on xenial help sign in
Don't display the mode switch warning dialog on tablets (LP: #1600290)
59464a1Lukáš Tinkl
qml/Components/Dialogs.qml+7−2
@@ -15,7 +15,7 @@
15 */
15 */
16
16
17import QtQuick 2.4
17import QtQuick 2.4
18−
18+import QtQuick.Window 2.2
19import Unity.Application 0.1
19import Unity.Application 0.1
20import Unity.Session 0.1
20import Unity.Session 0.1
21import GlobalShortcut 1.0
21import GlobalShortcut 1.0
@@ -41,6 +41,7 @@ Item {
41 }
41 }
42 }
42 }
43 property string usageScenario
43 property string usageScenario
44+ property size screenSize: Qt.size(Screen.width, Screen.height)
44
45
45 signal powerOffClicked();
46 signal powerOffClicked();
46
47
@@ -49,7 +50,11 @@ Item {
49 }
50 }
50
51
51 onUsageScenarioChanged: {
52 onUsageScenarioChanged: {
53+ // if we let the user switch manually to desktop mode, don't display the warning dialog
54+ // see MenuItemFactory.qml, for the Desktop Mode switch logic
55+ var isTabletSize = Math.min(screenSize.width, screenSize.height) > units.gu(60);
56+
52− if (usageScenario != "desktop" && legacyAppsModel.count > 0 && !d.modeSwitchWarningPopup) {
57+ if (usageScenario != "desktop" && legacyAppsModel.count > 0 && !d.modeSwitchWarningPopup && !isTabletSize) {
53 var comp = Qt.createComponent(Qt.resolvedUrl("ModeSwitchWarningDialog.qml"))
58 var comp = Qt.createComponent(Qt.resolvedUrl("ModeSwitchWarningDialog.qml"))
54 d.modeSwitchWarningPopup = comp.createObject(root, {model: legacyAppsModel});
59 d.modeSwitchWarningPopup = comp.createObject(root, {model: legacyAppsModel});
55 d.modeSwitchWarningPopup.forceClose.connect(function() {
60 d.modeSwitchWarningPopup.forceClose.connect(function() {
tests/qmltests/tst_Shell.qml+13−7
@@ -2154,8 +2154,10 @@ Rectangle {
2154
2154
2155 function test_switchToStagedForcesLegacyAppClosing_data() {
2155 function test_switchToStagedForcesLegacyAppClosing_data() {
2156 return [
2156 return [
2157− {tag: "forceClose", replug: false },
2157+ {tag: "forceClose", replug: false, tabletMode: false, screenSize: Qt.size(units.gu(20), units.gu(40)) },
2158+ {tag: "replug", replug: true, tabletMode: false, screenSize: Qt.size(units.gu(20), units.gu(40)) },
2159+ {tag: "forceClose+tablet", replug: false, tabletMode: true, screenSize: Qt.size(units.gu(90), units.gu(65)) },
2158− {tag: "replug", replug: true }
2160+ {tag: "replug+tablet", replug: true, tabletMode: true, screenSize: Qt.size(units.gu(90), units.gu(65)) }
2159 ];
2161 ];
2160 }
2162 }
2161
2163
@@ -2164,6 +2166,11 @@ Rectangle {
2164 shell.usageScenario = "desktop"
2166 shell.usageScenario = "desktop"
2165 waitForRendering(shell);
2167 waitForRendering(shell);
2166
2168
2169+ // setup some screen size
2170+ var dialogs = findChild(root, "dialogs");
2171+ verify(dialogs);
2172+ dialogs.screenSize = data.screenSize;
2173+
2167 ApplicationManager.startApplication("camera-app")
2174 ApplicationManager.startApplication("camera-app")
2168
2175
2169 shell.usageScenario = "phone"
2176 shell.usageScenario = "phone"
@@ -2182,14 +2189,13 @@ Rectangle {
2182 shell.usageScenario = "phone"
2189 shell.usageScenario = "phone"
2183 waitForRendering(shell);
2190 waitForRendering(shell);
2184
2191
2185− // The popup must appear now
2192+ // The popup must appear now, unless in "tablet" mode
2186 popup = findChild(root, "modeSwitchWarningDialog");
2193 popup = findChild(root, "modeSwitchWarningDialog");
2187− compare(popup !== null, true);
2194+ compare(popup !== null, !data.tabletMode);
2188
2195
2189− if (data.replug) {
2196+ if (data.replug || data.tabletMode) {
2190 shell.usageScenario = "desktop"
2197 shell.usageScenario = "desktop"
2191 waitForRendering(shell);
2198 waitForRendering(shell);
2192−
2193 } else {
2199 } else {
2194 var forceCloseButton = findChild(popup, "forceCloseButton");
2200 var forceCloseButton = findChild(popup, "forceCloseButton");
2195 mouseClick(forceCloseButton, forceCloseButton.width / 2, forceCloseButton.height / 2);
2201 mouseClick(forceCloseButton, forceCloseButton.width / 2, forceCloseButton.height / 2);
@@ -2200,7 +2206,7 @@ Rectangle {
2200 popup = findChild(root, "modeSwitchWarningDialog");
2206 popup = findChild(root, "modeSwitchWarningDialog");
2201 tryCompareFunction(function() { return popup === null}, true);
2207 tryCompareFunction(function() { return popup === null}, true);
2202
2208
2203− if (data.replug) {
2209+ if (data.replug || data.tabletMode) {
2204 // Libreoffice must still be running
2210 // Libreoffice must still be running
2205 compare(ApplicationManager.findApplication("libreoffice") !== null, true);
2211 compare(ApplicationManager.findApplication("libreoffice") !== null, true);
2206 } else {
2212 } else {