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
30import "Components/Math.js" as MathLocal
34import Unity.Notifications 1.0 as NotificationBackend
39 // this is only here to select the width / height of the window if not running fullscreen
40 property bool tablet: false
41 width: tablet ? units.gu(160) : applicationArguments.hasGeometry() ? applicationArguments.width() : units.gu(40)
42 height: tablet ? units.gu(100) : applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(71)
44 property real edgeSize: units.gu(2)
45 property url defaultBackground: shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg"
46 property url background: backgroundSettings.pictureUri
47 readonly property real panelHeight: panel.panelHeight
49 property bool dashShown: dash.shown
50 property bool stageScreenshotsReady: {
51 if (sideStage.shown) {
52 if (mainStage.applications.count > 0) {
53 return mainStage.usingScreenshots && sideStage.usingScreenshots;
55 return sideStage.usingScreenshots;
58 return mainStage.usingScreenshots;
62 property ListModel searchHistory: SearchHistoryModel {}
64 property var applicationManager: ApplicationManagerWrapper {}
66 Component.onCompleted: {
67 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
69 applicationManager.sideStageEnabled = Qt.binding(function() { return sideStage.enabled })
71 // FIXME: if application focused before shell starts, shell draws on top of it only.
72 // We should detect already running applications on shell start and bring them to the front.
73 applicationManager.unfocusCurrentApplication();
76 readonly property bool fullscreenMode: {
77 if (greeter.shown || lockscreen.shown) {
79 } else if (mainStage.usingScreenshots) { // Window Manager animating so want to re-evaluate fullscreen mode
80 return mainStage.switchingFromFullscreenToFullscreen;
81 } else if (applicationManager.mainStageFocusedApplication) {
82 return applicationManager.mainStageFocusedApplication.fullscreen;
89 target: applicationManager
90 ignoreUnknownSignals: true
92 // TODO: this should be protected to only unlock for certain applications / certain usecases
93 // potentially only in connection with a notification
95 shell.activateApplication(desktopFile);
99 function activateApplication(desktopFile, argument) {
100 if (applicationManager) {
101 // For newly started applications, as it takes them time to draw their first frame
102 // we add a delay before we hide the animation screenshots to compensate.
103 var addDelay = !applicationManager.getApplicationFromDesktopFile(desktopFile);
106 application = applicationManager.activateApplication(desktopFile, argument);
107 if (application == null) {
110 if (application.stage == ApplicationInfo.MainStage || !sideStage.enabled) {
111 mainStage.activateApplication(desktopFile, addDelay);
113 sideStage.activateApplication(desktopFile, addDelay);
120 id: backgroundSettings
121 schema.id: "org.gnome.desktop.background"
128 Keys.onVolumeUpPressed: volumeControl.volumeUp()
129 Keys.onVolumeDownPressed: volumeControl.volumeDown()
133 objectName: "underlay"
136 // Whether the underlay is fully covered by opaque UI elements.
137 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
139 // Whether the user should see the topmost application surface (if there's one at all).
140 property bool applicationSurfaceShouldBeSeen:
141 (mainStage.applications && mainStage.applications.count > 0)
142 && (!stages.fullyHidden && !mainStage.usingScreenshots)
144 // NB! Application surfaces are stacked behing the shell one. So they can only be seen by the user
145 // through the translucent parts of the shell surface.
146 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
150 objectName: "backgroundImage"
151 source: shell.background
154 if (status == Image.Error) {
155 backgroundSettings.pictureUri = shell.defaultBackground
163 opacity: dash.disappearingAnimationProgress
170 available: !greeter.shown && !lockscreen.shown
171 hides: [stages, launcher, panel.indicators]
172 shown: disappearingAnimationProgress !== 1.0
173 enabled: disappearingAnimationProgress === 0.0
174 // FIXME: unfocus all applications when going back to the dash
177 shell.applicationManager.unfocusCurrentApplication()
183 topMargin: panel.panelHeight
186 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
187 opacity: 1.0 - disappearingAnimationProgress
188 property real disappearingAnimationProgress: {
190 return greeter.showProgress;
192 return stagesOuterContainer.showProgress;
196 // FIXME: only necessary because stagesOuterContainer.showProgress and
197 // greeterRevealer.animatedProgress are not animated
198 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
203 id: stagesOuterContainer
206 height: parent.height
208 Behavior on x {SmoothedAnimation{velocity: 600}}
210 property real showProgress:
211 MathLocal.clamp(1 - (x + stages.x) / shell.width, 0, 1)
219 property bool fullyShown: shown && x == 0 && parent.x == 0
220 property bool fullyHidden: !shown && x == width
221 available: !greeter.shown
222 hides: [launcher, panel.indicators]
225 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
226 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
229 height: parent.height
231 // close the stages when no focused application remains
233 target: shell.applicationManager
234 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
235 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
236 ignoreUnknownSignals: true
239 function closeIfNoApplications() {
240 if (!shell.applicationManager.mainStageFocusedApplication
241 && !shell.applicationManager.sideStageFocusedApplication
242 && shell.applicationManager.mainStageApplications.count == 0
243 && shell.applicationManager.sideStageApplications.count == 0) {
248 // show the stages when an application gets the focus
250 target: shell.applicationManager
251 onMainStageFocusedApplicationChanged: {
252 if (shell.applicationManager.mainStageFocusedApplication) {
257 onSideStageFocusedApplicationChanged: {
258 if (shell.applicationManager.sideStageFocusedApplication) {
263 ignoreUnknownSignals: true
270 fullyShown: stages.fullyShown
271 fullyHidden: stages.fullyHidden
272 shouldUseScreenshots: !fullyShown
273 rightEdgeEnabled: !sideStage.enabled
275 applicationManager: shell.applicationManager
276 rightEdgeDraggingAreaWidth: shell.edgeSize
277 normalApplicationY: shell.panelHeight
286 // FIXME: workaround the fact that focusing a main stage application
287 // raises its surface on top of all other surfaces including the ones
288 // that belong to side stage applications.
289 onFocusedApplicationChanged: {
290 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
291 shell.applicationManager.focusApplication(sideStage.focusedApplication);
299 applicationManager: shell.applicationManager
300 rightEdgeDraggingAreaWidth: shell.edgeSize
301 normalApplicationY: shell.panelHeight
304 if (!shown && mainStage.applications.count == 0) {
308 // FIXME: when hiding the side stage, refocus the main stage
309 // application so that it goes in front of the side stage
310 // application and hides it
311 onFullyShownChanged: {
312 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
313 shell.applicationManager.focusApplication(mainStage.focusedApplication);
317 enabled: shell.width >= units.gu(60)
319 fullyShown: stages.fullyShown && shown
320 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
321 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
323 available: !greeter.shown && !lockscreen.shown && enabled
324 hides: [launcher, panel.indicators]
326 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
327 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
330 height: stages.height
331 handleExpanded: sideStageRevealer.pressed
335 id: sideStageRevealer
337 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
338 && sideStage.available
339 direction: Qt.RightToLeft
340 openedValue: parent.width - sideStage.width
341 hintDisplacement: units.gu(3)
342 /* The size of the sidestage handle needs to be bigger than the
343 typical size used for edge detection otherwise it is really
346 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
347 closedValue: parent.width + sideStage.handleSizeCollapsed
349 x: parent.width - width
350 width: sideStage.width + handleSize * 0.7
351 height: sideStage.height
352 orientation: Qt.Horizontal
358 anchors.top: parent.top
359 anchors.bottom: parent.bottom
360 anchors.right: parent.left
362 width: shell.edgeSize
363 direction: Direction.Leftwards
364 property bool haveApps: mainStage.applications.count > 0 || sideStage.applications.count > 0
366 maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
367 // Make autocompletion impossible when !haveApps
368 edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
375 hides: [launcher, panel.indicators, hud]
378 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
379 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
381 x: required ? 0 : - width
383 height: parent.height - panel.panelHeight
384 background: shell.background
386 onUnlocked: lockscreen.hide()
387 onCancel: greeter.show()
389 Component.onCompleted: {
390 if (LightDM.Users.count == 1) {
391 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
397 target: LightDM.Greeter
400 if (LightDM.Users.count == 1) {
401 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
403 lockscreen.alphaNumeric = false
405 lockscreen.alphaNumeric = true
407 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
417 hides: [launcher, panel.indicators, hud]
422 height: parent.height - panel.panelHeight
424 dragHandleWidth: shell.edgeSize
429 // If there is only one user, we start authenticating with that one here.
430 // If there are more users, the Greeter will handle that
431 if (LightDM.Users.count == 1) {
432 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
434 greeter.forceActiveFocus();
438 onUnlocked: greeter.hide()
440 var bgPath = greeter.model.data(uid, LightDM.UserRoles.BackgroundPathRole)
441 shell.background = bgPath ? bgPath : defaultBackground
444 onLeftTeaserPressedChanged: {
445 if (leftTeaserPressed) {
453 blockInput: greeter.shown || lockscreen.shown
460 property var previousMainApp: null
461 property var previousSideApp: null
463 function setFocused(focused) {
465 // FIXME: *FocusedApplication are not updated when unfocused, hence the need to check whether
466 // the stage was actually shown
467 if (mainStage.fullyShown) powerConnection.previousMainApp = applicationManager.mainStageFocusedApplication;
468 if (sideStage.fullyShown) powerConnection.previousSideApp = applicationManager.sideStageFocusedApplication;
469 applicationManager.unfocusCurrentApplication();
471 if (powerConnection.previousMainApp) {
472 applicationManager.focusApplication(powerConnection.previousMainApp);
473 powerConnection.previousMainApp = null;
475 if (powerConnection.previousSideApp) {
476 applicationManager.focusApplication(powerConnection.previousSideApp);
477 powerConnection.previousSideApp = null;
482 onPowerStateChange: {
483 if (state == 0) { // suspend
484 powerConnection.setFocused(false);
486 } else if (state == 1) { // active
487 powerConnection.setFocused(true);
499 anchors.fill: parent //because this draws indicator menus
500 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
504 fullscreenMode: shell.fullscreenMode
505 searchVisible: !greeter.shown && !lockscreen.shown
509 blockInput: panel.indicators.shown
516 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
517 height: parent.height
519 available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown
521 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
522 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
525 target: shell.applicationManager
526 onMainStageFocusedApplicationChanged: hud.hide()
527 onSideStageFocusedApplicationChanged: hud.hide()
532 blockInput: hud.shown
541 anchors.left: hud.left
542 height: parent.height
543 target: hud.revealerTarget
546 direction: Qt.RightToLeft
547 orientation: Qt.Vertical
548 handleSize: hud.handleHeight
549 onCloseClicked: target.hide()
555 enabled: !panel.indicators.shown
556 applicationIsOnForeground: applicationManager.mainStageFocusedApplication
557 || applicationManager.sideStageFocusedApplication
561 blockInput: launcher.shown
564 bottom: parent.bottom
567 width: launcher.width
573 anchors.top: parent.top
574 anchors.bottom: parent.bottom
576 dragAreaWidth: shell.edgeSize
577 available: !greeter.shown || greeter.narrowMode
578 onDashItemSelected: {
580 // Animate if moving between application and dash
582 dash.setCurrentScope("home.scope", true, false)
584 dash.setCurrentScope("home.scope", false, false)
590 dash.setCurrentScope("applications.scope", true, false)
595 onLauncherApplicationSelected:{
597 shell.activateApplication(desktopFile)
601 panel.indicators.hide()
610 model: NotificationBackend.Model
614 bottom: parent.bottom
615 leftMargin: units.gu(1)
616 rightMargin: units.gu(1)
617 topMargin: panel.panelHeight + units.gu(1)
622 when: overlay.width <= units.gu(60)
623 AnchorChanges { target: notifications; anchors.left: parent.left }
627 when: overlay.width > units.gu(60)
628 AnchorChanges { target: notifications; anchors.left: undefined }
629 PropertyChanges { target: notifications; width: units.gu(38) }
640 bottom: parent.bottom
643 width: shell.edgeSize
650 bottom: parent.bottom
653 width: shell.edgeSize
663 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
665 anchors.bottom: parent.bottom
666 anchors.left: parent.left
667 anchors.right: parent.right
668 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
670 enabled: shell.applicationManager && shell.applicationManager.keyboardVisible
675 visible: applicationManager.fake
676 text: "EARLY ALPHA\nNOT READY FOR USE"
679 font.weight: Font.Black
680 horizontalAlignment: Text.AlignHCenter
681 verticalAlignment: Text.AlignVCenter
682 fontSizeMode: Text.Fit
683 font.pixelSize: height/2
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