2015-06-21 19:18:02 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright 2015 Marco Martin <notmart@gmail.com>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU Library General Public License for more details
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import QtQuick 2.0
|
|
|
|
|
import QtQuick.Layouts 1.1
|
|
|
|
|
import QtQuick.Window 2.2
|
2016-06-27 16:34:20 +00:00
|
|
|
import org.kde.taskmanager 0.1 as TaskManager
|
2015-06-21 19:18:02 +00:00
|
|
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
2020-07-17 09:12:06 +00:00
|
|
|
import org.kde.plasma.components 3.0 as PlasmaComponents
|
2015-06-21 19:18:02 +00:00
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: delegate
|
|
|
|
|
width: window.width/2
|
|
|
|
|
height: window.height/2
|
2015-10-28 14:02:00 +00:00
|
|
|
|
|
|
|
|
//Workaround
|
|
|
|
|
property bool active: model.IsActive
|
|
|
|
|
onActiveChanged: {
|
2016-02-15 13:59:01 +00:00
|
|
|
//sometimes the task switcher window itself appears, screwing up the state
|
2015-10-28 14:02:00 +00:00
|
|
|
if (model.IsActive) {
|
2016-02-15 13:59:01 +00:00
|
|
|
// window.currentTaskIndex = index
|
2015-10-28 14:02:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-28 10:30:13 +00:00
|
|
|
function syncDelegateGeometry() {
|
2020-08-10 09:41:47 +00:00
|
|
|
let pos = pipeWireLoader.mapToItem(tasksView, 0, 0);
|
2020-07-28 10:30:13 +00:00
|
|
|
if (window.visible) {
|
2020-08-10 09:41:47 +00:00
|
|
|
tasksModel.requestPublishDelegateGeometry(tasksModel.index(model.index, 0), Qt.rect(pos.x, pos.y, pipeWireLoader.width, pipeWireLoader.height), pipeWireLoader);
|
2020-07-28 10:30:13 +00:00
|
|
|
} else {
|
2020-07-30 15:20:07 +00:00
|
|
|
// tasksModel.requestPublishDelegateGeometry(tasksModel.index(model.index, 0), Qt.rect(pos.x, pos.y, delegate.width, delegate.height), dummyWindowTask);
|
2020-07-28 10:30:13 +00:00
|
|
|
}
|
|
|
|
|
}
|
2015-10-28 14:02:00 +00:00
|
|
|
Connections {
|
|
|
|
|
target: tasksView
|
|
|
|
|
onContentYChanged: {
|
2020-07-28 10:30:13 +00:00
|
|
|
syncDelegateGeometry();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Connections {
|
|
|
|
|
target: window
|
|
|
|
|
function onVisibleChanged() {
|
|
|
|
|
syncDelegateGeometry();
|
2015-10-28 14:02:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
2020-07-30 15:20:07 +00:00
|
|
|
|
2020-07-28 10:30:13 +00:00
|
|
|
Component.onCompleted: syncDelegateGeometry();
|
2015-10-28 14:02:00 +00:00
|
|
|
|
2015-06-21 19:18:02 +00:00
|
|
|
Item {
|
|
|
|
|
anchors {
|
|
|
|
|
fill: parent
|
2020-07-17 09:12:06 +00:00
|
|
|
margins: units.smallSpacing
|
2015-06-21 19:18:02 +00:00
|
|
|
}
|
2015-09-23 15:46:54 +00:00
|
|
|
|
2015-06-21 19:26:14 +00:00
|
|
|
SequentialAnimation {
|
2015-06-21 19:18:02 +00:00
|
|
|
id: slideAnim
|
2015-06-21 19:26:14 +00:00
|
|
|
property alias to: internalSlideAnim.to
|
|
|
|
|
NumberAnimation {
|
|
|
|
|
id: internalSlideAnim
|
|
|
|
|
target: background
|
|
|
|
|
properties: "x"
|
|
|
|
|
duration: units.longDuration
|
|
|
|
|
easing.type: Easing.InOutQuad
|
|
|
|
|
}
|
|
|
|
|
ScriptAction {
|
|
|
|
|
script: {
|
|
|
|
|
if (background.x != 0) {
|
2016-06-28 12:37:41 +00:00
|
|
|
tasksModel.requestClose(tasksModel.index(model.index, 0));
|
2015-06-21 19:26:14 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-06-21 19:18:02 +00:00
|
|
|
}
|
|
|
|
|
Rectangle {
|
|
|
|
|
id: background
|
2015-09-23 15:46:54 +00:00
|
|
|
|
2015-06-21 19:18:02 +00:00
|
|
|
width: parent.width
|
|
|
|
|
height: parent.height
|
2016-02-15 13:59:01 +00:00
|
|
|
radius: units.smallSpacing
|
2020-07-29 15:50:10 +00:00
|
|
|
color: theme.backgroundColor
|
|
|
|
|
opacity: 1 * (1-Math.abs(x)/width)
|
|
|
|
|
ColumnLayout {
|
2015-06-21 19:18:02 +00:00
|
|
|
anchors {
|
2020-07-29 15:50:10 +00:00
|
|
|
fill: parent
|
2020-07-17 09:27:38 +00:00
|
|
|
margins: units.smallSpacing
|
2015-06-21 19:18:02 +00:00
|
|
|
}
|
2020-07-29 15:50:10 +00:00
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.maximumHeight: units.gridUnit
|
|
|
|
|
PlasmaCore.IconItem {
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
Layout.preferredWidth: height
|
|
|
|
|
usesPlasmaTheme: false
|
|
|
|
|
source: model.decoration
|
|
|
|
|
}
|
|
|
|
|
PlasmaComponents.Label {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
|
elide: Text.ElideRight
|
|
|
|
|
text: model.display
|
|
|
|
|
color: theme.textColor
|
|
|
|
|
}
|
|
|
|
|
PlasmaComponents.ToolButton {
|
|
|
|
|
z: 99
|
|
|
|
|
icon.name: "window-close"
|
|
|
|
|
icon.width: units.iconSizes.medium
|
|
|
|
|
icon.height: units.iconSizes.medium
|
|
|
|
|
onClicked: {
|
|
|
|
|
slideAnim.to = -background.width*2;
|
|
|
|
|
slideAnim.running = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-10 09:41:47 +00:00
|
|
|
Loader {
|
|
|
|
|
id: pipeWireLoader
|
2020-07-29 15:50:10 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.fillHeight: true
|
2020-08-10 09:41:47 +00:00
|
|
|
source: Qt.resolvedUrl("./Thumbnail.qml")
|
|
|
|
|
onStatusChanged: {
|
|
|
|
|
if (status === Loader.Error) {
|
|
|
|
|
source = Qt.resolvedUrl("./TaskIcon.qml");
|
|
|
|
|
}
|
2020-07-29 15:50:10 +00:00
|
|
|
}
|
|
|
|
|
}
|
2015-06-21 19:18:02 +00:00
|
|
|
}
|
|
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
drag {
|
|
|
|
|
target: background
|
|
|
|
|
axis: Drag.XAxis
|
|
|
|
|
}
|
|
|
|
|
onPressed: delegate.z = 10;
|
|
|
|
|
onClicked: {
|
2020-07-31 09:11:26 +00:00
|
|
|
window.setSingleActiveWindow(model.index, delegate);
|
|
|
|
|
if (!model.IsMinimized) {
|
|
|
|
|
window.visible = false;
|
2020-07-30 15:55:09 +00:00
|
|
|
}
|
2015-06-21 19:18:02 +00:00
|
|
|
}
|
|
|
|
|
onReleased: {
|
|
|
|
|
delegate.z = 0;
|
|
|
|
|
if (Math.abs(background.x) > background.width/2) {
|
2015-06-21 19:26:14 +00:00
|
|
|
slideAnim.to = background.x > 0 ? background.width*2 : -background.width*2;
|
|
|
|
|
slideAnim.running = true;
|
2015-06-21 19:18:02 +00:00
|
|
|
} else {
|
|
|
|
|
slideAnim.to = 0;
|
|
|
|
|
slideAnim.running = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|