2 * Copyright (C) 2013 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 AccountsService 0.1
20import Unity.Application 0.1
21import Ubuntu.Components 0.1
22import Ubuntu.Components.Popups 0.1
23import Ubuntu.Gestures 0.1
24import Unity.Launcher 0.1
26import LightDM 0.1 as LightDM
28import SessionBroadcast 0.1
36import Unity.Notifications 1.0 as NotificationBackend
37import Unity.Session 0.1
42 // this is only here to select the width / height of the window if not running fullscreen
43 property bool tablet: false
44 width: tablet ? units.gu(160) : applicationArguments.hasGeometry() ? applicationArguments.width() : units.gu(40)
45 height: tablet ? units.gu(100) : applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(71)
47 property real edgeSize: units.gu(2)
48 property url defaultBackground: Qt.resolvedUrl(shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg")
49 property url background
50 readonly property real panelHeight: panel.panelHeight
52 property bool dashShown: dash.shown && dash.available && underlay.visible
54 property bool sideStageEnabled: shell.width >= units.gu(100)
55 readonly property string focusedApplicationId: ApplicationManager.focusedApplicationId
57 function activateApplication(appId) {
58 if (ApplicationManager.findApplication(appId)) {
59 ApplicationManager.requestFocusApplication(appId);
61 var execFlags = shell.sideStageEnabled ? ApplicationManager.NoFlag : ApplicationManager.ForceMainStage;
62 ApplicationManager.startApplication(appId, execFlags);
69 property: "applicationManager"
70 value: ApplicationManager
73 Component.onCompleted: {
74 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
78 id: backgroundSettings
79 schema.id: "org.gnome.desktop.background"
81 property url gSettingsPicture: backgroundSettings.pictureUri != undefined && backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : shell.defaultBackground
82 onGSettingsPictureChanged: {
83 shell.background = gSettingsPicture
91 // Handle but do not filter out volume keys
92 Keys.onVolumeUpPressed: { volumeControl.volumeUp(); event.accepted = false; }
93 Keys.onVolumeDownPressed: { volumeControl.volumeDown(); event.accepted = false; }
96 if (event.key == Qt.Key_PowerOff || event.key == Qt.Key_PowerDown) {
97 if (!powerKeyTimer.running) {
98 powerKeyTimer.start();
100 event.accepted = true;
102 event.accepted = false;
107 if (event.key == Qt.Key_PowerOff || event.key == Qt.Key_PowerDown) {
108 powerKeyTimer.stop();
109 event.accepted = true;
111 event.accepted = false;
118 objectName: "underlay"
121 // Whether the underlay is fully covered by opaque UI elements.
122 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
123 visible: !fullyCovered
127 source: shell.width > shell.height ? "Dash/graphics/paper_landscape.png" : "Dash/graphics/paper_portrait.png"
128 fillMode: Image.PreserveAspectCrop
129 horizontalAlignment: Image.AlignRight
130 verticalAlignment: Image.AlignTop
137 available: !greeter.shown && !lockscreen.shown
138 hides: [stages, launcher, panel.indicators]
139 shown: disappearingAnimationProgress !== 1.0 && greeterWrapper.showProgress !== 1.0 &&
140 !(panel.indicators.fullyOpened && !sideStageEnabled)
141 enabled: disappearingAnimationProgress === 0.0 && greeterWrapper.showProgress === 0.0 && edgeDemo.dashEnabled
145 topMargin: panel.panelHeight
148 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
149 opacity: 1.0 - disappearingAnimationProgress
150 property real disappearingAnimationProgress: stages.showProgress
152 // FIXME: only necessary because stages.showProgress is not animated
153 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
159 direction: Direction.Leftwards
161 anchors { top: parent.top; right: parent.right; bottom: parent.bottom }
162 width: shell.edgeSize
164 property real progress: stages.width
167 if (status == DirectionalDragArea.Recognized) {
168 if (ApplicationManager.empty) {
169 progress = Math.max(stages.width - stagesDragArea.width + touchX, stages.width * .3);
171 progress = stages.width - stagesDragArea.width + touchX;
178 if (!ApplicationManager.empty && progress < stages.width - units.gu(10)) {
181 stagesDragArea.progress = Qt.binding(function () { return stages.width; });
190 height: parent.height
192 visible: !fullyHidden && !ApplicationManager.empty
199 return launcher.progress;
201 return stagesDragArea.progress
204 Behavior on x { SmoothedAnimation { velocity: 600; duration: UbuntuAnimation.FastDuration } }
206 property bool shown: false
209 if (ApplicationManager.count > 0) {
210 ApplicationManager.focusApplication(ApplicationManager.get(0).appId);
213 if (ApplicationManager.focusedApplicationId) {
214 ApplicationManager.updateScreenshot(ApplicationManager.focusedApplicationId);
215 ApplicationManager.unfocusCurrentApplication();
220 // Avoid a silent "divide by zero -> NaN" situation during init as shell.width will be
221 // zero. That breaks the property binding and the function won't be reevaluated once
222 // shell.width is set, with the NaN result staying there for good.
223 property real showProgress: shell.width ? MathUtils.clamp(1 - x / shell.width, 0, 1) : 0
225 property bool fullyShown: x == 0
226 property bool fullyHidden: x == width
228 property bool locked: applicationsDisplayLoader.item ? applicationsDisplayLoader.item.locked : false
230 // It might technically not be fullyShown but visually it just looks so.
231 property bool roughlyFullyShown: x >= 0 && x <= units.gu(1)
242 target: ApplicationManager
250 onApplicationAdded: {
260 if (ApplicationManager.empty) {
266 property bool dialogShown: false
273 text: "Are you sure that you want to logout?"
277 PopupUtils.close(dialogueLogout);
278 stages.dialogShown = false;
284 DBusUnitySessionService.Logout();
285 PopupUtils.close(dialogueLogout);
286 stages.dialogShown = false;
297 text: "Are you sure that you want to shutdown?"
301 PopupUtils.close(dialogueShutdown);
302 stages.dialogShown = false;
308 dBusUnitySessionServiceConnection.closeAllApps();
309 DBusUnitySessionService.Shutdown();
310 PopupUtils.close(dialogueShutdown);
311 stages.dialogShown = false;
322 text: "Are you sure that you want to reboot?"
326 PopupUtils.close(dialogueReboot)
327 stages.dialogShown = false;
333 dBusUnitySessionServiceConnection.closeAllApps();
334 DBusUnitySessionService.Reboot();
335 PopupUtils.close(dialogueReboot);
336 stages.dialogShown = false;
347 text: i18n.tr("Are you sure you would like to turn power off?")
349 text: i18n.tr("Power off")
351 dBusUnitySessionServiceConnection.closeAllApps();
352 PopupUtils.close(dialoguePower);
353 stages.dialogShown = false;
354 shutdownFadeOutRectangle.enabled = true;
355 shutdownFadeOutRectangle.visible = true;
356 shutdownFadeOut.start();
360 text: i18n.tr("Restart")
362 dBusUnitySessionServiceConnection.closeAllApps();
363 DBusUnitySessionService.Reboot();
364 PopupUtils.close(dialoguePower);
365 stages.dialogShown = false;
369 text: i18n.tr("Cancel")
371 PopupUtils.close(dialoguePower);
372 stages.dialogShown = false;
378 function showPowerDialog() {
379 if (!stages.dialogShown) {
380 stages.dialogShown = true;
381 PopupUtils.open(powerDialog);
386 id: dBusUnitySessionServiceConnection
387 objectName: "dBusUnitySessionServiceConnection"
388 target: DBusUnitySessionService
390 function closeAllApps() {
392 var app = ApplicationManager.get(0);
396 ApplicationManager.stopApplication(app.appId);
401 // Display a dialog to ask the user to confirm.
402 if (!stages.dialogShown) {
403 stages.dialogShown = true;
404 PopupUtils.open(logoutDialog);
408 onShutdownRequested: {
409 // Display a dialog to ask the user to confirm.
410 if (!stages.dialogShown) {
411 stages.dialogShown = true;
412 PopupUtils.open(shutdownDialog);
417 // Display a dialog to ask the user to confirm.
418 if (!stages.dialogShown) {
419 stages.dialogShown = true;
420 PopupUtils.open(rebootDialog);
431 id: applicationsDisplayLoader
434 source: shell.sideStageEnabled ? "Stages/TabletStage.qml" : "Stages/PhoneStage.qml"
437 target: applicationsDisplayLoader.item
438 property: "dragAreaWidth"
439 value: shell.edgeSize
442 target: applicationsDisplayLoader.item
443 property: "maximizedAppTopMargin"
444 // Not just using panel.panelHeight as that changes depending on the focused app.
445 value: panel.indicators.panelHeight
448 target: applicationsDisplayLoader.item
449 property: "interactive"
450 value: stages.roughlyFullyShown && !greeter.shown && !lockscreen.shown
457 anchors { fill: parent; topMargin: panel.panelHeight }
458 z: notifications.useModal || panel.indicators.shown ? overlay.z + 1 : overlay.z - 1
462 target: SurfaceManager
464 if (surface.type == MirSurfaceItem.InputMethod) {
465 inputMethod.surface = surface;
469 onSurfaceDestroyed: {
470 if (inputMethod.surface == surface) {
471 inputMethod.surface = null;
472 surface.parent = null;
474 if (!surface.parent) {
475 // there's no one displaying it. delete it right away
483 objectName: "lockscreen"
485 readonly property int backgroundTopMargin: -panel.panelHeight
487 hides: [launcher, panel.indicators]
490 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
491 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
495 height: parent.height - panel.panelHeight
496 background: shell.background
500 onEntered: LightDM.Greeter.respond(passphrase);
501 onCancel: greeter.show()
503 Component.onCompleted: {
504 if (LightDM.Users.count == 1) {
505 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
511 target: LightDM.Greeter
513 onShowGreeter: greeter.show()
516 if (LightDM.Users.count == 1) {
517 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
519 lockscreen.alphaNumeric = false
521 lockscreen.alphaNumeric = true
523 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
528 onAuthenticationComplete: {
529 if (LightDM.Greeter.promptless) {
532 if (LightDM.Greeter.authenticated) {
535 lockscreen.clear(true);
541 target: LightDM.Greeter
543 value: greeter.shown || lockscreen.shown
549 opacity: greeterWrapper.showProgress * 0.8
553 // Just a tiny wrapper to adjust greeter's x without messing with its own dragging
558 height: parent.height - panel.panelHeight
561 enabled: !launcher.dashSwipe
565 readonly property real showProgress: MathUtils.clamp((1 - x/width) + greeter.showProgress - 1, 0, 1)
569 objectName: "greeter"
572 hides: [launcher, panel.indicators]
575 defaultBackground: shell.background
578 height: parent.height
580 dragHandleWidth: shell.edgeSize
585 if (!LightDM.Greeter.promptless) {
588 // If there is only one user, we start authenticating with that one here.
589 // If there are more users, the Greeter will handle that
590 if (LightDM.Users.count == 1) {
591 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
593 greeter.forceActiveFocus();
597 onUnlocked: greeter.hide()
599 // Update launcher items for new user
600 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);
601 AccountsService.user = user;
602 LauncherModel.setUser(user);
605 onTease: launcher.tease()
608 target: ApplicationManager
609 property: "suspended"
610 value: greeter.shown && greeterWrapper.showProgress == 1
619 onDisplayPowerStateChange: {
620 // We ignore any display-off signals when the proximity sensor
621 // is active. This usually indicates something like a phone call.
622 if (status == Powerd.Off && reason != Powerd.Proximity) {
626 // No reason to chew demo CPU when user isn't watching
627 if (status == Powerd.Off) {
628 edgeDemo.paused = true;
629 } else if (status == Powerd.On) {
630 edgeDemo.paused = false;
635 function showHome() {
636 var animate = !greeter.shown && !stages.shown
638 dash.setCurrentScope("clickscope", animate, false)
650 anchors.fill: parent //because this draws indicator menus
653 available: edgeDemo.panelEnabled
654 contentEnabled: edgeDemo.panelContentEnabled
655 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
656 panelHeight: units.gu(3)
659 property bool topmostApplicationIsFullscreen:
660 ApplicationManager.focusedApplicationId &&
661 ApplicationManager.findApplication(ApplicationManager.focusedApplicationId).fullscreen
663 fullscreenMode: stages.roughlyFullyShown && topmostApplicationIsFullscreen
664 && !greeter.shown && !lockscreen.shown
670 readonly property bool dashSwipe: progress > 0
672 anchors.top: parent.top
673 anchors.bottom: parent.bottom
675 dragAreaWidth: shell.edgeSize
676 available: edgeDemo.launcherEnabled
679 if (edgeDemo.running)
685 if (!stages.locked) {
689 launcher.switchToNextState("visible");
697 onDashSwipeChanged: if (dashSwipe && stages.shown) dash.setCurrentScope("clickscope", false, true)
698 onLauncherApplicationSelected: {
699 if (!edgeDemo.running)
700 shell.activateApplication(appId)
704 panel.indicators.hide()
710 id: modalNotificationBackground
712 visible: notifications.useModal && !greeter.shown && (notifications.state == "narrow")
725 model: NotificationBackend.Model
730 height: parent.height - panel.panelHeight
735 when: overlay.width <= units.gu(60)
736 AnchorChanges { target: notifications; anchors.left: parent.left }
740 when: overlay.width > units.gu(60)
741 AnchorChanges { target: notifications; anchors.left: undefined }
742 PropertyChanges { target: notifications; width: units.gu(38) }
755 id: alphaDisclaimerLabel
756 anchors.centerIn: parent
757 visible: ApplicationManager.fake ? ApplicationManager.fake : false
759 text: "EARLY ALPHA\nNOT READY FOR USE"
762 font.weight: Font.Black
763 horizontalAlignment: Text.AlignHCenter
764 verticalAlignment: Text.AlignVCenter
765 fontSizeMode: Text.Fit
767 scale: Math.min(parent.width, parent.height) / width
772 z: alphaDisclaimerLabel.z + 10
776 indicators: panel.indicators
781 target: SessionBroadcast
782 onShowHome: showHome()
789 triggeredOnStart: false
792 stages.showPowerDialog();
797 id: shutdownFadeOutRectangle
803 NumberAnimation on opacity {
808 if (shutdownFadeOutRectangle.enabled && shutdownFadeOutRectangle.visible) {
809 DBusUnitySessionService.Shutdown();
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