File indexing completed on 2024-04-28 09:46:21
0001 /* 0002 * SPDX-FileCopyrightText: 2021 Dimitris Kardarakos <dimkard@posteo.net> 0003 * 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 #include <QtGlobal> 0008 0009 #ifdef Q_OS_ANDROID 0010 #include <QGuiApplication> 0011 #else 0012 #include <QApplication> 0013 #endif 0014 0015 #include <QNetworkAccessManager> 0016 #include <QNetworkDiskCache> 0017 #include <QQmlApplicationEngine> 0018 #include <QUrl> 0019 #include <QQuickStyle> 0020 #include <QCommandLineParser> 0021 #include <QQmlContext> 0022 #include <QIcon> 0023 #include <QStandardPaths> 0024 #include <KLocalizedContext> 0025 #include <KLocalizedString> 0026 #include <KAboutData> 0027 #include "calendarcontroller.h" 0028 #include "localcalendar.h" 0029 #include "eventmodel.h" 0030 #include "eventcontroller.h" 0031 #include "conferencemodel.h" 0032 #include "conferencecontroller.h" 0033 #include "settingscontroller.h" 0034 #include "calendarcontroller.h" 0035 #include "conference.h" 0036 #include "version.h" 0037 0038 Q_DECL_EXPORT int main(int argc, char *argv[]) 0039 { 0040 #ifdef Q_OS_ANDROID 0041 QGuiApplication app {argc, argv}; 0042 QQuickStyle::setStyle(QStringLiteral("org.kde.breeze")); 0043 #else 0044 QApplication app {argc, argv}; 0045 // Default to org.kde.desktop style unless the user forces another style 0046 if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) { 0047 QQuickStyle::setStyle(QStringLiteral("org.kde.desktop")); 0048 } 0049 #endif 0050 KLocalizedString::setApplicationDomain("kongress"); 0051 0052 KAboutData about {QStringLiteral("kongress"), i18n("Kongress"), QStringLiteral(KONGRESS_VERSION_STRING), i18n("KDE Conference Companion"), KAboutLicense::GPL_V3, i18n("© 2021 KDE Community")}; 0053 about.setOrganizationDomain(QByteArray {"kde.org"}); 0054 about.setProductName(QByteArray {"kongress"}); 0055 about.addAuthor(i18nc("@info:credit", "Dimitris Kardarakos"), i18nc("@info:credit", "Maintainer and Developer"), QStringLiteral("dimkard@posteo.net")); 0056 about.setHomepage(QStringLiteral("https://invent.kde.org/utilities/kongress")); 0057 0058 KAboutData::setApplicationData(about); 0059 0060 QCommandLineParser parser; 0061 about.setupCommandLine(&parser); 0062 parser.process(app); 0063 about.processCommandLine(&parser); 0064 0065 QGuiApplication::setApplicationName(about.componentName()); 0066 QGuiApplication::setApplicationDisplayName(about.displayName()); 0067 QGuiApplication::setOrganizationDomain(about.organizationDomain()); 0068 QGuiApplication::setApplicationVersion(about.version()); 0069 QGuiApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("org.kde.kongress"))); 0070 0071 QNetworkAccessManager nam; 0072 nam.setRedirectPolicy(QNetworkRequest::NoLessSafeRedirectPolicy); 0073 nam.enableStrictTransportSecurityStore(true, QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QLatin1String("/hsts/")); 0074 nam.setStrictTransportSecurityEnabled(true); 0075 QNetworkDiskCache namDiskCache; 0076 namDiskCache.setCacheDirectory(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QLatin1String("/nam/")); 0077 nam.setCache(&namDiskCache); 0078 0079 qmlRegisterType<LocalCalendar>("org.kde.kongress", 0, 1, "LocalCalendar"); 0080 qmlRegisterType<EventModel>("org.kde.kongress", 0, 1, "EventModel"); 0081 qmlRegisterType<EventController>("org.kde.kongress", 0, 1, "EventController"); 0082 qmlRegisterType<ConferenceModel>("org.kde.kongress", 0, 1, "ConferenceModel"); 0083 qmlRegisterType<Conference>("org.kde.kongress", 0, 1, "Conference"); 0084 0085 qmlRegisterSingletonType<SettingsController>("org.kde.kongress", 0, 1, "SettingsController", &SettingsController::qmlInstance); 0086 0087 ConferenceController conferenceController; 0088 conferenceController.setNetworkAccessManager(&nam); 0089 qmlRegisterSingletonInstance<ConferenceController>("org.kde.kongress", 0, 1, "ConferenceController", &conferenceController); 0090 0091 CalendarController calendarController; 0092 calendarController.setNetworkAccessManager(&nam); 0093 qmlRegisterSingletonInstance<CalendarController>("org.kde.kongress", 0, 1, "CalendarController", &calendarController); 0094 0095 EventController eventController; 0096 eventController.setCalendarController(&calendarController); 0097 qmlRegisterSingletonInstance<EventController>("org.kde.kongress", 0, 1, "EventController", &eventController); 0098 0099 QQmlApplicationEngine engine; 0100 engine.rootContext()->setContextObject(new KLocalizedContext {&engine}); 0101 engine.rootContext()->setContextProperty(QStringLiteral("_about"), QVariant::fromValue(about)); 0102 engine.load(QUrl {QStringLiteral("qrc:///Main.qml")}); 0103 0104 if (engine.rootObjects().isEmpty()) { 0105 return -1; 0106 } 0107 0108 int ret = app.exec(); 0109 return ret; 0110 }