Unity 8
WorkspacePreview.qml
1 import QtQuick 2.4
2 import Ubuntu.Components 1.3
3 import Unity.Application 0.1
4 import WindowManager 1.0
5 import ".."
6 import "../../Components"
7 
8 Item {
9  id: previewSpace
10  clip: true
11 
12  property var workspace
13 
14  property string background
15  property int screenHeight
16 
17  property real previewScale: previewSpace.height / previewSpace.screenHeight
18 
19  property bool containsDragLeft: false
20  property bool containsDragRight: false
21  property bool isActive: false
22  property bool isSelected: false
23 
24  Image {
25  source: previewSpace.background
26  anchors.fill: parent
27  sourceSize.width: width
28  sourceSize.height: height
29 
30  Repeater {
31  id: topLevelSurfaceRepeater
32  model: visible ? workspace.windowModel : null
33  delegate: Item {
34  width: surfaceItem.width
35  height: surfaceItem.height + decorationHeight * previewScale
36  x: model.window.position.x * previewScale
37  y: (model.window.position.y - decorationHeight) * previewScale
38  z: topLevelSurfaceRepeater.count - index
39  visible: model.window.state !== Mir.MinimizedState && model.window.state !== Mir.HiddenState
40 
41  property int decorationHeight: units.gu(3)
42 
43  WindowDecoration {
44  width: surfaceItem.implicitWidth
45  height: parent.decorationHeight
46  transform: Scale {
47  origin.x: 0
48  origin.y: 0
49  xScale: previewScale
50  yScale: previewScale
51  }
52  title: model.window && model.window.surface ? model.window.surface.name : ""
53  z: 3
54  }
55 
56  MirSurfaceItem {
57  id: surfaceItem
58  y: parent.decorationHeight * previewScale
59  width: implicitWidth * previewScale
60  height: implicitHeight * previewScale
61  surfaceWidth: -1
62  surfaceHeight: -1
63  surface: model.window.surface
64  }
65  }
66  }
67 
68  }
69 
70  Rectangle {
71  anchors.fill: parent
72  border.color: UbuntuColors.ash
73  border.width: units.gu(.5)
74  color: "transparent"
75  visible: previewSpace.isActive
76  }
77 
78  Rectangle {
79  anchors.fill: parent
80  border.color: UbuntuColors.blue
81  border.width: units.gu(.5)
82  color: "transparent"
83  visible: previewSpace.isSelected
84  }
85 
86  Rectangle {
87  anchors.fill: parent
88  anchors.rightMargin: parent.width / 2
89  color: "#55000000"
90  visible: previewSpace.containsDragLeft
91 
92  Column {
93  anchors.centerIn: parent
94  spacing: units.gu(1)
95  Icon {
96  source: "../graphics/multi-monitor_drop-here.png"
97  height: units.gu(4)
98  width: height
99  anchors.horizontalCenter: parent.horizontalCenter
100  }
101  Label {
102  text: qsTr("Drop here")
103  }
104  }
105  }
106 
107  Rectangle {
108  anchors.fill: parent
109  anchors.leftMargin: parent.width / 2
110  color: "#55000000"
111  visible: previewSpace.containsDragRight
112 
113  Column {
114  anchors.centerIn: parent
115  spacing: units.gu(1)
116  Icon {
117  source: "../graphics/multi-monitor_leave.png"
118  height: units.gu(4)
119  width: height
120  anchors.horizontalCenter: parent.horizontalCenter
121  }
122  Label {
123  text: qsTr("Drop and go")
124  }
125  }
126  }
127 }