on xenial help sign in
first somewhat working desktop stage
commite5eb93d507e0cd9823202bfd6b4eb7566a3cf79a authorMichael Zanetti <michael.zanetti@canonical.com> dateTue 18 Nov 2014, 23:51 (12 years ago) parent02ab6f8
3 files changed+213−1
qml/Shell.qml+2−1 qml/Stages/DesktopStage.qml+144 qml/Stages/WindowDecoration.qml+67
qml/Shell.qml+2−1
@@ -254,7 +254,8 @@ Item {
254254 // the screen larger (maybe connects to monitor) and tries to enter
255255 // tablet mode.
256256 property bool tabletMode: shell.sideStageEnabled && !greeter.hasLockedApp
257− source: tabletMode ? "Stages/TabletStage.qml" : "Stages/PhoneStage.qml"
257+ //source: tabletMode ? "Stages/TabletStage.qml" : "Stages/PhoneStage.qml"
258+ source: "Stages/DesktopStage.qml"
258259
259260 Binding {
260261 target: applicationsDisplayLoader.item
qml/Stages/DesktopStage.qmlnew file+144
@@ -0,0 +1,144 @@
1+import QtQuick 2.3
2+import Ubuntu.Components 1.1
3+import Unity.Application 0.1
4+
5+Item {
6+ id: root
7+
8+ anchors.fill: parent
9+
10+ Connections {
11+ target: ApplicationManager
12+ onApplicationAdded: {
13+ ApplicationManager.requestFocusApplication(ApplicationManager.get(ApplicationManager.count-1).appId)
14+// ApplicationManager.move(ApplicationManager.count - 1, 0)
15+ }
16+
17+ onFocusRequested: {
18+ var appIndex = priv.indexOf(appId);
19+ ApplicationManager.move(appIndex, 0);
20+ ApplicationManager.focusApplication(appId);
21+ appRepeater.itemAt(appIndex).state = "normal"
22+ }
23+ }
24+
25+ QtObject {
26+ id: priv
27+ function indexOf(appId) {
28+ for (var i = 0; i < ApplicationManager.count; i++) {
29+ if (ApplicationManager.get(i).appId == appId) {
30+ return i;
31+ }
32+ }
33+ return -1;
34+ }
35+
36+
37+ }
38+
39+ Repeater {
40+ id: appRepeater
41+ model: ApplicationManager
42+
43+ delegate: Item {
44+ id: appDelegate
45+ x: units.gu(5)
46+ y: units.gu(5)
47+ height: units.gu(30)
48+ width: units.gu(30)
49+ z: ApplicationManager.count - index
50+
51+ states: [
52+ State {
53+ name: "normal"
54+ },
55+ State {
56+ name: "maximized"
57+ PropertyChanges { target: appDelegate; x: 0; y: 0; width: root.width; height: root.height }
58+ },
59+ State {
60+ name: "minimized"
61+ PropertyChanges { target: appDelegate; x: 0; width: units.gu(5); height: units.gu(5); opacity: 0 }
62+ }
63+ ]
64+ transitions: [
65+ Transition {
66+ PropertyAnimation { target: appDelegate; properties: "x,y,opacity,width,height" }
67+ }
68+ ]
69+
70+ BorderImage {
71+ anchors {
72+ fill: appDelegate
73+ margins: -units.gu(2)
74+ }
75+ source: "graphics/dropshadow2gu.sci"
76+ opacity: .3
77+ Behavior on opacity { UbuntuNumberAnimation {} }
78+ }
79+
80+ MouseArea {
81+ anchors.fill: parent
82+ anchors.margins: -units.gu(0.5)
83+
84+ property bool resizeWidth: false
85+ property bool resizeHeight: false
86+
87+ property int startX: 0
88+ property int startWidth: 0
89+ property int startY: 0
90+ property int startHeight: 0
91+
92+ onPressed: {
93+ ApplicationManager.requestFocusApplication(model.appId)
94+ if (mouseX > width - units.gu(1)) {
95+ resizeWidth = true;
96+ startX = mouseX;
97+ startWidth = appDelegate.width;
98+ }
99+ if (mouseY > height - units.gu(1)) {
100+ resizeHeight = true;
101+ startY = mouseY;
102+ startHeight = appDelegate.height;
103+ }
104+ if (!resizeHeight && !resizeWidth) {
105+ drag.target = appDelegate;
106+ }
107+ }
108+
109+ onMouseXChanged: {
110+ if (resizeWidth) {
111+ appDelegate.width = startWidth + (mouseX - startX)
112+ }
113+ }
114+ onMouseYChanged: {
115+ if (resizeHeight) {
116+ appDelegate.height = startHeight + (mouseY - startY)
117+ }
118+ }
119+
120+ onReleased: {
121+ resizeWidth = false;
122+ resizeHeight = false;
123+ drag.target = undefined;
124+ }
125+ }
126+
127+ WindowDecoration {
128+ anchors { left: parent.left; top: parent.top; right: parent.right }
129+ height: units.gu(3)
130+ title: model.name
131+ onClose: ApplicationManager.stopApplication(model.appId)
132+ onMaximize: appDelegate.state = "maximized"
133+ onMinimize: appDelegate.state = "minimized"
134+ }
135+
136+ ApplicationWindow {
137+ anchors.fill: parent
138+ anchors.topMargin: units.gu(3)
139+ application: ApplicationManager.get(index)
140+ interactive: index == 0
141+ }
142+ }
143+ }
144+}
qml/Stages/WindowDecoration.qmlnew file+67
@@ -0,0 +1,67 @@
1+import QtQuick 2.3
2+import Ubuntu.Components 1.1
3+
4+Item {
5+ id: root
6+ clip: true
7+
8+ property alias title: titleLabel.text
9+
10+ signal close()
11+ signal minimize()
12+ signal maximize()
13+
14+ Rectangle {
15+ anchors.fill: parent
16+ anchors.bottomMargin: -radius
17+ radius: units.gu(.5)
18+ gradient: Gradient {
19+ GradientStop { color: "#626055"; position: 0 }
20+ GradientStop { color: "#3C3B37"; position: 1 }
21+ }
22+ }
23+
24+ Row {
25+ anchors { left: parent.left; top: parent.top; bottom: parent.bottom; margins: units.gu(0.7) }
26+ spacing: units.gu(0.5)
27+ Rectangle {
28+ height: parent.height; width: height; radius: height / 2
29+ gradient: Gradient {
30+ GradientStop { color: "#F49073"; position: 0 }
31+ GradientStop { color: "#DF4F1C"; position: 1 }
32+ }
33+ border.width: units.dp(.5)
34+ border.color: "black"
35+ MouseArea { anchors.fill: parent; onClicked: root.close() }
36+ }
37+ Rectangle {
38+ height: parent.height; width: height; radius: height / 2
39+ gradient: Gradient {
40+ GradientStop { color: "#92918C"; position: 0 }
41+ GradientStop { color: "#5E5D58"; position: 1 }
42+ }
43+ border.width: units.dp(.5)
44+ border.color: "black"
45+ MouseArea { anchors.fill: parent; onClicked: root.minimize() }
46+ }
47+ Rectangle {
48+ height: parent.height; width: height; radius: height / 2
49+ gradient: Gradient {
50+ GradientStop { color: "#92918C"; position: 0 }
51+ GradientStop { color: "#5E5D58"; position: 1 }
52+ }
53+ border.width: units.dp(.5)
54+ border.color: "black"
55+ MouseArea { anchors.fill: parent; onClicked: root.maximize() }
56+ }
57+
58+ Label {
59+ id: titleLabel
60+ color: "#DFDBD2"
61+ height: parent.height
62+ verticalAlignment: Text.AlignVCenter
63+ fontSize: "small"
64+ font.bold: true
65+ }
66+ }
67+}