Changeset View
Changeset View
Standalone View
Standalone View
src/main.cpp
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | |||||
51 | #include <QQmlApplicationEngine> | 51 | #include <QQmlApplicationEngine> | ||
52 | #include <QQmlEngine> | 52 | #include <QQmlEngine> | ||
53 | #include <QQmlFileSelector> | 53 | #include <QQmlFileSelector> | ||
54 | #include <QQmlDebuggingEnabler> | 54 | #include <QQmlDebuggingEnabler> | ||
55 | #include <QQmlContext> | 55 | #include <QQmlContext> | ||
56 | #include <QQuickStyle> | 56 | #include <QQuickStyle> | ||
57 | #include <QScreen> | 57 | #include <QScreen> | ||
58 | 58 | | |||
59 | #if defined Qt5AndroidExtras_FOUND && Qt5AndroidExtras_FOUND | ||||
60 | #include <QAndroidService> | ||||
61 | #endif | ||||
62 | | ||||
59 | #include <memory> | 63 | #include <memory> | ||
60 | 64 | | |||
61 | #if defined Qt5AndroidExtras_FOUND && Qt5AndroidExtras_FOUND | 65 | #if defined Qt5AndroidExtras_FOUND && Qt5AndroidExtras_FOUND | ||
62 | #include <QAndroidJniObject> | 66 | #include <QAndroidJniObject> | ||
63 | #include <QtAndroid> | 67 | #include <QtAndroid> | ||
64 | #endif | 68 | #endif | ||
65 | 69 | | |||
66 | #if defined Q_OS_ANDROID | 70 | #if defined Q_OS_ANDROID | ||
67 | int __attribute__((visibility("default"))) main(int argc, char *argv[]) | 71 | int __attribute__((visibility("default"))) main(int argc, char *argv[]) | ||
68 | #else | 72 | #else | ||
69 | int main(int argc, char *argv[]) | 73 | int main(int argc, char *argv[]) | ||
70 | #endif | 74 | #endif | ||
71 | { | 75 | { | ||
76 | #if defined Q_OS_ANDROID | ||||
77 | if(argc > 1 && strcmp(argv[1], "-service") == 0){ | ||||
78 | QAndroidService app(argc, argv); | ||||
79 | qInfo() << "Service starting..."; | ||||
80 | | ||||
81 | // My service stuff | ||||
82 | | ||||
83 | return app.exec(); | ||||
84 | } | ||||
85 | | ||||
86 | qInfo() << "Application starting..."; | ||||
87 | #endif | ||||
88 | | ||||
72 | QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); | 89 | QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); | ||
73 | 90 | | |||
74 | qputenv("QT_GSTREAMER_USE_PLAYBIN_VOLUME", "true"); | 91 | qputenv("QT_GSTREAMER_USE_PLAYBIN_VOLUME", "true"); | ||
75 | 92 | | |||
76 | QApplication app(argc, argv); | 93 | QApplication app(argc, argv); | ||
77 | 94 | | |||
95 | #if defined Qt5AndroidExtras_FOUND && Qt5AndroidExtras_FOUND | ||||
96 | qInfo() << QCoreApplication::arguments(); | ||||
97 | | ||||
98 | QAndroidJniObject::callStaticMethod<void>("org/kde/elisa/ElisaService", | ||||
99 | "startMyService", | ||||
100 | "(Landroid/content/Context;)V", | ||||
101 | QtAndroid::androidContext().object()); | ||||
102 | #endif | ||||
103 | | ||||
78 | #if defined KF5Crash_FOUND && KF5Crash_FOUND | 104 | #if defined KF5Crash_FOUND && KF5Crash_FOUND | ||
79 | KCrash::initialize(); | 105 | KCrash::initialize(); | ||
80 | #endif | 106 | #endif | ||
81 | 107 | | |||
82 | QApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("elisa"))); | 108 | QApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("elisa"))); | ||
83 | 109 | | |||
84 | KLocalizedString::setApplicationDomain("elisa"); | 110 | KLocalizedString::setApplicationDomain("elisa"); | ||
85 | 111 | | |||
Show All 18 Lines | |||||
104 | 130 | | |||
105 | QCommandLineParser parser; | 131 | QCommandLineParser parser; | ||
106 | parser.addHelpOption(); | 132 | parser.addHelpOption(); | ||
107 | parser.addVersionOption(); | 133 | parser.addVersionOption(); | ||
108 | aboutData.setupCommandLine(&parser); | 134 | aboutData.setupCommandLine(&parser); | ||
109 | parser.process(app); | 135 | parser.process(app); | ||
110 | aboutData.processCommandLine(&parser); | 136 | aboutData.processCommandLine(&parser); | ||
111 | 137 | | |||
112 | #if defined Qt5AndroidExtras_FOUND && Qt5AndroidExtras_FOUND | | |||
113 | qDebug() << QCoreApplication::arguments(); | | |||
114 | | ||||
115 | QAndroidJniObject::callStaticMethod<void>("com/kde/elisa/ElisaService", | | |||
116 | "startMyService", | | |||
117 | "(Landroid/content/Context;)V", | | |||
118 | QtAndroid::androidContext().object()); | | |||
119 | #endif | | |||
120 | | ||||
121 | QQuickStyle::setStyle(QStringLiteral("org.kde.desktop")); | 138 | QQuickStyle::setStyle(QStringLiteral("org.kde.desktop")); | ||
122 | QQuickStyle::setFallbackStyle(QStringLiteral("Fusion")); | 139 | QQuickStyle::setFallbackStyle(QStringLiteral("Fusion")); | ||
123 | 140 | | |||
124 | QQmlApplicationEngine engine; | 141 | QQmlApplicationEngine engine; | ||
125 | engine.addImportPath(QStringLiteral("qrc:/imports")); | 142 | engine.addImportPath(QStringLiteral("qrc:/imports")); | ||
126 | QQmlFileSelector selector(&engine); | 143 | QQmlFileSelector selector(&engine); | ||
127 | 144 | | |||
128 | #if defined KF5Declarative_FOUND && KF5Declarative_FOUND | 145 | #if defined KF5Declarative_FOUND && KF5Declarative_FOUND | ||
Show All 36 Lines |