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 Unity.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 applicationFocused: !!applicationManager.mainStageFocusedApplication
78 || !!applicationManager.shellStageFocusedApplication
80 readonly property bool fullscreenMode: {
81 if (greeter.shown || lockscreen.shown) {
83 } else if (mainStage.usingScreenshots) { // Window Manager animating so want to re-evaluate fullscreen mode
84 return mainStage.switchingFromFullscreenToFullscreen;
85 } else if (applicationManager.mainStageFocusedApplication) {
86 return applicationManager.mainStageFocusedApplication.fullscreen;
93 target: applicationManager
94 ignoreUnknownSignals: true
96 // TODO: this should be protected to only unlock for certain applications / certain usecases
97 // potentially only in connection with a notification
99 shell.activateApplication(desktopFile);
102 onMainStageFocusedApplicationChanged: {
103 var app = applicationManager.mainStageFocusedApplication
105 LauncherModel.applicationFocused(app.desktopFile);
107 LauncherModel.applicationFocused("");
112 function activateApplication(desktopFile, argument) {
113 if (applicationManager) {
114 // For newly started applications, as it takes them time to draw their first frame
115 // we add a delay before we hide the animation screenshots to compensate.
116 var addDelay = !applicationManager.getApplicationFromDesktopFile(desktopFile);
119 application = applicationManager.activateApplication(desktopFile, argument);
120 if (application == null) {
123 if (application.stage == ApplicationInfo.MainStage || !sideStage.enabled) {
124 mainStage.activateApplication(desktopFile, addDelay);
126 sideStage.activateApplication(desktopFile, addDelay);
133 id: backgroundSettings
134 schema.id: "org.gnome.desktop.background"
136 property url gSettingsPicture: backgroundSettings.pictureUri != undefined && backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : shell.defaultBackground
137 onGSettingsPictureChanged: {
138 shell.background = gSettingsPicture
141 // This is a dummy image that is needed to determine if the picture url
142 // in backgroundSettings points to a valid picture file.
143 // We can't do this with the real background image because setting a
144 // new source in onStatusChanged triggers a binding loop detection
145 // inside Image, which causes it not to render even though a valid source
146 // would be set. We don't mind about this image staying black and just
147 // use it for verification to populate the source for the real
150 source: shell.background
156 if (status == Image.Error && source != shell.defaultBackground) {
157 shell.background = defaultBackground
163 anchors.fill: parent // as needs to know the geometry of the shell
170 Keys.onVolumeUpPressed: volumeControl.volumeUp()
171 Keys.onVolumeDownPressed: volumeControl.volumeDown()
175 objectName: "underlay"
178 // Whether the underlay is fully covered by opaque UI elements.
179 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
181 readonly property bool applicationRunning: ((mainStage.applications && mainStage.applications.count > 0)
182 || (sideStage.applications && sideStage.applications.count > 0))
184 // Whether the user should see the topmost application surface (if there's one at all).
185 readonly property bool applicationSurfaceShouldBeSeen: applicationRunning && !stages.fullyHidden
186 && !mainStage.usingScreenshots // but want sideStage animating over app surface
190 // NB! Application surfaces are stacked behing the shell one. So they can only be seen by the user
191 // through the translucent parts of the shell surface.
192 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
196 objectName: "backgroundImage"
199 source: shell.background
205 opacity: dash.disappearingAnimationProgress
212 available: !greeter.shown && !lockscreen.shown
213 hides: [stages, launcher, panel.indicators]
214 shown: disappearingAnimationProgress !== 1.0
215 enabled: disappearingAnimationProgress === 0.0 && edgeDemo.dashEnabled
216 // FIXME: unfocus all applications when going back to the dash
219 shell.applicationManager.unfocusCurrentApplication()
225 topMargin: panel.panelHeight
228 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
229 opacity: 1.0 - disappearingAnimationProgress
230 property real disappearingAnimationProgress: {
232 return greeter.showProgress;
234 return stagesOuterContainer.showProgress;
238 // FIXME: only necessary because stagesOuterContainer.showProgress and
239 // greeterRevealer.animatedProgress are not animated
240 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
245 id: stagesOuterContainer
248 height: parent.height
250 Behavior on x {SmoothedAnimation{velocity: 600}}
252 property real showProgress:
253 MathLocal.clamp(1 - (x + stages.x) / shell.width, 0, 1)
261 property bool fullyShown: shown && x == 0 && parent.x == 0
262 property bool fullyHidden: !shown && x == width
263 available: !greeter.shown
264 hides: [launcher, panel.indicators]
267 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
268 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
271 height: parent.height
273 // close the stages when no focused application remains
275 target: shell.applicationManager
276 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
277 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
278 ignoreUnknownSignals: true
281 function closeIfNoApplications() {
282 if (!shell.applicationManager.mainStageFocusedApplication
283 && !shell.applicationManager.sideStageFocusedApplication
284 && shell.applicationManager.mainStageApplications.count == 0
285 && shell.applicationManager.sideStageApplications.count == 0) {
290 // show the stages when an application gets the focus
292 target: shell.applicationManager
293 onMainStageFocusedApplicationChanged: {
294 if (shell.applicationManager.mainStageFocusedApplication) {
299 onSideStageFocusedApplicationChanged: {
300 if (shell.applicationManager.sideStageFocusedApplication) {
305 ignoreUnknownSignals: true
312 fullyShown: stages.fullyShown
313 fullyHidden: stages.fullyHidden
314 shouldUseScreenshots: !fullyShown
315 rightEdgeEnabled: !sideStage.enabled
317 applicationManager: shell.applicationManager
318 rightEdgeDraggingAreaWidth: shell.edgeSize
319 normalApplicationY: shell.panelHeight
328 // FIXME: workaround the fact that focusing a main stage application
329 // raises its surface on top of all other surfaces including the ones
330 // that belong to side stage applications.
331 onFocusedApplicationChanged: {
332 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
333 shell.applicationManager.focusApplication(sideStage.focusedApplication);
341 applicationManager: shell.applicationManager
342 rightEdgeDraggingAreaWidth: shell.edgeSize
343 normalApplicationY: shell.panelHeight
346 if (!shown && mainStage.applications.count == 0) {
350 // FIXME: when hiding the side stage, refocus the main stage
351 // application so that it goes in front of the side stage
352 // application and hides it
353 onFullyShownChanged: {
354 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
355 shell.applicationManager.focusApplication(mainStage.focusedApplication);
359 enabled: shell.width >= units.gu(60)
361 fullyShown: stages.fullyShown && shown
362 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
363 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
365 available: !greeter.shown && !lockscreen.shown && enabled
366 hides: [launcher, panel.indicators]
368 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
369 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
372 height: stages.height
373 handleExpanded: sideStageRevealer.pressed
377 id: sideStageRevealer
379 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
380 && sideStage.available
381 direction: Qt.RightToLeft
382 openedValue: parent.width - sideStage.width
383 hintDisplacement: units.gu(3)
384 /* The size of the sidestage handle needs to be bigger than the
385 typical size used for edge detection otherwise it is really
388 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
389 closedValue: parent.width + sideStage.handleSizeCollapsed
391 x: parent.width - width
392 width: sideStage.width + handleSize * 0.7
393 height: sideStage.height
394 orientation: Qt.Horizontal
400 anchors.top: parent.top
401 anchors.bottom: parent.bottom
402 anchors.right: parent.left
404 width: shell.edgeSize
405 direction: Direction.Leftwards
406 enabled: edgeDemo.dashEnabled
407 property bool haveApps: mainStage.applications.count > 0 || sideStage.applications.count > 0
409 maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
410 // Make autocompletion impossible when !haveApps
411 edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
418 hides: [launcher, panel.indicators, hud]
421 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
422 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
424 x: required ? 0 : - width
426 height: parent.height - panel.panelHeight
427 background: shell.background
429 onUnlocked: lockscreen.hide()
430 onCancel: greeter.show()
432 Component.onCompleted: {
433 if (LightDM.Users.count == 1) {
434 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
441 target: LightDM.Greeter
444 if (LightDM.Users.count == 1) {
445 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
447 lockscreen.alphaNumeric = false
449 lockscreen.alphaNumeric = true
451 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
459 objectName: "greeter"
462 hides: [launcher, panel.indicators, hud]
467 height: parent.height - panel.panelHeight
469 dragHandleWidth: shell.edgeSize
474 // If there is only one user, we start authenticating with that one here.
475 // If there are more users, the Greeter will handle that
476 if (LightDM.Users.count == 1) {
477 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
480 greeter.forceActiveFocus();
484 onUnlocked: greeter.hide()
486 // Update launcher items for new user
487 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);
488 LauncherModel.setUser(user);
491 onLeftTeaserPressedChanged: {
492 if (leftTeaserPressed) {
500 blockInput: !applicationFocused || greeter.shown || lockscreen.shown || launcher.shown
501 || panel.indicators.shown
508 property var previousMainApp: null
509 property var previousSideApp: null
511 function setFocused(focused) {
513 powerConnection.previousMainApp = applicationManager.mainStageFocusedApplication;
514 powerConnection.previousSideApp = applicationManager.sideStageFocusedApplication;
515 applicationManager.unfocusCurrentApplication();
517 if (powerConnection.previousMainApp) {
518 applicationManager.focusApplication(powerConnection.previousMainApp);
519 powerConnection.previousMainApp = null;
521 if (powerConnection.previousSideApp) {
522 applicationManager.focusApplication(powerConnection.previousSideApp);
523 powerConnection.previousSideApp = null;
528 onDisplayPowerStateChange: {
529 // We ignore any display-off signals when the proximity sensor
530 // is active. This usually indicates something like a phone call.
531 if (status == Powerd.Off && (flags & Powerd.UseProximity) == 0) {
532 powerConnection.setFocused(false);
534 } else if (status == Powerd.On) {
535 powerConnection.setFocused(true);
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;
554 anchors.fill: parent //because this draws indicator menus
555 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
558 available: edgeDemo.panelEnabled
559 contentEnabled: edgeDemo.panelContentEnabled
561 fullscreenMode: shell.fullscreenMode
562 searchVisible: !greeter.shown && !lockscreen.shown
570 height: (panel.fullscreenMode) ? shell.edgeSize : panel.panelHeight
578 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
579 height: parent.height
581 available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown && edgeDemo.dashEnabled
583 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
584 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
587 target: shell.applicationManager
588 onMainStageFocusedApplicationChanged: hud.hide()
589 onSideStageFocusedApplicationChanged: hud.hide()
594 bottom: parent.bottom
598 height: (!hud.shown) ? shell.edgeSize : parent.height
608 anchors.left: hud.left
609 height: parent.height
610 target: hud.revealerTarget
613 direction: Qt.RightToLeft
614 orientation: Qt.Vertical
615 handleSize: hud.handleHeight
616 onCloseClicked: target.hide()
622 enabled: !panel.indicators.shown
623 applicationIsOnForeground: applicationFocused
627 blockInput: launcher.shown
630 bottom: parent.bottom
633 width: launcher.width
639 anchors.top: parent.top
640 anchors.bottom: parent.bottom
642 dragAreaWidth: shell.edgeSize
643 available: (!greeter.shown || greeter.narrowMode) && edgeDemo.launcherEnabled
644 onDashItemSelected: {
646 // Animate if moving between application and dash
648 dash.setCurrentScope("home.scope", true, false)
650 dash.setCurrentScope("home.scope", false, false)
656 dash.setCurrentScope("applications.scope", true, false)
661 onLauncherApplicationSelected:{
663 shell.activateApplication(desktopFile)
667 panel.indicators.hide()
676 model: NotificationBackend.Model
680 bottom: parent.bottom
681 leftMargin: units.gu(1)
682 rightMargin: units.gu(1)
683 topMargin: panel.panelHeight + units.gu(1)
688 when: overlay.width <= units.gu(60)
689 AnchorChanges { target: notifications; anchors.left: parent.left }
693 when: overlay.width > units.gu(60)
694 AnchorChanges { target: notifications; anchors.left: undefined }
695 PropertyChanges { target: notifications; width: units.gu(38) }
706 bottom: parent.bottom
709 width: shell.edgeSize
716 bottom: parent.bottom
719 width: shell.edgeSize
729 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
731 anchors.bottom: parent.bottom
732 anchors.left: parent.left
733 anchors.right: parent.right
734 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
736 enabled: shell.applicationManager && shell.applicationManager.keyboardVisible
740 anchors.centerIn: parent
741 visible: applicationManager.fake
742 text: "EARLY ALPHA\nNOT READY FOR USE"
745 font.weight: Font.Black
746 horizontalAlignment: Text.AlignHCenter
747 verticalAlignment: Text.AlignVCenter
748 fontSizeMode: Text.Fit
750 scale: Math.min(parent.width, parent.height) / width
758 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