@@ -89,7 +89,8 @@ AbstractStage {
89 GlobalShortcut {
89 GlobalShortcut {
90 id: minimizeRestoreShortcut
90 id: minimizeRestoreShortcut
91 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Down
91 shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Down
92− onTriggered: priv.focusedAppDelegate.maximized || priv.focusedAppDelegate.maximizedLeft || priv.focusedAppDelegate.maximizedRight
92+ onTriggered: priv.focusedAppDelegate.maximized || priv.focusedAppDelegate.maximizedLeft || priv.focusedAppDelegate.maximizedRight ||
93+ priv.focusedAppDelegate.maximizedHorizontally || priv.focusedAppDelegate.maximizedVertically
93 ? priv.focusedAppDelegate.restoreFromMaximized() : priv.focusedAppDelegate.minimize()
94 ? priv.focusedAppDelegate.restoreFromMaximized() : priv.focusedAppDelegate.minimize()
94 active: priv.focusedAppDelegate !== null
95 active: priv.focusedAppDelegate !== null
@@ -262,19 +263,16 @@ AbstractStage {
262 property alias widthIncrement: decoratedWindow.widthIncrement
263 property alias widthIncrement: decoratedWindow.widthIncrement
263 property alias heightIncrement: decoratedWindow.heightIncrement
264 property alias heightIncrement: decoratedWindow.heightIncrement
266− id: appDelegatePrivate
267− property bool maximized: false
266+ readonly property bool maximized: windowState & WindowStateStorage.WindowStateMaximized
268− property bool maximizedLeft: false
267+ readonly property bool maximizedLeft: windowState & WindowStateStorage.WindowStateMaximizedLeft
269− property bool maximizedRight: false
268+ readonly property bool maximizedRight: windowState & WindowStateStorage.WindowStateMaximizedRight
270− property bool minimized: false
269+ readonly property bool maximizedHorizontally: windowState & WindowStateStorage.WindowStateMaximizedHorizontally
271− }
270+ readonly property bool maximizedVertically: windowState & WindowStateStorage.WindowStateMaximizedVertically
272− readonly property alias maximized: appDelegatePrivate.maximized
271+ readonly property bool minimized: windowState & WindowStateStorage.WindowStateMinimized
273− readonly property alias maximizedLeft: appDelegatePrivate.maximizedLeft
274− readonly property alias maximizedRight: appDelegatePrivate.maximizedRight
275− readonly property alias minimized: appDelegatePrivate.minimized
276 readonly property alias fullscreen: decoratedWindow.fullscreen
272 readonly property alias fullscreen: decoratedWindow.fullscreen
274+ property int windowState: WindowStateStorage.WindowStateNormal
278 readonly property var application: model.application
276 readonly property var application: model.application
279 property bool animationsEnabled: true
277 property bool animationsEnabled: true
280 property alias title: decoratedWindow.title
278 property alias title: decoratedWindow.title
@@ -372,43 +370,41 @@ AbstractStage {
373 function maximize(animated) {
371 function maximize(animated) {
374 animationsEnabled = (animated === undefined) || animated;
372 animationsEnabled = (animated === undefined) || animated;
375− appDelegatePrivate.minimized = false;
373+ windowState = WindowStateStorage.WindowStateMaximized;
376− appDelegatePrivate.maximized = true;
377− appDelegatePrivate.maximizedLeft = false;
378− appDelegatePrivate.maximizedRight = false;
380 function maximizeLeft() {
375 function maximizeLeft() {
381− appDelegatePrivate.minimized = false;
376+ windowState = WindowStateStorage.WindowStateMaximizedLeft;
382− appDelegatePrivate.maximized = false;
383− appDelegatePrivate.maximizedLeft = true;
384− appDelegatePrivate.maximizedRight = false;
386 function maximizeRight() {
378 function maximizeRight() {
387− appDelegatePrivate.minimized = false;
379+ windowState = WindowStateStorage.WindowStateMaximizedRight;
388− appDelegatePrivate.maximized = false;
380+ }
389− appDelegatePrivate.maximizedLeft = false;
381+ function maximizeHorizontally() {
390− appDelegatePrivate.maximizedRight = true;
382+ windowState = WindowStateStorage.WindowStateMaximizedHorizontally;
384+ function maximizeVertically() {
385+ windowState = WindowStateStorage.WindowStateMaximizedVertically;
392 function minimize(animated) {
387 function minimize(animated) {
393 animationsEnabled = (animated === undefined) || animated;
388 animationsEnabled = (animated === undefined) || animated;
394− appDelegatePrivate.minimized = true;
389+ windowState |= WindowStateStorage.WindowStateMinimized; // add the minimized bit
396 function restoreFromMaximized(animated) {
391 function restoreFromMaximized(animated) {
397 animationsEnabled = (animated === undefined) || animated;
392 animationsEnabled = (animated === undefined) || animated;
398− appDelegatePrivate.minimized = false;
393+ windowState = WindowStateStorage.WindowStateNormal;
399− appDelegatePrivate.maximized = false;
400− appDelegatePrivate.maximizedLeft = false;
401− appDelegatePrivate.maximizedRight = false;
403 function restore(animated) {
395 function restore(animated) {
404 animationsEnabled = (animated === undefined) || animated;
396 animationsEnabled = (animated === undefined) || animated;
405− appDelegatePrivate.minimized = false;
397+ windowState &= ~WindowStateStorage.WindowStateMinimized; // clear the minimized bit
406 if (maximized)
398 if (maximized)
407 maximize();
399 maximize();
408 else if (maximizedLeft)
400 else if (maximizedLeft)
409 maximizeLeft();
401 maximizeLeft();
410 else if (maximizedRight)
402 else if (maximizedRight)
411 maximizeRight();
403 maximizeRight();
404+ else if (maximizedHorizontally)
405+ maximizeHorizontally();
406+ else if (maximizedVertically)
407+ maximizeVertically();
413 focus = true;
409 focus = true;
@@ -439,8 +435,7 @@ AbstractStage {
441 name: "normal";
437 name: "normal";
442− when: !appDelegate.maximized && !appDelegate.minimized
438+ when: appDelegate.windowState == WindowStateStorage.WindowStateNormal
443− && !appDelegate.maximizedLeft && !appDelegate.maximizedRight
444 PropertyChanges {
439 PropertyChanges {
445 target: appDelegate;
440 target: appDelegate;
446 visuallyMinimized: false;
441 visuallyMinimized: false;
@@ -488,13 +483,21 @@ AbstractStage {
488 requestedHeight: appContainer.height - PanelState.panelHeight
483 requestedHeight: appContainer.height - PanelState.panelHeight
487+ name: "maximizedHorizontally"; when: appDelegate.maximizedHorizontally && !appDelegate.minimized
488+ PropertyChanges { target: appDelegate; x: root.leftMargin; requestedWidth: appContainer.width - root.leftMargin }
491+ name: "maximizedVertically"; when: appDelegate.maximizedVertically && !appDelegate.minimized
492+ PropertyChanges { target: appDelegate; y: PanelState.panelHeight; requestedHeight: appContainer.height - PanelState.panelHeight }
492 name: "minimized"; when: appDelegate.minimized
495 name: "minimized"; when: appDelegate.minimized
493 PropertyChanges {
496 PropertyChanges {
494 target: appDelegate;
497 target: appDelegate;
495 x: -appDelegate.width / 2;
498 x: -appDelegate.width / 2;
496 scale: units.gu(5) / appDelegate.width;
499 scale: units.gu(5) / appDelegate.width;
497− opacity: 0
500+ opacity: 0;
498 visuallyMinimized: true;
501 visuallyMinimized: true;
499 visuallyMaximized: false
502 visuallyMaximized: false
@@ -599,7 +602,10 @@ AbstractStage {
600 onClose: { appDelegate.close(); }
603 onClose: { appDelegate.close(); }
601 onMaximize: appDelegate.maximized || appDelegate.maximizedLeft || appDelegate.maximizedRight
604 onMaximize: appDelegate.maximized || appDelegate.maximizedLeft || appDelegate.maximizedRight
605+ || appDelegate.maximizedHorizontally || appDelegate.maximizedVertically
602 ? appDelegate.restoreFromMaximized() : appDelegate.maximize()
606 ? appDelegate.restoreFromMaximized() : appDelegate.maximize()
607+ onMaximizeHorizontally: appDelegate.maximizedHorizontally ? appDelegate.restoreFromMaximized() : appDelegate.maximizeHorizontally()
608+ onMaximizeVertically: appDelegate.maximizedVertically ? appDelegate.restoreFromMaximized() : appDelegate.maximizeVertically()
603 onMinimize: appDelegate.minimize()
609 onMinimize: appDelegate.minimize()
604 onDecorationPressed: { appDelegate.focus = true; }
610 onDecorationPressed: { appDelegate.focus = true; }