~lukas-kde/unity8/betterSessionManagement

« back to all changes in this revision

Viewing changes to qml/Panel/Panel.qml

  • Committer: Lukáš Tinkl
  • Date: 2017-03-24 11:57:27 UTC
  • mfrom: (2800.1.91 unity8)
  • Revision ID: lukas.tinkl@canonical.com-20170324115727-34c7tvv3qnxvxzdj
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import Unity.ApplicationMenu 0.1
24
24
 
25
25
import QtQuick.Window 2.2
26
 
// for indicator-keyboard
27
 
import AccountsService 0.1
28
 
import Unity.InputInfo 0.1
29
26
 
30
27
import "../ApplicationMenus"
31
28
import "../Components"
41
38
    property real expandedPanelHeight: units.gu(7)
42
39
    property real indicatorMenuWidth: width
43
40
    property real applicationMenuWidth: width
 
41
    property alias applicationMenuContentX: __applicationMenus.menuContentX
44
42
 
45
43
    property alias applicationMenus: __applicationMenus
46
44
    property alias indicators: __indicators
47
45
    property bool fullscreenMode: false
48
46
    property real panelAreaShowProgress: 1.0
49
47
    property bool greeterShown: false
 
48
    property bool hasKeyboard: false
50
49
 
51
50
    property string mode: "staged"
52
51
 
176
175
                    // let it fall through to the window decoration of the maximized window behind, if any
177
176
                    mouse.accepted = false;
178
177
                }
 
178
                var menubar = menuBarLoader.item;
 
179
                if (menubar) {
 
180
                    menubar.invokeMenu(mouse);
 
181
                }
179
182
            }
180
183
 
181
184
            Row {
202
205
 
203
206
                Loader {
204
207
                    id: menuBarLoader
 
208
                    objectName: "menuBarLoader"
205
209
                    height: parent.height
206
210
                    enabled: d.enablePointerMenu
207
211
                    opacity: d.showPointerMenu ? 1 : 0
208
212
                    visible: opacity != 0
209
213
                    Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
210
 
                    active: __applicationMenus.model
211
 
 
212
 
                    property bool menusRequested: menuBarLoader.item ? menuBarLoader.item.showRequested : false
 
214
                    active: __applicationMenus.model && !callHint.visible
 
215
 
 
216
                    width: parent.width - windowControlButtons.width - units.gu(2) - __indicators.barWidth
 
217
 
 
218
                    readonly property bool menusRequested: menuBarLoader.item ? menuBarLoader.item.showRequested : false
213
219
 
214
220
                    sourceComponent: MenuBar {
215
221
                        id: bar
229
235
                            target: __indicators
230
236
                            onShownChanged: bar.dismiss();
231
237
                        }
 
238
 
 
239
                        onDoubleClicked: PanelState.restoreClicked()
 
240
                        onPressed: mouse.accepted = false // let the parent mouse area handle this, so it can both unsnap window and show menu
232
241
                    }
233
242
                }
234
243
            }
248
257
        PanelMenu {
249
258
            id: __applicationMenus
250
259
 
 
260
            x: menuContentX
251
261
            model: registeredMenuModel.model
252
262
            width: root.applicationMenuWidth
253
263
            minimizedPanelHeight: root.minimizedPanelHeight
256
266
            alignment: Qt.AlignLeft
257
267
            enableHint: !callHint.active && !fullscreenMode
258
268
            showOnClick: false
 
269
            adjustDragHandleSizeToContents: false
259
270
            panelColor: panelAreaBackground.color
260
271
 
261
272
            onShowTapped: {
264
275
                }
265
276
            }
266
277
 
267
 
            showRowTitle: !expanded
268
 
            rowTitle: PanelState.title
 
278
            hideRow: !expanded
269
279
            rowItemDelegate: ActionItem {
270
280
                id: actionItem
271
281
                property int ownIndex: index
272
282
                objectName: "appMenuItem"+index
 
283
                enabled: model.sensitive
273
284
 
274
285
                width: _title.width + units.gu(2)
275
286
                height: parent.height
283
294
                    anchors.centerIn: parent
284
295
                    text: actionItem.text
285
296
                    horizontalAlignment: Text.AlignLeft
286
 
                    color: enabled ? "white" : "#5d5d5d"
 
297
                    color: enabled ? theme.palette.normal.backgroundText : theme.palette.disabled.backgroundText
287
298
                }
288
299
            }
289
300
 
290
301
            pageDelegate: PanelMenuPage {
 
302
                readonly property bool isCurrent: modelIndex == __applicationMenus.currentMenuIndex
 
303
                onIsCurrentChanged: {
 
304
                    if (isCurrent && menuModel) {
 
305
                        menuModel.aboutToShow(modelIndex);
 
306
                    }
 
307
                }
 
308
 
291
309
                menuModel: __applicationMenus.model
292
310
                submenuIndex: modelIndex
293
311
 
306
324
            }
307
325
        }
308
326
 
 
327
        Label {
 
328
            id: rowLabel
 
329
            objectName: "panelTitle"
 
330
            anchors {
 
331
                left: parent.left
 
332
                leftMargin: units.gu(1)
 
333
                right: __indicators.left
 
334
                rightMargin: units.gu(1)
 
335
            }
 
336
            height: root.minimizedPanelHeight
 
337
            verticalAlignment: Text.AlignVCenter
 
338
            elide: Text.ElideRight
 
339
            maximumLineCount: 1
 
340
            fontSize: "medium"
 
341
            font.weight: Font.Medium
 
342
            color: Theme.palette.selected.backgroundText
 
343
            opacity: __applicationMenus.visible && !__applicationMenus.expanded ? 1 : 0
 
344
            visible: opacity != 0
 
345
            Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.SnapDuration } }
 
346
            text: PanelState.title
 
347
        }
 
348
 
309
349
        PanelMenu {
310
350
            id: __indicators
311
351
            objectName: "indicators"
335
375
                objectName: identifier+"-panelItem"
336
376
 
337
377
                property int ownIndex: index
338
 
                property bool overflow: parent.width - x > __indicators.overFlowWidth
339
 
                property bool hidden: !expanded && (overflow || !indicatorVisible || hideSessionIndicator || hideKeyboardIndicator)
 
378
                readonly property bool overflow: parent.width - x > __indicators.overFlowWidth
 
379
                readonly property bool hidden: !expanded && (overflow || !indicatorVisible || hideSessionIndicator || hideKeyboardIndicator)
340
380
                // HACK for indicator-session
341
381
                readonly property bool hideSessionIndicator: identifier == "indicator-session" && Math.min(Screen.width, Screen.height) <= units.gu(60)
342
382
                // HACK for indicator-keyboard
343
 
                readonly property bool hideKeyboardIndicator: identifier == "indicator-keyboard" && (AccountsService.keymaps.length < 2 || keyboardsModel.count == 0)
 
383
                readonly property bool hideKeyboardIndicator: identifier == "indicator-keyboard" && !hasKeyboard
344
384
 
345
385
                height: parent.height
346
386
                expanded: indicators.expanded
385
425
            }
386
426
 
387
427
            enabled: !applicationMenus.expanded
388
 
            opacity: !applicationMenus.expanded ? 1 : 0
 
428
            opacity: !callHint.visible && !applicationMenus.expanded ? 1 : 0
389
429
            Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
390
430
 
391
431
            onEnabledChanged: {
394
434
        }
395
435
    }
396
436
 
397
 
    InputDeviceModel {
398
 
        id: keyboardsModel
399
 
        deviceFilter: InputInfo.Keyboard
400
 
    }
401
 
 
402
437
    IndicatorsLight {
403
438
        id: indicatorLights
404
439
    }