Commit 2ff78e97 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

(cherry picked from commit 87b56206)
parent 2ea45bcf
......@@ -50,6 +50,7 @@
#include <KIO/DropJob>
#include <KIO/FavIconRequestJob>
#include <KIO/OpenFileManagerWindowJob>
#include <KIO/OpenUrlJob>
#include <KIO/StatJob>
#include <startuptasksmodel.h>
......@@ -431,7 +432,8 @@ void IconApplet::run()
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));
......@@ -450,12 +452,15 @@ void IconApplet::processDrop(QObject *dropEvent)
const QString &localPath = m_url.toLocalFile();
if (KDesktopFile::isDesktopFile(localPath)) {
KService::Ptr service(new KService(localPath));
auto *job = new KIO::ApplicationLauncherJob(service);
job->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled));
auto service = new KService(localPath);
if (service->isApplication()) {
KIO::ApplicationLauncherJob* job = new KIO::ApplicationLauncherJob(KService::Ptr(service));
job->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled));
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