From 05bc900a6d5bdc3b23fd2a2167fd94b7a3034378 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Fri, 22 May 2020 21:23:14 +0300 Subject: [PATCH] fix multiTasks global shortcuts on position --multi Tasks now work properly with global shortcuts on position even when only one of them is stealing them for its own use. --- .../package/contents/ui/applet/AppletItem.qml | 8 ++++++++ .../abilities/applets/PositionShortcuts.qml | 9 +++++++++ .../contents/ui/abilities/PositionShortcuts.qml | 10 ++++++++++ .../package/contents/ui/task/ShortcutBadge.qml | 8 +++++--- plasmoid/package/contents/ui/task/TaskItem.qml | 16 ++++++++++++---- 5 files changed, 44 insertions(+), 7 deletions(-) diff --git a/containment/package/contents/ui/applet/AppletItem.qml b/containment/package/contents/ui/applet/AppletItem.qml index bdbbea633..a54fed301 100644 --- a/containment/package/contents/ui/applet/AppletItem.qml +++ b/containment/package/contents/ui/applet/AppletItem.qml @@ -616,6 +616,10 @@ Item { target: appletItem.shortcuts onSglActivateEntryAtIndex: { + if (!appletItem.shortcuts.unifiedGlobalShortcuts) { + return; + } + var visibleIndex = appletItem.indexer.visibleIndex(appletItem.index); if (visibleIndex === entryIndex && !communicator.positionShortcutsAreSupported) { @@ -624,6 +628,10 @@ Item { } onSglNewInstanceForEntryAtIndex: { + if (!appletItem.shortcuts.unifiedGlobalShortcuts) { + return; + } + var visibleIndex = appletItem.indexer.visibleIndex(appletItem.index); if (visibleIndex === entryIndex && !communicator.positionShortcutsAreSupported) { diff --git a/declarativeimports/abilities/applets/PositionShortcuts.qml b/declarativeimports/abilities/applets/PositionShortcuts.qml index 164d37e08..c9b67b275 100644 --- a/declarativeimports/abilities/applets/PositionShortcuts.qml +++ b/declarativeimports/abilities/applets/PositionShortcuts.qml @@ -29,6 +29,15 @@ AbilityDefinition.PositionShortcuts { property bool isStealingGlobalPositionShortcuts: false readonly property bool showPositionShortcutBadges: ref.shortcuts.showPositionShortcutBadges + readonly property bool isEnabled: { + if (bridge) { + return bridge.shortcuts.host.unifiedGlobalShortcuts + || (!bridge.shortcuts.host.unifiedGlobalShortcuts && bridge.shortcuts.appletIndex === bridge.shortcuts.host.appletIdStealingPositionShortcuts); + } + + return true; + } + signal disabledIsStealingGlobalPositionShortcuts(); Item { diff --git a/plasmoid/package/contents/ui/abilities/PositionShortcuts.qml b/plasmoid/package/contents/ui/abilities/PositionShortcuts.qml index c975b60d3..6aa3c8a73 100644 --- a/plasmoid/package/contents/ui/abilities/PositionShortcuts.qml +++ b/plasmoid/package/contents/ui/abilities/PositionShortcuts.qml @@ -26,4 +26,14 @@ import org.kde.latte.abilities.applets 0.1 as AppletAbility AppletAbility.PositionShortcuts { id: shortcuts + + function shortcutIndex(entryIndex) { + if (!bridge) { + return indexer.visibleIndex(entryIndex); + } + + var base = bridge.indexer.host.visibleIndex(bridge.shortcuts.appletIndex); + + return (indexer.visibleIndex(entryIndex) - base); + } } diff --git a/plasmoid/package/contents/ui/task/ShortcutBadge.qml b/plasmoid/package/contents/ui/task/ShortcutBadge.qml index 938c5f861..d3a03fe78 100644 --- a/plasmoid/package/contents/ui/task/ShortcutBadge.qml +++ b/plasmoid/package/contents/ui/task/ShortcutBadge.qml @@ -25,7 +25,7 @@ import org.kde.latte.components 1.0 as LatteComponents Loader{ id: shorcutBadge anchors.fill: iconImageBuffer - active: taskItem.shortcuts.showPositionShortcutBadges && !taskItem.isSeparator && !taskItem.isHidden + active: taskItem.shortcuts.showPositionShortcutBadges && !taskItem.isSeparator && !taskItem.isHidden && taskItem.shortcuts.isEnabled asynchronous: true visible: badgeString !== "" @@ -35,14 +35,16 @@ Loader{ onActiveChanged: { if (active && taskItem.shortcuts.showPositionShortcutBadges) { - fixedIndex = taskItem.indexer.visibleIndex(taskItem.itemIndex); + fixedIndex = taskItem.shortcuts.shortcutIndex(taskItem.itemIndex); } else { fixedIndex = -1; } } Component.onCompleted: { - fixedIndex = taskItem.indexer.visibleIndex(taskItem.itemIndex); + if (taskItem.shortcuts.isEnabled) { + fixedIndex = taskItem.shortcuts.shortcutIndex(taskItem.itemIndex); + } } sourceComponent: Item{ diff --git a/plasmoid/package/contents/ui/task/TaskItem.qml b/plasmoid/package/contents/ui/task/TaskItem.qml index 75499a7fd..55e7ce747 100644 --- a/plasmoid/package/contents/ui/task/TaskItem.qml +++ b/plasmoid/package/contents/ui/task/TaskItem.qml @@ -1456,9 +1456,13 @@ MouseArea{ Connections { target: shortcuts onSglActivateEntryAtIndex: { - var visibleIndex = taskItem.indexer.visibleIndex(taskItem.itemIndex); + if (!taskItem.shortcuts.isEnabled) { + return; + } + + var shortcutIndex = taskItem.shortcuts.shortcutIndex(taskItem.itemIndex); - if (visibleIndex === entryIndex) { + if (shortcutIndex === entryIndex) { if (taskItem.isGroupParent) { taskItem.activateNextTask(); } else { @@ -1468,9 +1472,13 @@ MouseArea{ } onSglNewInstanceForEntryAtIndex: { - var visibleIndex = taskItem.indexer.visibleIndex(taskItem.itemIndex); + if (!taskItem.shortcuts.isEnabled) { + return; + } + + var shortcutIndex = taskItem.shortcuts.shortcutIndex(taskItem.itemIndex); - if (visibleIndex === entryIndex) { + if (shortcutIndex === entryIndex) { tasksModel.requestNewInstance(taskItem.modelIndex()); } }