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 Ubuntu.Application 0.1
19import Ubuntu.Components 0.1
20import Ubuntu.Gestures 0.1
21import LightDM 0.1 as LightDM
22import AccountsService 0.1
29import "Components/Math.js" as MathLocal
33import Unity.Notifications 1.0 as NotificationBackend
38 // this is only here to select the width / height of the window if not running fullscreen
39 property bool tablet: false
40 width: tablet ? units.gu(160) : applicationArguments.hasGeometry() ? applicationArguments.width() : units.gu(40)
41 height: tablet ? units.gu(100) : applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(71)
43 property real edgeSize: units.gu(2)
44 property url default_background: shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg"
45 property url background: default_background
46 readonly property real panelHeight: panel.panelHeight
48 property bool dashShown: dash.shown
49 property bool stageScreenshotsReady: {
50 if (sideStage.shown) {
51 if (mainStage.applications.count > 0) {
52 return mainStage.usingScreenshots && sideStage.usingScreenshots;
54 return sideStage.usingScreenshots;
57 return mainStage.usingScreenshots;
61 property bool showEdgeDemo: true
62 property bool showEdgeDemoInGreeter: showEdgeDemo //AccountsService.getUserProperty("lightdm", "demo-edges")
64 function hideEdgeDemo() {
65 var user = LightDM.Users.data(greeter.currentIndex, LightDM.UserRoles.NameRole);
66 AccountsService.setUserProperty(user, "demo-edges", false);
67 shell.showEdgeDemo = false;
69 function hideEdgeDemoInGreeter() {
70 //AccountsService.setUserProperty("lightdm", "demo-edges", false);
71 shell.showEdgeDemoInGreeter = false;
74 property ListModel searchHistory: SearchHistoryModel {}
76 property var applicationManager: ApplicationManagerWrapper {}
78 Component.onCompleted: {
79 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
81 applicationManager.sideStageEnabled = Qt.binding(function() { return sideStage.enabled })
83 // FIXME: if application focused before shell starts, shell draws on top of it only.
84 // We should detect already running applications on shell start and bring them to the front.
85 applicationManager.unfocusCurrentApplication();
88 readonly property bool fullscreenMode: {
89 if (greeter.shown || lockscreen.shown) {
91 } else if (mainStage.usingScreenshots) { // Window Manager animating so want to re-evaluate fullscreen mode
92 return mainStage.switchingFromFullscreenToFullscreen;
93 } else if (applicationManager.mainStageFocusedApplication) {
94 return applicationManager.mainStageFocusedApplication.fullscreen;
101 target: applicationManager
102 ignoreUnknownSignals: true
104 // TODO: this should be protected to only unlock for certain applications / certain usecases
105 // potentially only in connection with a notification
107 shell.activateApplication(desktopFile);
111 function activateApplication(desktopFile, argument) {
112 if (applicationManager) {
113 // For newly started applications, as it takes them time to draw their first frame
114 // we add a delay before we hide the animation screenshots to compensate.
115 var addDelay = !applicationManager.getApplicationFromDesktopFile(desktopFile);
118 application = applicationManager.activateApplication(desktopFile, argument);
119 if (application == null) {
122 if (application.stage == ApplicationInfo.MainStage || !sideStage.enabled) {
123 mainStage.activateApplication(desktopFile, addDelay);
125 sideStage.activateApplication(desktopFile, addDelay);
135 Keys.onVolumeUpPressed: volumeControl.volumeUp()
136 Keys.onVolumeDownPressed: volumeControl.volumeDown()
139 if (event.key == Qt.Key_PowerOff) {
146 objectName: "underlay"
149 // Whether the underlay is fully covered by opaque UI elements.
150 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
152 // Whether the user should see the topmost application surface (if there's one at all).
153 property bool applicationSurfaceShouldBeSeen:
154 (mainStage.applications && mainStage.applications.count > 0)
155 && (!stages.fullyHidden && !mainStage.usingScreenshots)
157 // NB! Application surfaces are stacked behing the shell one. So they can only be seen by the user
158 // through the translucent parts of the shell surface.
159 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
163 source: shell.background
164 sourceSize.width: parent.width
165 sourceSize.height: parent.height
172 opacity: dash.disappearingAnimationProgress
179 available: !greeter.shown && !lockscreen.shown
180 hides: [stages, launcher, panel.indicators]
181 shown: disappearingAnimationProgress !== 1.0
182 enabled: disappearingAnimationProgress === 0.0 && !leftEdgeDemo.visible && !topEdgeDemo.visible
183 // FIXME: unfocus all applications when going back to the dash
186 shell.applicationManager.unfocusCurrentApplication()
192 topMargin: panel.panelHeight
195 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
196 opacity: 1.0 - disappearingAnimationProgress
197 property real disappearingAnimationProgress: {
199 return greeter.showProgress;
201 return stagesOuterContainer.showProgress;
205 // FIXME: only necessary because stagesOuterContainer.showProgress and
206 // greeterRevealer.animatedProgress are not animated
207 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
214 title: i18n.tr("Top edge")
215 text: i18n.tr("Try swiping from the top edge to access the indicators")
218 enabled: shell.showEdgeDemo
219 onSkip: shell.hideEdgeDemo()
223 onShownChanged: if (topEdgeDemo.enabled && !greeter.shown) topEdgeDemo.visible = true
227 target: panel.indicators
228 onFullyOpenedChanged: if (topEdgeDemo.enabled && panel.indicators.fullyOpened) topEdgeDemo.visible = false
236 title: i18n.tr("Left edge")
237 text: i18n.tr("Swipe from the left to reveal the launcher for quick access to apps")
240 enabled: shell.showEdgeDemo
241 onSkip: shell.hideEdgeDemo()
244 target: bottomEdgeDemo
245 onVisibleChanged: if (leftEdgeDemo.enabled && !bottomEdgeDemo.visible) leftEdgeDemo.visible = true
251 if (leftEdgeDemo.enabled && launcher.progress >= 1.0) {
252 leftEdgeDemo.visible = false;
253 shell.hideEdgeDemo();
262 id: stagesOuterContainer
265 height: parent.height
267 Behavior on x {SmoothedAnimation{velocity: 600}}
269 property real showProgress:
270 MathLocal.clamp(1 - (x + stages.x) / shell.width, 0, 1)
278 property bool fullyShown: shown && x == 0 && parent.x == 0
279 property bool fullyHidden: !shown && x == width
280 available: !greeter.shown
281 hides: [launcher, panel.indicators]
284 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
285 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
288 height: parent.height
290 // close the stages when no focused application remains
292 target: shell.applicationManager
293 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
294 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
295 ignoreUnknownSignals: true
298 function closeIfNoApplications() {
299 if (!shell.applicationManager.mainStageFocusedApplication
300 && !shell.applicationManager.sideStageFocusedApplication
301 && shell.applicationManager.mainStageApplications.count == 0
302 && shell.applicationManager.sideStageApplications.count == 0) {
307 // show the stages when an application gets the focus
309 target: shell.applicationManager
310 onMainStageFocusedApplicationChanged: {
311 if (shell.applicationManager.mainStageFocusedApplication) {
316 onSideStageFocusedApplicationChanged: {
317 if (shell.applicationManager.sideStageFocusedApplication) {
322 ignoreUnknownSignals: true
330 fullyShown: stages.fullyShown
331 fullyHidden: stages.fullyHidden
332 shouldUseScreenshots: !fullyShown
333 rightEdgeEnabled: !sideStage.enabled
335 applicationManager: shell.applicationManager
336 rightEdgeDraggingAreaWidth: shell.edgeSize
337 normalApplicationY: shell.panelHeight
346 // FIXME: workaround the fact that focusing a main stage application
347 // raises its surface on top of all other surfaces including the ones
348 // that belong to side stage applications.
349 onFocusedApplicationChanged: {
350 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
351 shell.applicationManager.focusApplication(sideStage.focusedApplication);
359 applicationManager: shell.applicationManager
360 rightEdgeDraggingAreaWidth: shell.edgeSize
361 normalApplicationY: shell.panelHeight
364 if (!shown && mainStage.applications.count == 0) {
368 // FIXME: when hiding the side stage, refocus the main stage
369 // application so that it goes in front of the side stage
370 // application and hides it
371 onFullyShownChanged: {
372 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
373 shell.applicationManager.focusApplication(mainStage.focusedApplication);
377 enabled: shell.width >= units.gu(60)
379 fullyShown: stages.fullyShown && shown
380 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
381 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
383 available: !greeter.shown && !lockscreen.shown && enabled
384 hides: [launcher, panel.indicators]
386 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
387 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
390 height: stages.height
391 handleExpanded: sideStageRevealer.pressed
395 id: sideStageRevealer
397 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
398 && sideStage.available
399 direction: Qt.RightToLeft
400 openedValue: parent.width - sideStage.width
401 hintDisplacement: units.gu(3)
402 /* The size of the sidestage handle needs to be bigger than the
403 typical size used for edge detection otherwise it is really
406 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
407 closedValue: parent.width + sideStage.handleSizeCollapsed
409 x: parent.width - width
410 width: sideStage.width + handleSize * 0.7
411 height: sideStage.height
412 orientation: Qt.Horizontal
418 anchors.top: parent.top
419 anchors.bottom: parent.bottom
420 anchors.right: parent.left
422 width: shell.edgeSize
423 direction: Direction.Leftwards
424 property bool haveApps: mainStage.applications.count > 0 || sideStage.applications.count > 0
426 maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
427 // Make autocompletion impossible when !haveApps
428 edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
435 hides: [launcher, panel.indicators, hud]
438 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
439 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
441 x: required ? 0 : - width
443 height: parent.height - panel.panelHeight
444 background: shell.background
446 onUnlocked: lockscreen.hide()
447 onCancel: greeter.show()
449 Component.onCompleted: {
450 if (LightDM.Users.count == 1) {
451 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
458 target: LightDM.Greeter
461 if (LightDM.Users.count == 1) {
462 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
464 lockscreen.alphaNumeric = false
466 lockscreen.alphaNumeric = true
468 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
478 hides: [launcher, panel.indicators, hud]
483 height: parent.height - panel.panelHeight
485 dragHandleWidth: shell.edgeSize
487 property var previousMainApp: null
488 property var previousSideApp: null
493 // If there is only one user, we start authenticating with that one here.
494 // If there are more users, the Greeter will handle that
495 if (LightDM.Users.count == 1) {
496 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
499 greeter.forceActiveFocus();
500 // FIXME: *FocusedApplication are not updated when unfocused, hence the need to check whether
501 // the stage was actually shown
502 if (mainStage.fullyShown) greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
503 if (sideStage.fullyShown) greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
504 applicationManager.unfocusCurrentApplication();
506 if (greeter.previousMainApp) {
507 applicationManager.focusApplication(greeter.previousMainApp);
508 greeter.previousMainApp = null;
510 if (greeter.previousSideApp) {
511 applicationManager.focusApplication(greeter.previousSideApp);
512 greeter.previousSideApp = null;
517 onUnlocked: greeter.hide()
520 var bgPath = greeter.model.data(uid, LightDM.UserRoles.BackgroundPathRole)
521 shell.background = bgPath ? bgPath : default_background
522 // Update edge demo hint
523 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole)
524 shell.showEdgeDemo = AccountsService.getUserProperty(user, "demo-edges")
527 onLeftTeaserPressedChanged: {
528 if (leftTeaserPressed) {
537 title: i18n.tr("Right edge")
538 text: i18n.tr("Try swiping from the right edge to unlock the phone")
540 visible: shell.showEdgeDemoInGreeter
541 enabled: shell.showEdgeDemoInGreeter
543 shell.hideEdgeDemoInGreeter()
549 onUnlocked: if (rightEdgeDemo.enabled) rightEdgeDemo.visible = false
551 if (rightEdgeDemo.enabled && !greeter.shown) {
552 rightEdgeDemo.visible = false
553 shell.hideEdgeDemoInGreeter()
561 blockInput: greeter.shown || lockscreen.shown
572 anchors.fill: parent //because this draws indicator menus
573 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
576 available: !rightEdgeDemo.visible && !leftEdgeDemo.visible
578 fullscreenMode: shell.fullscreenMode
579 searchVisible: !greeter.shown && !lockscreen.shown
583 blockInput: panel.indicators.shown
590 title: i18n.tr("Close")
591 text: i18n.tr("Swipe up again to close the settings screen")
592 anchors.fill: panel.indicators
594 enabled: shell.showEdgeDemo
595 onSkip: shell.hideEdgeDemo()
598 target: panel.indicators
599 onFullyOpenedChanged: if (bottomEdgeDemo.enabled && panel.indicators.fullyOpened) bottomEdgeDemo.visible = true
600 onPartiallyOpenedChanged: if (bottomEdgeDemo.enabled && !panel.indicators.partiallyOpened && !panel.indicators.fullyOpened) bottomEdgeDemo.visible = false
608 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
609 height: parent.height
611 available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown && !topEdgeDemo.visible
613 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
614 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
617 target: shell.applicationManager
618 onMainStageFocusedApplicationChanged: hud.hide()
619 onSideStageFocusedApplicationChanged: hud.hide()
624 blockInput: hud.shown
633 anchors.left: hud.left
634 height: parent.height
635 target: hud.revealerTarget
638 direction: Qt.RightToLeft
639 orientation: Qt.Vertical
640 handleSize: hud.handleHeight
641 onCloseClicked: target.hide()
647 enabled: !panel.indicators.shown
648 applicationIsOnForeground: applicationManager.mainStageFocusedApplication
649 || applicationManager.sideStageFocusedApplication
653 blockInput: launcher.shown
656 bottom: parent.bottom
659 width: launcher.width
665 anchors.top: parent.top
666 anchors.bottom: parent.bottom
668 dragAreaWidth: shell.edgeSize
669 available: !greeter.locked && !rightEdgeDemo.visible && !topEdgeDemo.visible && !bottomEdgeDemo.visible
670 onDashItemSelected: {
672 // Animate if moving between application and dash
674 dash.setCurrentScope("home.scope", true, false)
676 dash.setCurrentScope("home.scope", false, false)
682 dash.setCurrentScope("applications.scope", true, false)
687 onLauncherApplicationSelected:{
689 shell.activateApplication(desktopFile)
693 panel.indicators.hide()
702 model: NotificationBackend.Model
706 bottom: parent.bottom
707 leftMargin: units.gu(1)
708 rightMargin: units.gu(1)
709 topMargin: panel.panelHeight + units.gu(1)
714 when: overlay.width <= units.gu(60)
715 AnchorChanges { target: notifications; anchors.left: parent.left }
719 when: overlay.width > units.gu(60)
720 AnchorChanges { target: notifications; anchors.left: undefined }
721 PropertyChanges { target: notifications; width: units.gu(38) }
732 bottom: parent.bottom
735 width: shell.edgeSize
742 bottom: parent.bottom
745 width: shell.edgeSize
755 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
757 anchors.bottom: parent.bottom
758 anchors.left: parent.left
759 anchors.right: parent.right
760 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
762 enabled: shell.applicationManager && shell.applicationManager.keyboardVisible
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