|
5 | 5 | #include <KLocalizedContext> |
6 | 6 | #include <KLocalizedString> |
7 | 7 | #include <KSharedConfig> |
| 8 | +#include <KWindowSystem> |
8 | 9 | #include <QApplication> |
9 | 10 | #include <QByteArray> |
10 | 11 | #include <QCoreApplication> |
@@ -108,6 +109,15 @@ auto main(int argc, char *argv[]) -> int |
108 | 109 |
|
109 | 110 | auto *window = dynamic_cast<QQuickWindow *>(engine->rootObjects().constFirst()); |
110 | 111 |
|
| 112 | + // honor the "Start minimized" setting on startup |
| 113 | + if (window != nullptr) { |
| 114 | + if (Config::startMinimized()) { |
| 115 | + window->hide(); |
| 116 | + } else { |
| 117 | + window->show(); |
| 118 | + } |
| 119 | + } |
| 120 | + |
111 | 121 | // clicking tray icon should toggle window |
112 | 122 | auto *tray_icon = new TrayIcon(tailscale); |
113 | 123 | tray_icon->setVisible(Config::enableTrayIcon()); |
@@ -135,6 +145,17 @@ auto main(int argc, char *argv[]) -> int |
135 | 145 | }); |
136 | 146 | QObject::connect(tray_icon, &TrayIcon::quitRequested, &app, &QCoreApplication::quit, Qt::QueuedConnection); |
137 | 147 |
|
| 148 | + // re-launching the unique instance should reveal and focus the window |
| 149 | + QObject::connect(&service, &KDBusService::activateRequested, window, [window](const QStringList &, const QString &) { |
| 150 | + if (window == nullptr) { |
| 151 | + return; |
| 152 | + } |
| 153 | + window->show(); |
| 154 | + KWindowSystem::updateStartupId(window); |
| 155 | + window->raise(); |
| 156 | + KWindowSystem::activateWindow(window); |
| 157 | + }); |
| 158 | + |
138 | 159 | QObject::connect(&app, &QCoreApplication::aboutToQuit, &app, [&engine]() { |
139 | 160 | engine.reset(); |
140 | 161 | }); |
|
0 commit comments