Commit bfbd9cf1 authored by David Redondo's avatar David Redondo 🏎
Browse files

Use the desktop file used for importing shortcuts

When the shortcuts are set by copying the desktop file to the kglobalaccel
directory, we can just use those in the kcm and do not need to do further lookup.
parent 4b2c0475
......@@ -106,21 +106,25 @@ Component GlobalAccelModel::loadComponent(const QList<KGlobalShortcutInfo> &info
{
const QString &componentUnique = info[0].componentUniqueName();
const QString &componentFriendly = info[0].componentFriendlyName();
KService::Ptr service = KService::serviceByStorageId(componentUnique);
KService::Ptr service;
// The shortcuts were imported by desktop file
if (componentUnique.endsWith(QLatin1String(".desktop"))) {
service = new KService(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kglobalaccel/") + componentUnique));
} else {
service = KService::serviceByStorageId(componentUnique);
}
if (!service) {
// Do we have an application with that name?
const KService::List apps = KServiceTypeTrader::self()->query(QStringLiteral("Application"),
// Do we have a service with that name?
const KService::List services = KServiceTypeTrader::self()->query(QStringLiteral("Application"),
QStringLiteral("Name == '%1' or Name == '%2'").arg(componentUnique, componentFriendly));
if (!apps.isEmpty()) {
service = apps[0];
}
service = services.value(0, KService::Ptr());
}
const QString type = service && service->isApplication() ? i18n("Applications") : i18n("System Services");
QString icon;
static const QHash<QString, QString> hardCodedIcons = {{"ActivityManager", "preferences-desktop-activities"},
{"KDE Keyboard Layout Switcher", "input-keyboard"},
{"krunner.desktop", "krunner"},
{"org_kde_powerdevil", "preferences-system-power-management"}};
if (service && !service->icon().isEmpty()) {
......
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