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
25import LightDM 0.1 as LightDM
27import SessionBroadcast 0.1
34import Unity.Notifications 1.0 as NotificationBackend
35import Unity.Session 0.1
40 // this is only here to select the width / height of the window if not running fullscreen
41 property bool tablet: false
42 width: tablet ? units.gu(160) : applicationArguments.hasGeometry() ? applicationArguments.width() : units.gu(40)
43 height: tablet ? units.gu(100) : applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(71)
45 property real edgeSize: units.gu(2)
46 property url defaultBackground: Qt.resolvedUrl(shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg")
47 property url background
48 readonly property real panelHeight: panel.panelHeight
50 property bool dashShown: dash.shown
52 property bool sideStageEnabled: shell.width >= units.gu(100)
53 readonly property string focusedApplicationId: ApplicationManager.focusedApplicationId
55 function activateApplication(appId) {
56 if (ApplicationManager.findApplication(appId)) {
57 ApplicationManager.requestFocusApplication(appId);
59 if (stages.locked && ApplicationManager.focusedApplicationId == appId) {
60 applicationsDisplayLoader.item.select(appId);
63 var execFlags = shell.sideStageEnabled ? ApplicationManager.NoFlag : ApplicationManager.ForceMainStage;
64 ApplicationManager.startApplication(appId, execFlags);
71 property: "applicationManager"
72 value: ApplicationManager
75 Component.onCompleted: {
76 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
80 id: backgroundSettings
81 schema.id: "org.gnome.desktop.background"
83 property url gSettingsPicture: backgroundSettings.pictureUri != undefined && backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : shell.defaultBackground
84 onGSettingsPictureChanged: {
85 shell.background = gSettingsPicture
92 Keys.onVolumeUpPressed: volumeControl.volumeUp()
93 Keys.onVolumeDownPressed: volumeControl.volumeDown()
98 anchors.rightMargin: stages.overlayWidth
99 clip: stages.overlayMode && !stages.painting
103 blockInput: parent.clip
108 objectName: "underlay"
110 anchors.rightMargin: -parent.anchors.rightMargin
112 // Whether the underlay is fully covered by opaque UI elements.
113 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicators.width
115 // Whether the user should see the topmost application surface (if there's one at all).
116 readonly property bool applicationSurfaceShouldBeSeen: stages.shown && !stages.painting && !stages.overlayMode
118 // NB! Application surfaces are stacked behind the shell one. So they can only be seen by the user
119 // through the translucent parts of the shell surface.
120 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
125 opacity: dash.disappearingAnimationProgress
132 available: !greeter.shown && !lockscreen.shown
133 hides: [stages, launcher, panel.indicators]
134 shown: disappearingAnimationProgress !== 1.0 && greeterWrapper.showProgress !== 1.0
135 enabled: disappearingAnimationProgress === 0.0 && greeterWrapper.showProgress === 0.0 && edgeDemo.dashEnabled
137 overviewHandleHeight: shell.edgeSize
141 topMargin: panel.panelHeight
144 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
145 opacity: 1.0 - disappearingAnimationProgress
146 property real disappearingAnimationProgress: {
147 if (stages.overlayMode) {
150 return stages.showProgress
154 // FIXME: only necessary because stages.showProgress is not animated
155 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
162 direction: Direction.Leftwards
164 anchors { top: parent.top; right: parent.right; bottom: parent.bottom }
165 width: shell.edgeSize
167 property real progress: stages.width
170 if (status == DirectionalDragArea.Recognized) {
171 if (ApplicationManager.count == 0) {
172 progress = Math.max(stages.width - stagesDragHandle.width + touchX, stages.width * .3)
174 progress = stages.width - stagesDragHandle.width + touchX
181 if (ApplicationManager.count > 0 && progress < stages.width - units.gu(10)) {
184 stagesDragHandle.progress = stages.width;
193 height: parent.height
197 if (overlayMode || locked) {
200 return launcher.progress
202 return stagesDragHandle.progress
206 Behavior on x { SmoothedAnimation { velocity: 600; duration: UbuntuAnimation.FastDuration } }
208 property bool shown: false
210 property real showProgress: overlayMode ? 0 : MathUtils.clamp(1 - x / shell.width, 0, 1)
212 property bool fullyShown: x == 0
213 property bool fullyHidden: x == width
215 property bool painting: applicationsDisplayLoader.item ? applicationsDisplayLoader.item.painting : false
216 property bool fullscreen: applicationsDisplayLoader.item ? applicationsDisplayLoader.item.fullscreen : false
217 property bool overlayMode: applicationsDisplayLoader.item ? applicationsDisplayLoader.item.overlayMode : false
218 property int overlayWidth: applicationsDisplayLoader.item ? applicationsDisplayLoader.item.overlayWidth : false
219 property bool locked: applicationsDisplayLoader.item ? applicationsDisplayLoader.item.locked : false
221 function show(focusApp) {
223 panel.indicators.hide();
226 if (!ApplicationManager.focusedApplicationId && ApplicationManager.count > 0 && focusApp) {
227 ApplicationManager.focusApplication(ApplicationManager.get(0).appId);
233 if (ApplicationManager.focusedApplicationId) {
234 ApplicationManager.unfocusCurrentApplication();
239 target: ApplicationManager
245 onFocusedApplicationIdChanged: {
246 if (ApplicationManager.focusedApplicationId.length > 0) {
249 if (!stages.overlayMode) {
255 onApplicationAdded: {
259 onApplicationRemoved: {
260 if (ApplicationManager.focusedApplicationId.length == 0) {
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/StageWithSideStage.qml" : "Stages/PhoneStage.qml"
437 target: applicationsDisplayLoader.item
439 value: !stages.fullyShown
442 target: applicationsDisplayLoader.item
447 target: applicationsDisplayLoader.item
448 property: "dragAreaWidth"
449 value: shell.edgeSize
456 objectName: "lockscreen"
458 readonly property int backgroundTopMargin: -panel.panelHeight
460 hides: [launcher, panel.indicators]
463 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
464 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
466 x: required ? 0 : - width
468 height: parent.height - panel.panelHeight
469 background: shell.background
473 onEntered: LightDM.Greeter.respond(passphrase);
474 onCancel: greeter.show()
476 Component.onCompleted: {
477 if (LightDM.Users.count == 1) {
478 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
484 target: LightDM.Greeter
486 onShowGreeter: greeter.show()
489 if (LightDM.Users.count == 1) {
490 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
492 lockscreen.alphaNumeric = false
494 lockscreen.alphaNumeric = true
496 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
501 onAuthenticationComplete: {
502 if (LightDM.Greeter.promptless) {
505 if (LightDM.Greeter.authenticated) {
508 lockscreen.clear(true);
514 target: LightDM.Greeter
516 value: greeter.shown || lockscreen.shown
522 opacity: greeterWrapper.showProgress * 0.8
526 // Just a tiny wrapper to adjust greeter's x without messing with its own dragging
531 height: parent.height - panel.panelHeight
534 enabled: !launcher.dashSwipe
538 readonly property real showProgress: MathUtils.clamp((1 - x/width) + greeter.showProgress - 1, 0, 1)
542 objectName: "greeter"
545 hides: [launcher, panel.indicators]
548 defaultBackground: shell.background
551 height: parent.height
553 dragHandleWidth: shell.edgeSize
558 if (!LightDM.Greeter.promptless) {
561 // If there is only one user, we start authenticating with that one here.
562 // If there are more users, the Greeter will handle that
563 if (LightDM.Users.count == 1) {
564 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
566 greeter.forceActiveFocus();
570 onUnlocked: greeter.hide()
572 // Update launcher items for new user
573 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);
574 AccountsService.user = user;
575 LauncherModel.setUser(user);
578 onTease: launcher.tease()
581 target: ApplicationManager
582 property: "suspended"
583 value: greeter.shown && greeterWrapper.showProgress == 1
590 blockInput: ApplicationManager.focusedApplicationId.length === 0 || greeter.shown || lockscreen.shown || launcher.shown
591 || panel.indicators.shown
598 onDisplayPowerStateChange: {
599 // We ignore any display-off signals when the proximity sensor
600 // is active. This usually indicates something like a phone call.
601 if (status == Powerd.Off && reason != Powerd.Proximity) {
605 // No reason to chew demo CPU when user isn't watching
606 if (status == Powerd.Off) {
607 edgeDemo.paused = true;
608 } else if (status == Powerd.On) {
609 edgeDemo.paused = false;
614 function showHome() {
615 var animate = !greeter.shown && !stages.shown
617 dash.setCurrentScope("clickscope", animate, false)
628 anchors.fill: parent //because this draws indicator menus
631 available: edgeDemo.panelEnabled
632 contentEnabled: edgeDemo.panelContentEnabled
633 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
634 panelHeight: units.gu(3)
636 property string focusedAppId: ApplicationManager.focusedApplicationId
637 property var focusedApplication: ApplicationManager.findApplication(focusedAppId)
638 fullscreenMode: focusedApplication && stages.fullscreen && !greeter.shown && !lockscreen.shown
646 height: (panel.fullscreenMode) ? shell.edgeSize : panel.panelHeight
652 blockInput: launcher.shown
655 bottom: parent.bottom
658 width: launcher.width
664 readonly property bool dashSwipe: progress > 0
666 anchors.top: parent.top
667 anchors.bottom: parent.bottom
669 dragAreaWidth: shell.edgeSize
670 available: edgeDemo.launcherEnabled
673 if (edgeDemo.running)
679 if (stages.shown && !stages.overlayMode && !stages.locked) {
683 launcher.switchToNextState("visible");
691 onDashSwipeChanged: if (dashSwipe && stages.shown) dash.setCurrentScope("clickscope", false, true)
692 onLauncherApplicationSelected: {
693 if (!edgeDemo.running)
694 shell.activateApplication(appId)
698 panel.indicators.hide()
704 id: modalNotificationBackground
706 visible: notifications.useModal && !greeter.shown && (notifications.state == "narrow")
717 blockInput: modalNotificationBackground.visible
724 model: NotificationBackend.Model
729 height: parent.height - panel.panelHeight
734 when: overlay.width <= units.gu(60)
735 AnchorChanges { target: notifications; anchors.left: parent.left }
739 when: overlay.width > units.gu(60)
740 AnchorChanges { target: notifications; anchors.left: undefined }
741 PropertyChanges { target: notifications; width: units.gu(38) }
746 anchors { left: parent.left; right: parent.right }
747 height: parent.contentHeight
748 blockInput: height > 0
754 onFocusChanged: if (!focus) forceActiveFocus();
759 bottom: parent.bottom
762 width: shell.edgeSize
769 bottom: parent.bottom
772 width: shell.edgeSize
783 anchors.topMargin: panel.panelHeight
784 anchors.fill: parent // as needs to know the geometry of the shell
787 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
789 anchors.bottom: parent.bottom
790 anchors.left: parent.left
791 anchors.right: parent.right
792 height: ApplicationManager.keyboardVisible ? ApplicationManager.keyboardHeight : 0
794 enabled: ApplicationManager.keyboardVisible
798 anchors.centerIn: parent
799 visible: ApplicationManager.fake ? ApplicationManager.fake : false
800 text: "EARLY ALPHA\nNOT READY FOR USE"
803 font.weight: Font.Black
804 horizontalAlignment: Text.AlignHCenter
805 verticalAlignment: Text.AlignVCenter
806 fontSizeMode: Text.Fit
808 scale: Math.min(parent.width, parent.height) / width
816 indicators: panel.indicators
821 target: SessionBroadcast
822 onShowHome: showHome()
826 if (event.key == Qt.Key_PowerOff || event.key == Qt.Key_PowerDown) {
827 if (!powerKeyTimer.running) {
828 powerKeyTimer.start();
830 event.accepted = true;
835 if (event.key == Qt.Key_PowerOff || event.key == Qt.Key_PowerDown) {
836 powerKeyTimer.stop();
837 event.accepted = true;
845 triggeredOnStart: false
848 stages.showPowerDialog();
853 id: shutdownFadeOutRectangle
859 NumberAnimation on opacity {
864 if (shutdownFadeOutRectangle.enabled && shutdownFadeOutRectangle.visible) {
865 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