on xenial help sign in
add close button on hover
9b5b6c1Michael Zanetti
qml/Stage/Spread/ScreensAndWorkspaces.qml+2−2
@@ -26,7 +26,7 @@ Item {
26 delegate: Item {
26 delegate: Item {
27 height: root.height - units.gu(6)
27 height: root.height - units.gu(6)
28 width: workspaces.width
28 width: workspaces.width
29− clip: true
29+// clip: true
30
30
31 UbuntuShape {
31 UbuntuShape {
32 id: header
32 id: header
@@ -108,7 +108,7 @@ Item {
108 id: workspaces
108 id: workspaces
109 height: parent.height - header.height - units.gu(2)
109 height: parent.height - header.height - units.gu(2)
110 width: {
110 width: {
111− if (screensProxy.count == 0) {
111+ if (screensProxy.count == 1) {
112 return Math.min(implicitWidth, root.width - units.gu(8));
112 return Math.min(implicitWidth, root.width - units.gu(8));
113 }
113 }
114 return Math.min(implicitWidth, model.screen.active ? root.width - units.gu(48) : units.gu(40))
114 return Math.min(implicitWidth, model.screen.active ? root.width - units.gu(48) : units.gu(40))
qml/Stage/Spread/Workspaces.qml+41−13
@@ -63,7 +63,7 @@ Item {
63 anchors.fill: parent
63 anchors.fill: parent
64 anchors.leftMargin: -itemWidth
64 anchors.leftMargin: -itemWidth
65 anchors.rightMargin: -itemWidth
65 anchors.rightMargin: -itemWidth
66−// interactive: false
66+ boundsBehavior: Flickable.StopAtBounds
67
67
68 orientation: ListView.Horizontal
68 orientation: ListView.Horizontal
69 spacing: units.gu(1)
69 spacing: units.gu(1)
@@ -93,6 +93,7 @@ Item {
93 displaced: Transition { UbuntuNumberAnimation { properties: "x" } }
93 displaced: Transition { UbuntuNumberAnimation { properties: "x" } }
94
94
95 delegate: Item {
95 delegate: Item {
96+ id: workspaceDelegate
96 objectName: "delegate" + index
97 objectName: "delegate" + index
97 height: parent.height
98 height: parent.height
98 width: listView.itemWidth
99 width: listView.itemWidth
@@ -173,7 +174,7 @@ Item {
173 Rotation {
174 Rotation {
174 angle: itemAngle
175 angle: itemAngle
175 axis { x: 0; y: 1; z: 0 }
176 axis { x: 0; y: 1; z: 0 }
176− origin { x: listView.itemWidth / 2; y: height / 2 }
177+ origin { x: itemAngle < 0 ? listView.itemWidth : 0; y: height / 2 }
177 },
178 },
178 Translate {
179 Translate {
179 x: itemOffset
180 x: itemOffset
@@ -186,18 +187,49 @@ Item {
186 background: root.background
187 background: root.background
187 screenHeight: root.screen.physicalSize.height
188 screenHeight: root.screen.physicalSize.height
188 containsDrag: listView.hoveredWorkspaceIndex == index
189 containsDrag: listView.hoveredWorkspaceIndex == index
190+ }
191+ MouseArea {
192+ anchors.fill: parent
193+ onClicked: {
194+ screenWindow.screen.currentWorkspace = model.workspace
195+ }
196+ }
197+
198+ MouseArea {
199+ id: closeMouseArea
200+ objectName: "closeMouseArea"
201+ anchors { left: parent.left; top: parent.top; leftMargin: -height / 2; topMargin: -height / 2 }
202+ hoverEnabled: true
203+ height: units.gu(4)
204+ width: height
205+
206+ onClicked: {
207+ model.workspace.unassign();
208+ root.commitScreenSetup();
209+ }
210+ Image {
211+ id: closeImage
212+ source: "../graphics/window-close.svg"
213+ anchors.fill: closeMouseArea
214+ anchors.margins: units.gu(1)
215+ sourceSize.width: width
216+ sourceSize.height: height
217+ readonly property var mousePos: hoverMouseArea.mapToItem(workspaceDelegate, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
218+ readonly property bool shown: (hoverMouseArea.containsMouse || parent.containsMouse)
219+ && mousePos.y < workspaceDelegate.width / 4
220+ && mousePos.y > -units.gu(2)
221+ && mousePos.x > -units.gu(2)
222+ && mousePos.x < workspaceDelegate.height / 4
223+ opacity: shown ? 1 : 0
224+ visible: opacity > 0
225+ Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
189
226
190− Label {
191− anchors.centerIn: parent
192− text: model.text
193− color: "red"
194− fontSize: "large"
195 }
227 }
196 }
228 }
197 }
229 }
198
230
199 MouseArea {
231 MouseArea {
200− id: mouseArea
232+ id: hoverMouseArea
201 anchors.fill: parent
233 anchors.fill: parent
202 hoverEnabled: true
234 hoverEnabled: true
203 propagateComposedEvents: true
235 propagateComposedEvents: true
@@ -262,10 +294,6 @@ Item {
262 drag.target = fakeDragItem;
294 drag.target = fakeDragItem;
263 }
295 }
264
296
265− onClicked: {
266− screenWindow.screen.currentWorkspace = fakeDragItem.workspace
267− }
268−
269 WorkspacePreview {
297 WorkspacePreview {
270 id: fakeDragItem
298 id: fakeDragItem
271 height: listView.height
299 height: listView.height
@@ -274,7 +302,7 @@ Item {
274 screenHeight: root.screen.physicalSize.height
302 screenHeight: root.screen.physicalSize.height
275 visible: Drag.active
303 visible: Drag.active
276
304
277− Drag.active: mouseArea.drag.active
305+ Drag.active: hoverMouseArea.drag.active
278 Drag.keys: ['workspace']
306 Drag.keys: ['workspace']
279
307
280 property var workspace
308 property var workspace
qml/Stage/Stage.qml+4−1
@@ -1829,12 +1829,15 @@ FocusScope {
1829 objectName: "closeMouseArea"
1829 objectName: "closeMouseArea"
1830 anchors { left: parent.left; top: parent.top; leftMargin: -height / 2; topMargin: -height / 2 + spreadMaths.closeIconOffset }
1830 anchors { left: parent.left; top: parent.top; leftMargin: -height / 2; topMargin: -height / 2 + spreadMaths.closeIconOffset }
1831 readonly property var mousePos: hoverMouseArea.mapToItem(appDelegate, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
1831 readonly property var mousePos: hoverMouseArea.mapToItem(appDelegate, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
1832− visible: !appDelegate.isDash && dragArea.distance == 0
1832+ readonly property bool shown: !appDelegate.isDash && dragArea.distance == 0
1833 && index == spreadItem.highlightedIndex
1833 && index == spreadItem.highlightedIndex
1834 && mousePos.y < (decoratedWindow.height / 3)
1834 && mousePos.y < (decoratedWindow.height / 3)
1835 && mousePos.y > -units.gu(4)
1835 && mousePos.y > -units.gu(4)
1836 && mousePos.x > -units.gu(4)
1836 && mousePos.x > -units.gu(4)
1837 && mousePos.x < (decoratedWindow.width * 2 / 3)
1837 && mousePos.x < (decoratedWindow.width * 2 / 3)
1838+ opacity: shown ? 1 : 0
1839+ visible: opacity > 0
1840+ Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
1838 height: units.gu(6)
1841 height: units.gu(6)
1839 width: height
1842 width: height
1840
1843