on xenial help sign in
add close button on hover
commit9b5b6c1072290a94fd894f96a6c78aa1d24ade99 authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 9 Mar 2017, 17:53 (10 years ago) parent77b7257
3 files changed+47−16
qml/Stage/Spread/ScreensAndWorkspaces.qml+2−2 qml/Stage/Spread/Workspaces.qml+41−13 qml/Stage/Stage.qml+4−1
qml/Stage/Spread/ScreensAndWorkspaces.qml+2−2
@@ -26,7 +26,7 @@ Item {
2626 delegate: Item {
2727 height: root.height - units.gu(6)
2828 width: workspaces.width
29− clip: true
29+// clip: true
3030
3131 UbuntuShape {
3232 id: header
@@ -108,7 +108,7 @@ Item {
108108 id: workspaces
109109 height: parent.height - header.height - units.gu(2)
110110 width: {
111− if (screensProxy.count == 0) {
111+ if (screensProxy.count == 1) {
112112 return Math.min(implicitWidth, root.width - units.gu(8));
113113 }
114114 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 {
6363 anchors.fill: parent
6464 anchors.leftMargin: -itemWidth
6565 anchors.rightMargin: -itemWidth
66−// interactive: false
66+ boundsBehavior: Flickable.StopAtBounds
6767
6868 orientation: ListView.Horizontal
6969 spacing: units.gu(1)
@@ -93,6 +93,7 @@ Item {
9393 displaced: Transition { UbuntuNumberAnimation { properties: "x" } }
9494
9595 delegate: Item {
96+ id: workspaceDelegate
9697 objectName: "delegate" + index
9798 height: parent.height
9899 width: listView.itemWidth
@@ -173,7 +174,7 @@ Item {
173174 Rotation {
174175 angle: itemAngle
175176 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 }
177178 },
178179 Translate {
179180 x: itemOffset
@@ -186,18 +187,49 @@ Item {
186187 background: root.background
187188 screenHeight: root.screen.physicalSize.height
188189 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 } }
189226
190− Label {
191− anchors.centerIn: parent
192− text: model.text
193− color: "red"
194− fontSize: "large"
195227 }
196228 }
197229 }
198230
199231 MouseArea {
200− id: mouseArea
232+ id: hoverMouseArea
201233 anchors.fill: parent
202234 hoverEnabled: true
203235 propagateComposedEvents: true
@@ -262,10 +294,6 @@ Item {
262294 drag.target = fakeDragItem;
263295 }
264296
265− onClicked: {
266− screenWindow.screen.currentWorkspace = fakeDragItem.workspace
267− }
268−
269297 WorkspacePreview {
270298 id: fakeDragItem
271299 height: listView.height
@@ -274,7 +302,7 @@ Item {
274302 screenHeight: root.screen.physicalSize.height
275303 visible: Drag.active
276304
277− Drag.active: mouseArea.drag.active
305+ Drag.active: hoverMouseArea.drag.active
278306 Drag.keys: ['workspace']
279307
280308 property var workspace
qml/Stage/Stage.qml+4−1
@@ -1829,12 +1829,15 @@ FocusScope {
18291829 objectName: "closeMouseArea"
18301830 anchors { left: parent.left; top: parent.top; leftMargin: -height / 2; topMargin: -height / 2 + spreadMaths.closeIconOffset }
18311831 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
18331833 && index == spreadItem.highlightedIndex
18341834 && mousePos.y < (decoratedWindow.height / 3)
18351835 && mousePos.y > -units.gu(4)
18361836 && mousePos.x > -units.gu(4)
18371837 && mousePos.x < (decoratedWindow.width * 2 / 3)
1838+ opacity: shown ? 1 : 0
1839+ visible: opacity > 0
1840+ Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
18381841 height: units.gu(6)
18391842 width: height
18401843