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
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 applicationFocused: !!applicationManager.mainStageFocusedApplication
79 || !!applicationManager.sideStageFocusedApplication
80 // Used for autopilot testing.
81 readonly property string currentFocusedAppId: applicationManager.currentFocusedAppId
83 readonly property bool fullscreenMode: {
84 if (greeter.shown || lockscreen.shown) {
86 } else if (mainStage.usingScreenshots) { // Window Manager animating so want to re-evaluate fullscreen mode
87 return mainStage.switchingFromFullscreenToFullscreen;
88 } else if (applicationManager.mainStageFocusedApplication) {
89 return applicationManager.mainStageFocusedApplication.fullscreen;
96 target: applicationManager
97 ignoreUnknownSignals: true
99 // TODO: this should be protected to only unlock for certain applications / certain usecases
100 // potentially only in connection with a notification
102 shell.activateApplication(desktopFile);
105 onMainStageFocusedApplicationChanged: {
106 var app = applicationManager.mainStageFocusedApplication
108 LauncherModel.applicationFocused(app.desktopFile);
110 LauncherModel.applicationFocused("");
115 function activateApplication(desktopFile, argument) {
116 if (applicationManager) {
117 // For newly started applications, as it takes them time to draw their first frame
118 // we add a delay before we hide the animation screenshots to compensate.
119 var addDelay = !applicationManager.getApplicationFromDesktopFile(desktopFile);
122 application = applicationManager.activateApplication(desktopFile, argument);
123 if (application == null) {
126 if (application.stage == ApplicationInfo.MainStage || !sideStage.enabled) {
127 mainStage.activateApplication(desktopFile, addDelay);
129 sideStage.activateApplication(desktopFile, addDelay);
136 id: backgroundSettings
137 schema.id: "org.gnome.desktop.background"
139 property url gSettingsPicture: backgroundSettings.pictureUri != undefined && backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : shell.defaultBackground
140 onGSettingsPictureChanged: {
141 shell.background = gSettingsPicture
144 // This is a dummy image that is needed to determine if the picture url
145 // in backgroundSettings points to a valid picture file.
146 // We can't do this with the real background image because setting a
147 // new source in onStatusChanged triggers a binding loop detection
148 // inside Image, which causes it not to render even though a valid source
149 // would be set. We don't mind about this image staying black and just
150 // use it for verification to populate the source for the real
153 source: shell.background
159 if (status == Image.Error && source != shell.defaultBackground) {
160 shell.background = defaultBackground
166 anchors.fill: parent // as needs to know the geometry of the shell
173 Keys.onVolumeUpPressed: volumeControl.volumeUp()
174 Keys.onVolumeDownPressed: volumeControl.volumeDown()
178 objectName: "underlay"
181 // Whether the underlay is fully covered by opaque UI elements.
182 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
184 readonly property bool applicationRunning: ((mainStage.applications && mainStage.applications.count > 0)
185 || (sideStage.applications && sideStage.applications.count > 0))
187 // Whether the user should see the topmost application surface (if there's one at all).
188 readonly property bool applicationSurfaceShouldBeSeen: applicationRunning && !stages.fullyHidden
189 && !mainStage.usingScreenshots // but want sideStage animating over app surface
193 // NB! Application surfaces are stacked behing the shell one. So they can only be seen by the user
194 // through the translucent parts of the shell surface.
195 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
199 objectName: "backgroundImage"
202 source: shell.background
208 opacity: dash.disappearingAnimationProgress
215 available: !greeter.shown && !lockscreen.shown
216 hides: [stages, launcher, panel.indicators]
217 shown: disappearingAnimationProgress !== 1.0
218 enabled: disappearingAnimationProgress === 0.0 && edgeDemo.dashEnabled
219 // FIXME: unfocus all applications when going back to the dash
222 shell.applicationManager.unfocusCurrentApplication()
228 topMargin: panel.panelHeight
231 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
232 opacity: 1.0 - disappearingAnimationProgress
233 property real disappearingAnimationProgress: {
235 return greeter.showProgress;
237 return stagesOuterContainer.showProgress;
241 // FIXME: only necessary because stagesOuterContainer.showProgress and
242 // greeterRevealer.animatedProgress are not animated
243 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
248 id: stagesOuterContainer
251 height: parent.height
253 Behavior on x {SmoothedAnimation{velocity: 600}}
255 property real showProgress:
256 MathLocal.clamp(1 - (x + stages.x) / shell.width, 0, 1)
264 property bool fullyShown: shown && x == 0 && parent.x == 0
265 property bool fullyHidden: !shown && x == width
266 available: !greeter.shown
267 hides: [launcher, panel.indicators]
270 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
271 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
274 height: parent.height
276 // close the stages when no focused application remains
278 target: shell.applicationManager
279 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
280 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
281 ignoreUnknownSignals: true
284 function closeIfNoApplications() {
285 if (!shell.applicationManager.mainStageFocusedApplication
286 && !shell.applicationManager.sideStageFocusedApplication
287 && shell.applicationManager.mainStageApplications.count == 0
288 && shell.applicationManager.sideStageApplications.count == 0) {
293 // show the stages when an application gets the focus
295 target: shell.applicationManager
296 onMainStageFocusedApplicationChanged: {
297 if (shell.applicationManager.mainStageFocusedApplication) {
302 onSideStageFocusedApplicationChanged: {
303 if (shell.applicationManager.sideStageFocusedApplication) {
308 ignoreUnknownSignals: true
315 fullyShown: stages.fullyShown
316 fullyHidden: stages.fullyHidden
317 shouldUseScreenshots: !fullyShown
318 rightEdgeEnabled: !sideStage.enabled
320 applicationManager: shell.applicationManager
321 rightEdgeDraggingAreaWidth: shell.edgeSize
322 normalApplicationY: shell.panelHeight
331 // FIXME: workaround the fact that focusing a main stage application
332 // raises its surface on top of all other surfaces including the ones
333 // that belong to side stage applications.
334 onFocusedApplicationChanged: {
335 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
336 shell.applicationManager.focusApplication(sideStage.focusedApplication);
344 applicationManager: shell.applicationManager
345 rightEdgeDraggingAreaWidth: shell.edgeSize
346 normalApplicationY: shell.panelHeight
349 if (!shown && mainStage.applications.count == 0) {
353 // FIXME: when hiding the side stage, refocus the main stage
354 // application so that it goes in front of the side stage
355 // application and hides it
356 onFullyShownChanged: {
357 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
358 shell.applicationManager.focusApplication(mainStage.focusedApplication);
362 enabled: shell.width >= units.gu(60)
364 fullyShown: stages.fullyShown && shown
365 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
366 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
368 available: !greeter.shown && !lockscreen.shown && enabled
369 hides: [launcher, panel.indicators]
371 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
372 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
375 height: stages.height
376 handleExpanded: sideStageRevealer.pressed
380 id: sideStageRevealer
382 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
383 && sideStage.available
384 direction: Qt.RightToLeft
385 openedValue: parent.width - sideStage.width
386 hintDisplacement: units.gu(3)
387 /* The size of the sidestage handle needs to be bigger than the
388 typical size used for edge detection otherwise it is really
391 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
392 closedValue: parent.width + sideStage.handleSizeCollapsed
394 x: parent.width - width
395 width: sideStage.width + handleSize * 0.7
396 height: sideStage.height
397 orientation: Qt.Horizontal
403 anchors.top: parent.top
404 anchors.bottom: parent.bottom
405 anchors.right: parent.left
407 width: shell.edgeSize
408 direction: Direction.Leftwards
409 enabled: edgeDemo.dashEnabled
410 property bool haveApps: mainStage.applications.count > 0 || sideStage.applications.count > 0
412 maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
413 // Make autocompletion impossible when !haveApps
414 edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
421 hides: [launcher, panel.indicators, hud]
424 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
425 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
427 x: required ? 0 : - width
429 height: parent.height - panel.panelHeight
430 background: shell.background
432 onUnlocked: lockscreen.hide()
433 onCancel: greeter.show()
435 Component.onCompleted: {
436 if (LightDM.Users.count == 1) {
437 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
444 target: LightDM.Greeter
447 if (LightDM.Users.count == 1) {
448 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
450 lockscreen.alphaNumeric = false
452 lockscreen.alphaNumeric = true
454 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
462 objectName: "greeter"
465 hides: [launcher, panel.indicators, hud]
470 height: parent.height - panel.panelHeight
472 dragHandleWidth: shell.edgeSize
477 // If there is only one user, we start authenticating with that one here.
478 // If there are more users, the Greeter will handle that
479 if (LightDM.Users.count == 1) {
480 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
483 greeter.forceActiveFocus();
487 onUnlocked: greeter.hide()
489 // Update launcher items for new user
490 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);
491 AccountsService.user = user;
492 LauncherModel.setUser(user);
495 onLeftTeaserPressedChanged: {
496 if (leftTeaserPressed) {
504 blockInput: !applicationFocused || greeter.shown || lockscreen.shown || launcher.shown
505 || panel.indicators.shown || hud.shown
512 property var previousMainApp: null
513 property var previousSideApp: null
515 function setFocused(focused) {
517 powerConnection.previousMainApp = applicationManager.mainStageFocusedApplication;
518 powerConnection.previousSideApp = applicationManager.sideStageFocusedApplication;
519 applicationManager.unfocusCurrentApplication();
521 if (powerConnection.previousMainApp) {
522 applicationManager.focusApplication(powerConnection.previousMainApp);
523 powerConnection.previousMainApp = null;
525 if (powerConnection.previousSideApp) {
526 applicationManager.focusApplication(powerConnection.previousSideApp);
527 powerConnection.previousSideApp = null;
532 onDisplayPowerStateChange: {
533 // We ignore any display-off signals when the proximity sensor
534 // is active. This usually indicates something like a phone call.
535 if (status == Powerd.Off && (flags & Powerd.UseProximity) == 0) {
536 powerConnection.setFocused(false);
538 } else if (status == Powerd.On) {
539 powerConnection.setFocused(true);
542 // No reason to chew demo CPU when user isn't watching
543 if (status == Powerd.Off) {
544 edgeDemo.paused = true;
545 } else if (status == Powerd.On) {
546 edgeDemo.paused = false;
558 anchors.fill: parent //because this draws indicator menus
559 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
562 available: edgeDemo.panelEnabled
563 contentEnabled: edgeDemo.panelContentEnabled
565 fullscreenMode: shell.fullscreenMode
566 searchVisible: !greeter.shown && !lockscreen.shown
574 height: (panel.fullscreenMode) ? shell.edgeSize : panel.panelHeight
582 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
583 height: parent.height
585 available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown && edgeDemo.dashEnabled
587 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
588 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
591 target: shell.applicationManager
592 onMainStageFocusedApplicationChanged: hud.hide()
593 onSideStageFocusedApplicationChanged: hud.hide()
602 anchors.left: hud.left
603 height: parent.height
604 target: hud.revealerTarget
607 direction: Qt.RightToLeft
608 orientation: Qt.Vertical
609 handleSize: hud.handleHeight
610 onCloseClicked: target.hide()
616 enabled: !panel.indicators.shown
617 applicationIsOnForeground: applicationFocused
621 blockInput: launcher.shown
624 bottom: parent.bottom
627 width: launcher.width
633 anchors.top: parent.top
634 anchors.bottom: parent.bottom
636 dragAreaWidth: shell.edgeSize
637 available: (!greeter.shown || greeter.narrowMode) && edgeDemo.launcherEnabled
638 onDashItemSelected: {
640 // Animate if moving between application and dash
642 dash.setCurrentScope("home.scope", true, false)
644 dash.setCurrentScope("home.scope", false, false)
650 dash.setCurrentScope("applications.scope", true, false)
655 onLauncherApplicationSelected:{
657 shell.activateApplication(desktopFile)
661 panel.indicators.hide()
670 model: NotificationBackend.Model
674 bottom: parent.bottom
675 leftMargin: units.gu(1)
676 rightMargin: units.gu(1)
677 topMargin: panel.panelHeight + units.gu(1)
682 when: overlay.width <= units.gu(60)
683 AnchorChanges { target: notifications; anchors.left: parent.left }
687 when: overlay.width > units.gu(60)
688 AnchorChanges { target: notifications; anchors.left: undefined }
689 PropertyChanges { target: notifications; width: units.gu(38) }
700 bottom: parent.bottom
703 width: shell.edgeSize
710 bottom: parent.bottom
713 width: shell.edgeSize
723 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
725 anchors.bottom: parent.bottom
726 anchors.left: parent.left
727 anchors.right: parent.right
728 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
730 enabled: shell.applicationManager && shell.applicationManager.keyboardVisible
734 anchors.centerIn: parent
735 visible: applicationManager.fake
736 text: "EARLY ALPHA\nNOT READY FOR USE"
739 font.weight: Font.Black
740 horizontalAlignment: Text.AlignHCenter
741 verticalAlignment: Text.AlignVCenter
742 fontSizeMode: Text.Fit
744 scale: Math.min(parent.width, parent.height) / width
752 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