2018-06-03 15:37:16 +03:00
|
|
|
#include <QtGlobal>
|
|
|
|
|
2018-06-10 14:44:36 +03:00
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
|
2018-06-02 15:55:53 +03:00
|
|
|
#include <QGuiApplication>
|
|
|
|
#include <QQmlApplicationEngine>
|
|
|
|
#include <QQmlContext>
|
|
|
|
#else
|
|
|
|
#include <QApplication>
|
|
|
|
#include "mainwindow.h"
|
|
|
|
#endif
|
|
|
|
|
2018-05-10 14:04:01 +03:00
|
|
|
#include <QIcon>
|
2018-05-10 14:24:56 +03:00
|
|
|
#include <QTranslator>
|
2018-03-12 11:43:03 +03:30
|
|
|
|
2018-05-07 19:33:05 +03:00
|
|
|
#include "CPP/cppmanager.h"
|
|
|
|
#include "CPP/mainmanager.h"
|
|
|
|
#include "CPP/outputmanager.h"
|
|
|
|
#include "CPP/pluginmanager.h"
|
|
|
|
#include "CPP/qmlmanager.h"
|
2018-05-26 16:48:58 +03:00
|
|
|
#include "CPP/buildmanager.h"
|
2018-06-03 15:37:16 +03:00
|
|
|
#include <iostream>
|
2018-05-26 16:48:58 +03:00
|
|
|
|
2018-03-12 11:43:03 +03:30
|
|
|
|
2018-06-02 15:55:53 +03:00
|
|
|
|
2018-06-03 15:37:16 +03:00
|
|
|
bool initLocale(const QString &locale, QGuiApplication& app, QTranslator &translator){
|
2018-05-10 14:24:56 +03:00
|
|
|
|
|
|
|
QString defaultLocale = QLocale::system().name();
|
|
|
|
defaultLocale.truncate(defaultLocale.lastIndexOf('_'));
|
|
|
|
|
2018-06-03 15:37:16 +03:00
|
|
|
if(!locale.isEmpty() && translator.load(QString(":/languages/%0").arg(locale))){
|
|
|
|
return app.installTranslator(&translator);
|
|
|
|
}
|
|
|
|
|
2018-05-10 14:24:56 +03:00
|
|
|
if(!translator.load(QString(":/languages/%0").arg(defaultLocale))){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-06-03 15:37:16 +03:00
|
|
|
return app.installTranslator(&translator);
|
2018-05-10 14:24:56 +03:00
|
|
|
}
|
|
|
|
|
2018-03-12 11:43:03 +03:30
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2018-06-24 19:30:56 +03:00
|
|
|
QGuiApplication *app;
|
2018-06-02 15:55:53 +03:00
|
|
|
|
|
|
|
|
2018-06-10 14:44:36 +03:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
|
2018-06-02 15:55:53 +03:00
|
|
|
app = new QGuiApplication(argc, argv);
|
|
|
|
#else
|
|
|
|
app = new QApplication(argc, argv);
|
2018-03-12 11:43:03 +03:30
|
|
|
|
2018-06-02 15:55:53 +03:00
|
|
|
#endif
|
|
|
|
|
2018-06-24 19:30:56 +03:00
|
|
|
QCoreApplication::setOrganizationName("QuasarApp");
|
|
|
|
QCoreApplication::setOrganizationDomain("https://quasarapp.github.io/QtDeployer/");
|
|
|
|
QCoreApplication::setApplicationName("Qt-Deployer");
|
2018-06-02 15:55:53 +03:00
|
|
|
|
|
|
|
app->setWindowIcon(QIcon("://icon"));
|
2018-05-10 14:04:01 +03:00
|
|
|
|
2018-06-03 15:37:16 +03:00
|
|
|
QTranslator translator;
|
|
|
|
|
|
|
|
QString locale = "";
|
|
|
|
|
|
|
|
if(argc > 1) {
|
|
|
|
locale = QString::fromLatin1(argv[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!initLocale(locale, *app, translator)){
|
|
|
|
std::cout << "error load language : " << locale.toStdString() <<std::endl;
|
|
|
|
}
|
2018-05-10 14:24:56 +03:00
|
|
|
|
2018-05-10 12:36:59 +03:00
|
|
|
CppManager C;
|
|
|
|
QmlManager Q;
|
|
|
|
PluginManager P;
|
|
|
|
OutputManager O;
|
2018-05-26 16:48:58 +03:00
|
|
|
BuildManager B;
|
|
|
|
|
2018-05-07 19:33:05 +03:00
|
|
|
|
2018-05-26 16:48:58 +03:00
|
|
|
MainManager M(&C, &Q, &O, &P, &B);
|
2018-03-12 11:43:03 +03:30
|
|
|
|
2018-06-10 14:44:36 +03:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
|
2018-05-10 12:36:59 +03:00
|
|
|
QQmlApplicationEngine engine;
|
2018-03-12 11:43:03 +03:30
|
|
|
|
2018-05-10 12:36:59 +03:00
|
|
|
auto *R = engine.rootContext();
|
|
|
|
R->setContextProperty("CppManager", &C);
|
|
|
|
R->setContextProperty("QmlManager", &Q);
|
|
|
|
R->setContextProperty("PluginManager", &P);
|
|
|
|
R->setContextProperty("MainManager", &M);
|
|
|
|
R->setContextProperty("OutputManager", &O);
|
2018-05-26 16:48:58 +03:00
|
|
|
R->setContextProperty("BuildManager", &B);
|
|
|
|
|
2018-05-07 19:33:05 +03:00
|
|
|
|
2018-03-12 11:43:03 +03:30
|
|
|
|
2018-05-10 12:36:59 +03:00
|
|
|
engine.load(QUrl(QLatin1String("qrc:/QML/main.qml")));
|
|
|
|
if (engine.rootObjects().isEmpty()) return -1;
|
2018-06-02 15:55:53 +03:00
|
|
|
#else
|
|
|
|
MainWindow mainApp(&M);
|
|
|
|
mainApp.show();
|
|
|
|
#endif
|
|
|
|
|
2018-06-17 19:50:55 +03:00
|
|
|
return app->exec();
|
2018-03-12 11:43:03 +03:30
|
|
|
|
|
|
|
}
|