diff --git a/components/mobileshell/qml/taskswitcher/TaskList.qml b/components/mobileshell/qml/taskswitcher/TaskList.qml index 44baa94f5c0cc227c815f957aa6035d546b9bf72..2eaa55cd525904ed22e586ff8ee2a1ad73d2a62e 100644 --- a/components/mobileshell/qml/taskswitcher/TaskList.qml +++ b/components/mobileshell/qml/taskswitcher/TaskList.qml @@ -16,9 +16,20 @@ 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 + // 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; + 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 +37,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 @@ -69,16 +86,7 @@ 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: { - 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 diff --git a/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml b/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml index 806f2f844cac1ce58159c1a2cba4261ca795fdc7..8f98d7e2a516c7e03bea6d63330b15bd048bbbe3 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,41 @@ 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 + + opacity: taskSwitcherState.currentlyBeingOpened || taskSwitcherState.currentlyBeingClosed || !root.visible ? 0.0 : 1.0 + + Behavior on opacity { + NumberAnimation { + duration: PlasmaCore.Units.shortDuration + } + } + + icon.name: "edit-clear-history" + + text: closeRequested ? "Confirm Close All" : "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 0f5229a8702c8112e352bcc7478f0590ac1afda3..4e661f3a4351f076adb46cb4fd22334945393d20 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();