Changeset View
Changeset View
Standalone View
Standalone View
main.cpp
Show All 23 Lines | |||||
24 | #include "main.h" | 24 | #include "main.h" | ||
25 | 25 | | |||
26 | //KDE | 26 | //KDE | ||
27 | #include <kaboutdata.h> | 27 | #include <kaboutdata.h> | ||
28 | #include <KCrash> | 28 | #include <KCrash> | ||
29 | #include <KLocalizedString> | 29 | #include <KLocalizedString> | ||
30 | #include <config-workspace.h> | 30 | #include <config-workspace.h> | ||
31 | #include <KDBusService> | 31 | #include <KDBusService> | ||
32 | #include <KWindowSystem> | ||||
32 | 33 | | |||
33 | //Qt | 34 | //Qt | ||
34 | #include <QCommandLineParser> | 35 | #include <QCommandLineParser> | ||
35 | 36 | | |||
36 | KicApp::KicApp(int &argc, char **argv) | 37 | KicApp::KicApp(int &argc, char **argv) | ||
37 | : QApplication(argc, argv) | 38 | : QApplication(argc, argv) | ||
38 | { | 39 | { | ||
39 | QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); | 40 | QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); | ||
Show All 16 Lines | |||||
56 | 57 | | |||
57 | QCommandLineParser parser; | 58 | QCommandLineParser parser; | ||
58 | parser.addHelpOption(); | 59 | parser.addHelpOption(); | ||
59 | parser.addVersionOption(); | 60 | parser.addVersionOption(); | ||
60 | aboutData.setupCommandLine(&parser); | 61 | aboutData.setupCommandLine(&parser); | ||
61 | parser.process(*this); | 62 | parser.process(*this); | ||
62 | aboutData.processCommandLine(&parser); | 63 | aboutData.processCommandLine(&parser); | ||
63 | 64 | | |||
65 | auto *service = new KDBusService(KDBusService::Unique, this); | ||||
66 | | ||||
64 | display = new KInfoCenter(); | 67 | display = new KInfoCenter(); | ||
65 | display->show(); | 68 | display->show(); | ||
66 | 69 | | |||
67 | (void)new KDBusService(KDBusService::Unique, this); | 70 | connect(service, &KDBusService::activateRequested, this, [this]() { | ||
71 | KWindowSystem::forceActiveWindow(display->winId()); | ||||
mart: KWindowSystem::forceActiveWindow should never be used by normal applications, it's reserved for… | |||||
The documentation of KDBusService recommends to use it: volkov: The documentation of KDBusService recommends to use it:
https://api.kde. | |||||
72 | }); | ||||
68 | } | 73 | } | ||
69 | 74 | | |||
70 | int main(int argc, char *argv[]) | 75 | int main(int argc, char *argv[]) | ||
71 | { | 76 | { | ||
72 | KicApp Kic(argc, argv); | 77 | KicApp Kic(argc, argv); | ||
73 | 78 | | |||
74 | KCrash::initialize(); | 79 | KCrash::initialize(); | ||
75 | 80 | | |||
76 | return Kic.exec(); | 81 | return Kic.exec(); | ||
77 | } | 82 | } |
KWindowSystem::forceActiveWindow should never be used by normal applications, it's reserved for workspaces and won't work on Wayland.
QWidget::activateWindow should be enough, even if that's not guaranteed to actually raise the window, is more correct.