@@ -12,12 +12,9 @@
13 * You should have received a copy of the GNU General Public License
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/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16− * Authors: Michael Zanetti <michael.zanetti@canonical.com>
19import QtQuick 2.4
17import QtQuick 2.4
20−import QtQuick.Layouts 1.1
21import Ubuntu.Components 1.3
18import Ubuntu.Components 1.3
22import Unity.Application 0.1
19import Unity.Application 0.1
23import "../Components/PanelState"
20import "../Components/PanelState"
@@ -55,7 +52,7 @@ AbstractStage {
55 onFocusRequested: {
52 onFocusRequested: {
56 var appIndex = priv.indexOf(appId);
53 var appIndex = priv.indexOf(appId);
57 var appDelegate = appRepeater.itemAt(appIndex);
54 var appDelegate = appRepeater.itemAt(appIndex);
58− appDelegate.restoreFromMinimized();
55+ appDelegate.restore();
60 if (spread.state == "altTab") {
57 if (spread.state == "altTab") {
61 spread.cancel();
58 spread.cancel();
@@ -107,7 +104,7 @@ AbstractStage {
107 id: minimizeRestoreShortcut
104 id: minimizeRestoreShortcut
108 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Down
105 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Down
109 onTriggered: priv.focusedAppDelegate.maximized || priv.focusedAppDelegate.maximizedLeft || priv.focusedAppDelegate.maximizedRight
106 onTriggered: priv.focusedAppDelegate.maximized || priv.focusedAppDelegate.maximizedLeft || priv.focusedAppDelegate.maximizedRight
110− ? priv.focusedAppDelegate.restore() : priv.focusedAppDelegate.minimize(true)
107+ ? priv.focusedAppDelegate.restoreFromMaximized() : priv.focusedAppDelegate.minimize()
111 active: priv.focusedAppDelegate !== null
108 active: priv.focusedAppDelegate !== null
@@ -119,18 +116,16 @@ AbstractStage {
119 var index = indexOf(focusedAppId);
116 var index = indexOf(focusedAppId);
120 return index >= 0 && index < appRepeater.count ? appRepeater.itemAt(index) : null
117 return index >= 0 && index < appRepeater.count ? appRepeater.itemAt(index) : null
119+ onFocusedAppDelegateChanged: updateForegroundMaximizedApp();
122 property int foregroundMaximizedAppIdIndex: -1
121 property int foregroundMaximizedAppIdIndex: -1
124 function updateForegroundMaximizedApp() {
123 function updateForegroundMaximizedApp() {
125 for (var i = 0; i < appRepeater.count; i++) {
124 for (var i = 0; i < appRepeater.count; i++) {
126 var item = appRepeater.itemAt(i);
125 var item = appRepeater.itemAt(i);
128 if (item && item.visuallyMaximized) {
126 if (item && item.visuallyMaximized) {
129− var app = ApplicationManager.get(i);
131− foregroundMaximizedAppIdIndex = i;
127+ foregroundMaximizedAppIdIndex = i;
136 foregroundMaximizedAppIdIndex = -1;
131 foregroundMaximizedAppIdIndex = -1;
@@ -149,7 +144,7 @@ AbstractStage {
149 for (var i = 0; i < appRepeater.count; i++) {
144 for (var i = 0; i < appRepeater.count; i++) {
150 var appDelegate = appRepeater.itemAt(i);
145 var appDelegate = appRepeater.itemAt(i);
151 if (appDelegate && !appDelegate.minimized) {
146 if (appDelegate && !appDelegate.minimized) {
152− appDelegate.minimize(false); // minimize but don't switch focus
147+ appDelegate.minimize();
@@ -173,24 +168,47 @@ AbstractStage {
173 onClose: {
168 onClose: {
174 ApplicationManager.stopApplication(ApplicationManager.focusedApplicationId)
169 ApplicationManager.stopApplication(ApplicationManager.focusedApplicationId)
176− onMinimize: appRepeater.itemAt(0).minimize(true);
171+ onMinimize: priv.focusedAppDelegate && priv.focusedAppDelegate.minimize();
177− onMaximize: appRepeater.itemAt(0).restore();
172+ onMaximize: priv.focusedAppDelegate // don't restore minimized apps when double clicking the panel
173+ && priv.focusedAppDelegate.restoreFromMaximized();
174+ onFocusMaximizedApp: if (priv.foregroundMaximizedAppIdIndex != -1) {
175+ ApplicationManager.focusApplication(appRepeater.itemAt(priv.foregroundMaximizedAppIdIndex).appId);
180 Binding {
179 Binding {
181 target: PanelState
180 target: PanelState
182 property: "buttonsVisible"
181 property: "buttonsVisible"
183− value: priv.focusedAppDelegate !== null && priv.focusedAppDelegate.maximized
182+ value: priv.focusedAppDelegate !== null && priv.focusedAppDelegate.maximized // FIXME for Locally integrated menus
183+ && spread.state == ""
186 Binding {
186 Binding {
187 target: PanelState
187 target: PanelState
188 property: "title"
188 property: "title"
190+ if (priv.focusedAppDelegate !== null && spread.state == "") {
191+ if (priv.focusedAppDelegate.maximized)
189− value: priv.focusedAppDelegate !== null && priv.focusedAppDelegate.title
192+ return priv.focusedAppDelegate.title
194+ return priv.focusedAppDelegate.appName
190− when: priv.focusedAppDelegate && priv.focusedAppDelegate.maximized
198+ when: priv.focusedAppDelegate
203+ property: "dropShadow"
204+ value: priv.focusedAppDelegate && !priv.focusedAppDelegate.maximized && priv.foregroundMaximizedAppIdIndex !== -1
207+ Component.onDestruction: {
208+ PanelState.title = "";
193− Component.onDestruction: PanelState.buttonsVisible = false;
209+ PanelState.buttonsVisible = false;
210+ PanelState.dropShadow = false;
195 FocusScope {
213 FocusScope {
196 id: appContainer
214 id: appContainer
@@ -211,19 +229,16 @@ AbstractStage {
211 model: ApplicationManager
229 model: ApplicationManager
212 objectName: "appRepeater"
230 objectName: "appRepeater"
214− onItemAdded: priv.updateForegroundMaximizedApp()
215− onItemRemoved: priv.updateForegroundMaximizedApp()
217 delegate: FocusScope {
232 delegate: FocusScope {
218 id: appDelegate
233 id: appDelegate
219 objectName: "appDelegate_" + appId
234 objectName: "appDelegate_" + appId
220 z: ApplicationManager.count - index
235 z: ApplicationManager.count - index
221− y: units.gu(3)
236+ y: PanelState.panelHeight
237+ focus: appId === priv.focusedAppId
222 width: decoratedWindow.width
238 width: decoratedWindow.width
223 height: decoratedWindow.height
239 height: decoratedWindow.height
224 property alias requestedWidth: decoratedWindow.requestedWidth
240 property alias requestedWidth: decoratedWindow.requestedWidth
225 property alias requestedHeight: decoratedWindow.requestedHeight
241 property alias requestedHeight: decoratedWindow.requestedHeight
226− focus: model.appId === priv.focusedAppId
228 QtObject {
243 QtObject {
229 id: appDelegatePrivate
244 id: appDelegatePrivate
@@ -240,6 +255,7 @@ AbstractStage {
240 readonly property string appId: model.appId
255 readonly property string appId: model.appId
241 property bool animationsEnabled: true
256 property bool animationsEnabled: true
242 property alias title: decoratedWindow.title
257 property alias title: decoratedWindow.title
258+ readonly property string appName: model.name
243 property bool visuallyMaximized: false
259 property bool visuallyMaximized: false
244 property bool visuallyMinimized: false
260 property bool visuallyMinimized: false
@@ -249,7 +265,6 @@ AbstractStage {
252− onZChanged: priv.updateForegroundMaximizedApp()
253 onVisuallyMaximizedChanged: priv.updateForegroundMaximizedApp()
268 onVisuallyMaximizedChanged: priv.updateForegroundMaximizedApp()
255 visible: !visuallyMinimized &&
270 visible: !visuallyMinimized &&
@@ -289,17 +304,16 @@ AbstractStage {
290 function minimize(animated) {
305 function minimize(animated) {
291 animationsEnabled = (animated === undefined) || animated;
306 animationsEnabled = (animated === undefined) || animated;
292− appDelegatePrivate.maximized = false;
293 appDelegatePrivate.minimized = true;
307 appDelegatePrivate.minimized = true;
295− function restore(animated) {
309+ function restoreFromMaximized(animated) {
296 animationsEnabled = (animated === undefined) || animated;
310 animationsEnabled = (animated === undefined) || animated;
297 appDelegatePrivate.minimized = false;
311 appDelegatePrivate.minimized = false;
298 appDelegatePrivate.maximized = false;
312 appDelegatePrivate.maximized = false;
299 appDelegatePrivate.maximizedLeft = false;
313 appDelegatePrivate.maximizedLeft = false;
300 appDelegatePrivate.maximizedRight = false;
314 appDelegatePrivate.maximizedRight = false;
302− function restoreFromMinimized(animated) {
316+ function restore(animated) {
303 animationsEnabled = (animated === undefined) || animated;
317 animationsEnabled = (animated === undefined) || animated;
304 appDelegatePrivate.minimized = false;
318 appDelegatePrivate.minimized = false;
305 if (maximized)
319 if (maximized)
@@ -312,6 +326,14 @@ AbstractStage {
314 states: [
328 states: [
330+ name: "fullscreen"; when: decoratedWindow.fullscreen
333+ target: appDelegate;
334+ y: -PanelState.panelHeight
316 name: "normal";
338 name: "normal";
317 when: !appDelegate.maximized && !appDelegate.minimized
339 when: !appDelegate.maximized && !appDelegate.minimized
@@ -323,7 +345,7 @@ AbstractStage {
326− name: "maximized"; when: appDelegate.maximized
348+ name: "maximized"; when: appDelegate.maximized && !appDelegate.minimized
327 PropertyChanges {
349 PropertyChanges {
328 target: appDelegate;
350 target: appDelegate;
329 x: 0; y: 0;
351 x: 0; y: 0;
@@ -334,11 +356,13 @@ AbstractStage {
336 name: "maximizedLeft"; when: appDelegate.maximizedLeft && !appDelegate.minimized
358 name: "maximizedLeft"; when: appDelegate.maximizedLeft && !appDelegate.minimized
337− PropertyChanges { target: appDelegate; x: 0; y: units.gu(3); width: root.width/2; height: root.height - units.gu(3) }
359+ PropertyChanges { target: appDelegate; x: 0; y: PanelState.panelHeight;
360+ requestedWidth: root.width/2; requestedHeight: root.height - PanelState.panelHeight }
340 name: "maximizedRight"; when: appDelegate.maximizedRight && !appDelegate.minimized
363 name: "maximizedRight"; when: appDelegate.maximizedRight && !appDelegate.minimized
341− PropertyChanges { target: appDelegate; x: root.width/2; y: units.gu(3); width: root.width/2; height: root.height - units.gu(3) }
364+ PropertyChanges { target: appDelegate; x: root.width/2; y: PanelState.panelHeight;
365+ requestedWidth: root.width/2; requestedHeight: root.height - PanelState.panelHeight }
344 name: "minimized"; when: appDelegate.minimized
368 name: "minimized"; when: appDelegate.minimized
@@ -359,15 +383,6 @@ AbstractStage {
359 PropertyAction { target: appDelegate; properties: "visuallyMinimized,visuallyMaximized" }
383 PropertyAction { target: appDelegate; properties: "visuallyMinimized,visuallyMaximized" }
360 UbuntuNumberAnimation { target: appDelegate; properties: "x,y,opacity,requestedWidth,requestedHeight,scale"; duration: UbuntuAnimation.FastDuration }
384 UbuntuNumberAnimation { target: appDelegate; properties: "x,y,opacity,requestedWidth,requestedHeight,scale"; duration: UbuntuAnimation.FastDuration }
364− enabled: appDelegate.animationsEnabled
365− PropertyAction { target: appDelegate; property: "visuallyMinimized" }
366− SequentialAnimation {
367− UbuntuNumberAnimation { target: appDelegate; properties: "x,y,opacity,requestedWidth,requestedHeight,scale"; duration: UbuntuAnimation.FastDuration }
368− PropertyAction { target: appDelegate; property: "visuallyMaximized" }
371 Transition {
386 Transition {
372 to: "minimized"
387 to: "minimized"
373 enabled: appDelegate.animationsEnabled
388 enabled: appDelegate.animationsEnabled
@@ -377,12 +392,21 @@ AbstractStage {
377 PropertyAction { target: appDelegate; property: "visuallyMinimized" }
392 PropertyAction { target: appDelegate; property: "visuallyMinimized" }
378 ScriptAction {
393 ScriptAction {
379 script: {
394 script: {
380− if (appDelegate.animationsEnabled && state === "minimized" ) {
395+ if (appDelegate.minimized) {
381 priv.focusNext();
396 priv.focusNext();
403+ to: "*" //maximized and fullscreen
404+ enabled: appDelegate.animationsEnabled
405+ PropertyAction { target: appDelegate; property: "visuallyMinimized" }
406+ SequentialAnimation {
407+ UbuntuNumberAnimation { target: appDelegate; properties: "x,y,opacity,requestedWidth,requestedHeight,scale"; duration: UbuntuAnimation.FastDuration }
408+ PropertyAction { target: appDelegate; property: "visuallyMaximized" }
@@ -418,8 +442,8 @@ AbstractStage {
419 onClose: ApplicationManager.stopApplication(model.appId)
443 onClose: ApplicationManager.stopApplication(model.appId)
420 onMaximize: appDelegate.maximized || appDelegate.maximizedLeft || appDelegate.maximizedRight
444 onMaximize: appDelegate.maximized || appDelegate.maximizedLeft || appDelegate.maximizedRight
421− ? appDelegate.restore() : appDelegate.maximize()
445+ ? appDelegate.restoreFromMaximized() : appDelegate.maximize()
422− onMinimize: appDelegate.minimize(true)
446+ onMinimize: appDelegate.minimize()
423 onDecorationPressed: { ApplicationManager.focusApplication(model.appId) }
447 onDecorationPressed: { ApplicationManager.focusApplication(model.appId) }