@@ -92,7 +92,8 @@ AbstractStage {
9292 GlobalShortcut {
9393 id: minimizeRestoreShortcut
9494 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Down
95− onTriggered: priv.focusedAppDelegate.maximized || priv.focusedAppDelegate.maximizedLeft || priv.focusedAppDelegate.maximizedRight
95+ onTriggered: priv.focusedAppDelegate.maximized || priv.focusedAppDelegate.maximizedLeft || priv.focusedAppDelegate.maximizedRight ||
96+ priv.focusedAppDelegate.maximizedHorizontally || priv.focusedAppDelegate.maximizedVertically
9697 ? priv.focusedAppDelegate.restoreFromMaximized() : priv.focusedAppDelegate.minimize()
9798 active: priv.focusedAppDelegate !== null
9899 }
@@ -161,9 +162,9 @@ AbstractStage {
161162
162163 Connections {
163164 target: PanelState
164− onClose: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.close(); } }
165− onMinimize: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.minimize(); } }
166− onRestore: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.restoreFromMaximized(); } }
165+ onCloseClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.close(); } }
166+ onMinimizeClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.minimize(); } }
167+ onRestoreClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.restoreFromMaximized(); } }
167168 onFocusMaximizedApp: {
168169 if (priv.foregroundMaximizedAppDelegate) {
169170 priv.foregroundMaximizedAppDelegate.focus = true;
@@ -291,19 +292,16 @@ AbstractStage {
291292 property alias widthIncrement: decoratedWindow.widthIncrement
292293 property alias heightIncrement: decoratedWindow.heightIncrement
293294
294− QtObject {
295− id: appDelegatePrivate
296− property bool maximized: false
297− property bool maximizedLeft: false
298− property bool maximizedRight: false
299− property bool minimized: false
300− }
301− readonly property alias maximized: appDelegatePrivate.maximized
302− readonly property alias maximizedLeft: appDelegatePrivate.maximizedLeft
303− readonly property alias maximizedRight: appDelegatePrivate.maximizedRight
304− readonly property alias minimized: appDelegatePrivate.minimized
295+ readonly property bool maximized: windowState & WindowStateStorage.WindowStateMaximized
296+ readonly property bool maximizedLeft: windowState & WindowStateStorage.WindowStateMaximizedLeft
297+ readonly property bool maximizedRight: windowState & WindowStateStorage.WindowStateMaximizedRight
298+ readonly property bool maximizedHorizontally: windowState & WindowStateStorage.WindowStateMaximizedHorizontally
299+ readonly property bool maximizedVertically: windowState & WindowStateStorage.WindowStateMaximizedVertically
300+ readonly property bool minimized: windowState & WindowStateStorage.WindowStateMinimized
305301 readonly property alias fullscreen: decoratedWindow.fullscreen
306302
303+ property int windowState: WindowStateStorage.WindowStateNormal
304+
307305 readonly property var application: model.application
308306 property bool animationsEnabled: true
309307 property alias title: decoratedWindow.title
@@ -402,43 +400,45 @@ AbstractStage {
402400
403401 function maximize(animated) {
404402 animationsEnabled = (animated === undefined) || animated;
405− appDelegatePrivate.minimized = false;
406− appDelegatePrivate.maximized = true;
407− appDelegatePrivate.maximizedLeft = false;
408− appDelegatePrivate.maximizedRight = false;
403+ windowState = WindowStateStorage.WindowStateMaximized;
404+ }
405+ function maximizeLeft(animated) {
406+ animationsEnabled = (animated === undefined) || animated;
407+ windowState = WindowStateStorage.WindowStateMaximizedLeft;
408+ }
409+ function maximizeRight(animated) {
410+ animationsEnabled = (animated === undefined) || animated;
411+ windowState = WindowStateStorage.WindowStateMaximizedRight;
409412 }
410− function maximizeLeft() {
411− appDelegatePrivate.minimized = false;
412− appDelegatePrivate.maximized = false;
413− appDelegatePrivate.maximizedLeft = true;
414− appDelegatePrivate.maximizedRight = false;
413+ function maximizeHorizontally(animated) {
414+ animationsEnabled = (animated === undefined) || animated;
415+ windowState = WindowStateStorage.WindowStateMaximizedHorizontally;
415416 }
416− function maximizeRight() {
417− appDelegatePrivate.minimized = false;
418− appDelegatePrivate.maximized = false;
419− appDelegatePrivate.maximizedLeft = false;
420− appDelegatePrivate.maximizedRight = true;
417+ function maximizeVertically(animated) {
418+ animationsEnabled = (animated === undefined) || animated;
419+ windowState = WindowStateStorage.WindowStateMaximizedVertically;
421420 }
422421 function minimize(animated) {
423422 animationsEnabled = (animated === undefined) || animated;
424− appDelegatePrivate.minimized = true;
423+ windowState |= WindowStateStorage.WindowStateMinimized; // add the minimized bit
425424 }
426425 function restoreFromMaximized(animated) {
427426 animationsEnabled = (animated === undefined) || animated;
428− appDelegatePrivate.minimized = false;
429− appDelegatePrivate.maximized = false;
430− appDelegatePrivate.maximizedLeft = false;
431− appDelegatePrivate.maximizedRight = false;
427+ windowState = WindowStateStorage.WindowStateNormal;
432428 }
433429 function restore(animated) {
434430 animationsEnabled = (animated === undefined) || animated;
435− appDelegatePrivate.minimized = false;
431+ windowState &= ~WindowStateStorage.WindowStateMinimized; // clear the minimized bit
436432 if (maximized)
437433 maximize();
438434 else if (maximizedLeft)
439435 maximizeLeft();
440436 else if (maximizedRight)
441437 maximizeRight();
438+ else if (maximizedHorizontally)
439+ maximizeHorizontally();
440+ else if (maximizedVertically)
441+ maximizeVertically();
442442
443443 focus = true;
444444 }
@@ -469,8 +469,7 @@ AbstractStage {
469469 },
470470 State {
471471 name: "normal";
472− when: !appDelegate.maximized && !appDelegate.minimized
473− && !appDelegate.maximizedLeft && !appDelegate.maximizedRight
472+ when: appDelegate.windowState == WindowStateStorage.WindowStateNormal
474473 PropertyChanges {
475474 target: appDelegate;
476475 visuallyMinimized: false;
@@ -518,13 +517,23 @@ AbstractStage {
518517 requestedHeight: appContainer.height - PanelState.panelHeight
519518 }
520519 },
520+ State {
521+ name: "maximizedHorizontally"; when: appDelegate.maximizedHorizontally && !appDelegate.minimized
522+ PropertyChanges { target: appDelegate; x: root.leftMargin }
523+ PropertyChanges { target: decoratedWindow; requestedWidth: appContainer.width - root.leftMargin }
524+ },
525+ State {
526+ name: "maximizedVertically"; when: appDelegate.maximizedVertically && !appDelegate.minimized
527+ PropertyChanges { target: appDelegate; y: PanelState.panelHeight }
528+ PropertyChanges { target: decoratedWindow; requestedHeight: appContainer.height - PanelState.panelHeight }
529+ },
521530 State {
522531 name: "minimized"; when: appDelegate.minimized
523532 PropertyChanges {
524533 target: appDelegate;
525534 x: -appDelegate.width / 2;
526535 scale: units.gu(5) / appDelegate.width;
527− opacity: 0
536+ opacity: 0;
528537 visuallyMinimized: true;
529538 visuallyMaximized: false
530539 }
@@ -627,10 +636,13 @@ AbstractStage {
627636 requestedWidth: appDelegate.requestedWidth
628637 requestedHeight: appDelegate.requestedHeight
629638
630− onClose: { appDelegate.close(); }
631− onMaximize: appDelegate.maximized || appDelegate.maximizedLeft || appDelegate.maximizedRight
632− ? appDelegate.restoreFromMaximized() : appDelegate.maximize()
633− onMinimize: appDelegate.minimize()
639+ onCloseClicked: { appDelegate.close(); }
640+ onMaximizeClicked: appDelegate.maximized || appDelegate.maximizedLeft || appDelegate.maximizedRight
641+ || appDelegate.maximizedHorizontally || appDelegate.maximizedVertically
642+ ? appDelegate.restoreFromMaximized() : appDelegate.maximize()
643+ onMaximizeHorizontallyClicked: appDelegate.maximizedHorizontally ? appDelegate.restoreFromMaximized() : appDelegate.maximizeHorizontally()
644+ onMaximizeVerticallyClicked: appDelegate.maximizedVertically ? appDelegate.restoreFromMaximized() : appDelegate.maximizeVertically()
645+ onMinimizeClicked: appDelegate.minimize()
634646 onDecorationPressed: { appDelegate.focus = true; }
635647 }
636648