on xenial help sign in
add WorkspaceSwitcher
commit4f8a0907c07cdc531bcc957af028453cf44f480f authorMichael Zanetti <michael.zanetti@canonical.com> dateWed 22 Mar 2017, 12:10 (10 years ago) parent8fdf9a4
2 files changed+126
qml/Stage/Stage.qml+42 qml/Stage/WorkspaceSwitcher.qml+84
qml/Stage/Stage.qml+42
@@ -225,6 +225,21 @@ FocusScope {
225225 active: priv.focusedAppDelegate !== null
226226 }
227227
228+ GlobalShortcut {
229+ id: showWorkspaceSwitcherShortcutLeft
230+ shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.Key_Left
231+ onTriggered: {
232+ workspaceSwitcher.left()
233+ }
234+ }
235+ GlobalShortcut {
236+ id: showWorkspaceSwitcherShortcutRight
237+ shortcut: Qt.AltModifier|Qt.ControlModifier|Qt.Key_Right
238+ onTriggered: {
239+ workspaceSwitcher.right()
240+ }
241+ }
242+
228243 QtObject {
229244 id: priv
230245 objectName: "DesktopStagePrivate"
@@ -1932,6 +1947,33 @@ FocusScope {
19321947 panelState: root.panelState
19331948 }
19341949
1950+ WorkspaceSwitcher {
1951+ id: workspaceSwitcher
1952+ anchors.centerIn: parent
1953+ height: units.gu(20)
1954+ background: root.background
1955+ opacity: shown ? 1 : 0
1956+ visible: opacity > 0
1957+ Behavior on opacity { UbuntuNumberAnimation {} }
1958+ property bool shown: false
1959+ function show() {
1960+ shown = true;
1961+ hideTimer.start();
1962+ }
1963+ Timer {
1964+ id: hideTimer
1965+ interval: 3000
1966+ onTriggered: workspaceSwitcher.shown = false;
1967+ }
1968+
1969+ function left() {
1970+ show()
1971+ }
1972+ function right() {
1973+ show();
1974+ }
1975+ }
1976+
19351977 PropertyAnimation {
19361978 id: shortRightEdgeSwipeAnimation
19371979 property: "x"
qml/Stage/WorkspaceSwitcher.qmlnew file+84
@@ -0,0 +1,84 @@
1+/*
2+ * Copyright (C) 2014-2016 Canonical, Ltd.
3+ *
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.
7+ *
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.
12+ *
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/>.
15+ */
16+
17+import QtQuick 2.4
18+import Ubuntu.Components 1.3
19+import "Spread"
20+import WindowManager 1.0
21+import Unity.Application 0.1
22+
23+UbuntuShape {
24+ id: root
25+
26+ backgroundColor: "#F2111111"
27+ width: screensRow.childrenRect.width + units.gu(4)
28+
29+ property var screensProxy: Screens.createProxy();
30+ property string background
31+
32+ Row {
33+ id: screensRow
34+ anchors {
35+ top: parent.top; topMargin: units.gu(2)
36+ left: parent.left; leftMargin: units.gu(2)
37+ }
38+
39+ Repeater {
40+ model: screensProxy
41+
42+ delegate: Item {
43+ height: root.height - units.gu(4)
44+ width: workspaces.width
45+
46+ UbuntuShape {
47+ id: header
48+ anchors { left: parent.left; top: parent.top; right: parent.right }
49+ height: units.gu(4)
50+ backgroundColor: "white"
51+
52+ Label {
53+ anchors { left: parent.left; top: parent.top; right: parent.right; margins: units.gu(1) }
54+ text: model.screen.name
55+ color: UbuntuColors.ash
56+ }
57+ }
58+
59+ Workspaces {
60+ id: workspaces
61+ height: parent.height - header.height - units.gu(2)
62+ width: {
63+ var width = 0;
64+ if (screensProxy.count == 1) {
65+ width = Math.min(implicitWidth, root.width - units.gu(8));
66+ } else {
67+ width = Math.min(implicitWidth, model.screen.active ? root.width - units.gu(48) : units.gu(40))
68+ }
69+ return Math.max(workspaces.minimumWidth, width);
70+ }
71+
72+ Behavior on width { UbuntuNumberAnimation {} }
73+ anchors.bottom: parent.bottom
74+ anchors.bottomMargin: units.gu(1)
75+ anchors.horizontalCenter: parent.horizontalCenter
76+ screen: model.screen
77+ background: root.background
78+
79+ workspaceModel: model.screen.workspaces
80+ }
81+ }
82+ }
83+ }
84+}