on xenial help sign in
Open portrait apps in sidestage by default
aa1e355Nick Dedekind
plugins/Utils/windowstatestorage.cpp+2−2
@@ -95,7 +95,7 @@ void WindowStateStorage::saveStage(const QString &appId, int stage)
95 saveValue(queryString);
95 saveValue(queryString);
96}
96}
97
97
98−int WindowStateStorage::getStage(const QString &appId) const
98+int WindowStateStorage::getStage(const QString &appId, int defaultValue) const
99{
99{
100 const QString queryString = QStringLiteral("SELECT * FROM stage WHERE appId = '%1';")
100 const QString queryString = QStringLiteral("SELECT * FROM stage WHERE appId = '%1';")
101 .arg(sanitiseString(appId));
101 .arg(sanitiseString(appId));
@@ -103,7 +103,7 @@ int WindowStateStorage::getStage(const QString &appId) const
103 QSqlQuery query = getValue(queryString);
103 QSqlQuery query = getValue(queryString);
104
104
105 if (!query.first()) {
105 if (!query.first()) {
106− return unity::shell::application::ApplicationInfoInterface::MainStage;
106+ return defaultValue;
107 }
107 }
108 return query.value("stage").toInt();
108 return query.value("stage").toInt();
109}
109}
plugins/Utils/windowstatestorage.h+1−1
@@ -49,7 +49,7 @@ public:
49 Q_INVOKABLE QRect getGeometry(const QString &windowId, const QRect defaultValue) const;
49 Q_INVOKABLE QRect getGeometry(const QString &windowId, const QRect defaultValue) const;
50
50
51 Q_INVOKABLE void saveStage(const QString &appId, int stage);
51 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;
53
53
54private:
54private:
55 void initdb();
55 void initdb();
qml/Stages/TabletStage.qml+9−3
@@ -101,7 +101,7 @@ AbstractStage {
101 orientations |= Qt.LandscapeOrientation | Qt.InvertedLandscapeOrientation;
101 orientations |= Qt.LandscapeOrientation | Qt.InvertedLandscapeOrientation;
102 if (priv.sideStageItemId && !spreadView.surfaceDragging) {
102 if (priv.sideStageItemId && !spreadView.surfaceDragging) {
103 // If we have a sidestage app, support Portrait orientation
103 // 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
105 orientations |= Qt.PortraitOrientation|Qt.InvertedPortraitOrientation;
105 orientations |= Qt.PortraitOrientation|Qt.InvertedPortraitOrientation;
106 }
106 }
107 return orientations;
107 return orientations;
@@ -849,9 +849,15 @@ AbstractStage {
849
849
850 function refreshStage() {
850 function refreshStage() {
851 var newStage = ApplicationInfoInterface.MainStage;
851 var newStage = ApplicationInfoInterface.MainStage;
852− if (priv.sideStageEnabled) {
852+ if (priv.sideStageEnabled) { // we're in lanscape rotation.
853 if (application && application.supportedOrientations & (Qt.PortraitOrientation|Qt.InvertedPortraitOrientation)) {
853 if (application && application.supportedOrientations & (Qt.PortraitOrientation|Qt.InvertedPortraitOrientation)) {
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+ }
854− newStage = WindowStateStorage.getStage(application.appId);
860+ newStage = WindowStateStorage.getStage(application.appId, defaultStage);
855 }
861 }
856 }
862 }
857
863
tests/mocks/Utils/windowstatestorage.cpp+2−2
@@ -53,9 +53,9 @@ void WindowStateStorage::saveStage(const QString &appId, int stage)
53 Q_EMIT stageSaved(appId, stage);
53 Q_EMIT stageSaved(appId, stage);
54}
54}
55
55
56−int WindowStateStorage::getStage(const QString &appId) const
56+int WindowStateStorage::getStage(const QString &appId, int defaultValue) const
57{
57{
58− return m_stage.value(appId, unity::shell::application::ApplicationInfoInterface::MainStage);
58+ return m_stage.value(appId, defaultValue);
59}
59}
60
60
61void WindowStateStorage::clear()
61void WindowStateStorage::clear()
tests/mocks/Utils/windowstatestorage.h+1−1
@@ -48,7 +48,7 @@ public:
48 Q_INVOKABLE QRect getGeometry(const QString &windowId, const QRect &defaultValue);
48 Q_INVOKABLE QRect getGeometry(const QString &windowId, const QRect &defaultValue);
49
49
50 Q_INVOKABLE void saveStage(const QString &appId, int stage);
50 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;
52
52
53 // Only in the mock, to easily restore a fresh state
53 // Only in the mock, to easily restore a fresh state
54 Q_INVOKABLE void clear();
54 Q_INVOKABLE void clear();
tests/qmltests/Stages/tst_TabletStage.qml+24−2
@@ -493,14 +493,36 @@ Rectangle {
493 function() { return sideStage.shown; });
493 function() { return sideStage.shown; });
494 }
494 }
495
495
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() {
497 return [
519 return [
498 { tag: "MainStage", stage: ApplicationInfoInterface.MainStage, mainStageAppId: "webbrowser-app", sideStageAppId: ""},
520 { tag: "MainStage", stage: ApplicationInfoInterface.MainStage, mainStageAppId: "webbrowser-app", sideStageAppId: ""},
499 { tag: "SideStage", stage: ApplicationInfoInterface.SideStage, mainStageAppId: "unity8-dash", sideStageAppId: "webbrowser-app" },
521 { tag: "SideStage", stage: ApplicationInfoInterface.SideStage, mainStageAppId: "unity8-dash", sideStageAppId: "webbrowser-app" },
500 ];
522 ];
501 }
523 }
502
524
503− function test_applicationLoadsInCorrectStage(data) {
525+ function test_applicationLoadsInSavedStage(data) {
504 WindowStateStorage.saveStage(webbrowserCheckBox.appId, data.stage)
526 WindowStateStorage.saveStage(webbrowserCheckBox.appId, data.stage)
505
527
506 var stagesPriv = findInvisibleChild(tabletStage, "stagesPriv");
528 var stagesPriv = findInvisibleChild(tabletStage, "stagesPriv");