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
38 d.previousWorkspace();
40 function showRight() {
52 function showLeftMoveApp(appSurface) {
53 d.currentAppSurface = appSurface
55 d.previousWorkspace();
57 function showRightMoveApp(appSurface) {
58 d.currentAppSurface = appSurface
62 function showUpMoveApp(appSurface) {
63 d.currentAppSurface = appSurface
67 function showDownMoveApp(appSurface) {
68 d.currentAppSurface = appSurface
77 if (d.currentAppSurface) {
78 d.shiftPressed = true;
84 d.highlightedScreenIndex = screensProxy.activeScreen;
85 var activeScreen = screensProxy.get(screensProxy.activeScreen);
86 d.highlightedWorkspaceIndex = activeScreen.workspaces.indexOf(activeScreen.currentWorkspace)
92 property bool active: false
93 property bool shown: false
94 property bool altPressed: false
95 property bool ctrlPressed: false
96 property bool shiftPressed: false
97 property var currentAppSurface: null
99 property int rowHeight: root.height - units.gu(4)
101 property int highlightedScreenIndex: -1
102 property int highlightedWorkspaceIndex: -1
104 function previousWorkspace() {
105 highlightedWorkspaceIndex = Math.max(highlightedWorkspaceIndex - 1, 0);
107 function nextWorkspace() {
108 var screen = screensProxy.get(highlightedScreenIndex);
109 highlightedWorkspaceIndex = Math.min(highlightedWorkspaceIndex + 1, screen.workspaces.count - 1);
111 function previousScreen() {
112 highlightedScreenIndex = Math.max(highlightedScreenIndex - 1, 0);
113 var screen = screensProxy.get(highlightedScreenIndex);
114 highlightedWorkspaceIndex = Math.min(highlightedWorkspaceIndex, screen.workspaces.count - 1)
116 function nextScreen() {
117 highlightedScreenIndex = Math.min(highlightedScreenIndex + 1, screensProxy.count - 1);
118 var screen = screensProxy.get(highlightedScreenIndex);
119 highlightedWorkspaceIndex = Math.min(highlightedWorkspaceIndex, screen.workspaces.count - 1)
126 onTriggered: d.shown = false;
132 d.previousWorkspace();
147 d.altPressed = false;
150 d.ctrlPressed = false;
153 d.shiftPressed = false;
157 if (!d.altPressed && !d.ctrlPressed && !d.shiftPressed) {
158 if (d.currentAppSurface) {
159 let _workspace = screensProxy.get(d.highlightedScreenIndex).workspaces.get(d.highlightedWorkspaceIndex)
160 WorkspaceManager.moveSurfaceToWorkspace(d.currentAppSurface, _workspace);
161 d.currentAppSurface = null
166 screensProxy.get(d.highlightedScreenIndex).workspaces.get(d.highlightedWorkspaceIndex).activate();
171 backgroundColor: "#F2111111"
173 width: Math.min(parent.width, screensColumn.width + units.gu(4))
174 anchors.horizontalCenter: parent.horizontalCenter
175 height: parent.height
180 top: parent.top; topMargin: units.gu(2) - d.highlightedScreenIndex * (d.rowHeight + screensColumn.spacing)
181 left: parent.left; leftMargin: units.gu(2)
183 width: screensRepeater.itemAt(d.highlightedScreenIndex).width
185 Behavior on anchors.topMargin { LomiriNumberAnimation {} }
186 Behavior on width { LomiriNumberAnimation {} }
194 width: workspaces.width
195 anchors.horizontalCenter: parent.horizontalCenter
196 opacity: d.highlightedScreenIndex == index ? 1 : 0
197 Behavior on opacity { LomiriNumberAnimation {} }
201 anchors { left: parent.left; top: parent.top; right: parent.right }
203 backgroundColor: "white"
206 anchors { left: parent.left; top: parent.top; right: parent.right; margins: units.gu(1) }
207 text: model.screen.name
208 color: LomiriColors.ash
214 height: parent.height - header.height - units.gu(2)
215 width: Math.min(implicitWidth, root.width - units.gu(4))
217 anchors.bottom: parent.bottom
218 anchors.bottomMargin: units.gu(1)
219 anchors.horizontalCenter: parent.horizontalCenter
221 background: root.background
222 selectedIndex: d.highlightedScreenIndex == index ? d.highlightedWorkspaceIndex : -1
224 workspaceModel: model.screen.workspaces
225 availableDesktopArea: root.availableDesktopArea