diff --git a/src/runtime/globalshortcutsregistry.h b/src/runtime/globalshortcutsregistry.h --- a/src/runtime/globalshortcutsregistry.h +++ b/src/runtime/globalshortcutsregistry.h @@ -31,6 +31,7 @@ namespace KdeDGlobalAccel { class Component; + class KServiceActionComponent; } /** @@ -132,6 +133,8 @@ bool unregisterKey(int key, GlobalShortcut *shortcut); + void markComponentAsDisabled(KdeDGlobalAccel::KServiceActionComponent *component); + public Q_SLOTS: void clear(); diff --git a/src/runtime/globalshortcutsregistry.cpp b/src/runtime/globalshortcutsregistry.cpp --- a/src/runtime/globalshortcutsregistry.cpp +++ b/src/runtime/globalshortcutsregistry.cpp @@ -92,12 +92,17 @@ KdeDGlobalAccel::Component *GlobalShortcutsRegistry::addComponent(KdeDGlobalAccel::Component *component) { + qDebug() << component->uniqueName(); if (_components.value(component->uniqueName())) { + qDebug() << component->uniqueName(); Q_ASSERT_X(false, "GlobalShortcutsRegistry::addComponent", "component already registered?!?!"); return _components.value(component->uniqueName()); } - + KConfigGroup disabledGroup(&_config, "disabledComponents"); + auto disabledComponents = disabledGroup.readEntry("disabled", QStringList()); + disabledComponents.removeAll(component->uniqueName()); + disabledGroup.writeEntry("disabled",disabledComponents); _components.insert(component->uniqueName(), component); QDBusConnection conn(QDBusConnection::sessionBus()); @@ -262,6 +267,7 @@ void GlobalShortcutsRegistry::loadSettings() { const auto groupList = _config.groupList(); + auto disabledComponents = KConfigGroup(&_config, "disabledComponents").readEntry("disabled", QStringList()); for (const QString &groupName : groupList) { qCDebug(KGLOBALACCELD) << "Loading group " << groupName; @@ -321,14 +327,11 @@ const QStringList patterns = {QStringLiteral("*.desktop")}; const auto lstDesktopFiles = dir.entryList(patterns); for (const QString &desktopFile : lstDesktopFiles) { - if (_components.contains(desktopFile)) { + if (_components.contains(desktopFile) || disabledComponents.contains(desktopFile)) { continue; } KDesktopFile f(dir.filePath(desktopFile)); - if (f.noDisplay()) { - continue; - } KdeDGlobalAccel::KServiceActionComponent *component = new KdeDGlobalAccel::KServiceActionComponent( desktopFile, @@ -440,5 +443,13 @@ _config.sync(); } +void GlobalShortcutsRegistry::markComponentAsDisabled(KdeDGlobalAccel::KServiceActionComponent *component) +{ + KConfigGroup disabledGroup(&_config, "disabledComponents"); + auto disabledComponents = disabledGroup.readEntry("disabled", QStringList()); + disabledComponents.append(component->uniqueName()); + disabledGroup.writeEntry("disabled",disabledComponents); +} + #include "moc_globalshortcutsregistry.cpp" diff --git a/src/runtime/kserviceactioncomponent.cpp b/src/runtime/kserviceactioncomponent.cpp --- a/src/runtime/kserviceactioncomponent.cpp +++ b/src/runtime/kserviceactioncomponent.cpp @@ -19,6 +19,7 @@ #include "kserviceactioncomponent.h" #include "globalshortcutcontext.h" +#include "globalshortcutsregistry.h" #include "logging_p.h" #include @@ -140,10 +141,7 @@ for (GlobalShortcut *shortcut : shortcuts) { shortcut->setIsPresent(false); } - - m_desktopFile.desktopGroup().writeEntry("NoDisplay", true); - m_desktopFile.desktopGroup().sync(); - + GlobalShortcutsRegistry::self()->markComponentAsDisabled(this); return Component::cleanUp(); }