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
42 // this is only here to select the width / height of the window if not running fullscreen
43 property bool tablet: false
44 width: tablet ? units.gu(160) : applicationArguments.hasGeometry() ? applicationArguments.width() : units.gu(40)
45 height: tablet ? units.gu(100) : applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(71)
47 property real edgeSize: units.gu(2)
48 property url defaultBackground: Qt.resolvedUrl(shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg")
49 property url background
50 readonly property real panelHeight: panel.panelHeight
52 property bool dashShown: dash.shown
53 property bool stageScreenshotsReady: {
54 if (sideStage.shown) {
55 if (mainStage.applications.count > 0) {
56 return mainStage.usingScreenshots && sideStage.usingScreenshots;
58 return sideStage.usingScreenshots;
61 return mainStage.usingScreenshots;
65 property var applicationManager: ApplicationManagerWrapper {}
69 property: "applicationManager"
70 value: ApplicationManager
73 Component.onCompleted: {
74 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
76 applicationManager.sideStageEnabled = Qt.binding(function() { return sideStage.enabled })
78 // FIXME: if application focused before shell starts, shell draws on top of it only.
79 // We should detect already running applications on shell start and bring them to the front.
80 applicationManager.unfocusCurrentApplication();
82 applicationManager.setMainStageAppRect(mainStageAppRect);
83 applicationManager.setSideStageAppRect(sideStageAppRect);
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(appId, 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(appId);
108 application = applicationManager.activateApplication(appId, argument);
109 if (application == null) {
112 if (application.stage == ApplicationInfo.MainStage || !sideStage.enabled) {
113 mainStage.activateApplication(appId, addDelay);
115 sideStage.activateApplication(appId, addDelay);
122 target: applicationManager
123 onFocusRequested: activateApplication(appId)
127 id: backgroundSettings
128 schema.id: "org.gnome.desktop.background"
130 property url gSettingsPicture: backgroundSettings.pictureUri != undefined && backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : shell.defaultBackground
131 onGSettingsPictureChanged: {
132 shell.background = gSettingsPicture
139 Keys.onVolumeUpPressed: volumeControl.volumeUp()
140 Keys.onVolumeDownPressed: volumeControl.volumeDown()
144 objectName: "underlay"
147 // Whether the underlay is fully covered by opaque UI elements.
148 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
150 readonly property bool mainStageApplicationRunning: mainStage.applications && mainStage.applications.count > 0
151 readonly property bool sideStageApplicationRunning: sideStage.applications && sideStage.applications.count > 0
153 // Whether the user should see the topmost application surface (if there's one at all).
154 readonly property bool mainStageApplicationShown: mainStageApplicationRunning && !stages.fullyHidden
155 && !mainStage.usingScreenshots // but want sideStage animating over app surface
159 // NB! Application surfaces are stacked behing the shell one. So they can only be seen by the user
160 // through the translucent parts of the shell surface.
161 visible: !fullyCovered && !mainStageApplicationShown
165 clip: !parent.mainStageApplicationShown && parent.sideStageApplicationRunning && stagesOuterContainer.showProgress > 0
168 var w = parent.width - sideStage.width
169 w += stagesOuterContainer.x + stages.x + (sideStage.x - sideStageRevealer.openedValue)
170 return Math.min(w, parent.width);
175 height: parent.height
179 source: shell.width > shell.height ? "Dash/graphics/paper_landscape.png" : "Dash/graphics/paper_portrait.png"
180 fillMode: Image.PreserveAspectCrop
181 horizontalAlignment: Image.AlignRight
182 verticalAlignment: Image.AlignTop
189 available: !greeter.shown && !lockscreen.shown
190 hides: [stages, launcher, panel.indicators]
191 shown: disappearingAnimationProgress !== 1.0
192 enabled: disappearingAnimationProgress === 0.0 && edgeDemo.dashEnabled
193 // FIXME: unfocus all applications when going back to the dash
196 shell.applicationManager.unfocusCurrentApplication()
200 width: underlay.width
201 height: underlay.height - y
204 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
205 opacity: 1.0 - disappearingAnimationProgress
206 property real disappearingAnimationProgress: {
208 return greeter.showProgress;
210 if (underlayClipper.clip)
213 return stagesOuterContainer.showProgress;
217 // FIXME: only necessary because stagesOuterContainer.showProgress and
218 // greeterRevealer.animatedProgress are not animated
219 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
223 width: underlay.width
224 height: underlay.height
226 opacity: 0.5 * ((sideStage.x - sideStageRevealer.closedValue) / (sideStageRevealer.openedValue - sideStageRevealer.closedValue))
227 visible: sideStageHideButton.enabled
231 id: sideStageHideButton
232 enabled: mainStage.applications.count == 0 && sideStage.shown
242 id: stagesOuterContainer
245 height: parent.height
246 x: mainStage.applications.count > 0 ? launcher.progress : 0
247 Behavior on x {SmoothedAnimation{velocity: 600}}
249 property real showProgress:
250 MathUtils.clamp(1 - (x + stages.x) / shell.width, 0, 1)
258 function doLauncherHide() {
259 if (mainStage.applications.count > 0) {
262 if (sideStage.shown) {
268 property bool fullyShown: shown && x == 0 && parent.x == 0
269 property bool fullyHidden: !shown && x == width
270 available: !greeter.shown
271 hides: [panel.indicators]
274 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
275 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
278 height: parent.height
280 // close the stages when no focused application remains
282 target: shell.applicationManager
283 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
284 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
285 ignoreUnknownSignals: true
288 function closeIfNoApplications() {
289 if (!shell.applicationManager.mainStageFocusedApplication
290 && !shell.applicationManager.sideStageFocusedApplication
291 && shell.applicationManager.mainStageApplications.count == 0
292 && shell.applicationManager.sideStageApplications.count == 0) {
297 // show the stages when an application gets the focus
299 target: shell.applicationManager
300 onMainStageFocusedApplicationChanged: {
301 if (shell.applicationManager.mainStageFocusedApplication) {
306 onSideStageFocusedApplicationChanged: {
307 if (shell.applicationManager.sideStageFocusedApplication) {
312 ignoreUnknownSignals: true
319 fullyShown: stages.fullyShown
320 fullyHidden: stages.fullyHidden
321 shouldUseScreenshots: !fullyShown
322 rightEdgeEnabled: !sideStage.enabled
324 applicationManager: shell.applicationManager
325 rightEdgeDraggingAreaWidth: shell.edgeSize
326 normalApplicationY: shell.panelHeight
335 // FIXME: workaround the fact that focusing a main stage application
336 // raises its surface on top of all other surfaces including the ones
337 // that belong to side stage applications.
338 onFocusedApplicationChanged: {
339 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
340 shell.applicationManager.focusApplication(sideStage.focusedApplication);
348 applicationManager: shell.applicationManager
349 rightEdgeDraggingAreaWidth: shell.edgeSize
350 normalApplicationY: shell.panelHeight
352 // FIXME: when hiding the side stage, refocus the main stage
353 // application so that it goes in front of the side stage
354 // application and hides it
355 onFullyShownChanged: {
356 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
357 shell.applicationManager.focusApplication(mainStage.focusedApplication);
361 enabled: shell.width >= units.gu(60)
363 fullyShown: stages.fullyShown && shown
364 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
365 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
367 available: !greeter.shown && !lockscreen.shown && enabled
368 hides: [launcher, panel.indicators]
370 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
371 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
374 height: stages.height
375 handleExpanded: sideStageRevealer.pressed
378 target: sideStage.applications
380 if (sideStage.applications.count == 0) {
381 if (sideStage.shown) { // if all SS app closed, hide side stage
384 // Sidestage is hidden and there is no main app, make sure the
385 // stages is totally hidden too
386 if (mainStage.applications.count == 0) {
396 id: sideStageRevealer
398 enabled: sideStage.applications.count > 0
399 && sideStage.available
400 direction: Qt.RightToLeft
401 openedValue: parent.width - sideStage.width
402 hintDisplacement: units.gu(3)
403 /* The size of the sidestage handle needs to be bigger than the
404 typical size used for edge detection otherwise it is really
407 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
408 closedValue: parent.width + sideStage.handleSizeCollapsed
410 x: parent.width - width
411 width: sideStage.width + handleSize * 0.7
412 height: sideStage.height
413 orientation: Qt.Horizontal
416 // Defines the rectangle occupied by an application on the main or side stage.
417 // Used only to inform the ApplicationManager. Can be removed when the proper
418 // architecture is in place (unity8 as mir compositor).
422 y: mainStage.y + mainStage.normalApplicationY
423 width: mainStage.width
424 height: mainStage.height
425 visible: false; enabled: false
429 x: sideStageRevealer.openedValue
430 y: sideStage.y + sideStage.normalApplicationY
431 width: sideStage.width
432 height: sideStage.height
433 visible: false; enabled: false
439 anchors.top: parent.top
440 anchors.bottom: parent.bottom
441 anchors.right: parent.left
443 width: shell.edgeSize
444 direction: Direction.Leftwards
445 enabled: greeter.showProgress == 0 && edgeDemo.dashEnabled
446 property bool haveApps: mainStage.applications.count > 0 || sideStage.applications.count > 0
448 maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
449 // Make autocompletion impossible when !haveApps
450 edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
457 objectName: "lockscreen"
459 readonly property int backgroundTopMargin: -panel.panelHeight
461 hides: [launcher, panel.indicators, hud]
464 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
465 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
467 x: required ? 0 : - width
469 height: parent.height - panel.panelHeight
470 background: shell.background
473 onEntered: LightDM.Greeter.respond(passphrase);
474 onCancel: greeter.show()
476 Component.onCompleted: {
477 if (LightDM.Users.count == 1) {
478 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
484 target: LightDM.Greeter
487 if (LightDM.Users.count == 1) {
488 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
490 lockscreen.alphaNumeric = false
492 lockscreen.alphaNumeric = true
494 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
499 onAuthenticationComplete: {
500 if (LightDM.Greeter.promptless) {
503 if (LightDM.Greeter.authenticated) {
506 lockscreen.clear(true);
513 objectName: "greeter"
516 hides: [launcher, panel.indicators, hud]
519 defaultBackground: shell.defaultBackground
523 height: parent.height - panel.panelHeight
525 dragHandleWidth: shell.edgeSize
527 property var previousMainApp: null
528 property var previousSideApp: null
530 function removeApplicationFocus() {
531 greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
532 if (sideStage.fullyShown) { // if side stage hidden, don't focus it on restore
533 greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
535 applicationManager.unfocusCurrentApplication();
538 function restoreApplicationFocus() {
539 if (greeter.previousMainApp) {
540 applicationManager.focusApplication(greeter.previousMainApp);
541 greeter.previousMainApp = null;
543 if (greeter.previousSideApp) {
544 applicationManager.focusApplication(greeter.previousSideApp);
545 greeter.previousSideApp = null;
552 // If there is only one user, we start authenticating with that one here.
553 // If there are more users, the Greeter will handle that
554 if (LightDM.Users.count == 1) {
555 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
557 greeter.forceActiveFocus();
558 removeApplicationFocus();
560 restoreApplicationFocus();
564 onUnlocked: greeter.hide()
566 // Update launcher items for new user
567 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);
568 AccountsService.user = user;
569 LauncherModel.setUser(user);
572 onLeftTeaserPressedChanged: {
573 if (leftTeaserPressed) {
579 target: applicationManager
580 ignoreUnknownSignals: true
581 // If any app is focused when greeter is open, it's due to a user action
582 // like a snap decision (say, an incoming call).
583 // TODO: these should be protected to only unlock for certain applications / certain usecases
584 // potentially only in connection with a notification.
585 onMainStageFocusedApplicationChanged: {
586 if (greeter.shown && applicationManager.mainStageFocusedApplication) {
587 greeter.previousMainApp = null // make way for new focused app
588 greeter.previousSideApp = null
592 onSideStageFocusedApplicationChanged: {
593 if (greeter.shown && applicationManager.sideStageFocusedApplication) {
594 greeter.previousMainApp = null // make way for new focused app
595 greeter.previousSideApp = null
604 if (applicationManager.sideStageFocusedApplication && sideStage.shown)
605 return parent.width - sideStage.width;
609 height: parent.height
610 blockInput: !applicationManager.mainStageFocusedApplication || greeter.shown || lockscreen.shown || launcher.shown
611 || panel.indicators.shown || hud.shown
618 onDisplayPowerStateChange: {
619 // We ignore any display-off signals when the proximity sensor
620 // is active. This usually indicates something like a phone call.
621 if (status == Powerd.Off && (flags & Powerd.UseProximity) == 0) {
625 // No reason to chew demo CPU when user isn't watching
626 if (status == Powerd.Off) {
627 edgeDemo.paused = true;
628 } else if (status == Powerd.On) {
629 edgeDemo.paused = false;
634 function showHome() {
635 var animate = !greeter.shown && !stages.shown
637 dash.setCurrentScope("clickscope", animate, false)
641 function hideIndicatorMenu(delay) {
642 panel.hideIndicatorMenu(delay);
652 anchors.fill: parent //because this draws indicator menus
653 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
656 available: edgeDemo.panelEnabled
657 contentEnabled: edgeDemo.panelContentEnabled
659 fullscreenMode: shell.fullscreenMode
660 searchVisible: !greeter.shown && !lockscreen.shown && dash.shown && dash.searchable
668 height: (panel.fullscreenMode) ? shell.edgeSize : panel.panelHeight
676 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
677 height: parent.height
679 available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown && edgeDemo.dashEnabled
681 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
682 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
685 target: shell.applicationManager
686 onMainStageFocusedApplicationChanged: hud.hide()
687 onSideStageFocusedApplicationChanged: hud.hide()
696 anchors.left: hud.left
697 height: parent.height
698 target: hud.revealerTarget
701 direction: Qt.RightToLeft
702 orientation: Qt.Vertical
703 handleSize: hud.handleHeight
704 onCloseClicked: target.hide()
711 enabled: hud.available
712 applicationIsOnForeground: (stages.shown && mainStage.applications.count > 0) || (stages.shown && sideStage.shown)
716 blockInput: launcher.shown
719 bottom: parent.bottom
722 width: launcher.width
728 readonly property bool dashSwipe: progress > 0
730 anchors.top: parent.top
731 anchors.bottom: parent.bottom
733 dragAreaWidth: shell.edgeSize
734 available: !greeter.locked && edgeDemo.launcherEnabled
737 if (edgeDemo.running)
744 stages.doLauncherHide();
748 onDashSwipeChanged: if (dashSwipe && stages.shown) dash.setCurrentScope("clickscope", false, true)
749 onLauncherApplicationSelected:{
750 if (edgeDemo.running)
754 shell.activateApplication(appId)
758 panel.indicators.hide()
768 model: NotificationBackend.Model
774 bottom: parent.bottom
775 topMargin: panel.panelHeight
780 when: overlay.width <= units.gu(60)
781 AnchorChanges { target: notifications; anchors.left: parent.left }
785 when: overlay.width > units.gu(60)
786 AnchorChanges { target: notifications; anchors.left: undefined }
787 PropertyChanges { target: notifications; width: units.gu(38) }
792 anchors { left: parent.left; right: parent.right }
793 height: parent.contentHeight
794 blockInput: height > 0
800 onFocusChanged: if (!focus) forceActiveFocus();
805 bottom: parent.bottom
808 width: shell.edgeSize
815 bottom: parent.bottom
818 width: shell.edgeSize
829 anchors.centerIn: parent
830 visible: applicationManager.fake
831 text: "EARLY ALPHA\nNOT READY FOR USE"
834 font.weight: Font.Black
835 horizontalAlignment: Text.AlignHCenter
836 verticalAlignment: Text.AlignVCenter
837 fontSizeMode: Text.Fit
839 scale: Math.min(parent.width, parent.height) / width
847 indicators: panel.indicators
852 target: SessionBroadcast
853 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