on xenial help sign in
move the logic for opening the ModeSwitchWarningDialog to Dialogs.qml
commit5661b7e46531c1fa26c6de5bb4d3117dee117402 authorMichael Zanetti <michael.zanetti@canonical.com> dateWed 4 Nov 2015, 18:03 (11 years ago) parent815b3ba
2 files changed+25−24
qml/Components/Dialogs.qml+25−1 qml/Shell.qml−23
qml/Components/Dialogs.qml+25−1
@@ -21,6 +21,7 @@ import Unity.Session 0.1
2121import Ubuntu.Components 1.1
2222import GlobalShortcut 1.0
2323import Unity.Platform 1.0
24+import Utils 0.1
2425import "../Greeter"
2526
2627Item {
@@ -45,6 +46,28 @@ Item {
4546 d.showPowerDialog();
4647 }
4748
49+ onUsageScenarioChanged: {
50+ if (usageScenario != "desktop" && legacyAppsModel.count > 0 && !d.modeSwitchWarningPopup) {
51+ var comp = Qt.createComponent(Qt.resolvedUrl("ModeSwitchWarningDialog.qml"))
52+ d.modeSwitchWarningPopup = comp.createObject(shell, {model: legacyAppsModel});
53+ d.modeSwitchWarningPopup.forceClose.connect(function() {
54+ while (legacyAppsModel.count > 0) {
55+ ApplicationManager.stopApplication(legacyAppsModel.get(0).appId);
56+ }
57+ })
58+ } else if (usageScenario == "desktop" && d.modeSwitchWarningPopup) {
59+ d.modeSwitchWarningPopup.hide();
60+ d.modeSwitchWarningPopup.destroy();
61+ d.modeSwitchWarningPopup = null;
62+ }
63+ }
64+
65+ ApplicationsFilterModel {
66+ id: legacyAppsModel
67+ applicationsModel: ApplicationManager
68+ filterTouchApps: true
69+ }
70+
4871 GlobalShortcut { // reboot/shutdown dialog
4972 shortcut: Qt.Key_PowerDown
5073 active: Platform.isPC
@@ -91,6 +114,8 @@ Item {
91114 id: d // private stuff
92115 objectName: "dialogsPrivate"
93116
117+ property var modeSwitchWarningPopup: null
118+
94119 function showPowerDialog() {
95120 if (!dialogLoader.active) {
96121 dialogLoader.sourceComponent = powerDialogComponent;
@@ -270,5 +295,4 @@ Item {
270295 unitySessionService.endSession();
271296 }
272297 }
273−
274298}
qml/Shell.qml−23
@@ -95,29 +95,6 @@ Item {
9595 }
9696 }
9797
98− property var modeSwitchWarningPopup: null
99− onUsageScenarioChanged: {
100− if (usageScenario != "desktop" && legacyAppsModel.count > 0 && !modeSwitchWarningPopup) {
101− var comp = Qt.createComponent(Qt.resolvedUrl("Components/ModeSwitchWarningDialog.qml"))
102− modeSwitchWarningPopup = comp.createObject(shell, {model: legacyAppsModel});
103− modeSwitchWarningPopup.forceClose.connect(function() {
104− while (legacyAppsModel.count > 0) {
105− ApplicationManager.stopApplication(legacyAppsModel.get(0).appId);
106− }
107− })
108− } else if (usageScenario == "desktop" && modeSwitchWarningPopup) {
109− modeSwitchWarningPopup.hide();
110− modeSwitchWarningPopup.destroy();
111− modeSwitchWarningPopup = null;
112− }
113− }
114−
115− ApplicationsFilterModel {
116− id: legacyAppsModel
117− applicationsModel: ApplicationManager
118− filterTouchApps: true
119− }
120−
12198 // For autopilot consumption
12299 readonly property string focusedApplicationId: ApplicationManager.focusedApplicationId
123100