2022-05-10 20:10:34 +00:00
|
|
|
#include <QGuiApplication>
|
|
|
|
#include <QQmlApplicationEngine>
|
|
|
|
|
|
|
|
#include <QLocale>
|
|
|
|
#include <QTranslator>
|
|
|
|
|
|
|
|
#include <Helpers/helpers.h>
|
|
|
|
#include <Helpers/logs.h>
|
|
|
|
|
|
|
|
#include <QDir>
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
using namespace Status;
|
|
|
|
|
|
|
|
void setApplicationInformation(QGuiApplication& app);
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
//qInstallMessageHandler(Helpers::logFormatter);
|
|
|
|
|
|
|
|
QGuiApplication app(argc, argv);
|
|
|
|
|
|
|
|
setApplicationInformation(app);
|
2022-07-04 21:14:13 +00:00
|
|
|
|
2022-05-10 20:10:34 +00:00
|
|
|
QTranslator translator;
|
|
|
|
const QStringList uiLanguages = QLocale::system().uiLanguages();
|
|
|
|
for (const QString &locale : uiLanguages) {
|
2022-06-30 17:24:31 +00:00
|
|
|
const QString baseName = BUILD_PROJECT_NAME + QLocale(locale).name();
|
2022-05-10 20:10:34 +00:00
|
|
|
if (translator.load(":/i18n/" + baseName)) {
|
|
|
|
app.installTranslator(&translator);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QQmlApplicationEngine engine;
|
|
|
|
|
|
|
|
const QUrl url(u"qrc:/Status/Application/qml/main.qml"_qs);
|
|
|
|
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
|
|
|
&app, [url](QObject *obj, const QUrl &objUrl) {
|
|
|
|
if (!obj && url == objUrl)
|
|
|
|
QCoreApplication::exit(-1);
|
|
|
|
}, Qt::QueuedConnection);
|
|
|
|
engine.load(url);
|
|
|
|
|
|
|
|
return app.exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setApplicationInformation(QGuiApplication& app) {
|
|
|
|
#if !defined BUILD_PROJECT_ORGANIZATION_NAME
|
|
|
|
static_assert(false, "Compile-time define missing: BUILD_PROJECT_ORGANIZATION_NAME")
|
|
|
|
#endif
|
2022-06-30 17:24:31 +00:00
|
|
|
app.setOrganizationName(BUILD_PROJECT_ORGANIZATION_NAME);
|
2022-05-10 20:10:34 +00:00
|
|
|
#if !defined BUILD_PROJECT_ORGANIZATION_DOMAIN
|
|
|
|
static_assert(false, "Compile-time define missing: BUILD_PROJECT_ORGANIZATION_DOMAIN")
|
|
|
|
#endif
|
2022-06-30 17:24:31 +00:00
|
|
|
app.setOrganizationDomain(BUILD_PROJECT_ORGANIZATION_DOMAIN);
|
2022-05-10 20:10:34 +00:00
|
|
|
#if !defined BUILD_PROJECT_APPLICATION_NAME
|
|
|
|
static_assert(false, "Compile-time define missing: BUILD_PROJECT_APPLICATION_NAME")
|
|
|
|
#endif
|
2022-06-30 17:24:31 +00:00
|
|
|
app.setApplicationName(BUILD_PROJECT_APPLICATION_NAME);
|
2022-05-10 20:10:34 +00:00
|
|
|
}
|