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
34import Unity.Notifications 1.0 as NotificationBackend
39 // this is only here to select the width / height of the window if not running fullscreen
40 property bool tablet: false
41 width: tablet ? units.gu(160) : applicationArguments.hasGeometry() ? applicationArguments.width() : units.gu(40)
42 height: tablet ? units.gu(100) : applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(71)
44 property real edgeSize: units.gu(2)
45 property url defaultBackground: Qt.resolvedUrl(shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg")
46 property url background
47 readonly property real panelHeight: panel.panelHeight
49 property bool dashShown: dash.shown
50 property bool stageScreenshotsReady: {
51 if (sideStage.shown) {
52 if (mainStage.applications.count > 0) {
53 return mainStage.usingScreenshots && sideStage.usingScreenshots;
55 return sideStage.usingScreenshots;
58 return mainStage.usingScreenshots;
62 property var applicationManager: ApplicationManagerWrapper {}
66 property: "applicationManager"
67 value: ApplicationManager
70 Component.onCompleted: {
71 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
73 applicationManager.sideStageEnabled = Qt.binding(function() { return sideStage.enabled })
75 // FIXME: if application focused before shell starts, shell draws on top of it only.
76 // We should detect already running applications on shell start and bring them to the front.
77 applicationManager.unfocusCurrentApplication();
80 readonly property bool applicationFocused: !!applicationManager.mainStageFocusedApplication
81 || !!applicationManager.sideStageFocusedApplication
82 // Used for autopilot testing.
83 readonly property string currentFocusedAppId: ApplicationManager.focusedApplicationId
85 readonly property bool fullscreenMode: {
86 if (greeter.shown || lockscreen.shown) {
88 } else if (mainStage.usingScreenshots) { // Window Manager animating so want to re-evaluate fullscreen mode
89 return mainStage.switchingFromFullscreenToFullscreen;
90 } else if (applicationManager.mainStageFocusedApplication) {
91 return applicationManager.mainStageFocusedApplication.fullscreen;
97 function activateApplication(appId, argument) {
98 if (applicationManager) {
99 // For newly started applications, as it takes them time to draw their first frame
100 // we add a delay before we hide the animation screenshots to compensate.
101 var addDelay = !applicationManager.getApplicationFromDesktopFile(appId);
104 application = applicationManager.activateApplication(appId, argument);
105 if (application == null) {
108 if (application.stage == ApplicationInfo.MainStage || !sideStage.enabled) {
109 mainStage.activateApplication(appId, addDelay);
111 sideStage.activateApplication(appId, addDelay);
118 id: backgroundSettings
119 schema.id: "org.gnome.desktop.background"
121 property url gSettingsPicture: backgroundSettings.pictureUri != undefined && backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : shell.defaultBackground
122 onGSettingsPictureChanged: {
123 shell.background = gSettingsPicture
126 // This is a dummy image that is needed to determine if the picture url
127 // in backgroundSettings points to a valid picture file.
128 // We can't do this with the real background image because setting a
129 // new source in onStatusChanged triggers a binding loop detection
130 // inside Image, which causes it not to render even though a valid source
131 // would be set. We don't mind about this image staying black and just
132 // use it for verification to populate the source for the real
135 source: shell.background
141 if (status == Image.Error && source != shell.defaultBackground) {
142 shell.background = defaultBackground
151 Keys.onVolumeUpPressed: volumeControl.volumeUp()
152 Keys.onVolumeDownPressed: volumeControl.volumeDown()
156 objectName: "underlay"
159 // Whether the underlay is fully covered by opaque UI elements.
160 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
162 readonly property bool applicationRunning: ((mainStage.applications && mainStage.applications.count > 0)
163 || (sideStage.applications && sideStage.applications.count > 0))
165 // Whether the user should see the topmost application surface (if there's one at all).
166 readonly property bool applicationSurfaceShouldBeSeen: applicationRunning && !stages.fullyHidden
167 && !mainStage.usingScreenshots // but want sideStage animating over app surface
171 // NB! Application surfaces are stacked behing the shell one. So they can only be seen by the user
172 // through the translucent parts of the shell surface.
173 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
177 objectName: "backgroundImage"
180 source: shell.background
181 fillMode: Image.PreserveAspectCrop
187 opacity: dash.disappearingAnimationProgress
194 available: !greeter.shown && !lockscreen.shown
195 hides: [stages, launcher, panel.indicators]
196 shown: disappearingAnimationProgress !== 1.0
197 enabled: disappearingAnimationProgress === 0.0 && edgeDemo.dashEnabled
198 // FIXME: unfocus all applications when going back to the dash
201 shell.applicationManager.unfocusCurrentApplication()
207 topMargin: panel.panelHeight
210 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
211 opacity: 1.0 - disappearingAnimationProgress
212 property real disappearingAnimationProgress: {
214 return greeter.showProgress;
216 return stagesOuterContainer.showProgress;
220 // FIXME: only necessary because stagesOuterContainer.showProgress and
221 // greeterRevealer.animatedProgress are not animated
222 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
227 id: stagesOuterContainer
230 height: parent.height
232 Behavior on x {SmoothedAnimation{velocity: 600}}
234 property real showProgress:
235 MathUtils.clamp(1 - (x + stages.x) / shell.width, 0, 1)
243 property bool fullyShown: shown && x == 0 && parent.x == 0
244 property bool fullyHidden: !shown && x == width
245 available: !greeter.shown
246 hides: [panel.indicators]
249 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
250 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
253 height: parent.height
255 // close the stages when no focused application remains
257 target: shell.applicationManager
258 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
259 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
260 ignoreUnknownSignals: true
263 function closeIfNoApplications() {
264 if (!shell.applicationManager.mainStageFocusedApplication
265 && !shell.applicationManager.sideStageFocusedApplication
266 && shell.applicationManager.mainStageApplications.count == 0
267 && shell.applicationManager.sideStageApplications.count == 0) {
272 // show the stages when an application gets the focus
274 target: shell.applicationManager
275 onMainStageFocusedApplicationChanged: {
276 if (shell.applicationManager.mainStageFocusedApplication) {
281 onSideStageFocusedApplicationChanged: {
282 if (shell.applicationManager.sideStageFocusedApplication) {
287 ignoreUnknownSignals: true
294 fullyShown: stages.fullyShown
295 fullyHidden: stages.fullyHidden
296 shouldUseScreenshots: !fullyShown
297 rightEdgeEnabled: !sideStage.enabled
299 applicationManager: shell.applicationManager
300 rightEdgeDraggingAreaWidth: shell.edgeSize
301 normalApplicationY: shell.panelHeight
310 // FIXME: workaround the fact that focusing a main stage application
311 // raises its surface on top of all other surfaces including the ones
312 // that belong to side stage applications.
313 onFocusedApplicationChanged: {
314 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
315 shell.applicationManager.focusApplication(sideStage.focusedApplication);
323 applicationManager: shell.applicationManager
324 rightEdgeDraggingAreaWidth: shell.edgeSize
325 normalApplicationY: shell.panelHeight
328 if (!shown && mainStage.applications.count == 0) {
332 // FIXME: when hiding the side stage, refocus the main stage
333 // application so that it goes in front of the side stage
334 // application and hides it
335 onFullyShownChanged: {
336 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
337 shell.applicationManager.focusApplication(mainStage.focusedApplication);
341 enabled: shell.width >= units.gu(100)
343 fullyShown: stages.fullyShown && shown
344 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
345 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
347 available: !greeter.shown && !lockscreen.shown && enabled
348 hides: [launcher, panel.indicators]
350 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
351 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
354 height: stages.height
355 handleExpanded: sideStageRevealer.pressed
359 id: sideStageRevealer
361 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
362 && sideStage.available
363 direction: Qt.RightToLeft
364 openedValue: parent.width - sideStage.width
365 hintDisplacement: units.gu(3)
366 /* The size of the sidestage handle needs to be bigger than the
367 typical size used for edge detection otherwise it is really
370 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
371 closedValue: parent.width + sideStage.handleSizeCollapsed
373 x: parent.width - width
374 width: sideStage.width + handleSize * 0.7
375 height: sideStage.height
376 orientation: Qt.Horizontal
382 anchors.top: parent.top
383 anchors.bottom: parent.bottom
384 anchors.right: parent.left
386 width: shell.edgeSize
387 direction: Direction.Leftwards
388 enabled: greeter.showProgress == 0 && edgeDemo.dashEnabled
389 property bool haveApps: mainStage.applications.count > 0 || sideStage.applications.count > 0
391 maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
392 // Make autocompletion impossible when !haveApps
393 edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
400 objectName: "lockscreen"
402 readonly property int backgroundTopMargin: -panel.panelHeight
404 hides: [launcher, panel.indicators]
407 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
408 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
410 x: required ? 0 : - width
412 height: parent.height - panel.panelHeight
413 background: shell.background
416 onEntered: LightDM.Greeter.respond(passphrase);
417 onCancel: greeter.show()
419 Component.onCompleted: {
420 if (LightDM.Users.count == 1) {
421 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
427 target: LightDM.Greeter
430 if (LightDM.Users.count == 1) {
431 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
433 lockscreen.alphaNumeric = false
435 lockscreen.alphaNumeric = true
437 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
442 onAuthenticationComplete: {
443 if (LightDM.Greeter.promptless) {
446 if (LightDM.Greeter.authenticated) {
449 lockscreen.clear(true);
456 objectName: "greeter"
459 hides: [launcher, panel.indicators]
462 defaultBackground: shell.background
466 height: parent.height - panel.panelHeight
468 dragHandleWidth: shell.edgeSize
470 property var previousMainApp: null
471 property var previousSideApp: null
473 function removeApplicationFocus() {
474 greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
475 greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
476 applicationManager.unfocusCurrentApplication();
479 function restoreApplicationFocus() {
480 if (greeter.previousMainApp) {
481 applicationManager.focusApplication(greeter.previousMainApp);
482 greeter.previousMainApp = null;
484 if (greeter.previousSideApp) {
485 applicationManager.focusApplication(greeter.previousSideApp);
486 greeter.previousSideApp = null;
493 // If there is only one user, we start authenticating with that one here.
494 // If there are more users, the Greeter will handle that
495 if (LightDM.Users.count == 1) {
496 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
498 greeter.forceActiveFocus();
499 removeApplicationFocus();
501 restoreApplicationFocus();
505 onUnlocked: greeter.hide()
507 // Update launcher items for new user
508 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);
509 AccountsService.user = user;
510 LauncherModel.setUser(user);
513 onLeftTeaserPressedChanged: {
514 if (leftTeaserPressed) {
520 target: applicationManager
521 ignoreUnknownSignals: true
522 // If any app is focused when greeter is open, it's due to a user action
523 // like a snap decision (say, an incoming call).
524 // TODO: these should be protected to only unlock for certain applications / certain usecases
525 // potentially only in connection with a notification.
526 onMainStageFocusedApplicationChanged: {
527 if (greeter.shown && applicationManager.mainStageFocusedApplication) {
528 greeter.previousMainApp = null // make way for new focused app
529 greeter.previousSideApp = null
533 onSideStageFocusedApplicationChanged: {
534 if (greeter.shown && applicationManager.sideStageFocusedApplication) {
535 greeter.previousMainApp = null // make way for new focused app
536 greeter.previousSideApp = null
545 blockInput: !applicationFocused || greeter.shown || lockscreen.shown || launcher.shown
546 || panel.indicators.shown
553 onDisplayPowerStateChange: {
554 // We ignore any display-off signals when the proximity sensor
555 // is active. This usually indicates something like a phone call.
556 if (status == Powerd.Off && (flags & Powerd.UseProximity) == 0) {
560 // No reason to chew demo CPU when user isn't watching
561 if (status == Powerd.Off) {
562 edgeDemo.paused = true;
563 } else if (status == Powerd.On) {
564 edgeDemo.paused = false;
569 function showHome() {
570 var animate = !greeter.shown && !stages.shown
572 dash.setCurrentScope("home.scope", animate, false)
576 function hideIndicatorMenu(delay) {
577 panel.hideIndicatorMenu(delay);
587 anchors.fill: parent //because this draws indicator menus
588 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
591 available: edgeDemo.panelEnabled
592 contentEnabled: edgeDemo.panelContentEnabled
594 fullscreenMode: shell.fullscreenMode
595 searchVisible: !greeter.shown && !lockscreen.shown && dash.shown && dash.searchable
603 height: (panel.fullscreenMode) ? shell.edgeSize : panel.panelHeight
609 blockInput: launcher.shown
612 bottom: parent.bottom
615 width: launcher.width
621 readonly property bool dashSwipe: progress > 0
623 anchors.top: parent.top
624 anchors.bottom: parent.bottom
626 dragAreaWidth: shell.edgeSize
627 available: (!greeter.shown || greeter.narrowMode) && edgeDemo.launcherEnabled
630 if (edgeDemo.running)
641 onDashSwipeChanged: if (dashSwipe && stages.shown) dash.setCurrentScope("applications.scope", false, true)
642 onLauncherApplicationSelected:{
643 if (edgeDemo.running)
647 shell.activateApplication(appId)
651 panel.indicators.hide()
659 model: NotificationBackend.Model
665 bottom: parent.bottom
666 topMargin: panel.panelHeight
671 when: overlay.width <= units.gu(60)
672 AnchorChanges { target: notifications; anchors.left: parent.left }
676 when: overlay.width > units.gu(60)
677 AnchorChanges { target: notifications; anchors.left: undefined }
678 PropertyChanges { target: notifications; width: units.gu(38) }
683 anchors { left: parent.left; right: parent.right }
684 height: parent.contentHeight
685 blockInput: height > 0
691 onFocusChanged: if (!focus) forceActiveFocus();
696 bottom: parent.bottom
699 width: shell.edgeSize
706 bottom: parent.bottom
709 width: shell.edgeSize
720 anchors.topMargin: panel.panelHeight
721 anchors.fill: parent // as needs to know the geometry of the shell
724 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
726 anchors.bottom: parent.bottom
727 anchors.left: parent.left
728 anchors.right: parent.right
729 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
731 enabled: shell.applicationManager && shell.applicationManager.keyboardVisible
735 anchors.centerIn: parent
736 visible: applicationManager.fake
737 text: "EARLY ALPHA\nNOT READY FOR USE"
740 font.weight: Font.Black
741 horizontalAlignment: Text.AlignHCenter
742 verticalAlignment: Text.AlignVCenter
743 fontSizeMode: Text.Fit
745 scale: Math.min(parent.width, parent.height) / width
753 indicators: panel.indicators
758 target: SessionBroadcast
759 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