Debian Codegraph @

templates/kirigami6/src/main.cpp

raw
1 /*
2 SPDX-License-Identifier: GPL-2.0-or-later
3 SPDX-FileCopyrightText: %{CURRENT_YEAR} %{AUTHOR} <%{EMAIL}>
4 */
5
6 #include <QtGlobal>
7 #ifdef Q_OS_ANDROID
8 #include <QGuiApplication>
9 #else
10 #include <QApplication>
11 #endif
12
13 #include <QIcon>
14 #include <QQmlApplicationEngine>
15 #include <QQmlContext>
16 #include <QQuickStyle>
17 #include <QUrl>
18
19 #include "app.h"
20 #include "version-%{APPNAMELC}.h"
21 #include <KAboutData>
22 #include <KLocalizedContext>
23 #include <KLocalizedString>
24
25 #include "%{APPNAMELC}config.h"
26
27 using namespace Qt::Literals::StringLiterals;
28
29 #ifdef Q_OS_ANDROID
30 Q_DECL_EXPORT
31 #endif
32 int main(int argc, char *argv[])
33 {
34 #ifdef Q_OS_ANDROID
35 QGuiApplication app(argc, argv);
36 QQuickStyle::setStyle(QStringLiteral("org.kde.breeze"));
37 #else
38 QApplication app(argc, argv);
39
40 // Default to org.kde.desktop style unless the user forces another style
41 if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) {
42 QQuickStyle::setStyle(u"org.kde.desktop"_s);
43 }
44 #endif
45
46 #ifdef Q_OS_WINDOWS
47 if (AttachConsole(ATTACH_PARENT_PROCESS)) {
48 freopen("CONOUT$", "w", stdout);
49 freopen("CONOUT$", "w", stderr);
50 }
51
52 QApplication::setStyle(QStringLiteral("breeze"));
53 auto font = app.font();
54 font.setPointSize(10);
55 app.setFont(font);
56 #endif
57
58 KLocalizedString::setApplicationDomain("%{APPNAMELC}");
59 QCoreApplication::setOrganizationName(u"KDE"_s);
60
61 KAboutData aboutData(
62 // The program name used internally.
63 u"%{APPNAMELC}"_s,
64 // A displayable program name string.
65 i18nc("@title", "%{APPNAME}"),
66 // The program version string.
67 QStringLiteral(%{APPNAMEUC}_VERSION_STRING),
68 // Short description of what the app does.
69 i18n("Application Description"),
70 // The license this code is released under.
71 KAboutLicense::GPL,
72 // Copyright Statement.
73 i18n("(c) %{CURRENT_YEAR}"));
74 aboutData.addAuthor(i18nc("@info:credit", "%{AUTHOR}"),
75 i18nc("@info:credit", "Maintainer"),
76 u"%{EMAIL}"_s,
77 u"https://yourwebsite.com"_s);
78 aboutData.setTranslator(i18nc("NAME OF TRANSLATORS", "Your names"), i18nc("EMAIL OF TRANSLATORS", "Your emails"));
79 KAboutData::setApplicationData(aboutData);
80 QGuiApplication::setWindowIcon(QIcon::fromTheme(u"org.kde.%{APPNAMELC}"_s));
81
82 QQmlApplicationEngine engine;
83
84 auto config = %{APPNAME}Config::self();
85
86 qmlRegisterSingletonInstance("org.kde.%{APPNAMELC}.private", 1, 0, "Config", config);
87
88 engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
89 engine.loadFromModule("org.kde.%{APPNAMELC}", u"Main");
90
91 if (engine.rootObjects().isEmpty()) {
92 return -1;
93 }
94
95 return app.exec();
96 }