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();
81 applicationManager.setMainStageAppRect(mainStageAppRect);
82 applicationManager.setSideStageAppRect(sideStageAppRect);
85 readonly property bool applicationFocused: !!applicationManager.mainStageFocusedApplication
86 || !!applicationManager.sideStageFocusedApplication
87 // Used for autopilot testing.
88 readonly property string currentFocusedAppId: ApplicationManager.focusedApplicationId
90 readonly property bool fullscreenMode: {
91 if (greeter.shown || lockscreen.shown) {
93 } else if (mainStage.usingScreenshots) { // Window Manager animating so want to re-evaluate fullscreen mode
94 return mainStage.switchingFromFullscreenToFullscreen;
95 } else if (applicationManager.mainStageFocusedApplication) {
96 return applicationManager.mainStageFocusedApplication.fullscreen;
102 function activateApplication(appId, argument) {
103 if (applicationManager) {
104 // For newly started applications, as it takes them time to draw their first frame
105 // we add a delay before we hide the animation screenshots to compensate.
106 var addDelay = !applicationManager.getApplicationFromDesktopFile(appId);
109 application = applicationManager.activateApplication(appId, argument);
110 if (application == null) {
113 if (application.stage == ApplicationInfo.MainStage || !sideStage.enabled) {
114 mainStage.activateApplication(appId, addDelay);
116 sideStage.activateApplication(appId, addDelay);
123 id: backgroundSettings
124 schema.id: "org.gnome.desktop.background"
126 property url gSettingsPicture: backgroundSettings.pictureUri != undefined && backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : shell.defaultBackground
127 onGSettingsPictureChanged: {
128 shell.background = gSettingsPicture
135 Keys.onVolumeUpPressed: volumeControl.volumeUp()
136 Keys.onVolumeDownPressed: volumeControl.volumeDown()
140 objectName: "underlay"
143 // Whether the underlay is fully covered by opaque UI elements.
144 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
146 readonly property bool mainStageApplicationRunning: mainStage.applications && mainStage.applications.count > 0
147 readonly property bool sideStageApplicationRunning: sideStage.applications && sideStage.applications.count > 0
149 // Whether the user should see the topmost application surface (if there's one at all).
150 readonly property bool mainStageApplicationShown: mainStageApplicationRunning && !stages.fullyHidden
151 && !mainStage.usingScreenshots // but want sideStage animating over app surface
155 // NB! Application surfaces are stacked behing the shell one. So they can only be seen by the user
156 // through the translucent parts of the shell surface.
157 visible: !fullyCovered && !mainStageApplicationShown
161 clip: !parent.mainStageApplicationShown && parent.sideStageApplicationRunning && stagesOuterContainer.showProgress > 0
164 var w = parent.width - sideStage.width
165 w += stagesOuterContainer.x + stages.x
166 return Math.min(w, parent.width);
171 height: parent.height
174 width: underlay.width
175 height: underlay.height
177 opacity: dash.disappearingAnimationProgress
182 source: shell.width > shell.height ? "Dash/graphics/paper_landscape.png" : "Dash/graphics/paper_portrait.png"
183 fillMode: Image.PreserveAspectCrop
184 horizontalAlignment: Image.AlignRight
185 verticalAlignment: Image.AlignTop
192 available: !greeter.shown && !lockscreen.shown
193 hides: [stages, launcher, panel.indicators]
194 shown: disappearingAnimationProgress !== 1.0
195 enabled: disappearingAnimationProgress === 0.0 && edgeDemo.dashEnabled
196 // FIXME: unfocus all applications when going back to the dash
199 shell.applicationManager.unfocusCurrentApplication()
203 width: underlay.width
204 height: underlay.height - y
207 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
208 opacity: 1.0 - disappearingAnimationProgress
209 property real disappearingAnimationProgress: {
211 return greeter.showProgress;
213 if (underlayClipper.clip)
214 return stagesOuterContainer.showProgress * 0.5;
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 }}
226 enabled: stagesOuterContainer.showProgress == 1
236 id: stagesOuterContainer
239 height: parent.height
241 Behavior on x {SmoothedAnimation{velocity: 600}}
243 property real showProgress:
244 MathUtils.clamp(1 - (x + stages.x) / shell.width, 0, 1)
252 property bool fullyShown: shown && x == 0 && parent.x == 0
253 property bool fullyHidden: !shown && x == width
254 available: !greeter.shown
255 hides: [panel.indicators]
258 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
259 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
262 height: parent.height
264 // close the stages when no focused application remains
266 target: shell.applicationManager
267 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
268 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
269 ignoreUnknownSignals: true
272 function closeIfNoApplications() {
273 if (!shell.applicationManager.mainStageFocusedApplication
274 && !shell.applicationManager.sideStageFocusedApplication
275 && shell.applicationManager.mainStageApplications.count == 0
276 && shell.applicationManager.sideStageApplications.count == 0) {
281 // show the stages when an application gets the focus
283 target: shell.applicationManager
284 onMainStageFocusedApplicationChanged: {
285 if (shell.applicationManager.mainStageFocusedApplication) {
290 onSideStageFocusedApplicationChanged: {
291 if (shell.applicationManager.sideStageFocusedApplication) {
296 ignoreUnknownSignals: true
303 fullyShown: stages.fullyShown
304 fullyHidden: stages.fullyHidden
305 shouldUseScreenshots: !fullyShown
306 rightEdgeEnabled: !sideStage.enabled
308 applicationManager: shell.applicationManager
309 rightEdgeDraggingAreaWidth: shell.edgeSize
310 normalApplicationY: shell.panelHeight
319 // FIXME: workaround the fact that focusing a main stage application
320 // raises its surface on top of all other surfaces including the ones
321 // that belong to side stage applications.
322 onFocusedApplicationChanged: {
323 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
324 shell.applicationManager.focusApplication(sideStage.focusedApplication);
332 applicationManager: shell.applicationManager
333 rightEdgeDraggingAreaWidth: shell.edgeSize
334 normalApplicationY: shell.panelHeight
337 if (!shown && mainStage.applications.count == 0) {
341 // FIXME: when hiding the side stage, refocus the main stage
342 // application so that it goes in front of the side stage
343 // application and hides it
344 onFullyShownChanged: {
345 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
346 shell.applicationManager.focusApplication(mainStage.focusedApplication);
350 enabled: shell.width >= units.gu(60)
352 fullyShown: stages.fullyShown && shown
353 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
354 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
356 available: !greeter.shown && !lockscreen.shown && enabled
357 hides: [launcher, panel.indicators]
359 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
360 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
363 height: stages.height
364 handleExpanded: sideStageRevealer.pressed
368 id: sideStageRevealer
370 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
371 && sideStage.available
372 direction: Qt.RightToLeft
373 openedValue: parent.width - sideStage.width
374 hintDisplacement: units.gu(3)
375 /* The size of the sidestage handle needs to be bigger than the
376 typical size used for edge detection otherwise it is really
379 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
380 closedValue: parent.width + sideStage.handleSizeCollapsed
382 x: parent.width - width
383 width: sideStage.width + handleSize * 0.7
384 height: sideStage.height
385 orientation: Qt.Horizontal
388 // Defines the rectangle occupied by an application on the main or side stage.
389 // Used only to inform the ApplicationManager. Can be removed when the proper
390 // architecture is in place (unity8 as mir compositor).
394 y: mainStage.y + mainStage.normalApplicationY
395 width: mainStage.width
396 height: mainStage.height
397 visible: false; enabled: false
401 x: sideStageRevealer.openedValue
402 y: sideStage.y + sideStage.normalApplicationY
403 width: sideStage.width
404 height: sideStage.height
405 visible: false; enabled: false
411 anchors.top: parent.top
412 anchors.bottom: parent.bottom
413 anchors.right: parent.left
415 width: shell.edgeSize
416 direction: Direction.Leftwards
417 enabled: greeter.showProgress == 0 && edgeDemo.dashEnabled
418 property bool haveApps: mainStage.applications.count > 0 || sideStage.applications.count > 0
420 maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
421 // Make autocompletion impossible when !haveApps
422 edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
429 objectName: "lockscreen"
431 readonly property int backgroundTopMargin: -panel.panelHeight
433 hides: [launcher, panel.indicators, hud]
436 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
437 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
439 x: required ? 0 : - width
441 height: parent.height - panel.panelHeight
442 background: shell.background
445 onEntered: LightDM.Greeter.respond(passphrase);
446 onCancel: greeter.show()
448 Component.onCompleted: {
449 if (LightDM.Users.count == 1) {
450 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
457 target: LightDM.Greeter
460 if (LightDM.Users.count == 1) {
461 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
463 lockscreen.alphaNumeric = false
465 lockscreen.alphaNumeric = true
467 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
472 onAuthenticationComplete: {
473 if (LightDM.Greeter.promptless) {
476 if (LightDM.Greeter.authenticated) {
479 lockscreen.clear(true);
486 objectName: "greeter"
489 hides: [launcher, panel.indicators, hud]
492 defaultBackground: shell.background
496 height: parent.height - panel.panelHeight
498 dragHandleWidth: shell.edgeSize
500 property var previousMainApp: null
501 property var previousSideApp: null
503 function removeApplicationFocus() {
504 greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
505 if (sideStage.fullyShown) { // if side stage hidden, don't focus it on restore
506 greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
508 applicationManager.unfocusCurrentApplication();
511 function restoreApplicationFocus() {
512 if (greeter.previousMainApp) {
513 applicationManager.focusApplication(greeter.previousMainApp);
514 greeter.previousMainApp = null;
516 if (greeter.previousSideApp) {
517 applicationManager.focusApplication(greeter.previousSideApp);
518 greeter.previousSideApp = null;
525 // If there is only one user, we start authenticating with that one here.
526 // If there are more users, the Greeter will handle that
527 if (LightDM.Users.count == 1) {
528 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
531 greeter.forceActiveFocus();
532 removeApplicationFocus();
534 restoreApplicationFocus();
538 onUnlocked: greeter.hide()
540 // Update launcher items for new user
541 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);
542 AccountsService.user = user;
543 LauncherModel.setUser(user);
546 onLeftTeaserPressedChanged: {
547 if (leftTeaserPressed) {
553 target: applicationManager
554 ignoreUnknownSignals: true
555 // If any app is focused when greeter is open, it's due to a user action
556 // like a snap decision (say, an incoming call).
557 // TODO: these should be protected to only unlock for certain applications / certain usecases
558 // potentially only in connection with a notification.
559 onMainStageFocusedApplicationChanged: {
560 if (greeter.shown && applicationManager.mainStageFocusedApplication) {
561 greeter.previousMainApp = null // make way for new focused app
562 greeter.previousSideApp = null
566 onSideStageFocusedApplicationChanged: {
567 if (greeter.shown && applicationManager.sideStageFocusedApplication) {
568 greeter.previousMainApp = null // make way for new focused app
569 greeter.previousSideApp = null
578 if (applicationManager.sideStageFocusedApplication)
579 return parent.width - sideStage.width;
583 height: parent.height
584 blockInput: !applicationManager.mainStageFocusedApplication || greeter.shown || lockscreen.shown || launcher.shown
585 || panel.indicators.shown || hud.shown
592 onDisplayPowerStateChange: {
593 // We ignore any display-off signals when the proximity sensor
594 // is active. This usually indicates something like a phone call.
595 if (status == Powerd.Off && (flags & Powerd.UseProximity) == 0) {
599 // No reason to chew demo CPU when user isn't watching
600 if (status == Powerd.Off) {
601 edgeDemo.paused = true;
602 } else if (status == Powerd.On) {
603 edgeDemo.paused = false;
608 function showHome() {
609 var animate = !greeter.shown && !stages.shown
611 dash.setCurrentScope("clickscope", animate, false)
615 function hideIndicatorMenu(delay) {
616 panel.hideIndicatorMenu(delay);
626 anchors.fill: parent //because this draws indicator menus
627 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
630 available: edgeDemo.panelEnabled
631 contentEnabled: edgeDemo.panelContentEnabled
633 fullscreenMode: shell.fullscreenMode
634 searchVisible: !greeter.shown && !lockscreen.shown && dash.shown
642 height: (panel.fullscreenMode) ? shell.edgeSize : panel.panelHeight
650 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
651 height: parent.height
653 available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown && edgeDemo.dashEnabled
655 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
656 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
659 target: shell.applicationManager
660 onMainStageFocusedApplicationChanged: hud.hide()
661 onSideStageFocusedApplicationChanged: hud.hide()
670 anchors.left: hud.left
671 height: parent.height
672 target: hud.revealerTarget
675 direction: Qt.RightToLeft
676 orientation: Qt.Vertical
677 handleSize: hud.handleHeight
678 onCloseClicked: target.hide()
685 enabled: hud.available
686 applicationIsOnForeground: applicationFocused
690 blockInput: launcher.shown
693 bottom: parent.bottom
696 width: launcher.width
702 readonly property bool dashSwipe: progress > 0
704 anchors.top: parent.top
705 anchors.bottom: parent.bottom
707 dragAreaWidth: shell.edgeSize
708 available: (!greeter.shown || greeter.narrowMode) && edgeDemo.launcherEnabled
711 if (edgeDemo.running)
722 onDashSwipeChanged: if (dashSwipe && stages.shown) dash.setCurrentScope("clickscope", false, true)
723 onLauncherApplicationSelected:{
724 if (edgeDemo.running)
728 shell.activateApplication(appId)
732 panel.indicators.hide()
742 model: NotificationBackend.Model
748 bottom: parent.bottom
749 topMargin: panel.panelHeight
754 when: overlay.width <= units.gu(60)
755 AnchorChanges { target: notifications; anchors.left: parent.left }
759 when: overlay.width > units.gu(60)
760 AnchorChanges { target: notifications; anchors.left: undefined }
761 PropertyChanges { target: notifications; width: units.gu(38) }
766 anchors { left: parent.left; right: parent.right }
767 height: parent.contentHeight
768 blockInput: height > 0
774 onFocusChanged: if (!focus) forceActiveFocus();
779 bottom: parent.bottom
782 width: shell.edgeSize
789 bottom: parent.bottom
792 width: shell.edgeSize
803 anchors.centerIn: parent
804 visible: applicationManager.fake
805 text: "EARLY ALPHA\nNOT READY FOR USE"
808 font.weight: Font.Black
809 horizontalAlignment: Text.AlignHCenter
810 verticalAlignment: Text.AlignVCenter
811 fontSizeMode: Text.Fit
813 scale: Math.min(parent.width, parent.height) / width
821 indicators: panel.indicators
826 target: SessionBroadcast
827 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