on xenial help sign in
Add an initial, rudimentary DesktopStage to get started

Approved by: Gerry Boland

commit015e1a301a5dfef63d6eabe306046b8d5bce398e authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 11 Dec 2014, 13:23 (12 years ago) parentd92457bebc0ef3
5 files changed+271−1
com.canonical.Unity8.gschema.xml+14 debian/unity8-common.install+1 qml/Shell.qml+7−1 qml/Stages/DesktopStage.qml+162 qml/Stages/WindowDecoration.qml+87
com.canonical.Unity8.gschema.xmlnew file+14
@@ -0,0 +1,14 @@
1+<schemalist>
2+ <enum id="usage-mode-enum">
3+ <value nick="Staged" value="0" />
4+ <value nick="Windowed" value="1" />
5+ </enum>
6+
7+ <schema path="/com/canonical/unity8/" id="com.canonical.Unity8" gettext-domain="unity8">
8+ <key enum="usage-mode-enum" name="usage-mode">
9+ <default>"Staged"</default>
10+ <summary>The usage mode.</summary>
11+ <description>The usage mode chosen will affect the Window Management behaviour.</description>
12+ </key>
13+ </schema>
14+</schemalist>
debian/unity8-common.install+1
@@ -3,4 +3,5 @@ usr/share/unity8/Components
33usr/share/unity8/Dash
44usr/share/unity8/Notifications
55usr/share/unity8/graphics
6+com.canonical.Unity8.gschema.xml usr/share/glib-2.0/schemas/
67var/lib/polkit-1/localauthority/10-vendor.d
qml/Shell.qml+7−1
@@ -267,7 +267,13 @@ Item {
267267 // the screen larger (maybe connects to monitor) and tries to enter
268268 // tablet mode.
269269 property bool tabletMode: shell.sideStageEnabled && !greeter.hasLockedApp
270− source: tabletMode ? "Stages/TabletStage.qml" : "Stages/PhoneStage.qml"
270+ source: usageModeSettings.usageMode === "Windowed" ? "Stages/DesktopStage.qml"
271+ : tabletMode ? "Stages/TabletStage.qml" : "Stages/PhoneStage.qml"
272+
273+ GSettings {
274+ id: usageModeSettings
275+ schema.id: "com.canonical.Unity8"
276+ }
271277
272278 Binding {
273279 target: applicationsDisplayLoader.item
qml/Stages/DesktopStage.qmlnew file+162
@@ -0,0 +1,162 @@
1+/*
2+ * Copyright (C) 2014 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+ * Authors: Michael Zanetti <michael.zanetti@canonical.com>
17+ */
18+
19+import QtQuick 2.3
20+import Ubuntu.Components 1.1
21+import Unity.Application 0.1
22+
23+Item {
24+ id: root
25+
26+ anchors.fill: parent
27+
28+ Connections {
29+ target: ApplicationManager
30+ onApplicationAdded: {
31+ // Initial placement to avoid having the window decoration behind the panel
32+ appRepeater.itemAt(ApplicationManager.count-1).y = units.gu(3)
33+ ApplicationManager.requestFocusApplication(ApplicationManager.get(ApplicationManager.count-1).appId)
34+ }
35+
36+ onFocusRequested: {
37+ var appIndex = priv.indexOf(appId);
38+ var appDelegate = appRepeater.itemAt(appIndex);
39+ if (appDelegate.state === "minimized") {
40+ appDelegate.state = "normal"
41+ }
42+ ApplicationManager.focusApplication(appId);
43+ }
44+ }
45+
46+ QtObject {
47+ id: priv
48+ function indexOf(appId) {
49+ for (var i = 0; i < ApplicationManager.count; i++) {
50+ if (ApplicationManager.get(i).appId == appId) {
51+ return i;
52+ }
53+ }
54+ return -1;
55+ }
56+ }
57+
58+ Repeater {
59+ id: appRepeater
60+ model: ApplicationManager
61+
62+ delegate: Item {
63+ id: appDelegate
64+ height: units.gu(30)
65+ width: units.gu(30)
66+ z: ApplicationManager.count - index
67+
68+ states: [
69+ State {
70+ name: "normal"
71+ },
72+ State {
73+ name: "maximized"
74+ PropertyChanges { target: appDelegate; x: 0; y: 0; width: root.width; height: root.height }
75+ },
76+ State {
77+ name: "minimized"
78+ PropertyChanges { target: appDelegate; x: -appDelegate.width / 2; scale: units.gu(5) / appDelegate.width; opacity: 0 }
79+ }
80+ ]
81+ transitions: [
82+ Transition {
83+ PropertyAnimation { target: appDelegate; properties: "x,y,opacity,width,height,scale" }
84+ }
85+ ]
86+
87+ BorderImage {
88+ anchors {
89+ fill: appDelegate
90+ margins: -units.gu(2)
91+ }
92+ source: "graphics/dropshadow2gu.sci"
93+ opacity: .3
94+ Behavior on opacity { UbuntuNumberAnimation {} }
95+ }
96+
97+ MouseArea {
98+ anchors.fill: parent
99+ anchors.margins: -units.gu(0.5)
100+
101+ property bool resizeWidth: false
102+ property bool resizeHeight: false
103+
104+ property int startX: 0
105+ property int startWidth: 0
106+ property int startY: 0
107+ property int startHeight: 0
108+
109+ onPressed: {
110+ ApplicationManager.requestFocusApplication(model.appId)
111+ if (mouseX > width - units.gu(1)) {
112+ resizeWidth = true;
113+ startX = mouseX;
114+ startWidth = appDelegate.width;
115+ }
116+ if (mouseY > height - units.gu(1)) {
117+ resizeHeight = true;
118+ startY = mouseY;
119+ startHeight = appDelegate.height;
120+ }
121+ if (!resizeHeight && !resizeWidth) {
122+ drag.target = appDelegate;
123+ }
124+ }
125+
126+ onMouseXChanged: {
127+ if (resizeWidth) {
128+ appDelegate.width = startWidth + (mouseX - startX)
129+ }
130+ }
131+ onMouseYChanged: {
132+ if (resizeHeight) {
133+ appDelegate.height = startHeight + (mouseY - startY)
134+ }
135+ }
136+
137+ onReleased: {
138+ resizeWidth = false;
139+ resizeHeight = false;
140+ drag.target = undefined;
141+ }
142+ }
143+
144+ WindowDecoration {
145+ anchors { left: parent.left; top: parent.top; right: parent.right }
146+ height: units.gu(3)
147+ title: model.name
148+ onClose: ApplicationManager.stopApplication(model.appId)
149+ onMaximize: appDelegate.state = (appDelegate.state == "maximized" ? "normal" : "maximized")
150+ onMinimize: appDelegate.state = "minimized"
151+ active: ApplicationManager.focusedApplicationId == model.appId
152+ }
153+
154+ ApplicationWindow {
155+ anchors.fill: parent
156+ anchors.topMargin: units.gu(3)
157+ application: ApplicationManager.get(index)
158+ interactive: index == 0
159+ }
160+ }
161+ }
162+}
qml/Stages/WindowDecoration.qmlnew file+87
@@ -0,0 +1,87 @@
1+/*
2+ * Copyright (C) 2014 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+ * Authors: Michael Zanetti <michael.zanetti@canonical.com>
17+ */
18+
19+import QtQuick 2.3
20+import Ubuntu.Components 1.1
21+
22+Item {
23+ id: root
24+ clip: true
25+
26+ property alias title: titleLabel.text
27+ property bool active: false
28+
29+ signal close()
30+ signal minimize()
31+ signal maximize()
32+
33+ Rectangle {
34+ anchors.fill: parent
35+ anchors.bottomMargin: -radius
36+ radius: units.gu(.5)
37+ gradient: Gradient {
38+ GradientStop { color: "#626055"; position: 0 }
39+ GradientStop { color: "#3C3B37"; position: 1 }
40+ }
41+ }
42+
43+ Row {
44+ anchors { left: parent.left; top: parent.top; bottom: parent.bottom; margins: units.gu(0.7) }
45+ spacing: units.gu(0.5)
46+ opacity: root.active ? 1 : 0.5
47+ Rectangle {
48+ height: parent.height; width: height; radius: height / 2
49+ gradient: Gradient {
50+ GradientStop { color: "#F49073"; position: 0 }
51+ GradientStop { color: "#DF4F1C"; position: 1 }
52+ }
53+ border.width: units.dp(.5)
54+ border.color: "black"
55+ MouseArea { anchors.fill: parent; onClicked: root.close() }
56+ }
57+ Rectangle {
58+ height: parent.height; width: height; radius: height / 2
59+ gradient: Gradient {
60+ GradientStop { color: "#92918C"; position: 0 }
61+ GradientStop { color: "#5E5D58"; position: 1 }
62+ }
63+ border.width: units.dp(.5)
64+ border.color: "black"
65+ MouseArea { anchors.fill: parent; onClicked: root.minimize() }
66+ }
67+ Rectangle {
68+ height: parent.height; width: height; radius: height / 2
69+ gradient: Gradient {
70+ GradientStop { color: "#92918C"; position: 0 }
71+ GradientStop { color: "#5E5D58"; position: 1 }
72+ }
73+ border.width: units.dp(.5)
74+ border.color: "black"
75+ MouseArea { anchors.fill: parent; onClicked: root.maximize() }
76+ }
77+
78+ Label {
79+ id: titleLabel
80+ color: "#DFDBD2"
81+ height: parent.height
82+ verticalAlignment: Text.AlignVCenter
83+ fontSize: "small"
84+ font.bold: true
85+ }
86+ }
87+}