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 width: surfaceItem.width
52 height: surfaceItem.height + decorationHeight * previewScale
53 x: (model.window.position.x - screen.position.x) * previewScale
54 y: (model.window.position.y - screen.position.y - decorationHeight) * previewScale
55 z: topLevelSurfaceRepeater.count - index
56 visible: model.window.state !== Mir.MinimizedState && model.window.state !== Mir.HiddenState
57
58 property int decorationHeight: units.gu(3)
59
60 WindowDecoration {
61 width: surfaceItem.implicitWidth
62 height: parent.decorationHeight
63 transform: Scale {
64 origin.x: 0
65 origin.y: 0
66 xScale: previewScale
67 yScale: previewScale
68 }
69 title: model.window && model.window.surface ? model.window.surface.name : ""
70 z: 3
71 }
72
73 MirSurfaceItem {
74 id: surfaceItem
75 y: parent.decorationHeight * previewScale
76 width: implicitWidth * previewScale
77 height: implicitHeight * previewScale
78 surfaceWidth: -1
79 surfaceHeight: -1
80 surface: model.window.surface
81 }
82 }
83 }
84
85 }
86
87 Rectangle {
88 anchors.fill: parent
89 border.color: LomiriColors.ash
90 border.width: units.gu(.5)
91 color: "transparent"
92 visible: previewSpace.isActive
93 }
94
95 Rectangle {
96 anchors.fill: parent
97 border.color: LomiriColors.blue
98 border.width: units.gu(.5)
99 color: "transparent"
100 visible: previewSpace.isSelected
101 }
102
103 Rectangle {
104 anchors.fill: parent
105 anchors.rightMargin: parent.width / 2
106 color: "#55000000"
107 visible: previewSpace.containsDragLeft
108
109 Column {
110 anchors.centerIn: parent
111 spacing: units.gu(1)
112 Icon {
113 source: "../graphics/multi-monitor_drop-here.png"
114 height: units.gu(4)
115 width: height
116 anchors.horizontalCenter: parent.horizontalCenter
117 }
118 Label {
119 text: qsTr("Drop here")
120 }
121 }
122 }
123
124 Rectangle {
125 anchors.fill: parent
126 anchors.leftMargin: parent.width / 2
127 color: "#55000000"
128 visible: previewSpace.containsDragRight
129
130 Column {
131 anchors.centerIn: parent
132 spacing: units.gu(1)
133 Icon {
134 source: "../graphics/multi-monitor_leave.png"
135 height: units.gu(4)
136 width: height
137 anchors.horizontalCenter: parent.horizontalCenter
138 }
139 Label {
140 text: qsTr("Drop and go")
141 }
142 }
143 }
144}