Commit 60aad465 authored by David Faure's avatar David Faure

Port all KRun::runService/runApplication to KIO/ApplicationLauncherJob

Summary: And use KNotificationJobUiDelegate in case of errors

Test Plan: Untested other than compilation

Reviewers: broulik, davidedmundson

Reviewed By: broulik

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D29124
parent 0e40a1ca
......@@ -13,6 +13,7 @@ target_link_libraries(plasma_applet_icon
KF5::KIOCore # for OpenFileManagerWindowJob
KF5::KIOGui # for FavIconRequestJob
KF5::KIOWidgets # for KRun
KF5::Notifications
KF5::Plasma
PW::LibTaskManager)
......
......@@ -40,7 +40,9 @@
#include <KFileItemListProperties>
#include <KFileUtils>
#include <KJobWidgets>
#include <KIO/ApplicationLauncherJob>
#include <KLocalizedString>
#include <KNotificationJobUiDelegate>
#include <KProtocolManager>
#include <KRun>
......@@ -444,7 +446,11 @@ void IconApplet::processDrop(QObject *dropEvent)
const QString &localPath = m_url.toLocalFile();
if (KDesktopFile::isDesktopFile(localPath)) {
KRun::runService(KService(localPath), urls, nullptr);
KService::Ptr service(new KService(localPath));
auto *job = new KIO::ApplicationLauncherJob(service);
job->setUrls(urls);
job->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled));
job->start();
return;
}
......
......@@ -28,11 +28,12 @@
#include <QDir>
#include <QStandardPaths>
#include <KIO/ApplicationLauncherJob>
#include <KLocalizedString>
#include <KMimeTypeTrader>
#include <KNotificationJobUiDelegate>
#include <KPropertiesDialog>
#include <KProtocolInfo>
#include <KRun>
#include <KActivities/Stats/Cleaning>
#include <KActivities/Stats/ResultSet>
......@@ -131,7 +132,10 @@ bool handleFileItemAction(const KFileItem &fileItem, const QString &actionId, co
return false;
}
KRun::runService(*service, QList<QUrl>() << fileItem.url(), QApplication::activeWindow());
auto *job = new KIO::ApplicationLauncherJob(service);
job->setUrls({fileItem.url()});
job->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled));
job->start();
*close = true;
......@@ -314,7 +318,10 @@ bool handleRecentDocumentAction(KService::Ptr service, const QString &actionId,
return false;
}
return (KRun::runService(*service, QList<QUrl>() << QUrl(argument), QApplication::activeWindow()) != 0);
auto *job = new KIO::ApplicationLauncherJob(service);
job->setUrls({QUrl(argument)});
job->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled));
return job->exec();
}
Q_GLOBAL_STATIC(MenuEntryEditor, menuEntryEditor)
......
......@@ -35,8 +35,10 @@
#include <KActivities/ResourceInstance>
#include <KConfigGroup>
#include <KJob>
#include <KIO/ApplicationLauncherJob>
#include <KLocalizedString>
#include <KMimeTypeTrader>
#include <KNotificationJobUiDelegate>
#include <KRun>
#include <KSycoca>
#include <KShell>
......@@ -203,10 +205,14 @@ bool AppEntry::run(const QString& actionId, const QVariant &argument)
}
#endif
KRun::runApplication(*m_service, {}, nullptr, KRun::DeleteTemporaryFiles, {}, KStartupInfo::createNewStartupIdForTimestamp(timeStamp));
auto *job = new KIO::ApplicationLauncherJob(m_service);
job->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled));
job->setRunFlags(KIO::ApplicationLauncherJob::DeleteTemporaryFiles);
job->setStartupId(KStartupInfo::createNewStartupIdForTimestamp(timeStamp));
job->start();
KActivities::ResourceInstance::notifyAccessed(QUrl(QStringLiteral("applications:") + m_service->storageId()),
QStringLiteral("org.kde.plasma.kicker"));
QStringLiteral("org.kde.plasma.kicker"));
return true;
}
......
......@@ -37,8 +37,10 @@
#include <KActivities/ResourceInstance>
#include <KFileItem>
#include <KIO/ApplicationLauncherJob>
#include <KLocalizedString>
#include <KMimeTypeTrader>
#include <KNotificationJobUiDelegate>
#include <KRun>
#include <KService>
#include <KStartupInfo>
......@@ -379,8 +381,10 @@ bool RecentUsageModel::trigger(int row, const QString &actionId, const QVariant
}
#endif
// TODO Once we depend on KDE Frameworks 5.24 and D1902 is merged, use KRun::runApplication instead
KRun::runService(*service, {}, nullptr, true, {}, KStartupInfo::createNewStartupIdForTimestamp(timeStamp));
auto *job = new KIO::ApplicationLauncherJob(service);
job->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled));
job->setStartupId(KStartupInfo::createNewStartupIdForTimestamp(timeStamp));
job->start();
KActivities::ResourceInstance::notifyAccessed(QUrl(QStringLiteral("applications:") + storageId),
QStringLiteral("org.kde.plasma.kicker"));
......
......@@ -31,10 +31,11 @@
#include <QRegularExpression>
#include <KLocalizedString>
#include <KIO/ApplicationLauncherJob>
#include <KNotificationJobUiDelegate>
#include <KService>
#include <KStringHandler>
#include <KMimeTypeTrader>
#include <KRun>
#include <KWindowSystem>
#include "klippersettings.h"
......@@ -298,7 +299,10 @@ void URLGrabber::execute( const ClipAction* action, int cmdIdx ) const
}
if( !command.serviceStorageId.isEmpty()) {
KService::Ptr service = KService::serviceByStorageId( command.serviceStorageId );
KRun::runApplication( *service, QList< QUrl >() << QUrl( text ), nullptr );
auto *job = new KIO::ApplicationLauncherJob(service);
job->setUrls({QUrl(text)});
job->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled));
job->start();
} else {
ClipCommandProcess* proc = new ClipCommandProcess(*action, command, text, m_history, m_myClipItem);
if (proc->program().isEmpty()) {
......
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