on xenial help sign in
Save stage on drop-onto-stage
commitd7e7ba69a52e63a899bce041a80080d9ad18c91c authorNick Dedekind <nick.dedekind@canonical.com> dateMon 9 May 2016, 14:03 (10 years ago) parentd3030d3
2 files changed+84−43
qml/Stages/TabletStage.qml+7−2 tests/qmltests/Stages/tst_TabletStage.qml+77−41
qml/Stages/TabletStage.qml+7−2
@@ -624,7 +624,7 @@ AbstractStage {
624624 enabled: priv.sideStageEnabled
625625
626626 onDropped: {
627− drop.source.spreadDelegate.stage = ApplicationInfoInterface.MainStage;
627+ drop.source.spreadDelegate.saveStage(ApplicationInfoInterface.MainStage);
628628 drop.source.spreadDelegate.focus = true;
629629 }
630630 keys: "SideStage"
@@ -679,7 +679,7 @@ AbstractStage {
679679 }
680680 onDropped: {
681681 if (drop.keys == "MainStage") {
682− drop.source.spreadDelegate.stage = ApplicationInfoInterface.SideStage;
682+ drop.source.spreadDelegate.saveStage(ApplicationInfoInterface.SideStage);
683683 drop.source.spreadDelegate.focus = true;
684684 }
685685 }
@@ -810,6 +810,11 @@ AbstractStage {
810810 }
811811 }
812812
813+ function saveStage(newStage) {
814+ stage = newStage;
815+ WindowStateStorage.saveStage(application.appId, newStage);
816+ }
817+
813818 // FIXME: A regular binding doesn't update any more after closing an app.
814819 // Using a Binding for now.
815820 Binding {
tests/qmltests/Stages/tst_TabletStage.qml+77−41
@@ -242,6 +242,48 @@ Rectangle {
242242 appWindow.width * 0.1, -appWindow.height / 2);
243243 }
244244
245+ function dragToSideStage(surfaceId) {
246+ sideStage.showNow();
247+ var targetAppDelegate = findChild(tabletStage, "spreadDelegate_" + surfaceId);
248+
249+ var pos = tabletStage.width - sideStage.width - (tabletStage.width - sideStage.width) / 2;
250+ var end_pos = tabletStage.width - sideStage.width / 2;
251+
252+ multiTouchDragUntil([0,1,2],
253+ tabletStage,
254+ pos,
255+ tabletStage.height / 2,
256+ units.gu(3),
257+ 0,
258+ function() {
259+ pos += units.gu(3);
260+ return sideStage.shown && !sideStage.showAnimation.running &&
261+ pos >= end_pos;
262+ });
263+ tryCompare(targetAppDelegate, "stage", ApplicationInfoInterface.SideStage);
264+ }
265+
266+ function dragToMainStage(surfaceId) {
267+ sideStage.showNow();
268+ var targetAppDelegate = findChild(tabletStage, "spreadDelegate_" + surfaceId);
269+ verify(targetAppDelegate);
270+
271+ var pos = tabletStage.width - sideStage.width / 2;
272+ var end_pos = tabletStage.width - sideStage.width - (tabletStage.width - sideStage.width) / 2;
273+
274+ multiTouchDragUntil([0,1,2],
275+ tabletStage,
276+ pos,
277+ tabletStage.height / 2,
278+ -units.gu(3),
279+ 0,
280+ function() {
281+ pos -= units.gu(3);
282+ return pos <= end_pos;
283+ });
284+ tryCompare(targetAppDelegate, "stage", ApplicationInfoInterface.MainStage);
285+ }
286+
245287 function test_tappingSwitchesFocusBetweenStages() {
246288 WindowStateStorage.saveStage(dialerCheckBox.appId, ApplicationInfoInterface.SideStage)
247289
@@ -555,20 +597,7 @@ Rectangle {
555597 verify(appDelegate);
556598 compare(appDelegate.stage, ApplicationInfoInterface.MainStage);
557599
558− var pos = tabletStage.width - sideStage.width - (tabletStage.width - sideStage.width) / 2;
559− var end_pos = tabletStage.width - sideStage.width / 2;
560−
561− multiTouchDragUntil([0,1,2],
562− tabletStage,
563− pos,
564− tabletStage.height / 2,
565− units.gu(3),
566− 0,
567− function() {
568− pos += units.gu(3);
569− return sideStage.shown && !sideStage.showAnimation.running &&
570− pos >= end_pos;
571− });
600+ dragToSideStage(webbrowserSurfaceId);
572601
573602 tryCompare(appDelegate, "stage", ApplicationInfoInterface.SideStage);
574603 }
@@ -584,19 +613,7 @@ Rectangle {
584613 verify(appDelegate);
585614 compare(appDelegate.stage, ApplicationInfoInterface.SideStage);
586615
587− var pos = tabletStage.width - sideStage.width / 2;
588− var end_pos = tabletStage.width - sideStage.width - (tabletStage.width - sideStage.width) / 2;
589−
590− multiTouchDragUntil([0,1,2],
591− tabletStage,
592− pos,
593− tabletStage.height / 2,
594− -units.gu(3),
595− 0,
596− function() {
597− pos -= units.gu(3);
598− return pos <= end_pos;
599− });
616+ dragToMainStage(webbrowserSurfaceId);
600617
601618 tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
602619 }
@@ -737,22 +754,41 @@ Rectangle {
737754
738755 tryCompare(appDelegate.surface, "activeFocus", true);
739756
740− var pos = tabletStage.width - sideStage.width - (tabletStage.width - sideStage.width) / 2;
741− var end_pos = tabletStage.width - sideStage.width / 2;
742−
743− multiTouchDragUntil([0,1,2],
744− tabletStage,
745− pos,
746− tabletStage.height / 2,
747− units.gu(3),
748− 0,
749− function() {
750− pos += units.gu(3);
751− return sideStage.shown && !sideStage.showAnimation.running &&
752− pos >= end_pos;
753− });
757+ dragToSideStage(webbrowserSurfaceId);
754758
755759 tryCompare(appDelegate.surface, "activeFocus", true);
756760 }
761+
762+ function test_switchStageOnRotation() {
763+ WindowStateStorage.saveStage(webbrowserCheckBox.appId, ApplicationInfoInterface.SideStage)
764+ var webbrowserSurfaceId = topSurfaceList.nextId;
765+ webbrowserCheckBox.checked = true;
766+ waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
767+
768+ var appDelegate = findChild(tabletStage, "spreadDelegate_" + webbrowserSurfaceId);
769+ verify(appDelegate);
770+ compare(appDelegate.stage, ApplicationInfoInterface.SideStage);
771+
772+ tabletStage.shellOrientation = Qt.PortraitOrientation;
773+ tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
774+ }
775+
776+ function test_restoreOriginalStageOnRotation() {
777+ var webbrowserSurfaceId = topSurfaceList.nextId;
778+ webbrowserCheckBox.checked = true;
779+ waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
780+
781+ var appDelegate = findChild(tabletStage, "spreadDelegate_" + webbrowserSurfaceId);
782+ verify(appDelegate);
783+
784+ dragToSideStage(webbrowserSurfaceId);
785+
786+ // will be in sidestage now
787+ tabletStage.shellOrientation = Qt.PortraitOrientation;
788+ tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
789+
790+ tabletStage.shellOrientation = Qt.LandscapeOrientation;
791+ tryCompare(appDelegate, "stage", ApplicationInfoInterface.SideStage);
792+ }
757793 }
758794}