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

[runners/service] Set url for matches

That way we don't need to manually create the mimedata any more
parent 9f8b04f0
Pipeline #209302 passed with stage
in 10 minutes and 8 seconds
......@@ -157,6 +157,14 @@ private:
QUrl url(service->storageId());
url.setScheme(QStringLiteral("applications"));
match.setData(url);
QString path = service->entryPath();
if (!QDir::isAbsolutePath(path)) {
path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kservices5/") + path);
}
match.setUrls({QUrl::fromLocalFile(path)});
QString exec = service->exec();
// We have a snap, remove the ENV variable
if (exec.contains(QLatin1String("BAMF_DESKTOP_FILE_HINT"))) {
......@@ -466,31 +474,3 @@ void ServiceRunner::run(const Plasma::RunnerContext &context, const Plasma::Quer
job->setUiDelegate(delegate);
job->start();
}
QMimeData *ServiceRunner::mimeDataForMatch(const Plasma::QueryMatch &match)
{
const QUrl dataUrl = match.data().toUrl();
const QString actionName = QUrlQuery(dataUrl).queryItemValue(QStringLiteral("action"));
if (!actionName.isEmpty()) {
return nullptr;
}
KService::Ptr service = KService::serviceByStorageId(dataUrl.path());
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;
}
auto *data = new QMimeData();
data->setUrls(QList<QUrl>{QUrl::fromLocalFile(path)});
return data;
}
......@@ -29,9 +29,6 @@ public:
void match(Plasma::RunnerContext &context) override;
void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match) override;
protected Q_SLOTS:
QMimeData *mimeDataForMatch(const Plasma::QueryMatch &match) override;
protected:
void setupMatch(const KService::Ptr &service, Plasma::QueryMatch &action);
};
Supports Markdown
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