on xenial help sign in
Default portrait only apps to the side stage. (LP: #1573153)
commit044b17cfabbf174559a93b5c897feccbc5696a9e authorNick Dedekind <nick.dedekind@canonical.com> dateMon 27 Jun 2016, 18:44 (10 years ago) parent41e68200cfe3f7
6 files changed+38−11
plugins/Utils/windowstatestorage.cpp+2−2 plugins/Utils/windowstatestorage.h+1−1 qml/Stages/TabletStage.qml+8−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+8−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;
@@ -851,9 +851,14 @@ AbstractStage {
851851
852852 function refreshStage() {
853853 var newStage = ApplicationInfoInterface.MainStage;
854− if (priv.sideStageEnabled) {
854+ if (priv.sideStageEnabled) { // we're in lanscape rotation.
855855 if (!isDash && application && application.supportedOrientations & (Qt.PortraitOrientation|Qt.InvertedPortraitOrientation)) {
856− newStage = WindowStateStorage.getStage(application.appId);
856+ var defaultStage = ApplicationInfoInterface.SideStage; // if application supports portrait, it defaults to sidestage.
857+ if (application.supportedOrientations & (Qt.LandscapeOrientation|Qt.InvertedLandscapeOrientation)) {
858+ // if it supports lanscape, it defaults to mainstage.
859+ defaultStage = ApplicationInfoInterface.MainStage;
860+ }
861+ newStage = WindowStateStorage.getStage(application.appId, defaultStage);
857862 }
858863 }
859864
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
@@ -535,14 +535,36 @@ Rectangle {
535535 function() { return sideStage.shown; });
536536 }
537537
538− function test_applicationLoadsInCorrectStage_data() {
538+ function test_applicationLoadsInDefaultStage_data() {
539+ return [
540+ { tag: "MainStage", appId: "webbrowser-app", mainStageAppId: "webbrowser-app", sideStageAppId: "" },
541+ { tag: "SideStage", appId: "dialer-app", mainStageAppId: "unity8-dash", sideStageAppId: "dialer-app" },
542+ ];
543+ }
544+
545+ function test_applicationLoadsInDefaultStage(data) {
546+ var stagesPriv = findInvisibleChild(tabletStage, "stagesPriv");
547+ verify(stagesPriv);
548+
549+ tryCompare(stagesPriv, "mainStageAppId", "unity8-dash");
550+ tryCompare(stagesPriv, "sideStageAppId", "");
551+
552+ var appSurfaceId = topSurfaceList.nextId;
553+ var app = ApplicationManager.startApplication(data.appId);
554+ waitUntilAppSurfaceShowsUp(appSurfaceId);
555+
556+ tryCompare(stagesPriv, "mainStageAppId", data.mainStageAppId);
557+ tryCompare(stagesPriv, "sideStageAppId", data.sideStageAppId);
558+ }
559+
560+ function test_applicationLoadsInSavedStage_data() {
539561 return [
540562 { tag: "MainStage", stage: ApplicationInfoInterface.MainStage, mainStageAppId: "webbrowser-app", sideStageAppId: ""},
541563 { tag: "SideStage", stage: ApplicationInfoInterface.SideStage, mainStageAppId: "unity8-dash", sideStageAppId: "webbrowser-app" },
542564 ];
543565 }
544566
545− function test_applicationLoadsInCorrectStage(data) {
567+ function test_applicationLoadsInSavedStage(data) {
546568 WindowStateStorage.saveStage(webbrowserCheckBox.appId, data.stage)
547569
548570 var stagesPriv = findInvisibleChild(tabletStage, "stagesPriv");