[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-i18n-doc
Subject: [discover/Plasma/5.17] notifier: notifier: make it possible to replace the instance
From: Aleix Pol <null () kde ! org>
Date: 2019-10-29 1:01:25
Message-ID: E1iPFsz-0003ir-8J () code ! kde ! org
[Download RAW message or body]
Git commit 4c13b6c371cf35c11befad0ffd6f1826e2f7ff02 by Aleix Pol.
Committed on 29/10/2019 at 01:01.
Pushed by apol into branch 'Plasma/5.17'.
notifier: make it possible to replace the instance
It's useful to easily restart the process.
Note to translators: this adds a couple of i18n calls but this is a
libexec process and these are only rendered in --help, so I assume it's
okay to include in a stable branch.
CCMAIL: kde-i18n-doc@kde.org
M +39 -2 notifier/main.cpp
https://commits.kde.org/discover/4c13b6c371cf35c11befad0ffd6f1826e2f7ff02
diff --git a/notifier/main.cpp b/notifier/main.cpp
index f2eacd13..299a8ccd 100644
--- a/notifier/main.cpp
+++ b/notifier/main.cpp
@@ -21,9 +21,16 @@
#include <KStatusNotifierItem>
#include <QMenu>
#include <KLocalizedString>
+#include <KAboutData>
#include <KCrash>
#include <KDBusService>
+#include <QCommandLineParser>
+#include <QDBusMessage>
+#include <QDBusConnection>
+#include <QDBusConnectionInterface>
+#include <QDebug>
#include "DiscoverNotifier.h"
+#include "../DiscoverVersion.h"
KStatusNotifierItem::ItemStatus sniStatus(DiscoverNotifier::State state)
{
@@ -42,11 +49,41 @@ KStatusNotifierItem::ItemStatus sniStatus(DiscoverNotifier::State \
state) int main(int argc, char** argv)
{
QApplication app(argc, argv);
- DiscoverNotifier notifier;
+ app.setOrganizationDomain(QStringLiteral("kde.org"));
- KDBusService service(KDBusService::Unique);
KCrash::setFlags(KCrash::AutoRestart);
+ {
+ KAboutData about(QStringLiteral("DiscoverNotifier"), i18n("Discover \
Notifier"), version, i18n("System update status notifier"), + \
KAboutLicense::GPL, i18n(" © 2010-2019 Plasma Development Team")); + \
about.addAuthor(QStringLiteral("Aleix Pol Gonzalez"), {}, \
QStringLiteral("aleixpol@kde.org")); + \
about.setProductName("discover/discover"); + \
about.setProgramLogo(app.windowIcon()); +
+ QCommandLineParser parser;
+ QCommandLineOption replaceOption({QStringLiteral("replace")},
+ i18n("Replace an existing instance"));
+ parser.addOption(replaceOption);
+ about.setupCommandLine(&parser);
+ parser.process(app);
+ about.processCommandLine(&parser);
+
+ if (parser.isSet(replaceOption)) {
+ auto message = \
QDBusMessage::createMethodCall(QStringLiteral("org.kde.DiscoverNotifier"), + \
QStringLiteral("/MainApplication"), + \
QStringLiteral("org.qtproject.Qt.QCoreApplication"), + \
QStringLiteral("quit")); + auto reply = \
QDBusConnection::sessionBus().call(message); //deliberately block until it's done, so \
we register the name after the app quits +
+ while (QDBusConnection::sessionBus().interface()->isServiceRegistered(QStringLiteral("org.kde.DiscoverNotifier"))) \
{ + QCoreApplication::processEvents(QEventLoop::AllEvents);
+ }
+ }
+ }
+
+ KDBusService service(KDBusService::Unique);
+ DiscoverNotifier notifier;
+
KStatusNotifierItem item;
item.setTitle(i18n("Updates"));
item.setToolTipTitle(i18n("Updates"));
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic