Commit 53375168 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

[Notifier] Port from KRun::runCommand

Use ApplicationLauncherJob for launching the main application and CommandLauncherJob for launching the updater.
This also gives us a nice startup feedback for both cases now.
The KService::serviceByDesktopName could in theory return null but imho that would be severely broken
if we have the updater running but rest of Discover is absent.

Differential Revision: https://phabricator.kde.org/D28821
parent 50231939
......@@ -4,7 +4,7 @@ add_executable(DiscoverNotifier BackendNotifierFactory.cpp DiscoverNotifier.cpp
target_link_libraries(DiscoverNotifier
KF5::Notifications
KF5::I18n
KF5::KIOWidgets
KF5::KIOGui
KF5::Crash
KF5::DBusAddons
......
......@@ -24,11 +24,14 @@
#include <QDBusInterface>
#include <QDBusPendingReply>
#include <QNetworkConfigurationManager>
#include <KRun>
#include <KLocalizedString>
#include <KNotification>
#include <KNotificationJobUiDelegate>
#include <KPluginFactory>
#include <KIO/ApplicationLauncherJob>
#include <KIO/CommandLauncherJob>
#include "../libdiscover/utils.h"
DiscoverNotifier::DiscoverNotifier(QObject * parent)
......@@ -61,14 +64,28 @@ DiscoverNotifier::~DiscoverNotifier() = default;
void DiscoverNotifier::showDiscover()
{
KRun::runCommand(QStringLiteral("plasma-discover"), nullptr);
if (m_updatesAvailableNotification) { m_updatesAvailableNotification->close(); }
auto *job = new KIO::ApplicationLauncherJob(KService::serviceByDesktopName(QStringLiteral("org.kde.discover")));
job->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoErrorHandlingEnabled));
job->start();
if (m_updatesAvailableNotification) {
m_updatesAvailableNotification->close();
}
}
void DiscoverNotifier::showDiscoverUpdates()
{
KRun::runCommand(QStringLiteral("plasma-discover --mode update"), nullptr);
if (m_updatesAvailableNotification) { m_updatesAvailableNotification->close(); }
auto *job = new KIO::CommandLauncherJob(QStringLiteral("plasma-discover"), {
QStringLiteral("--mode"),
QStringLiteral("update")
});
job->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoErrorHandlingEnabled));
job->setDesktopName(QStringLiteral("org.kde.discover"));
job->start();
if (m_updatesAvailableNotification) {
m_updatesAvailableNotification->close();
}
}
void DiscoverNotifier::showUpdatesNotification()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment