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 Ubuntu.Application 0.1
21import Ubuntu.Components 0.1
22import Ubuntu.Gestures 0.1
23import Unity.Launcher 0.1
24import LightDM 0.1 as LightDM
32import "Components/Math.js" as MathLocal
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 {}
68 Component.onCompleted: {
69 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
71 applicationManager.sideStageEnabled = Qt.binding(function() { return sideStage.enabled })
73 // FIXME: if application focused before shell starts, shell draws on top of it only.
74 // We should detect already running applications on shell start and bring them to the front.
75 applicationManager.unfocusCurrentApplication();
78 readonly property bool fullscreenMode: {
79 if (greeter.shown || lockscreen.shown) {
81 } else if (mainStage.usingScreenshots) { // Window Manager animating so want to re-evaluate fullscreen mode
82 return mainStage.switchingFromFullscreenToFullscreen;
83 } else if (applicationManager.mainStageFocusedApplication) {
84 return applicationManager.mainStageFocusedApplication.fullscreen;
91 target: applicationManager
92 ignoreUnknownSignals: true
94 // TODO: this should be protected to only unlock for certain applications / certain usecases
95 // potentially only in connection with a notification
97 shell.activateApplication(desktopFile);
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
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: [launcher, 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: 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]
452 height: parent.height - panel.panelHeight
454 dragHandleWidth: shell.edgeSize
459 // If there is only one user, we start authenticating with that one here.
460 // If there are more users, the Greeter will handle that
461 if (LightDM.Users.count == 1) {
462 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
465 greeter.forceActiveFocus();
469 onUnlocked: greeter.hide()
471 // Update launcher items for new user
472 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);
473 AccountsService.user = user;
474 LauncherModel.setUser(user);
477 onLeftTeaserPressedChanged: {
478 if (leftTeaserPressed) {
486 blockInput: greeter.shown || lockscreen.shown
493 property var previousMainApp: null
494 property var previousSideApp: null
496 function setFocused(focused) {
498 // FIXME: *FocusedApplication are not updated when unfocused, hence the need to check whether
499 // the stage was actually shown
500 if (mainStage.fullyShown) powerConnection.previousMainApp = applicationManager.mainStageFocusedApplication;
501 if (sideStage.fullyShown) powerConnection.previousSideApp = applicationManager.sideStageFocusedApplication;
502 applicationManager.unfocusCurrentApplication();
504 if (powerConnection.previousMainApp) {
505 applicationManager.focusApplication(powerConnection.previousMainApp);
506 powerConnection.previousMainApp = null;
508 if (powerConnection.previousSideApp) {
509 applicationManager.focusApplication(powerConnection.previousSideApp);
510 powerConnection.previousSideApp = null;
515 onDisplayPowerStateChange: {
516 // We ignore any display-off signals when the proximity sensor
517 // is active. This usually indicates something like a phone call.
518 if (status == Powerd.Off && (flags & Powerd.UseProximity) == 0) {
519 powerConnection.setFocused(false);
521 } else if (status == Powerd.On) {
522 powerConnection.setFocused(true);
525 // No reason to chew demo CPU when user isn't watching
526 if (status == Powerd.Off) {
527 edgeDemo.paused = true;
528 } else if (status == Powerd.On) {
529 edgeDemo.paused = false;
541 anchors.fill: parent //because this draws indicator menus
542 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
545 available: edgeDemo.panelEnabled
546 contentEnabled: edgeDemo.panelContentEnabled
548 fullscreenMode: shell.fullscreenMode
549 searchVisible: !greeter.shown && !lockscreen.shown
553 blockInput: panel.indicators.shown
560 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
561 height: parent.height
563 available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown && edgeDemo.dashEnabled
565 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
566 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
569 target: shell.applicationManager
570 onMainStageFocusedApplicationChanged: hud.hide()
571 onSideStageFocusedApplicationChanged: hud.hide()
576 blockInput: hud.shown
585 anchors.left: hud.left
586 height: parent.height
587 target: hud.revealerTarget
590 direction: Qt.RightToLeft
591 orientation: Qt.Vertical
592 handleSize: hud.handleHeight
593 onCloseClicked: target.hide()
599 enabled: !panel.indicators.shown
600 applicationIsOnForeground: applicationManager.mainStageFocusedApplication
601 || applicationManager.sideStageFocusedApplication
605 blockInput: launcher.shown
608 bottom: parent.bottom
611 width: launcher.width
617 anchors.top: parent.top
618 anchors.bottom: parent.bottom
620 dragAreaWidth: shell.edgeSize
621 available: (!greeter.shown || greeter.narrowMode) && edgeDemo.launcherEnabled
622 onDashItemSelected: {
624 // Animate if moving between application and dash
626 dash.setCurrentScope("home.scope", true, false)
628 dash.setCurrentScope("home.scope", false, false)
634 dash.setCurrentScope("applications.scope", true, false)
639 onLauncherApplicationSelected:{
641 shell.activateApplication(desktopFile)
645 panel.indicators.hide()
654 model: NotificationBackend.Model
658 bottom: parent.bottom
659 leftMargin: units.gu(1)
660 rightMargin: units.gu(1)
661 topMargin: panel.panelHeight + units.gu(1)
666 when: overlay.width <= units.gu(60)
667 AnchorChanges { target: notifications; anchors.left: parent.left }
671 when: overlay.width > units.gu(60)
672 AnchorChanges { target: notifications; anchors.left: undefined }
673 PropertyChanges { target: notifications; width: units.gu(38) }
684 bottom: parent.bottom
687 width: shell.edgeSize
694 bottom: parent.bottom
697 width: shell.edgeSize
707 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
709 anchors.bottom: parent.bottom
710 anchors.left: parent.left
711 anchors.right: parent.right
712 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
714 enabled: shell.applicationManager && shell.applicationManager.keyboardVisible
718 anchors.centerIn: parent
719 visible: applicationManager.fake
720 text: "EARLY ALPHA\nNOT READY FOR USE"
723 font.weight: Font.Black
724 horizontalAlignment: Text.AlignHCenter
725 verticalAlignment: Text.AlignVCenter
726 fontSizeMode: Text.Fit
728 scale: Math.min(parent.width, parent.height) / width
736 indicators: panel.indicators
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