Warning, /plasma/plasma-mobile/kwin/mobiletaskswitcher/qml/TaskList.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org> 0002 // SPDX-License-Identifier: GPL-2.0-or-later 0003 0004 import QtQuick 0005 import QtQuick.Layouts 0006 0007 import org.kde.kirigami 2.20 as Kirigami 0008 import org.kde.plasma.components 3.0 as PlasmaComponents 0009 0010 import org.kde.kwin 3.0 as KWinComponents 0011 0012 MouseArea { 0013 id: root 0014 readonly property int count: repeater.count 0015 0016 required property real shellTopMargin 0017 required property real shellBottomMargin 0018 0019 required property var taskSwitcher 0020 readonly property var taskSwitcherState: taskSwitcher.taskSwitcherState 0021 0022 property int taskInteractingCount: 0 0023 0024 // account for system header and footer offset (center the preview image) 0025 readonly property real taskY: { 0026 let headerHeight = shellTopMargin; 0027 let footerHeight = shellBottomMargin; 0028 let diff = headerHeight - footerHeight; 0029 0030 let baseY = (taskSwitcher.height / 2) - (taskSwitcherState.taskHeight / 2) - (taskSwitcherState.taskHeaderHeight / 2) 0031 0032 return baseY + diff / 2 - shellTopMargin; 0033 } 0034 0035 function getTaskAt(index) { 0036 return repeater.itemAt(index); 0037 } 0038 0039 function closeAll() { 0040 for (var i = 0; i < repeater.count; i++) { 0041 repeater.itemAt(i).closeApp(); 0042 } 0043 } 0044 0045 function minimizeAll() { 0046 for (var i = 0; i < repeater.count; i++) { 0047 let item = repeater.itemAt(i); 0048 0049 // update property 0050 if (!item.window.minimized) { 0051 taskSwitcherState.wasInActiveTask = true; 0052 } 0053 0054 // minimize window immediately if it shows up 0055 item.minimizeApp(); 0056 } 0057 } 0058 0059 function jumpToFirstVisibleWindow() { 0060 for (var i = 0; i < repeater.count; i++) { 0061 let item = repeater.itemAt(i); 0062 0063 if (!item.window.minimized) { 0064 taskSwitcherState.goToTaskIndex(i); 0065 break; 0066 } 0067 } 0068 } 0069 0070 transform: Scale { 0071 origin.x: root.width / 2 0072 origin.y: root.height / 2 0073 xScale: taskSwitcherState.currentScale 0074 yScale: taskSwitcherState.currentScale 0075 } 0076 0077 onClicked: { 0078 // if tapped on the background, then hide 0079 if (!taskSwitcherState.currentlyBeingOpened) { 0080 taskSwitcher.hide(); 0081 } 0082 } 0083 0084 onPressedChanged: { 0085 if (!taskSwitcherState.currentlyBeingOpened && pressed) { 0086 // ensure animations aren't running when finger is pressed 0087 taskSwitcherState.cancelAnimations(); 0088 } 0089 } 0090 0091 Repeater { 0092 id: repeater 0093 model: taskSwitcher.tasksModel 0094 0095 // left margin from root edge such that the task is centered 0096 readonly property real leftMargin: (root.width / 2) - (taskSwitcherState.taskWidth / 2) 0097 0098 delegate: Task { 0099 id: task 0100 readonly property int currentIndex: model.index 0101 0102 // this is the x-position with respect to the list 0103 property real listX: taskSwitcherState.xPositionFromTaskIndex(currentIndex); 0104 Behavior on listX { 0105 NumberAnimation { 0106 duration: Kirigami.Units.longDuration 0107 easing.type: Easing.InOutQuad 0108 } 0109 } 0110 0111 // this is the actual displayed x-position on screen 0112 x: listX + repeater.leftMargin - taskSwitcherState.xPosition 0113 y: root.taskY 0114 0115 // ensure current task is above others 0116 z: taskSwitcherState.currentTaskIndex === currentIndex ? 1 : 0 0117 0118 // only show header once task switcher is opened 0119 showHeader: !taskSwitcherState.currentlyBeingOpened 0120 0121 // darken effect as task gets away from the centre of the screen 0122 darken: { 0123 const distFromCentreProgress = Math.abs(x - repeater.leftMargin) / taskSwitcherState.taskWidth; 0124 const upperBoundAdjust = Math.min(0.5, distFromCentreProgress) - 0.2; 0125 return Math.max(0, upperBoundAdjust); 0126 } 0127 0128 // update count of tasks being interacted with, so we know whether we are in a swipe up action 0129 onInteractingActiveChanged: { 0130 let offset = interactingActive ? 1 : -1; 0131 taskInteractingCount = Math.max(0, taskInteractingCount + offset); 0132 } 0133 0134 width: taskSwitcherState.taskWidth 0135 height: taskSwitcherState.taskHeight 0136 previewWidth: taskSwitcherState.previewWidth 0137 previewHeight: taskSwitcherState.previewHeight 0138 0139 taskSwitcher: root.taskSwitcher 0140 } 0141 } 0142 }