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
34import Unity.Notifications 1.0 as NotificationBackend
39 // this is only here to select the width / height of the window if not running fullscreen
40 property bool tablet: false
41 width: tablet ? units.gu(160) : applicationArguments.hasGeometry() ? applicationArguments.width() : units.gu(40)
42 height: tablet ? units.gu(100) : applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(71)
44 property real edgeSize: units.gu(2)
45 property url defaultBackground: Qt.resolvedUrl(shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg")
46 property url background
47 readonly property real panelHeight: panel.panelHeight
49 property bool dashShown: dash.shown
50 property bool stageScreenshotsReady: {
51 if (sideStage.shown) {
52 if (mainStage.applications.count > 0) {
53 return mainStage.usingScreenshots && sideStage.usingScreenshots;
55 return sideStage.usingScreenshots;
58 return mainStage.usingScreenshots;
62 property var applicationManager: ApplicationManagerWrapper {}
66 property: "applicationManager"
67 value: ApplicationManager
70 Component.onCompleted: {
71 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
73 applicationManager.sideStageEnabled = Qt.binding(function() { return sideStage.enabled })
75 // FIXME: if application focused before shell starts, shell draws on top of it only.
76 // We should detect already running applications on shell start and bring them to the front.
77 applicationManager.unfocusCurrentApplication();
80 readonly property bool applicationFocused: !!applicationManager.mainStageFocusedApplication
81 || !!applicationManager.sideStageFocusedApplication
82 // Used for autopilot testing.
83 readonly property string currentFocusedAppId: ApplicationManager.focusedApplicationId
85 readonly property bool fullscreenMode: {
86 if (greeter.shown || lockscreen.shown) {
88 } else if (mainStage.usingScreenshots) { // Window Manager animating so want to re-evaluate fullscreen mode
89 return mainStage.switchingFromFullscreenToFullscreen;
90 } else if (applicationManager.mainStageFocusedApplication) {
91 return applicationManager.mainStageFocusedApplication.fullscreen;
97 function activateApplication(appId, argument) {
98 if (applicationManager) {
99 // For newly started applications, as it takes them time to draw their first frame
100 // we add a delay before we hide the animation screenshots to compensate.
101 var addDelay = !applicationManager.getApplicationFromDesktopFile(appId);
104 application = applicationManager.activateApplication(appId, argument);
105 if (application == null) {
108 if (application.stage == ApplicationInfo.MainStage || !sideStage.enabled) {
109 mainStage.activateApplication(appId, addDelay);
111 sideStage.activateApplication(appId, addDelay);
118 id: backgroundSettings
119 schema.id: "org.gnome.desktop.background"
121 property url gSettingsPicture: backgroundSettings.pictureUri != undefined && backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : shell.defaultBackground
122 onGSettingsPictureChanged: {
123 shell.background = gSettingsPicture
130 Keys.onVolumeUpPressed: volumeControl.volumeUp()
131 Keys.onVolumeDownPressed: volumeControl.volumeDown()
135 objectName: "underlay"
138 // Whether the underlay is fully covered by opaque UI elements.
139 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
141 readonly property bool applicationRunning: ((mainStage.applications && mainStage.applications.count > 0)
142 || (sideStage.applications && sideStage.applications.count > 0))
144 // Whether the user should see the topmost application surface (if there's one at all).
145 readonly property bool applicationSurfaceShouldBeSeen: applicationRunning && !stages.fullyHidden
146 && !mainStage.usingScreenshots // but want sideStage animating over app surface
150 // NB! Application surfaces are stacked behing the shell one. So they can only be seen by the user
151 // through the translucent parts of the shell surface.
152 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
157 opacity: dash.disappearingAnimationProgress
162 source: shell.width > shell.height ? "Dash/graphics/paper_landscape.png" : "Dash/graphics/paper_portrait.png"
163 fillMode: Image.PreserveAspectCrop
164 horizontalAlignment: Image.AlignRight
165 verticalAlignment: Image.AlignTop
172 available: !greeter.shown && !lockscreen.shown
173 hides: [stages, launcher, panel.indicators]
174 shown: disappearingAnimationProgress !== 1.0
175 enabled: disappearingAnimationProgress === 0.0 && edgeDemo.dashEnabled
176 // FIXME: unfocus all applications when going back to the dash
179 shell.applicationManager.unfocusCurrentApplication()
185 topMargin: panel.panelHeight
188 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
189 opacity: 1.0 - disappearingAnimationProgress
190 property real disappearingAnimationProgress: {
192 return greeter.showProgress;
194 return stagesOuterContainer.showProgress;
198 // FIXME: only necessary because stagesOuterContainer.showProgress and
199 // greeterRevealer.animatedProgress are not animated
200 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
205 id: stagesOuterContainer
208 height: parent.height
210 Behavior on x {SmoothedAnimation{velocity: 600}}
212 property real showProgress:
213 MathUtils.clamp(1 - (x + stages.x) / shell.width, 0, 1)
221 property bool fullyShown: shown && x == 0 && parent.x == 0
222 property bool fullyHidden: !shown && x == width
223 available: !greeter.shown
224 hides: [panel.indicators]
227 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
228 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
231 height: parent.height
233 // close the stages when no focused application remains
235 target: shell.applicationManager
236 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
237 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
238 ignoreUnknownSignals: true
241 function closeIfNoApplications() {
242 if (!shell.applicationManager.mainStageFocusedApplication
243 && !shell.applicationManager.sideStageFocusedApplication
244 && shell.applicationManager.mainStageApplications.count == 0
245 && shell.applicationManager.sideStageApplications.count == 0) {
250 // show the stages when an application gets the focus
252 target: shell.applicationManager
253 onMainStageFocusedApplicationChanged: {
254 if (shell.applicationManager.mainStageFocusedApplication) {
259 onSideStageFocusedApplicationChanged: {
260 if (shell.applicationManager.sideStageFocusedApplication) {
265 ignoreUnknownSignals: true
272 fullyShown: stages.fullyShown
273 fullyHidden: stages.fullyHidden
274 shouldUseScreenshots: !fullyShown
275 rightEdgeEnabled: !sideStage.enabled
277 applicationManager: shell.applicationManager
278 rightEdgeDraggingAreaWidth: shell.edgeSize
279 normalApplicationY: shell.panelHeight
288 // FIXME: workaround the fact that focusing a main stage application
289 // raises its surface on top of all other surfaces including the ones
290 // that belong to side stage applications.
291 onFocusedApplicationChanged: {
292 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
293 shell.applicationManager.focusApplication(sideStage.focusedApplication);
301 applicationManager: shell.applicationManager
302 rightEdgeDraggingAreaWidth: shell.edgeSize
303 normalApplicationY: shell.panelHeight
306 if (!shown && mainStage.applications.count == 0) {
310 // FIXME: when hiding the side stage, refocus the main stage
311 // application so that it goes in front of the side stage
312 // application and hides it
313 onFullyShownChanged: {
314 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
315 shell.applicationManager.focusApplication(mainStage.focusedApplication);
319 enabled: shell.width >= units.gu(100)
321 fullyShown: stages.fullyShown && shown
322 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
323 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
325 available: !greeter.shown && !lockscreen.shown && enabled
326 hides: [launcher, panel.indicators]
328 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
329 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
332 height: stages.height
333 handleExpanded: sideStageRevealer.pressed
337 id: sideStageRevealer
339 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
340 && sideStage.available
341 direction: Qt.RightToLeft
342 openedValue: parent.width - sideStage.width
343 hintDisplacement: units.gu(3)
344 /* The size of the sidestage handle needs to be bigger than the
345 typical size used for edge detection otherwise it is really
348 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
349 closedValue: parent.width + sideStage.handleSizeCollapsed
351 x: parent.width - width
352 width: sideStage.width + handleSize * 0.7
353 height: sideStage.height
354 orientation: Qt.Horizontal
360 anchors.top: parent.top
361 anchors.bottom: parent.bottom
362 anchors.right: parent.left
364 width: shell.edgeSize
365 direction: Direction.Leftwards
366 enabled: greeter.showProgress == 0 && edgeDemo.dashEnabled
367 property bool haveApps: mainStage.applications.count > 0 || sideStage.applications.count > 0
369 maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
370 // Make autocompletion impossible when !haveApps
371 edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
378 objectName: "lockscreen"
380 readonly property int backgroundTopMargin: -panel.panelHeight
382 hides: [launcher, panel.indicators]
385 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
386 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
388 x: required ? 0 : - width
390 height: parent.height - panel.panelHeight
391 background: shell.background
394 onEntered: LightDM.Greeter.respond(passphrase);
395 onCancel: greeter.show()
397 Component.onCompleted: {
398 if (LightDM.Users.count == 1) {
399 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
405 target: LightDM.Greeter
408 if (LightDM.Users.count == 1) {
409 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
411 lockscreen.alphaNumeric = false
413 lockscreen.alphaNumeric = true
415 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
420 onAuthenticationComplete: {
421 if (LightDM.Greeter.promptless) {
424 if (LightDM.Greeter.authenticated) {
427 lockscreen.clear(true);
434 objectName: "greeter"
437 hides: [launcher, panel.indicators]
440 defaultBackground: shell.background
444 height: parent.height - panel.panelHeight
446 dragHandleWidth: shell.edgeSize
448 property var previousMainApp: null
449 property var previousSideApp: null
451 function removeApplicationFocus() {
452 greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
453 greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
454 applicationManager.unfocusCurrentApplication();
457 function restoreApplicationFocus() {
458 if (greeter.previousMainApp) {
459 applicationManager.focusApplication(greeter.previousMainApp);
460 greeter.previousMainApp = null;
462 if (greeter.previousSideApp) {
463 applicationManager.focusApplication(greeter.previousSideApp);
464 greeter.previousSideApp = null;
471 // If there is only one user, we start authenticating with that one here.
472 // If there are more users, the Greeter will handle that
473 if (LightDM.Users.count == 1) {
474 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
476 greeter.forceActiveFocus();
477 removeApplicationFocus();
479 restoreApplicationFocus();
483 onUnlocked: greeter.hide()
485 // Update launcher items for new user
486 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);
487 AccountsService.user = user;
488 LauncherModel.setUser(user);
491 onLeftTeaserPressedChanged: {
492 if (leftTeaserPressed) {
498 target: applicationManager
499 ignoreUnknownSignals: true
500 // If any app is focused when greeter is open, it's due to a user action
501 // like a snap decision (say, an incoming call).
502 // TODO: these should be protected to only unlock for certain applications / certain usecases
503 // potentially only in connection with a notification.
504 onMainStageFocusedApplicationChanged: {
505 if (greeter.shown && applicationManager.mainStageFocusedApplication) {
506 greeter.previousMainApp = null // make way for new focused app
507 greeter.previousSideApp = null
511 onSideStageFocusedApplicationChanged: {
512 if (greeter.shown && applicationManager.sideStageFocusedApplication) {
513 greeter.previousMainApp = null // make way for new focused app
514 greeter.previousSideApp = null
523 blockInput: !applicationFocused || greeter.shown || lockscreen.shown || launcher.shown
524 || panel.indicators.shown
531 onDisplayPowerStateChange: {
532 // We ignore any display-off signals when the proximity sensor
533 // is active. This usually indicates something like a phone call.
534 if (status == Powerd.Off && (flags & Powerd.UseProximity) == 0) {
538 // No reason to chew demo CPU when user isn't watching
539 if (status == Powerd.Off) {
540 edgeDemo.paused = true;
541 } else if (status == Powerd.On) {
542 edgeDemo.paused = false;
547 function showHome() {
548 var animate = !greeter.shown && !stages.shown
550 dash.setCurrentScope("clickscope", animate, false)
554 function hideIndicatorMenu(delay) {
555 panel.hideIndicatorMenu(delay);
565 anchors.fill: parent //because this draws indicator menus
566 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
569 available: edgeDemo.panelEnabled
570 contentEnabled: edgeDemo.panelContentEnabled
572 fullscreenMode: shell.fullscreenMode
573 searchVisible: !greeter.shown && !lockscreen.shown && dash.shown && dash.searchable
581 height: (panel.fullscreenMode) ? shell.edgeSize : panel.panelHeight
587 blockInput: launcher.shown
590 bottom: parent.bottom
593 width: launcher.width
599 readonly property bool dashSwipe: progress > 0
601 anchors.top: parent.top
602 anchors.bottom: parent.bottom
604 dragAreaWidth: shell.edgeSize
605 available: (!greeter.shown || greeter.narrowMode) && edgeDemo.launcherEnabled
608 if (edgeDemo.running)
619 onDashSwipeChanged: if (dashSwipe && stages.shown) dash.setCurrentScope("clickscope", false, true)
620 onLauncherApplicationSelected:{
621 if (edgeDemo.running)
625 shell.activateApplication(appId)
629 panel.indicators.hide()
637 model: NotificationBackend.Model
643 bottom: parent.bottom
644 topMargin: panel.panelHeight
649 when: overlay.width <= units.gu(60)
650 AnchorChanges { target: notifications; anchors.left: parent.left }
654 when: overlay.width > units.gu(60)
655 AnchorChanges { target: notifications; anchors.left: undefined }
656 PropertyChanges { target: notifications; width: units.gu(38) }
661 anchors { left: parent.left; right: parent.right }
662 height: parent.contentHeight
663 blockInput: height > 0
669 onFocusChanged: if (!focus) forceActiveFocus();
674 bottom: parent.bottom
677 width: shell.edgeSize
684 bottom: parent.bottom
687 width: shell.edgeSize
698 anchors.topMargin: panel.panelHeight
699 anchors.fill: parent // as needs to know the geometry of the shell
702 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
704 anchors.bottom: parent.bottom
705 anchors.left: parent.left
706 anchors.right: parent.right
707 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
709 enabled: shell.applicationManager && shell.applicationManager.keyboardVisible
713 anchors.centerIn: parent
714 visible: applicationManager.fake
715 text: "EARLY ALPHA\nNOT READY FOR USE"
718 font.weight: Font.Black
719 horizontalAlignment: Text.AlignHCenter
720 verticalAlignment: Text.AlignVCenter
721 fontSizeMode: Text.Fit
723 scale: Math.min(parent.width, parent.height) / width
731 indicators: panel.indicators
736 target: SessionBroadcast
737 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