Changeset View
Changeset View
Standalone View
Standalone View
src/main.cpp
Show All 25 Lines | |||||
26 | *****************************************************************/ | 26 | *****************************************************************/ | ||
27 | 27 | | |||
28 | #include <cstdlib> | 28 | #include <cstdlib> | ||
29 | #include <unistd.h> | 29 | #include <unistd.h> | ||
30 | 30 | | |||
31 | #include <QIcon> | 31 | #include <QIcon> | ||
32 | 32 | | |||
33 | #include <KAboutData> | 33 | #include <KAboutData> | ||
34 | #include <KConfigGroup> | ||||
34 | #include <KLocalizedString> | 35 | #include <KLocalizedString> | ||
36 | #include <KSharedConfig> | ||||
35 | #include <QCommandLineParser> | 37 | #include <QCommandLineParser> | ||
36 | #include <QDebug> | 38 | #include <QDebug> | ||
37 | #include <QTemporaryFile> | 39 | #include <QTemporaryFile> | ||
38 | #include <QFile> | 40 | #include <QFile> | ||
39 | 41 | | |||
40 | #include <QDBusConnection> | 42 | #include <QDBusConnection> | ||
41 | #include <QDBusInterface> | 43 | #include <QDBusInterface> | ||
42 | #include <QDBusReply> | 44 | #include <QDBusReply> | ||
Show All 22 Lines | 66 | void openDrKonqiDialog () { | |||
65 | DrKonqiDialog *w = new DrKonqiDialog(); | 67 | DrKonqiDialog *w = new DrKonqiDialog(); | ||
66 | QObject::connect(w, &DrKonqiDialog::rejected, qApp, &QApplication::quit); | 68 | QObject::connect(w, &DrKonqiDialog::rejected, qApp, &QApplication::quit); | ||
67 | w->show(); | 69 | w->show(); | ||
68 | #ifdef Q_OS_MACOS | 70 | #ifdef Q_OS_MACOS | ||
69 | KWindowSystem::forceActiveWindow(w->winId()); | 71 | KWindowSystem::forceActiveWindow(w->winId()); | ||
70 | #endif | 72 | #endif | ||
71 | } | 73 | } | ||
72 | 74 | | |||
73 | void requestDrKonqiDialog(bool restarted) { | 75 | void requestDrKonqiDialog(bool restarted, bool interactionAllowed) { | ||
74 | StatusNotifier *statusNotifier = new StatusNotifier(); | 76 | StatusNotifier *statusNotifier = new StatusNotifier(); | ||
77 | statusNotifier->setActivationAllowed(interactionAllowed); | ||||
78 | if (interactionAllowed) { | ||||
79 | statusNotifier->show(); | ||||
80 | } | ||||
75 | if (!restarted) { | 81 | if (!restarted) { | ||
76 | statusNotifier->notify(); | 82 | statusNotifier->notify(); | ||
77 | } | 83 | } | ||
78 | QObject::connect(statusNotifier, &StatusNotifier::expired, qApp, &QApplication::quit); | 84 | QObject::connect(statusNotifier, &StatusNotifier::expired, qApp, &QApplication::quit); | ||
79 | QObject::connect(statusNotifier, &StatusNotifier::activated, &openDrKonqiDialog); | 85 | QObject::connect(statusNotifier, &StatusNotifier::activated, &openDrKonqiDialog); | ||
80 | } | 86 | } | ||
81 | 87 | | |||
82 | bool isShuttingDown() { | 88 | bool isShuttingDown() { | ||
▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Line(s) | |||||
205 | #endif | 211 | #endif | ||
206 | 212 | | |||
207 | if (!DrKonqi::init()) { | 213 | if (!DrKonqi::init()) { | ||
208 | return 1; | 214 | return 1; | ||
209 | } | 215 | } | ||
210 | 216 | | |||
211 | app.setQuitOnLastWindowClosed(false); | 217 | app.setQuitOnLastWindowClosed(false); | ||
212 | 218 | | |||
213 | | ||||
214 | const bool restarted = parser.isSet(restartedOption); | 219 | const bool restarted = parser.isSet(restartedOption); | ||
215 | 220 | | |||
221 | // Whether the user should be encouraged to file a bug report | ||||
222 | const bool interactionAllowed = KConfigGroup(KSharedConfig::openConfig(), "General").readEntry("InteractionAllowed", true); | ||||
223 | const bool shuttingDown = isShuttingDown(); | ||||
224 | | ||||
225 | // For automatically restarted services or during shutdown, do nothing in case no interaction is allowed | ||||
sitter: Surely it should also return right away if isShuttingDown down and interaction isn't allowed… | |||||
sitter: What about this? | |||||
226 | if (!forceDialog && !interactionAllowed && (restarted || shuttingDown)) { | ||||
227 | return 0; | ||||
228 | } | ||||
229 | | ||||
216 | // if no notification service is running (eg. shell crashed, or other desktop environment) | 230 | // if no notification service is running (eg. shell crashed, or other desktop environment) | ||
217 | // and we didn't auto-restart the app, open DrKonqi dialog instead of showing an SNI | 231 | // and we didn't auto-restart the app, open DrKonqi dialog instead of showing an SNI | ||
218 | // and emitting a desktop notification. | 232 | // and emitting a desktop notification. | ||
219 | if (isShuttingDown()) { | 233 | if (shuttingDown) { | ||
220 | DrKonqi::shutdownSaveReport(); | 234 | DrKonqi::shutdownSaveReport(); | ||
221 | } else if (forceDialog || (!restarted && !StatusNotifier::notificationServiceRegistered())) { | 235 | } else if (forceDialog || (!restarted && !StatusNotifier::notificationServiceRegistered())) { | ||
222 | openDrKonqiDialog(); | 236 | openDrKonqiDialog(); | ||
223 | } else { | 237 | } else { | ||
224 | requestDrKonqiDialog(restarted); | 238 | requestDrKonqiDialog(restarted, interactionAllowed); | ||
225 | } | 239 | } | ||
226 | 240 | | |||
227 | return app.exec(); | 241 | return app.exec(); | ||
228 | } | 242 | } |
Surely it should also return right away if isShuttingDown down and interaction isn't allowed, otherwise you create a dump needlessly on account of the user not being meant to report it.