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: Qt.resolvedUrl(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 var applicationManager: ApplicationManagerWrapper {}
68 property: "applicationManager"
69 value: ApplicationManager
72 Component.onCompleted: {
73 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
75 applicationManager.sideStageEnabled = Qt.binding(function() { return sideStage.enabled })
77 // FIXME: if application focused before shell starts, shell draws on top of it only.
78 // We should detect already running applications on shell start and bring them to the front.
79 applicationManager.unfocusCurrentApplication();
82 readonly property bool applicationFocused: !!applicationManager.mainStageFocusedApplication
83 || !!applicationManager.sideStageFocusedApplication
84 // Used for autopilot testing.
85 readonly property string currentFocusedAppId: ApplicationManager.focusedApplicationId
87 readonly property bool fullscreenMode: {
88 if (greeter.shown || lockscreen.shown) {
90 } else if (mainStage.usingScreenshots) { // Window Manager animating so want to re-evaluate fullscreen mode
91 return mainStage.switchingFromFullscreenToFullscreen;
92 } else if (applicationManager.mainStageFocusedApplication) {
93 return applicationManager.mainStageFocusedApplication.fullscreen;
99 function activateApplication(appId, argument) {
100 if (applicationManager) {
101 // For newly started applications, as it takes them time to draw their first frame
102 // we add a delay before we hide the animation screenshots to compensate.
103 var addDelay = !applicationManager.getApplicationFromDesktopFile(appId);
106 application = applicationManager.activateApplication(appId, argument);
107 if (application == null) {
110 if (application.stage == ApplicationInfo.MainStage || !sideStage.enabled) {
111 mainStage.activateApplication(appId, addDelay);
113 sideStage.activateApplication(appId, addDelay);
120 id: backgroundSettings
121 schema.id: "org.gnome.desktop.background"
123 property url gSettingsPicture: backgroundSettings.pictureUri != undefined && backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : shell.defaultBackground
124 onGSettingsPictureChanged: {
125 shell.background = gSettingsPicture
132 Keys.onVolumeUpPressed: volumeControl.volumeUp()
133 Keys.onVolumeDownPressed: volumeControl.volumeDown()
137 objectName: "underlay"
140 // Whether the underlay is fully covered by opaque UI elements.
141 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
143 readonly property bool applicationRunning: ((mainStage.applications && mainStage.applications.count > 0)
144 || (sideStage.applications && sideStage.applications.count > 0))
146 // Whether the user should see the topmost application surface (if there's one at all).
147 readonly property bool applicationSurfaceShouldBeSeen: applicationRunning && !stages.fullyHidden
148 && !mainStage.usingScreenshots // but want sideStage animating over app surface
152 // NB! Application surfaces are stacked behing the shell one. So they can only be seen by the user
153 // through the translucent parts of the shell surface.
154 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
159 opacity: dash.disappearingAnimationProgress
166 available: !greeter.shown && !lockscreen.shown
167 hides: [stages, launcher, panel.indicators]
168 shown: disappearingAnimationProgress !== 1.0
169 enabled: disappearingAnimationProgress === 0.0 && edgeDemo.dashEnabled
170 // FIXME: unfocus all applications when going back to the dash
173 shell.applicationManager.unfocusCurrentApplication()
179 topMargin: panel.panelHeight
182 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
183 opacity: 1.0 - disappearingAnimationProgress
184 property real disappearingAnimationProgress: {
186 return greeter.showProgress;
188 return stagesOuterContainer.showProgress;
192 // FIXME: only necessary because stagesOuterContainer.showProgress and
193 // greeterRevealer.animatedProgress are not animated
194 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
199 id: stagesOuterContainer
202 height: parent.height
204 Behavior on x {SmoothedAnimation{velocity: 600}}
206 property real showProgress:
207 MathUtils.clamp(1 - (x + stages.x) / shell.width, 0, 1)
215 property bool fullyShown: shown && x == 0 && parent.x == 0
216 property bool fullyHidden: !shown && x == width
217 available: !greeter.shown
218 hides: [panel.indicators]
221 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
222 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
225 height: parent.height
227 // close the stages when no focused application remains
229 target: shell.applicationManager
230 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
231 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
232 ignoreUnknownSignals: true
235 function closeIfNoApplications() {
236 if (!shell.applicationManager.mainStageFocusedApplication
237 && !shell.applicationManager.sideStageFocusedApplication
238 && shell.applicationManager.mainStageApplications.count == 0
239 && shell.applicationManager.sideStageApplications.count == 0) {
244 // show the stages when an application gets the focus
246 target: shell.applicationManager
247 onMainStageFocusedApplicationChanged: {
248 if (shell.applicationManager.mainStageFocusedApplication) {
253 onSideStageFocusedApplicationChanged: {
254 if (shell.applicationManager.sideStageFocusedApplication) {
259 ignoreUnknownSignals: true
266 fullyShown: stages.fullyShown
267 fullyHidden: stages.fullyHidden
268 shouldUseScreenshots: !fullyShown
269 rightEdgeEnabled: !sideStage.enabled
271 applicationManager: shell.applicationManager
272 rightEdgeDraggingAreaWidth: shell.edgeSize
273 normalApplicationY: shell.panelHeight
282 // FIXME: workaround the fact that focusing a main stage application
283 // raises its surface on top of all other surfaces including the ones
284 // that belong to side stage applications.
285 onFocusedApplicationChanged: {
286 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
287 shell.applicationManager.focusApplication(sideStage.focusedApplication);
295 applicationManager: shell.applicationManager
296 rightEdgeDraggingAreaWidth: shell.edgeSize
297 normalApplicationY: shell.panelHeight
300 if (!shown && mainStage.applications.count == 0) {
304 // FIXME: when hiding the side stage, refocus the main stage
305 // application so that it goes in front of the side stage
306 // application and hides it
307 onFullyShownChanged: {
308 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
309 shell.applicationManager.focusApplication(mainStage.focusedApplication);
313 enabled: shell.width >= units.gu(60)
315 fullyShown: stages.fullyShown && shown
316 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
317 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
319 available: !greeter.shown && !lockscreen.shown && enabled
320 hides: [launcher, panel.indicators]
322 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
323 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
326 height: stages.height
327 handleExpanded: sideStageRevealer.pressed
331 id: sideStageRevealer
333 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
334 && sideStage.available
335 direction: Qt.RightToLeft
336 openedValue: parent.width - sideStage.width
337 hintDisplacement: units.gu(3)
338 /* The size of the sidestage handle needs to be bigger than the
339 typical size used for edge detection otherwise it is really
342 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
343 closedValue: parent.width + sideStage.handleSizeCollapsed
345 x: parent.width - width
346 width: sideStage.width + handleSize * 0.7
347 height: sideStage.height
348 orientation: Qt.Horizontal
354 anchors.top: parent.top
355 anchors.bottom: parent.bottom
356 anchors.right: parent.left
358 width: shell.edgeSize
359 direction: Direction.Leftwards
360 enabled: greeter.showProgress == 0 && edgeDemo.dashEnabled
361 property bool haveApps: mainStage.applications.count > 0 || sideStage.applications.count > 0
363 maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
364 // Make autocompletion impossible when !haveApps
365 edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
372 objectName: "lockscreen"
374 readonly property int backgroundTopMargin: -panel.panelHeight
376 hides: [launcher, panel.indicators, hud]
379 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
380 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
382 x: required ? 0 : - width
384 height: parent.height - panel.panelHeight
385 background: shell.background
388 onEntered: LightDM.Greeter.respond(passphrase);
389 onCancel: greeter.show()
391 Component.onCompleted: {
392 if (LightDM.Users.count == 1) {
393 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
400 target: LightDM.Greeter
403 if (LightDM.Users.count == 1) {
404 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
406 lockscreen.alphaNumeric = false
408 lockscreen.alphaNumeric = true
410 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
415 onAuthenticationComplete: {
416 if (LightDM.Greeter.promptless) {
419 if (LightDM.Greeter.authenticated) {
422 lockscreen.clear(true);
429 objectName: "greeter"
432 hides: [launcher, panel.indicators, hud]
435 defaultBackground: shell.background
439 height: parent.height - panel.panelHeight
441 dragHandleWidth: shell.edgeSize
443 property var previousMainApp: null
444 property var previousSideApp: null
446 function removeApplicationFocus() {
447 greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
448 greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
449 applicationManager.unfocusCurrentApplication();
452 function restoreApplicationFocus() {
453 if (greeter.previousMainApp) {
454 applicationManager.focusApplication(greeter.previousMainApp);
455 greeter.previousMainApp = null;
457 if (greeter.previousSideApp) {
458 applicationManager.focusApplication(greeter.previousSideApp);
459 greeter.previousSideApp = null;
466 // If there is only one user, we start authenticating with that one here.
467 // If there are more users, the Greeter will handle that
468 if (LightDM.Users.count == 1) {
469 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
472 greeter.forceActiveFocus();
473 removeApplicationFocus();
475 restoreApplicationFocus();
479 onUnlocked: greeter.hide()
481 // Update launcher items for new user
482 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);
483 AccountsService.user = user;
484 LauncherModel.setUser(user);
487 onLeftTeaserPressedChanged: {
488 if (leftTeaserPressed) {
494 target: applicationManager
495 ignoreUnknownSignals: true
496 // If any app is focused when greeter is open, it's due to a user action
497 // like a snap decision (say, an incoming call).
498 // TODO: these should be protected to only unlock for certain applications / certain usecases
499 // potentially only in connection with a notification.
500 onMainStageFocusedApplicationChanged: {
501 if (greeter.shown && applicationManager.mainStageFocusedApplication) {
502 greeter.previousMainApp = null // make way for new focused app
503 greeter.previousSideApp = null
507 onSideStageFocusedApplicationChanged: {
508 if (greeter.shown && applicationManager.sideStageFocusedApplication) {
509 greeter.previousMainApp = null // make way for new focused app
510 greeter.previousSideApp = null
519 blockInput: !applicationFocused || greeter.shown || lockscreen.shown || launcher.shown
520 || panel.indicators.shown || hud.shown
527 onDisplayPowerStateChange: {
528 // We ignore any display-off signals when the proximity sensor
529 // is active. This usually indicates something like a phone call.
530 if (status == Powerd.Off && (flags & Powerd.UseProximity) == 0) {
534 // No reason to chew demo CPU when user isn't watching
535 if (status == Powerd.Off) {
536 edgeDemo.paused = true;
537 } else if (status == Powerd.On) {
538 edgeDemo.paused = false;
543 function showHome() {
544 var animate = !greeter.shown && !stages.shown
546 dash.setCurrentScope("home.scope", animate, false)
550 function hideIndicatorMenu(delay) {
551 panel.hideIndicatorMenu(delay);
561 anchors.fill: parent //because this draws indicator menus
562 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
565 available: edgeDemo.panelEnabled
566 contentEnabled: edgeDemo.panelContentEnabled
568 fullscreenMode: shell.fullscreenMode
569 searchVisible: !greeter.shown && !lockscreen.shown && dash.shown
577 height: (panel.fullscreenMode) ? shell.edgeSize : panel.panelHeight
585 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
586 height: parent.height
588 available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown && edgeDemo.dashEnabled
590 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
591 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
594 target: shell.applicationManager
595 onMainStageFocusedApplicationChanged: hud.hide()
596 onSideStageFocusedApplicationChanged: hud.hide()
605 anchors.left: hud.left
606 height: parent.height
607 target: hud.revealerTarget
610 direction: Qt.RightToLeft
611 orientation: Qt.Vertical
612 handleSize: hud.handleHeight
613 onCloseClicked: target.hide()
620 enabled: hud.available
621 applicationIsOnForeground: applicationFocused
625 blockInput: launcher.shown
628 bottom: parent.bottom
631 width: launcher.width
637 readonly property bool dashSwipe: progress > 0
639 anchors.top: parent.top
640 anchors.bottom: parent.bottom
642 dragAreaWidth: shell.edgeSize
643 available: (!greeter.shown || greeter.narrowMode) && edgeDemo.launcherEnabled
646 if (edgeDemo.running)
657 onDashSwipeChanged: if (dashSwipe && stages.shown) dash.setCurrentScope("applications.scope", false, true)
658 onLauncherApplicationSelected:{
659 if (edgeDemo.running)
663 shell.activateApplication(appId)
667 panel.indicators.hide()
677 model: NotificationBackend.Model
683 bottom: parent.bottom
684 topMargin: panel.panelHeight
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