Changeset View
Changeset View
Standalone View
Standalone View
krunner/main.cpp
Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | 61 | // QGuiApplication app(argc, argv); | |||
---|---|---|---|---|---|
80 | parser.addOption(replaceOption); | 80 | parser.addOption(replaceOption); | ||
81 | parser.addPositionalArgument(QStringLiteral("query"), i18n("The query to run, only used if -c is not provided")); | 81 | parser.addPositionalArgument(QStringLiteral("query"), i18n("The query to run, only used if -c is not provided")); | ||
82 | 82 | | |||
83 | aboutData.setupCommandLine(&parser); | 83 | aboutData.setupCommandLine(&parser); | ||
84 | 84 | | |||
85 | parser.process(app); | 85 | parser.process(app); | ||
86 | aboutData.processCommandLine(&parser); | 86 | aboutData.processCommandLine(&parser); | ||
87 | 87 | | |||
88 | if (parser.isSet(replaceOption)) { | | |||
89 | auto message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.krunner"), | | |||
90 | QStringLiteral("/MainApplication"), | | |||
91 | QStringLiteral("org.qtproject.Qt.QCoreApplication"), | | |||
92 | QStringLiteral("quit")); | | |||
93 | QDBusConnection::sessionBus().call(message); //deliberately block until it's done, so we register the name after the app quits | | |||
94 | } | | |||
95 | | ||||
96 | if (!KAuthorized::authorize(QStringLiteral("run_command"))) { | 88 | if (!KAuthorized::authorize(QStringLiteral("run_command"))) { | ||
97 | return -1; | 89 | return -1; | ||
98 | } | 90 | } | ||
99 | 91 | | |||
100 | KDBusService service(KDBusService::Unique); | 92 | KDBusService service(KDBusService::Unique | KDBusService::StartupOption(parser.isSet(replaceOption) ? KDBusService::Replace : 0)); | ||
101 | 93 | | |||
102 | QGuiApplication::setFallbackSessionManagementEnabled(false); | 94 | QGuiApplication::setFallbackSessionManagementEnabled(false); | ||
103 | 95 | | |||
104 | auto disableSessionManagement = [](QSessionManager &sm) { | 96 | auto disableSessionManagement = [](QSessionManager &sm) { | ||
105 | sm.setRestartHint(QSessionManager::RestartNever); | 97 | sm.setRestartHint(QSessionManager::RestartNever); | ||
106 | }; | 98 | }; | ||
107 | QObject::connect(&app, &QGuiApplication::commitDataRequest, disableSessionManagement); | 99 | QObject::connect(&app, &QGuiApplication::commitDataRequest, disableSessionManagement); | ||
108 | QObject::connect(&app, &QGuiApplication::saveStateRequest, disableSessionManagement); | 100 | QObject::connect(&app, &QGuiApplication::saveStateRequest, disableSessionManagement); | ||
Show All 27 Lines |