From 74772cd7a99d80669b42ec3bc8ece4c816784bae Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Thu, 23 May 2019 17:56:28 +0300 Subject: [PATCH] introduce SCROLLING options for Tasks --the user can now adjust the Scrolling options for its Tasks when the items overflow. The following are provided: Scrolling: ENABLE/DISABLE --Manual Scrolling: DISABLE/PARALLEL/HORIZONTALANDVERTICAL --Auto Scrolling: ENABLE/DISABLE BUG: 407779 --- containment/package/contents/config/main.xml | 13 ++- containment/package/contents/ui/main.qml | 5 +- liblatte2/types.h | 8 ++ plasmoid/package/contents/ui/main.qml | 5 +- .../package/contents/ui/task/TaskItem.qml | 49 +++++++--- .../ui/taskslayout/ScrollableList.qml | 2 +- .../configuration/pages/TasksConfig.qml | 95 ++++++++++++++++--- 7 files changed, 149 insertions(+), 28 deletions(-) diff --git a/containment/package/contents/config/main.xml b/containment/package/contents/config/main.xml index 73184e10a..ee2e16996 100644 --- a/containment/package/contents/config/main.xml +++ b/containment/package/contents/config/main.xml @@ -324,9 +324,20 @@ true - + false + + true + + + + + + + + 1 + true diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index 2df919110..cb83f2690 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -420,7 +420,10 @@ Item { property bool showAudioBadge: plasmoid.configuration.showAudioBadge property bool audioBadgeActionsEnabled: plasmoid.configuration.audioBadgeActionsEnabled - property bool scrollingTasksEnabled: plasmoid.configuration.scrollingTasksEnabled + property bool scrollTasksEnabled: plasmoid.configuration.scrollTasksEnabled + property bool autoScrollTasksEnabled: plasmoid.configuration.autoScrollTasksEnabled + property int manualScrollTasksType: plasmoid.configuration.manualScrollTasksType + property bool showWindowActions: plasmoid.configuration.showWindowActions property bool showWindowsOnlyFromLaunchers: plasmoid.configuration.showWindowsOnlyFromLaunchers property bool showOnlyCurrentScreen: plasmoid.configuration.showOnlyCurrentScreen diff --git a/liblatte2/types.h b/liblatte2/types.h index 7e819b45b..78e0e2d55 100644 --- a/liblatte2/types.h +++ b/liblatte2/types.h @@ -107,6 +107,14 @@ public: }; Q_ENUM(ClickAction); + enum ManualScrollType + { + ManualScrollDisabled = 0, + ManualScrollOnlyParallel, + ManualScrollVerticalHorizontal + }; + Q_ENUM(ManualScrollType); + enum ScrollAction { ScrollNone = 0, diff --git a/plasmoid/package/contents/ui/main.qml b/plasmoid/package/contents/ui/main.qml index e561ea264..948233231 100644 --- a/plasmoid/package/contents/ui/main.qml +++ b/plasmoid/package/contents/ui/main.qml @@ -169,7 +169,10 @@ Item { property bool mouseWheelActions: latteView ? latteView.mouseWheelActions : true property bool parabolicEffectEnabled: latteView ? latteView.parabolicEffectEnabled : zoomFactor>1 && !root.editMode - property bool scrollingEnabled: latteView ? latteView.scrollingTasksEnabled : false + property bool scrollingEnabled: latteView ? latteView.scrollTasksEnabled : false + property bool autoScrollTasksEnabled: latteView ? (scrollingEnabled && latteView.autoScrollTasksEnabled) : false + property bool manualScrollTasksEnabled: latteView ? (scrollingEnabled && manualScrollTasksType !== Latte.Types.ManualScrollDisabled) : Latte.Types.ManualScrollDisabled + property int manualScrollTasksType: latteView ? latteView.manualScrollTasksType : 0 property bool showInfoBadge: latteView ? latteView.showInfoBadge : plasmoid.configuration.showInfoBadge property bool showProgressBadge: latteView ? latteView.showProgressBadge : plasmoid.configuration.showInfoBadge diff --git a/plasmoid/package/contents/ui/task/TaskItem.qml b/plasmoid/package/contents/ui/task/TaskItem.qml index dbceede57..7ed8a8612 100644 --- a/plasmoid/package/contents/ui/task/TaskItem.qml +++ b/plasmoid/package/contents/ui/task/TaskItem.qml @@ -622,7 +622,9 @@ MouseArea{ } } - scrollableList.autoScrollFor(taskItem); + if (root.autoScrollTasksEnabled) { + scrollableList.autoScrollFor(taskItem); + } if (root.latteView && root.latteView.isHalfShown) { return; @@ -853,25 +855,43 @@ MouseArea{ } } - onWheel: { - if (isSeparator || !root.mouseWheelActions || wheelIsBlocked || inBouncingAnimation + onWheel: { + if (isSeparator + || wheelIsBlocked + || !(root.mouseWheelActions || manualScrollTasksEnabled) + || inBouncingAnimation || (latteView && (latteView.dockIsHidden || latteView.inSlidingIn || latteView.inSlidingOut))){ return; } - var angle = wheel.angleDelta.y / 8; + var angleVertical = wheel.angleDelta.y / 8; + var angleHorizontal = wheel.angleDelta.x / 8; wheelIsBlocked = true; scrollDelayer.start(); - //positive direction - if (angle > 12) { + var verticalDirection = (Math.abs(angleVertical) > Math.abs(angleHorizontal)); + var mainAngle = verticalDirection ? angleVertical : angleHorizontal; + + var positiveDirection = (mainAngle > 12); + var negativeDirection = (mainAngle < -12); + + var parallelScrolling = (verticalDirection && plasmoid.formFactor === PlasmaCore.Types.Vertical) + || (!verticalDirection && plasmoid.formFactor === PlasmaCore.Types.Horizontal); + + if (positiveDirection) { slotPublishGeometries(); - if (root.scrollingEnabled && scrollableList.contentsExceed) { + var overflowScrollingAccepted = (root.manualScrollTasksEnabled + && scrollableList.contentsExceed + && (root.manualScrollTasksType === Latte.Types.ManualScrollVerticalHorizontal + || (root.manualScrollTasksType === Latte.Types.ManualScrollOnlyParallel && parallelScrolling)) ); + + + if (overflowScrollingAccepted) { scrollableList.increasePos(); - } else { + } else if (root.mouseWheelActions){ if (isLauncher || root.disableAllWindowsFunctionality) { wrapper.runLauncherAnimation(); } else if (isGroupParent) { @@ -888,13 +908,18 @@ MouseArea{ hidePreviewWindow(); } - } else if (angle < -12) { + } else if (negativeDirection) { slotPublishGeometries(); - //negative direction - if (root.scrollingEnabled && scrollableList.contentsExceed) { + var overflowScrollingAccepted = (root.manualScrollTasksEnabled + && scrollableList.contentsExceed + && (root.manualScrollTasksType === Latte.Types.ManualScrollVerticalHorizontal + || (root.manualScrollTasksType === Latte.Types.ManualScrollOnlyParallel && parallelScrolling)) ); + + + if (overflowScrollingAccepted) { scrollableList.decreasePos(); - } else { + } else if (root.mouseWheelActions){ if (isLauncher || root.disableAllWindowsFunctionality) { // do nothing } else if (isGroupParent) { diff --git a/plasmoid/package/contents/ui/taskslayout/ScrollableList.qml b/plasmoid/package/contents/ui/taskslayout/ScrollableList.qml index 164ad0bfa..e4099993f 100644 --- a/plasmoid/package/contents/ui/taskslayout/ScrollableList.qml +++ b/plasmoid/package/contents/ui/taskslayout/ScrollableList.qml @@ -160,7 +160,7 @@ Flickable{ //! at the view boundaries, parabolic effect AND autoscroll at the //! boundaries create animation breakage - if (!contentsExceed || root.tasksCount < 3 + if (!root.autoScrollTasksEnabled || !contentsExceed || root.tasksCount < 3 || (task.itemIndex===parabolicManager.lastRealTaskIndex && root.zoomFactor>1)) { //last task with parabolic effect breaks the autoscolling behavior return; diff --git a/shell/package/contents/configuration/pages/TasksConfig.qml b/shell/package/contents/configuration/pages/TasksConfig.qml index defc80d18..4fa84070a 100644 --- a/shell/package/contents/configuration/pages/TasksConfig.qml +++ b/shell/package/contents/configuration/pages/TasksConfig.qml @@ -132,18 +132,6 @@ PlasmaComponents.Page { } } - LatteComponents.CheckBox { - Layout.maximumWidth: dialog.optionsWidth - text: i18n("Support scrolling when items overflow") - checked: plasmoid.configuration.scrollingTasksEnabled - tooltip: i18n("When items overflow the user is able to scroll between them.\nTake note that automatic icon decrease mechanism will be disabled.") - visible: dialog.highLevel - - onClicked: { - plasmoid.configuration.scrollingTasksEnabled = !plasmoid.configuration.scrollingTasksEnabled; - } - } - LatteComponents.CheckBox { id: windowActionsChk Layout.maximumWidth: dialog.optionsWidth @@ -325,6 +313,88 @@ PlasmaComponents.Page { } //! END: Launchers Group + //! BEGIN: Scrolling + ColumnLayout { + spacing: units.smallSpacing + visible: dialog.expertLevel + + LatteComponents.HeaderSwitch { + id: scrollingHeader + Layout.minimumWidth: dialog.optionsWidth + 2 *units.smallSpacing + Layout.maximumWidth: Layout.minimumWidth + Layout.minimumHeight: implicitHeight + Layout.bottomMargin: units.smallSpacing + enabled: Latte.WindowSystem.compositingActive + + checked: plasmoid.configuration.scrollTasksEnabled + text: i18n("Scrolling") + tooltip: i18n("Enable tasks scrolling when they overflow and exceed the available space"); + + onPressed: { + plasmoid.configuration.scrollTasksEnabled = !plasmoid.configuration.scrollTasksEnabled;; + } + } + + ColumnLayout { + Layout.leftMargin: units.smallSpacing * 2 + Layout.rightMargin: units.smallSpacing * 2 + spacing: 0 + enabled: scrollingHeader.checked + + GridLayout { + columns: 2 + Layout.minimumWidth: dialog.optionsWidth + Layout.maximumWidth: Layout.minimumWidth + + Layout.topMargin: units.smallSpacing + + PlasmaComponents.Label { + Layout.fillWidth: true + text: i18n("Manual") + } + + LatteComponents.ComboBox { + id: manualScrolling + Layout.minimumWidth: leftClickAction.width + Layout.maximumWidth: leftClickAction.width + model: [i18nc("disabled manual scrolling", "Disabled scrolling"), + dialog.panelIsVertical ? i18n("Only vertical scrolling") : i18n("Only horizontal scrolling"), + i18n("Horizonal and vertical scrolling")] + + currentIndex: plasmoid.configuration.manualScrollTasksType + onCurrentIndexChanged: plasmoid.configuration.manualScrollTasksType = currentIndex; + } + + PlasmaComponents.Label { + id: autoScrollText + Layout.fillWidth: true + text: i18n("Automatic") + } + + LatteComponents.ComboBox { + id: autoScrolling + Layout.minimumWidth: leftClickAction.width + Layout.maximumWidth: leftClickAction.width + model: [ + i18n("Disabled"), + i18n("Enabled") + ] + + currentIndex: plasmoid.configuration.autoScrollTasksEnabled + onCurrentIndexChanged: { + if (currentIndex === 0) { + plasmoid.configuration.autoScrollTasksEnabled = false; + } else { + plasmoid.configuration.autoScrollTasksEnabled = true; + } + } + } + } + } + } + //! END: Scolling + + //! BEGIN: Actions ColumnLayout { spacing: units.smallSpacing @@ -348,6 +418,7 @@ PlasmaComponents.Page { enabled: !disableAllWindowsFunctionality PlasmaComponents.Label { + id: leftClickLbl text: i18n("Left Click") }