Changeset View
Changeset View
Standalone View
Standalone View
krunner/main.cpp
Show All 18 Lines | |||||
19 | #include <QApplication> | 19 | #include <QApplication> | ||
20 | #include <KLocalizedString> | 20 | #include <KLocalizedString> | ||
21 | 21 | | |||
22 | #include <QCommandLineParser> | 22 | #include <QCommandLineParser> | ||
23 | #include <QAction> | 23 | #include <QAction> | ||
24 | #include <QUrl> | 24 | #include <QUrl> | ||
25 | #include <QDebug> | 25 | #include <QDebug> | ||
26 | #include <QQuickWindow> | 26 | #include <QQuickWindow> | ||
27 | #include <QSessionManager> | | |||
28 | #include <QDBusMessage> | 27 | #include <QDBusMessage> | ||
29 | #include <QDBusConnection> | 28 | #include <QDBusConnection> | ||
30 | 29 | | |||
31 | #include <KAuthorized> | 30 | #include <KAuthorized> | ||
32 | #include <KAboutData> | 31 | #include <KAboutData> | ||
33 | #include <KDBusService> | 32 | #include <KDBusService> | ||
34 | 33 | | |||
35 | #include <kdeclarative/qmlobject.h> | 34 | #include <kdeclarative/qmlobject.h> | ||
36 | #include <KQuickAddons/QtQuickSettings> | 35 | #include <KQuickAddons/QtQuickSettings> | ||
37 | 36 | | |||
38 | #include <kworkspace.h> | 37 | #include <kworkspace.h> | ||
39 | 38 | | |||
40 | #include "view.h" | 39 | #include "view.h" | ||
41 | 40 | | |||
42 | int main(int argc, char **argv) | 41 | int main(int argc, char **argv) | ||
43 | { | 42 | { | ||
44 | qunsetenv("QT_DEVICE_PIXEL_RATIO"); | 43 | qunsetenv("QT_DEVICE_PIXEL_RATIO"); | ||
45 | QCommandLineParser parser; | 44 | QCommandLineParser parser; | ||
46 | QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); | 45 | QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); | ||
46 | QCoreApplication::setAttribute(Qt::AA_DisableSessionManager); | ||||
47 | 47 | | |||
48 | const bool qpaVariable = qEnvironmentVariableIsSet("QT_QPA_PLATFORM"); | 48 | const bool qpaVariable = qEnvironmentVariableIsSet("QT_QPA_PLATFORM"); | ||
49 | KWorkSpace::detectPlatform(argc, argv); | 49 | KWorkSpace::detectPlatform(argc, argv); | ||
50 | QQuickWindow::setDefaultAlphaBuffer(true); | 50 | QQuickWindow::setDefaultAlphaBuffer(true); | ||
51 | QApplication app(argc, argv); | 51 | QApplication app(argc, argv); | ||
52 | if (!qpaVariable) { | 52 | if (!qpaVariable) { | ||
53 | // don't leak the env variable to processes we start | 53 | // don't leak the env variable to processes we start | ||
54 | qunsetenv("QT_QPA_PLATFORM"); | 54 | qunsetenv("QT_QPA_PLATFORM"); | ||
Show All 31 Lines | 61 | // QGuiApplication app(argc, argv); | |||
86 | aboutData.processCommandLine(&parser); | 86 | aboutData.processCommandLine(&parser); | ||
87 | 87 | | |||
88 | if (!KAuthorized::authorize(QStringLiteral("run_command"))) { | 88 | if (!KAuthorized::authorize(QStringLiteral("run_command"))) { | ||
89 | return -1; | 89 | return -1; | ||
90 | } | 90 | } | ||
91 | 91 | | |||
92 | KDBusService service(KDBusService::Unique | KDBusService::StartupOption(parser.isSet(replaceOption) ? KDBusService::Replace : 0)); | 92 | KDBusService service(KDBusService::Unique | KDBusService::StartupOption(parser.isSet(replaceOption) ? KDBusService::Replace : 0)); | ||
93 | 93 | | |||
94 | QGuiApplication::setFallbackSessionManagementEnabled(false); | | |||
95 | | ||||
96 | auto disableSessionManagement = [](QSessionManager &sm) { | | |||
97 | sm.setRestartHint(QSessionManager::RestartNever); | | |||
98 | }; | | |||
99 | QObject::connect(&app, &QGuiApplication::commitDataRequest, disableSessionManagement); | | |||
100 | QObject::connect(&app, &QGuiApplication::saveStateRequest, disableSessionManagement); | | |||
101 | | ||||
102 | View view; | 94 | View view; | ||
103 | 95 | | |||
104 | auto updateVisibility = [&]() { | 96 | auto updateVisibility = [&]() { | ||
105 | const QString query = parser.positionalArguments().value(0); | 97 | const QString query = parser.positionalArguments().value(0); | ||
106 | 98 | | |||
107 | if (parser.isSet(daemonOption)) { | 99 | if (parser.isSet(daemonOption)) { | ||
108 | view.setVisible(false); | 100 | view.setVisible(false); | ||
109 | } else if (parser.isSet(clipboardOption)) { | 101 | } else if (parser.isSet(clipboardOption)) { | ||
Show All 18 Lines |