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 ListModel searchHistory: SearchHistoryModel {}
67 property var applicationManager: ApplicationManagerWrapper {}
71 property: "applicationManager"
72 value: ApplicationManager
75 Component.onCompleted: {
76 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
78 applicationManager.sideStageEnabled = Qt.binding(function() { return sideStage.enabled })
80 // FIXME: if application focused before shell starts, shell draws on top of it only.
81 // We should detect already running applications on shell start and bring them to the front.
82 applicationManager.unfocusCurrentApplication();
85 readonly property bool applicationFocused: !!applicationManager.mainStageFocusedApplication
86 || !!applicationManager.sideStageFocusedApplication
87 // Used for autopilot testing.
88 readonly property string currentFocusedAppId: ApplicationManager.focusedApplicationId
90 readonly property bool fullscreenMode: {
91 if (greeter.shown || lockscreen.shown) {
93 } else if (mainStage.usingScreenshots) { // Window Manager animating so want to re-evaluate fullscreen mode
94 return mainStage.switchingFromFullscreenToFullscreen;
95 } else if (applicationManager.mainStageFocusedApplication) {
96 return applicationManager.mainStageFocusedApplication.fullscreen;
102 function activateApplication(desktopFile, argument) {
103 if (applicationManager) {
104 // For newly started applications, as it takes them time to draw their first frame
105 // we add a delay before we hide the animation screenshots to compensate.
106 var addDelay = !applicationManager.getApplicationFromDesktopFile(desktopFile);
109 application = applicationManager.activateApplication(desktopFile, argument);
110 if (application == null) {
113 if (application.stage == ApplicationInfo.MainStage || !sideStage.enabled) {
114 mainStage.activateApplication(desktopFile, addDelay);
116 sideStage.activateApplication(desktopFile, addDelay);
123 id: backgroundSettings
124 schema.id: "org.gnome.desktop.background"
126 property url gSettingsPicture: backgroundSettings.pictureUri != undefined && backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : shell.defaultBackground
127 onGSettingsPictureChanged: {
128 shell.background = gSettingsPicture
131 // This is a dummy image that is needed to determine if the picture url
132 // in backgroundSettings points to a valid picture file.
133 // We can't do this with the real background image because setting a
134 // new source in onStatusChanged triggers a binding loop detection
135 // inside Image, which causes it not to render even though a valid source
136 // would be set. We don't mind about this image staying black and just
137 // use it for verification to populate the source for the real
140 source: shell.background
146 if (status == Image.Error && source != shell.defaultBackground) {
147 shell.background = defaultBackground
156 Keys.onVolumeUpPressed: volumeControl.volumeUp()
157 Keys.onVolumeDownPressed: volumeControl.volumeDown()
161 objectName: "underlay"
164 // Whether the underlay is fully covered by opaque UI elements.
165 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
167 readonly property bool applicationRunning: ((mainStage.applications && mainStage.applications.count > 0)
168 || (sideStage.applications && sideStage.applications.count > 0))
170 // Whether the user should see the topmost application surface (if there's one at all).
171 readonly property bool applicationSurfaceShouldBeSeen: applicationRunning && !stages.fullyHidden
172 && !mainStage.usingScreenshots // but want sideStage animating over app surface
176 // NB! Application surfaces are stacked behing the shell one. So they can only be seen by the user
177 // through the translucent parts of the shell surface.
178 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
182 objectName: "backgroundImage"
185 source: shell.background
186 fillMode: Image.PreserveAspectCrop
192 opacity: dash.disappearingAnimationProgress
199 available: !greeter.shown && !lockscreen.shown
200 hides: [stages, launcher, panel.indicators]
201 shown: disappearingAnimationProgress !== 1.0
202 enabled: disappearingAnimationProgress === 0.0 && edgeDemo.dashEnabled
203 // FIXME: unfocus all applications when going back to the dash
206 shell.applicationManager.unfocusCurrentApplication()
212 topMargin: panel.panelHeight
215 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
216 opacity: 1.0 - disappearingAnimationProgress
217 property real disappearingAnimationProgress: {
219 return greeter.showProgress;
221 return stagesOuterContainer.showProgress;
225 // FIXME: only necessary because stagesOuterContainer.showProgress and
226 // greeterRevealer.animatedProgress are not animated
227 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
232 id: stagesOuterContainer
235 height: parent.height
237 Behavior on x {SmoothedAnimation{velocity: 600}}
239 property real showProgress:
240 MathLocal.clamp(1 - (x + stages.x) / shell.width, 0, 1)
248 property bool fullyShown: shown && x == 0 && parent.x == 0
249 property bool fullyHidden: !shown && x == width
250 available: !greeter.shown
251 hides: [panel.indicators]
254 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
255 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
258 height: parent.height
260 // close the stages when no focused application remains
262 target: shell.applicationManager
263 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
264 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
265 ignoreUnknownSignals: true
268 function closeIfNoApplications() {
269 if (!shell.applicationManager.mainStageFocusedApplication
270 && !shell.applicationManager.sideStageFocusedApplication
271 && shell.applicationManager.mainStageApplications.count == 0
272 && shell.applicationManager.sideStageApplications.count == 0) {
277 // show the stages when an application gets the focus
279 target: shell.applicationManager
280 onMainStageFocusedApplicationChanged: {
281 if (shell.applicationManager.mainStageFocusedApplication) {
286 onSideStageFocusedApplicationChanged: {
287 if (shell.applicationManager.sideStageFocusedApplication) {
292 ignoreUnknownSignals: true
299 fullyShown: stages.fullyShown
300 fullyHidden: stages.fullyHidden
301 shouldUseScreenshots: !fullyShown
302 rightEdgeEnabled: !sideStage.enabled
304 applicationManager: shell.applicationManager
305 rightEdgeDraggingAreaWidth: shell.edgeSize
306 normalApplicationY: shell.panelHeight
315 // FIXME: workaround the fact that focusing a main stage application
316 // raises its surface on top of all other surfaces including the ones
317 // that belong to side stage applications.
318 onFocusedApplicationChanged: {
319 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
320 shell.applicationManager.focusApplication(sideStage.focusedApplication);
328 applicationManager: shell.applicationManager
329 rightEdgeDraggingAreaWidth: shell.edgeSize
330 normalApplicationY: shell.panelHeight
333 if (!shown && mainStage.applications.count == 0) {
337 // FIXME: when hiding the side stage, refocus the main stage
338 // application so that it goes in front of the side stage
339 // application and hides it
340 onFullyShownChanged: {
341 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
342 shell.applicationManager.focusApplication(mainStage.focusedApplication);
346 enabled: shell.width >= units.gu(60)
348 fullyShown: stages.fullyShown && shown
349 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
350 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
352 available: !greeter.shown && !lockscreen.shown && enabled
353 hides: [launcher, panel.indicators]
355 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
356 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
359 height: stages.height
360 handleExpanded: sideStageRevealer.pressed
364 id: sideStageRevealer
366 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
367 && sideStage.available
368 direction: Qt.RightToLeft
369 openedValue: parent.width - sideStage.width
370 hintDisplacement: units.gu(3)
371 /* The size of the sidestage handle needs to be bigger than the
372 typical size used for edge detection otherwise it is really
375 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
376 closedValue: parent.width + sideStage.handleSizeCollapsed
378 x: parent.width - width
379 width: sideStage.width + handleSize * 0.7
380 height: sideStage.height
381 orientation: Qt.Horizontal
387 anchors.top: parent.top
388 anchors.bottom: parent.bottom
389 anchors.right: parent.left
391 width: shell.edgeSize
392 direction: Direction.Leftwards
393 enabled: greeter.showProgress == 0 && edgeDemo.dashEnabled
394 property bool haveApps: mainStage.applications.count > 0 || sideStage.applications.count > 0
396 maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
397 // Make autocompletion impossible when !haveApps
398 edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
405 objectName: "lockscreen"
407 readonly property int backgroundTopMargin: -panel.panelHeight
409 hides: [launcher, panel.indicators, hud]
412 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
413 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
415 x: required ? 0 : - width
417 height: parent.height - panel.panelHeight
418 background: shell.background
420 onUnlocked: lockscreen.hide()
421 onCancel: greeter.show()
423 Component.onCompleted: {
424 if (LightDM.Users.count == 1) {
425 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
432 target: LightDM.Greeter
435 if (LightDM.Users.count == 1) {
436 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
438 lockscreen.alphaNumeric = false
440 lockscreen.alphaNumeric = true
442 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
450 objectName: "greeter"
453 hides: [launcher, panel.indicators, hud]
456 defaultBackground: shell.background
460 height: parent.height - panel.panelHeight
462 dragHandleWidth: shell.edgeSize
464 property var previousMainApp: null
465 property var previousSideApp: null
467 function removeApplicationFocus() {
468 greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
469 greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
470 applicationManager.unfocusCurrentApplication();
473 function restoreApplicationFocus() {
474 if (greeter.previousMainApp) {
475 applicationManager.focusApplication(greeter.previousMainApp);
476 greeter.previousMainApp = null;
478 if (greeter.previousSideApp) {
479 applicationManager.focusApplication(greeter.previousSideApp);
480 greeter.previousSideApp = null;
487 // If there is only one user, we start authenticating with that one here.
488 // If there are more users, the Greeter will handle that
489 if (LightDM.Users.count == 1) {
490 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
493 greeter.forceActiveFocus();
494 removeApplicationFocus();
496 restoreApplicationFocus();
500 onUnlocked: greeter.hide()
502 // Update launcher items for new user
503 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);
504 AccountsService.user = user;
505 LauncherModel.setUser(user);
508 onLeftTeaserPressedChanged: {
509 if (leftTeaserPressed) {
515 target: applicationManager
516 ignoreUnknownSignals: true
517 // If any app is focused when greeter is open, it's due to a user action
518 // like a snap decision (say, an incoming call).
519 // TODO: these should be protected to only unlock for certain applications / certain usecases
520 // potentially only in connection with a notification.
521 onMainStageFocusedApplicationChanged: {
522 if (greeter.shown && applicationManager.mainStageFocusedApplication) {
523 greeter.previousMainApp = null // make way for new focused app
524 greeter.previousSideApp = null
528 onSideStageFocusedApplicationChanged: {
529 if (greeter.shown && applicationManager.sideStageFocusedApplication) {
530 greeter.previousMainApp = null // make way for new focused app
531 greeter.previousSideApp = null
540 blockInput: !applicationFocused || greeter.shown || lockscreen.shown || launcher.shown
541 || panel.indicators.shown || hud.shown
548 onDisplayPowerStateChange: {
549 // We ignore any display-off signals when the proximity sensor
550 // is active. This usually indicates something like a phone call.
551 if (status == Powerd.Off && (flags & Powerd.UseProximity) == 0) {
555 // No reason to chew demo CPU when user isn't watching
556 if (status == Powerd.Off) {
557 edgeDemo.paused = true;
558 } else if (status == Powerd.On) {
559 edgeDemo.paused = false;
564 function showHome() {
565 var animate = !greeter.shown && !stages.shown
567 dash.setCurrentScope("home.scope", animate, false)
578 anchors.fill: parent //because this draws indicator menus
579 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
582 available: edgeDemo.panelEnabled
583 contentEnabled: edgeDemo.panelContentEnabled
585 fullscreenMode: shell.fullscreenMode
586 searchVisible: !greeter.shown && !lockscreen.shown && dash.shown
594 height: (panel.fullscreenMode) ? shell.edgeSize : panel.panelHeight
602 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
603 height: parent.height
605 available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown && edgeDemo.dashEnabled
607 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
608 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
611 target: shell.applicationManager
612 onMainStageFocusedApplicationChanged: hud.hide()
613 onSideStageFocusedApplicationChanged: hud.hide()
622 anchors.left: hud.left
623 height: parent.height
624 target: hud.revealerTarget
627 direction: Qt.RightToLeft
628 orientation: Qt.Vertical
629 handleSize: hud.handleHeight
630 onCloseClicked: target.hide()
637 enabled: hud.available
638 applicationIsOnForeground: applicationFocused
642 blockInput: launcher.shown
645 bottom: parent.bottom
648 width: launcher.width
654 readonly property bool dashSwipe: progress > 0
656 anchors.top: parent.top
657 anchors.bottom: parent.bottom
659 dragAreaWidth: shell.edgeSize
660 available: (!greeter.shown || greeter.narrowMode) && edgeDemo.launcherEnabled
662 onDashItemSelected: showHome()
669 onDashSwipeChanged: if (dashSwipe && stages.shown) dash.setCurrentScope("applications.scope", false, true)
670 onLauncherApplicationSelected:{
672 shell.activateApplication(appId)
676 panel.indicators.hide()
686 model: NotificationBackend.Model
690 bottom: parent.bottom
691 leftMargin: units.gu(1)
692 rightMargin: units.gu(1)
693 topMargin: panel.panelHeight + units.gu(1)
698 when: overlay.width <= units.gu(60)
699 AnchorChanges { target: notifications; anchors.left: parent.left }
703 when: overlay.width > units.gu(60)
704 AnchorChanges { target: notifications; anchors.left: undefined }
705 PropertyChanges { target: notifications; width: units.gu(38) }
710 anchors { left: parent.left; right: parent.right }
711 height: parent.contentHeight
712 blockInput: height > 0
718 onFocusChanged: if (!focus) forceActiveFocus();
723 bottom: parent.bottom
726 width: shell.edgeSize
733 bottom: parent.bottom
736 width: shell.edgeSize
747 anchors.topMargin: panel.panelHeight
748 anchors.fill: parent // as needs to know the geometry of the shell
751 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
753 anchors.bottom: parent.bottom
754 anchors.left: parent.left
755 anchors.right: parent.right
756 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
758 enabled: shell.applicationManager && shell.applicationManager.keyboardVisible
762 anchors.centerIn: parent
763 visible: applicationManager.fake
764 text: "EARLY ALPHA\nNOT READY FOR USE"
767 font.weight: Font.Black
768 horizontalAlignment: Text.AlignHCenter
769 verticalAlignment: Text.AlignVCenter
770 fontSizeMode: Text.Fit
772 scale: Math.min(parent.width, parent.height) / width
780 indicators: panel.indicators
785 target: SessionBroadcast
786 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