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.source == "")
125 if (testImage.status == Image.Ready) {
126 if (shell.width / shell.height <= testImage.sourceSize.width / testImage.sourceSize.height) {
127 backgroundImage.sourceSize.width = 0
128 backgroundImage.sourceSize.height = Qt.binding(function() { return shell.height })
130 backgroundImage.sourceSize.height = 0
131 backgroundImage.sourceSize.width = Qt.binding(function() { return shell.width })
134 shell.background = testImage.source
135 } else if (testImage.status == Image.Error) {
136 shell.background = shell.default_background
139 // unload testImage source to save memory
140 testImage.source = ""
146 property url gsettingsImage: backgroundSettings.pictureUri
148 source: gsettingsImage
151 onGsettingsImageChanged: source = gsettingsImage
152 onStatusChanged: updateImage()
159 Keys.onVolumeUpPressed: volumeControl.volumeUp()
160 Keys.onVolumeDownPressed: volumeControl.volumeDown()
163 if (event.key == Qt.Key_PowerOff) {
171 visible: !(panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth)
172 && (stages.fullyHidden
173 || (stages.fullyShown && mainStage.usingScreenshots)
174 || !stages.fullyShown && (mainStage.usingScreenshots || (sideStage.shown && sideStage.usingScreenshots)))
178 source: shell.background
180 fillMode: Image.PreserveAspectCrop
186 opacity: dash.disappearingAnimationProgress
192 available: !greeter.shown && !lockscreen.shown
193 hides: [stages, launcher, panel.indicators]
194 shown: disappearingAnimationProgress !== 1.0
195 enabled: disappearingAnimationProgress === 0.0
196 // FIXME: unfocus all applications when going back to the dash
199 shell.applicationManager.unfocusCurrentApplication()
205 topMargin: panel.panelHeight
208 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
209 opacity: 1.0 - disappearingAnimationProgress
210 property real disappearingAnimationProgress: {
212 return greeter.showProgress;
214 return stagesOuterContainer.showProgress;
218 // FIXME: only necessary because stagesRevealer.animatedProgress and
219 // greeterRevealer.animatedProgress are not animated
220 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
226 id: stagesOuterContainer
229 height: parent.height
231 Behavior on x {SmoothedAnimation{velocity: 600}}
233 property real showProgress:
234 MathLocal.clamp(1 - (x + stages.x) / shell.width, 0, 1)
241 property bool fullyShown: shown && x == 0 && parent.x == 0
242 property bool fullyHidden: !shown && x == width
243 available: !greeter.shown
244 hides: [launcher, panel.indicators]
247 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
248 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
251 height: parent.height
253 // close the stages when no focused application remains
255 target: shell.applicationManager
256 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
257 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
258 ignoreUnknownSignals: true
261 function closeIfNoApplications() {
262 if (!shell.applicationManager.mainStageFocusedApplication
263 && !shell.applicationManager.sideStageFocusedApplication
264 && shell.applicationManager.mainStageApplications.count == 0
265 && shell.applicationManager.sideStageApplications.count == 0) {
270 // show the stages when an application gets the focus
272 target: shell.applicationManager
273 onMainStageFocusedApplicationChanged: {
274 if (shell.applicationManager.mainStageFocusedApplication) {
279 onSideStageFocusedApplicationChanged: {
280 if (shell.applicationManager.sideStageFocusedApplication) {
285 ignoreUnknownSignals: true
293 fullyShown: stages.fullyShown
294 shouldUseScreenshots: !fullyShown
295 rightEdgeEnabled: !sideStage.enabled
297 applicationManager: shell.applicationManager
298 rightEdgeDraggingAreaWidth: shell.edgeSize
299 normalApplicationY: shell.panelHeight
305 function showWithoutAnimation() {
306 stages.showWithoutAnimation();
311 // FIXME: workaround the fact that focusing a main stage application
312 // raises its surface on top of all other surfaces including the ones
313 // that belong to side stage applications.
314 onFocusedApplicationChanged: {
315 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
316 shell.applicationManager.focusApplication(sideStage.focusedApplication);
324 applicationManager: shell.applicationManager
325 rightEdgeDraggingAreaWidth: shell.edgeSize
326 normalApplicationY: shell.panelHeight
329 if (!shown && mainStage.applications.count == 0) {
333 // FIXME: when hiding the side stage, refocus the main stage
334 // application so that it goes in front of the side stage
335 // application and hides it
336 onFullyShownChanged: {
337 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
338 shell.applicationManager.focusApplication(mainStage.focusedApplication);
342 enabled: shell.width >= units.gu(60)
344 fullyShown: stages.fullyShown && shown
345 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
346 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
348 available: !greeter.shown && !lockscreen.shown && enabled
349 hides: [launcher, panel.indicators]
351 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
352 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
355 height: stages.height
356 handleExpanded: sideStageRevealer.pressed
360 id: sideStageRevealer
362 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
363 && sideStage.available
364 direction: Qt.RightToLeft
365 openedValue: parent.width - sideStage.width
366 hintDisplacement: units.gu(3)
367 /* The size of the sidestage handle needs to be bigger than the
368 typical size used for edge detection otherwise it is really
371 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
372 closedValue: parent.width + sideStage.handleSizeCollapsed
374 x: parent.width - width
375 width: sideStage.width + handleSize * 0.7
376 height: sideStage.height
377 orientation: Qt.Horizontal
383 anchors.top: parent.top
384 anchors.bottom: parent.bottom
385 anchors.right: parent.left
387 width: shell.edgeSize
388 direction: Direction.Leftwards
389 enabled: mainStage.applications.count > 0 || sideStage.applications.count > 0
396 hides: [launcher, panel.indicators, hud]
399 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
400 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
402 x: required ? 0 : - width
404 height: parent.height - panel.panelHeight
405 background: shell.background
407 onUnlocked: lockscreen.hide()
408 onCancel: greeter.show()
410 Component.onCompleted: {
411 if (LightDM.Users.count == 1) {
412 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
418 target: LightDM.Greeter
421 if (LightDM.Users.count == 1) {
422 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
424 lockscreen.alphaNumeric = false
426 lockscreen.alphaNumeric = true
428 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
438 hides: [launcher, panel.indicators, hud]
443 height: parent.height - panel.panelHeight
445 dragHandleWidth: shell.edgeSize
447 property var previousMainApp: null
448 property var previousSideApp: null
453 // If there is only one user, we start authenticating with that one here.
454 // If there are more users, the Greeter will handle that
455 if (LightDM.Users.count == 1) {
456 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
458 greeter.forceActiveFocus();
459 // FIXME: *FocusedApplication are not updated when unfocused, hence the need to check whether
460 // the stage was actually shown
461 if (mainStage.fullyShown) greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
462 if (sideStage.fullyShown) greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
463 applicationManager.unfocusCurrentApplication();
465 if (greeter.previousMainApp) {
466 applicationManager.focusApplication(greeter.previousMainApp);
467 greeter.previousMainApp = null;
469 if (greeter.previousSideApp) {
470 applicationManager.focusApplication(greeter.previousSideApp);
471 greeter.previousSideApp = null;
476 onUnlocked: greeter.hide()
478 var bgPath = greeter.model.data(uid, LightDM.UserRoles.BackgroundPathRole)
479 shell.background = bgPath ? bgPath : default_background
482 onLeftTeaserPressedChanged: {
483 if (leftTeaserPressed) {
491 blockInput: greeter.shown || lockscreen.shown
501 anchors.fill: parent //because this draws indicator menus
502 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
506 fullscreenMode: shell.fullscreenMode
507 searchVisible: !greeter.shown && !lockscreen.shown
511 blockInput: panel.indicators.shown
518 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
519 height: parent.height
521 available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown
523 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
524 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
527 target: shell.applicationManager
528 onMainStageFocusedApplicationChanged: hud.hide()
529 onSideStageFocusedApplicationChanged: hud.hide()
534 blockInput: hud.shown
543 anchors.left: hud.left
544 height: parent.height
545 target: hud.revealerTarget
548 direction: Qt.RightToLeft
549 orientation: Qt.Vertical
550 handleSize: hud.handleHeight
551 onCloseClicked: target.hide()
557 enabled: !panel.indicators.shown
558 applicationIsOnForeground: applicationManager.mainStageFocusedApplication
559 || applicationManager.sideStageFocusedApplication
563 blockInput: launcher.shown
566 bottom: parent.bottom
569 width: launcher.width
575 anchors.top: parent.top
576 anchors.bottom: parent.bottom
578 dragAreaWidth: shell.edgeSize
579 available: !greeter.locked
580 onDashItemSelected: {
582 // Animate if moving between application and dash
584 dash.setCurrentScope("home.scope", true, false)
586 dash.setCurrentScope("home.scope", false, false)
592 dash.setCurrentScope("applications.scope", true, false)
597 onLauncherApplicationSelected:{
599 shell.activateApplication(desktopFile)
603 panel.indicators.hide()
612 model: NotificationBackend.Model
616 bottom: parent.bottom
617 leftMargin: units.gu(1)
618 rightMargin: units.gu(1)
619 topMargin: panel.panelHeight + units.gu(1)
624 when: overlay.width <= units.gu(60)
625 AnchorChanges { target: notifications; anchors.left: parent.left }
629 when: overlay.width > units.gu(60)
630 AnchorChanges { target: notifications; anchors.left: undefined }
631 PropertyChanges { target: notifications; width: units.gu(38) }
642 bottom: parent.bottom
645 width: shell.edgeSize
652 bottom: parent.bottom
655 width: shell.edgeSize
665 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
667 anchors.bottom: parent.bottom
668 anchors.left: parent.left
669 anchors.right: parent.right
670 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
672 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