2015-05-12 14:21:38 +02:00
|
|
|
%{Cpp:LicenseTemplate}\
|
2015-08-22 19:16:53 +09:00
|
|
|
%{JS: QtSupport.qtIncludes([], ["QtGui/QGuiApplication", "QtQml/QQmlApplicationEngine"])}
|
2021-01-11 16:50:34 +01:00
|
|
|
@if %{HasTranslation}
|
|
|
|
|
#include <QLocale>
|
|
|
|
|
#include <QTranslator>
|
|
|
|
|
@endif
|
|
|
|
|
|
2013-11-19 17:00:38 +01:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
|
{
|
2016-08-10 14:13:43 +02:00
|
|
|
@if %{UseVirtualKeyboard}
|
|
|
|
|
qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
|
|
|
|
|
|
|
|
|
|
@endif
|
2021-09-03 15:37:44 +02:00
|
|
|
@if !%{IsQt6}
|
2017-12-01 15:26:27 +01:00
|
|
|
@if %{SetQPAPhysicalSize}
|
|
|
|
|
if (qEnvironmentVariableIsEmpty("QTGLESSTREAM_DISPLAY")) {
|
|
|
|
|
qputenv("QT_QPA_EGLFS_PHYSICAL_WIDTH", QByteArray("213"));
|
|
|
|
|
qputenv("QT_QPA_EGLFS_PHYSICAL_HEIGHT", QByteArray("120"));
|
|
|
|
|
|
2020-11-27 12:09:47 +01:00
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
2017-12-01 15:26:27 +01:00
|
|
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
2020-11-27 12:09:47 +01:00
|
|
|
#endif
|
2017-12-01 15:26:27 +01:00
|
|
|
}
|
|
|
|
|
@else
|
2020-11-27 12:09:47 +01:00
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
2017-08-01 15:37:05 +02:00
|
|
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
2020-11-27 12:09:47 +01:00
|
|
|
#endif
|
2017-12-01 15:26:27 +01:00
|
|
|
@endif
|
2021-09-03 15:37:44 +02:00
|
|
|
@endif
|
2013-11-19 17:00:38 +01:00
|
|
|
QGuiApplication app(argc, argv);
|
2021-01-11 16:50:34 +01:00
|
|
|
@if %{HasTranslation}
|
|
|
|
|
|
|
|
|
|
QTranslator translator;
|
|
|
|
|
const QStringList uiLanguages = QLocale::system().uiLanguages();
|
|
|
|
|
for (const QString &locale : uiLanguages) {
|
|
|
|
|
const QString baseName = "%{JS: value('ProjectName') + '_'}" + QLocale(locale).name();
|
|
|
|
|
if (translator.load(":/i18n/" + baseName)) {
|
|
|
|
|
app.installTranslator(&translator);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@endif
|
2013-11-19 17:00:38 +01:00
|
|
|
|
2014-01-29 15:43:04 +01:00
|
|
|
QQmlApplicationEngine engine;
|
2021-09-03 15:37:44 +02:00
|
|
|
@if %{IsQt6}
|
|
|
|
|
const QUrl url(u"qrc:/%{JS: value('ProjectName')}/main.qml"_qs);
|
|
|
|
|
@else
|
2019-01-15 13:13:45 +01:00
|
|
|
const QUrl url(QStringLiteral("qrc:/main.qml"));
|
2021-09-03 15:37:44 +02:00
|
|
|
@endif
|
2019-01-15 13:13:45 +01:00
|
|
|
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
|
|
|
|
&app, [url](QObject *obj, const QUrl &objUrl) {
|
|
|
|
|
if (!obj && url == objUrl)
|
|
|
|
|
QCoreApplication::exit(-1);
|
|
|
|
|
}, Qt::QueuedConnection);
|
|
|
|
|
engine.load(url);
|
2013-11-19 17:00:38 +01:00
|
|
|
|
|
|
|
|
return app.exec();
|
|
|
|
|
}
|