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 defaultBackground: shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg"
45 property url background: backgroundSettings.pictureUri
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 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
68 applicationManager.sideStageEnabled = Qt.binding(function() { return sideStage.enabled })
70 // FIXME: if application focused before shell starts, shell draws on top of it only.
71 // We should detect already running applications on shell start and bring them to the front.
72 applicationManager.unfocusCurrentApplication();
75 readonly property bool fullscreenMode: {
76 if (greeter.shown || lockscreen.shown) {
78 } else if (mainStage.usingScreenshots) { // Window Manager animating so want to re-evaluate fullscreen mode
79 return mainStage.switchingFromFullscreenToFullscreen;
80 } else if (applicationManager.mainStageFocusedApplication) {
81 return applicationManager.mainStageFocusedApplication.fullscreen;
88 target: applicationManager
89 ignoreUnknownSignals: true
91 // TODO: this should be protected to only unlock for certain applications / certain usecases
92 // potentially only in connection with a notification
94 shell.activateApplication(desktopFile);
98 function activateApplication(desktopFile, argument) {
99 if (applicationManager) {
100 // For newly started applications, as it takes them time to draw their first frame
101 // we add a delay before we hide the animation screenshots to compensate.
102 var addDelay = !applicationManager.getApplicationFromDesktopFile(desktopFile);
105 application = applicationManager.activateApplication(desktopFile, argument);
106 if (application == null) {
109 if (application.stage == ApplicationInfo.MainStage || !sideStage.enabled) {
110 mainStage.activateApplication(desktopFile, addDelay);
112 sideStage.activateApplication(desktopFile, addDelay);
119 id: backgroundSettings
120 schema.id: "org.gnome.desktop.background"
127 Keys.onVolumeUpPressed: volumeControl.volumeUp()
128 Keys.onVolumeDownPressed: volumeControl.volumeDown()
131 if (event.key == Qt.Key_PowerOff) {
138 objectName: "underlay"
141 // Whether the underlay is fully covered by opaque UI elements.
142 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
144 // Whether the user should see the topmost application surface (if there's one at all).
145 property bool applicationSurfaceShouldBeSeen:
146 (mainStage.applications && mainStage.applications.count > 0)
147 && (!stages.fullyHidden && !mainStage.usingScreenshots)
149 // NB! Application surfaces are stacked behing the shell one. So they can only be seen by the user
150 // through the translucent parts of the shell surface.
151 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
155 objectName: "backgroundImage"
156 source: shell.background
159 if (status == Image.Error) {
160 backgroundSettings.pictureUri = shell.defaultBackground
168 opacity: dash.disappearingAnimationProgress
175 available: !greeter.shown && !lockscreen.shown
176 hides: [stages, launcher, panel.indicators]
177 shown: disappearingAnimationProgress !== 1.0
178 enabled: disappearingAnimationProgress === 0.0
179 // FIXME: unfocus all applications when going back to the dash
182 shell.applicationManager.unfocusCurrentApplication()
188 topMargin: panel.panelHeight
191 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
192 opacity: 1.0 - disappearingAnimationProgress
193 property real disappearingAnimationProgress: {
195 return greeter.showProgress;
197 return stagesOuterContainer.showProgress;
201 // FIXME: only necessary because stagesOuterContainer.showProgress and
202 // greeterRevealer.animatedProgress are not animated
203 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
208 id: stagesOuterContainer
211 height: parent.height
213 Behavior on x {SmoothedAnimation{velocity: 600}}
215 property real showProgress:
216 MathLocal.clamp(1 - (x + stages.x) / shell.width, 0, 1)
224 property bool fullyShown: shown && x == 0 && parent.x == 0
225 property bool fullyHidden: !shown && x == width
226 available: !greeter.shown
227 hides: [launcher, panel.indicators]
230 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
231 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
234 height: parent.height
236 // close the stages when no focused application remains
238 target: shell.applicationManager
239 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
240 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
241 ignoreUnknownSignals: true
244 function closeIfNoApplications() {
245 if (!shell.applicationManager.mainStageFocusedApplication
246 && !shell.applicationManager.sideStageFocusedApplication
247 && shell.applicationManager.mainStageApplications.count == 0
248 && shell.applicationManager.sideStageApplications.count == 0) {
253 // show the stages when an application gets the focus
255 target: shell.applicationManager
256 onMainStageFocusedApplicationChanged: {
257 if (shell.applicationManager.mainStageFocusedApplication) {
262 onSideStageFocusedApplicationChanged: {
263 if (shell.applicationManager.sideStageFocusedApplication) {
268 ignoreUnknownSignals: true
275 fullyShown: stages.fullyShown
276 fullyHidden: stages.fullyHidden
277 shouldUseScreenshots: !fullyShown
278 rightEdgeEnabled: !sideStage.enabled
280 applicationManager: shell.applicationManager
281 rightEdgeDraggingAreaWidth: shell.edgeSize
282 normalApplicationY: shell.panelHeight
291 // FIXME: workaround the fact that focusing a main stage application
292 // raises its surface on top of all other surfaces including the ones
293 // that belong to side stage applications.
294 onFocusedApplicationChanged: {
295 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
296 shell.applicationManager.focusApplication(sideStage.focusedApplication);
304 applicationManager: shell.applicationManager
305 rightEdgeDraggingAreaWidth: shell.edgeSize
306 normalApplicationY: shell.panelHeight
309 if (!shown && mainStage.applications.count == 0) {
313 // FIXME: when hiding the side stage, refocus the main stage
314 // application so that it goes in front of the side stage
315 // application and hides it
316 onFullyShownChanged: {
317 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
318 shell.applicationManager.focusApplication(mainStage.focusedApplication);
322 enabled: shell.width >= units.gu(60)
324 fullyShown: stages.fullyShown && shown
325 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
326 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
328 available: !greeter.shown && !lockscreen.shown && enabled
329 hides: [launcher, panel.indicators]
331 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
332 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
335 height: stages.height
336 handleExpanded: sideStageRevealer.pressed
340 id: sideStageRevealer
342 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
343 && sideStage.available
344 direction: Qt.RightToLeft
345 openedValue: parent.width - sideStage.width
346 hintDisplacement: units.gu(3)
347 /* The size of the sidestage handle needs to be bigger than the
348 typical size used for edge detection otherwise it is really
351 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
352 closedValue: parent.width + sideStage.handleSizeCollapsed
354 x: parent.width - width
355 width: sideStage.width + handleSize * 0.7
356 height: sideStage.height
357 orientation: Qt.Horizontal
363 anchors.top: parent.top
364 anchors.bottom: parent.bottom
365 anchors.right: parent.left
367 width: shell.edgeSize
368 direction: Direction.Leftwards
369 property bool haveApps: mainStage.applications.count > 0 || sideStage.applications.count > 0
371 maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
372 // Make autocompletion impossible when !haveApps
373 edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
380 hides: [launcher, panel.indicators, hud]
383 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
384 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
386 x: required ? 0 : - width
388 height: parent.height - panel.panelHeight
389 background: shell.background
391 onUnlocked: lockscreen.hide()
392 onCancel: greeter.show()
394 Component.onCompleted: {
395 if (LightDM.Users.count == 1) {
396 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
402 target: LightDM.Greeter
405 if (LightDM.Users.count == 1) {
406 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
408 lockscreen.alphaNumeric = false
410 lockscreen.alphaNumeric = true
412 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
420 objectName: "greeter"
423 hides: [launcher, panel.indicators, hud]
428 height: parent.height - panel.panelHeight
430 dragHandleWidth: shell.edgeSize
432 property var previousMainApp: null
433 property var previousSideApp: null
438 // If there is only one user, we start authenticating with that one here.
439 // If there are more users, the Greeter will handle that
440 if (LightDM.Users.count == 1) {
441 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
443 greeter.forceActiveFocus();
444 // FIXME: *FocusedApplication are not updated when unfocused, hence the need to check whether
445 // the stage was actually shown
446 if (mainStage.fullyShown) greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
447 if (sideStage.fullyShown) greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
448 applicationManager.unfocusCurrentApplication();
450 if (greeter.previousMainApp) {
451 applicationManager.focusApplication(greeter.previousMainApp);
452 greeter.previousMainApp = null;
454 if (greeter.previousSideApp) {
455 applicationManager.focusApplication(greeter.previousSideApp);
456 greeter.previousSideApp = null;
461 onUnlocked: greeter.hide()
463 var bgPath = greeter.model.data(uid, LightDM.UserRoles.BackgroundPathRole)
464 shell.background = bgPath ? bgPath : defaultBackground
467 onLeftTeaserPressedChanged: {
468 if (leftTeaserPressed) {
476 blockInput: greeter.shown || lockscreen.shown
486 anchors.fill: parent //because this draws indicator menus
487 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
491 fullscreenMode: shell.fullscreenMode
492 searchVisible: !greeter.shown && !lockscreen.shown
496 blockInput: panel.indicators.shown
503 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
504 height: parent.height
506 available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown
508 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
509 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
512 target: shell.applicationManager
513 onMainStageFocusedApplicationChanged: hud.hide()
514 onSideStageFocusedApplicationChanged: hud.hide()
519 blockInput: hud.shown
528 anchors.left: hud.left
529 height: parent.height
530 target: hud.revealerTarget
533 direction: Qt.RightToLeft
534 orientation: Qt.Vertical
535 handleSize: hud.handleHeight
536 onCloseClicked: target.hide()
542 enabled: !panel.indicators.shown
543 applicationIsOnForeground: applicationManager.mainStageFocusedApplication
544 || applicationManager.sideStageFocusedApplication
548 blockInput: launcher.shown
551 bottom: parent.bottom
554 width: launcher.width
559 objectName: "launcher"
561 anchors.top: parent.top
562 anchors.bottom: parent.bottom
564 dragAreaWidth: shell.edgeSize
565 available: !greeter.locked
566 onDashItemSelected: {
568 // Animate if moving between application and dash
570 dash.setCurrentScope("home.scope", true, false)
572 dash.setCurrentScope("home.scope", false, false)
578 dash.setCurrentScope("applications.scope", true /* animate */, true /* reset */)
583 onLauncherApplicationSelected:{
585 shell.activateApplication(desktopFile)
589 panel.indicators.hide()
598 model: NotificationBackend.Model
602 bottom: parent.bottom
603 leftMargin: units.gu(1)
604 rightMargin: units.gu(1)
605 topMargin: panel.panelHeight + units.gu(1)
610 when: overlay.width <= units.gu(60)
611 AnchorChanges { target: notifications; anchors.left: parent.left }
615 when: overlay.width > units.gu(60)
616 AnchorChanges { target: notifications; anchors.left: undefined }
617 PropertyChanges { target: notifications; width: units.gu(38) }
628 bottom: parent.bottom
631 width: shell.edgeSize
638 bottom: parent.bottom
641 width: shell.edgeSize
651 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
653 anchors.bottom: parent.bottom
654 anchors.left: parent.left
655 anchors.right: parent.right
656 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
658 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