2 * Copyright (C) 2014-2017 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18import QtQuick.Window 2.2
19import Unity.Application 0.1
20import Unity.Session 0.1
21import GlobalShortcut 1.0
22import Ubuntu.Components 1.3
23import Unity.Platform 1.0
29 acceptedButtons: Qt.AllButtons
31 onWheel: wheel.accepted = true
33 readonly property bool hasActiveDialog: dialogLoader.active || d.modeSwitchWarningPopup
35 // to be set from outside, useful mostly for testing purposes
36 property var unitySessionService: DBusUnitySessionService
37 property var closeAllApps: function() {
39 var app = ApplicationManager.get(0);
43 ApplicationManager.stopApplication(app.appId);
46 property string usageScenario
47 property size screenSize: Qt.size(Screen.width, Screen.height)
48 property bool hasKeyboard: false
50 signal powerOffClicked();
52 function showPowerDialog() {
56 onUsageScenarioChanged: {
57 // if we let the user switch manually to desktop mode, don't display the warning dialog
58 // see MenuItemFactory.qml, for the Desktop Mode switch logic
59 var isTabletSize = Math.min(screenSize.width, screenSize.height) > units.gu(60);
61 if (usageScenario != "desktop" && legacyAppsModel.count > 0 && !d.modeSwitchWarningPopup && !isTabletSize) {
62 var comp = Qt.createComponent(Qt.resolvedUrl("ModeSwitchWarningDialog.qml"))
63 d.modeSwitchWarningPopup = comp.createObject(root, {model: legacyAppsModel});
64 d.modeSwitchWarningPopup.forceClose.connect(function() {
65 for (var i = legacyAppsModel.count - 1; i >= 0; i--) {
66 ApplicationManager.stopApplication(legacyAppsModel.get(i).appId);
68 d.modeSwitchWarningPopup.hide();
69 d.modeSwitchWarningPopup.destroy();
70 d.modeSwitchWarningPopup = null;
72 } else if (usageScenario == "desktop" && d.modeSwitchWarningPopup) {
73 d.modeSwitchWarningPopup.hide();
74 d.modeSwitchWarningPopup.destroy();
75 d.modeSwitchWarningPopup = null;
79 ApplicationsFilterModel {
81 applicationsModel: ApplicationManager
85 GlobalShortcut { // reboot/shutdown dialog
86 shortcut: Qt.Key_PowerDown
88 onTriggered: root.unitySessionService.RequestShutdown()
91 GlobalShortcut { // reboot/shutdown dialog
92 shortcut: Qt.Key_PowerOff
94 onTriggered: root.unitySessionService.RequestShutdown()
97 GlobalShortcut { // sleep
98 shortcut: Qt.Key_Sleep
99 onTriggered: root.unitySessionService.Suspend()
102 GlobalShortcut { // hibernate
103 shortcut: Qt.Key_Hibernate
104 onTriggered: root.unitySessionService.Hibernate()
107 GlobalShortcut { // logout/lock dialog
108 shortcut: Qt.Key_LogOff
109 onTriggered: root.unitySessionService.RequestLogout()
112 GlobalShortcut { // logout/lock dialog
113 shortcut: Qt.ControlModifier|Qt.AltModifier|Qt.Key_Delete
114 onTriggered: root.unitySessionService.RequestLogout()
117 GlobalShortcut { // lock screen
118 shortcut: Qt.Key_ScreenSaver
119 onTriggered: LightDMService.greeter.showGreeter()
122 GlobalShortcut { // lock screen
123 shortcut: Qt.ControlModifier|Qt.AltModifier|Qt.Key_L
124 onTriggered: LightDMService.greeter.showGreeter()
127 GlobalShortcut { // lock screen
128 shortcut: Qt.MetaModifier|Qt.Key_L
129 onTriggered: LightDMService.greeter.showGreeter()
133 id: d // private stuff
134 objectName: "dialogsPrivate"
136 property var modeSwitchWarningPopup: null
138 function showPowerDialog() {
139 if (!dialogLoader.active) {
140 dialogLoader.sourceComponent = powerDialogComponent;
141 dialogLoader.focus = true;
142 dialogLoader.active = true;
149 objectName: "dialogLoader"
154 if (previousFocusedItem) {
155 previousFocusedItem.forceActiveFocus(Qt.OtherFocusReason);
156 previousFocusedItem = undefined;
158 previousSourceComponent = undefined;
159 sourceComponent = undefined;
162 onSourceComponentChanged: {
163 if (previousSourceComponent !== sourceComponent) {
164 previousSourceComponent = sourceComponent;
165 previousFocusedItem = window.activeFocusItem;
169 property var previousSourceComponent: undefined
170 property var previousFocusedItem: undefined
174 id: logoutDialogComponent
177 title: i18n.ctr("Title: Lock/Log out dialog", "Log out")
178 text: i18n.tr("Are you sure you want to log out?")
181 text: i18n.ctr("Button: Lock the system", "Lock")
183 LightDMService.greeter.showGreeter()
186 Component.onCompleted: if (root.hasKeyboard) forceActiveFocus(Qt.TabFocusReason)
191 text: i18n.ctr("Button: Log out from the system", "Log Out")
193 unitySessionService.logout();
199 text: i18n.tr("Cancel")
208 id: rebootDialogComponent
211 title: i18n.ctr("Title: Reboot dialog", "Reboot")
212 text: i18n.tr("Are you sure you want to reboot?")
226 unitySessionService.reboot();
229 color: theme.palette.normal.negative
230 Component.onCompleted: if (root.hasKeyboard) forceActiveFocus(Qt.TabFocusReason)
236 id: powerDialogComponent
239 title: i18n.ctr("Title: Power off/Restart dialog", "Power")
240 text: i18n.tr("Are you sure you would like\nto power off?")
244 text: i18n.ctr("Button: Power off the system", "Power off")
248 root.powerOffClicked();
250 color: theme.palette.normal.negative
251 Component.onCompleted: if (root.hasKeyboard) forceActiveFocus(Qt.TabFocusReason)
255 text: i18n.ctr("Button: Restart the system", "Restart")
258 unitySessionService.reboot();
264 text: i18n.tr("Cancel")
273 target: root.unitySessionService
276 // Display a dialog to ask the user to confirm.
277 if (!dialogLoader.active) {
278 dialogLoader.sourceComponent = logoutDialogComponent;
279 dialogLoader.focus = true;
280 dialogLoader.active = true;
284 onShutdownRequested: {
285 // Display a dialog to ask the user to confirm.
290 // Display a dialog to ask the user to confirm.
292 // display a combined reboot/shutdown dialog, sadly the session indicator calls rather the "Reboot()" method
293 // than shutdown when clicking on the "Shutdown..." menu item
294 // FIXME: when/if session indicator is fixed, put the rebootDialogComponent here
301 unitySessionService.endSession();
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list