@@ -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+}