Lomiri
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.4
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 string background
31 property int screenHeight
32
33 property real previewScale: previewSpace.height / previewSpace.screenHeight
34
35 property bool containsDragLeft: false
36 property bool containsDragRight: false
37 property bool isActive: false
38 property bool isSelected: false
39
40 Image {
41 source: previewSpace.background
42 anchors.fill: parent
43 sourceSize.width: width
44 sourceSize.height: height
45
46 Repeater {
47 id: topLevelSurfaceRepeater
48 model: visible ? workspace.windowModel : null
49 delegate: Item {
50 width: surfaceItem.width
51 height: surfaceItem.height + decorationHeight * previewScale
52 x: model.window.position.x * previewScale
53 y: (model.window.position.y - decorationHeight) * previewScale
54 z: topLevelSurfaceRepeater.count - index
55 visible: model.window.state !== Mir.MinimizedState && model.window.state !== Mir.HiddenState
56
57 property int decorationHeight: units.gu(3)
58
59 WindowDecoration {
60 width: surfaceItem.implicitWidth
61 height: parent.decorationHeight
62 transform: Scale {
63 origin.x: 0
64 origin.y: 0
65 xScale: previewScale
66 yScale: previewScale
67 }
68 title: model.window && model.window.surface ? model.window.surface.name : ""
69 z: 3
70 }
71
72 MirSurfaceItem {
73 id: surfaceItem
74 y: parent.decorationHeight * previewScale
75 width: implicitWidth * previewScale
76 height: implicitHeight * previewScale
77 surfaceWidth: -1
78 surfaceHeight: -1
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}