Commit 87b56206 authored by Nate Graham's avatar Nate Graham 🔩
Browse files

[applets/icon] Handle non-Applications URLs again

In the past, this applet naively passed the URL to KRun when clicked on
or something was dragged on top of it. However during porting away from
KRun, it was ported to KIO::ApplicationLauncherJob, which only handles
applications, not other types of URLs.

This commit fixes that by making it use KIO::OpenURLJob (which can
handle applications as well as arbitrary URLs) when it's clicked on. We
also short-circuit the application-specific logic when something is
dragged on it and it's not an application, which allows the
non-application logic to be reached.

BUG: 427797
FIXED-IN: 5.20.3
parent 29ea3d65
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include <KIO/DropJob> #include <KIO/DropJob>
#include <KIO/FavIconRequestJob> #include <KIO/FavIconRequestJob>
#include <KIO/OpenFileManagerWindowJob> #include <KIO/OpenFileManagerWindowJob>
#include <KIO/OpenUrlJob>
#include <KIO/StatJob> #include <KIO/StatJob>
#include <startuptasksmodel.h> #include <startuptasksmodel.h>
...@@ -431,7 +432,8 @@ void IconApplet::run() ...@@ -431,7 +432,8 @@ void IconApplet::run()
connect(m_startupTasksModel, &QAbstractItemModel::rowsAboutToBeRemoved, this, std::bind(handleRow, false /*busy*/, _1, _2, _3)); connect(m_startupTasksModel, &QAbstractItemModel::rowsAboutToBeRemoved, this, std::bind(handleRow, false /*busy*/, _1, _2, _3));
} }
KIO::ApplicationLauncherJob *job = new KIO::ApplicationLauncherJob(KService::Ptr(new KService(m_localPath))); KIO::OpenUrlJob* job = new KIO::OpenUrlJob(QUrl::fromLocalFile(m_localPath));
job->setRunExecutables(true); // so it can launch apps
job->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled)); job->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled));
job->start(); job->start();
} }
...@@ -450,12 +452,15 @@ void IconApplet::processDrop(QObject *dropEvent) ...@@ -450,12 +452,15 @@ void IconApplet::processDrop(QObject *dropEvent)
const QString &localPath = m_url.toLocalFile(); const QString &localPath = m_url.toLocalFile();
if (KDesktopFile::isDesktopFile(localPath)) { if (KDesktopFile::isDesktopFile(localPath)) {
KService::Ptr service(new KService(localPath)); auto service = new KService(localPath);
auto *job = new KIO::ApplicationLauncherJob(service);
job->setUrls(urls); if (service->isApplication()) {
job->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled)); KIO::ApplicationLauncherJob* job = new KIO::ApplicationLauncherJob(KService::Ptr(service));
job->start(); job->setUrls(urls);
return; job->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled));
} }
QMimeDatabase db; QMimeDatabase db;
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