@@ -90,7 +90,8 @@ AbstractStage {
90 GlobalShortcut {
90 GlobalShortcut {
91 id: minimizeRestoreShortcut
91 id: minimizeRestoreShortcut
92 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Down
92 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Down
93− onTriggered: priv.focusedAppDelegate.maximized || priv.focusedAppDelegate.maximizedLeft || priv.focusedAppDelegate.maximizedRight
93+ onTriggered: priv.focusedAppDelegate.maximized || priv.focusedAppDelegate.maximizedLeft || priv.focusedAppDelegate.maximizedRight ||
94+ priv.focusedAppDelegate.maximizedHorizontally || priv.focusedAppDelegate.maximizedVertically
94 ? priv.focusedAppDelegate.restoreFromMaximized() : priv.focusedAppDelegate.minimize()
95 ? priv.focusedAppDelegate.restoreFromMaximized() : priv.focusedAppDelegate.minimize()
95 active: priv.focusedAppDelegate !== null
96 active: priv.focusedAppDelegate !== null
@@ -159,9 +160,9 @@ AbstractStage {
160 Connections {
161 Connections {
161 target: PanelState
162 target: PanelState
162− onClose: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.close(); } }
163+ onCloseClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.close(); } }
163− onMinimize: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.minimize(); } }
164+ onMinimizeClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.minimize(); } }
164− onMaximize: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.restoreFromMaximized(); } }
165+ onRestoreClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.restoreFromMaximized(); } }
165 onFocusMaximizedApp: {
166 onFocusMaximizedApp: {
166 if (priv.foregroundMaximizedAppDelegate) {
167 if (priv.foregroundMaximizedAppDelegate) {
167 priv.foregroundMaximizedAppDelegate.focus = true;
168 priv.foregroundMaximizedAppDelegate.focus = true;
@@ -276,19 +277,16 @@ AbstractStage {
276 property alias widthIncrement: decoratedWindow.widthIncrement
277 property alias widthIncrement: decoratedWindow.widthIncrement
277 property alias heightIncrement: decoratedWindow.heightIncrement
278 property alias heightIncrement: decoratedWindow.heightIncrement
280− id: appDelegatePrivate
281− property bool maximized: false
280+ readonly property bool maximized: windowState & WindowStateStorage.WindowStateMaximized
282− property bool maximizedLeft: false
281+ readonly property bool maximizedLeft: windowState & WindowStateStorage.WindowStateMaximizedLeft
283− property bool maximizedRight: false
282+ readonly property bool maximizedRight: windowState & WindowStateStorage.WindowStateMaximizedRight
284− property bool minimized: false
283+ readonly property bool maximizedHorizontally: windowState & WindowStateStorage.WindowStateMaximizedHorizontally
285− }
284+ readonly property bool maximizedVertically: windowState & WindowStateStorage.WindowStateMaximizedVertically
286− readonly property alias maximized: appDelegatePrivate.maximized
285+ readonly property bool minimized: windowState & WindowStateStorage.WindowStateMinimized
287− readonly property alias maximizedLeft: appDelegatePrivate.maximizedLeft
288− readonly property alias maximizedRight: appDelegatePrivate.maximizedRight
289− readonly property alias minimized: appDelegatePrivate.minimized
290 readonly property alias fullscreen: decoratedWindow.fullscreen
286 readonly property alias fullscreen: decoratedWindow.fullscreen
288+ property int windowState: WindowStateStorage.WindowStateNormal
292 readonly property var application: model.application
290 readonly property var application: model.application
293 property bool animationsEnabled: true
291 property bool animationsEnabled: true
294 property alias title: decoratedWindow.title
292 property alias title: decoratedWindow.title
@@ -386,43 +384,45 @@ AbstractStage {
387 function maximize(animated) {
385 function maximize(animated) {
388 animationsEnabled = (animated === undefined) || animated;
386 animationsEnabled = (animated === undefined) || animated;
389− appDelegatePrivate.minimized = false;
387+ windowState = WindowStateStorage.WindowStateMaximized;
390− appDelegatePrivate.maximized = true;
388+ }
391− appDelegatePrivate.maximizedLeft = false;
389+ function maximizeLeft(animated) {
392− appDelegatePrivate.maximizedRight = false;
390+ animationsEnabled = (animated === undefined) || animated;
391+ windowState = WindowStateStorage.WindowStateMaximizedLeft;
393+ function maximizeRight(animated) {
394+ animationsEnabled = (animated === undefined) || animated;
395+ windowState = WindowStateStorage.WindowStateMaximizedRight;
394− function maximizeLeft() {
397+ function maximizeHorizontally(animated) {
395− appDelegatePrivate.minimized = false;
398+ animationsEnabled = (animated === undefined) || animated;
396− appDelegatePrivate.maximized = false;
399+ windowState = WindowStateStorage.WindowStateMaximizedHorizontally;
397− appDelegatePrivate.maximizedLeft = true;
398− appDelegatePrivate.maximizedRight = false;
400− function maximizeRight() {
401+ function maximizeVertically(animated) {
401− appDelegatePrivate.minimized = false;
402+ animationsEnabled = (animated === undefined) || animated;
402− appDelegatePrivate.maximized = false;
403+ windowState = WindowStateStorage.WindowStateMaximizedVertically;
403− appDelegatePrivate.maximizedLeft = false;
404− appDelegatePrivate.maximizedRight = true;
406 function minimize(animated) {
405 function minimize(animated) {
407 animationsEnabled = (animated === undefined) || animated;
406 animationsEnabled = (animated === undefined) || animated;
408− appDelegatePrivate.minimized = true;
407+ windowState |= WindowStateStorage.WindowStateMinimized; // add the minimized bit
410 function restoreFromMaximized(animated) {
409 function restoreFromMaximized(animated) {
411 animationsEnabled = (animated === undefined) || animated;
410 animationsEnabled = (animated === undefined) || animated;
412− appDelegatePrivate.minimized = false;
411+ windowState = WindowStateStorage.WindowStateNormal;
413− appDelegatePrivate.maximized = false;
414− appDelegatePrivate.maximizedLeft = false;
415− appDelegatePrivate.maximizedRight = false;
417 function restore(animated) {
413 function restore(animated) {
418 animationsEnabled = (animated === undefined) || animated;
414 animationsEnabled = (animated === undefined) || animated;
419− appDelegatePrivate.minimized = false;
415+ windowState &= ~WindowStateStorage.WindowStateMinimized; // clear the minimized bit
420 if (maximized)
416 if (maximized)
421 maximize();
417 maximize();
422 else if (maximizedLeft)
418 else if (maximizedLeft)
423 maximizeLeft();
419 maximizeLeft();
424 else if (maximizedRight)
420 else if (maximizedRight)
425 maximizeRight();
421 maximizeRight();
422+ else if (maximizedHorizontally)
423+ maximizeHorizontally();
424+ else if (maximizedVertically)
425+ maximizeVertically();
427 focus = true;
427 focus = true;
@@ -453,8 +453,7 @@ AbstractStage {
455 name: "normal";
455 name: "normal";
456− when: !appDelegate.maximized && !appDelegate.minimized
456+ when: appDelegate.windowState == WindowStateStorage.WindowStateNormal
457− && !appDelegate.maximizedLeft && !appDelegate.maximizedRight
458 PropertyChanges {
457 PropertyChanges {
459 target: appDelegate;
458 target: appDelegate;
460 visuallyMinimized: false;
459 visuallyMinimized: false;
@@ -502,13 +501,23 @@ AbstractStage {
502 requestedHeight: appContainer.height - PanelState.panelHeight
501 requestedHeight: appContainer.height - PanelState.panelHeight
505+ name: "maximizedHorizontally"; when: appDelegate.maximizedHorizontally && !appDelegate.minimized
506+ PropertyChanges { target: appDelegate; x: root.leftMargin }
507+ PropertyChanges { target: decoratedWindow; requestedWidth: appContainer.width - root.leftMargin }
510+ name: "maximizedVertically"; when: appDelegate.maximizedVertically && !appDelegate.minimized
511+ PropertyChanges { target: appDelegate; y: PanelState.panelHeight }
512+ PropertyChanges { target: decoratedWindow; requestedHeight: appContainer.height - PanelState.panelHeight }
506 name: "minimized"; when: appDelegate.minimized
515 name: "minimized"; when: appDelegate.minimized
507 PropertyChanges {
516 PropertyChanges {
508 target: appDelegate;
517 target: appDelegate;
509 x: -appDelegate.width / 2;
518 x: -appDelegate.width / 2;
510 scale: units.gu(5) / appDelegate.width;
519 scale: units.gu(5) / appDelegate.width;
511− opacity: 0
520+ opacity: 0;
512 visuallyMinimized: true;
521 visuallyMinimized: true;
513 visuallyMaximized: false
522 visuallyMaximized: false
@@ -611,10 +620,13 @@ AbstractStage {
611 requestedWidth: appDelegate.requestedWidth
620 requestedWidth: appDelegate.requestedWidth
612 requestedHeight: appDelegate.requestedHeight
621 requestedHeight: appDelegate.requestedHeight
614− onClose: { appDelegate.close(); }
623+ onCloseClicked: { appDelegate.close(); }
615− onMaximize: appDelegate.maximized || appDelegate.maximizedLeft || appDelegate.maximizedRight
624+ onMaximizeClicked: appDelegate.maximized || appDelegate.maximizedLeft || appDelegate.maximizedRight
625+ || appDelegate.maximizedHorizontally || appDelegate.maximizedVertically
616− ? appDelegate.restoreFromMaximized() : appDelegate.maximize()
626+ ? appDelegate.restoreFromMaximized() : appDelegate.maximize()
627+ onMaximizeHorizontallyClicked: appDelegate.maximizedHorizontally ? appDelegate.restoreFromMaximized() : appDelegate.maximizeHorizontally()
628+ onMaximizeVerticallyClicked: appDelegate.maximizedVertically ? appDelegate.restoreFromMaximized() : appDelegate.maximizeVertically()
617− onMinimize: appDelegate.minimize()
629+ onMinimizeClicked: appDelegate.minimize()
618 onDecorationPressed: { appDelegate.focus = true; }
630 onDecorationPressed: { appDelegate.focus = true; }