Changeset View
Changeset View
Standalone View
Standalone View
daemon/powerdevilapp.cpp
Show First 20 Lines • Show All 197 Lines • ▼ Show 20 Line(s) | 166 | { | |||
---|---|---|---|---|---|
198 | } | 198 | } | ||
199 | configGroup.writeEntry(QStringLiteral("kdedShortcutMigration"), true); | 199 | configGroup.writeEntry(QStringLiteral("kdedShortcutMigration"), true); | ||
200 | configGroup.sync(); | 200 | configGroup.sync(); | ||
201 | } | 201 | } | ||
202 | 202 | | |||
203 | int main(int argc, char **argv) | 203 | int main(int argc, char **argv) | ||
204 | { | 204 | { | ||
205 | QGuiApplication::setDesktopSettingsAware(false); | 205 | QGuiApplication::setDesktopSettingsAware(false); | ||
206 | QGuiApplication::setAttribute(Qt::AA_DisableSessionManager); | ||||
206 | KWorkSpace::detectPlatform(argc, argv); | 207 | KWorkSpace::detectPlatform(argc, argv); | ||
207 | PowerDevilApp app(argc, argv); | 208 | PowerDevilApp app(argc, argv); | ||
208 | 209 | | |||
209 | auto disableSessionManagement = [](QSessionManager &sm) { | 210 | bool replace = false; | ||
210 | sm.setRestartHint(QSessionManager::RestartNever); | 211 | { | ||
211 | }; | 212 | QCommandLineParser parser; | ||
212 | QObject::connect(&app, &QGuiApplication::commitDataRequest, disableSessionManagement); | 213 | QCommandLineOption replaceOption({QStringLiteral("replace")}, i18n("Replace an existing instance")); | ||
213 | QObject::connect(&app, &QGuiApplication::saveStateRequest, disableSessionManagement); | 214 | | ||
215 | parser.addOption(replaceOption); | ||||
216 | | ||||
217 | KAboutData aboutData = KAboutData::applicationData(); | ||||
218 | aboutData.setupCommandLine(&parser); | ||||
214 | 219 | | |||
215 | KDBusService service(KDBusService::Unique); | 220 | parser.process(app); | ||
221 | aboutData.processCommandLine(&parser); | ||||
222 | | ||||
223 | replace = parser.isSet(replaceOption); | ||||
224 | } | ||||
225 | KDBusService service(KDBusService::Unique | KDBusService::StartupOption(replace ? KDBusService::Replace : 0)); | ||||
216 | KCrash::setFlags(KCrash::AutoRestart); | 226 | KCrash::setFlags(KCrash::AutoRestart); | ||
217 | 227 | | |||
218 | app.setQuitOnLastWindowClosed(false); | 228 | app.setQuitOnLastWindowClosed(false); | ||
219 | app.init(); | 229 | app.init(); | ||
220 | 230 | | |||
221 | return app.exec(); | 231 | return app.exec(); | ||
222 | } | 232 | } |