2018-01-20 17:44:28 +03:00
|
|
|
#include <QApplication>
|
2018-05-13 23:11:35 +03:00
|
|
|
#include <QFont>
|
|
|
|
#include <QFontDatabase>
|
2018-05-12 17:24:40 +03:00
|
|
|
#include <iostream>
|
2018-01-20 17:44:28 +03:00
|
|
|
//#include <QScreen>
|
|
|
|
#include <QQmlApplicationEngine>
|
|
|
|
#include <QQmlComponent>
|
2018-04-11 20:27:22 +03:00
|
|
|
#include "backEnd.h"
|
2018-04-11 23:10:52 +03:00
|
|
|
#include <QTranslator>
|
2018-05-13 23:11:35 +03:00
|
|
|
|
|
|
|
void setFont(const QApplication& app){
|
|
|
|
|
|
|
|
QString fontPath = "://ubuntu";
|
|
|
|
int fontId = QFontDatabase::addApplicationFont(fontPath);
|
|
|
|
if (fontId != -1)
|
|
|
|
{
|
|
|
|
QFont font(QFontDatabase::applicationFontFamilies(fontId).at(0));
|
|
|
|
app.setFont(font);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-12 17:24:40 +03:00
|
|
|
bool initLocale(const QString &locale, QApplication& 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
return app.installTranslator(&translator);
|
|
|
|
}
|
|
|
|
|
2018-01-20 17:44:28 +03:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2018-07-15 12:18:30 +03:00
|
|
|
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // <--
|
|
|
|
|
2018-01-20 17:44:28 +03:00
|
|
|
QApplication app(argc, argv);
|
2018-05-13 23:11:35 +03:00
|
|
|
setFont(app);
|
|
|
|
|
2018-04-11 23:10:52 +03:00
|
|
|
QTranslator translator;
|
|
|
|
|
2018-05-12 17:24:40 +03:00
|
|
|
QString locale = "";
|
|
|
|
|
|
|
|
if(argc > 1) {
|
|
|
|
locale = QString::fromLatin1(argv[1]);
|
|
|
|
}
|
2018-04-11 23:10:52 +03:00
|
|
|
|
2018-05-12 17:24:40 +03:00
|
|
|
if(!initLocale(locale, app, translator)){
|
|
|
|
std::cout << "error load language : " << locale.toStdString() <<std::endl;
|
|
|
|
}
|
2018-04-11 23:10:52 +03:00
|
|
|
|
2018-01-20 17:44:28 +03:00
|
|
|
QQmlApplicationEngine engine;
|
2018-04-11 20:27:22 +03:00
|
|
|
qmlRegisterType<BackEnd>("BackEnd",1,0,"BackEnd");
|
2018-01-20 17:44:28 +03:00
|
|
|
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
|
|
|
|
|
|
|
|
return app.exec();
|
|
|
|
}
|