Lomiri
Loading...
Searching...
No Matches
WorkspacePreview.qml
1/*
2 * Copyright (C) 2017 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.12
18import Lomiri.Components 1.3
19import QtMir.Application 0.1
20import WindowManager 1.0
21import ".."
22import "../../Components"
23
24Item {
25 id: previewSpace
26 clip: true
27
28 property var workspace
29
30 property QtObject screen
31 property string background
32 property int screenHeight
33
34 property real previewScale: previewSpace.height / previewSpace.screenHeight
35
36 property bool containsDragLeft: false
37 property bool containsDragRight: false
38 property bool isActive: false
39 property bool isSelected: false
40
41 Image {
42 source: previewSpace.background
43 anchors.fill: parent
44 sourceSize.width: width
45 sourceSize.height: height
46
47 Repeater {
48 id: topLevelSurfaceRepeater
49 model: visible ? workspace.windowModel : null
50 delegate: Item {
51 readonly property bool isMaximized : model.window.state === Mir.MaximizedState
52 width: surfaceItem.width * previewScale
53 height: surfaceItem.height + decorationHeight * previewScale
54 x: isMaximized ? 0 : (model.window.position.x - screen.position.x) * previewScale
55 y: isMaximized ? 0 : (model.window.position.y - screen.position.y - decorationHeight) * previewScale
56 z: topLevelSurfaceRepeater.count - index
57 visible: model.window.state !== Mir.MinimizedState && model.window.state !== Mir.HiddenState
58
59 property int decorationHeight: units.gu(3)
60
61 WindowDecoration {
62 width: surfaceItem.implicitWidth
63 height: parent.decorationHeight
64 transform: Scale {
65 origin.x: 0
66 origin.y: 0
67 xScale: previewScale
68 yScale: previewScale
69 }
70 title: model.window && model.window.surface ? model.window.surface.name : ""
71 z: 3
72 }
73
74 MirSurfaceItem {
75 id: surfaceItem
76 y: parent.decorationHeight * previewScale
77 width: implicitWidth * previewScale
78 height: implicitHeight * previewScale
79 surface: model.window.surface
80 }
81 }
82 }
83
84 }
85
86 Rectangle {
87 anchors.fill: parent
88 border.color: LomiriColors.ash
89 border.width: units.gu(.5)
90 color: "transparent"
91 visible: previewSpace.isActive
92 }
93
94 Rectangle {
95 anchors.fill: parent
96 border.color: LomiriColors.blue
97 border.width: units.gu(.5)
98 color: "transparent"
99 visible: previewSpace.isSelected
100 }
101
102 Rectangle {
103 anchors.fill: parent
104 anchors.rightMargin: parent.width / 2
105 color: "#55000000"
106 visible: previewSpace.containsDragLeft
107
108 Column {
109 anchors.centerIn: parent
110 spacing: units.gu(1)
111 Icon {
112 source: "../graphics/multi-monitor_drop-here.png"
113 height: units.gu(4)
114 width: height
115 anchors.horizontalCenter: parent.horizontalCenter
116 }
117 Label {
118 text: qsTr("Drop here")
119 }
120 }
121 }
122
123 Rectangle {
124 anchors.fill: parent
125 anchors.leftMargin: parent.width / 2
126 color: "#55000000"
127 visible: previewSpace.containsDragRight
128
129 Column {
130 anchors.centerIn: parent
131 spacing: units.gu(1)
132 Icon {
133 source: "../graphics/multi-monitor_leave.png"
134 height: units.gu(4)
135 width: height
136 anchors.horizontalCenter: parent.horizontalCenter
137 }
138 Label {
139 text: qsTr("Drop and go")
140 }
141 }
142 }
143}