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 Unity.Launcher 0.1
23import LightDM 0.1 as LightDM
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 ListModel searchHistory: SearchHistoryModel {}
65 property var applicationManager: ApplicationManagerWrapper {}
67 Component.onCompleted: {
68 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
70 applicationManager.sideStageEnabled = Qt.binding(function() { return sideStage.enabled })
72 // FIXME: if application focused before shell starts, shell draws on top of it only.
73 // We should detect already running applications on shell start and bring them to the front.
74 applicationManager.unfocusCurrentApplication();
77 readonly property bool fullscreenMode: {
78 if (greeter.shown || lockscreen.shown) {
80 } else if (mainStage.usingScreenshots) { // Window Manager animating so want to re-evaluate fullscreen mode
81 return mainStage.switchingFromFullscreenToFullscreen;
82 } else if (applicationManager.mainStageFocusedApplication) {
83 return applicationManager.mainStageFocusedApplication.fullscreen;
90 target: applicationManager
91 ignoreUnknownSignals: true
93 // TODO: this should be protected to only unlock for certain applications / certain usecases
94 // potentially only in connection with a notification
96 shell.activateApplication(desktopFile);
99 onMainStageFocusedApplicationChanged: {
100 var app = applicationManager.mainStageFocusedApplication
101 LauncherModel.applicationFocused(app.desktopFile);
105 function activateApplication(desktopFile, argument) {
106 if (applicationManager) {
107 // For newly started applications, as it takes them time to draw their first frame
108 // we add a delay before we hide the animation screenshots to compensate.
109 var addDelay = !applicationManager.getApplicationFromDesktopFile(desktopFile);
112 application = applicationManager.activateApplication(desktopFile, argument);
113 if (application == null) {
116 if (application.stage == ApplicationInfo.MainStage || !sideStage.enabled) {
117 mainStage.activateApplication(desktopFile, addDelay);
119 sideStage.activateApplication(desktopFile, addDelay);
126 id: backgroundSettings
127 schema.id: "org.gnome.desktop.background"
129 property url gSettingsPicture: backgroundSettings.pictureUri != undefined && backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : shell.defaultBackground
130 onGSettingsPictureChanged: {
131 shell.background = gSettingsPicture
134 // This is a dummy image that is needed to determine if the picture url
135 // in backgroundSettings points to a valid picture file.
136 // We can't do this with the real background image because setting a
137 // new source in onStatusChanged triggers a binding loop detection
138 // inside Image, which causes it not to render even though a valid source
139 // would be set. We don't mind about this image staying black and just
140 // use it for verification to populate the source for the real
143 source: shell.background
149 if (status == Image.Error && source != shell.defaultBackground) {
150 shell.background = defaultBackground
159 Keys.onVolumeUpPressed: volumeControl.volumeUp()
160 Keys.onVolumeDownPressed: volumeControl.volumeDown()
164 objectName: "underlay"
167 // Whether the underlay is fully covered by opaque UI elements.
168 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
170 readonly property bool applicationRunning: ((mainStage.applications && mainStage.applications.count > 0)
171 || (sideStage.applications && sideStage.applications.count > 0))
173 // Whether the user should see the topmost application surface (if there's one at all).
174 readonly property bool applicationSurfaceShouldBeSeen: applicationRunning && !stages.fullyHidden
175 && !mainStage.usingScreenshots // but want sideStage animating over app surface
179 // NB! Application surfaces are stacked behing the shell one. So they can only be seen by the user
180 // through the translucent parts of the shell surface.
181 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
185 objectName: "backgroundImage"
188 source: shell.background
194 opacity: dash.disappearingAnimationProgress
201 available: !greeter.shown && !lockscreen.shown
202 hides: [stages, launcher, panel.indicators]
203 shown: disappearingAnimationProgress !== 1.0
204 enabled: disappearingAnimationProgress === 0.0 && edgeDemo.dashEnabled
205 // FIXME: unfocus all applications when going back to the dash
208 shell.applicationManager.unfocusCurrentApplication()
214 topMargin: panel.panelHeight
217 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
218 opacity: 1.0 - disappearingAnimationProgress
219 property real disappearingAnimationProgress: {
221 return greeter.showProgress;
223 return stagesOuterContainer.showProgress;
227 // FIXME: only necessary because stagesOuterContainer.showProgress and
228 // greeterRevealer.animatedProgress are not animated
229 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
234 id: stagesOuterContainer
237 height: parent.height
239 Behavior on x {SmoothedAnimation{velocity: 600}}
241 property real showProgress:
242 MathLocal.clamp(1 - (x + stages.x) / shell.width, 0, 1)
250 property bool fullyShown: shown && x == 0 && parent.x == 0
251 property bool fullyHidden: !shown && x == width
252 available: !greeter.shown
253 hides: [launcher, panel.indicators]
256 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
257 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
260 height: parent.height
262 // close the stages when no focused application remains
264 target: shell.applicationManager
265 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
266 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
267 ignoreUnknownSignals: true
270 function closeIfNoApplications() {
271 if (!shell.applicationManager.mainStageFocusedApplication
272 && !shell.applicationManager.sideStageFocusedApplication
273 && shell.applicationManager.mainStageApplications.count == 0
274 && shell.applicationManager.sideStageApplications.count == 0) {
279 // show the stages when an application gets the focus
281 target: shell.applicationManager
282 onMainStageFocusedApplicationChanged: {
283 if (shell.applicationManager.mainStageFocusedApplication) {
288 onSideStageFocusedApplicationChanged: {
289 if (shell.applicationManager.sideStageFocusedApplication) {
294 ignoreUnknownSignals: true
301 fullyShown: stages.fullyShown
302 fullyHidden: stages.fullyHidden
303 shouldUseScreenshots: !fullyShown
304 rightEdgeEnabled: !sideStage.enabled
306 applicationManager: shell.applicationManager
307 rightEdgeDraggingAreaWidth: shell.edgeSize
308 normalApplicationY: shell.panelHeight
317 // FIXME: workaround the fact that focusing a main stage application
318 // raises its surface on top of all other surfaces including the ones
319 // that belong to side stage applications.
320 onFocusedApplicationChanged: {
321 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
322 shell.applicationManager.focusApplication(sideStage.focusedApplication);
330 applicationManager: shell.applicationManager
331 rightEdgeDraggingAreaWidth: shell.edgeSize
332 normalApplicationY: shell.panelHeight
335 if (!shown && mainStage.applications.count == 0) {
339 // FIXME: when hiding the side stage, refocus the main stage
340 // application so that it goes in front of the side stage
341 // application and hides it
342 onFullyShownChanged: {
343 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
344 shell.applicationManager.focusApplication(mainStage.focusedApplication);
348 enabled: shell.width >= units.gu(60)
350 fullyShown: stages.fullyShown && shown
351 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
352 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
354 available: !greeter.shown && !lockscreen.shown && enabled
355 hides: [launcher, panel.indicators]
357 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
358 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
361 height: stages.height
362 handleExpanded: sideStageRevealer.pressed
366 id: sideStageRevealer
368 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
369 && sideStage.available
370 direction: Qt.RightToLeft
371 openedValue: parent.width - sideStage.width
372 hintDisplacement: units.gu(3)
373 /* The size of the sidestage handle needs to be bigger than the
374 typical size used for edge detection otherwise it is really
377 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
378 closedValue: parent.width + sideStage.handleSizeCollapsed
380 x: parent.width - width
381 width: sideStage.width + handleSize * 0.7
382 height: sideStage.height
383 orientation: Qt.Horizontal
389 anchors.top: parent.top
390 anchors.bottom: parent.bottom
391 anchors.right: parent.left
393 width: shell.edgeSize
394 direction: Direction.Leftwards
395 enabled: edgeDemo.dashEnabled
396 property bool haveApps: mainStage.applications.count > 0 || sideStage.applications.count > 0
398 maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
399 // Make autocompletion impossible when !haveApps
400 edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
407 hides: [launcher, panel.indicators, hud]
410 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
411 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
413 x: required ? 0 : - width
415 height: parent.height - panel.panelHeight
416 background: shell.background
418 onUnlocked: lockscreen.hide()
419 onCancel: greeter.show()
421 Component.onCompleted: {
422 if (LightDM.Users.count == 1) {
423 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
430 target: LightDM.Greeter
433 if (LightDM.Users.count == 1) {
434 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
436 lockscreen.alphaNumeric = false
438 lockscreen.alphaNumeric = true
440 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
448 objectName: "greeter"
451 hides: [launcher, panel.indicators, hud]
456 height: parent.height - panel.panelHeight
458 dragHandleWidth: shell.edgeSize
463 // If there is only one user, we start authenticating with that one here.
464 // If there are more users, the Greeter will handle that
465 if (LightDM.Users.count == 1) {
466 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
469 greeter.forceActiveFocus();
473 onUnlocked: greeter.hide()
475 // Update launcher items for new user
476 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);
477 LauncherModel.setUser(user);
480 onLeftTeaserPressedChanged: {
481 if (leftTeaserPressed) {
489 blockInput: greeter.shown || lockscreen.shown
496 property var previousMainApp: null
497 property var previousSideApp: null
499 function setFocused(focused) {
501 // FIXME: *FocusedApplication are not updated when unfocused, hence the need to check whether
502 // the stage was actually shown
503 if (mainStage.fullyShown) powerConnection.previousMainApp = applicationManager.mainStageFocusedApplication;
504 if (sideStage.fullyShown) powerConnection.previousSideApp = applicationManager.sideStageFocusedApplication;
505 applicationManager.unfocusCurrentApplication();
507 if (powerConnection.previousMainApp) {
508 applicationManager.focusApplication(powerConnection.previousMainApp);
509 powerConnection.previousMainApp = null;
511 if (powerConnection.previousSideApp) {
512 applicationManager.focusApplication(powerConnection.previousSideApp);
513 powerConnection.previousSideApp = null;
518 onDisplayPowerStateChange: {
519 // We ignore any display-off signals when the proximity sensor
520 // is active. This usually indicates something like a phone call.
521 if (status == Powerd.Off && (flags & Powerd.UseProximity) == 0) {
522 powerConnection.setFocused(false);
524 } else if (status == Powerd.On) {
525 powerConnection.setFocused(true);
528 // No reason to chew demo CPU when user isn't watching
529 if (status == Powerd.Off) {
530 edgeDemo.paused = true;
531 } else if (status == Powerd.On) {
532 edgeDemo.paused = false;
544 anchors.fill: parent //because this draws indicator menus
545 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
548 available: edgeDemo.panelEnabled
549 contentEnabled: edgeDemo.panelContentEnabled
551 fullscreenMode: shell.fullscreenMode
552 searchVisible: !greeter.shown && !lockscreen.shown
556 blockInput: panel.indicators.shown
563 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
564 height: parent.height
566 available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown && edgeDemo.dashEnabled
568 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
569 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
572 target: shell.applicationManager
573 onMainStageFocusedApplicationChanged: hud.hide()
574 onSideStageFocusedApplicationChanged: hud.hide()
579 blockInput: hud.shown
588 anchors.left: hud.left
589 height: parent.height
590 target: hud.revealerTarget
593 direction: Qt.RightToLeft
594 orientation: Qt.Vertical
595 handleSize: hud.handleHeight
596 onCloseClicked: target.hide()
602 enabled: !panel.indicators.shown
603 applicationIsOnForeground: applicationManager.mainStageFocusedApplication
604 || applicationManager.sideStageFocusedApplication
608 blockInput: launcher.shown
611 bottom: parent.bottom
614 width: launcher.width
620 anchors.top: parent.top
621 anchors.bottom: parent.bottom
623 dragAreaWidth: shell.edgeSize
624 available: (!greeter.shown || greeter.narrowMode) && edgeDemo.launcherEnabled
625 onDashItemSelected: {
627 // Animate if moving between application and dash
629 dash.setCurrentScope("home.scope", true, false)
631 dash.setCurrentScope("home.scope", false, false)
637 dash.setCurrentScope("applications.scope", true, false)
642 onLauncherApplicationSelected:{
644 shell.activateApplication(desktopFile)
648 panel.indicators.hide()
657 model: NotificationBackend.Model
661 bottom: parent.bottom
662 leftMargin: units.gu(1)
663 rightMargin: units.gu(1)
664 topMargin: panel.panelHeight + units.gu(1)
669 when: overlay.width <= units.gu(60)
670 AnchorChanges { target: notifications; anchors.left: parent.left }
674 when: overlay.width > units.gu(60)
675 AnchorChanges { target: notifications; anchors.left: undefined }
676 PropertyChanges { target: notifications; width: units.gu(38) }
687 bottom: parent.bottom
690 width: shell.edgeSize
697 bottom: parent.bottom
700 width: shell.edgeSize
710 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
712 anchors.bottom: parent.bottom
713 anchors.left: parent.left
714 anchors.right: parent.right
715 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
717 enabled: shell.applicationManager && shell.applicationManager.keyboardVisible
721 anchors.centerIn: parent
722 visible: applicationManager.fake
723 text: "EARLY ALPHA\nNOT READY FOR USE"
726 font.weight: Font.Black
727 horizontalAlignment: Text.AlignHCenter
728 verticalAlignment: Text.AlignVCenter
729 fontSizeMode: Text.Fit
731 scale: Math.min(parent.width, parent.height) / width
739 indicators: panel.indicators
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