From c1bcd5c5ca5dc040f5afd287e3dcee7df8f990db Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sun, 3 Feb 2019 18:49:28 +0200 Subject: [PATCH] improvements for global shortcuts based on position BUG: 403880 --- app/shortcuts/globalshortcuts.cpp | 35 ++++++++++--------- .../configuration/pages/BehaviorConfig.qml | 26 +++++++------- .../configuration/pages/TasksConfig.qml | 2 +- 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/app/shortcuts/globalshortcuts.cpp b/app/shortcuts/globalshortcuts.cpp index eb1274254..39c36b14f 100644 --- a/app/shortcuts/globalshortcuts.cpp +++ b/app/shortcuts/globalshortcuts.cpp @@ -372,22 +372,25 @@ void GlobalShortcuts::activateEntry(int index, Qt::Key modifier) QList sortedViews = sortedViewsList(m_corona->layoutManager()->currentLatteViews()); - if (m_shortcutsTracker->basedOnPositionEnabled()){ - foreach (auto view, sortedViews) { - if ((!view->latteTasksPresent() && view->tasksPresent() && - activatePlasmaTaskManagerEntryAtContainment(view->containment(), index, modifier)) - || activateLatteEntryAtContainment(view, index, modifier)) { + foreach (auto view, sortedViews) { + if (!view->isPreferredForShortcuts()) { + continue; + } - if (!m_hideViews.contains(view)) { - m_hideViews.append(view); - } + if ((!view->latteTasksPresent() && view->tasksPresent() && + activatePlasmaTaskManagerEntryAtContainment(view->containment(), index, modifier)) + || activateLatteEntryAtContainment(view, index, modifier)) { - view->visibility()->setBlockHiding(true); - m_hideViewsTimer.start(); - return; + if (!m_hideViews.contains(view)) { + m_hideViews.append(view); } + + view->visibility()->setBlockHiding(true); + m_hideViewsTimer.start(); + return; } } + } //! update badge for specific view item @@ -593,12 +596,10 @@ void GlobalShortcuts::showViews() Latte::View *viewWithTasks{nullptr}; Latte::View *viewWithMeta{nullptr}; - if (m_shortcutsTracker->basedOnPositionEnabled()) { - foreach (auto view, sortedViews) { - if (!viewWithTasks && isCapableToShowShortcutBadges(view)) { - viewWithTasks = view; - break; - } + foreach (auto view, sortedViews) { + if (!viewWithTasks && view->isPreferredForShortcuts() && isCapableToShowShortcutBadges(view)) { + viewWithTasks = view; + break; } } diff --git a/shell/package/contents/configuration/pages/BehaviorConfig.qml b/shell/package/contents/configuration/pages/BehaviorConfig.qml index 9b123877a..ccb256cdc 100644 --- a/shell/package/contents/configuration/pages/BehaviorConfig.qml +++ b/shell/package/contents/configuration/pages/BehaviorConfig.qml @@ -541,6 +541,19 @@ PlasmaComponents.Page { } } + PlasmaComponents.CheckBox { + Layout.leftMargin: units.smallSpacing * 2 + text: i18n("Activate based on position through global shortcuts") + checked: latteView.isPreferredForShortcuts + //enabled: shortcutsEngine.basedOnPositionEnabled + + tooltip: i18n("This view is used for based on position global shortcuts. Take note that only one view can have that option enabled for each layout") + + onClicked: { + latteView.isPreferredForShortcuts = checked + } + } + PlasmaComponents.CheckBox { Layout.leftMargin: units.smallSpacing * 2 text: i18n("Decrease size automatically when needed") @@ -576,19 +589,6 @@ PlasmaComponents.Page { } } - PlasmaComponents.CheckBox { - Layout.leftMargin: units.smallSpacing * 2 - text: i18n("Prefer for based on position global shortcuts") - checked: latteView.isPreferredForShortcuts - enabled: shortcutsEngine.basedOnPositionEnabled - - tooltip: i18n("This view is preferred to use the based on position global shortcuts. Take note that only one view can have that option enabled for each layout") - - onClicked: { - latteView.isPreferredForShortcuts = checked - } - } - PlasmaComponents.CheckBox { Layout.leftMargin: units.smallSpacing * 2 text: i18n("Can be above fullscreen windows") diff --git a/shell/package/contents/configuration/pages/TasksConfig.qml b/shell/package/contents/configuration/pages/TasksConfig.qml index 5c9b329b1..80c2e25d3 100644 --- a/shell/package/contents/configuration/pages/TasksConfig.qml +++ b/shell/package/contents/configuration/pages/TasksConfig.qml @@ -172,7 +172,7 @@ PlasmaComponents.Page { checked: !plasmoid.configuration.unifiedGlobalShortcuts tooltip: i18n("Based on position global shortcuts are enabled only for tasks and not for applets") visible: dialog.highLevel - enabled: shortcutsEngine.basedOnPositionEnabled + enabled: latteView.isPreferredForShortcuts onClicked: { plasmoid.configuration.unifiedGlobalShortcuts = !checked