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
32import "Components/Math.js" as MathLocal
36import Unity.Notifications 1.0 as NotificationBackend
41 // this is only here to select the width / height of the window if not running fullscreen
42 property bool tablet: false
43 width: tablet ? units.gu(160) : applicationArguments.hasGeometry() ? applicationArguments.width() : units.gu(40)
44 height: tablet ? units.gu(100) : applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(71)
46 property real edgeSize: units.gu(2)
47 property url defaultBackground: shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg"
48 property url background
49 readonly property real panelHeight: panel.panelHeight
51 property bool dashShown: dash.shown
52 property bool stageScreenshotsReady: {
53 if (sideStage.shown) {
54 if (mainStage.applications.count > 0) {
55 return mainStage.usingScreenshots && sideStage.usingScreenshots;
57 return sideStage.usingScreenshots;
60 return mainStage.usingScreenshots;
64 property ListModel searchHistory: SearchHistoryModel {}
66 property var applicationManager: ApplicationManagerWrapper {}
70 property: "applicationManager"
71 value: ApplicationManager
74 Component.onCompleted: {
75 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
77 applicationManager.sideStageEnabled = Qt.binding(function() { return sideStage.enabled })
79 // FIXME: if application focused before shell starts, shell draws on top of it only.
80 // We should detect already running applications on shell start and bring them to the front.
81 applicationManager.unfocusCurrentApplication();
84 readonly property bool applicationFocused: !!applicationManager.mainStageFocusedApplication
85 || !!applicationManager.sideStageFocusedApplication
87 readonly property bool fullscreenMode: {
88 if (greeter.shown || lockscreen.shown) {
90 } else if (mainStage.usingScreenshots) { // Window Manager animating so want to re-evaluate fullscreen mode
91 return mainStage.switchingFromFullscreenToFullscreen;
92 } else if (applicationManager.mainStageFocusedApplication) {
93 return applicationManager.mainStageFocusedApplication.fullscreen;
100 target: applicationManager
101 ignoreUnknownSignals: true
103 // TODO: this should be protected to only unlock for certain applications / certain usecases
104 // potentially only in connection with a notification
106 shell.activateApplication(desktopFile);
110 function activateApplication(desktopFile, argument) {
111 if (applicationManager) {
112 // For newly started applications, as it takes them time to draw their first frame
113 // we add a delay before we hide the animation screenshots to compensate.
114 var addDelay = !applicationManager.getApplicationFromDesktopFile(desktopFile);
117 application = applicationManager.activateApplication(desktopFile, argument);
118 if (application == null) {
121 if (application.stage == ApplicationInfo.MainStage || !sideStage.enabled) {
122 mainStage.activateApplication(desktopFile, addDelay);
124 sideStage.activateApplication(desktopFile, addDelay);
131 id: backgroundSettings
132 schema.id: "org.gnome.desktop.background"
134 property url gSettingsPicture: backgroundSettings.pictureUri != undefined && backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : shell.defaultBackground
135 onGSettingsPictureChanged: {
136 shell.background = gSettingsPicture
139 // This is a dummy image that is needed to determine if the picture url
140 // in backgroundSettings points to a valid picture file.
141 // We can't do this with the real background image because setting a
142 // new source in onStatusChanged triggers a binding loop detection
143 // inside Image, which causes it not to render even though a valid source
144 // would be set. We don't mind about this image staying black and just
145 // use it for verification to populate the source for the real
148 source: shell.background
154 if (status == Image.Error && source != shell.defaultBackground) {
155 shell.background = defaultBackground
161 anchors.fill: parent // as needs to know the geometry of the shell
168 Keys.onVolumeUpPressed: volumeControl.volumeUp()
169 Keys.onVolumeDownPressed: volumeControl.volumeDown()
173 objectName: "underlay"
176 // Whether the underlay is fully covered by opaque UI elements.
177 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
179 readonly property bool applicationRunning: ((mainStage.applications && mainStage.applications.count > 0)
180 || (sideStage.applications && sideStage.applications.count > 0))
182 // Whether the user should see the topmost application surface (if there's one at all).
183 readonly property bool applicationSurfaceShouldBeSeen: applicationRunning && !stages.fullyHidden
184 && !mainStage.usingScreenshots // but want sideStage animating over app surface
188 // NB! Application surfaces are stacked behing the shell one. So they can only be seen by the user
189 // through the translucent parts of the shell surface.
190 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
194 objectName: "backgroundImage"
197 source: shell.background
203 opacity: dash.disappearingAnimationProgress
210 available: !greeter.shown && !lockscreen.shown
211 hides: [stages, launcher, panel.indicators]
212 shown: disappearingAnimationProgress !== 1.0
213 enabled: disappearingAnimationProgress === 0.0 && edgeDemo.dashEnabled
214 // FIXME: unfocus all applications when going back to the dash
217 shell.applicationManager.unfocusCurrentApplication()
223 topMargin: panel.panelHeight
226 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
227 opacity: 1.0 - disappearingAnimationProgress
228 property real disappearingAnimationProgress: {
230 return greeter.showProgress;
232 return stagesOuterContainer.showProgress;
236 // FIXME: only necessary because stagesOuterContainer.showProgress and
237 // greeterRevealer.animatedProgress are not animated
238 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
243 id: stagesOuterContainer
246 height: parent.height
248 Behavior on x {SmoothedAnimation{velocity: 600}}
250 property real showProgress:
251 MathLocal.clamp(1 - (x + stages.x) / shell.width, 0, 1)
259 property bool fullyShown: shown && x == 0 && parent.x == 0
260 property bool fullyHidden: !shown && x == width
261 available: !greeter.shown
262 hides: [panel.indicators]
265 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
266 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
269 height: parent.height
271 // close the stages when no focused application remains
273 target: shell.applicationManager
274 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
275 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
276 ignoreUnknownSignals: true
279 function closeIfNoApplications() {
280 if (!shell.applicationManager.mainStageFocusedApplication
281 && !shell.applicationManager.sideStageFocusedApplication
282 && shell.applicationManager.mainStageApplications.count == 0
283 && shell.applicationManager.sideStageApplications.count == 0) {
288 // show the stages when an application gets the focus
290 target: shell.applicationManager
291 onMainStageFocusedApplicationChanged: {
292 if (shell.applicationManager.mainStageFocusedApplication) {
297 onSideStageFocusedApplicationChanged: {
298 if (shell.applicationManager.sideStageFocusedApplication) {
303 ignoreUnknownSignals: true
310 fullyShown: stages.fullyShown
311 fullyHidden: stages.fullyHidden
312 shouldUseScreenshots: !fullyShown
313 rightEdgeEnabled: !sideStage.enabled
315 applicationManager: shell.applicationManager
316 rightEdgeDraggingAreaWidth: shell.edgeSize
317 normalApplicationY: shell.panelHeight
326 // FIXME: workaround the fact that focusing a main stage application
327 // raises its surface on top of all other surfaces including the ones
328 // that belong to side stage applications.
329 onFocusedApplicationChanged: {
330 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
331 shell.applicationManager.focusApplication(sideStage.focusedApplication);
339 applicationManager: shell.applicationManager
340 rightEdgeDraggingAreaWidth: shell.edgeSize
341 normalApplicationY: shell.panelHeight
344 if (!shown && mainStage.applications.count == 0) {
348 // FIXME: when hiding the side stage, refocus the main stage
349 // application so that it goes in front of the side stage
350 // application and hides it
351 onFullyShownChanged: {
352 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
353 shell.applicationManager.focusApplication(mainStage.focusedApplication);
357 enabled: shell.width >= units.gu(60)
359 fullyShown: stages.fullyShown && shown
360 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
361 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
363 available: !greeter.shown && !lockscreen.shown && enabled
364 hides: [launcher, panel.indicators]
366 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
367 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
370 height: stages.height
371 handleExpanded: sideStageRevealer.pressed
375 id: sideStageRevealer
377 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
378 && sideStage.available
379 direction: Qt.RightToLeft
380 openedValue: parent.width - sideStage.width
381 hintDisplacement: units.gu(3)
382 /* The size of the sidestage handle needs to be bigger than the
383 typical size used for edge detection otherwise it is really
386 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
387 closedValue: parent.width + sideStage.handleSizeCollapsed
389 x: parent.width - width
390 width: sideStage.width + handleSize * 0.7
391 height: sideStage.height
392 orientation: Qt.Horizontal
398 anchors.top: parent.top
399 anchors.bottom: parent.bottom
400 anchors.right: parent.left
402 width: shell.edgeSize
403 direction: Direction.Leftwards
404 enabled: edgeDemo.dashEnabled
405 property bool haveApps: mainStage.applications.count > 0 || sideStage.applications.count > 0
407 maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
408 // Make autocompletion impossible when !haveApps
409 edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
416 hides: [launcher, panel.indicators, hud]
419 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
420 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
422 x: required ? 0 : - width
424 height: parent.height - panel.panelHeight
425 background: shell.background
427 onUnlocked: lockscreen.hide()
428 onCancel: greeter.show()
430 Component.onCompleted: {
431 if (LightDM.Users.count == 1) {
432 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
439 target: LightDM.Greeter
442 if (LightDM.Users.count == 1) {
443 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
445 lockscreen.alphaNumeric = false
447 lockscreen.alphaNumeric = true
449 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
457 objectName: "greeter"
460 hides: [launcher, panel.indicators, hud]
463 defaultBackground: shell.background
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 AccountsService.user = user;
489 LauncherModel.setUser(user);
492 onLeftTeaserPressedChanged: {
493 if (leftTeaserPressed) {
501 blockInput: !applicationFocused || greeter.shown || lockscreen.shown || launcher.shown
502 || panel.indicators.shown || hud.shown
509 property var previousMainApp: null
510 property var previousSideApp: null
512 function setFocused(focused) {
514 powerConnection.previousMainApp = applicationManager.mainStageFocusedApplication;
515 powerConnection.previousSideApp = applicationManager.sideStageFocusedApplication;
516 applicationManager.unfocusCurrentApplication();
518 if (powerConnection.previousMainApp) {
519 applicationManager.focusApplication(powerConnection.previousMainApp);
520 powerConnection.previousMainApp = null;
522 if (powerConnection.previousSideApp) {
523 applicationManager.focusApplication(powerConnection.previousSideApp);
524 powerConnection.previousSideApp = null;
529 onDisplayPowerStateChange: {
530 // We ignore any display-off signals when the proximity sensor
531 // is active. This usually indicates something like a phone call.
532 if (status == Powerd.Off && (flags & Powerd.UseProximity) == 0) {
533 powerConnection.setFocused(false);
535 } else if (status == Powerd.On) {
536 powerConnection.setFocused(true);
539 // No reason to chew demo CPU when user isn't watching
540 if (status == Powerd.Off) {
541 edgeDemo.paused = true;
542 } else if (status == Powerd.On) {
543 edgeDemo.paused = false;
555 anchors.fill: parent //because this draws indicator menus
556 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
559 available: edgeDemo.panelEnabled
560 contentEnabled: edgeDemo.panelContentEnabled
562 fullscreenMode: shell.fullscreenMode
563 searchVisible: !greeter.shown && !lockscreen.shown
571 height: (panel.fullscreenMode) ? shell.edgeSize : panel.panelHeight
579 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
580 height: parent.height
582 available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown && edgeDemo.dashEnabled
584 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
585 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
588 target: shell.applicationManager
589 onMainStageFocusedApplicationChanged: hud.hide()
590 onSideStageFocusedApplicationChanged: hud.hide()
599 anchors.left: hud.left
600 height: parent.height
601 target: hud.revealerTarget
604 direction: Qt.RightToLeft
605 orientation: Qt.Vertical
606 handleSize: hud.handleHeight
607 onCloseClicked: target.hide()
613 enabled: !panel.indicators.shown
614 applicationIsOnForeground: applicationFocused
618 blockInput: launcher.shown
621 bottom: parent.bottom
624 width: launcher.width
630 anchors.top: parent.top
631 anchors.bottom: parent.bottom
633 dragAreaWidth: shell.edgeSize
634 available: (!greeter.shown || greeter.narrowMode) && edgeDemo.launcherEnabled
635 onDashItemSelected: {
637 // Animate if moving between application and dash
639 dash.setCurrentScope("home.scope", true, false)
641 dash.setCurrentScope("home.scope", false, false)
647 dash.setCurrentScope("applications.scope", true, false)
652 onLauncherApplicationSelected:{
654 shell.activateApplication(appId)
658 panel.indicators.hide()
667 model: NotificationBackend.Model
671 bottom: parent.bottom
672 leftMargin: units.gu(1)
673 rightMargin: units.gu(1)
674 topMargin: panel.panelHeight + units.gu(1)
679 when: overlay.width <= units.gu(60)
680 AnchorChanges { target: notifications; anchors.left: parent.left }
684 when: overlay.width > units.gu(60)
685 AnchorChanges { target: notifications; anchors.left: undefined }
686 PropertyChanges { target: notifications; width: units.gu(38) }
697 bottom: parent.bottom
700 width: shell.edgeSize
707 bottom: parent.bottom
710 width: shell.edgeSize
720 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
722 anchors.bottom: parent.bottom
723 anchors.left: parent.left
724 anchors.right: parent.right
725 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
727 enabled: shell.applicationManager && shell.applicationManager.keyboardVisible
731 anchors.centerIn: parent
732 visible: applicationManager.fake
733 text: "EARLY ALPHA\nNOT READY FOR USE"
736 font.weight: Font.Black
737 horizontalAlignment: Text.AlignHCenter
738 verticalAlignment: Text.AlignVCenter
739 fontSizeMode: Text.Fit
741 scale: Math.min(parent.width, parent.height) / width
749 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