blob: 105e42e07bd3f011e6e226cefacf824325edc82c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore/QFile>
#include <QtCore/QStandardPaths>
#include <QtCore/QSettings>
#include <QtGui/QFont>
#include <QtGui/QIcon>
#include <QtGui/QFontDatabase>
#include <QtGui/QGuiApplication>
#include <QtQml/QQmlApplicationEngine>
#if defined(USE_STATIC_BUILD_FLAG)
#include <QtQml/QQmlEngineExtensionPlugin>
Q_IMPORT_QML_PLUGIN(QtLauncherPlugin)
Q_IMPORT_QML_PLUGIN(QtImageProvidersPlugin)
#endif
void displayHelp(const char *appName)
{
printf("Usage: \n"
" > %s [options]\n"
"\n"
"Options:\n"
" --applications-root [path] Specify a different applications root\n"
, appName
);
}
int main(int argc, char **argv)
{
QGuiApplication app(argc, argv);
QString appsRoot;
const QStringList args = app.arguments();
for (int i = 1; i < args.size(); ++i) {
const QString arg = args.at(i);
if (arg == QStringLiteral("--applications-root")) {
++i;
appsRoot = args.at(i);
} else if (arg == QStringLiteral("-h")
|| arg == QStringLiteral("--help")
|| arg == QStringLiteral("-?")) {
displayHelp(argv[0]);
return 0;
} else {
qCritical() << "Unknown command line argument:" << args.at(i);
displayHelp(argv[0]);
return 0;
}
}
if (appsRoot.isEmpty()) {
QSettings settings("Qt", "QtLauncher");
appsRoot = settings.value("defaultApplicationRoot").toString();
}
if (appsRoot.isEmpty()) {
appsRoot = "/usr/share/examples/boot2qt-launcher-demos";
}
qInfo() << "Applications Root:" << appsRoot;
QQmlApplicationEngine engine;
engine.setInitialProperties({{"appsRoot", appsRoot}});
engine.loadFromModule("QtLauncher", "Main");
return app.exec();
}
|