on xenial help sign in
Open portrait apps in sidestage by default
commitaa1e355c77d72d71bab16932fc34a99ed9f0618f authorNick Dedekind <nick.dedekind@canonical.com> dateMon 20 Jun 2016, 15:26 (10 years ago) parente9a27e4
6 files changed+39−11
plugins/Utils/windowstatestorage.cpp+2−2 plugins/Utils/windowstatestorage.h+1−1 qml/Stages/TabletStage.qml+9−3 tests/mocks/Utils/windowstatestorage.cpp+2−2 tests/mocks/Utils/windowstatestorage.h+1−1 tests/qmltests/Stages/tst_TabletStage.qml+24−2
plugins/Utils/windowstatestorage.cpp+2−2
@@ -95,7 +95,7 @@ void WindowStateStorage::saveStage(const QString &appId, int stage)
9595 saveValue(queryString);
9696}
9797
98−int WindowStateStorage::getStage(const QString &appId) const
98+int WindowStateStorage::getStage(const QString &appId, int defaultValue) const
9999{
100100 const QString queryString = QStringLiteral("SELECT * FROM stage WHERE appId = '%1';")
101101 .arg(sanitiseString(appId));
@@ -103,7 +103,7 @@ int WindowStateStorage::getStage(const QString &appId) const
103103 QSqlQuery query = getValue(queryString);
104104
105105 if (!query.first()) {
106− return unity::shell::application::ApplicationInfoInterface::MainStage;
106+ return defaultValue;
107107 }
108108 return query.value("stage").toInt();
109109}
plugins/Utils/windowstatestorage.h+1−1
@@ -49,7 +49,7 @@ public:
4949 Q_INVOKABLE QRect getGeometry(const QString &windowId, const QRect defaultValue) const;
5050
5151 Q_INVOKABLE void saveStage(const QString &appId, int stage);
52− Q_INVOKABLE int getStage(const QString &appId) const;
52+ Q_INVOKABLE int getStage(const QString &appId, int defaultValue) const;
5353
5454private:
5555 void initdb();
qml/Stages/TabletStage.qml+9−3
@@ -101,7 +101,7 @@ AbstractStage {
101101 orientations |= Qt.LandscapeOrientation | Qt.InvertedLandscapeOrientation;
102102 if (priv.sideStageItemId && !spreadView.surfaceDragging) {
103103 // If we have a sidestage app, support Portrait orientation
104− // so that it will switch the sidestage app to mainstage on rotate
104+ // so that it will switch the sidestage app to mainstage on rotate to portrait
105105 orientations |= Qt.PortraitOrientation|Qt.InvertedPortraitOrientation;
106106 }
107107 return orientations;
@@ -849,9 +849,15 @@ AbstractStage {
849849
850850 function refreshStage() {
851851 var newStage = ApplicationInfoInterface.MainStage;
852− if (priv.sideStageEnabled) {
852+ if (priv.sideStageEnabled) { // we're in lanscape rotation.
853853 if (application && application.supportedOrientations & (Qt.PortraitOrientation|Qt.InvertedPortraitOrientation)) {
854− newStage = WindowStateStorage.getStage(application.appId);
854+
855+ var defaultStage = ApplicationInfoInterface.SideStage; // if application supports portrait, it defaults to sidestage.
856+ if (application.supportedOrientations & (Qt.LandscapeOrientation|Qt.InvertedLandscapeOrientation)) {
857+ // if it supports lanscape, it defaults to mainstage.
858+ defaultStage = ApplicationInfoInterface.MainStage;
859+ }
860+ newStage = WindowStateStorage.getStage(application.appId, defaultStage);
855861 }
856862 }
857863
tests/mocks/Utils/windowstatestorage.cpp+2−2
@@ -53,9 +53,9 @@ void WindowStateStorage::saveStage(const QString &appId, int stage)
5353 Q_EMIT stageSaved(appId, stage);
5454}
5555
56−int WindowStateStorage::getStage(const QString &appId) const
56+int WindowStateStorage::getStage(const QString &appId, int defaultValue) const
5757{
58− return m_stage.value(appId, unity::shell::application::ApplicationInfoInterface::MainStage);
58+ return m_stage.value(appId, defaultValue);
5959}
6060
6161void WindowStateStorage::clear()
tests/mocks/Utils/windowstatestorage.h+1−1
@@ -48,7 +48,7 @@ public:
4848 Q_INVOKABLE QRect getGeometry(const QString &windowId, const QRect &defaultValue);
4949
5050 Q_INVOKABLE void saveStage(const QString &appId, int stage);
51− Q_INVOKABLE int getStage(const QString &appId) const;
51+ Q_INVOKABLE int getStage(const QString &appId, int defaultValue) const;
5252
5353 // Only in the mock, to easily restore a fresh state
5454 Q_INVOKABLE void clear();
tests/qmltests/Stages/tst_TabletStage.qml+24−2
@@ -493,14 +493,36 @@ Rectangle {
493493 function() { return sideStage.shown; });
494494 }
495495
496− function test_applicationLoadsInCorrectStage_data() {
496+ function test_applicationLoadsInDefaultStage_data() {
497+ return [
498+ { tag: "MainStage", appId: "webbrowser-app", mainStageAppId: "webbrowser-app", sideStageAppId: "" },
499+ { tag: "SideStage", appId: "dialer-app", mainStageAppId: "unity8-dash", sideStageAppId: "dialer-app" },
500+ ];
501+ }
502+
503+ function test_applicationLoadsInDefaultStage(data) {
504+ var stagesPriv = findInvisibleChild(tabletStage, "stagesPriv");
505+ verify(stagesPriv);
506+
507+ tryCompare(stagesPriv, "mainStageAppId", "unity8-dash");
508+ tryCompare(stagesPriv, "sideStageAppId", "");
509+
510+ var appSurfaceId = topSurfaceList.nextId;
511+ var app = ApplicationManager.startApplication(data.appId);
512+ waitUntilAppSurfaceShowsUp(appSurfaceId);
513+
514+ tryCompare(stagesPriv, "mainStageAppId", data.mainStageAppId);
515+ tryCompare(stagesPriv, "sideStageAppId", data.sideStageAppId);
516+ }
517+
518+ function test_applicationLoadsInSavedStage_data() {
497519 return [
498520 { tag: "MainStage", stage: ApplicationInfoInterface.MainStage, mainStageAppId: "webbrowser-app", sideStageAppId: ""},
499521 { tag: "SideStage", stage: ApplicationInfoInterface.SideStage, mainStageAppId: "unity8-dash", sideStageAppId: "webbrowser-app" },
500522 ];
501523 }
502524
503− function test_applicationLoadsInCorrectStage(data) {
525+ function test_applicationLoadsInSavedStage(data) {
504526 WindowStateStorage.saveStage(webbrowserCheckBox.appId, data.stage)
505527
506528 var stagesPriv = findInvisibleChild(tabletStage, "stagesPriv");