Changeset View
Changeset View
Standalone View
Standalone View
krunner/main.cpp
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 42 | { | |||
---|---|---|---|---|---|
47 | 47 | | |||
48 | QQuickWindow::setDefaultAlphaBuffer(true); | 48 | QQuickWindow::setDefaultAlphaBuffer(true); | ||
49 | QApplication app(argc, argv); | 49 | QApplication app(argc, argv); | ||
50 | 50 | | |||
51 | KQuickAddons::QtQuickSettings::init(); | 51 | KQuickAddons::QtQuickSettings::init(); | ||
52 | 52 | | |||
53 | // TODO: Make it a QGuiApplication once we don't depend on KDELibs4Support | 53 | // TODO: Make it a QGuiApplication once we don't depend on KDELibs4Support | ||
54 | // QGuiApplication app(argc, argv); | 54 | // QGuiApplication app(argc, argv); | ||
55 | app.setApplicationName(QStringLiteral("krunner")); | 55 | | ||
56 | app.setOrganizationDomain(QStringLiteral("kde.org")); | 56 | KAboutData aboutData(QStringLiteral("krunner"), | ||
57 | app.setApplicationVersion(QStringLiteral(PROJECT_VERSION)); | 57 | i18n("krunner"), | ||
58 | QStringLiteral(PROJECT_VERSION), | ||||
59 | i18n("Run Command interface"), | ||||
60 | KAboutLicense::GPL); | ||||
61 | | ||||
62 | KAboutData::setApplicationData(aboutData); | ||||
58 | app.setQuitOnLastWindowClosed(false); | 63 | app.setQuitOnLastWindowClosed(false); | ||
59 | parser.setApplicationDescription(i18n("Run Command interface")); | | |||
60 | 64 | | |||
65 | aboutData.setupCommandLine(&parser); | ||||
61 | parser.addHelpOption(); | 66 | parser.addHelpOption(); | ||
62 | parser.addVersionOption(); | 67 | parser.addVersionOption(); | ||
68 | | ||||
63 | parser.process(app); | 69 | parser.process(app); | ||
70 | aboutData.processCommandLine(&parser); | ||||
64 | 71 | | |||
65 | if (!KAuthorized::authorize(QStringLiteral("run_command"))) { | 72 | if (!KAuthorized::authorize(QStringLiteral("run_command"))) { | ||
66 | return -1; | 73 | return -1; | ||
67 | } | 74 | } | ||
68 | 75 | | |||
69 | KDBusService service(KDBusService::Unique); | 76 | KDBusService service(KDBusService::Unique); | ||
70 | 77 | | |||
71 | KAboutData aboutData(QStringLiteral("krunner"), | | |||
72 | i18n("krunner"), | | |||
73 | QStringLiteral(PROJECT_VERSION), | | |||
74 | i18n("Run Command interface"), | | |||
75 | KAboutLicense::GPL); | | |||
76 | | ||||
77 | KAboutData::setApplicationData(aboutData); | | |||
78 | | ||||
79 | QGuiApplication::setFallbackSessionManagementEnabled(false); | 78 | QGuiApplication::setFallbackSessionManagementEnabled(false); | ||
80 | 79 | | |||
81 | auto disableSessionManagement = [](QSessionManager &sm) { | 80 | auto disableSessionManagement = [](QSessionManager &sm) { | ||
82 | sm.setRestartHint(QSessionManager::RestartNever); | 81 | sm.setRestartHint(QSessionManager::RestartNever); | ||
83 | }; | 82 | }; | ||
84 | QObject::connect(&app, &QGuiApplication::commitDataRequest, disableSessionManagement); | 83 | QObject::connect(&app, &QGuiApplication::commitDataRequest, disableSessionManagement); | ||
85 | QObject::connect(&app, &QGuiApplication::saveStateRequest, disableSessionManagement); | 84 | QObject::connect(&app, &QGuiApplication::saveStateRequest, disableSessionManagement); | ||
86 | 85 | | |||
87 | View view; | 86 | View view; | ||
88 | view.setVisible(false); | 87 | view.setVisible(false); | ||
89 | 88 | | |||
90 | QObject::connect(&service, &KDBusService::activateRequested, &view, &View::display); | 89 | QObject::connect(&service, &KDBusService::activateRequested, &view, &View::display); | ||
91 | 90 | | |||
92 | return app.exec(); | 91 | return app.exec(); | ||
93 | } | 92 | } |