on xenial help sign in
Save the last surface stage on stage drop. (LP: #1579003)
41e6820Nick Dedekind
qml/Stages/TabletStage.qml+7−5
@@ -624,7 +624,7 @@ AbstractStage {
624 enabled: priv.sideStageEnabled
624 enabled: priv.sideStageEnabled
625
625
626 onDropped: {
626 onDropped: {
627− drop.source.spreadDelegate.stage = ApplicationInfoInterface.MainStage;
627+ drop.source.spreadDelegate.saveStage(ApplicationInfoInterface.MainStage);
628 drop.source.spreadDelegate.focus = true;
628 drop.source.spreadDelegate.focus = true;
629 }
629 }
630 keys: "SideStage"
630 keys: "SideStage"
@@ -679,7 +679,7 @@ AbstractStage {
679 }
679 }
680 onDropped: {
680 onDropped: {
681 if (drop.keys == "MainStage") {
681 if (drop.keys == "MainStage") {
682− drop.source.spreadDelegate.stage = ApplicationInfoInterface.SideStage;
682+ drop.source.spreadDelegate.saveStage(ApplicationInfoInterface.SideStage);
683 drop.source.spreadDelegate.focus = true;
683 drop.source.spreadDelegate.focus = true;
684 }
684 }
685 }
685 }
@@ -810,6 +810,11 @@ AbstractStage {
810 }
810 }
811 }
811 }
812
812
813+ function saveStage(newStage) {
814+ stage = newStage;
815+ WindowStateStorage.saveStage(application.appId, newStage);
816+ }
817+
813 // FIXME: A regular binding doesn't update any more after closing an app.
818 // FIXME: A regular binding doesn't update any more after closing an app.
814 // Using a Binding for now.
819 // Using a Binding for now.
815 Binding {
820 Binding {
@@ -843,9 +848,6 @@ AbstractStage {
843 refreshStage();
848 refreshStage();
844 _constructing = false;
849 _constructing = false;
845 }
850 }
846− Component.onDestruction: {
847− WindowStateStorage.saveStage(application.appId, stage);
848− }
849
851
850 function refreshStage() {
852 function refreshStage() {
851 var newStage = ApplicationInfoInterface.MainStage;
853 var newStage = ApplicationInfoInterface.MainStage;
tests/qmltests/Stages/tst_TabletStage.qml+116−46
@@ -242,6 +242,48 @@ Rectangle {
242 appWindow.width * 0.1, -appWindow.height / 2);
242 appWindow.width * 0.1, -appWindow.height / 2);
243 }
243 }
244
244
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+
245 function test_tappingSwitchesFocusBetweenStages() {
287 function test_tappingSwitchesFocusBetweenStages() {
246 WindowStateStorage.saveStage(dialerCheckBox.appId, ApplicationInfoInterface.SideStage)
288 WindowStateStorage.saveStage(dialerCheckBox.appId, ApplicationInfoInterface.SideStage)
247
289
@@ -519,13 +561,13 @@ Rectangle {
519
561
520 function test_applicationSavesLastStage_data() {
562 function test_applicationSavesLastStage_data() {
521 return [
563 return [
522− { tag: "MainStage", stage: ApplicationInfoInterface.MainStage},
564+ { tag: "MainStage", fromStage: ApplicationInfoInterface.MainStage, toStage: ApplicationInfoInterface.SideStage },
523− { tag: "SideStage", stage: ApplicationInfoInterface.SideStage},
565+ { tag: "SideStage", fromStage: ApplicationInfoInterface.SideStage, toStage: ApplicationInfoInterface.MainStage },
524 ];
566 ];
525 }
567 }
526
568
527 function test_applicationSavesLastStage(data) {
569 function test_applicationSavesLastStage(data) {
528− WindowStateStorage.saveStage(webbrowserCheckBox.appId, data.stage);
570+ WindowStateStorage.saveStage(webbrowserCheckBox.appId, data.fromStage);
529 stageSaver.clear();
571 stageSaver.clear();
530
572
531 var stagesPriv = findInvisibleChild(tabletStage, "stagesPriv");
573 var stagesPriv = findInvisibleChild(tabletStage, "stagesPriv");
@@ -538,11 +580,15 @@ Rectangle {
538 webbrowserCheckBox.checked = true;
580 webbrowserCheckBox.checked = true;
539 waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
581 waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
540
582
541− webbrowserCheckBox.checked = false;
583+ if (data.toStage === ApplicationInfoInterface.SideStage) {
584+ dragToSideStage(webbrowserSurfaceId);
585+ } else {
586+ dragToMainStage(webbrowserSurfaceId);
587+ }
542
588
543 tryCompare(stageSaver, "count", 1);
589 tryCompare(stageSaver, "count", 1);
544 compare(stageSaver.signalArguments[0][0], "webbrowser-app")
590 compare(stageSaver.signalArguments[0][0], "webbrowser-app")
545− compare(stageSaver.signalArguments[0][1], data.stage)
591+ compare(stageSaver.signalArguments[0][1], data.toStage)
546 }
592 }
547
593
548 function test_loadSideStageByDraggingFromMainStage() {
594 function test_loadSideStageByDraggingFromMainStage() {
@@ -555,20 +601,7 @@ Rectangle {
555 verify(appDelegate);
601 verify(appDelegate);
556 compare(appDelegate.stage, ApplicationInfoInterface.MainStage);
602 compare(appDelegate.stage, ApplicationInfoInterface.MainStage);
557
603
558− var pos = tabletStage.width - sideStage.width - (tabletStage.width - sideStage.width) / 2;
604+ dragToSideStage(webbrowserSurfaceId);
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− });
572
605
573 var spreadView = findChild(tabletStageLoader, "spreadView")
606 var spreadView = findChild(tabletStageLoader, "spreadView")
574 tryCompare(spreadView, "surfaceDragging", false);
607 tryCompare(spreadView, "surfaceDragging", false);
@@ -586,19 +619,7 @@ Rectangle {
586 verify(appDelegate);
619 verify(appDelegate);
587 compare(appDelegate.stage, ApplicationInfoInterface.SideStage);
620 compare(appDelegate.stage, ApplicationInfoInterface.SideStage);
588
621
589− var pos = tabletStage.width - sideStage.width / 2;
622+ dragToMainStage(webbrowserSurfaceId);
590− var end_pos = tabletStage.width - sideStage.width - (tabletStage.width - sideStage.width) / 2;
591−
592− multiTouchDragUntil([0,1,2],
593− tabletStage,
594− pos,
595− tabletStage.height / 2,
596− -units.gu(3),
597− 0,
598− function() {
599− pos -= units.gu(3);
600− return pos <= end_pos;
601− });
602
623
603 var spreadView = findChild(tabletStageLoader, "spreadView")
624 var spreadView = findChild(tabletStageLoader, "spreadView")
604 tryCompare(spreadView, "surfaceDragging", false);
625 tryCompare(spreadView, "surfaceDragging", false);
@@ -741,20 +762,7 @@ Rectangle {
741
762
742 tryCompare(appDelegate.surface, "activeFocus", true);
763 tryCompare(appDelegate.surface, "activeFocus", true);
743
764
744− var pos = tabletStage.width - sideStage.width - (tabletStage.width - sideStage.width) / 2;
765+ dragToSideStage(webbrowserSurfaceId);
745− var end_pos = tabletStage.width - sideStage.width / 2;
746−
747− multiTouchDragUntil([0,1,2],
748− tabletStage,
749− pos,
750− tabletStage.height / 2,
751− units.gu(3),
752− 0,
753− function() {
754− pos += units.gu(3);
755− return sideStage.shown && !sideStage.showAnimation.running &&
756− pos >= end_pos;
757− });
758
766
759 var spreadView = findChild(tabletStageLoader, "spreadView")
767 var spreadView = findChild(tabletStageLoader, "spreadView")
760 tryCompare(spreadView, "surfaceDragging", false);
768 tryCompare(spreadView, "surfaceDragging", false);
@@ -789,5 +797,67 @@ Rectangle {
789 tryCompare(spreadView, "surfaceDragging", false);
797 tryCompare(spreadView, "surfaceDragging", false);
790 tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
798 tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
791 }
799 }
800+
801+ function test_switchStageOnRotation() {
802+ WindowStateStorage.saveStage(webbrowserCheckBox.appId, ApplicationInfoInterface.SideStage)
803+ var webbrowserSurfaceId = topSurfaceList.nextId;
804+ webbrowserCheckBox.checked = true;
805+ waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
806+
807+ var appDelegate = findChild(tabletStage, "spreadDelegate_" + webbrowserSurfaceId);
808+ verify(appDelegate);
809+ compare(appDelegate.stage, ApplicationInfoInterface.SideStage);
810+
811+ tabletStage.shellOrientation = Qt.PortraitOrientation;
812+ tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
813+ }
814+
815+ function test_restoreOriginalStageOnRotation() {
816+ var webbrowserSurfaceId = topSurfaceList.nextId;
817+ webbrowserCheckBox.checked = true;
818+ waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
819+
820+ var appDelegate = findChild(tabletStage, "spreadDelegate_" + webbrowserSurfaceId);
821+ verify(appDelegate);
822+
823+ dragToSideStage(webbrowserSurfaceId);
824+
825+ // will be in sidestage now
826+ tabletStage.shellOrientation = Qt.PortraitOrientation;
827+ tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
828+
829+ tabletStage.shellOrientation = Qt.LandscapeOrientation;
830+ tryCompare(appDelegate, "stage", ApplicationInfoInterface.SideStage);
831+ }
832+
833+ function test_restoreSavedStageOnCloseReopen() {
834+ var webbrowserSurfaceId = topSurfaceList.nextId;
835+ webbrowserCheckBox.checked = true;
836+ waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
837+
838+ var appDelegate = findChild(tabletStage, "spreadDelegate_" + webbrowserSurfaceId);
839+ verify(appDelegate);
840+
841+ dragToSideStage(webbrowserSurfaceId);
842+ // will be in sidestage now
843+ tabletStage.shellOrientation = Qt.PortraitOrientation;
844+ tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
845+
846+ webbrowserCheckBox.checked = false;
847+ tryCompare(ApplicationManager, "count", 1);
848+
849+ // back to landscape
850+ tabletStage.shellOrientation = Qt.LandscapeOrientation;
851+
852+ webbrowserSurfaceId = topSurfaceList.nextId;
853+ webbrowserCheckBox.checked = true;
854+ waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
855+
856+ appDelegate = findChild(tabletStage, "spreadDelegate_" + webbrowserSurfaceId);
857+ verify(appDelegate);
858+ tryCompare(appDelegate, "stage", ApplicationInfoInterface.SideStage);
859+ }
860+
861+
792 }
862 }
793}
863}