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/>.
19import Ubuntu.Application 0.1
20import Ubuntu.Components 0.1
21import Ubuntu.Gestures 0.1
22import LightDM 0.1 as LightDM
23import AccountsService 0.1
31import "Components/Math.js" as MathLocal
35import Unity.Notifications 1.0 as NotificationBackend
40 // this is only here to select the width / height of the window if not running fullscreen
41 property bool tablet: false
42 width: tablet ? units.gu(160) : applicationArguments.hasGeometry() ? applicationArguments.width() : units.gu(40)
43 height: tablet ? units.gu(100) : applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(71)
45 property real edgeSize: units.gu(2)
46 property url defaultBackground: shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg"
47 property url background
48 readonly property real panelHeight: panel.panelHeight
50 property bool dashShown: dash.shown
51 property bool stageScreenshotsReady: {
52 if (sideStage.shown) {
53 if (mainStage.applications.count > 0) {
54 return mainStage.usingScreenshots && sideStage.usingScreenshots;
56 return sideStage.usingScreenshots;
59 return mainStage.usingScreenshots;
63 property bool showEdgeDemo: false
64 property bool showEdgeDemoInGreeter: showEdgeDemo //AccountsService.getUserProperty("lightdm", "demo-edges")
66 function hideEdgeDemo() {
67 var user = LightDM.Users.data(greeter.currentIndex, LightDM.UserRoles.NameRole);
68 AccountsService.setUserProperty(user, "demo-edges", false);
69 shell.showEdgeDemo = false;
71 function hideEdgeDemoInGreeter() {
72 //AccountsService.setUserProperty("lightdm", "demo-edges", false);
73 shell.showEdgeDemoInGreeter = false;
76 property ListModel searchHistory: SearchHistoryModel {}
78 property var applicationManager: ApplicationManagerWrapper {}
80 Component.onCompleted: {
81 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
83 applicationManager.sideStageEnabled = Qt.binding(function() { return sideStage.enabled })
85 // FIXME: if application focused before shell starts, shell draws on top of it only.
86 // We should detect already running applications on shell start and bring them to the front.
87 applicationManager.unfocusCurrentApplication();
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;
103 target: applicationManager
104 ignoreUnknownSignals: true
106 // TODO: this should be protected to only unlock for certain applications / certain usecases
107 // potentially only in connection with a notification
109 shell.activateApplication(desktopFile);
113 function activateApplication(desktopFile, argument) {
114 if (applicationManager) {
115 // For newly started applications, as it takes them time to draw their first frame
116 // we add a delay before we hide the animation screenshots to compensate.
117 var addDelay = !applicationManager.getApplicationFromDesktopFile(desktopFile);
120 application = applicationManager.activateApplication(desktopFile, argument);
121 if (application == null) {
124 if (application.stage == ApplicationInfo.MainStage || !sideStage.enabled) {
125 mainStage.activateApplication(desktopFile, addDelay);
127 sideStage.activateApplication(desktopFile, addDelay);
134 id: backgroundSettings
135 schema.id: "org.gnome.desktop.background"
137 property url gSettingsPicture: backgroundSettings.pictureUri != undefined && backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : shell.defaultBackground
138 onGSettingsPictureChanged: {
139 shell.background = gSettingsPicture
142 // This is a dummy image that is needed to determine if the picture url
143 // in backgroundSettings points to a valid picture file.
144 // We can't do this with the real background image because setting a
145 // new source in onStatusChanged triggers a binding loop detection
146 // inside Image, which causes it not to render even though a valid source
147 // would be set. We don't mind about this image staying black and just
148 // use it for verification to populate the source for the real
151 source: shell.background
157 if (status == Image.Error && source != shell.defaultBackground) {
158 shell.background = defaultBackground
167 Keys.onVolumeUpPressed: volumeControl.volumeUp()
168 Keys.onVolumeDownPressed: volumeControl.volumeDown()
172 objectName: "underlay"
175 // Whether the underlay is fully covered by opaque UI elements.
176 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
178 // Whether the user should see the topmost application surface (if there's one at all).
179 property bool applicationSurfaceShouldBeSeen:
180 (mainStage.applications && mainStage.applications.count > 0)
181 && (!stages.fullyHidden && !mainStage.usingScreenshots)
183 // NB! Application surfaces are stacked behing the shell one. So they can only be seen by the user
184 // through the translucent parts of the shell surface.
185 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
189 objectName: "backgroundImage"
192 source: shell.background
198 opacity: dash.disappearingAnimationProgress
205 available: !greeter.shown && !lockscreen.shown
206 hides: [stages, launcher, panel.indicators]
207 shown: disappearingAnimationProgress !== 1.0
208 enabled: disappearingAnimationProgress === 0.0 && !leftEdgeDemo.active && !topEdgeDemo.active && !finalEdgeDemo.active
209 // FIXME: unfocus all applications when going back to the dash
212 shell.applicationManager.unfocusCurrentApplication()
218 topMargin: panel.panelHeight
221 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
222 opacity: 1.0 - disappearingAnimationProgress
223 property real disappearingAnimationProgress: {
225 return greeter.showProgress;
227 return stagesOuterContainer.showProgress;
231 // FIXME: only necessary because stagesOuterContainer.showProgress and
232 // greeterRevealer.animatedProgress are not animated
233 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
240 title: i18n.tr("Top edge")
241 text: i18n.tr("Try swiping from the top edge to access the indicators")
244 available: shell.showEdgeDemo
245 onSkip: shell.hideEdgeDemo()
249 onShownChanged: if (!greeter.shown) topEdgeDemo.show()
253 target: panel.indicators
254 onFullyOpenedChanged: if (panel.indicators.fullyOpened) topEdgeDemo.hideNow()
262 title: i18n.tr("Left edge")
263 text: i18n.tr("Swipe from the left to reveal the launcher for quick access to apps")
266 available: shell.showEdgeDemo
267 onSkip: shell.hideEdgeDemo()
270 target: bottomEdgeDemo
271 onActiveChanged: if (!bottomEdgeDemo.active) leftEdgeDemo.show()
276 onStateChanged: if (launcher.state == "visible") leftEdgeDemo.hide()
282 id: stagesOuterContainer
285 height: parent.height
287 Behavior on x {SmoothedAnimation{velocity: 600}}
289 property real showProgress:
290 MathLocal.clamp(1 - (x + stages.x) / shell.width, 0, 1)
298 property bool fullyShown: shown && x == 0 && parent.x == 0
299 property bool fullyHidden: !shown && x == width
300 available: !greeter.shown
301 hides: [launcher, panel.indicators]
304 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
305 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
308 height: parent.height
310 // close the stages when no focused application remains
312 target: shell.applicationManager
313 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
314 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
315 ignoreUnknownSignals: true
318 function closeIfNoApplications() {
319 if (!shell.applicationManager.mainStageFocusedApplication
320 && !shell.applicationManager.sideStageFocusedApplication
321 && shell.applicationManager.mainStageApplications.count == 0
322 && shell.applicationManager.sideStageApplications.count == 0) {
327 // show the stages when an application gets the focus
329 target: shell.applicationManager
330 onMainStageFocusedApplicationChanged: {
331 if (shell.applicationManager.mainStageFocusedApplication) {
336 onSideStageFocusedApplicationChanged: {
337 if (shell.applicationManager.sideStageFocusedApplication) {
342 ignoreUnknownSignals: true
349 fullyShown: stages.fullyShown
350 fullyHidden: stages.fullyHidden
351 shouldUseScreenshots: !fullyShown
352 rightEdgeEnabled: !sideStage.enabled
354 applicationManager: shell.applicationManager
355 rightEdgeDraggingAreaWidth: shell.edgeSize
356 normalApplicationY: shell.panelHeight
365 // FIXME: workaround the fact that focusing a main stage application
366 // raises its surface on top of all other surfaces including the ones
367 // that belong to side stage applications.
368 onFocusedApplicationChanged: {
369 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
370 shell.applicationManager.focusApplication(sideStage.focusedApplication);
378 applicationManager: shell.applicationManager
379 rightEdgeDraggingAreaWidth: shell.edgeSize
380 normalApplicationY: shell.panelHeight
383 if (!shown && mainStage.applications.count == 0) {
387 // FIXME: when hiding the side stage, refocus the main stage
388 // application so that it goes in front of the side stage
389 // application and hides it
390 onFullyShownChanged: {
391 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
392 shell.applicationManager.focusApplication(mainStage.focusedApplication);
396 enabled: shell.width >= units.gu(60)
398 fullyShown: stages.fullyShown && shown
399 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
400 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
402 available: !greeter.shown && !lockscreen.shown && enabled
403 hides: [launcher, panel.indicators]
405 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
406 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
409 height: stages.height
410 handleExpanded: sideStageRevealer.pressed
414 id: sideStageRevealer
416 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
417 && sideStage.available
418 direction: Qt.RightToLeft
419 openedValue: parent.width - sideStage.width
420 hintDisplacement: units.gu(3)
421 /* The size of the sidestage handle needs to be bigger than the
422 typical size used for edge detection otherwise it is really
425 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
426 closedValue: parent.width + sideStage.handleSizeCollapsed
428 x: parent.width - width
429 width: sideStage.width + handleSize * 0.7
430 height: sideStage.height
431 orientation: Qt.Horizontal
437 anchors.top: parent.top
438 anchors.bottom: parent.bottom
439 anchors.right: parent.left
441 width: shell.edgeSize
442 direction: Direction.Leftwards
443 property bool haveApps: mainStage.applications.count > 0 || sideStage.applications.count > 0
445 maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
446 // Make autocompletion impossible when !haveApps
447 edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
454 hides: [launcher, panel.indicators, hud]
457 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
458 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
460 x: required ? 0 : - width
462 height: parent.height - panel.panelHeight
463 background: shell.background
465 onUnlocked: lockscreen.hide()
466 onCancel: greeter.show()
468 Component.onCompleted: {
469 if (LightDM.Users.count == 1) {
470 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
477 target: LightDM.Greeter
480 if (LightDM.Users.count == 1) {
481 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
483 lockscreen.alphaNumeric = false
485 lockscreen.alphaNumeric = true
487 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
495 objectName: "greeter"
498 hides: [launcher, panel.indicators, hud]
503 height: parent.height - panel.panelHeight
505 dragHandleWidth: shell.edgeSize
510 // If there is only one user, we start authenticating with that one here.
511 // If there are more users, the Greeter will handle that
512 if (LightDM.Users.count == 1) {
513 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
516 greeter.forceActiveFocus();
520 onUnlocked: greeter.hide()
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
542 shell.hideEdgeDemoInGreeter()
550 if (rightEdgeDemo.active) {
552 shell.hideEdgeDemoInGreeter()
557 onShownChanged: if (!greeter.shown) hide()
564 blockInput: greeter.shown || lockscreen.shown
571 property var previousMainApp: null
572 property var previousSideApp: null
574 function setFocused(focused) {
576 // FIXME: *FocusedApplication are not updated when unfocused, hence the need to check whether
577 // the stage was actually shown
578 if (mainStage.fullyShown) powerConnection.previousMainApp = applicationManager.mainStageFocusedApplication;
579 if (sideStage.fullyShown) powerConnection.previousSideApp = applicationManager.sideStageFocusedApplication;
580 applicationManager.unfocusCurrentApplication();
582 if (powerConnection.previousMainApp) {
583 applicationManager.focusApplication(powerConnection.previousMainApp);
584 powerConnection.previousMainApp = null;
586 if (powerConnection.previousSideApp) {
587 applicationManager.focusApplication(powerConnection.previousSideApp);
588 powerConnection.previousSideApp = null;
593 onDisplayPowerStateChange: {
594 // We ignore any display-off signals when the proximity sensor
595 // is active. This usually indicates something like a phone call.
596 if (status == Powerd.Off && (flags & Powerd.UseProximity) == 0) {
597 powerConnection.setFocused(false);
599 } else if (status == Powerd.On) {
600 powerConnection.setFocused(true);
612 anchors.fill: parent //because this draws indicator menus
613 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
616 available: !rightEdgeDemo.active && !leftEdgeDemo.active && !finalEdgeDemo.active
618 fullscreenMode: shell.fullscreenMode
619 searchVisible: !greeter.shown && !lockscreen.shown
623 blockInput: panel.indicators.shown
630 title: i18n.tr("Close")
631 text: i18n.tr("Swipe up again to close the settings screen")
632 anchors.fill: panel.indicators
634 available: shell.showEdgeDemo
635 onSkip: shell.hideEdgeDemo()
638 target: panel.indicators
639 onFullyOpenedChanged: if (panel.indicators.fullyOpened) bottomEdgeDemo.show()
640 onPartiallyOpenedChanged: if (!panel.indicators.partiallyOpened && !panel.indicators.fullyOpened) bottomEdgeDemo.hideNow()
648 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
649 height: parent.height
651 available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown && !topEdgeDemo.active
653 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
654 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
657 target: shell.applicationManager
658 onMainStageFocusedApplicationChanged: hud.hide()
659 onSideStageFocusedApplicationChanged: hud.hide()
664 blockInput: hud.shown
673 anchors.left: hud.left
674 height: parent.height
675 target: hud.revealerTarget
678 direction: Qt.RightToLeft
679 orientation: Qt.Vertical
680 handleSize: hud.handleHeight
681 onCloseClicked: target.hide()
687 enabled: !panel.indicators.shown
688 applicationIsOnForeground: applicationManager.mainStageFocusedApplication
689 || applicationManager.sideStageFocusedApplication
693 blockInput: launcher.shown
696 bottom: parent.bottom
699 width: launcher.width
705 anchors.top: parent.top
706 anchors.bottom: parent.bottom
708 dragAreaWidth: shell.edgeSize
709 available: (!greeter.shown || greeter.narrowMode) && !rightEdgeDemo.active && !topEdgeDemo.active && !bottomEdgeDemo.active && !finalEdgeDemo.active
710 onDashItemSelected: {
712 // Animate if moving between application and dash
714 dash.setCurrentScope("home.scope", true, false)
716 dash.setCurrentScope("home.scope", false, false)
722 dash.setCurrentScope("applications.scope", true, false)
727 onLauncherApplicationSelected:{
729 shell.activateApplication(desktopFile)
733 panel.indicators.hide()
742 model: NotificationBackend.Model
746 bottom: parent.bottom
747 leftMargin: units.gu(1)
748 rightMargin: units.gu(1)
749 topMargin: panel.panelHeight + units.gu(1)
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) }
771 title: i18n.tr("Well done")
772 text: i18n.tr("You have now mastered the edge gestures and can start using the phone")
773 skipText: i18n.tr("Finish")
774 anchors.fill: overlay
776 available: shell.showEdgeDemo
777 onSkip: shell.hideEdgeDemo()
782 if (leftEdgeDemo.active && !leftEdgeDemo.shown) {
783 finalEdgeDemo.show();
795 bottom: parent.bottom
798 width: shell.edgeSize
805 bottom: parent.bottom
808 width: shell.edgeSize
818 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
820 anchors.bottom: parent.bottom
821 anchors.left: parent.left
822 anchors.right: parent.right
823 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
825 enabled: shell.applicationManager && shell.applicationManager.keyboardVisible
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
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