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) {
133 visible: !(panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth)
134 && (stages.fullyHidden
135 || (stages.fullyShown && mainStage.usingScreenshots)
136 || !stages.fullyShown && (mainStage.usingScreenshots || (sideStage.shown && sideStage.usingScreenshots)))
140 source: shell.background
141 sourceSize.width: parent.width
142 sourceSize.height: parent.height
149 opacity: dash.disappearingAnimationProgress
155 available: !greeter.shown && !lockscreen.shown
156 hides: [stages, launcher, panel.indicators]
157 shown: disappearingAnimationProgress !== 1.0
158 enabled: disappearingAnimationProgress === 0.0
159 // FIXME: unfocus all applications when going back to the dash
162 shell.applicationManager.unfocusCurrentApplication()
168 topMargin: panel.panelHeight
171 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
172 opacity: 1.0 - disappearingAnimationProgress
173 property real disappearingAnimationProgress: {
175 return greeter.showProgress;
177 return stagesOuterContainer.showProgress;
181 // FIXME: only necessary because stagesRevealer.animatedProgress and
182 // greeterRevealer.animatedProgress are not animated
183 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
189 id: stagesOuterContainer
192 height: parent.height
194 Behavior on x {SmoothedAnimation{velocity: 600}}
196 property real showProgress:
197 MathLocal.clamp(1 - (x + stages.x) / shell.width, 0, 1)
204 property bool fullyShown: shown && x == 0 && parent.x == 0
205 property bool fullyHidden: !shown && x == width
206 available: !greeter.shown
207 hides: [launcher, panel.indicators]
210 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
211 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
214 height: parent.height
216 // close the stages when no focused application remains
218 target: shell.applicationManager
219 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
220 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
221 ignoreUnknownSignals: true
224 function closeIfNoApplications() {
225 if (!shell.applicationManager.mainStageFocusedApplication
226 && !shell.applicationManager.sideStageFocusedApplication
227 && shell.applicationManager.mainStageApplications.count == 0
228 && shell.applicationManager.sideStageApplications.count == 0) {
233 // show the stages when an application gets the focus
235 target: shell.applicationManager
236 onMainStageFocusedApplicationChanged: {
237 if (shell.applicationManager.mainStageFocusedApplication) {
242 onSideStageFocusedApplicationChanged: {
243 if (shell.applicationManager.sideStageFocusedApplication) {
248 ignoreUnknownSignals: true
256 fullyShown: stages.fullyShown
257 shouldUseScreenshots: !fullyShown
258 rightEdgeEnabled: !sideStage.enabled
260 applicationManager: shell.applicationManager
261 rightEdgeDraggingAreaWidth: shell.edgeSize
262 normalApplicationY: shell.panelHeight
271 // FIXME: workaround the fact that focusing a main stage application
272 // raises its surface on top of all other surfaces including the ones
273 // that belong to side stage applications.
274 onFocusedApplicationChanged: {
275 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
276 shell.applicationManager.focusApplication(sideStage.focusedApplication);
284 applicationManager: shell.applicationManager
285 rightEdgeDraggingAreaWidth: shell.edgeSize
286 normalApplicationY: shell.panelHeight
289 if (!shown && mainStage.applications.count == 0) {
293 // FIXME: when hiding the side stage, refocus the main stage
294 // application so that it goes in front of the side stage
295 // application and hides it
296 onFullyShownChanged: {
297 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
298 shell.applicationManager.focusApplication(mainStage.focusedApplication);
302 enabled: shell.width >= units.gu(60)
304 fullyShown: stages.fullyShown && shown
305 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
306 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
308 available: !greeter.shown && !lockscreen.shown && enabled
309 hides: [launcher, panel.indicators]
311 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
312 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
315 height: stages.height
316 handleExpanded: sideStageRevealer.pressed
320 id: sideStageRevealer
322 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
323 && sideStage.available
324 direction: Qt.RightToLeft
325 openedValue: parent.width - sideStage.width
326 hintDisplacement: units.gu(3)
327 /* The size of the sidestage handle needs to be bigger than the
328 typical size used for edge detection otherwise it is really
331 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
332 closedValue: parent.width + sideStage.handleSizeCollapsed
334 x: parent.width - width
335 width: sideStage.width + handleSize * 0.7
336 height: sideStage.height
337 orientation: Qt.Horizontal
343 anchors.top: parent.top
344 anchors.bottom: parent.bottom
345 anchors.right: parent.left
347 width: shell.edgeSize
348 direction: Direction.Leftwards
349 enabled: mainStage.applications.count > 0 || sideStage.applications.count > 0
356 hides: [launcher, panel.indicators, hud]
359 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
360 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
362 x: required ? 0 : - width
364 height: parent.height - panel.panelHeight
365 background: shell.background
367 onUnlocked: lockscreen.hide()
368 onCancel: greeter.show()
370 Component.onCompleted: {
371 if (LightDM.Users.count == 1) {
372 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
378 target: LightDM.Greeter
381 if (LightDM.Users.count == 1) {
382 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
384 lockscreen.alphaNumeric = false
386 lockscreen.alphaNumeric = true
388 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
398 hides: [launcher, panel.indicators, hud]
403 height: parent.height - panel.panelHeight
405 dragHandleWidth: shell.edgeSize
407 property var previousMainApp: null
408 property var previousSideApp: null
413 // If there is only one user, we start authenticating with that one here.
414 // If there are more users, the Greeter will handle that
415 if (LightDM.Users.count == 1) {
416 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
418 greeter.forceActiveFocus();
419 // FIXME: *FocusedApplication are not updated when unfocused, hence the need to check whether
420 // the stage was actually shown
421 if (mainStage.fullyShown) greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
422 if (sideStage.fullyShown) greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
423 applicationManager.unfocusCurrentApplication();
425 if (greeter.previousMainApp) {
426 applicationManager.focusApplication(greeter.previousMainApp);
427 greeter.previousMainApp = null;
429 if (greeter.previousSideApp) {
430 applicationManager.focusApplication(greeter.previousSideApp);
431 greeter.previousSideApp = null;
436 onUnlocked: greeter.hide()
438 var bgPath = greeter.model.data(uid, LightDM.UserRoles.BackgroundPathRole)
439 shell.background = bgPath ? bgPath : default_background
442 onLeftTeaserPressedChanged: {
443 if (leftTeaserPressed) {
451 blockInput: greeter.shown || lockscreen.shown
461 anchors.fill: parent //because this draws indicator menus
462 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
466 fullscreenMode: shell.fullscreenMode
467 searchVisible: !greeter.shown && !lockscreen.shown
471 blockInput: panel.indicators.shown
478 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
479 height: parent.height
481 available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown
483 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
484 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
487 target: shell.applicationManager
488 onMainStageFocusedApplicationChanged: hud.hide()
489 onSideStageFocusedApplicationChanged: hud.hide()
494 blockInput: hud.shown
503 anchors.left: hud.left
504 height: parent.height
505 target: hud.revealerTarget
508 direction: Qt.RightToLeft
509 orientation: Qt.Vertical
510 handleSize: hud.handleHeight
511 onCloseClicked: target.hide()
517 enabled: !panel.indicators.shown
518 applicationIsOnForeground: applicationManager.mainStageFocusedApplication
519 || applicationManager.sideStageFocusedApplication
523 blockInput: launcher.shown
526 bottom: parent.bottom
529 width: launcher.width
535 anchors.top: parent.top
536 anchors.bottom: parent.bottom
538 dragAreaWidth: shell.edgeSize
539 available: !greeter.locked
540 onDashItemSelected: {
542 // Animate if moving between application and dash
544 dash.setCurrentScope("home.scope", true, false)
546 dash.setCurrentScope("home.scope", false, false)
552 dash.setCurrentScope("applications.scope", true, false)
557 onLauncherApplicationSelected:{
559 shell.activateApplication(desktopFile)
563 panel.indicators.hide()
572 model: NotificationBackend.Model
576 bottom: parent.bottom
577 leftMargin: units.gu(1)
578 rightMargin: units.gu(1)
579 topMargin: panel.panelHeight + units.gu(1)
584 when: overlay.width <= units.gu(60)
585 AnchorChanges { target: notifications; anchors.left: parent.left }
589 when: overlay.width > units.gu(60)
590 AnchorChanges { target: notifications; anchors.left: undefined }
591 PropertyChanges { target: notifications; width: units.gu(38) }
602 bottom: parent.bottom
605 width: shell.edgeSize
612 bottom: parent.bottom
615 width: shell.edgeSize
625 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
627 anchors.bottom: parent.bottom
628 anchors.left: parent.left
629 anchors.right: parent.right
630 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
632 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