@@ -92,7 +92,8 @@ AbstractStage {
92 GlobalShortcut {
92 GlobalShortcut {
93 id: minimizeRestoreShortcut
93 id: minimizeRestoreShortcut
94 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Down
94 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
96 ? priv.focusedAppDelegate.restoreFromMaximized() : priv.focusedAppDelegate.minimize()
97 ? priv.focusedAppDelegate.restoreFromMaximized() : priv.focusedAppDelegate.minimize()
97 active: priv.focusedAppDelegate !== null
98 active: priv.focusedAppDelegate !== null
@@ -161,9 +162,9 @@ AbstractStage {
162 Connections {
163 Connections {
163 target: PanelState
164 target: PanelState
164− onClose: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.close(); } }
165+ onCloseClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.close(); } }
165− onMinimize: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.minimize(); } }
166+ onMinimizeClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.minimize(); } }
166− onRestore: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.restoreFromMaximized(); } }
167+ onRestoreClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.restoreFromMaximized(); } }
167 onFocusMaximizedApp: {
168 onFocusMaximizedApp: {
168 if (priv.foregroundMaximizedAppDelegate) {
169 if (priv.foregroundMaximizedAppDelegate) {
169 priv.foregroundMaximizedAppDelegate.focus = true;
170 priv.foregroundMaximizedAppDelegate.focus = true;
@@ -291,19 +292,16 @@ AbstractStage {
291 property alias widthIncrement: decoratedWindow.widthIncrement
292 property alias widthIncrement: decoratedWindow.widthIncrement
292 property alias heightIncrement: decoratedWindow.heightIncrement
293 property alias heightIncrement: decoratedWindow.heightIncrement
295− id: appDelegatePrivate
296− property bool maximized: false
295+ readonly property bool maximized: windowState & WindowStateStorage.WindowStateMaximized
297− property bool maximizedLeft: false
296+ readonly property bool maximizedLeft: windowState & WindowStateStorage.WindowStateMaximizedLeft
298− property bool maximizedRight: false
297+ readonly property bool maximizedRight: windowState & WindowStateStorage.WindowStateMaximizedRight
299− property bool minimized: false
298+ readonly property bool maximizedHorizontally: windowState & WindowStateStorage.WindowStateMaximizedHorizontally
300− }
299+ readonly property bool maximizedVertically: windowState & WindowStateStorage.WindowStateMaximizedVertically
301− readonly property alias maximized: appDelegatePrivate.maximized
300+ readonly property bool minimized: windowState & WindowStateStorage.WindowStateMinimized
302− readonly property alias maximizedLeft: appDelegatePrivate.maximizedLeft
303− readonly property alias maximizedRight: appDelegatePrivate.maximizedRight
304− readonly property alias minimized: appDelegatePrivate.minimized
305 readonly property alias fullscreen: decoratedWindow.fullscreen
301 readonly property alias fullscreen: decoratedWindow.fullscreen
303+ property int windowState: WindowStateStorage.WindowStateNormal
307 readonly property var application: model.application
305 readonly property var application: model.application
308 property bool animationsEnabled: true
306 property bool animationsEnabled: true
309 property alias title: decoratedWindow.title
307 property alias title: decoratedWindow.title
@@ -402,43 +400,45 @@ AbstractStage {
403 function maximize(animated) {
401 function maximize(animated) {
404 animationsEnabled = (animated === undefined) || animated;
402 animationsEnabled = (animated === undefined) || animated;
405− appDelegatePrivate.minimized = false;
403+ windowState = WindowStateStorage.WindowStateMaximized;
406− appDelegatePrivate.maximized = true;
404+ }
407− appDelegatePrivate.maximizedLeft = false;
405+ function maximizeLeft(animated) {
408− appDelegatePrivate.maximizedRight = false;
406+ animationsEnabled = (animated === undefined) || animated;
407+ windowState = WindowStateStorage.WindowStateMaximizedLeft;
409+ function maximizeRight(animated) {
410+ animationsEnabled = (animated === undefined) || animated;
411+ windowState = WindowStateStorage.WindowStateMaximizedRight;
410− function maximizeLeft() {
413+ function maximizeHorizontally(animated) {
411− appDelegatePrivate.minimized = false;
414+ animationsEnabled = (animated === undefined) || animated;
412− appDelegatePrivate.maximized = false;
415+ windowState = WindowStateStorage.WindowStateMaximizedHorizontally;
413− appDelegatePrivate.maximizedLeft = true;
414− appDelegatePrivate.maximizedRight = false;
416− function maximizeRight() {
417+ function maximizeVertically(animated) {
417− appDelegatePrivate.minimized = false;
418+ animationsEnabled = (animated === undefined) || animated;
418− appDelegatePrivate.maximized = false;
419+ windowState = WindowStateStorage.WindowStateMaximizedVertically;
419− appDelegatePrivate.maximizedLeft = false;
420− appDelegatePrivate.maximizedRight = true;
422 function minimize(animated) {
421 function minimize(animated) {
423 animationsEnabled = (animated === undefined) || animated;
422 animationsEnabled = (animated === undefined) || animated;
424− appDelegatePrivate.minimized = true;
423+ windowState |= WindowStateStorage.WindowStateMinimized; // add the minimized bit
426 function restoreFromMaximized(animated) {
425 function restoreFromMaximized(animated) {
427 animationsEnabled = (animated === undefined) || animated;
426 animationsEnabled = (animated === undefined) || animated;
428− appDelegatePrivate.minimized = false;
427+ windowState = WindowStateStorage.WindowStateNormal;
429− appDelegatePrivate.maximized = false;
430− appDelegatePrivate.maximizedLeft = false;
431− appDelegatePrivate.maximizedRight = false;
433 function restore(animated) {
429 function restore(animated) {
434 animationsEnabled = (animated === undefined) || animated;
430 animationsEnabled = (animated === undefined) || animated;
435− appDelegatePrivate.minimized = false;
431+ windowState &= ~WindowStateStorage.WindowStateMinimized; // clear the minimized bit
436 if (maximized)
432 if (maximized)
437 maximize();
433 maximize();
438 else if (maximizedLeft)
434 else if (maximizedLeft)
439 maximizeLeft();
435 maximizeLeft();
440 else if (maximizedRight)
436 else if (maximizedRight)
441 maximizeRight();
437 maximizeRight();
438+ else if (maximizedHorizontally)
439+ maximizeHorizontally();
440+ else if (maximizedVertically)
441+ maximizeVertically();
443 focus = true;
443 focus = true;
@@ -469,8 +469,7 @@ AbstractStage {
471 name: "normal";
471 name: "normal";
472− when: !appDelegate.maximized && !appDelegate.minimized
472+ when: appDelegate.windowState == WindowStateStorage.WindowStateNormal
473− && !appDelegate.maximizedLeft && !appDelegate.maximizedRight
474 PropertyChanges {
473 PropertyChanges {
475 target: appDelegate;
474 target: appDelegate;
476 visuallyMinimized: false;
475 visuallyMinimized: false;
@@ -518,13 +517,23 @@ AbstractStage {
518 requestedHeight: appContainer.height - PanelState.panelHeight
517 requestedHeight: appContainer.height - PanelState.panelHeight
521+ name: "maximizedHorizontally"; when: appDelegate.maximizedHorizontally && !appDelegate.minimized
522+ PropertyChanges { target: appDelegate; x: root.leftMargin }
523+ PropertyChanges { target: decoratedWindow; requestedWidth: appContainer.width - root.leftMargin }
526+ name: "maximizedVertically"; when: appDelegate.maximizedVertically && !appDelegate.minimized
527+ PropertyChanges { target: appDelegate; y: PanelState.panelHeight }
528+ PropertyChanges { target: decoratedWindow; requestedHeight: appContainer.height - PanelState.panelHeight }
522 name: "minimized"; when: appDelegate.minimized
531 name: "minimized"; when: appDelegate.minimized
523 PropertyChanges {
532 PropertyChanges {
524 target: appDelegate;
533 target: appDelegate;
525 x: -appDelegate.width / 2;
534 x: -appDelegate.width / 2;
526 scale: units.gu(5) / appDelegate.width;
535 scale: units.gu(5) / appDelegate.width;
527− opacity: 0
536+ opacity: 0;
528 visuallyMinimized: true;
537 visuallyMinimized: true;
529 visuallyMaximized: false
538 visuallyMaximized: false
@@ -627,10 +636,13 @@ AbstractStage {
627 requestedWidth: appDelegate.requestedWidth
636 requestedWidth: appDelegate.requestedWidth
628 requestedHeight: appDelegate.requestedHeight
637 requestedHeight: appDelegate.requestedHeight
630− onClose: { appDelegate.close(); }
639+ onCloseClicked: { appDelegate.close(); }
631− onMaximize: appDelegate.maximized || appDelegate.maximizedLeft || appDelegate.maximizedRight
640+ onMaximizeClicked: appDelegate.maximized || appDelegate.maximizedLeft || appDelegate.maximizedRight
641+ || appDelegate.maximizedHorizontally || appDelegate.maximizedVertically
632− ? appDelegate.restoreFromMaximized() : appDelegate.maximize()
642+ ? appDelegate.restoreFromMaximized() : appDelegate.maximize()
643+ onMaximizeHorizontallyClicked: appDelegate.maximizedHorizontally ? appDelegate.restoreFromMaximized() : appDelegate.maximizeHorizontally()
644+ onMaximizeVerticallyClicked: appDelegate.maximizedVertically ? appDelegate.restoreFromMaximized() : appDelegate.maximizeVertically()
633− onMinimize: appDelegate.minimize()
645+ onMinimizeClicked: appDelegate.minimize()
634 onDecorationPressed: { appDelegate.focus = true; }
646 onDecorationPressed: { appDelegate.focus = true; }