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 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"
123 function updateImage() {
124 if (testImage.source == "")
127 if (testImage.status == Image.Ready) {
128 if (shell.width / shell.height <= testImage.sourceSize.width / testImage.sourceSize.height) {
129 backgroundImage.sourceSize.width = 0
130 backgroundImage.sourceSize.height = Qt.binding(function() { return shell.height })
132 backgroundImage.sourceSize.height = 0
133 backgroundImage.sourceSize.width = Qt.binding(function() { return shell.width })
136 shell.background = testImage.source
137 } else if (testImage.status == Image.Error) {
138 shell.background = shell.default_background
141 // unload testImage source to save memory
142 testImage.source = ""
148 property url gsettingsImage: backgroundSettings.pictureUri
150 source: gsettingsImage
153 onGsettingsImageChanged: source = gsettingsImage
154 onStatusChanged: updateImage()
161 Keys.onVolumeUpPressed: volumeControl.volumeUp()
162 Keys.onVolumeDownPressed: volumeControl.volumeDown()
165 if (event.key == Qt.Key_PowerOff) {
172 objectName: "underlay"
175 // Whether the underlay is fully covered by opaque UI elements.
176 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
178 // Whether the user should see the topmost application surface (if there's one at all).
179 property bool applicationSurfaceShouldBeSeen:
180 (mainStage.applications && mainStage.applications.count > 0)
181 && (!stages.fullyHidden && !mainStage.usingScreenshots)
183 // NB! Application surfaces are stacked behing the shell one. So they can only be seen by the user
184 // through the translucent parts of the shell surface.
185 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
189 source: shell.background
191 fillMode: Image.PreserveAspectCrop
197 opacity: dash.disappearingAnimationProgress
204 available: !greeter.shown && !lockscreen.shown
205 hides: [stages, launcher, panel.indicators]
206 shown: disappearingAnimationProgress !== 1.0
207 enabled: disappearingAnimationProgress === 0.0
208 // FIXME: unfocus all applications when going back to the dash
211 shell.applicationManager.unfocusCurrentApplication()
217 topMargin: panel.panelHeight
220 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
221 opacity: 1.0 - disappearingAnimationProgress
222 property real disappearingAnimationProgress: {
224 return greeter.showProgress;
226 return stagesOuterContainer.showProgress;
230 // FIXME: only necessary because stagesOuterContainer.showProgress and
231 // greeterRevealer.animatedProgress are not animated
232 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
238 id: stagesOuterContainer
241 height: parent.height
243 Behavior on x {SmoothedAnimation{velocity: 600}}
245 property real showProgress:
246 MathLocal.clamp(1 - (x + stages.x) / shell.width, 0, 1)
254 property bool fullyShown: shown && x == 0 && parent.x == 0
255 property bool fullyHidden: !shown && x == width
256 available: !greeter.shown
257 hides: [launcher, panel.indicators]
260 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
261 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
264 height: parent.height
266 // close the stages when no focused application remains
268 target: shell.applicationManager
269 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
270 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
271 ignoreUnknownSignals: true
274 function closeIfNoApplications() {
275 if (!shell.applicationManager.mainStageFocusedApplication
276 && !shell.applicationManager.sideStageFocusedApplication
277 && shell.applicationManager.mainStageApplications.count == 0
278 && shell.applicationManager.sideStageApplications.count == 0) {
283 // show the stages when an application gets the focus
285 target: shell.applicationManager
286 onMainStageFocusedApplicationChanged: {
287 if (shell.applicationManager.mainStageFocusedApplication) {
292 onSideStageFocusedApplicationChanged: {
293 if (shell.applicationManager.sideStageFocusedApplication) {
298 ignoreUnknownSignals: true
306 fullyShown: stages.fullyShown
307 fullyHidden: stages.fullyHidden
308 shouldUseScreenshots: !fullyShown
309 rightEdgeEnabled: !sideStage.enabled
311 applicationManager: shell.applicationManager
312 rightEdgeDraggingAreaWidth: shell.edgeSize
313 normalApplicationY: shell.panelHeight
322 // FIXME: workaround the fact that focusing a main stage application
323 // raises its surface on top of all other surfaces including the ones
324 // that belong to side stage applications.
325 onFocusedApplicationChanged: {
326 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
327 shell.applicationManager.focusApplication(sideStage.focusedApplication);
335 applicationManager: shell.applicationManager
336 rightEdgeDraggingAreaWidth: shell.edgeSize
337 normalApplicationY: shell.panelHeight
340 if (!shown && mainStage.applications.count == 0) {
344 // FIXME: when hiding the side stage, refocus the main stage
345 // application so that it goes in front of the side stage
346 // application and hides it
347 onFullyShownChanged: {
348 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
349 shell.applicationManager.focusApplication(mainStage.focusedApplication);
353 enabled: shell.width >= units.gu(60)
355 fullyShown: stages.fullyShown && shown
356 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
357 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
359 available: !greeter.shown && !lockscreen.shown && enabled
360 hides: [launcher, panel.indicators]
362 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
363 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
366 height: stages.height
367 handleExpanded: sideStageRevealer.pressed
371 id: sideStageRevealer
373 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
374 && sideStage.available
375 direction: Qt.RightToLeft
376 openedValue: parent.width - sideStage.width
377 hintDisplacement: units.gu(3)
378 /* The size of the sidestage handle needs to be bigger than the
379 typical size used for edge detection otherwise it is really
382 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
383 closedValue: parent.width + sideStage.handleSizeCollapsed
385 x: parent.width - width
386 width: sideStage.width + handleSize * 0.7
387 height: sideStage.height
388 orientation: Qt.Horizontal
394 anchors.top: parent.top
395 anchors.bottom: parent.bottom
396 anchors.right: parent.left
398 width: shell.edgeSize
399 direction: Direction.Leftwards
400 property bool haveApps: mainStage.applications.count > 0 || sideStage.applications.count > 0
402 maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
403 // Make autocompletion impossible when !haveApps
404 edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
411 hides: [launcher, panel.indicators, hud]
414 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
415 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
417 x: required ? 0 : - width
419 height: parent.height - panel.panelHeight
420 background: shell.background
422 onUnlocked: lockscreen.hide()
423 onCancel: greeter.show()
425 Component.onCompleted: {
426 if (LightDM.Users.count == 1) {
427 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
433 target: LightDM.Greeter
436 if (LightDM.Users.count == 1) {
437 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
439 lockscreen.alphaNumeric = false
441 lockscreen.alphaNumeric = true
443 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
451 objectName: "greeter"
454 hides: [launcher, panel.indicators, hud]
459 height: parent.height - panel.panelHeight
461 dragHandleWidth: shell.edgeSize
463 property var previousMainApp: null
464 property var previousSideApp: null
469 // If there is only one user, we start authenticating with that one here.
470 // If there are more users, the Greeter will handle that
471 if (LightDM.Users.count == 1) {
472 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
474 greeter.forceActiveFocus();
475 // FIXME: *FocusedApplication are not updated when unfocused, hence the need to check whether
476 // the stage was actually shown
477 if (mainStage.fullyShown) greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
478 if (sideStage.fullyShown) greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
479 applicationManager.unfocusCurrentApplication();
481 if (greeter.previousMainApp) {
482 applicationManager.focusApplication(greeter.previousMainApp);
483 greeter.previousMainApp = null;
485 if (greeter.previousSideApp) {
486 applicationManager.focusApplication(greeter.previousSideApp);
487 greeter.previousSideApp = null;
492 onUnlocked: greeter.hide()
494 var bgPath = greeter.model.data(uid, LightDM.UserRoles.BackgroundPathRole)
495 shell.background = bgPath ? bgPath : default_background
498 onLeftTeaserPressedChanged: {
499 if (leftTeaserPressed) {
507 blockInput: greeter.shown || lockscreen.shown
517 anchors.fill: parent //because this draws indicator menus
518 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
522 fullscreenMode: shell.fullscreenMode
523 searchVisible: !greeter.shown && !lockscreen.shown
527 blockInput: panel.indicators.shown
534 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
535 height: parent.height
537 available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown
539 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
540 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
543 target: shell.applicationManager
544 onMainStageFocusedApplicationChanged: hud.hide()
545 onSideStageFocusedApplicationChanged: hud.hide()
550 blockInput: hud.shown
559 anchors.left: hud.left
560 height: parent.height
561 target: hud.revealerTarget
564 direction: Qt.RightToLeft
565 orientation: Qt.Vertical
566 handleSize: hud.handleHeight
567 onCloseClicked: target.hide()
573 enabled: !panel.indicators.shown
574 applicationIsOnForeground: applicationManager.mainStageFocusedApplication
575 || applicationManager.sideStageFocusedApplication
579 blockInput: launcher.shown
582 bottom: parent.bottom
585 width: launcher.width
590 objectName: "launcher"
592 anchors.top: parent.top
593 anchors.bottom: parent.bottom
595 dragAreaWidth: shell.edgeSize
596 available: !greeter.locked
597 onDashItemSelected: {
599 // Animate if moving between application and dash
601 dash.setCurrentScope("home.scope", true, false)
603 dash.setCurrentScope("home.scope", false, false)
609 dash.setCurrentScope("applications.scope", true /* animate */, true /* reset */)
614 onLauncherApplicationSelected:{
616 shell.activateApplication(desktopFile)
620 panel.indicators.hide()
629 model: NotificationBackend.Model
633 bottom: parent.bottom
634 leftMargin: units.gu(1)
635 rightMargin: units.gu(1)
636 topMargin: panel.panelHeight + units.gu(1)
641 when: overlay.width <= units.gu(60)
642 AnchorChanges { target: notifications; anchors.left: parent.left }
646 when: overlay.width > units.gu(60)
647 AnchorChanges { target: notifications; anchors.left: undefined }
648 PropertyChanges { target: notifications; width: units.gu(38) }
659 bottom: parent.bottom
662 width: shell.edgeSize
669 bottom: parent.bottom
672 width: shell.edgeSize
682 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
684 anchors.bottom: parent.bottom
685 anchors.left: parent.left
686 anchors.right: parent.right
687 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
689 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