diff options
author | rtk0c <[email protected]> | 2022-07-01 18:12:31 +0000 |
---|---|---|
committer | rtk0c <[email protected]> | 2022-07-01 18:12:31 +0000 |
commit | b992ae0fa4d792002ffae10a9ef893ef4fa42ac4 (patch) | |
tree | b3bfd176df672eefd9a6a627bfeddd03f22cf458 /ui.qt/src/main.cpp | |
parent | fa744c91b0b15d5978e915816e712e388ead7e64 (diff) |
Convert hardcoding files in CMakeLists.txt to file(GLOB)
git-svn-id: file:///home/arch/svn/epistmool/trunk@8 71f44415-077c-4ad7-a976-72ddbf76608f
Diffstat (limited to 'ui.qt/src/main.cpp')
-rw-r--r-- | ui.qt/src/main.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/ui.qt/src/main.cpp b/ui.qt/src/main.cpp new file mode 100644 index 0000000..e8af4aa --- /dev/null +++ b/ui.qt/src/main.cpp @@ -0,0 +1,35 @@ +#include <QApplication> +#include <QLocale> +#include <QQmlApplicationEngine> +#include <QTranslator> + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QTranslator translator; + QStringList uiLanguages = QLocale::system().uiLanguages(); + for (const QString& locale : uiLanguages) { + const QString baseName = "EpistmoolUI_" + QLocale(locale).name(); + if (translator.load(":/i18n/" + baseName)) { + app.installTranslator(&translator); + break; + } + } + + QQmlApplicationEngine engine; + QUrl url(u"qrc:/EpistmoolUI/qml/MainWindow.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(); +} |