Commit 7f78cc4f authored by Yari Polla's avatar Yari Polla Committed by Devin Lin
Browse files

taskswitcher: implement close all button

Hi, this implements a close all button for the task switcher.

Regarding the double check (`Clear All` -> `Are you sure?`), as far as I know, no system has such a feature for this kind of operation, at the moment, so take it as a proposal.
parent 5a9802ae
Pipeline #207461 passed with stage
in 1 minute and 14 seconds
......@@ -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
......
......@@ -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;
}
}
}
}
}
}
......
......@@ -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();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment