From ef7a78cfe1b1c55805251895514e74d6cdfcb0c8 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 31 Jul 2020 14:20:55 +0200 Subject: [PATCH] single mousearea on bottom --- .../taskpanel/package/contents/ui/Button.qml | 21 +++---- .../taskpanel/package/contents/ui/main.qml | 60 +++++++++---------- 2 files changed, 36 insertions(+), 45 deletions(-) diff --git a/containments/taskpanel/package/contents/ui/Button.qml b/containments/taskpanel/package/contents/ui/Button.qml index 21cfae2..aac2e3a 100644 --- a/containments/taskpanel/package/contents/ui/Button.qml +++ b/containments/taskpanel/package/contents/ui/Button.qml @@ -24,22 +24,24 @@ import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.kquickcontrolsaddons 2.0 -MouseArea { +Item { id: button width: Math.min(parent.width, parent.height) height: width + property MouseArea mouseArea + readonly property bool pressed: mouseArea.pressed && mouseArea.activeButton == button property alias iconSource: icon.source - property bool checked - property bool checkable - property bool clickable + signal clicked() + Rectangle { radius: height/2 anchors.fill: parent - opacity: button.pressed && button.containsMouse && button.clickable ? 0.1 : 0 + opacity: button.pressed && button.enabled ? 0.1 : 0 color: PlasmaCore.ColorScope.textColor Behavior on opacity { - OpacityAnimator { + //an OpacityAnimator causes stuttering in task switcher dragging + NumberAnimation { duration: units.longDuration easing.type: Easing.InOutQuad } @@ -49,11 +51,6 @@ MouseArea { id: icon anchors.fill: parent colorGroup: PlasmaCore.ColorScope.colorGroup - enabled: button.enabled && button.clickable - } - onClicked: { - if (checkable) { - checked = !checked; - } + //enabled: button.enabled && button.clickable } } diff --git a/containments/taskpanel/package/contents/ui/main.qml b/containments/taskpanel/package/contents/ui/main.qml index 4fbcc39..8a90387 100644 --- a/containments/taskpanel/package/contents/ui/main.qml +++ b/containments/taskpanel/package/contents/ui/main.qml @@ -110,12 +110,18 @@ PlasmaCore.ColorScope { property bool isDragging: false property bool opening: false drag.filterChildren: true - function managePressed(mouse) { + property Button activeButton + + onPressed: { startMouseY = oldMouseY = mouse.y; - taskSwitcher.offset = -taskSwitcher.height + taskSwitcher.offset = -taskSwitcher.height; + activeButton = icons.childAt(mouse.x, mouse.y); } - onPressed: managePressed(mouse); onPositionChanged: { + let newButton = icons.childAt(mouse.x, mouse.y); + if (newButton != activeButton) { + activeButton = null; + } if (!isDragging && Math.abs(startMouseY - oldMouseY) < root.height) { oldMouseY = mouse.y; return; @@ -127,6 +133,7 @@ PlasmaCore.ColorScope { opening = oldMouseY > mouse.y; if (taskSwitcher.visibility == Window.Hidden && taskSwitcher.offset > -taskSwitcher.height + units.gridUnit && taskSwitcher.tasksCount) { + activeButton = null; taskSwitcher.showFullScreen(); //no tasks, let's scroll up the homescreen instead } else if (taskSwitcher.tasksCount === 0) { @@ -135,16 +142,21 @@ PlasmaCore.ColorScope { oldMouseY = mouse.y; } onReleased: { - if (!isDragging) { - return; - } - if (taskSwitcher.visibility == Window.Hidden) { if (taskSwitcher.tasksCount === 0) { MobileShell.HomeScreenControls.snapHomeScreenPosition(); } + + if (activeButton) { + activeButton.clicked(); + } return; } + + if (!isDragging) { + return; + } + if (opening) { taskSwitcher.show(); } else { @@ -187,19 +199,16 @@ PlasmaCore.ColorScope { anchors.left: parent.left height: parent.height width: parent.width/3 + mouseArea: mainMouseArea enabled: root.hasTasks - clickable: root.hasTasks && !taskSwitcher.visible iconSource: "box" onClicked: { - if (!clickable) { + if (!enabled) { return; } plasmoid.nativeInterface.showDesktop = false; taskSwitcher.visible ? taskSwitcher.hide() : taskSwitcher.show(); } - onPressed: mainMouseArea.managePressed(mouse); - onPositionChanged: mainMouseArea.positionChanged(mouse); - onReleased: mainMouseArea.released(mouse); } Button { @@ -207,28 +216,16 @@ PlasmaCore.ColorScope { height: parent.height width: parent.width/3 anchors.horizontalCenter: parent.horizontalCenter + mouseArea: mainMouseArea iconSource: "start-here-kde" - clickable: !taskSwitcher.visible && (root.showingApp || MobileShell.HomeScreenControls.homeScreenPosition != 0) - //checkable: true + enabled: !taskSwitcher.visible && (root.showingApp || MobileShell.HomeScreenControls.homeScreenPosition != 0) onClicked: { - if (!clickable) { + if (!enabled) { return; } root.minimizeAll(); MobileShell.HomeScreenControls.resetHomeScreenPosition(); plasmoid.nativeInterface.allMinimizedChanged(); - //plasmoid.nativeInterface.showDesktop = checked; - } - onPressed: mainMouseArea.managePressed(mouse); - onPositionChanged: mainMouseArea.positionChanged(mouse); - onReleased: mainMouseArea.released(mouse); - Connections { - target: root.taskSwitcher - onCurrentTaskIndexChanged: { - if (root.taskSwitcher.currentTaskIndex < 0) { - showDesktopButton.checked = false; - } - } } } @@ -236,11 +233,11 @@ PlasmaCore.ColorScope { height: parent.height width: parent.width/3 anchors.right: parent.right + mouseArea: mainMouseArea iconSource: "paint-none" - //FIXME:Qt.UserRole+9 is IsWindow Qt.UserRole+15 is IsClosable. We can't reach that enum from QML - clickable: plasmoid.nativeInterface.hasCloseableActiveWindow && !taskSwitcher.visible + enabled: plasmoid.nativeInterface.hasCloseableActiveWindow && !taskSwitcher.visible onClicked: { - if (!clickable) { + if (!enabled) { return; } if (!plasmoid.nativeInterface.hasCloseableActiveWindow) { @@ -251,9 +248,6 @@ PlasmaCore.ColorScope { taskSwitcher.model.requestClose(index); } } - onPressed: mainMouseArea.managePressed(mouse); - onPositionChanged: mainMouseArea.positionChanged(mouse); - onReleased: mainMouseArea.released(mouse); } } } -- GitLab