on xenial help sign in
rework/simplify how stages are revealed in Shell.qml.
commit8df8725a14ac8029e99b57e2396c1125180b37cf authorMichael Zanetti <michael.zanetti@canonical.com> dateTue 4 Feb 2014, 22:02 (13 years ago) parentca2e8f5
3 files changed+99−85
qml/Shell.qml+80−83 qml/Stages/PhoneStage.qml+17−2 tests/mocks/Unity/Application/ApplicationManager.cpp+2
qml/Shell.qml+80−83
@@ -56,11 +56,13 @@ FocusScope {
5656 if (ApplicationManager.findApplication(appId)) {
5757 print("Shell.qml: activating app", appId);
5858 ApplicationManager.activateApplication(appId);
59+ stages.show();
5960 } else {
6061 print("starting app", appId);
6162
6263 var execFlags = shell.sideStageEnabled ? ApplicationManager.NoFlag : ApplicationManager.ForceMainStage;
6364 ApplicationManager.startApplication(appId, execFlags);
65+ stages.show();
6466 }
6567 }
6668
@@ -122,7 +124,7 @@ FocusScope {
122124 readonly property bool applicationRunning: ApplicationManager.focusedApplicationId.length > 0
123125
124126 // Whether the user should see the topmost application surface (if there's one at all).
125− readonly property bool applicationSurfaceShouldBeSeen: applicationRunning && !stages.painting
127+ readonly property bool applicationSurfaceShouldBeSeen: stages.shown && !stages.painting
126128
127129 // NB! Application surfaces are stacked behind the shell one. So they can only be seen by the user
128130 // through the translucent parts of the shell surface.
@@ -163,115 +165,111 @@ FocusScope {
163165 if (greeter.shown) {
164166 return greeter.showProgress;
165167 } else {
166− return stagesOuterContainer.showProgress;
168+ return stages.showProgress;
167169 }
168170 }
169171
170− // FIXME: only necessary because stagesOuterContainer.showProgress and
172+ // FIXME: only necessary because stages.showProgress and
171173 // greeterRevealer.animatedProgress are not animated
172174 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
173175 }
174176 }
175177
176− Item {
177− id: stagesOuterContainer
178+ EdgeDragArea {
179+ id: stagesDragHandle
180+ direction: Direction.LeftWards
181+
182+ anchors { top: parent.top; right: parent.right; bottom: parent.bottom }
183+ width: shell.edgeSize
184+
185+ property real progress: stages.width
186+
187+ onTouchXChanged: {
188+ if (status == DirectionalDragArea.Recognized) {
189+ if (ApplicationManager.count == 0) {
190+ progress = Math.max(stages.width + touchX * 2, stages.width * .7)
191+ } else {
192+ progress = stages.width + touchX
193+ }
194+ }
195+ }
178196
197+ onDraggingChanged: {
198+ if (!dragging) {
199+ if (ApplicationManager.count > 0 && progress < stages.width - units.gu(10)) {
200+ stages.show()
201+ }
202+ stagesDragHandle.progress = stages.width;
203+ }
204+ }
205+ }
206+
207+ Item {
208+ id: stages
209+ objectName: "stages"
179210 width: parent.width
180211 height: parent.height
181− x: launcher.progress
182− Behavior on x {SmoothedAnimation{velocity: 600}}
183212
184− property real showProgress: MathUtils.clamp(1 - (x + stages.x) / shell.width, 0, 1)
213+ x: shown ? launcher.progress : stagesDragHandle.progress
185214
186− Showable {
187− id: stages
188− objectName: "stages"
215+ Behavior on x { SmoothedAnimation { velocity: 600; duration: UbuntuAnimation.SlowDuration } }
189216
190− x: width
217+ property bool shown: false
191218
192− property bool fullyShown: shown && x == 0 && parent.x == 0
193− property bool fullyHidden: !shown && x == width
219+ property real showProgress: MathUtils.clamp(1 - x / shell.width, 0, 1)
194220
195− property bool painting: applicationsDisplayLoader.item ? applicationsDisplayLoader.item.painting : false
196− property bool fullscreen: applicationsDisplayLoader.item ? applicationsDisplayLoader.item.fullscreen : false
221+ property bool fullyShown: x == 0
222+ property bool fullyHidden: x == width
197223
198− available: !greeter.shown
199− hides: [panel.indicators]
200− shown: false
201− opacity: 1.0
202− showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
203− hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
204−
205− width: parent.width
206− height: parent.height
224+ property bool painting: applicationsDisplayLoader.item ? applicationsDisplayLoader.item.painting : false
225+ property bool fullscreen: applicationsDisplayLoader.item ? applicationsDisplayLoader.item.fullscreen : false
207226
208− property string lastFocusedAppId
209− onShownChanged: {
210− print("stages shown", shown)
211− if (shown) {
212− if (!ApplicationManager.focusedApplicationId && lastFocusedAppId) {
213− ApplicationManager.focusApplication(lastFocusedAppId);
214− }
215− } else {
216− lastFocusedAppId = ApplicationManager.focusedApplicationId;
217− ApplicationManager.unfocusCurrentApplication();
218− }
227+ function show() {
228+ shown = true;
229+ panel.indicators.hide();
230+ if (!ApplicationManager.focusedApplicationId && ApplicationManager.count > 0) {
231+ ApplicationManager.focusApplication(ApplicationManager.get(0).appId);
219232 }
233+ }
220234
221− Connections {
222− target: ApplicationManager
223− onFocusedApplicationIdChanged: {
224− if (ApplicationManager.focusedApplicationId.length > 0) {
225− print("should show stages")
226− stages.show();
227− } else {
228− stages.hide();
229− }
230− }
235+ function hide() {
236+ shown = false;
237+ ApplicationManager.unfocusCurrentApplication();
238+ }
231239
232− onApplicationAdded: {
240+ Connections {
241+ target: ApplicationManager
242+ onFocusedApplicationIdChanged: {
243+ if (ApplicationManager.focusedApplicationId.length > 0) {
233244 stages.show();
234245 }
235246 }
236247
237− Loader {
238− id: applicationsDisplayLoader
239− anchors.fill: parent
240−
241− source: shell.sideStageEnabled ? "Stages/StageWithSideStage.qml" : "Stages/PhoneStage.qml"
242−
243− Binding {
244− target: applicationsDisplayLoader.item
245− property: "moving"
246− value: !stages.fullyShown
247− }
248− Binding {
249− target: applicationsDisplayLoader.item
250− property: "shown"
251− value: stages.shown
252− }
253− Binding {
254− target: applicationsDisplayLoader.item
255− property: "dragAreaWidth"
256− value: shell.edgeSize
257− }
248+ onApplicationAdded: {
249+ stages.show();
258250 }
251+ }
259252
260− DragHandle {
261− id: stagesDragHandle
262−
263− anchors.top: parent.top
264− anchors.bottom: parent.bottom
265− anchors.right: parent.left
253+ Loader {
254+ id: applicationsDisplayLoader
255+ anchors.fill: parent
266256
267− width: shell.edgeSize
268− direction: Direction.Leftwards
269− enabled: greeter.showProgress == 0 && edgeDemo.dashEnabled
270− property bool haveApps: ApplicationManager.count > 0
257+ source: shell.sideStageEnabled ? "Stages/StageWithSideStage.qml" : "Stages/PhoneStage.qml"
271258
272− maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
273− // Make autocompletion impossible when !haveApps
274− edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
259+ Binding {
260+ target: applicationsDisplayLoader.item
261+ property: "moving"
262+ value: !stages.fullyShown
263+ }
264+ Binding {
265+ target: applicationsDisplayLoader.item
266+ property: "shown"
267+ value: stages.shown
268+ }
269+ Binding {
270+ target: applicationsDisplayLoader.item
271+ property: "dragAreaWidth"
272+ value: shell.edgeSize
275273 }
276274 }
277275 }
@@ -433,8 +431,7 @@ FocusScope {
433431 }
434432 property string focusedAppId: ApplicationManager.focusedApplicationId
435433 property var focusedApplication: ApplicationManager.findApplication(focusedAppId)
436− fullscreenMode: stages.painting ? stages.fullscreen :
437− focusedApplication && focusedApplication.fullscreen && !greeter.shown && !lockscreen.shown
434+ fullscreenMode: focusedApplication && stages.fullscreen && !greeter.shown && !lockscreen.shown
438435 searchVisible: !greeter.shown && !lockscreen.shown && dash.shown
439436
440437 InputFilterArea {
qml/Stages/PhoneStage.qml+17−2
@@ -23,7 +23,13 @@ Item {
2323
2424 onMovingChanged: {
2525 if (moving) {
26− priv.requestNewScreenshot();
26+ if (ApplicationManager.focusedApplicationId) {
27+ priv.requestNewScreenshot();
28+ } else {
29+ mainScreenshotImage.anchors.leftMargin = 0;
30+ mainScreenshotImage.src = ApplicationManager.get(0).screenshot
31+ mainScreenshotImage.visible = true;
32+ }
2733 } else {
2834 mainScreenshotImage.visible = false;
2935 }
@@ -52,12 +58,21 @@ Item {
5258 mainScreenshotImage.visible = false;
5359 priv.applicationStarting = true;
5460 } else {
55− mainScreenshotImage.src = "foobar";
61+ mainScreenshotImage.src = "";
5662 priv.newFocusedAppId = appId;
5763 priv.secondApplicationStarting = true;
5864 priv.requestNewScreenshot();
5965 }
6066 }
67+
68+ onApplicationRemoved: {
69+ if (ApplicationManager.count == 0) {
70+ mainScreenshotImage.src = ""
71+ mainScreenshotImage.visible = false;
72+ } else {
73+ mainScreenshotImage.src = ApplicationManager.get(0).screenshot
74+ }
75+ }
6176 }
6277
6378 QtObject {
tests/mocks/Unity/Application/ApplicationManager.cpp+2
@@ -97,6 +97,7 @@ void ApplicationManager::add(ApplicationInfo *application) {
9797 beginInsertRows(QModelIndex(), m_runningApplications.size(), m_runningApplications.size());
9898 m_runningApplications.append(application);
9999 endInsertRows();
100+ Q_EMIT applicationAdded(application->appId());
100101 Q_EMIT countChanged();
101102}
102103
@@ -106,6 +107,7 @@ void ApplicationManager::remove(ApplicationInfo *application) {
106107 beginRemoveRows(QModelIndex(), i, i);
107108 m_runningApplications.removeAt(i);
108109 endRemoveRows();
110+ Q_EMIT applicationRemoved(application->appId());
109111 Q_EMIT countChanged();
110112 }
111113}