2 * Copyright (C) 2014-2016 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
20import WindowManager 1.0
21import QtMir.Application 0.1
26 opacity: d.shown ? 1 : 0
28 Behavior on opacity { LomiriNumberAnimation {} }
30 property var screensProxy: Screens.createProxy();
31 property string background
32 property Item availableDesktopArea
34 readonly property alias active: d.active
36 signal workspaceSelected(var selectedWorkspace)
40 d.previousWorkspace();
42 function showRight() {
54 function showLeftMoveApp(appSurface) {
55 d.currentAppSurface = appSurface
57 d.previousWorkspace();
59 function showRightMoveApp(appSurface) {
60 d.currentAppSurface = appSurface
64 function showUpMoveApp(appSurface) {
65 d.currentAppSurface = appSurface
69 function showDownMoveApp(appSurface) {
70 d.currentAppSurface = appSurface
79 if (d.currentAppSurface) {
80 d.shiftPressed = true;
86 d.highlightedScreenIndex = screensProxy.activeScreen;
87 var activeScreen = screensProxy.get(screensProxy.activeScreen);
88 d.highlightedWorkspaceIndex = activeScreen.workspaces.indexOf(activeScreen.currentWorkspace)
94 property bool active: false
95 property bool shown: false
96 property bool altPressed: false
97 property bool ctrlPressed: false
98 property bool shiftPressed: false
99 property var currentAppSurface: null
101 property int rowHeight: root.height - units.gu(4)
103 property int highlightedScreenIndex: -1
104 property int highlightedWorkspaceIndex: -1
106 function previousWorkspace() {
107 highlightedWorkspaceIndex = Math.max(highlightedWorkspaceIndex - 1, 0);
109 function nextWorkspace() {
110 var screen = screensProxy.get(highlightedScreenIndex);
111 highlightedWorkspaceIndex = Math.min(highlightedWorkspaceIndex + 1, screen.workspaces.count - 1);
113 function previousScreen() {
114 highlightedScreenIndex = Math.max(highlightedScreenIndex - 1, 0);
115 var screen = screensProxy.get(highlightedScreenIndex);
116 highlightedWorkspaceIndex = Math.min(highlightedWorkspaceIndex, screen.workspaces.count - 1)
118 function nextScreen() {
119 highlightedScreenIndex = Math.min(highlightedScreenIndex + 1, screensProxy.count - 1);
120 var screen = screensProxy.get(highlightedScreenIndex);
121 highlightedWorkspaceIndex = Math.min(highlightedWorkspaceIndex, screen.workspaces.count - 1)
128 onTriggered: d.shown = false;
134 d.previousWorkspace();
149 d.altPressed = false;
152 d.ctrlPressed = false;
155 d.shiftPressed = false;
159 if (!d.altPressed && !d.ctrlPressed && !d.shiftPressed) {
160 if (d.currentAppSurface) {
161 let _workspace = screensProxy.get(d.highlightedScreenIndex).workspaces.get(d.highlightedWorkspaceIndex)
162 WorkspaceManager.moveSurfaceToWorkspace(d.currentAppSurface, _workspace);
163 d.currentAppSurface = null
169 const selectedWorkspace = screensProxy.get(d.highlightedScreenIndex).workspaces.get(d.highlightedWorkspaceIndex);
170 selectedWorkspace.activate();
171 root.workspaceSelected(selectedWorkspace)
176 backgroundColor: "#F2111111"
178 width: Math.min(parent.width, screensColumn.width + units.gu(4))
179 anchors.horizontalCenter: parent.horizontalCenter
180 height: parent.height
185 top: parent.top; topMargin: units.gu(2) - d.highlightedScreenIndex * (d.rowHeight + screensColumn.spacing)
186 left: parent.left; leftMargin: units.gu(2)
188 width: screensRepeater.itemAt(d.highlightedScreenIndex).width
190 Behavior on anchors.topMargin { LomiriNumberAnimation {} }
191 Behavior on width { LomiriNumberAnimation {} }
199 width: workspaces.width
200 anchors.horizontalCenter: parent.horizontalCenter
201 opacity: d.highlightedScreenIndex == index ? 1 : 0
202 Behavior on opacity { LomiriNumberAnimation {} }
206 anchors { left: parent.left; top: parent.top; right: parent.right }
208 backgroundColor: "white"
211 anchors { left: parent.left; top: parent.top; right: parent.right; margins: units.gu(1) }
212 text: model.screen.name
213 color: LomiriColors.ash
219 height: parent.height - header.height - units.gu(2)
220 width: Math.min(implicitWidth, root.width - units.gu(4))
222 anchors.bottom: parent.bottom
223 anchors.bottomMargin: units.gu(1)
224 anchors.horizontalCenter: parent.horizontalCenter
226 background: root.background
227 selectedIndex: d.highlightedScreenIndex == index ? d.highlightedWorkspaceIndex : -1
229 workspaceModel: model.screen.workspaces
230 availableDesktopArea: root.availableDesktopArea