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
29import "Components/Math.js" as MathLocal
33import Unity.Notifications 1.0 as NotificationBackend
38 // this is only here to select the width / height of the window if not running fullscreen
39 property bool tablet: false
40 width: tablet ? units.gu(160) : units.gu(40)
41 height: tablet ? units.gu(100) : units.gu(71)
43 property real edgeSize: units.gu(2)
44 property url default_background: shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg"
45 property url background: default_background
46 readonly property real panelHeight: panel.panelHeight
48 property bool dashShown: dash.shown
49 property bool stageScreenshotsReady: {
50 if (sideStage.shown) {
51 if (mainStage.applications.count > 0) {
52 return mainStage.usingScreenshots && sideStage.usingScreenshots;
54 return sideStage.usingScreenshots;
57 return mainStage.usingScreenshots;
61 property ListModel searchHistory: SearchHistoryModel {}
63 property var applicationManager: ApplicationManagerWrapper {}
65 Component.onCompleted: {
66 applicationManager.sideStageEnabled = Qt.binding(function() { return sideStage.enabled })
68 // FIXME: if application focused before shell starts, shell draws on top of it only.
69 // We should detect already running applications on shell start and bring them to the front.
70 applicationManager.unfocusCurrentApplication();
73 readonly property bool fullscreenMode: {
74 if (greeter.shown || lockscreen.shown) {
76 } else if (mainStage.usingScreenshots) { // Window Manager animating so want to re-evaluate fullscreen mode
77 return mainStage.switchingFromFullscreenToFullscreen;
78 } else if (applicationManager.mainStageFocusedApplication) {
79 return applicationManager.mainStageFocusedApplication.fullscreen;
86 target: applicationManager
87 ignoreUnknownSignals: true
89 // TODO: this should be protected to only unlock for certain applications / certain usecases
90 // potentially only in connection with a notification
92 shell.activateApplication(desktopFile);
96 function activateApplication(desktopFile, argument) {
97 if (applicationManager) {
98 // For newly started applications, as it takes them time to draw their first frame
99 // we add a delay before we hide the animation screenshots to compensate.
100 var addDelay = !applicationManager.getApplicationFromDesktopFile(desktopFile);
103 application = applicationManager.activateApplication(desktopFile, argument);
104 if (application == null) {
107 if (application.stage == ApplicationInfo.MainStage || !sideStage.enabled) {
108 mainStage.activateApplication(desktopFile, addDelay);
110 sideStage.activateApplication(desktopFile, addDelay);
117 id: backgroundSettings
118 schema: "org.gnome.desktop.background"
121 function updateImage() {
122 if (testImage.status == Image.Ready) {
123 if (shell.width / shell.height <= testImage.sourceSize.width / testImage.sourceSize.height) {
124 backgroundImage.sourceSize = undefined
125 backgroundImage.sourceSize.height = shell.height
128 backgroundImage.sourceSize = undefined
129 backgroundImage.sourceSize.width = shell.width
132 shell.background = testImage.source
133 } else if (testImage.status == Image.Error) {
134 shell.background = shell.default_background
140 source: backgroundSettings.pictureUri
142 onStatusChanged: updateImage()
149 Keys.onVolumeUpPressed: volumeControl.volumeUp()
150 Keys.onVolumeDownPressed: volumeControl.volumeDown()
153 if (event.key == Qt.Key_PowerOff) {
161 visible: !(panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth)
162 && (stages.fullyHidden
163 || (stages.fullyShown && mainStage.usingScreenshots)
164 || !stages.fullyShown && (mainStage.usingScreenshots || (sideStage.shown && sideStage.usingScreenshots)))
168 source: shell.background
170 fillMode: Image.PreserveAspectCrop
176 opacity: dash.disappearingAnimationProgress
182 available: !greeter.shown && !lockscreen.shown
183 hides: [stages, launcher, panel.indicators]
184 shown: disappearingAnimationProgress !== 1.0
185 enabled: disappearingAnimationProgress === 0.0
186 // FIXME: unfocus all applications when going back to the dash
189 shell.applicationManager.unfocusCurrentApplication()
195 topMargin: panel.panelHeight
198 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
199 opacity: 1.0 - disappearingAnimationProgress
200 property real disappearingAnimationProgress: {
202 return greeter.showProgress;
204 return stagesOuterContainer.showProgress;
208 // FIXME: only necessary because stagesRevealer.animatedProgress and
209 // greeterRevealer.animatedProgress are not animated
210 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
216 id: stagesOuterContainer
219 height: parent.height
221 Behavior on x {SmoothedAnimation{velocity: 600}}
223 property real showProgress:
224 MathLocal.clamp(1 - (x + stages.x) / shell.width, 0, 1)
231 property bool fullyShown: shown && x == 0 && parent.x == 0
232 property bool fullyHidden: !shown && x == width
233 available: !greeter.shown
234 hides: [launcher, panel.indicators]
237 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
238 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
241 height: parent.height
243 // close the stages when no focused application remains
245 target: shell.applicationManager
246 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
247 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
248 ignoreUnknownSignals: true
251 function closeIfNoApplications() {
252 if (!shell.applicationManager.mainStageFocusedApplication
253 && !shell.applicationManager.sideStageFocusedApplication
254 && shell.applicationManager.mainStageApplications.count == 0
255 && shell.applicationManager.sideStageApplications.count == 0) {
260 // show the stages when an application gets the focus
262 target: shell.applicationManager
263 onMainStageFocusedApplicationChanged: {
264 if (shell.applicationManager.mainStageFocusedApplication) {
269 onSideStageFocusedApplicationChanged: {
270 if (shell.applicationManager.sideStageFocusedApplication) {
275 ignoreUnknownSignals: true
283 fullyShown: stages.fullyShown
284 shouldUseScreenshots: !fullyShown
285 rightEdgeEnabled: !sideStage.enabled
287 applicationManager: shell.applicationManager
288 rightEdgeDraggingAreaWidth: shell.edgeSize
289 normalApplicationY: shell.panelHeight
295 function showWithoutAnimation() {
296 stages.showWithoutAnimation();
301 // FIXME: workaround the fact that focusing a main stage application
302 // raises its surface on top of all other surfaces including the ones
303 // that belong to side stage applications.
304 onFocusedApplicationChanged: {
305 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
306 shell.applicationManager.focusApplication(sideStage.focusedApplication);
314 applicationManager: shell.applicationManager
315 rightEdgeDraggingAreaWidth: shell.edgeSize
316 normalApplicationY: shell.panelHeight
319 if (!shown && mainStage.applications.count == 0) {
323 // FIXME: when hiding the side stage, refocus the main stage
324 // application so that it goes in front of the side stage
325 // application and hides it
326 onFullyShownChanged: {
327 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
328 shell.applicationManager.focusApplication(mainStage.focusedApplication);
332 enabled: shell.width >= units.gu(60)
334 fullyShown: stages.fullyShown && shown
335 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
336 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
338 available: !greeter.shown && !lockscreen.shown && enabled
339 hides: [launcher, panel.indicators]
341 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
342 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
345 height: stages.height
346 handleExpanded: sideStageRevealer.pressed
350 id: sideStageRevealer
352 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
353 && sideStage.available
354 direction: Qt.RightToLeft
355 openedValue: parent.width - sideStage.width
356 hintDisplacement: units.gu(3)
357 /* The size of the sidestage handle needs to be bigger than the
358 typical size used for edge detection otherwise it is really
361 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
362 closedValue: parent.width + sideStage.handleSizeCollapsed
364 x: parent.width - width
365 width: sideStage.width + handleSize * 0.7
366 height: sideStage.height
367 orientation: Qt.Horizontal
373 anchors.top: parent.top
374 anchors.bottom: parent.bottom
375 anchors.right: parent.left
377 width: shell.edgeSize
378 direction: Direction.Leftwards
379 enabled: mainStage.applications.count > 0 || sideStage.applications.count > 0
386 hides: [launcher, panel.indicators, hud]
389 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
390 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
392 x: required ? 0 : - width
394 height: parent.height - panel.panelHeight
395 background: shell.background
397 onUnlocked: lockscreen.hide()
398 onCancel: greeter.show()
400 Component.onCompleted: {
401 if (LightDM.Users.count == 1) {
402 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
408 target: LightDM.Greeter
411 if (LightDM.Users.count == 1) {
412 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
414 lockscreen.alphaNumeric = false
416 lockscreen.alphaNumeric = true
418 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
428 hides: [launcher, panel.indicators, hud]
433 height: parent.height - panel.panelHeight
435 dragHandleWidth: shell.edgeSize
437 property var previousMainApp: null
438 property var previousSideApp: null
443 // If there is only one user, we start authenticating with that one here.
444 // If there are more users, the Greeter will handle that
445 if (LightDM.Users.count == 1) {
446 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
448 greeter.forceActiveFocus();
449 // FIXME: *FocusedApplication are not updated when unfocused, hence the need to check whether
450 // the stage was actually shown
451 if (mainStage.fullyShown) greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
452 if (sideStage.fullyShown) greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
453 applicationManager.unfocusCurrentApplication();
455 if (greeter.previousMainApp) {
456 applicationManager.focusApplication(greeter.previousMainApp);
457 greeter.previousMainApp = null;
459 if (greeter.previousSideApp) {
460 applicationManager.focusApplication(greeter.previousSideApp);
461 greeter.previousSideApp = null;
466 onUnlocked: greeter.hide()
468 var bgPath = greeter.model.data(uid, LightDM.UserRoles.BackgroundPathRole)
469 shell.background = bgPath ? bgPath : default_background
472 onLeftTeaserPressedChanged: {
473 if (leftTeaserPressed) {
481 blockInput: greeter.shown || lockscreen.shown
491 anchors.fill: parent //because this draws indicator menus
492 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
496 fullscreenMode: shell.fullscreenMode
497 searchVisible: !greeter.shown && !lockscreen.shown
501 blockInput: panel.indicators.shown
508 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
509 height: parent.height
511 available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown
513 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
514 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
517 target: shell.applicationManager
518 onMainStageFocusedApplicationChanged: hud.hide()
519 onSideStageFocusedApplicationChanged: hud.hide()
524 blockInput: hud.shown
533 anchors.left: hud.left
534 height: parent.height
535 target: hud.revealerTarget
538 direction: Qt.RightToLeft
539 orientation: Qt.Vertical
540 handleSize: hud.handleHeight
541 onCloseClicked: target.hide()
547 enabled: !panel.indicators.shown
548 applicationIsOnForeground: applicationManager.mainStageFocusedApplication
549 || applicationManager.sideStageFocusedApplication
553 blockInput: launcher.shown
556 bottom: parent.bottom
559 width: launcher.width
565 anchors.top: parent.top
566 anchors.bottom: parent.bottom
568 dragAreaWidth: shell.edgeSize
569 available: !greeter.locked
570 onDashItemSelected: {
572 // Animate if moving between application and dash
574 dash.setCurrentScope("home.scope", true, false)
576 dash.setCurrentScope("home.scope", false, false)
582 dash.setCurrentScope("applications.scope", true, false)
587 onLauncherApplicationSelected:{
589 shell.activateApplication(desktopFile)
593 panel.indicators.hide()
602 model: NotificationBackend.Model
606 bottom: parent.bottom
607 leftMargin: units.gu(1)
608 rightMargin: units.gu(1)
609 topMargin: panel.panelHeight + units.gu(1)
614 when: overlay.width <= units.gu(60)
615 AnchorChanges { target: notifications; anchors.left: parent.left }
619 when: overlay.width > units.gu(60)
620 AnchorChanges { target: notifications; anchors.left: undefined }
621 PropertyChanges { target: notifications; width: units.gu(38) }
632 bottom: parent.bottom
635 width: shell.edgeSize
642 bottom: parent.bottom
645 width: shell.edgeSize
655 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
657 anchors.bottom: parent.bottom
658 anchors.left: parent.left
659 anchors.right: parent.right
660 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
662 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