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.Gestures 0.1
23import Unity.Launcher 0.1
24import LightDM 0.1 as LightDM
26import SessionBroadcast 0.1
33import "Components/Math.js" as MathLocal
37import Unity.Notifications 1.0 as NotificationBackend
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: 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
53 property bool stageScreenshotsReady: {
54 if (sideStage.shown) {
55 if (mainStage.applications.count > 0) {
56 return mainStage.usingScreenshots && sideStage.usingScreenshots;
58 return sideStage.usingScreenshots;
61 return mainStage.usingScreenshots;
65 property var applicationManager: ApplicationManagerWrapper {}
69 property: "applicationManager"
70 value: ApplicationManager
73 Component.onCompleted: {
74 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
76 applicationManager.sideStageEnabled = Qt.binding(function() { return sideStage.enabled })
78 // FIXME: if application focused before shell starts, shell draws on top of it only.
79 // We should detect already running applications on shell start and bring them to the front.
80 applicationManager.unfocusCurrentApplication();
83 readonly property bool applicationFocused: !!applicationManager.mainStageFocusedApplication
84 || !!applicationManager.sideStageFocusedApplication
85 // Used for autopilot testing.
86 readonly property string currentFocusedAppId: ApplicationManager.focusedApplicationId
88 readonly property bool fullscreenMode: {
89 if (greeter.shown || lockscreen.shown) {
91 } else if (mainStage.usingScreenshots) { // Window Manager animating so want to re-evaluate fullscreen mode
92 return mainStage.switchingFromFullscreenToFullscreen;
93 } else if (applicationManager.mainStageFocusedApplication) {
94 return applicationManager.mainStageFocusedApplication.fullscreen;
100 function activateApplication(desktopFile, argument) {
101 if (applicationManager) {
102 // For newly started applications, as it takes them time to draw their first frame
103 // we add a delay before we hide the animation screenshots to compensate.
104 var addDelay = !applicationManager.getApplicationFromDesktopFile(desktopFile);
107 application = applicationManager.activateApplication(desktopFile, argument);
108 if (application == null) {
111 if (application.stage == ApplicationInfo.MainStage || !sideStage.enabled) {
112 mainStage.activateApplication(desktopFile, addDelay);
114 sideStage.activateApplication(desktopFile, addDelay);
121 id: backgroundSettings
122 schema.id: "org.gnome.desktop.background"
124 property url gSettingsPicture: backgroundSettings.pictureUri != undefined && backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : shell.defaultBackground
125 onGSettingsPictureChanged: {
126 shell.background = gSettingsPicture
129 // This is a dummy image that is needed to determine if the picture url
130 // in backgroundSettings points to a valid picture file.
131 // We can't do this with the real background image because setting a
132 // new source in onStatusChanged triggers a binding loop detection
133 // inside Image, which causes it not to render even though a valid source
134 // would be set. We don't mind about this image staying black and just
135 // use it for verification to populate the source for the real
138 source: shell.background
144 if (status == Image.Error && source != shell.defaultBackground) {
145 shell.background = defaultBackground
154 Keys.onVolumeUpPressed: volumeControl.volumeUp()
155 Keys.onVolumeDownPressed: volumeControl.volumeDown()
159 objectName: "underlay"
162 // Whether the underlay is fully covered by opaque UI elements.
163 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
165 readonly property bool applicationRunning: ((mainStage.applications && mainStage.applications.count > 0)
166 || (sideStage.applications && sideStage.applications.count > 0))
168 // Whether the user should see the topmost application surface (if there's one at all).
169 readonly property bool applicationSurfaceShouldBeSeen: applicationRunning && !stages.fullyHidden
170 && !mainStage.usingScreenshots // but want sideStage animating over app surface
174 // NB! Application surfaces are stacked behing the shell one. So they can only be seen by the user
175 // through the translucent parts of the shell surface.
176 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
180 objectName: "backgroundImage"
183 source: shell.background
184 fillMode: Image.PreserveAspectCrop
190 opacity: dash.disappearingAnimationProgress
197 available: !greeter.shown && !lockscreen.shown
198 hides: [stages, launcher, panel.indicators]
199 shown: disappearingAnimationProgress !== 1.0
200 enabled: disappearingAnimationProgress === 0.0 && edgeDemo.dashEnabled
201 // FIXME: unfocus all applications when going back to the dash
204 shell.applicationManager.unfocusCurrentApplication()
210 topMargin: panel.panelHeight
213 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
214 opacity: 1.0 - disappearingAnimationProgress
215 property real disappearingAnimationProgress: {
217 return greeter.showProgress;
219 return stagesOuterContainer.showProgress;
223 // FIXME: only necessary because stagesOuterContainer.showProgress and
224 // greeterRevealer.animatedProgress are not animated
225 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
230 id: stagesOuterContainer
233 height: parent.height
235 Behavior on x {SmoothedAnimation{velocity: 600}}
237 property real showProgress:
238 MathLocal.clamp(1 - (x + stages.x) / shell.width, 0, 1)
246 property bool fullyShown: shown && x == 0 && parent.x == 0
247 property bool fullyHidden: !shown && x == width
248 available: !greeter.shown
249 hides: [panel.indicators]
252 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
253 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
256 height: parent.height
258 // close the stages when no focused application remains
260 target: shell.applicationManager
261 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
262 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
263 ignoreUnknownSignals: true
266 function closeIfNoApplications() {
267 if (!shell.applicationManager.mainStageFocusedApplication
268 && !shell.applicationManager.sideStageFocusedApplication
269 && shell.applicationManager.mainStageApplications.count == 0
270 && shell.applicationManager.sideStageApplications.count == 0) {
275 // show the stages when an application gets the focus
277 target: shell.applicationManager
278 onMainStageFocusedApplicationChanged: {
279 if (shell.applicationManager.mainStageFocusedApplication) {
284 onSideStageFocusedApplicationChanged: {
285 if (shell.applicationManager.sideStageFocusedApplication) {
290 ignoreUnknownSignals: true
297 fullyShown: stages.fullyShown
298 fullyHidden: stages.fullyHidden
299 shouldUseScreenshots: !fullyShown
300 rightEdgeEnabled: !sideStage.enabled
302 applicationManager: shell.applicationManager
303 rightEdgeDraggingAreaWidth: shell.edgeSize
304 normalApplicationY: shell.panelHeight
313 // FIXME: workaround the fact that focusing a main stage application
314 // raises its surface on top of all other surfaces including the ones
315 // that belong to side stage applications.
316 onFocusedApplicationChanged: {
317 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
318 shell.applicationManager.focusApplication(sideStage.focusedApplication);
326 applicationManager: shell.applicationManager
327 rightEdgeDraggingAreaWidth: shell.edgeSize
328 normalApplicationY: shell.panelHeight
331 if (!shown && mainStage.applications.count == 0) {
335 // FIXME: when hiding the side stage, refocus the main stage
336 // application so that it goes in front of the side stage
337 // application and hides it
338 onFullyShownChanged: {
339 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
340 shell.applicationManager.focusApplication(mainStage.focusedApplication);
344 enabled: shell.width >= units.gu(60)
346 fullyShown: stages.fullyShown && shown
347 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
348 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
350 available: !greeter.shown && !lockscreen.shown && enabled
351 hides: [launcher, panel.indicators]
353 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
354 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
357 height: stages.height
358 handleExpanded: sideStageRevealer.pressed
362 id: sideStageRevealer
364 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
365 && sideStage.available
366 direction: Qt.RightToLeft
367 openedValue: parent.width - sideStage.width
368 hintDisplacement: units.gu(3)
369 /* The size of the sidestage handle needs to be bigger than the
370 typical size used for edge detection otherwise it is really
373 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
374 closedValue: parent.width + sideStage.handleSizeCollapsed
376 x: parent.width - width
377 width: sideStage.width + handleSize * 0.7
378 height: sideStage.height
379 orientation: Qt.Horizontal
385 anchors.top: parent.top
386 anchors.bottom: parent.bottom
387 anchors.right: parent.left
389 width: shell.edgeSize
390 direction: Direction.Leftwards
391 enabled: greeter.showProgress == 0 && edgeDemo.dashEnabled
392 property bool haveApps: mainStage.applications.count > 0 || sideStage.applications.count > 0
394 maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
395 // Make autocompletion impossible when !haveApps
396 edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
403 hides: [launcher, panel.indicators, hud]
406 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
407 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
409 x: required ? 0 : - width
411 height: parent.height - panel.panelHeight
412 background: shell.background
414 onUnlocked: lockscreen.hide()
415 onCancel: greeter.show()
417 Component.onCompleted: {
418 if (LightDM.Users.count == 1) {
419 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
426 target: LightDM.Greeter
429 if (LightDM.Users.count == 1) {
430 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
432 lockscreen.alphaNumeric = false
434 lockscreen.alphaNumeric = true
436 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
444 objectName: "greeter"
447 hides: [launcher, panel.indicators, hud]
450 defaultBackground: shell.background
454 height: parent.height - panel.panelHeight
456 dragHandleWidth: shell.edgeSize
458 property var previousMainApp: null
459 property var previousSideApp: null
461 function removeApplicationFocus() {
462 greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
463 greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
464 applicationManager.unfocusCurrentApplication();
467 function restoreApplicationFocus() {
468 if (greeter.previousMainApp) {
469 applicationManager.focusApplication(greeter.previousMainApp);
470 greeter.previousMainApp = null;
472 if (greeter.previousSideApp) {
473 applicationManager.focusApplication(greeter.previousSideApp);
474 greeter.previousSideApp = null;
481 // If there is only one user, we start authenticating with that one here.
482 // If there are more users, the Greeter will handle that
483 if (LightDM.Users.count == 1) {
484 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
487 greeter.forceActiveFocus();
488 removeApplicationFocus();
490 restoreApplicationFocus();
494 onUnlocked: greeter.hide()
496 // Update launcher items for new user
497 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);
498 AccountsService.user = user;
499 LauncherModel.setUser(user);
502 onLeftTeaserPressedChanged: {
503 if (leftTeaserPressed) {
509 target: applicationManager
510 ignoreUnknownSignals: true
511 // If any app is focused when greeter is open, it's due to a user action
512 // like a snap decision (say, an incoming call).
513 // TODO: these should be protected to only unlock for certain applications / certain usecases
514 // potentially only in connection with a notification.
515 onMainStageFocusedApplicationChanged: {
516 if (greeter.shown && applicationManager.mainStageFocusedApplication) {
517 greeter.previousMainApp = null // make way for new focused app
518 greeter.previousSideApp = null
522 onSideStageFocusedApplicationChanged: {
523 if (greeter.shown && applicationManager.sideStageFocusedApplication) {
524 greeter.previousMainApp = null // make way for new focused app
525 greeter.previousSideApp = null
534 blockInput: !applicationFocused || greeter.shown || lockscreen.shown || launcher.shown
535 || panel.indicators.shown || hud.shown
542 onDisplayPowerStateChange: {
543 // We ignore any display-off signals when the proximity sensor
544 // is active. This usually indicates something like a phone call.
545 if (status == Powerd.Off && (flags & Powerd.UseProximity) == 0) {
549 // No reason to chew demo CPU when user isn't watching
550 if (status == Powerd.Off) {
551 edgeDemo.paused = true;
552 } else if (status == Powerd.On) {
553 edgeDemo.paused = false;
558 function showHome() {
559 var animate = !greeter.shown && !stages.shown
561 dash.setCurrentScope("home.scope", animate, false)
572 anchors.fill: parent //because this draws indicator menus
573 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
576 available: edgeDemo.panelEnabled
577 contentEnabled: edgeDemo.panelContentEnabled
579 fullscreenMode: shell.fullscreenMode
580 searchVisible: !greeter.shown && !lockscreen.shown && dash.shown
588 height: (panel.fullscreenMode) ? shell.edgeSize : panel.panelHeight
596 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
597 height: parent.height
599 available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown && edgeDemo.dashEnabled
601 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
602 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
605 target: shell.applicationManager
606 onMainStageFocusedApplicationChanged: hud.hide()
607 onSideStageFocusedApplicationChanged: hud.hide()
616 anchors.left: hud.left
617 height: parent.height
618 target: hud.revealerTarget
621 direction: Qt.RightToLeft
622 orientation: Qt.Vertical
623 handleSize: hud.handleHeight
624 onCloseClicked: target.hide()
631 enabled: hud.available
632 applicationIsOnForeground: applicationFocused
636 blockInput: launcher.shown
639 bottom: parent.bottom
642 width: launcher.width
648 anchors.top: parent.top
649 anchors.bottom: parent.bottom
651 dragAreaWidth: shell.edgeSize
652 available: (!greeter.shown || greeter.narrowMode) && edgeDemo.launcherEnabled
653 onDashItemSelected: showHome()
656 dash.setCurrentScope("applications.scope", true /* animate */, true /* reset */)
661 onLauncherApplicationSelected:{
663 shell.activateApplication(appId)
667 panel.indicators.hide()
677 model: NotificationBackend.Model
681 bottom: parent.bottom
682 leftMargin: units.gu(1)
683 rightMargin: units.gu(1)
684 topMargin: panel.panelHeight + units.gu(1)
689 when: overlay.width <= units.gu(60)
690 AnchorChanges { target: notifications; anchors.left: parent.left }
694 when: overlay.width > units.gu(60)
695 AnchorChanges { target: notifications; anchors.left: undefined }
696 PropertyChanges { target: notifications; width: units.gu(38) }
701 anchors { left: parent.left; right: parent.right }
702 height: parent.contentHeight
703 blockInput: height > 0
709 onFocusChanged: if (!focus) forceActiveFocus();
714 bottom: parent.bottom
717 width: shell.edgeSize
724 bottom: parent.bottom
727 width: shell.edgeSize
738 anchors.topMargin: panel.panelHeight
739 anchors.fill: parent // as needs to know the geometry of the shell
742 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
744 anchors.bottom: parent.bottom
745 anchors.left: parent.left
746 anchors.right: parent.right
747 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
749 enabled: shell.applicationManager && shell.applicationManager.keyboardVisible
753 anchors.centerIn: parent
754 visible: applicationManager.fake
755 text: "EARLY ALPHA\nNOT READY FOR USE"
758 font.weight: Font.Black
759 horizontalAlignment: Text.AlignHCenter
760 verticalAlignment: Text.AlignVCenter
761 fontSizeMode: Text.Fit
763 scale: Math.min(parent.width, parent.height) / width
771 indicators: panel.indicators
776 target: SessionBroadcast
777 onShowHome: showHome()
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