Changeset View
Changeset View
Standalone View
Standalone View
applets/kicker/plugin/actionlist.cpp
Show All 19 Lines | |||||
20 | 20 | | |||
21 | #include "actionlist.h" | 21 | #include "actionlist.h" | ||
22 | #include "menuentryeditor.h" | 22 | #include "menuentryeditor.h" | ||
23 | 23 | | |||
24 | #include <config-appstream.h> | 24 | #include <config-appstream.h> | ||
25 | 25 | | |||
26 | #include <QApplication> | 26 | #include <QApplication> | ||
27 | #include <QDesktopServices> | 27 | #include <QDesktopServices> | ||
28 | #include <QDir> | ||||
29 | #include <QStandardPaths> | ||||
28 | 30 | | |||
29 | #include <KLocalizedString> | 31 | #include <KLocalizedString> | ||
30 | #include <KMimeTypeTrader> | 32 | #include <KMimeTypeTrader> | ||
31 | #include <KPropertiesDialog> | 33 | #include <KPropertiesDialog> | ||
32 | #include <KProtocolInfo> | 34 | #include <KProtocolInfo> | ||
33 | #include <KRun> | 35 | #include <KRun> | ||
34 | 36 | | |||
35 | #include <KActivities/Stats/Cleaning> | 37 | #include <KActivities/Stats/Cleaning> | ||
▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Line(s) | 144 | { | |||
148 | if (ContainmentInterface::mayAddLauncher(appletInterface, ContainmentInterface::Desktop)) { | 150 | if (ContainmentInterface::mayAddLauncher(appletInterface, ContainmentInterface::Desktop)) { | ||
149 | actionList << Kicker::createActionItem(i18n("Add to Desktop"), QStringLiteral("addToDesktop")); | 151 | actionList << Kicker::createActionItem(i18n("Add to Desktop"), QStringLiteral("addToDesktop")); | ||
150 | } | 152 | } | ||
151 | 153 | | |||
152 | if (ContainmentInterface::mayAddLauncher(appletInterface, ContainmentInterface::Panel)) { | 154 | if (ContainmentInterface::mayAddLauncher(appletInterface, ContainmentInterface::Panel)) { | ||
153 | actionList << Kicker::createActionItem(i18n("Add to Panel (Widget)"), QStringLiteral("addToPanel")); | 155 | actionList << Kicker::createActionItem(i18n("Add to Panel (Widget)"), QStringLiteral("addToPanel")); | ||
154 | } | 156 | } | ||
155 | 157 | | |||
156 | if (service && ContainmentInterface::mayAddLauncher(appletInterface, ContainmentInterface::TaskManager, service->entryPath())) { | 158 | if (service && ContainmentInterface::mayAddLauncher(appletInterface, ContainmentInterface::TaskManager, Kicker::resolvedServiceEntryPath(service))) { | ||
157 | actionList << Kicker::createActionItem(i18n("Pin to Task Manager"), QStringLiteral("addToTaskManager")); | 159 | actionList << Kicker::createActionItem(i18n("Pin to Task Manager"), QStringLiteral("addToTaskManager")); | ||
158 | } | 160 | } | ||
159 | 161 | | |||
160 | return actionList; | 162 | return actionList; | ||
161 | } | 163 | } | ||
162 | 164 | | |||
163 | bool handleAddLauncherAction(const QString &actionId, QObject *appletInterface, const KService::Ptr &service) | 165 | bool handleAddLauncherAction(const QString &actionId, QObject *appletInterface, const KService::Ptr &service) | ||
164 | { | 166 | { | ||
165 | if (!service) { | 167 | if (!service) { | ||
166 | return false; | 168 | return false; | ||
167 | } | 169 | } | ||
168 | 170 | | |||
169 | if (actionId == QLatin1String("addToDesktop")) { | 171 | if (actionId == QLatin1String("addToDesktop")) { | ||
170 | if (ContainmentInterface::mayAddLauncher(appletInterface, ContainmentInterface::Desktop)) { | 172 | if (ContainmentInterface::mayAddLauncher(appletInterface, ContainmentInterface::Desktop)) { | ||
171 | ContainmentInterface::addLauncher(appletInterface, ContainmentInterface::Desktop, service->entryPath()); | 173 | ContainmentInterface::addLauncher(appletInterface, ContainmentInterface::Desktop, Kicker::resolvedServiceEntryPath(service)); | ||
172 | } | 174 | } | ||
173 | return true; | 175 | return true; | ||
174 | } else if (actionId == QLatin1String("addToPanel")) { | 176 | } else if (actionId == QLatin1String("addToPanel")) { | ||
175 | if (ContainmentInterface::mayAddLauncher(appletInterface, ContainmentInterface::Panel)) { | 177 | if (ContainmentInterface::mayAddLauncher(appletInterface, ContainmentInterface::Panel)) { | ||
176 | ContainmentInterface::addLauncher(appletInterface, ContainmentInterface::Panel, service->entryPath()); | 178 | ContainmentInterface::addLauncher(appletInterface, ContainmentInterface::Panel, Kicker::resolvedServiceEntryPath(service)); | ||
177 | } | 179 | } | ||
178 | return true; | 180 | return true; | ||
179 | } else if (actionId == QLatin1String("addToTaskManager")) { | 181 | } else if (actionId == QLatin1String("addToTaskManager")) { | ||
180 | if (ContainmentInterface::mayAddLauncher(appletInterface, ContainmentInterface::TaskManager, service->entryPath())) { | 182 | if (ContainmentInterface::mayAddLauncher(appletInterface, ContainmentInterface::TaskManager, Kicker::resolvedServiceEntryPath(service))) { | ||
181 | ContainmentInterface::addLauncher(appletInterface, ContainmentInterface::TaskManager, service->entryPath()); | 183 | ContainmentInterface::addLauncher(appletInterface, ContainmentInterface::TaskManager, Kicker::resolvedServiceEntryPath(service)); | ||
182 | } | 184 | } | ||
183 | return true; | 185 | return true; | ||
184 | } | 186 | } | ||
185 | 187 | | |||
186 | return false; | 188 | return false; | ||
187 | } | 189 | } | ||
188 | 190 | | |||
189 | QString storageIdFromService(KService::Ptr service) | 191 | QString storageIdFromService(KService::Ptr service) | ||
▲ Show 20 Lines • Show All 201 Lines • ▼ Show 20 Line(s) | |||||
391 | { | 393 | { | ||
392 | if (actionId == QLatin1String("manageApplication")) { | 394 | if (actionId == QLatin1String("manageApplication")) { | ||
393 | return QDesktopServices::openUrl(QUrl(argument.toString())); | 395 | return QDesktopServices::openUrl(QUrl(argument.toString())); | ||
394 | } | 396 | } | ||
395 | 397 | | |||
396 | return false; | 398 | return false; | ||
397 | } | 399 | } | ||
398 | 400 | | |||
401 | QString resolvedServiceEntryPath(const KService::Ptr &service) | ||||
402 | { | ||||
403 | QString path = service->entryPath(); | ||||
404 | if (!QDir::isAbsolutePath(path)) { | ||||
405 | path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kservices5/") + path); | ||||
406 | } | ||||
407 | return path; | ||||
408 | } | ||||
399 | 409 | | |||
400 | } | 410 | } |