Commit 2ce76bc5 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

[Kicker] Look up relative entryPaths

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

BUG: 397070
FIXED-IN: 5.14.0

Differential Revision: https://phabricator.kde.org/D14647
parent e0d50ff1
......@@ -25,6 +25,8 @@
#include <QApplication>
#include <QDesktopServices>
#include <QDir>
#include <QStandardPaths>
#include <KLocalizedString>
#include <KMimeTypeTrader>
......@@ -153,7 +155,7 @@ QVariantList createAddLauncherActionList(QObject *appletInterface, const KServic
actionList << Kicker::createActionItem(i18n("Add to Panel (Widget)"), QStringLiteral("addToPanel"));
}
if (service && ContainmentInterface::mayAddLauncher(appletInterface, ContainmentInterface::TaskManager, service->entryPath())) {
if (service && ContainmentInterface::mayAddLauncher(appletInterface, ContainmentInterface::TaskManager, Kicker::resolvedServiceEntryPath(service))) {
actionList << Kicker::createActionItem(i18n("Pin to Task Manager"), QStringLiteral("addToTaskManager"));
}
......@@ -168,17 +170,17 @@ bool handleAddLauncherAction(const QString &actionId, QObject *appletInterface,
if (actionId == QLatin1String("addToDesktop")) {
if (ContainmentInterface::mayAddLauncher(appletInterface, ContainmentInterface::Desktop)) {
ContainmentInterface::addLauncher(appletInterface, ContainmentInterface::Desktop, service->entryPath());
ContainmentInterface::addLauncher(appletInterface, ContainmentInterface::Desktop, Kicker::resolvedServiceEntryPath(service));
}
return true;
} else if (actionId == QLatin1String("addToPanel")) {
if (ContainmentInterface::mayAddLauncher(appletInterface, ContainmentInterface::Panel)) {
ContainmentInterface::addLauncher(appletInterface, ContainmentInterface::Panel, service->entryPath());
ContainmentInterface::addLauncher(appletInterface, ContainmentInterface::Panel, Kicker::resolvedServiceEntryPath(service));
}
return true;
} else if (actionId == QLatin1String("addToTaskManager")) {
if (ContainmentInterface::mayAddLauncher(appletInterface, ContainmentInterface::TaskManager, service->entryPath())) {
ContainmentInterface::addLauncher(appletInterface, ContainmentInterface::TaskManager, service->entryPath());
if (ContainmentInterface::mayAddLauncher(appletInterface, ContainmentInterface::TaskManager, Kicker::resolvedServiceEntryPath(service))) {
ContainmentInterface::addLauncher(appletInterface, ContainmentInterface::TaskManager, Kicker::resolvedServiceEntryPath(service));
}
return true;
}
......@@ -396,5 +398,13 @@ bool handleAppstreamActions(const QString &actionId, const QVariant &argument)
return false;
}
QString resolvedServiceEntryPath(const KService::Ptr &service)
{
QString path = service->entryPath();
if (!QDir::isAbsolutePath(path)) {
path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kservices5/") + path);
}
return path;
}
}
......@@ -65,4 +65,6 @@ bool handleEditApplicationAction(const QString &actionId, const KService::Ptr &s
QVariantList appstreamActions(const KService::Ptr &service);
bool handleAppstreamActions(const QString &actionId, const QVariant &argument);
QString resolvedServiceEntryPath(const KService::Ptr &service);
}
......@@ -125,7 +125,7 @@ QString AppEntry::menuId() const
QUrl AppEntry::url() const
{
return QUrl::fromLocalFile(m_service->entryPath());
return QUrl::fromLocalFile(Kicker::resolvedServiceEntryPath(m_service));
}
bool AppEntry::hasActions() const
......
......@@ -75,7 +75,7 @@ QVariant RunnerMatchesModel::data(const QModelIndex &index, int role) const
|| runnerId == QLatin1String("services")) {
KService::Ptr service = KService::serviceByStorageId(match.data().toString());
if (service) {
return QUrl::fromLocalFile(service->entryPath());
return QUrl::fromLocalFile(Kicker::resolvedServiceEntryPath(service));
}
}
} else if (role == Kicker::HasActionListRole) {
......
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