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
33 readonly property alias active: d.active
37 d.previousWorkspace();
39 function showRight() {
60 d.highlightedScreenIndex = screensProxy.activeScreen;
61 var activeScreen = screensProxy.get(screensProxy.activeScreen);
62 d.highlightedWorkspaceIndex = activeScreen.workspaces.indexOf(activeScreen.currentWorkspace)
68 property bool active: false
69 property bool shown: false
70 property bool altPressed: false
71 property bool ctrlPressed: false
73 property int rowHeight: root.height - units.gu(4)
75 property int highlightedScreenIndex: -1
76 property int highlightedWorkspaceIndex: -1
78 function previousWorkspace() {
79 highlightedWorkspaceIndex = Math.max(highlightedWorkspaceIndex - 1, 0);
81 function nextWorkspace() {
82 var screen = screensProxy.get(highlightedScreenIndex);
83 highlightedWorkspaceIndex = Math.min(highlightedWorkspaceIndex + 1, screen.workspaces.count - 1);
85 function previousScreen() {
86 highlightedScreenIndex = Math.max(highlightedScreenIndex - 1, 0);
87 var screen = screensProxy.get(highlightedScreenIndex);
88 highlightedWorkspaceIndex = Math.min(highlightedWorkspaceIndex, screen.workspaces.count - 1)
90 function nextScreen() {
91 highlightedScreenIndex = Math.min(highlightedScreenIndex + 1, screensProxy.count - 1);
92 var screen = screensProxy.get(highlightedScreenIndex);
93 highlightedWorkspaceIndex = Math.min(highlightedWorkspaceIndex, screen.workspaces.count - 1)
100 onTriggered: d.shown = false;
106 d.previousWorkspace();
121 d.altPressed = false;
124 d.ctrlPressed = false;
128 if (!d.altPressed && !d.ctrlPressed) {
132 screensProxy.get(d.highlightedScreenIndex).workspaces.get(d.highlightedWorkspaceIndex).activate();
137 backgroundColor: "#F2111111"
139 width: Math.min(parent.width, screensColumn.width + units.gu(4))
140 anchors.horizontalCenter: parent.horizontalCenter
141 height: parent.height
146 top: parent.top; topMargin: units.gu(2) - d.highlightedScreenIndex * (d.rowHeight + screensColumn.spacing)
147 left: parent.left; leftMargin: units.gu(2)
149 width: screensRepeater.itemAt(d.highlightedScreenIndex).width
151 Behavior on anchors.topMargin { LomiriNumberAnimation {} }
152 Behavior on width { LomiriNumberAnimation {} }
160 width: workspaces.width
161 anchors.horizontalCenter: parent.horizontalCenter
162 opacity: d.highlightedScreenIndex == index ? 1 : 0
163 Behavior on opacity { LomiriNumberAnimation {} }
167 anchors { left: parent.left; top: parent.top; right: parent.right }
169 backgroundColor: "white"
172 anchors { left: parent.left; top: parent.top; right: parent.right; margins: units.gu(1) }
173 text: model.screen.name
174 color: LomiriColors.ash
180 height: parent.height - header.height - units.gu(2)
181 width: Math.min(implicitWidth, root.width - units.gu(4))
183 anchors.bottom: parent.bottom
184 anchors.bottomMargin: units.gu(1)
185 anchors.horizontalCenter: parent.horizontalCenter
187 background: root.background
188 selectedIndex: d.highlightedScreenIndex == index ? d.highlightedWorkspaceIndex : -1
190 workspaceModel: model.screen.workspaces