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 Ubuntu.Application 0.1
19import Ubuntu.Components 0.1
20import Ubuntu.Gestures 0.1
21import LightDM 0.1 as LightDM
28import "Components/Math.js" as MathLocal
32import Unity.Notifications 1.0 as NotificationBackend
37 // this is only here to select the width / height of the window if not running fullscreen
38 property bool tablet: false
39 width: tablet ? units.gu(160) : units.gu(40)
40 height: tablet ? units.gu(100) : units.gu(71)
42 property real edgeSize: units.gu(2)
43 property url default_background: shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg"
44 property url background: default_background
45 readonly property real panelHeight: panel.panelHeight
47 property bool dashShown: dash.shown
48 property bool stageScreenshotsReady: {
49 if (sideStage.shown) {
50 if (mainStage.applications.count > 0) {
51 return mainStage.usingScreenshots && sideStage.usingScreenshots;
53 return sideStage.usingScreenshots;
56 return mainStage.usingScreenshots;
60 property ListModel searchHistory: SearchHistoryModel {}
62 property var applicationManager: ApplicationManagerWrapper {}
64 Component.onCompleted: {
65 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
67 applicationManager.sideStageEnabled = Qt.binding(function() { return sideStage.enabled })
69 // FIXME: if application focused before shell starts, shell draws on top of it only.
70 // We should detect already running applications on shell start and bring them to the front.
71 applicationManager.unfocusCurrentApplication();
74 readonly property bool fullscreenMode: {
75 if (greeter.shown || lockscreen.shown) {
77 } else if (mainStage.usingScreenshots) { // Window Manager animating so want to re-evaluate fullscreen mode
78 return mainStage.switchingFromFullscreenToFullscreen;
79 } else if (applicationManager.mainStageFocusedApplication) {
80 return applicationManager.mainStageFocusedApplication.fullscreen;
87 target: applicationManager
88 ignoreUnknownSignals: true
90 // TODO: this should be protected to only unlock for certain applications / certain usecases
91 // potentially only in connection with a notification
93 shell.activateApplication(desktopFile);
97 function activateApplication(desktopFile, argument) {
98 if (applicationManager) {
99 // For newly started applications, as it takes them time to draw their first frame
100 // we add a delay before we hide the animation screenshots to compensate.
101 var addDelay = !applicationManager.getApplicationFromDesktopFile(desktopFile);
104 application = applicationManager.activateApplication(desktopFile, argument);
105 if (application == null) {
108 if (application.stage == ApplicationInfo.MainStage || !sideStage.enabled) {
109 mainStage.activateApplication(desktopFile, addDelay);
111 sideStage.activateApplication(desktopFile, addDelay);
121 Keys.onVolumeUpPressed: volumeControl.volumeUp()
122 Keys.onVolumeDownPressed: volumeControl.volumeDown()
125 if (event.key == Qt.Key_PowerOff) {
134 // Whether the underlay is fully covered by opaque UI elements.
135 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
137 // Whether the user should see the topmost application surface (if there's one at all).
138 property bool applicationSurfaceShouldBeSeen:
139 (mainStage.applications && mainStage.applications.count > 0)
140 && (!stages.fullyHidden && !mainStage.usingScreenshots)
142 // NB! Application surfaces are stacked behing the shell one. So they can only be seen by the user
143 // through the translucent parts of the shell surface.
144 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
148 source: shell.background
149 sourceSize.width: parent.width
150 sourceSize.height: parent.height
157 opacity: dash.disappearingAnimationProgress
164 available: !greeter.shown && !lockscreen.shown
165 hides: [stages, launcher, panel.indicators]
166 shown: disappearingAnimationProgress !== 1.0
167 enabled: disappearingAnimationProgress === 0.0
168 // FIXME: unfocus all applications when going back to the dash
171 shell.applicationManager.unfocusCurrentApplication()
177 topMargin: panel.panelHeight
180 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
181 opacity: 1.0 - disappearingAnimationProgress
182 property real disappearingAnimationProgress: {
184 return greeter.showProgress;
186 return stagesOuterContainer.showProgress;
190 // FIXME: only necessary because stagesOuterContainer.showProgress and
191 // greeterRevealer.animatedProgress are not animated
192 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
198 id: stagesOuterContainer
201 height: parent.height
203 Behavior on x {SmoothedAnimation{velocity: 600}}
205 property real showProgress:
206 MathLocal.clamp(1 - (x + stages.x) / shell.width, 0, 1)
213 property bool fullyShown: shown && x == 0 && parent.x == 0
214 property bool fullyHidden: !shown && x == width
215 available: !greeter.shown
216 hides: [launcher, panel.indicators]
219 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
220 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
223 height: parent.height
225 // close the stages when no focused application remains
227 target: shell.applicationManager
228 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
229 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
230 ignoreUnknownSignals: true
233 function closeIfNoApplications() {
234 if (!shell.applicationManager.mainStageFocusedApplication
235 && !shell.applicationManager.sideStageFocusedApplication
236 && shell.applicationManager.mainStageApplications.count == 0
237 && shell.applicationManager.sideStageApplications.count == 0) {
242 // show the stages when an application gets the focus
244 target: shell.applicationManager
245 onMainStageFocusedApplicationChanged: {
246 if (shell.applicationManager.mainStageFocusedApplication) {
251 onSideStageFocusedApplicationChanged: {
252 if (shell.applicationManager.sideStageFocusedApplication) {
257 ignoreUnknownSignals: true
265 fullyShown: stages.fullyShown
266 fullyHidden: stages.fullyHidden
267 shouldUseScreenshots: !fullyShown
268 rightEdgeEnabled: !sideStage.enabled
270 applicationManager: shell.applicationManager
271 rightEdgeDraggingAreaWidth: shell.edgeSize
272 normalApplicationY: shell.panelHeight
281 // FIXME: workaround the fact that focusing a main stage application
282 // raises its surface on top of all other surfaces including the ones
283 // that belong to side stage applications.
284 onFocusedApplicationChanged: {
285 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
286 shell.applicationManager.focusApplication(sideStage.focusedApplication);
294 applicationManager: shell.applicationManager
295 rightEdgeDraggingAreaWidth: shell.edgeSize
296 normalApplicationY: shell.panelHeight
299 if (!shown && mainStage.applications.count == 0) {
303 // FIXME: when hiding the side stage, refocus the main stage
304 // application so that it goes in front of the side stage
305 // application and hides it
306 onFullyShownChanged: {
307 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
308 shell.applicationManager.focusApplication(mainStage.focusedApplication);
312 enabled: shell.width >= units.gu(60)
314 fullyShown: stages.fullyShown && shown
315 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
316 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
318 available: !greeter.shown && !lockscreen.shown && enabled
319 hides: [launcher, panel.indicators]
321 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
322 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
325 height: stages.height
326 handleExpanded: sideStageRevealer.pressed
330 id: sideStageRevealer
332 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
333 && sideStage.available
334 direction: Qt.RightToLeft
335 openedValue: parent.width - sideStage.width
336 hintDisplacement: units.gu(3)
337 /* The size of the sidestage handle needs to be bigger than the
338 typical size used for edge detection otherwise it is really
341 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
342 closedValue: parent.width + sideStage.handleSizeCollapsed
344 x: parent.width - width
345 width: sideStage.width + handleSize * 0.7
346 height: sideStage.height
347 orientation: Qt.Horizontal
353 anchors.top: parent.top
354 anchors.bottom: parent.bottom
355 anchors.right: parent.left
357 width: shell.edgeSize
358 direction: Direction.Leftwards
359 property bool haveApps: mainStage.applications.count > 0 || sideStage.applications.count > 0
361 maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
362 // Make autocompletion impossible when !haveApps
363 edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
370 hides: [launcher, panel.indicators, hud]
373 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
374 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
376 x: required ? 0 : - width
378 height: parent.height - panel.panelHeight
379 background: shell.background
381 onUnlocked: lockscreen.hide()
382 onCancel: greeter.show()
384 Component.onCompleted: {
385 if (LightDM.Users.count == 1) {
386 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
392 target: LightDM.Greeter
395 if (LightDM.Users.count == 1) {
396 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
398 lockscreen.alphaNumeric = false
400 lockscreen.alphaNumeric = true
402 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
412 hides: [launcher, panel.indicators, hud]
417 height: parent.height - panel.panelHeight
419 dragHandleWidth: shell.edgeSize
421 property var previousMainApp: null
422 property var previousSideApp: null
427 // If there is only one user, we start authenticating with that one here.
428 // If there are more users, the Greeter will handle that
429 if (LightDM.Users.count == 1) {
430 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
432 greeter.forceActiveFocus();
433 // FIXME: *FocusedApplication are not updated when unfocused, hence the need to check whether
434 // the stage was actually shown
435 if (mainStage.fullyShown) greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
436 if (sideStage.fullyShown) greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
437 applicationManager.unfocusCurrentApplication();
439 if (greeter.previousMainApp) {
440 applicationManager.focusApplication(greeter.previousMainApp);
441 greeter.previousMainApp = null;
443 if (greeter.previousSideApp) {
444 applicationManager.focusApplication(greeter.previousSideApp);
445 greeter.previousSideApp = null;
450 onUnlocked: greeter.hide()
452 var bgPath = greeter.model.data(uid, LightDM.UserRoles.BackgroundPathRole)
453 shell.background = bgPath ? bgPath : default_background
456 onLeftTeaserPressedChanged: {
457 if (leftTeaserPressed) {
465 blockInput: greeter.shown || lockscreen.shown
475 anchors.fill: parent //because this draws indicator menus
476 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
480 fullscreenMode: shell.fullscreenMode
481 searchVisible: !greeter.shown && !lockscreen.shown
485 blockInput: panel.indicators.shown
492 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
493 height: parent.height
495 available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown
497 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
498 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
501 target: shell.applicationManager
502 onMainStageFocusedApplicationChanged: hud.hide()
503 onSideStageFocusedApplicationChanged: hud.hide()
508 blockInput: hud.shown
517 anchors.left: hud.left
518 height: parent.height
519 target: hud.revealerTarget
522 direction: Qt.RightToLeft
523 orientation: Qt.Vertical
524 handleSize: hud.handleHeight
525 onCloseClicked: target.hide()
531 enabled: !panel.indicators.shown
532 applicationIsOnForeground: applicationManager.mainStageFocusedApplication
533 || applicationManager.sideStageFocusedApplication
537 blockInput: launcher.shown
540 bottom: parent.bottom
543 width: launcher.width
549 anchors.top: parent.top
550 anchors.bottom: parent.bottom
552 dragAreaWidth: shell.edgeSize
553 available: !greeter.locked
554 onDashItemSelected: {
556 // Animate if moving between application and dash
558 dash.setCurrentScope("home.scope", true, false)
560 dash.setCurrentScope("home.scope", false, false)
566 dash.setCurrentScope("applications.scope", true, false)
571 onLauncherApplicationSelected:{
573 shell.activateApplication(desktopFile)
577 panel.indicators.hide()
586 model: NotificationBackend.Model
590 bottom: parent.bottom
591 leftMargin: units.gu(1)
592 rightMargin: units.gu(1)
593 topMargin: panel.panelHeight + units.gu(1)
598 when: overlay.width <= units.gu(60)
599 AnchorChanges { target: notifications; anchors.left: parent.left }
603 when: overlay.width > units.gu(60)
604 AnchorChanges { target: notifications; anchors.left: undefined }
605 PropertyChanges { target: notifications; width: units.gu(38) }
616 bottom: parent.bottom
619 width: shell.edgeSize
626 bottom: parent.bottom
629 width: shell.edgeSize
639 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
641 anchors.bottom: parent.bottom
642 anchors.left: parent.left
643 anchors.right: parent.right
644 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
646 enabled: shell.applicationManager && shell.applicationManager.keyboardVisible
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