Changeset View
Changeset View
Standalone View
Standalone View
src/runtime/globalshortcutsregistry.cpp
| Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Line(s) | 84 | for (const int key : listKeys) | |||
|---|---|---|---|---|---|
| 87 | } | 87 | } | ||
| 88 | } | 88 | } | ||
| 89 | _active_keys.clear(); | 89 | _active_keys.clear(); | ||
| 90 | } | 90 | } | ||
| 91 | 91 | | |||
| 92 | 92 | | |||
| 93 | KdeDGlobalAccel::Component *GlobalShortcutsRegistry::addComponent(KdeDGlobalAccel::Component *component) | 93 | KdeDGlobalAccel::Component *GlobalShortcutsRegistry::addComponent(KdeDGlobalAccel::Component *component) | ||
| 94 | { | 94 | { | ||
| 95 | qDebug() << component->uniqueName(); | ||||
meven: To remove | |||||
| 95 | if (_components.value(component->uniqueName())) | 96 | if (_components.value(component->uniqueName())) | ||
| 96 | { | 97 | { | ||
| 98 | qDebug() << component->uniqueName(); | ||||
meven: To remove | |||||
| 97 | Q_ASSERT_X(false, "GlobalShortcutsRegistry::addComponent", "component already registered?!?!"); | 99 | Q_ASSERT_X(false, "GlobalShortcutsRegistry::addComponent", "component already registered?!?!"); | ||
| 98 | return _components.value(component->uniqueName()); | 100 | return _components.value(component->uniqueName()); | ||
| 99 | } | 101 | } | ||
| 100 | 102 | KConfigGroup disabledGroup(&_config, "disabledComponents"); | |||
| 103 | auto disabledComponents = disabledGroup.readEntry("disabled", QStringList()); | ||||
| 104 | if (disabledComponents.contains(component->uniqueName())) { | ||||
| 105 | disabledComponents.removeAll(component->uniqueName()); | ||||
| 106 | disabledGroup.writeEntry("disabled",disabledComponents); | ||||
| 107 | _config.sync(); | ||||
| 108 | } | ||||
| 101 | _components.insert(component->uniqueName(), component); | 109 | _components.insert(component->uniqueName(), component); | ||
| 102 | QDBusConnection conn(QDBusConnection::sessionBus()); | 110 | QDBusConnection conn(QDBusConnection::sessionBus()); | ||
| 103 | 111 | | |||
| 104 | conn.registerObject( | 112 | conn.registerObject( | ||
| 105 | component->dbusPath().path(), | 113 | component->dbusPath().path(), | ||
| 106 | component, | 114 | component, | ||
| 107 | QDBusConnection::ExportScriptableContents); | 115 | QDBusConnection::ExportScriptableContents); | ||
| 108 | return component; | 116 | return component; | ||
| ▲ Show 20 Lines • Show All 148 Lines • ▼ Show 20 Line(s) | 248 | #endif | |||
| 257 | 265 | | |||
| 258 | return true; | 266 | return true; | ||
| 259 | } | 267 | } | ||
| 260 | 268 | | |||
| 261 | 269 | | |||
| 262 | void GlobalShortcutsRegistry::loadSettings() | 270 | void GlobalShortcutsRegistry::loadSettings() | ||
| 263 | { | 271 | { | ||
| 264 | const auto groupList = _config.groupList(); | 272 | const auto groupList = _config.groupList(); | ||
| 273 | auto disabledComponents = KConfigGroup(&_config, "disabledComponents").readEntry("disabled", QStringList()); | ||||
| 265 | for (const QString &groupName : groupList) | 274 | for (const QString &groupName : groupList) | ||
disabledComponents is the group name, right? It would also be part of groupList, so it would try to load it as shortcut... fvogt: `disabledComponents` is the group name, right? It would also be part of `groupList`, so it… | |||||
davidre: good point | |||||
| 266 | { | 275 | { | ||
| 276 | if (groupName == QLatin1String("disabledComponents")) { | ||||
| 277 | continue; | ||||
| 278 | } | ||||
| 267 | qCDebug(KGLOBALACCELD) << "Loading group " << groupName; | 279 | qCDebug(KGLOBALACCELD) << "Loading group " << groupName; | ||
| 268 | 280 | | |||
| 269 | Q_ASSERT(groupName.indexOf('\x1d')==-1); | 281 | Q_ASSERT(groupName.indexOf('\x1d')==-1); | ||
| 270 | 282 | | |||
| 271 | // loadSettings isn't designed to be called in between. Only at the | 283 | // loadSettings isn't designed to be called in between. Only at the | ||
| 272 | // beginning. | 284 | // beginning. | ||
| 273 | Q_ASSERT(!getComponent(groupName)); | 285 | Q_ASSERT(!getComponent(groupName)); | ||
| 274 | 286 | | |||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | |||||
| 316 | for (const QString &path : desktopPaths) { | 328 | for (const QString &path : desktopPaths) { | ||
| 317 | QDir dir(path); | 329 | QDir dir(path); | ||
| 318 | if (!dir.exists()) { | 330 | if (!dir.exists()) { | ||
| 319 | continue; | 331 | continue; | ||
| 320 | } | 332 | } | ||
| 321 | const QStringList patterns = {QStringLiteral("*.desktop")}; | 333 | const QStringList patterns = {QStringLiteral("*.desktop")}; | ||
| 322 | const auto lstDesktopFiles = dir.entryList(patterns); | 334 | const auto lstDesktopFiles = dir.entryList(patterns); | ||
| 323 | for (const QString &desktopFile : lstDesktopFiles) { | 335 | for (const QString &desktopFile : lstDesktopFiles) { | ||
| 324 | if (_components.contains(desktopFile)) { | 336 | if (_components.contains(desktopFile) || disabledComponents.contains(desktopFile)) { | ||
Is desktopFile the equivalent to component->uniqueName()? I would assume no, so this check might need to be moved after the KServiceActionComponent construction fvogt: Is `desktopFile` the equivalent to `component->uniqueName()`? I would assume no, so this check… | |||||
davidre: It actually is if you follow the constructor chain | |||||
| 325 | continue; | 337 | continue; | ||
| 326 | } | 338 | } | ||
| 327 | 339 | | |||
| 328 | KDesktopFile f(dir.filePath(desktopFile)); | 340 | KDesktopFile f(dir.filePath(desktopFile)); | ||
| 329 | if (f.noDisplay()) { | | |||
| 330 | continue; | | |||
| 331 | } | | |||
| 332 | 341 | | |||
| 333 | KdeDGlobalAccel::KServiceActionComponent *component = new KdeDGlobalAccel::KServiceActionComponent( | 342 | KdeDGlobalAccel::KServiceActionComponent *component = new KdeDGlobalAccel::KServiceActionComponent( | ||
| 334 | desktopFile, | 343 | desktopFile, | ||
| 335 | f.readName(), | 344 | f.readName(), | ||
| 336 | this); | 345 | this); | ||
| 337 | component->activateGlobalShortcutContext(QStringLiteral("default")); | 346 | component->activateGlobalShortcutContext(QStringLiteral("default")); | ||
| 338 | component->loadFromService(); | 347 | component->loadFromService(); | ||
| 339 | } | 348 | } | ||
| ▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Line(s) | 443 | else | |||
| 435 | { | 444 | { | ||
| 436 | component->writeSettings(configGroup); | 445 | component->writeSettings(configGroup); | ||
| 437 | } | 446 | } | ||
| 438 | } | 447 | } | ||
| 439 | 448 | | |||
| 440 | _config.sync(); | 449 | _config.sync(); | ||
| 441 | } | 450 | } | ||
| 442 | 451 | | |||
| 452 | void GlobalShortcutsRegistry::markComponentAsDisabled(KdeDGlobalAccel::KServiceActionComponent *component) | ||||
| 453 | { | ||||
| 454 | KConfigGroup disabledGroup(&_config, "disabledComponents"); | ||||
| 455 | auto disabledComponents = disabledGroup.readEntry("disabled", QStringList()); | ||||
| 456 | disabledComponents.append(component->uniqueName()); | ||||
| 457 | disabledGroup.writeEntry("disabled", disabledComponents); | ||||
| 458 | } | ||||
| 459 | | ||||
| 443 | 460 | | |||
| 444 | #include "moc_globalshortcutsregistry.cpp" | 461 | #include "moc_globalshortcutsregistry.cpp" | ||
To remove