~mterry/+junk/u8.2

« back to all changes in this revision

Viewing changes to qml/Shell.qml

  • Committer: Michael Terry
  • Date: 2014-11-17 14:56:04 UTC
  • mfrom: (1317.1.118 unity8)
  • Revision ID: michael.terry@canonical.com-20141117145604-96dn9p5nwkifq2f4
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
import "Components"
37
37
import "Notifications"
38
38
import "Stages"
 
39
import "Panel/Indicators"
39
40
import Unity.Notifications 1.0 as NotificationBackend
40
41
import Unity.Session 0.1
41
42
import Unity.DashCommunicator 0.1
54
55
    readonly property real panelHeight: panel.panelHeight
55
56
 
56
57
    readonly property bool locked: LightDM.Greeter.active && !LightDM.Greeter.authenticated && !forcedUnlock
 
58
    readonly property alias hasLockedApp: greeter.hasLockedApp
57
59
    readonly property bool forcedUnlock: edgeDemo.running
58
60
    onForcedUnlockChanged: if (forcedUnlock) lockscreen.hide()
59
61
 
90
92
    }
91
93
 
92
94
    function startLockedApp(app) {
93
 
        if (!shell.locked) {
94
 
            console.warn("Called startLockedApp(%1) when not locked, ignoring".arg(app))
95
 
            return
 
95
        if (shell.locked) {
 
96
            greeter.lockedApp = app;
96
97
        }
97
 
        greeter.lockedApp = app
98
 
        shell.activateApplication(app)
 
98
        shell.activateApplication(app);
99
99
    }
100
100
 
101
101
    Binding {
132
132
        objectName: "dashCommunicator"
133
133
    }
134
134
 
 
135
    ScreenGrabber {
 
136
        id: screenGrabber
 
137
        z: edgeDemo.z + 10
 
138
        enabled: Powerd.status === Powerd.On
 
139
    }
 
140
 
135
141
    Binding {
136
142
        target: ApplicationManager
137
143
        property: "forceDashActive"
138
144
        value: launcher.shown || launcher.dashSwipe
139
145
    }
140
146
 
 
147
    VolumeKeyFilter {
 
148
        id: volumeKeyFilter
 
149
        onVolumeDownPressed: volumeControl.volumeDown()
 
150
        onVolumeUpPressed: volumeControl.volumeUp()
 
151
        onBothVolumeKeysPressed: screenGrabber.capture()
 
152
    }
141
153
 
142
154
    WindowKeysFilter {
143
 
        // Handle but do not filter out volume keys
144
 
        Keys.onVolumeUpPressed: { volumeControl.volumeUp(); event.accepted = false; }
145
 
        Keys.onVolumeDownPressed: { volumeControl.volumeDown(); event.accepted = false; }
146
 
 
147
155
        Keys.onPressed: {
148
156
            if (event.key == Qt.Key_PowerOff || event.key == Qt.Key_PowerDown) {
149
157
                dialogs.onPowerKeyPressed();
150
158
                event.accepted = true;
151
159
            } else {
 
160
                volumeKeyFilter.onKeyPressed(event.key);
152
161
                event.accepted = false;
153
162
            }
154
163
        }
158
167
                dialogs.onPowerKeyReleased();
159
168
                event.accepted = true;
160
169
            } else {
 
170
                volumeKeyFilter.onKeyReleased(event.key);
161
171
                event.accepted = false;
162
172
            }
163
173
        }
174
184
            target: ApplicationManager
175
185
            onFocusRequested: {
176
186
                if (greeter.narrowMode) {
177
 
                    if (appId === "dialer-app" && callManager.hasCalls) {
 
187
                    if (appId === "dialer-app" && callManager.hasCalls && shell.locked) {
178
188
                        // If we are in the middle of a call, make dialer lockedApp and show it.
179
189
                        // This can happen if user backs out of dialer back to greeter, then
180
190
                        // launches dialer again.
243
253
                target: applicationsDisplayLoader.item
244
254
                property: "maximizedAppTopMargin"
245
255
                // Not just using panel.panelHeight as that changes depending on the focused app.
246
 
                value: panel.indicators.panelHeight
 
256
                value: panel.indicators.minimizedPanelHeight + units.dp(2) // dp(2) for orange line
247
257
            }
248
258
            Binding {
249
259
                target: applicationsDisplayLoader.item
250
260
                property: "interactive"
251
 
                value: edgeDemo.stagesEnabled && !greeter.shown && !lockscreen.shown && panel.indicators.fullyClosed && launcher.progress == 0
 
261
                value: edgeDemo.stagesEnabled && !greeter.shown && !lockscreen.shown && panel.indicators.fullyClosed && launcher.progress == 0 && !notifications.useModal
252
262
            }
253
263
            Binding {
254
264
                target: applicationsDisplayLoader.item
370
380
        onHideGreeter: greeter.login()
371
381
 
372
382
        onShowPrompt: {
 
383
            shell.enabled = true;
 
384
            if (!LightDM.Greeter.active) {
 
385
                return; // could happen if hideGreeter() comes in before we prompt
 
386
            }
373
387
            if (greeter.narrowMode) {
374
388
                if (isDefaultPrompt) {
375
389
                    if (lockscreen.alphaNumeric) {
390
404
        }
391
405
 
392
406
        onPromptlessChanged: {
 
407
            if (!LightDM.Greeter.active) {
 
408
                return; // could happen if hideGreeter() comes in before we prompt
 
409
            }
393
410
            if (greeter.narrowMode) {
394
411
                if (LightDM.Greeter.promptless && LightDM.Greeter.authenticated) {
395
412
                    lockscreen.hide()
401
418
        }
402
419
 
403
420
        onAuthenticationComplete: {
 
421
            shell.enabled = true;
404
422
            if (LightDM.Greeter.authenticated) {
405
423
                AccountsService.failedLogins = 0
406
424
            }
537
555
 
538
556
            onShownChanged: {
539
557
                if (shown) {
 
558
                    // Disable everything so that user can't swipe greeter or
 
559
                    // launcher until we get first prompt/authenticate, which
 
560
                    // will re-enable the shell.
 
561
                    shell.enabled = false;
 
562
 
540
563
                    if (greeter.narrowMode) {
541
564
                        LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
542
565
                    } else {
547
570
                }
548
571
            }
549
572
 
550
 
            /* TODO re-enable when the corresponding changes in the service land (LP: #1361074)
551
573
            Component.onCompleted: {
552
574
                Connectivity.unlockAllModems()
553
 
            } */
 
575
            }
554
576
 
555
577
            onUnlocked: greeter.hide()
556
578
            onSelected: {
594
616
        target: Powerd
595
617
 
596
618
        onStatusChanged: {
597
 
            if (Powerd.status === Powerd.Off && !callManager.hasCalls && !edgeDemo.running) {
 
619
            if (Powerd.status === Powerd.Off && reason !== Powerd.Proximity &&
 
620
                    !callManager.hasCalls && !edgeDemo.running) {
598
621
                greeter.showNow()
599
622
            }
600
623
        }
610
633
        }
611
634
 
612
635
        var animate = !LightDM.Greeter.active && !stages.shown
613
 
        dash.setCurrentScope("clickscope", animate, false)
 
636
        dash.setCurrentScope(0, animate, false)
614
637
        ApplicationManager.requestFocusApplication("unity8-dash")
615
638
    }
616
639
 
646
669
                available: edgeDemo.panelEnabled && (!shell.locked || AccountsService.enableIndicatorsWhileLocked) && !greeter.hasLockedApp
647
670
                contentEnabled: edgeDemo.panelContentEnabled
648
671
                width: parent.width > units.gu(60) ? units.gu(40) : parent.width
649
 
                panelHeight: units.gu(3)
650
 
 
 
672
 
 
673
                minimizedPanelHeight: units.gu(3)
 
674
                expandedPanelHeight: units.gu(7)
 
675
 
 
676
                indicatorsModel: visibleIndicators.model
 
677
            }
 
678
 
 
679
            VisibleIndicators {
 
680
                id: visibleIndicators
 
681
                objectName: "visibleIndicators"
651
682
                // TODO: This should be sourced by device type (eg "desktop", "tablet", "phone"...)
652
683
                profile: LightDM.Greeter.active ? (indicatorProfile + "_greeter") : indicatorProfile
 
684
                Component.onCompleted: initialise(profile)
 
685
            }
 
686
            callHint {
 
687
                greeterShown: greeter.shown || lockscreen.shown
653
688
            }
654
689
 
655
690
            property bool topmostApplicationIsFullscreen:
676
711
            onDash: showDash()
677
712
            onDashSwipeChanged: {
678
713
                if (dashSwipe) {
679
 
                    dash.setCurrentScope("clickscope", false, true)
 
714
                    dash.setCurrentScope(0, false, true)
680
715
                }
681
716
            }
682
717
            onLauncherApplicationSelected: {
696
731
        Rectangle {
697
732
            id: modalNotificationBackground
698
733
 
699
 
            visible: notifications.useModal && !greeter.shown && (notifications.state == "narrow")
 
734
            visible: notifications.useModal && (notifications.state == "narrow")
700
735
            color: "#000000"
701
736
            anchors.fill: parent
702
737
            opacity: 0.9
712
747
            model: NotificationBackend.Model
713
748
            margin: units.gu(1)
714
749
 
715
 
            y: panel.panelHeight
 
750
            y: topmostIsFullscreen ? 0 : panel.panelHeight
716
751
            width: parent.width
717
 
            height: parent.height - panel.panelHeight
 
752
            height: parent.height - (topmostIsFullscreen ? 0 : panel.panelHeight)
718
753
 
719
754
            states: [
720
755
                State {
766
801
        paused: Powerd.status === Powerd.Off // Saves power
767
802
        greeter: greeter
768
803
        launcher: launcher
769
 
        indicators: panel.indicators
 
804
        panel: panel
770
805
        stages: stages
771
806
    }
772
807