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 bool launcherLockedVisible: false
33 property real topPanelHeight
35 readonly property alias active: d.active
39 d.previousWorkspace();
41 function showRight() {
53 function showLeftMoveApp(appSurface) {
54 d.currentAppSurface = appSurface
56 d.previousWorkspace();
58 function showRightMoveApp(appSurface) {
59 d.currentAppSurface = appSurface
63 function showUpMoveApp(appSurface) {
64 d.currentAppSurface = appSurface
68 function showDownMoveApp(appSurface) {
69 d.currentAppSurface = appSurface
78 if (d.currentAppSurface) {
79 d.shiftPressed = true;
85 d.highlightedScreenIndex = screensProxy.activeScreen;
86 var activeScreen = screensProxy.get(screensProxy.activeScreen);
87 d.highlightedWorkspaceIndex = activeScreen.workspaces.indexOf(activeScreen.currentWorkspace)
93 property bool active: false
94 property bool shown: false
95 property bool altPressed: false
96 property bool ctrlPressed: false
97 property bool shiftPressed: false
98 property var currentAppSurface: null
100 property int rowHeight: root.height - units.gu(4)
102 property int highlightedScreenIndex: -1
103 property int highlightedWorkspaceIndex: -1
105 function previousWorkspace() {
106 highlightedWorkspaceIndex = Math.max(highlightedWorkspaceIndex - 1, 0);
108 function nextWorkspace() {
109 var screen = screensProxy.get(highlightedScreenIndex);
110 highlightedWorkspaceIndex = Math.min(highlightedWorkspaceIndex + 1, screen.workspaces.count - 1);
112 function previousScreen() {
113 highlightedScreenIndex = Math.max(highlightedScreenIndex - 1, 0);
114 var screen = screensProxy.get(highlightedScreenIndex);
115 highlightedWorkspaceIndex = Math.min(highlightedWorkspaceIndex, screen.workspaces.count - 1)
117 function nextScreen() {
118 highlightedScreenIndex = Math.min(highlightedScreenIndex + 1, screensProxy.count - 1);
119 var screen = screensProxy.get(highlightedScreenIndex);
120 highlightedWorkspaceIndex = Math.min(highlightedWorkspaceIndex, screen.workspaces.count - 1)
127 onTriggered: d.shown = false;
133 d.previousWorkspace();
148 d.altPressed = false;
151 d.ctrlPressed = false;
154 d.shiftPressed = false;
158 if (!d.altPressed && !d.ctrlPressed && !d.shiftPressed) {
159 if (d.currentAppSurface) {
160 let _workspace = screensProxy.get(d.highlightedScreenIndex).workspaces.get(d.highlightedWorkspaceIndex)
161 WorkspaceManager.moveSurfaceToWorkspace(d.currentAppSurface, _workspace);
162 d.currentAppSurface = null
167 screensProxy.get(d.highlightedScreenIndex).workspaces.get(d.highlightedWorkspaceIndex).activate();
172 backgroundColor: "#F2111111"
174 width: Math.min(parent.width, screensColumn.width + units.gu(4))
175 anchors.horizontalCenter: parent.horizontalCenter
176 height: parent.height
181 top: parent.top; topMargin: units.gu(2) - d.highlightedScreenIndex * (d.rowHeight + screensColumn.spacing)
182 left: parent.left; leftMargin: units.gu(2)
184 width: screensRepeater.itemAt(d.highlightedScreenIndex).width
186 Behavior on anchors.topMargin { LomiriNumberAnimation {} }
187 Behavior on width { LomiriNumberAnimation {} }
195 width: workspaces.width
196 anchors.horizontalCenter: parent.horizontalCenter
197 opacity: d.highlightedScreenIndex == index ? 1 : 0
198 Behavior on opacity { LomiriNumberAnimation {} }
202 anchors { left: parent.left; top: parent.top; right: parent.right }
204 backgroundColor: "white"
207 anchors { left: parent.left; top: parent.top; right: parent.right; margins: units.gu(1) }
208 text: model.screen.name
209 color: LomiriColors.ash
215 height: parent.height - header.height - units.gu(2)
216 width: Math.min(implicitWidth, root.width - units.gu(4))
218 anchors.bottom: parent.bottom
219 anchors.bottomMargin: units.gu(1)
220 anchors.horizontalCenter: parent.horizontalCenter
222 background: root.background
223 selectedIndex: d.highlightedScreenIndex == index ? d.highlightedWorkspaceIndex : -1
225 workspaceModel: model.screen.workspaces
226 launcherLockedVisible: root.launcherLockedVisible
227 topPanelHeight: root.topPanelHeight