Commit f47d78bc authored by Nicolas Fella's avatar Nicolas Fella
Browse files

[runners] Port from KRun to OpenUrlJob

The former is deprecated
parent 8cbaa7eb
...@@ -12,6 +12,7 @@ target_link_libraries(baloorunner ...@@ -12,6 +12,7 @@ target_link_libraries(baloorunner
KF5::KIOWidgets KF5::KIOWidgets
KF5::I18n KF5::I18n
KF5::Baloo KF5::Baloo
KF5::Notifications
Qt5::DBus Qt5::DBus
) )
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include <QAction> #include <QAction>
#include <QIcon> #include <QIcon>
#include <QDir> #include <QDir>
#include <KRun>
#include <KLocalizedString> #include <KLocalizedString>
#include <QMimeDatabase> #include <QMimeDatabase>
#include <QTimer> #include <QTimer>
...@@ -36,6 +35,8 @@ ...@@ -36,6 +35,8 @@
#include <Baloo/IndexerConfig> #include <Baloo/IndexerConfig>
#include <KIO/OpenFileManagerWindowJob> #include <KIO/OpenFileManagerWindowJob>
#include <KIO/OpenUrlJob>
#include <KNotificationJobUiDelegate>
#include "krunner1adaptor.h" #include "krunner1adaptor.h"
...@@ -202,5 +203,8 @@ void SearchRunner::Run(const QString& id, const QString& actionId) ...@@ -202,5 +203,8 @@ void SearchRunner::Run(const QString& id, const QString& actionId)
return; return;
} }
new KRun(url, nullptr); auto *job = new KIO::OpenUrlJob(url);
job->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoErrorHandlingEnabled));
job->setRunExecutables(false);
job->start();
} }
...@@ -11,6 +11,7 @@ target_link_libraries(krunner_locations ...@@ -11,6 +11,7 @@ target_link_libraries(krunner_locations
KF5::KIOWidgets KF5::KIOWidgets
KF5::I18n KF5::I18n
KF5::Runner KF5::Runner
KF5::Notifications
) )
install(TARGETS krunner_locations DESTINATION "${KDE_INSTALL_PLUGINDIR}/kf5/krunner" ) install(TARGETS krunner_locations DESTINATION "${KDE_INSTALL_PLUGINDIR}/kf5/krunner" )
...@@ -25,15 +25,14 @@ ...@@ -25,15 +25,14 @@
#include <QDebug> #include <QDebug>
#include <KApplicationTrader> #include <KApplicationTrader>
#include <KRun>
#include <KLocalizedString> #include <KLocalizedString>
#include <KProtocolInfo> #include <KProtocolInfo>
#include <KUriFilter> #include <KUriFilter>
#include <KIO/DesktopExecParser> #include <KIO/DesktopExecParser>
#include <KIO/Global> #include <KIO/Global>
#include <KShell> #include <KShell>
#include <KIO/OpenUrlJob>
#include <kservicetypetrader.h> #include <KNotificationJobUiDelegate>
K_EXPORT_PLASMA_RUNNER_WITH_JSON(LocationsRunner, "plasma-runner-locations.json") K_EXPORT_PLASMA_RUNNER_WITH_JSON(LocationsRunner, "plasma-runner-locations.json")
...@@ -186,9 +185,13 @@ void LocationsRunner::run(const Plasma::RunnerContext &context, const Plasma::Qu ...@@ -186,9 +185,13 @@ void LocationsRunner::run(const Plasma::RunnerContext &context, const Plasma::Qu
location = convertCaseInsensitivePath(location); location = convertCaseInsensitivePath(location);
QUrl urlToRun(KUriFilter::self()->filteredUri(location, {QStringLiteral("kshorturifilter")})); const QUrl urlToRun(KUriFilter::self()->filteredUri(location, {QStringLiteral("kshorturifilter")}));
auto *job = new KIO::OpenUrlJob(urlToRun);
job->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoErrorHandlingEnabled));
job->setRunExecutables(false);
job->start();
new KRun(urlToRun, nullptr);
} }
QMimeData * LocationsRunner::mimeDataForMatch(const Plasma::QueryMatch &match) QMimeData * LocationsRunner::mimeDataForMatch(const Plasma::QueryMatch &match)
......
...@@ -8,10 +8,10 @@ add_library(krunner_placesrunner MODULE ${krunner_placesrunner_SRCS}) ...@@ -8,10 +8,10 @@ add_library(krunner_placesrunner MODULE ${krunner_placesrunner_SRCS})
kcoreaddons_desktop_to_json(krunner_placesrunner plasma-runner-places.desktop) kcoreaddons_desktop_to_json(krunner_placesrunner plasma-runner-places.desktop)
target_link_libraries(krunner_placesrunner target_link_libraries(krunner_placesrunner
KF5::KIOCore KF5::KIOCore
KF5::KIOWidgets
KF5::KIOFileWidgets KF5::KIOFileWidgets
KF5::I18n KF5::I18n
KF5::Runner KF5::Runner
KF5::Notifications
) )
install(TARGETS krunner_placesrunner DESTINATION "${KDE_INSTALL_PLUGINDIR}/kf5/krunner" ) install(TARGETS krunner_placesrunner DESTINATION "${KDE_INSTALL_PLUGINDIR}/kf5/krunner" )
...@@ -27,8 +27,10 @@ ...@@ -27,8 +27,10 @@
#include <QIcon> #include <QIcon>
#include <QMimeData> #include <QMimeData>
#include <QUrl> #include <QUrl>
#include <KRun>
#include <KLocalizedString> #include <KLocalizedString>
#include <KIO/OpenUrlJob>
#include <KNotificationJobUiDelegate>
K_EXPORT_PLASMA_RUNNER_WITH_JSON(PlacesRunner, "plasma-runner-places.json") K_EXPORT_PLASMA_RUNNER_WITH_JSON(PlacesRunner, "plasma-runner-places.json")
...@@ -75,7 +77,10 @@ PlacesRunnerHelper::PlacesRunnerHelper(PlacesRunner *runner) ...@@ -75,7 +77,10 @@ PlacesRunnerHelper::PlacesRunnerHelper(PlacesRunner *runner)
connect(&m_places, &KFilePlacesModel::setupDone, this, [this](const QModelIndex &index, bool success) { connect(&m_places, &KFilePlacesModel::setupDone, this, [this](const QModelIndex &index, bool success) {
if (success && m_pendingUdi == m_places.deviceForIndex(index).udi()) { if (success && m_pendingUdi == m_places.deviceForIndex(index).udi()) {
new KRun(m_places.url(index), nullptr); auto *job = new KIO::OpenUrlJob(m_places.url(index));
job->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoErrorHandlingEnabled));
job->setRunExecutables(false);
job->start();
} }
m_pendingUdi.clear(); m_pendingUdi.clear();
}); });
...@@ -156,7 +161,10 @@ void PlacesRunner::run(const Plasma::RunnerContext &context, const Plasma::Query ...@@ -156,7 +161,10 @@ void PlacesRunner::run(const Plasma::RunnerContext &context, const Plasma::Query
Q_UNUSED(context); Q_UNUSED(context);
//I don't just pass the model index because the list could change before the user clicks on it, which would make everything go wrong. Ideally we don't want things to go wrong. //I don't just pass the model index because the list could change before the user clicks on it, which would make everything go wrong. Ideally we don't want things to go wrong.
if (action.data().type() == QVariant::Url) { if (action.data().type() == QVariant::Url) {
new KRun(action.data().toUrl(), nullptr); auto *job = new KIO::OpenUrlJob(action.data().toUrl());
job->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoErrorHandlingEnabled));
job->setRunExecutables(false);
job->start();
} else if (action.data().canConvert<QString>()) { } else if (action.data().canConvert<QString>()) {
m_helper->openDevice(action.data().toString()); m_helper->openDevice(action.data().toString());
} }
......
...@@ -12,6 +12,7 @@ target_link_libraries(krunner_recentdocuments ...@@ -12,6 +12,7 @@ target_link_libraries(krunner_recentdocuments
KF5::I18n KF5::I18n
KF5::ActivitiesStats KF5::ActivitiesStats
KF5::Runner KF5::Runner
KF5::Notifications
) )
install(TARGETS krunner_recentdocuments DESTINATION "${KDE_INSTALL_PLUGINDIR}/kf5/krunner" ) install(TARGETS krunner_recentdocuments DESTINATION "${KDE_INSTALL_PLUGINDIR}/kf5/krunner" )
...@@ -23,10 +23,11 @@ ...@@ -23,10 +23,11 @@
#include <QDir> #include <QDir>
#include <QMimeData> #include <QMimeData>
#include <KRun>
#include <KLocalizedString> #include <KLocalizedString>
#include <KIO/OpenFileManagerWindowJob> #include <KIO/OpenFileManagerWindowJob>
#include <KIO/OpenUrlJob>
#include <KIO/Job> #include <KIO/Job>
#include <KNotificationJobUiDelegate>
#include <KShell> #include <KShell>
#include <KActivities/Stats/ResultModel> #include <KActivities/Stats/ResultModel>
...@@ -118,8 +119,10 @@ void RecentDocuments::run(const Plasma::RunnerContext &context, const Plasma::Qu ...@@ -118,8 +119,10 @@ void RecentDocuments::run(const Plasma::RunnerContext &context, const Plasma::Qu
return; return;
} }
auto run = new KRun(url, nullptr); auto *job = new KIO::OpenUrlJob(url);
run->setRunExecutables(false); job->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoErrorHandlingEnabled));
job->setRunExecutables(false);
job->start();
} }
QMimeData * RecentDocuments::mimeDataForMatch(const Plasma::QueryMatch& match) QMimeData * RecentDocuments::mimeDataForMatch(const Plasma::QueryMatch& match)
......
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