From 5061ac249fa78d6b64e0b07de187508ca1c5a3e4 Mon Sep 17 00:00:00 2001 From: Yari Polla Date: Thu, 14 Jul 2022 16:52:23 +0200 Subject: [PATCH 1/6] taskswitcher/tasklist: avoid recalculating task y every time a task is created and implement closeAll function --- .../mobileshell/qml/taskswitcher/TaskList.qml | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/components/mobileshell/qml/taskswitcher/TaskList.qml b/components/mobileshell/qml/taskswitcher/TaskList.qml index 44baa94f5..6a977258d 100644 --- a/components/mobileshell/qml/taskswitcher/TaskList.qml +++ b/components/mobileshell/qml/taskswitcher/TaskList.qml @@ -16,9 +16,19 @@ import org.kde.plasma.private.mobileshell 1.0 as MobileShell Item { id: root - required property var taskSwitcher + required property var taskSwitcher readonly property var taskSwitcherState: taskSwitcher.taskSwitcherState + readonly property real taskY: { + let headerHeight = MobileShell.Shell.topMargin; + let footerHeight = MobileShell.Shell.bottomMargin; + let diff = headerHeight - footerHeight; + + let baseY = (taskSwitcher.height / 2) - (taskSwitcherState.taskHeight / 2) - (taskSwitcherState.taskHeaderHeight / 2) + + return baseY + diff / 2 - MobileShell.TopPanelControls.panelHeight; + } + transform: Scale { origin.x: root.width / 2 origin.y: root.height / 2 @@ -26,6 +36,12 @@ Item { yScale: taskSwitcherState.currentScale } + function closeAll() { + for (var i = 0; i < repeater.count; i++) { + repeater.itemAt(i).closeApp(); + } + } + // taphandler activates even if delegate touched TapHandler { enabled: !taskSwitcherState.currentlyBeingOpened @@ -70,15 +86,7 @@ Item { x: listX + repeater.leftMargin - taskSwitcherState.xPosition // account for system header and footer offset (center the preview image) - y: { - let headerHeight = MobileShell.Shell.topMargin; - let footerHeight = MobileShell.Shell.bottomMargin; - let diff = headerHeight - footerHeight; - - let baseY = (taskSwitcher.height / 2) - (height / 2) - (taskSwitcherState.taskHeaderHeight / 2) - - return baseY + diff / 2 - MobileShell.TopPanelControls.panelHeight; - } + y: root.taskY // ensure current task is above others z: taskSwitcherState.currentTaskIndex === currentIndex ? 1 : 0 -- GitLab From 0942762ab84c8d2b44db29e8610bc3f53e6b1ec9 Mon Sep 17 00:00:00 2001 From: Yari Polla Date: Thu, 14 Jul 2022 16:52:30 +0200 Subject: [PATCH 2/6] taskswitcher: add button to close all the opened tasks --- .../qml/taskswitcher/TaskSwitcher.qml | 37 +++++++++++++++++++ .../qml/taskswitcher/TaskSwitcherState.qml | 6 +++ 2 files changed, 43 insertions(+) diff --git a/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml b/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml index 806f2f844..8eae4f228 100644 --- a/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml +++ b/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml @@ -115,6 +115,7 @@ Item { function instantHide() { opacity = 0; visible = false; + closeAllButton.closeRequested = false; } function hide() { @@ -171,9 +172,11 @@ Item { to: 0 duration: PlasmaCore.Units.shortDuration easing.type: Easing.InOutQuad + onFinished: { root.visible = false; tasksModel.taskReorderingEnabled = true; + closeAllButton.closeRequested = false; } } @@ -204,11 +207,15 @@ Item { FlickContainer { id: flickable + anchors.fill: parent + taskSwitcherState: root.taskSwitcherState // the item is effectively anchored to the flickable bounds TaskList { + id: taskList + taskSwitcher: root opacity: { @@ -223,6 +230,36 @@ Item { x: flickable.contentX width: flickable.width height: flickable.height + + PlasmaComponents.ToolButton { + id: closeAllButton + + property bool closeRequested: false + + anchors { + bottom: parent.bottom + bottomMargin: taskList.taskY / 2 + horizontalCenter: parent.horizontalCenter + } + + PlasmaCore.ColorScope.colorGroup: PlasmaCore.Theme.ComplementaryColorGroup + PlasmaCore.ColorScope.inherit: false + + visible: !taskSwitcherState.currentlyBeingOpened && !taskSwitcherState.currentlyBeingClosed + + icon.name: "edit-clear-history" + + font.pointSize: PlasmaCore.Theme.defaultFont.pointSize * 1.5 + text: closeRequested ? "Are you sure?" : "Close All" + + onClicked: { + if (closeRequested) { + taskList.closeAll(); + } else { + closeRequested = true; + } + } + } } } } diff --git a/components/mobileshell/qml/taskswitcher/TaskSwitcherState.qml b/components/mobileshell/qml/taskswitcher/TaskSwitcherState.qml index 0f5229a87..4e661f3a4 100644 --- a/components/mobileshell/qml/taskswitcher/TaskSwitcherState.qml +++ b/components/mobileshell/qml/taskswitcher/TaskSwitcherState.qml @@ -62,6 +62,9 @@ QtObject { // whether we are in a swipe up gesture to open the task switcher property bool currentlyBeingOpened: false + // whether the task switcher is being closed: an animation is running + property bool currentlyBeingClosed: false + // whether we are in a swipe left/right gesture to walk through tasks property bool scrollingTasks: false @@ -237,7 +240,10 @@ QtObject { duration: MobileShell.MobileShellSettings.animationsEnabled ? 300 : 0 easing.type: Easing.OutQuint + onStarted: root.currentlyBeingClosed = true + onFinished: { + root.currentlyBeingClosed = false; root.currentlyBeingOpened = false; taskSwitcher.setSingleActiveWindow(root.currentTaskIndex); taskSwitcher.instantHide(); -- GitLab From 110a798ae5204a5c7189e7c8a3413559069d861b Mon Sep 17 00:00:00 2001 From: Yari Polla Date: Thu, 14 Jul 2022 22:34:21 +0200 Subject: [PATCH 3/6] taskswitcher: fix icon size and text in close all button --- components/mobileshell/qml/taskswitcher/TaskSwitcher.qml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml b/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml index 8eae4f228..ff7d8ec0a 100644 --- a/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml +++ b/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml @@ -248,9 +248,11 @@ Item { visible: !taskSwitcherState.currentlyBeingOpened && !taskSwitcherState.currentlyBeingClosed icon.name: "edit-clear-history" + icon.height: PlasmaCore.Units.iconSizes.medium + icon.width: PlasmaCore.Units.iconSizes.medium font.pointSize: PlasmaCore.Theme.defaultFont.pointSize * 1.5 - text: closeRequested ? "Are you sure?" : "Close All" + text: closeRequested ? "Tap one more time to close all" : "Close All" onClicked: { if (closeRequested) { -- GitLab From a2515cc5f21c1fd083caf6317e76360162e30391 Mon Sep 17 00:00:00 2001 From: Yari Polla Date: Wed, 20 Jul 2022 14:53:40 +0200 Subject: [PATCH 4/6] taskswitcher: minor changes --- .../mobileshell/qml/taskswitcher/TaskSwitcher.qml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml b/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml index ff7d8ec0a..15ae292b7 100644 --- a/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml +++ b/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml @@ -245,14 +245,20 @@ Item { PlasmaCore.ColorScope.colorGroup: PlasmaCore.Theme.ComplementaryColorGroup PlasmaCore.ColorScope.inherit: false - visible: !taskSwitcherState.currentlyBeingOpened && !taskSwitcherState.currentlyBeingClosed + opacity: taskSwitcherState.currentlyBeingOpened || taskSwitcherState.currentlyBeingClosed || !root.visible ? 0.0 : 1.0 + + Behavior on opacity { + NumberAnimation { + duration: PlasmaCore.Units.shortDuration + } + } icon.name: "edit-clear-history" icon.height: PlasmaCore.Units.iconSizes.medium icon.width: PlasmaCore.Units.iconSizes.medium font.pointSize: PlasmaCore.Theme.defaultFont.pointSize * 1.5 - text: closeRequested ? "Tap one more time to close all" : "Close All" + text: closeRequested ? "Confirm Close All" : "Close All" onClicked: { if (closeRequested) { -- GitLab From 93fe69692267fde249bd149eb7ed77aaca020bf1 Mon Sep 17 00:00:00 2001 From: Yari Polla Date: Wed, 20 Jul 2022 14:56:41 +0200 Subject: [PATCH 5/6] taskswitcher: add comment --- components/mobileshell/qml/taskswitcher/TaskList.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mobileshell/qml/taskswitcher/TaskList.qml b/components/mobileshell/qml/taskswitcher/TaskList.qml index 6a977258d..2eaa55cd5 100644 --- a/components/mobileshell/qml/taskswitcher/TaskList.qml +++ b/components/mobileshell/qml/taskswitcher/TaskList.qml @@ -19,6 +19,7 @@ Item { required property var taskSwitcher readonly property var taskSwitcherState: taskSwitcher.taskSwitcherState + // account for system header and footer offset (center the preview image) readonly property real taskY: { let headerHeight = MobileShell.Shell.topMargin; let footerHeight = MobileShell.Shell.bottomMargin; @@ -85,7 +86,6 @@ Item { // this is the actual displayed x-position on screen x: listX + repeater.leftMargin - taskSwitcherState.xPosition - // account for system header and footer offset (center the preview image) y: root.taskY // ensure current task is above others -- GitLab From 1794d77b3197dbc8c6d8f754f7858ecee2278320 Mon Sep 17 00:00:00 2001 From: Yari Polla Date: Thu, 21 Jul 2022 13:26:07 +0200 Subject: [PATCH 6/6] taskswitcher: re-fix icon and font size --- components/mobileshell/qml/taskswitcher/TaskSwitcher.qml | 3 --- 1 file changed, 3 deletions(-) diff --git a/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml b/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml index 15ae292b7..8f98d7e2a 100644 --- a/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml +++ b/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml @@ -254,10 +254,7 @@ Item { } icon.name: "edit-clear-history" - icon.height: PlasmaCore.Units.iconSizes.medium - icon.width: PlasmaCore.Units.iconSizes.medium - font.pointSize: PlasmaCore.Theme.defaultFont.pointSize * 1.5 text: closeRequested ? "Confirm Close All" : "Close All" onClicked: { -- GitLab