on xenial help sign in
move the logic for opening the ModeSwitchWarningDialog to Dialogs.qml
5661b7eMichael Zanetti
qml/Components/Dialogs.qml+25−1
@@ -21,6 +21,7 @@ import Unity.Session 0.1
21import Ubuntu.Components 1.1
21import Ubuntu.Components 1.1
22import GlobalShortcut 1.0
22import GlobalShortcut 1.0
23import Unity.Platform 1.0
23import Unity.Platform 1.0
24+import Utils 0.1
24import "../Greeter"
25import "../Greeter"
25
26
26Item {
27Item {
@@ -45,6 +46,28 @@ Item {
45 d.showPowerDialog();
46 d.showPowerDialog();
46 }
47 }
47
48
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+
48 GlobalShortcut { // reboot/shutdown dialog
71 GlobalShortcut { // reboot/shutdown dialog
49 shortcut: Qt.Key_PowerDown
72 shortcut: Qt.Key_PowerDown
50 active: Platform.isPC
73 active: Platform.isPC
@@ -91,6 +114,8 @@ Item {
91 id: d // private stuff
114 id: d // private stuff
92 objectName: "dialogsPrivate"
115 objectName: "dialogsPrivate"
93
116
117+ property var modeSwitchWarningPopup: null
118+
94 function showPowerDialog() {
119 function showPowerDialog() {
95 if (!dialogLoader.active) {
120 if (!dialogLoader.active) {
96 dialogLoader.sourceComponent = powerDialogComponent;
121 dialogLoader.sourceComponent = powerDialogComponent;
@@ -270,5 +295,4 @@ Item {
270 unitySessionService.endSession();
295 unitySessionService.endSession();
271 }
296 }
272 }
297 }
273−
274}
298}
qml/Shell.qml−23
@@ -95,29 +95,6 @@ Item {
95 }
95 }
96 }
96 }
97
97
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−
121 // For autopilot consumption
98 // For autopilot consumption
122 readonly property string focusedApplicationId: ApplicationManager.focusedApplicationId
99 readonly property string focusedApplicationId: ApplicationManager.focusedApplicationId
123
100