2 * Copyright (C) 2017 Canonical Ltd.
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.
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.
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/>.
18import Lomiri.Components 1.3
19import Lomiri.Components.Popups 1.3
20import WindowManager 1.0
21import QtMir.Application 0.1
22import QtQuick.Layouts 1.12
29 property string background
31 property var screensProxy: Screens.createProxy();
33 property QtObject activeWorkspace: null
35 property string mode : "staged"
36 property bool launcherLockedVisible: false
37 property real topPanelHeight
42 id: deviceConfiguration
47 anchors.bottom: parent.bottom
48 anchors.horizontalCenter: parent.horizontalCenter
49 Behavior on anchors.horizontalCenterOffset { NumberAnimation { duration: LomiriAnimation.SlowDuration } }
52 property var selectedIndex: undefined
58 height: root.height - units.gu(6)
59 width: workspaces.width
60 visible: (deviceConfiguration.category == "phone" && index !== 0) || deviceConfiguration.category != "phone"
64 anchors { left: parent.left; top: parent.top; right: parent.right }
68 property bool isCurrent: {
69 // another screen is selected.
70 if (row.selectedIndex != undefined && row.selectedIndex != index) return false;
72 // this screen is active.
73 if (WMScreen.active && WMScreen.isSameAs(model.screen) && WMScreen.currentWorkspace.isSameAs(activeWorkspace)) return true;
74 if (model.screen.workspaces.indexOf(activeWorkspace) >= 0) return true;
80 property bool isSelected: screenMA.containsMouse
81 onIsSelectedChanged: {
83 row.selectedIndex = Qt.binding(function() { return index; });
84 } else if (row.selectedIndex === index) {
85 row.selectedIndex = undefined;
91 backgroundColor: "white"
92 opacity: header.isCurrent || header.isSelected ? 1.0 : 0.5
100 workspaces.workspaceModel.insert(workspaces.workspaceModel.count, {text: drag.source.text})
101 drag.source.inDropArea = true;
105 workspaces.workspaceModel.remove(workspaces.workspaceModel.count - 1, 1)
106 drag.source.inDropArea = false;
110 drag.source.inDropArea = false;
117 anchors.margins: units.gu(1)
120 Layout.fillHeight: true
121 text: model.screen.name
122 color: header.isCurrent || header.isSelected ? "black" : "white"
126 Layout.fillHeight: true
127 text: model.screen.outputTypeName
128 color: header.isCurrent || header.isSelected ? "black" : "white"
133 Layout.fillHeight: true
134 text: screen.availableModes[screen.currentModeIndex].size.width + "x" + screen.availableModes[screen.currentModeIndex].size.height
135 color: header.isCurrent || header.isSelected ? "black" : "white"
148 source: "image://theme/select"
149 color: header.isCurrent || header.isSelected ? "black" : "white"
150 visible: model.screen.active
159 var obj = screensMenuComponent.createObject(header)
160 obj.open(mouseX, mouseY)
165 id: screensMenuComponent
169 height: contentColumn.childrenRect.height
170 backgroundColor: "white"
172 function open(mouseX, mouseY) {
173 x = Math.max(0, Math.min(mouseX - width / 2, parent.width - width))
174 y = mouseY + units.gu(1)
180 screensMenu.destroy()
188 height: layout.height
189 highlightColor: "transparent"
192 title.text: qsTr("Add workspace")
196 screen.workspaces.addWorkspace();
197 Screens.sync(root.screensProxy);
198 screensMenu.destroy();
208 height: parent.height - header.height - units.gu(2)
211 if (screensProxy.count == 1) {
212 width = Math.min(implicitWidth, root.width - units.gu(8));
214 width = Math.min(implicitWidth, model.screen.active ? root.width - units.gu(48) : units.gu(40))
216 return Math.max(workspaces.minimumWidth, width);
219 Behavior on width { LomiriNumberAnimation {} }
220 anchors.bottom: parent.bottom
221 anchors.bottomMargin: units.gu(1)
222 anchors.horizontalCenter: parent.horizontalCenter
224 background: root.background
225 launcherLockedVisible: root.launcherLockedVisible
226 topPanelHeight: root.topPanelHeight
228 workspaceModel: model.screen.workspaces
229 activeWorkspace: root.activeWorkspace
232 onCommitScreenSetup: Screens.sync(root.screensProxy)
233 onCloseSpread: root.closeSpread();
236 root.activeWorkspace = workspace;
244 anchors { left: parent.left; top: parent.top; bottom: parent.bottom; topMargin: units.gu(6); bottomMargin: units.gu(1) }
247 visible: (row.width - root.width + units.gu(10)) / 2 - row.anchors.horizontalCenterOffset > units.gu(5)
252 onPressed: mouse.accepted = false;
257 keys: ["application", "workspace"]
261 anchors { right: parent.right; top: parent.top; bottom: parent.bottom; topMargin: units.gu(6); bottomMargin: units.gu(1) }
264 visible: (row.width - root.width + units.gu(10)) / 2 + row.anchors.horizontalCenterOffset > units.gu(5)
269 onPressed: mouse.accepted = false;
272 id: rightFakeDropArea
274 keys: ["application", "workspace"]
279 running: leftScrollArea.containsMouse || rightScrollArea.containsMouse || leftFakeDropArea.containsDrag || rightFakeDropArea.containsDrag
280 interval: LomiriAnimation.SlowDuration
281 triggeredOnStart: true
283 var newOffset = row.anchors.horizontalCenterOffset;
284 var maxOffset = Math.max((row.width - root.width + units.gu(10)) / 2, 0);
285 if (leftScrollArea.containsMouse || leftFakeDropArea.containsDrag) {
286 newOffset += units.gu(20)
288 newOffset -= units.gu(20)
290 newOffset = Math.max(-maxOffset, Math.min(maxOffset, newOffset));
291 row.anchors.horizontalCenterOffset = newOffset;