on xenial help sign in
Active Scree visuals in Spread
fb0297bNick Dedekind
qml/Stage/Spread/ScreensAndWorkspaces.qml+49−8
@@ -12,8 +12,8 @@ Item {
12
12
13 property var screensProxy: Screens.createProxy();
13 property var screensProxy: Screens.createProxy();
14
14
15− property var lastClickedWorkspace: null
15+ property QtObject lastClickedWorkspace: null
16− property var activeWorkspace: null
16+ property QtObject activeWorkspace: null
17 onActiveWorkspaceChanged: print("********************* active workspace changed:", activeWorkspace)
17 onActiveWorkspaceChanged: print("********************* active workspace changed:", activeWorkspace)
18
18
19 signal closeSpread();
19 signal closeSpread();
@@ -23,9 +23,9 @@ Item {
23 anchors.bottom: parent.bottom
23 anchors.bottom: parent.bottom
24 anchors.horizontalCenter: parent.horizontalCenter
24 anchors.horizontalCenter: parent.horizontalCenter
25 Behavior on anchors.horizontalCenterOffset { NumberAnimation { duration: UbuntuAnimation.SlowDuration } }
25 Behavior on anchors.horizontalCenterOffset { NumberAnimation { duration: UbuntuAnimation.SlowDuration } }
26−// anchors.left: parent.left
27 spacing: units.gu(1)
26 spacing: units.gu(1)
28
27
28+ property var selectedIndex: undefined
29
29
30 Repeater {
30 Repeater {
31 model: screensProxy
31 model: screensProxy
@@ -34,13 +34,39 @@ Item {
34 height: root.height - units.gu(6)
34 height: root.height - units.gu(6)
35 width: workspaces.width
35 width: workspaces.width
36
36
37− UbuntuShape {
37+ Item {
38 id: header
38 id: header
39 anchors { left: parent.left; top: parent.top; right: parent.right }
39 anchors { left: parent.left; top: parent.top; right: parent.right }
40 height: units.gu(7)
40 height: units.gu(7)
41− backgroundColor: "white"
42 z: 1
41 z: 1
43
42
43+ property bool isCurrent: {
44+ // another screen is selected.
45+ if (row.selectedIndex != undefined && row.selectedIndex != index) return false;
46+
47+ // this screen is active.
48+ if (WMScreen.active && WMScreen.isSameAs(model.screen) && WMScreen.currentWorkspace.isSameAs(activeWorkspace)) return true;
49+ if (model.screen.workspaces.indexOf(activeWorkspace) >= 0) return true;
50+
51+ // not active.
52+ return false;
53+ }
54+
55+ property bool isSelected: screenMA.containsMouse
56+ onIsSelectedChanged: {
57+ if (isSelected) {
58+ row.selectedIndex = Qt.binding(function() { return index; });
59+ } else if (row.selectedIndex === index) {
60+ row.selectedIndex = undefined;
61+ }
62+ }
63+
64+ UbuntuShape {
65+ anchors.fill: parent
66+ backgroundColor: "white"
67+ opacity: header.isCurrent || header.isSelected ? 1.0 : 0.5
68+ }
69+
44 DropArea {
70 DropArea {
45 anchors.fill: parent
71 anchors.fill: parent
46 keys: ["workspace"]
72 keys: ["workspace"]
@@ -66,23 +92,38 @@ Item {
66
92
67 Label {
93 Label {
68 text: model.screen.name
94 text: model.screen.name
69− color: "black"
95+ color: header.isCurrent || header.isSelected ? "black" : "white"
70 }
96 }
71
97
72 Label {
98 Label {
73 text: model.screen.outputTypeName
99 text: model.screen.outputTypeName
74− color: "black"
100+ color: header.isCurrent || header.isSelected ? "black" : "white"
75 fontSize: "x-small"
101 fontSize: "x-small"
76 }
102 }
77
103
78 Label {
104 Label {
79 text: screen.availableModes[screen.currentModeIndex].size.width + "x" + screen.availableModes[screen.currentModeIndex].size.height
105 text: screen.availableModes[screen.currentModeIndex].size.width + "x" + screen.availableModes[screen.currentModeIndex].size.height
80− color: "black"
106+ color: header.isCurrent || header.isSelected ? "black" : "white"
81 fontSize: "x-small"
107 fontSize: "x-small"
82 }
108 }
83 }
109 }
84
110
111+ Icon {
112+ anchors {
113+ top: parent.top
114+ right: parent.right
115+ margins: units.gu(1)
116+ }
117+ width: units.gu(3)
118+ height: width
119+ source: "image://theme/select"
120+ color: header.isCurrent || header.isSelected ? "black" : "white"
121+ visible: model.screen.active
122+ }
123+
85 MouseArea {
124 MouseArea {
125+ id: screenMA
126+ hoverEnabled: true
86 anchors.fill: parent
127 anchors.fill: parent
87
128
88 onClicked: {
129 onClicked: {
qml/Stage/Spread/Workspaces.qml+1−1
@@ -257,7 +257,7 @@ Item {
257 screenHeight: listView.screenHeight
257 screenHeight: listView.screenHeight
258 containsDragLeft: listView.hoveredWorkspaceIndex == index && listView.hoveredHalf == "left"
258 containsDragLeft: listView.hoveredWorkspaceIndex == index && listView.hoveredHalf == "left"
259 containsDragRight: listView.hoveredWorkspaceIndex == index && listView.hoveredHalf == "right"
259 containsDragRight: listView.hoveredWorkspaceIndex == index && listView.hoveredHalf == "right"
260− isActive: workspace == root.activeWorkspace
260+ isActive: workspace.isSameAs(root.activeWorkspace)
261 isSelected: index === root.selectedIndex
261 isSelected: index === root.selectedIndex
262 workspace: model.workspace
262 workspace: model.workspace
263 }
263 }