mirror of
https://github.com/QuasarApp/QtDeployer.git
synced 2025-04-26 21:44:31 +00:00
fix main
This commit is contained in:
parent
a08350c1ef
commit
af77667f10
@ -3,6 +3,9 @@
|
||||
#include <QQmlContext>
|
||||
#include <QIcon>
|
||||
#include <QTranslator>
|
||||
#include <QFont>
|
||||
#include <QFontDatabase>
|
||||
#include <iostream>
|
||||
|
||||
#include "CPP/cppmanager.h"
|
||||
#include "CPP/mainmanager.h"
|
||||
@ -10,28 +13,47 @@
|
||||
#include "CPP/pluginmanager.h"
|
||||
#include "CPP/qmlmanager.h"
|
||||
|
||||
bool loadTr(QGuiApplication &app){
|
||||
QTranslator translator;
|
||||
void setFont(const QGuiApplication& app){
|
||||
|
||||
QString fontPath = "://ubuntu";
|
||||
int fontId = QFontDatabase::addApplicationFont(fontPath);
|
||||
if (fontId != -1)
|
||||
{
|
||||
QFont font(QFontDatabase::applicationFontFamilies(fontId).at(0));
|
||||
app.setFont(font);
|
||||
}
|
||||
}
|
||||
|
||||
bool initLocale(const QString &locale, QGuiApplication& app, QTranslator &translator){
|
||||
|
||||
QString defaultLocale = QLocale::system().name();
|
||||
defaultLocale.truncate(defaultLocale.lastIndexOf('_'));
|
||||
|
||||
if(!locale.isEmpty() && translator.load(QString(":/languages/%0").arg(locale))){
|
||||
return app.installTranslator(&translator);
|
||||
}
|
||||
|
||||
if(!translator.load(QString(":/languages/%0").arg(defaultLocale))){
|
||||
return false;
|
||||
}
|
||||
app.installTranslator(&translator);
|
||||
|
||||
return true;
|
||||
|
||||
return app.installTranslator(&translator);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QGuiApplication app(argc, argv);
|
||||
setFont(app);
|
||||
|
||||
QTranslator translator;
|
||||
|
||||
QString locale = "";
|
||||
|
||||
app.setWindowIcon(QIcon("://icon"));
|
||||
|
||||
loadTr(app);
|
||||
if(!initLocale(locale, app, translator)){
|
||||
std::cout << "error load language : " << locale.toStdString() <<std::endl;
|
||||
}
|
||||
|
||||
CppManager C;
|
||||
QmlManager Q;
|
||||
|
@ -12,6 +12,7 @@
|
||||
<file alias="icon">res/icon.png</file>
|
||||
<file>QML/Header.qml</file>
|
||||
<file>QML/About.qml</file>
|
||||
<file alias="ubuntu">res/ubuntu.ttf</file>
|
||||
</qresource>
|
||||
<qresource prefix="/languages">
|
||||
<file alias="en">languages/en.qm</file>
|
||||
|
BIN
source/res/ubuntu.ttf
Normal file
BIN
source/res/ubuntu.ttf
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user