on xenial help sign in
Address review comments; consolidate some shared stage code
commit0a7be36786ede550b0c366f33c29759af04c8441 authorMichael Terry <michael.terry@canonical.com> dateThu 15 Oct 2015, 12:56 (11 years ago) parente1261bc
4 files changed+50−74
qml/Stages/AbstractStage.qml+26 qml/Stages/DesktopStage.qml+3−20 qml/Stages/PhoneStage.qml+13−28 qml/Stages/TabletStage.qml+8−26
qml/Stages/AbstractStage.qml+26
@@ -21,6 +21,32 @@ import GSettings 1.0
2121Rectangle {
2222 id: root
2323
24+ color: "#111111"
25+
26+ // Controls to be set from outside
27+ property bool altTabPressed
28+ property url background
29+ property bool beingResized
30+ property int dragAreaWidth
31+ property bool interactive
32+ property real inverseProgress // This is the progress for left edge drags, in pixels.
33+ property bool keepDashRunning: true
34+ property real maximizedAppTopMargin
35+ property real nativeHeight
36+ property int nativeOrientation
37+ property real nativeWidth
38+ property int shellOrientation
39+ property int shellOrientationAngle
40+ property int shellPrimaryOrientation
41+ property bool spreadEnabled: true // If false, animations and right edge will be disabled
42+ property bool suspended
43+
44+ // To be read from outside
45+ property var mainApp: null
46+ property int mainAppWindowOrientationAngle
47+ property bool orientationChangesEnabled
48+
49+ // Shared code for use in stage implementations
2450 GSettings {
2551 id: lifecycleExceptions
2652 schema.id: "com.canonical.qtmir"
qml/Stages/DesktopStage.qml+3−20
@@ -29,32 +29,13 @@ AbstractStage {
2929 id: root
3030 anchors.fill: parent
3131
32− // Controls to be set from outside
33− property int dragAreaWidth // just to comply with the interface shared between stages
34− property real maximizedAppTopMargin
35− property bool interactive
36− property bool spreadEnabled // just to comply with the interface shared between stages
37− property real inverseProgress: 0 // just to comply with the interface shared between stages
38− property int shellOrientationAngle: 0
39− property int shellOrientation
40− property int shellPrimaryOrientation
41− property int nativeOrientation
42− property bool beingResized: false
43− property bool keepDashRunning: true
44− property bool suspended: false
45− property alias background: wallpaper.source
46− property alias altTabPressed: spread.altTabPressed
47−
4832 // functions to be called from outside
4933 function updateFocusedAppOrientation() { /* TODO */ }
5034 function updateFocusedAppOrientationAnimated() { /* TODO */}
5135
52− // To be read from outside
53− readonly property var mainApp: ApplicationManager.focusedApplicationId
36+ mainApp: ApplicationManager.focusedApplicationId
5437 ? ApplicationManager.findApplication(ApplicationManager.focusedApplicationId)
5538 : null
56− property int mainAppWindowOrientationAngle: 0
57− readonly property bool orientationChangesEnabled: false
5839
5940 Connections {
6041 target: ApplicationManager
@@ -121,6 +102,7 @@ AbstractStage {
121102 CrossFadeImage {
122103 id: wallpaper
123104 anchors.fill: parent
105+ source: root.background
124106 sourceSize { height: root.height; width: root.width }
125107 fillMode: Image.PreserveAspectCrop
126108 }
@@ -272,5 +254,6 @@ AbstractStage {
272254 anchors.fill: parent
273255 workspace: appContainer
274256 focus: state == "altTab"
257+ altTabPressed: root.altTabPressed
275258 }
276259}
qml/Stages/PhoneStage.qml+13−28
@@ -25,26 +25,11 @@ import "../Components"
2525AbstractStage {
2626 id: root
2727
28− // Controls to be set from outside
29− property int dragAreaWidth
30− property real maximizedAppTopMargin
31− property bool interactive
32− property bool spreadEnabled: true // If false, animations and right edge will be disabled
33− property real inverseProgress: 0 // This is the progress for left edge drags, in pixels.
3428 property QtObject applicationManager: ApplicationManager
3529 property bool focusFirstApp: true // If false, focused app will appear on right edge like other apps
3630 property bool altTabEnabled: true
3731 property real startScale: 1.1
3832 property real endScale: 0.7
39− property bool keepDashRunning: true
40− property bool suspended: false
41− property int shellOrientationAngle: 0
42− property int shellOrientation
43− property int shellPrimaryOrientation
44− property int nativeOrientation
45− property real nativeWidth
46− property real nativeHeight
47− property bool beingResized: false
4833 onBeingResizedChanged: {
4934 if (beingResized) {
5035 // Brace yourselves for impact!
@@ -56,6 +41,8 @@ AbstractStage {
5641 priv.reset();
5742 }
5843 }
44+
45+ // Functions to be called from outside
5946 function updateFocusedAppOrientation() {
6047 if (spreadRepeater.count > 0) {
6148 spreadRepeater.itemAt(0).matchShellOrientation();
@@ -85,16 +72,14 @@ AbstractStage {
8572 }
8673 }
8774
88− // To be read from outside
89− readonly property var mainApp: applicationManager.focusedApplicationId
75+ mainApp: applicationManager.focusedApplicationId
9076 ? applicationManager.findApplication(applicationManager.focusedApplicationId)
9177 : null
9278
93− property int mainAppWindowOrientationAngle: 0
94− readonly property bool orientationChangesEnabled: priv.focusedAppOrientationChangesEnabled
95− && !priv.focusedAppDelegateIsDislocated
96− && !(priv.focusedAppDelegate && priv.focusedAppDelegate.xBehavior.running)
97− && spreadView.phase === 0
79+ orientationChangesEnabled: priv.focusedAppOrientationChangesEnabled
80+ && !priv.focusedAppDelegateIsDislocated
81+ && !(priv.focusedAppDelegate && priv.focusedAppDelegate.xBehavior.running)
82+ && spreadView.phase === 0
9883
9984 // How far left the stage has been dragged
10085 readonly property real dragProgress: spreadRepeater.count > 0 ? -spreadRepeater.itemAt(0).xTranslate : 0
@@ -106,8 +91,6 @@ AbstractStage {
10691
10792 signal opened()
10893
109− color: "#111111"
110−
11194 function select(appId) {
11295 spreadView.snapTo(priv.indexOf(appId));
11396 }
@@ -438,19 +421,21 @@ AbstractStage {
438421 dropShadow: spreadView.active || priv.focusedAppDelegateIsDislocated
439422 focusFirstApp: root.focusFirstApp
440423
424+ readonly property bool isDash: model.appId == "unity8-dash"
425+
426+ readonly property bool canSuspend: model.isTouchApp
427+ && !isExemptFromLifecycle(model.appId)
428+
441429 Binding {
442430 target: appDelegate.application
443431 property: "requestedState"
444− value: !model.isTouchApp
445− || isExemptFromLifecycle(model.appId)
432+ value: !canSuspend
446433 || (isDash && root.keepDashRunning)
447434 || (!root.suspended && appDelegate.focus)
448435 ? ApplicationInfoInterface.RequestedRunning
449436 : ApplicationInfoInterface.RequestedSuspended
450437 }
451438
452− readonly property bool isDash: model.appId == "unity8-dash"
453−
454439 z: isDash && !spreadView.active ? -1 : behavioredIndex
455440
456441 x: {
qml/Stages/TabletStage.qml+8−26
@@ -25,25 +25,8 @@ AbstractStage {
2525 id: root
2626 objectName: "stages"
2727 anchors.fill: parent
28− color: "#111111"
29−
30− // Controls to be set from outside
31− property int dragAreaWidth
32− property real maximizedAppTopMargin
33− property bool interactive
34− property alias beingResized: spreadView.beingResized
35−
36− property bool spreadEnabled: true // If false, animations and right edge will be disabled
37−
38− property real inverseProgress: 0 // This is the progress for left edge drags, in pixels.
39− property bool keepDashRunning: true
40− property bool suspended: false
41− property int shellOrientationAngle: 0
42− property int shellOrientation
43− property int shellPrimaryOrientation
44− property int nativeOrientation
45− property real nativeWidth
46− property real nativeHeight
28+
29+ // Functions to be called from outside
4730 function updateFocusedAppOrientation() {
4831 var mainStageAppIndex = priv.indexOf(priv.mainStageAppId);
4932 if (mainStageAppIndex >= 0 && mainStageAppIndex < spreadRepeater.count) {
@@ -86,10 +69,7 @@ AbstractStage {
8669 }
8770 }
8871
89− // To be read from outside
90− property var mainApp: null
91− property int mainAppWindowOrientationAngle: 0
92− readonly property bool orientationChangesEnabled: priv.mainAppOrientationChangesEnabled
72+ orientationChangesEnabled: priv.mainAppOrientationChangesEnabled
9373
9474 onWidthChanged: {
9575 spreadView.selectedIndex = -1;
@@ -302,7 +282,7 @@ AbstractStage {
302282 }
303283
304284 property bool animateX: true
305− property bool beingResized: false
285+ property bool beingResized: root.beingResized
306286 onBeingResizedChanged: {
307287 if (beingResized) {
308288 // Brace yourselves for impact!
@@ -629,11 +609,13 @@ AbstractStage {
629609
630610 readonly property bool isDash: model.appId == "unity8-dash"
631611
612+ readonly property bool canSuspend: model.isTouchApp
613+ && !isExemptFromLifecycle(model.appId)
614+
632615 Binding {
633616 target: spreadTile.application
634617 property: "requestedState"
635− value: !model.isTouchApp
636− || isExemptFromLifecycle(model.appId)
618+ value: !canSuspend
637619 || (isDash && root.keepDashRunning)
638620 || (!root.suspended && (model.appId == priv.mainStageAppId
639621 || model.appId == priv.sideStageAppId))