[plasma/plasma-desktop] applets/taskmanager: applets/taskmanager: Consolidate Meta+1–9 shortcuts into Backend
Méven Car <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 8cdade3d2d972b53ca01c50efe99d97a36fb7fb6 by Méven Car, on behalf of Salman Farooq.
Committed on 21/07/2026 at 12:49.
Pushed by ngraham into branch 'master'.
applets/taskmanager: Consolidate Meta+1–9 shortcuts into Backend
Move the Meta+1–9 shortcut registration into Backend::setupShortcuts(),
alongside the cycling and move shortcuts added in d29361ea.
The dispatch now uses the same priority order as the other task
shortcuts, preferring a non-screen-filtered taskbar with the active task,
then a screen-filtered one, with a last fallback that lets Meta+number
launch pinned apps even when no task is active.
Shortcut action IDs are preserved ("activate task manager entry 1"
through "10"), so existing user customizations in kglobalshortcutsrc
continue to work.
Part of the decoupling from shellcorona described in the companion MR:
plasma-workspace!6848.
M +34 -1 applets/taskmanager/backend.cpp
https://invent.kde.org/plasma/plasma-desktop/-/commit/8cdade3d2d972b53ca01c50efe99d97a36fb7fb6
diff --git a/applets/taskmanager/backend.cpp b/applets/taskmanager/backend.cpp
index 8536f45327..8d68e41065 100644
--- a/applets/taskmanager/backend.cpp
+++ b/applets/taskmanager/backend.cpp
@@ -604,6 +604,18 @@ void Backend::setupShortcuts()
moveTaskForwardAction->setText(i18n("Move Active Task Manager Entry Forward"));
KGlobalAccel::self()->setGlobalShortcut(moveTaskForwardAction,
QList<QKeySequence>() << QKeySequence(Qt::META | Qt::CTRL | Qt::SHIFT | Qt::Key_PageDown));
+
+ for (int i = 0; i < 10; ++i) {
+ const int entryNumber = i + 1;
+ const auto key = static_cast<Qt::Key>(Qt::Key_0 + (entryNumber % 10));
+
+ QAction *action = collection->addAction(QStringLiteral("activate task manager entry %1").arg(QString::number(entryNumber)));
+ action->setText(i18n("Activate Task Manager Entry %1", entryNumber));
+ KGlobalAccel::setGlobalShortcut(action, entryNumber < 10 ? QKeySequence(Qt::META | key) : QKeySequence());
+ QObject::connect(action, &QAction::triggered, collection, [i](bool) {
+ dispatchActivateTaskAtIndex(i);
+ });
+ }
});
}
@@ -635,8 +647,29 @@ Backend *Backend::findTargetBackend()
void Backend::dispatchActivateTaskAtIndex(int index)
{
+ // Prefer the same priority order as the other task shortcuts:
+ // 1. Non-screen-filtered taskbar with the active task
+ // 2. Screen-filtered taskbar with the active task
+ if (auto *target = findTargetBackend()) {
+ Q_EMIT target->activateTaskAtIndexRequested(index);
+ return;
+ }
+
+ // If no task is active on any taskmanager (e.g. the user wants to
+ // launch a pinned app), fallback: prefer a non-screen-filtered
+ // instance, then the first available instance.
+ Backend *fallback = nullptr;
for (auto *instance : std::as_const(s_instances)) {
- Q_EMIT instance->activateTaskAtIndexRequested(index);
+ if (!instance->m_showsOnlyCurrentScreen) {
+ Q_EMIT instance->activateTaskAtIndexRequested(index);
+ return;
+ }
+ if (!fallback) {
+ fallback = instance;
+ }
+ }
+ if (fallback) {
+ Q_EMIT fallback->activateTaskAtIndexRequested(index);
}
}