mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-08-02 09:48:50 +00:00
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.
This commit is contained in:
parent
5a9802ae5f
commit
7f78cc4ff6
3 changed files with 67 additions and 11 deletions
|
|
@ -19,6 +19,17 @@ Item {
|
||||||
required property var taskSwitcher
|
required property var taskSwitcher
|
||||||
readonly property var taskSwitcherState: taskSwitcher.taskSwitcherState
|
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 {
|
transform: Scale {
|
||||||
origin.x: root.width / 2
|
origin.x: root.width / 2
|
||||||
origin.y: root.height / 2
|
origin.y: root.height / 2
|
||||||
|
|
@ -26,6 +37,12 @@ Item {
|
||||||
yScale: taskSwitcherState.currentScale
|
yScale: taskSwitcherState.currentScale
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function closeAll() {
|
||||||
|
for (var i = 0; i < repeater.count; i++) {
|
||||||
|
repeater.itemAt(i).closeApp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// taphandler activates even if delegate touched
|
// taphandler activates even if delegate touched
|
||||||
TapHandler {
|
TapHandler {
|
||||||
enabled: !taskSwitcherState.currentlyBeingOpened
|
enabled: !taskSwitcherState.currentlyBeingOpened
|
||||||
|
|
@ -69,16 +86,7 @@ Item {
|
||||||
// this is the actual displayed x-position on screen
|
// this is the actual displayed x-position on screen
|
||||||
x: listX + repeater.leftMargin - taskSwitcherState.xPosition
|
x: listX + repeater.leftMargin - taskSwitcherState.xPosition
|
||||||
|
|
||||||
// account for system header and footer offset (center the preview image)
|
y: root.taskY
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ensure current task is above others
|
// ensure current task is above others
|
||||||
z: taskSwitcherState.currentTaskIndex === currentIndex ? 1 : 0
|
z: taskSwitcherState.currentTaskIndex === currentIndex ? 1 : 0
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,7 @@ Item {
|
||||||
function instantHide() {
|
function instantHide() {
|
||||||
opacity = 0;
|
opacity = 0;
|
||||||
visible = false;
|
visible = false;
|
||||||
|
closeAllButton.closeRequested = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function hide() {
|
function hide() {
|
||||||
|
|
@ -171,9 +172,11 @@ Item {
|
||||||
to: 0
|
to: 0
|
||||||
duration: PlasmaCore.Units.shortDuration
|
duration: PlasmaCore.Units.shortDuration
|
||||||
easing.type: Easing.InOutQuad
|
easing.type: Easing.InOutQuad
|
||||||
|
|
||||||
onFinished: {
|
onFinished: {
|
||||||
root.visible = false;
|
root.visible = false;
|
||||||
tasksModel.taskReorderingEnabled = true;
|
tasksModel.taskReorderingEnabled = true;
|
||||||
|
closeAllButton.closeRequested = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -204,11 +207,15 @@ Item {
|
||||||
|
|
||||||
FlickContainer {
|
FlickContainer {
|
||||||
id: flickable
|
id: flickable
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
taskSwitcherState: root.taskSwitcherState
|
taskSwitcherState: root.taskSwitcherState
|
||||||
|
|
||||||
// the item is effectively anchored to the flickable bounds
|
// the item is effectively anchored to the flickable bounds
|
||||||
TaskList {
|
TaskList {
|
||||||
|
id: taskList
|
||||||
|
|
||||||
taskSwitcher: root
|
taskSwitcher: root
|
||||||
|
|
||||||
opacity: {
|
opacity: {
|
||||||
|
|
@ -223,6 +230,41 @@ Item {
|
||||||
x: flickable.contentX
|
x: flickable.contentX
|
||||||
width: flickable.width
|
width: flickable.width
|
||||||
height: flickable.height
|
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
|
// whether we are in a swipe up gesture to open the task switcher
|
||||||
property bool currentlyBeingOpened: false
|
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
|
// whether we are in a swipe left/right gesture to walk through tasks
|
||||||
property bool scrollingTasks: false
|
property bool scrollingTasks: false
|
||||||
|
|
||||||
|
|
@ -237,7 +240,10 @@ QtObject {
|
||||||
duration: MobileShell.MobileShellSettings.animationsEnabled ? 300 : 0
|
duration: MobileShell.MobileShellSettings.animationsEnabled ? 300 : 0
|
||||||
easing.type: Easing.OutQuint
|
easing.type: Easing.OutQuint
|
||||||
|
|
||||||
|
onStarted: root.currentlyBeingClosed = true
|
||||||
|
|
||||||
onFinished: {
|
onFinished: {
|
||||||
|
root.currentlyBeingClosed = false;
|
||||||
root.currentlyBeingOpened = false;
|
root.currentlyBeingOpened = false;
|
||||||
taskSwitcher.setSingleActiveWindow(root.currentTaskIndex);
|
taskSwitcher.setSingleActiveWindow(root.currentTaskIndex);
|
||||||
taskSwitcher.instantHide();
|
taskSwitcher.instantHide();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue