on xenial help sign in
Address review comments; consolidate some shared stage code
0a7be36Michael Terry
qml/Stages/AbstractStage.qml+26
@@ -21,6 +21,32 @@ import GSettings 1.0
21Rectangle {
21Rectangle {
22 id: root
22 id: root
23
23
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
24 GSettings {
50 GSettings {
25 id: lifecycleExceptions
51 id: lifecycleExceptions
26 schema.id: "com.canonical.qtmir"
52 schema.id: "com.canonical.qtmir"
qml/Stages/DesktopStage.qml+3−20
@@ -29,32 +29,13 @@ AbstractStage {
29 id: root
29 id: root
30 anchors.fill: parent
30 anchors.fill: parent
31
31
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−
48 // functions to be called from outside
32 // functions to be called from outside
49 function updateFocusedAppOrientation() { /* TODO */ }
33 function updateFocusedAppOrientation() { /* TODO */ }
50 function updateFocusedAppOrientationAnimated() { /* TODO */}
34 function updateFocusedAppOrientationAnimated() { /* TODO */}
51
35
52− // To be read from outside
53− readonly property var mainApp: ApplicationManager.focusedApplicationId
36+ mainApp: ApplicationManager.focusedApplicationId
54 ? ApplicationManager.findApplication(ApplicationManager.focusedApplicationId)
37 ? ApplicationManager.findApplication(ApplicationManager.focusedApplicationId)
55 : null
38 : null
56− property int mainAppWindowOrientationAngle: 0
57− readonly property bool orientationChangesEnabled: false
58
39
59 Connections {
40 Connections {
60 target: ApplicationManager
41 target: ApplicationManager
@@ -121,6 +102,7 @@ AbstractStage {
121 CrossFadeImage {
102 CrossFadeImage {
122 id: wallpaper
103 id: wallpaper
123 anchors.fill: parent
104 anchors.fill: parent
105+ source: root.background
124 sourceSize { height: root.height; width: root.width }
106 sourceSize { height: root.height; width: root.width }
125 fillMode: Image.PreserveAspectCrop
107 fillMode: Image.PreserveAspectCrop
126 }
108 }
@@ -272,5 +254,6 @@ AbstractStage {
272 anchors.fill: parent
254 anchors.fill: parent
273 workspace: appContainer
255 workspace: appContainer
274 focus: state == "altTab"
256 focus: state == "altTab"
257+ altTabPressed: root.altTabPressed
275 }
258 }
276}
259}
qml/Stages/PhoneStage.qml+13−28
@@ -25,26 +25,11 @@ import "../Components"
25AbstractStage {
25AbstractStage {
26 id: root
26 id: root
27
27
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.
34 property QtObject applicationManager: ApplicationManager
28 property QtObject applicationManager: ApplicationManager
35 property bool focusFirstApp: true // If false, focused app will appear on right edge like other apps
29 property bool focusFirstApp: true // If false, focused app will appear on right edge like other apps
36 property bool altTabEnabled: true
30 property bool altTabEnabled: true
37 property real startScale: 1.1
31 property real startScale: 1.1
38 property real endScale: 0.7
32 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
48 onBeingResizedChanged: {
33 onBeingResizedChanged: {
49 if (beingResized) {
34 if (beingResized) {
50 // Brace yourselves for impact!
35 // Brace yourselves for impact!
@@ -56,6 +41,8 @@ AbstractStage {
56 priv.reset();
41 priv.reset();
57 }
42 }
58 }
43 }
44+
45+ // Functions to be called from outside
59 function updateFocusedAppOrientation() {
46 function updateFocusedAppOrientation() {
60 if (spreadRepeater.count > 0) {
47 if (spreadRepeater.count > 0) {
61 spreadRepeater.itemAt(0).matchShellOrientation();
48 spreadRepeater.itemAt(0).matchShellOrientation();
@@ -85,16 +72,14 @@ AbstractStage {
85 }
72 }
86 }
73 }
87
74
88− // To be read from outside
89− readonly property var mainApp: applicationManager.focusedApplicationId
75+ mainApp: applicationManager.focusedApplicationId
90 ? applicationManager.findApplication(applicationManager.focusedApplicationId)
76 ? applicationManager.findApplication(applicationManager.focusedApplicationId)
91 : null
77 : null
92
78
93− property int mainAppWindowOrientationAngle: 0
94− readonly property bool orientationChangesEnabled: priv.focusedAppOrientationChangesEnabled
79+ orientationChangesEnabled: priv.focusedAppOrientationChangesEnabled
95− && !priv.focusedAppDelegateIsDislocated
80+ && !priv.focusedAppDelegateIsDislocated
96− && !(priv.focusedAppDelegate && priv.focusedAppDelegate.xBehavior.running)
81+ && !(priv.focusedAppDelegate && priv.focusedAppDelegate.xBehavior.running)
97− && spreadView.phase === 0
82+ && spreadView.phase === 0
98
83
99 // How far left the stage has been dragged
84 // How far left the stage has been dragged
100 readonly property real dragProgress: spreadRepeater.count > 0 ? -spreadRepeater.itemAt(0).xTranslate : 0
85 readonly property real dragProgress: spreadRepeater.count > 0 ? -spreadRepeater.itemAt(0).xTranslate : 0
@@ -106,8 +91,6 @@ AbstractStage {
106
91
107 signal opened()
92 signal opened()
108
93
109− color: "#111111"
110−
111 function select(appId) {
94 function select(appId) {
112 spreadView.snapTo(priv.indexOf(appId));
95 spreadView.snapTo(priv.indexOf(appId));
113 }
96 }
@@ -438,19 +421,21 @@ AbstractStage {
438 dropShadow: spreadView.active || priv.focusedAppDelegateIsDislocated
421 dropShadow: spreadView.active || priv.focusedAppDelegateIsDislocated
439 focusFirstApp: root.focusFirstApp
422 focusFirstApp: root.focusFirstApp
440
423
424+ readonly property bool isDash: model.appId == "unity8-dash"
425+
426+ readonly property bool canSuspend: model.isTouchApp
427+ && !isExemptFromLifecycle(model.appId)
428+
441 Binding {
429 Binding {
442 target: appDelegate.application
430 target: appDelegate.application
443 property: "requestedState"
431 property: "requestedState"
444− value: !model.isTouchApp
432+ value: !canSuspend
445− || isExemptFromLifecycle(model.appId)
446 || (isDash && root.keepDashRunning)
433 || (isDash && root.keepDashRunning)
447 || (!root.suspended && appDelegate.focus)
434 || (!root.suspended && appDelegate.focus)
448 ? ApplicationInfoInterface.RequestedRunning
435 ? ApplicationInfoInterface.RequestedRunning
449 : ApplicationInfoInterface.RequestedSuspended
436 : ApplicationInfoInterface.RequestedSuspended
450 }
437 }
451
438
452− readonly property bool isDash: model.appId == "unity8-dash"
453−
454 z: isDash && !spreadView.active ? -1 : behavioredIndex
439 z: isDash && !spreadView.active ? -1 : behavioredIndex
455
440
456 x: {
441 x: {
qml/Stages/TabletStage.qml+8−26
@@ -25,25 +25,8 @@ AbstractStage {
25 id: root
25 id: root
26 objectName: "stages"
26 objectName: "stages"
27 anchors.fill: parent
27 anchors.fill: parent
28− color: "#111111"
28+
29−
30− // Controls to be set from outside
29+ // Functions to be called 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
47 function updateFocusedAppOrientation() {
30 function updateFocusedAppOrientation() {
48 var mainStageAppIndex = priv.indexOf(priv.mainStageAppId);
31 var mainStageAppIndex = priv.indexOf(priv.mainStageAppId);
49 if (mainStageAppIndex >= 0 && mainStageAppIndex < spreadRepeater.count) {
32 if (mainStageAppIndex >= 0 && mainStageAppIndex < spreadRepeater.count) {
@@ -86,10 +69,7 @@ AbstractStage {
86 }
69 }
87 }
70 }
88
71
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
93
73
94 onWidthChanged: {
74 onWidthChanged: {
95 spreadView.selectedIndex = -1;
75 spreadView.selectedIndex = -1;
@@ -302,7 +282,7 @@ AbstractStage {
302 }
282 }
303
283
304 property bool animateX: true
284 property bool animateX: true
305− property bool beingResized: false
285+ property bool beingResized: root.beingResized
306 onBeingResizedChanged: {
286 onBeingResizedChanged: {
307 if (beingResized) {
287 if (beingResized) {
308 // Brace yourselves for impact!
288 // Brace yourselves for impact!
@@ -629,11 +609,13 @@ AbstractStage {
629
609
630 readonly property bool isDash: model.appId == "unity8-dash"
610 readonly property bool isDash: model.appId == "unity8-dash"
631
611
612+ readonly property bool canSuspend: model.isTouchApp
613+ && !isExemptFromLifecycle(model.appId)
614+
632 Binding {
615 Binding {
633 target: spreadTile.application
616 target: spreadTile.application
634 property: "requestedState"
617 property: "requestedState"
635− value: !model.isTouchApp
618+ value: !canSuspend
636− || isExemptFromLifecycle(model.appId)
637 || (isDash && root.keepDashRunning)
619 || (isDash && root.keepDashRunning)
638 || (!root.suspended && (model.appId == priv.mainStageAppId
620 || (!root.suspended && (model.appId == priv.mainStageAppId
639 || model.appId == priv.sideStageAppId))
621 || model.appId == priv.sideStageAppId))