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
78 height: implicitHeight
79 surface: model.window.surface
80 transform: Scale {
81 origin.x: 0
82 origin.y: 0
83 xScale: previewScale
84 yScale: previewScale
85 }
86 }
87 }
88 }
89
90 }
91
92 Rectangle {
93 anchors.fill: parent
94 border.color: LomiriColors.ash
95 border.width: units.gu(.5)
96 color: "transparent"
97 visible: previewSpace.isActive
98 }
99
100 Rectangle {
101 anchors.fill: parent
102 border.color: LomiriColors.blue
103 border.width: units.gu(.5)
104 color: "transparent"
105 visible: previewSpace.isSelected
106 }
107
108 Rectangle {
109 anchors.fill: parent
110 anchors.rightMargin: parent.width / 2
111 color: "#55000000"
112 visible: previewSpace.containsDragLeft
113
114 Column {
115 anchors.centerIn: parent
116 spacing: units.gu(1)
117 Icon {
118 source: "../graphics/multi-monitor_drop-here.png"
119 height: units.gu(4)
120 width: height
121 anchors.horizontalCenter: parent.horizontalCenter
122 }
123 Label {
124 text: qsTr("Drop here")
125 }
126 }
127 }
128
129 Rectangle {
130 anchors.fill: parent
131 anchors.leftMargin: parent.width / 2
132 color: "#55000000"
133 visible: previewSpace.containsDragRight
134
135 Column {
136 anchors.centerIn: parent
137 spacing: units.gu(1)
138 Icon {
139 source: "../graphics/multi-monitor_leave.png"
140 height: units.gu(4)
141 width: height
142 anchors.horizontalCenter: parent.horizontalCenter
143 }
144 Label {
145 text: qsTr("Drop and go")
146 }
147 }
148 }
149}