~lukas-kde/unity8/dashboard

« back to all changes in this revision

Viewing changes to qml/Components/Dialogs.qml

  • Committer: Lukáš Tinkl
  • Date: 2017-01-26 12:13:17 UTC
  • mfrom: (2749.1.49 unity8)
  • Revision ID: lukas.tinkl@canonical.com-20170126121317-qms39s9pikclidbe
merge trunk, fix conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2014-2016 Canonical, Ltd.
 
2
 * Copyright (C) 2014-2017 Canonical, Ltd.
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
5
5
 * it under the terms of the GNU General Public License as published by
24
24
import Utils 0.1
25
25
import "../Greeter"
26
26
 
27
 
Item {
 
27
MouseArea {
28
28
    id: root
 
29
    acceptedButtons: Qt.AllButtons
 
30
    hoverEnabled: true
 
31
    onWheel: wheel.accepted = true
29
32
 
30
 
    readonly property alias hasActiveDialog: dialogLoader.active
 
33
    readonly property bool hasActiveDialog: dialogLoader.active || d.modeSwitchWarningPopup
31
34
 
32
35
    // to be set from outside, useful mostly for testing purposes
33
36
    property var unitySessionService: DBusUnitySessionService
42
45
    }
43
46
    property string usageScenario
44
47
    property size screenSize: Qt.size(Screen.width, Screen.height)
 
48
    property bool hasKeyboard: false
45
49
 
46
50
    signal powerOffClicked();
47
51
 
120
124
        onTriggered: LightDMService.greeter.showGreeter()
121
125
    }
122
126
 
 
127
    GlobalShortcut { // lock screen
 
128
        shortcut: Qt.MetaModifier|Qt.Key_L
 
129
        onTriggered: LightDMService.greeter.showGreeter()
 
130
    }
 
131
 
123
132
    QtObject {
124
133
        id: d // private stuff
125
134
        objectName: "dialogsPrivate"
140
149
        objectName: "dialogLoader"
141
150
        anchors.fill: parent
142
151
        active: false
 
152
        onActiveChanged: {
 
153
            if (!active) {
 
154
                if (previousFocusedItem) {
 
155
                    previousFocusedItem.forceActiveFocus(Qt.OtherFocusReason);
 
156
                    previousFocusedItem = undefined;
 
157
                }
 
158
                previousSourceComponent = undefined;
 
159
                sourceComponent = undefined;
 
160
            }
 
161
        }
 
162
        onSourceComponentChanged: {
 
163
            if (previousSourceComponent !== sourceComponent) {
 
164
                previousSourceComponent = sourceComponent;
 
165
                previousFocusedItem = window.activeFocusItem;
 
166
            }
 
167
        }
 
168
 
 
169
        property var previousSourceComponent: undefined
 
170
        property var previousFocusedItem: undefined
143
171
    }
144
172
 
145
173
    Component {
149
177
            title: i18n.ctr("Title: Lock/Log out dialog", "Log out")
150
178
            text: i18n.tr("Are you sure you want to log out?")
151
179
            Button {
 
180
                width: parent.width
152
181
                text: i18n.ctr("Button: Lock the system", "Lock")
153
182
                onClicked: {
154
183
                    LightDMService.greeter.showGreeter()
155
184
                    logoutDialog.hide();
156
185
                }
 
186
                Component.onCompleted: if (root.hasKeyboard) forceActiveFocus(Qt.TabFocusReason)
157
187
            }
158
188
            Button {
 
189
                width: parent.width
159
190
                focus: true
160
191
                text: i18n.ctr("Button: Log out from the system", "Log Out")
161
192
                onClicked: {
164
195
                }
165
196
            }
166
197
            Button {
 
198
                width: parent.width
167
199
                text: i18n.tr("Cancel")
168
200
                onClicked: {
169
201
                    logoutDialog.hide();
179
211
            title: i18n.ctr("Title: Reboot dialog", "Reboot")
180
212
            text: i18n.tr("Are you sure you want to reboot?")
181
213
            Button {
 
214
                width: parent.width
182
215
                text: i18n.tr("No")
183
216
                onClicked: {
184
217
                    rebootDialog.hide();
185
218
                }
186
219
            }
187
220
            Button {
 
221
                width: parent.width
188
222
                focus: true
189
223
                text: i18n.tr("Yes")
190
224
                onClicked: {
193
227
                    rebootDialog.hide();
194
228
                }
195
229
                color: theme.palette.normal.negative
 
230
                Component.onCompleted: if (root.hasKeyboard) forceActiveFocus(Qt.TabFocusReason)
196
231
            }
197
232
        }
198
233
    }
204
239
            title: i18n.ctr("Title: Power off/Restart dialog", "Power")
205
240
            text: i18n.tr("Are you sure you would like\nto power off?")
206
241
            Button {
 
242
                width: parent.width
207
243
                focus: true
208
244
                text: i18n.ctr("Button: Power off the system", "Power off")
209
245
                onClicked: {
212
248
                    root.powerOffClicked();
213
249
                }
214
250
                color: theme.palette.normal.negative
 
251
                Component.onCompleted: if (root.hasKeyboard) forceActiveFocus(Qt.TabFocusReason)
215
252
            }
216
253
            Button {
 
254
                width: parent.width
217
255
                text: i18n.ctr("Button: Restart the system", "Restart")
218
256
                onClicked: {
219
257
                    root.closeAllApps();
222
260
                }
223
261
            }
224
262
            Button {
 
263
                width: parent.width
225
264
                text: i18n.tr("Cancel")
226
265
                onClicked: {
227
266
                    powerDialog.hide();