[Service Runner] Look up relative entryPaths

For KCMs we get a relative entryPath() for our KService resulting in an invalid URL being created.

CCBUG: 397070

Differential Revision: https://phabricator.kde.org/D14546
wilder-5.14
Kai Uwe Broulik 8 years ago
parent 79ac081089
commit cf7381d7fb
  1. 26
      runners/services/servicerunner.cpp

@ -22,8 +22,10 @@
#include <QMimeData>
#include <QIcon>
#include <QDebug>
#include <QDir>
#include <QIcon>
#include <QStandardPaths>
#include <QUrl>
#include <KActivities/ResourceInstance>
@ -467,16 +469,22 @@ void ServiceRunner::run(const Plasma::RunnerContext &context, const Plasma::Quer
QMimeData * ServiceRunner::mimeDataForMatch(const Plasma::QueryMatch &match)
{
KService::Ptr service = KService::serviceByStorageId(match.data().toString());
if (service) {
QMimeData * result = new QMimeData();
QList<QUrl> urls;
urls << QUrl::fromLocalFile(service->entryPath());
qCDebug(RUNNER_SERVICES) << urls;
result->setUrls(urls);
return result;
if (!service) {
return nullptr;
}
QString path = service->entryPath();
if (!QDir::isAbsolutePath(path)) {
path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kservices5/") + path);
}
if (path.isEmpty()) {
return nullptr;
}
return 0;
QMimeData *data = new QMimeData();
data->setUrls(QList<QUrl>{QUrl::fromLocalFile(path)});
return data;
}
K_EXPORT_PLASMA_RUNNER(services, ServiceRunner)

Loading…
Cancel
Save