on xenial help sign in
Don't display the mode switch warning dialog on tablets (LP: #1600290)

Approved by: Michael Zanetti

commit59464a1e98ee2cd2b804206e1701aa1d0c64e5cc authorLukáš Tinkl <lukas.tinkl@canonical.com> dateWed 3 Aug 2016, 15:53 (10 years ago) parent18e9b46b20e9b4
2 files changed+20−9
qml/Components/Dialogs.qml+7−2 tests/qmltests/tst_Shell.qml+13−7
qml/Components/Dialogs.qml+7−2
@@ -15,7 +15,7 @@
1515 */
1616
1717import QtQuick 2.4
18−
18+import QtQuick.Window 2.2
1919import Unity.Application 0.1
2020import Unity.Session 0.1
2121import GlobalShortcut 1.0
@@ -41,6 +41,7 @@ Item {
4141 }
4242 }
4343 property string usageScenario
44+ property size screenSize: Qt.size(Screen.width, Screen.height)
4445
4546 signal powerOffClicked();
4647
@@ -49,7 +50,11 @@ Item {
4950 }
5051
5152 onUsageScenarioChanged: {
52− if (usageScenario != "desktop" && legacyAppsModel.count > 0 && !d.modeSwitchWarningPopup) {
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+
57+ if (usageScenario != "desktop" && legacyAppsModel.count > 0 && !d.modeSwitchWarningPopup && !isTabletSize) {
5358 var comp = Qt.createComponent(Qt.resolvedUrl("ModeSwitchWarningDialog.qml"))
5459 d.modeSwitchWarningPopup = comp.createObject(root, {model: legacyAppsModel});
5560 d.modeSwitchWarningPopup.forceClose.connect(function() {
tests/qmltests/tst_Shell.qml+13−7
@@ -2154,8 +2154,10 @@ Rectangle {
21542154
21552155 function test_switchToStagedForcesLegacyAppClosing_data() {
21562156 return [
2157− {tag: "forceClose", replug: false },
2158− {tag: "replug", replug: true }
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)) },
2160+ {tag: "replug+tablet", replug: true, tabletMode: true, screenSize: Qt.size(units.gu(90), units.gu(65)) }
21592161 ];
21602162 }
21612163
@@ -2164,6 +2166,11 @@ Rectangle {
21642166 shell.usageScenario = "desktop"
21652167 waitForRendering(shell);
21662168
2169+ // setup some screen size
2170+ var dialogs = findChild(root, "dialogs");
2171+ verify(dialogs);
2172+ dialogs.screenSize = data.screenSize;
2173+
21672174 ApplicationManager.startApplication("camera-app")
21682175
21692176 shell.usageScenario = "phone"
@@ -2182,14 +2189,13 @@ Rectangle {
21822189 shell.usageScenario = "phone"
21832190 waitForRendering(shell);
21842191
2185− // The popup must appear now
2192+ // The popup must appear now, unless in "tablet" mode
21862193 popup = findChild(root, "modeSwitchWarningDialog");
2187− compare(popup !== null, true);
2194+ compare(popup !== null, !data.tabletMode);
21882195
2189− if (data.replug) {
2196+ if (data.replug || data.tabletMode) {
21902197 shell.usageScenario = "desktop"
21912198 waitForRendering(shell);
2192−
21932199 } else {
21942200 var forceCloseButton = findChild(popup, "forceCloseButton");
21952201 mouseClick(forceCloseButton, forceCloseButton.width / 2, forceCloseButton.height / 2);
@@ -2200,7 +2206,7 @@ Rectangle {
22002206 popup = findChild(root, "modeSwitchWarningDialog");
22012207 tryCompareFunction(function() { return popup === null}, true);
22022208
2203− if (data.replug) {
2209+ if (data.replug || data.tabletMode) {
22042210 // Libreoffice must still be running
22052211 compare(ApplicationManager.findApplication("libreoffice") !== null, true);
22062212 } else {