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
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) : applicationArguments.hasGeometry() ? applicationArguments.width() : units.gu(40)
41 height: tablet ? units.gu(100) : applicationArguments.hasGeometry() ? applicationArguments.height() : 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);
122 Keys.onVolumeUpPressed: volumeControl.volumeUp()
123 Keys.onVolumeDownPressed: volumeControl.volumeDown()
127 objectName: "underlay"
130 // Whether the underlay is fully covered by opaque UI elements.
131 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
133 // Whether the user should see the topmost application surface (if there's one at all).
134 property bool applicationSurfaceShouldBeSeen:
135 (mainStage.applications && mainStage.applications.count > 0)
136 && (!stages.fullyHidden && !mainStage.usingScreenshots)
138 // NB! Application surfaces are stacked behing the shell one. So they can only be seen by the user
139 // through the translucent parts of the shell surface.
140 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
144 source: shell.background
145 sourceSize.width: parent.width
146 sourceSize.height: parent.height
153 opacity: dash.disappearingAnimationProgress
160 available: !greeter.shown && !lockscreen.shown
161 hides: [stages, launcher, panel.indicators]
162 shown: disappearingAnimationProgress !== 1.0
163 enabled: disappearingAnimationProgress === 0.0
164 // FIXME: unfocus all applications when going back to the dash
167 shell.applicationManager.unfocusCurrentApplication()
173 topMargin: panel.panelHeight
176 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
177 opacity: 1.0 - disappearingAnimationProgress
178 property real disappearingAnimationProgress: {
180 return greeter.showProgress;
182 return stagesOuterContainer.showProgress;
186 // FIXME: only necessary because stagesOuterContainer.showProgress and
187 // greeterRevealer.animatedProgress are not animated
188 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
194 id: stagesOuterContainer
197 height: parent.height
199 Behavior on x {SmoothedAnimation{velocity: 600}}
201 property real showProgress:
202 MathLocal.clamp(1 - (x + stages.x) / shell.width, 0, 1)
210 property bool fullyShown: shown && x == 0 && parent.x == 0
211 property bool fullyHidden: !shown && x == width
212 available: !greeter.shown
213 hides: [launcher, panel.indicators]
216 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
217 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
220 height: parent.height
222 // close the stages when no focused application remains
224 target: shell.applicationManager
225 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
226 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
227 ignoreUnknownSignals: true
230 function closeIfNoApplications() {
231 if (!shell.applicationManager.mainStageFocusedApplication
232 && !shell.applicationManager.sideStageFocusedApplication
233 && shell.applicationManager.mainStageApplications.count == 0
234 && shell.applicationManager.sideStageApplications.count == 0) {
239 // show the stages when an application gets the focus
241 target: shell.applicationManager
242 onMainStageFocusedApplicationChanged: {
243 if (shell.applicationManager.mainStageFocusedApplication) {
248 onSideStageFocusedApplicationChanged: {
249 if (shell.applicationManager.sideStageFocusedApplication) {
254 ignoreUnknownSignals: true
262 fullyShown: stages.fullyShown
263 fullyHidden: stages.fullyHidden
264 shouldUseScreenshots: !fullyShown
265 rightEdgeEnabled: !sideStage.enabled
267 applicationManager: shell.applicationManager
268 rightEdgeDraggingAreaWidth: shell.edgeSize
269 normalApplicationY: shell.panelHeight
278 // FIXME: workaround the fact that focusing a main stage application
279 // raises its surface on top of all other surfaces including the ones
280 // that belong to side stage applications.
281 onFocusedApplicationChanged: {
282 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
283 shell.applicationManager.focusApplication(sideStage.focusedApplication);
291 applicationManager: shell.applicationManager
292 rightEdgeDraggingAreaWidth: shell.edgeSize
293 normalApplicationY: shell.panelHeight
296 if (!shown && mainStage.applications.count == 0) {
300 // FIXME: when hiding the side stage, refocus the main stage
301 // application so that it goes in front of the side stage
302 // application and hides it
303 onFullyShownChanged: {
304 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
305 shell.applicationManager.focusApplication(mainStage.focusedApplication);
309 enabled: shell.width >= units.gu(60)
311 fullyShown: stages.fullyShown && shown
312 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
313 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
315 available: !greeter.shown && !lockscreen.shown && enabled
316 hides: [launcher, panel.indicators]
318 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
319 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
322 height: stages.height
323 handleExpanded: sideStageRevealer.pressed
327 id: sideStageRevealer
329 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
330 && sideStage.available
331 direction: Qt.RightToLeft
332 openedValue: parent.width - sideStage.width
333 hintDisplacement: units.gu(3)
334 /* The size of the sidestage handle needs to be bigger than the
335 typical size used for edge detection otherwise it is really
338 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
339 closedValue: parent.width + sideStage.handleSizeCollapsed
341 x: parent.width - width
342 width: sideStage.width + handleSize * 0.7
343 height: sideStage.height
344 orientation: Qt.Horizontal
350 anchors.top: parent.top
351 anchors.bottom: parent.bottom
352 anchors.right: parent.left
354 width: shell.edgeSize
355 direction: Direction.Leftwards
356 property bool haveApps: mainStage.applications.count > 0 || sideStage.applications.count > 0
358 maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
359 // Make autocompletion impossible when !haveApps
360 edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
367 hides: [launcher, panel.indicators, hud]
370 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
371 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
373 x: required ? 0 : - width
375 height: parent.height - panel.panelHeight
376 background: shell.background
378 onUnlocked: lockscreen.hide()
379 onCancel: greeter.show()
381 Component.onCompleted: {
382 if (LightDM.Users.count == 1) {
383 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
389 target: LightDM.Greeter
392 if (LightDM.Users.count == 1) {
393 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
395 lockscreen.alphaNumeric = false
397 lockscreen.alphaNumeric = true
399 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
409 hides: [launcher, panel.indicators, hud]
414 height: parent.height - panel.panelHeight
416 dragHandleWidth: shell.edgeSize
421 // If there is only one user, we start authenticating with that one here.
422 // If there are more users, the Greeter will handle that
423 if (LightDM.Users.count == 1) {
424 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
426 greeter.forceActiveFocus();
430 onUnlocked: greeter.hide()
432 var bgPath = greeter.model.data(uid, LightDM.UserRoles.BackgroundPathRole)
433 shell.background = bgPath ? bgPath : default_background
436 onLeftTeaserPressedChanged: {
437 if (leftTeaserPressed) {
445 blockInput: greeter.shown || lockscreen.shown
452 property var previousMainApp: null
453 property var previousSideApp: null
455 function setFocused(focused) {
457 // FIXME: *FocusedApplication are not updated when unfocused, hence the need to check whether
458 // the stage was actually shown
459 if (mainStage.fullyShown) powerConnection.previousMainApp = applicationManager.mainStageFocusedApplication;
460 if (sideStage.fullyShown) powerConnection.previousSideApp = applicationManager.sideStageFocusedApplication;
461 applicationManager.unfocusCurrentApplication();
463 if (powerConnection.previousMainApp) {
464 applicationManager.focusApplication(powerConnection.previousMainApp);
465 powerConnection.previousMainApp = null;
467 if (powerConnection.previousSideApp) {
468 applicationManager.focusApplication(powerConnection.previousSideApp);
469 powerConnection.previousSideApp = null;
474 onPowerStateChange: {
475 if (state == 0) { // suspend
476 powerConnection.setFocused(false);
478 } else if (state == 1) { // active
479 powerConnection.setFocused(true);
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.shown || greeter.narrowMode
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
667 visible: applicationManager.fake
668 text: "EARLY ALPHA\nNOT READY FOR USE"
671 font.weight: Font.Black
672 horizontalAlignment: Text.AlignHCenter
673 verticalAlignment: Text.AlignVCenter
674 fontSizeMode: Text.Fit
675 font.pixelSize: height/2
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