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
36import Unity.Notifications 1.0 as NotificationBackend
41 // this is only here to select the width / height of the window if not running fullscreen
42 property bool tablet: false
43 width: tablet ? units.gu(160) : applicationArguments.hasGeometry() ? applicationArguments.width() : units.gu(40)
44 height: tablet ? units.gu(100) : applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(71)
46 property real edgeSize: units.gu(2)
47 property url defaultBackground: shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg"
48 property url background
49 readonly property real panelHeight: panel.panelHeight
51 property bool dashShown: dash.shown
52 property bool stageScreenshotsReady: {
53 if (sideStage.shown) {
54 if (mainStage.applications.count > 0) {
55 return mainStage.usingScreenshots && sideStage.usingScreenshots;
57 return sideStage.usingScreenshots;
60 return mainStage.usingScreenshots;
64 property ListModel searchHistory: SearchHistoryModel {}
66 property var applicationManager: ApplicationManagerWrapper {}
70 property: "applicationManager"
71 value: ApplicationManager
74 Component.onCompleted: {
75 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
77 applicationManager.sideStageEnabled = Qt.binding(function() { return sideStage.enabled })
79 // FIXME: if application focused before shell starts, shell draws on top of it only.
80 // We should detect already running applications on shell start and bring them to the front.
81 applicationManager.unfocusCurrentApplication();
84 readonly property bool applicationFocused: !!applicationManager.mainStageFocusedApplication
85 || !!applicationManager.sideStageFocusedApplication
86 // Used for autopilot testing.
87 readonly property string currentFocusedAppId: ApplicationManager.focusedApplicationId
89 readonly property bool fullscreenMode: {
90 if (greeter.shown || lockscreen.shown) {
92 } else if (mainStage.usingScreenshots) { // Window Manager animating so want to re-evaluate fullscreen mode
93 return mainStage.switchingFromFullscreenToFullscreen;
94 } else if (applicationManager.mainStageFocusedApplication) {
95 return applicationManager.mainStageFocusedApplication.fullscreen;
101 function activateApplication(desktopFile, argument) {
102 if (applicationManager) {
103 // For newly started applications, as it takes them time to draw their first frame
104 // we add a delay before we hide the animation screenshots to compensate.
105 var addDelay = !applicationManager.getApplicationFromDesktopFile(desktopFile);
108 application = applicationManager.activateApplication(desktopFile, argument);
109 if (application == null) {
112 if (application.stage == ApplicationInfo.MainStage || !sideStage.enabled) {
113 mainStage.activateApplication(desktopFile, addDelay);
115 sideStage.activateApplication(desktopFile, addDelay);
122 id: backgroundSettings
123 schema.id: "org.gnome.desktop.background"
125 property url gSettingsPicture: backgroundSettings.pictureUri != undefined && backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : shell.defaultBackground
126 onGSettingsPictureChanged: {
127 shell.background = gSettingsPicture
130 // This is a dummy image that is needed to determine if the picture url
131 // in backgroundSettings points to a valid picture file.
132 // We can't do this with the real background image because setting a
133 // new source in onStatusChanged triggers a binding loop detection
134 // inside Image, which causes it not to render even though a valid source
135 // would be set. We don't mind about this image staying black and just
136 // use it for verification to populate the source for the real
139 source: shell.background
145 if (status == Image.Error && source != shell.defaultBackground) {
146 shell.background = defaultBackground
155 Keys.onVolumeUpPressed: volumeControl.volumeUp()
156 Keys.onVolumeDownPressed: volumeControl.volumeDown()
160 objectName: "underlay"
163 // Whether the underlay is fully covered by opaque UI elements.
164 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
166 readonly property bool applicationRunning: ((mainStage.applications && mainStage.applications.count > 0)
167 || (sideStage.applications && sideStage.applications.count > 0))
169 // Whether the user should see the topmost application surface (if there's one at all).
170 readonly property bool applicationSurfaceShouldBeSeen: applicationRunning && !stages.fullyHidden
171 && !mainStage.usingScreenshots // but want sideStage animating over app surface
175 // NB! Application surfaces are stacked behing the shell one. So they can only be seen by the user
176 // through the translucent parts of the shell surface.
177 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
181 objectName: "backgroundImage"
184 source: shell.background
185 fillMode: Image.PreserveAspectCrop
191 opacity: dash.disappearingAnimationProgress
198 available: !greeter.shown && !lockscreen.shown
199 hides: [stages, launcher, panel.indicators]
200 shown: disappearingAnimationProgress !== 1.0
201 enabled: disappearingAnimationProgress === 0.0 && edgeDemo.dashEnabled
202 // FIXME: unfocus all applications when going back to the dash
205 shell.applicationManager.unfocusCurrentApplication()
211 topMargin: panel.panelHeight
214 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
215 opacity: 1.0 - disappearingAnimationProgress
216 property real disappearingAnimationProgress: {
218 return greeter.showProgress;
220 return stagesOuterContainer.showProgress;
224 // FIXME: only necessary because stagesOuterContainer.showProgress and
225 // greeterRevealer.animatedProgress are not animated
226 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
231 id: stagesOuterContainer
234 height: parent.height
236 Behavior on x {SmoothedAnimation{velocity: 600}}
238 property real showProgress:
239 MathUtils.clamp(1 - (x + stages.x) / shell.width, 0, 1)
247 property bool fullyShown: shown && x == 0 && parent.x == 0
248 property bool fullyHidden: !shown && x == width
249 available: !greeter.shown
250 hides: [panel.indicators]
253 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
254 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
257 height: parent.height
259 // close the stages when no focused application remains
261 target: shell.applicationManager
262 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
263 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
264 ignoreUnknownSignals: true
267 function closeIfNoApplications() {
268 if (!shell.applicationManager.mainStageFocusedApplication
269 && !shell.applicationManager.sideStageFocusedApplication
270 && shell.applicationManager.mainStageApplications.count == 0
271 && shell.applicationManager.sideStageApplications.count == 0) {
276 // show the stages when an application gets the focus
278 target: shell.applicationManager
279 onMainStageFocusedApplicationChanged: {
280 if (shell.applicationManager.mainStageFocusedApplication) {
285 onSideStageFocusedApplicationChanged: {
286 if (shell.applicationManager.sideStageFocusedApplication) {
291 ignoreUnknownSignals: true
298 fullyShown: stages.fullyShown
299 fullyHidden: stages.fullyHidden
300 shouldUseScreenshots: !fullyShown
301 rightEdgeEnabled: !sideStage.enabled
303 applicationManager: shell.applicationManager
304 rightEdgeDraggingAreaWidth: shell.edgeSize
305 normalApplicationY: shell.panelHeight
314 // FIXME: workaround the fact that focusing a main stage application
315 // raises its surface on top of all other surfaces including the ones
316 // that belong to side stage applications.
317 onFocusedApplicationChanged: {
318 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
319 shell.applicationManager.focusApplication(sideStage.focusedApplication);
327 applicationManager: shell.applicationManager
328 rightEdgeDraggingAreaWidth: shell.edgeSize
329 normalApplicationY: shell.panelHeight
332 if (!shown && mainStage.applications.count == 0) {
336 // FIXME: when hiding the side stage, refocus the main stage
337 // application so that it goes in front of the side stage
338 // application and hides it
339 onFullyShownChanged: {
340 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
341 shell.applicationManager.focusApplication(mainStage.focusedApplication);
345 enabled: shell.width >= units.gu(60)
347 fullyShown: stages.fullyShown && shown
348 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
349 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
351 available: !greeter.shown && !lockscreen.shown && enabled
352 hides: [launcher, panel.indicators]
354 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
355 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
358 height: stages.height
359 handleExpanded: sideStageRevealer.pressed
363 id: sideStageRevealer
365 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
366 && sideStage.available
367 direction: Qt.RightToLeft
368 openedValue: parent.width - sideStage.width
369 hintDisplacement: units.gu(3)
370 /* The size of the sidestage handle needs to be bigger than the
371 typical size used for edge detection otherwise it is really
374 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
375 closedValue: parent.width + sideStage.handleSizeCollapsed
377 x: parent.width - width
378 width: sideStage.width + handleSize * 0.7
379 height: sideStage.height
380 orientation: Qt.Horizontal
386 anchors.top: parent.top
387 anchors.bottom: parent.bottom
388 anchors.right: parent.left
390 width: shell.edgeSize
391 direction: Direction.Leftwards
392 enabled: greeter.showProgress == 0 && edgeDemo.dashEnabled
393 property bool haveApps: mainStage.applications.count > 0 || sideStage.applications.count > 0
395 maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
396 // Make autocompletion impossible when !haveApps
397 edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
404 objectName: "lockscreen"
406 readonly property int backgroundTopMargin: -panel.panelHeight
408 hides: [launcher, panel.indicators, hud]
411 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
412 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
414 x: required ? 0 : - width
416 height: parent.height - panel.panelHeight
417 background: shell.background
419 onUnlocked: lockscreen.hide()
420 onCancel: greeter.show()
422 Component.onCompleted: {
423 if (LightDM.Users.count == 1) {
424 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
431 target: LightDM.Greeter
434 if (LightDM.Users.count == 1) {
435 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
437 lockscreen.alphaNumeric = false
439 lockscreen.alphaNumeric = true
441 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
449 objectName: "greeter"
452 hides: [launcher, panel.indicators, hud]
455 defaultBackground: shell.background
459 height: parent.height - panel.panelHeight
461 dragHandleWidth: shell.edgeSize
463 property var previousMainApp: null
464 property var previousSideApp: null
466 function removeApplicationFocus() {
467 greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
468 greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
469 applicationManager.unfocusCurrentApplication();
472 function restoreApplicationFocus() {
473 if (greeter.previousMainApp) {
474 applicationManager.focusApplication(greeter.previousMainApp);
475 greeter.previousMainApp = null;
477 if (greeter.previousSideApp) {
478 applicationManager.focusApplication(greeter.previousSideApp);
479 greeter.previousSideApp = null;
486 // If there is only one user, we start authenticating with that one here.
487 // If there are more users, the Greeter will handle that
488 if (LightDM.Users.count == 1) {
489 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
492 greeter.forceActiveFocus();
493 removeApplicationFocus();
495 restoreApplicationFocus();
499 onUnlocked: greeter.hide()
501 // Update launcher items for new user
502 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);
503 AccountsService.user = user;
504 LauncherModel.setUser(user);
507 onLeftTeaserPressedChanged: {
508 if (leftTeaserPressed) {
514 target: applicationManager
515 ignoreUnknownSignals: true
516 // If any app is focused when greeter is open, it's due to a user action
517 // like a snap decision (say, an incoming call).
518 // TODO: these should be protected to only unlock for certain applications / certain usecases
519 // potentially only in connection with a notification.
520 onMainStageFocusedApplicationChanged: {
521 if (greeter.shown && applicationManager.mainStageFocusedApplication) {
522 greeter.previousMainApp = null // make way for new focused app
523 greeter.previousSideApp = null
527 onSideStageFocusedApplicationChanged: {
528 if (greeter.shown && applicationManager.sideStageFocusedApplication) {
529 greeter.previousMainApp = null // make way for new focused app
530 greeter.previousSideApp = null
539 blockInput: !applicationFocused || greeter.shown || lockscreen.shown || launcher.shown
540 || panel.indicators.shown || hud.shown
547 onDisplayPowerStateChange: {
548 // We ignore any display-off signals when the proximity sensor
549 // is active. This usually indicates something like a phone call.
550 if (status == Powerd.Off && (flags & Powerd.UseProximity) == 0) {
554 // No reason to chew demo CPU when user isn't watching
555 if (status == Powerd.Off) {
556 edgeDemo.paused = true;
557 } else if (status == Powerd.On) {
558 edgeDemo.paused = false;
563 function showHome() {
564 var animate = !greeter.shown && !stages.shown
566 dash.setCurrentScope("home.scope", animate, false)
577 anchors.fill: parent //because this draws indicator menus
578 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
581 available: edgeDemo.panelEnabled
582 contentEnabled: edgeDemo.panelContentEnabled
584 fullscreenMode: shell.fullscreenMode
585 searchVisible: !greeter.shown && !lockscreen.shown && dash.shown
593 height: (panel.fullscreenMode) ? shell.edgeSize : panel.panelHeight
601 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
602 height: parent.height
604 available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown && edgeDemo.dashEnabled
606 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
607 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
610 target: shell.applicationManager
611 onMainStageFocusedApplicationChanged: hud.hide()
612 onSideStageFocusedApplicationChanged: hud.hide()
621 anchors.left: hud.left
622 height: parent.height
623 target: hud.revealerTarget
626 direction: Qt.RightToLeft
627 orientation: Qt.Vertical
628 handleSize: hud.handleHeight
629 onCloseClicked: target.hide()
636 enabled: hud.available
637 applicationIsOnForeground: applicationFocused
641 blockInput: launcher.shown
644 bottom: parent.bottom
647 width: launcher.width
653 readonly property bool dashSwipe: progress > 0
655 anchors.top: parent.top
656 anchors.bottom: parent.bottom
658 dragAreaWidth: shell.edgeSize
659 available: (!greeter.shown || greeter.narrowMode) && edgeDemo.launcherEnabled
661 onDashItemSelected: showHome()
668 onDashSwipeChanged: if (dashSwipe && stages.shown) dash.setCurrentScope("applications.scope", false, true)
669 onLauncherApplicationSelected:{
671 shell.activateApplication(appId)
675 panel.indicators.hide()
685 model: NotificationBackend.Model
689 bottom: parent.bottom
690 leftMargin: units.gu(1)
691 rightMargin: units.gu(1)
692 topMargin: panel.panelHeight + units.gu(1)
697 when: overlay.width <= units.gu(60)
698 AnchorChanges { target: notifications; anchors.left: parent.left }
702 when: overlay.width > units.gu(60)
703 AnchorChanges { target: notifications; anchors.left: undefined }
704 PropertyChanges { target: notifications; width: units.gu(38) }
709 anchors { left: parent.left; right: parent.right }
710 height: parent.contentHeight
711 blockInput: height > 0
717 onFocusChanged: if (!focus) forceActiveFocus();
722 bottom: parent.bottom
725 width: shell.edgeSize
732 bottom: parent.bottom
735 width: shell.edgeSize
746 anchors.topMargin: panel.panelHeight
747 anchors.fill: parent // as needs to know the geometry of the shell
750 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
752 anchors.bottom: parent.bottom
753 anchors.left: parent.left
754 anchors.right: parent.right
755 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
757 enabled: shell.applicationManager && shell.applicationManager.keyboardVisible
761 anchors.centerIn: parent
762 visible: applicationManager.fake
763 text: "EARLY ALPHA\nNOT READY FOR USE"
766 font.weight: Font.Black
767 horizontalAlignment: Text.AlignHCenter
768 verticalAlignment: Text.AlignVCenter
769 fontSizeMode: Text.Fit
771 scale: Math.min(parent.width, parent.height) / width
779 indicators: panel.indicators
784 target: SessionBroadcast
785 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