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 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.id: "org.gnome.desktop.background"
125 Keys.onVolumeUpPressed: volumeControl.volumeUp()
126 Keys.onVolumeDownPressed: volumeControl.volumeDown()
129 if (event.key == Qt.Key_PowerOff) {
137 visible: !(panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth)
138 && (stages.fullyHidden
139 || (stages.fullyShown && mainStage.usingScreenshots)
140 || !stages.fullyShown && (mainStage.usingScreenshots || (sideStage.shown && sideStage.usingScreenshots)))
144 source: shell.background
147 if (status == Image.Error) {
148 backgroundSettings.pictureUri = shell.defaultBackground
156 opacity: dash.disappearingAnimationProgress
162 available: !greeter.shown && !lockscreen.shown
163 hides: [stages, launcher, panel.indicators]
164 shown: disappearingAnimationProgress !== 1.0
165 enabled: disappearingAnimationProgress === 0.0
166 // FIXME: unfocus all applications when going back to the dash
169 shell.applicationManager.unfocusCurrentApplication()
175 topMargin: panel.panelHeight
178 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
179 opacity: 1.0 - disappearingAnimationProgress
180 property real disappearingAnimationProgress: {
182 return greeter.showProgress;
184 return stagesOuterContainer.showProgress;
188 // FIXME: only necessary because stagesRevealer.animatedProgress and
189 // greeterRevealer.animatedProgress are not animated
190 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
196 id: stagesOuterContainer
199 height: parent.height
201 Behavior on x {SmoothedAnimation{velocity: 600}}
203 property real showProgress:
204 MathLocal.clamp(1 - (x + stages.x) / shell.width, 0, 1)
211 property bool fullyShown: shown && x == 0 && parent.x == 0
212 property bool fullyHidden: !shown && x == width
213 available: !greeter.shown
214 hides: [launcher, panel.indicators]
217 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
218 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
221 height: parent.height
223 // close the stages when no focused application remains
225 target: shell.applicationManager
226 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
227 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
228 ignoreUnknownSignals: true
231 function closeIfNoApplications() {
232 if (!shell.applicationManager.mainStageFocusedApplication
233 && !shell.applicationManager.sideStageFocusedApplication
234 && shell.applicationManager.mainStageApplications.count == 0
235 && shell.applicationManager.sideStageApplications.count == 0) {
240 // show the stages when an application gets the focus
242 target: shell.applicationManager
243 onMainStageFocusedApplicationChanged: {
244 if (shell.applicationManager.mainStageFocusedApplication) {
249 onSideStageFocusedApplicationChanged: {
250 if (shell.applicationManager.sideStageFocusedApplication) {
255 ignoreUnknownSignals: true
263 fullyShown: stages.fullyShown
264 shouldUseScreenshots: !fullyShown
265 rightEdgeEnabled: !sideStage.enabled
267 applicationManager: shell.applicationManager
268 rightEdgeDraggingAreaWidth: shell.edgeSize
269 normalApplicationY: shell.panelHeight
275 function showWithoutAnimation() {
276 stages.showWithoutAnimation();
281 // FIXME: workaround the fact that focusing a main stage application
282 // raises its surface on top of all other surfaces including the ones
283 // that belong to side stage applications.
284 onFocusedApplicationChanged: {
285 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
286 shell.applicationManager.focusApplication(sideStage.focusedApplication);
294 applicationManager: shell.applicationManager
295 rightEdgeDraggingAreaWidth: shell.edgeSize
296 normalApplicationY: shell.panelHeight
299 if (!shown && mainStage.applications.count == 0) {
303 // FIXME: when hiding the side stage, refocus the main stage
304 // application so that it goes in front of the side stage
305 // application and hides it
306 onFullyShownChanged: {
307 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
308 shell.applicationManager.focusApplication(mainStage.focusedApplication);
312 enabled: shell.width >= units.gu(60)
314 fullyShown: stages.fullyShown && shown
315 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
316 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
318 available: !greeter.shown && !lockscreen.shown && enabled
319 hides: [launcher, panel.indicators]
321 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
322 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
325 height: stages.height
326 handleExpanded: sideStageRevealer.pressed
330 id: sideStageRevealer
332 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
333 && sideStage.available
334 direction: Qt.RightToLeft
335 openedValue: parent.width - sideStage.width
336 hintDisplacement: units.gu(3)
337 /* The size of the sidestage handle needs to be bigger than the
338 typical size used for edge detection otherwise it is really
341 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
342 closedValue: parent.width + sideStage.handleSizeCollapsed
344 x: parent.width - width
345 width: sideStage.width + handleSize * 0.7
346 height: sideStage.height
347 orientation: Qt.Horizontal
353 anchors.top: parent.top
354 anchors.bottom: parent.bottom
355 anchors.right: parent.left
357 width: shell.edgeSize
358 direction: Direction.Leftwards
359 enabled: mainStage.applications.count > 0 || sideStage.applications.count > 0
366 hides: [launcher, panel.indicators, hud]
369 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
370 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
372 x: required ? 0 : - width
374 height: parent.height - panel.panelHeight
375 background: shell.background
377 onUnlocked: lockscreen.hide()
378 onCancel: greeter.show()
380 Component.onCompleted: {
381 if (LightDM.Users.count == 1) {
382 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
388 target: LightDM.Greeter
391 if (LightDM.Users.count == 1) {
392 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
394 lockscreen.alphaNumeric = false
396 lockscreen.alphaNumeric = true
398 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
408 hides: [launcher, panel.indicators, hud]
413 height: parent.height - panel.panelHeight
415 dragHandleWidth: shell.edgeSize
417 property var previousMainApp: null
418 property var previousSideApp: null
423 // If there is only one user, we start authenticating with that one here.
424 // If there are more users, the Greeter will handle that
425 if (LightDM.Users.count == 1) {
426 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
428 greeter.forceActiveFocus();
429 // FIXME: *FocusedApplication are not updated when unfocused, hence the need to check whether
430 // the stage was actually shown
431 if (mainStage.fullyShown) greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
432 if (sideStage.fullyShown) greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
433 applicationManager.unfocusCurrentApplication();
435 if (greeter.previousMainApp) {
436 applicationManager.focusApplication(greeter.previousMainApp);
437 greeter.previousMainApp = null;
439 if (greeter.previousSideApp) {
440 applicationManager.focusApplication(greeter.previousSideApp);
441 greeter.previousSideApp = null;
446 onUnlocked: greeter.hide()
448 var bgPath = greeter.model.data(uid, LightDM.UserRoles.BackgroundPathRole)
449 shell.background = bgPath ? bgPath : defaultBackground
452 onLeftTeaserPressedChanged: {
453 if (leftTeaserPressed) {
461 blockInput: greeter.shown || lockscreen.shown
471 anchors.fill: parent //because this draws indicator menus
472 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
476 fullscreenMode: shell.fullscreenMode
477 searchVisible: !greeter.shown && !lockscreen.shown
481 blockInput: panel.indicators.shown
488 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
489 height: parent.height
491 available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown
493 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
494 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
497 target: shell.applicationManager
498 onMainStageFocusedApplicationChanged: hud.hide()
499 onSideStageFocusedApplicationChanged: hud.hide()
504 blockInput: hud.shown
513 anchors.left: hud.left
514 height: parent.height
515 target: hud.revealerTarget
518 direction: Qt.RightToLeft
519 orientation: Qt.Vertical
520 handleSize: hud.handleHeight
521 onCloseClicked: target.hide()
527 enabled: !panel.indicators.shown
528 applicationIsOnForeground: applicationManager.mainStageFocusedApplication
529 || applicationManager.sideStageFocusedApplication
533 blockInput: launcher.shown
536 bottom: parent.bottom
539 width: launcher.width
545 anchors.top: parent.top
546 anchors.bottom: parent.bottom
548 dragAreaWidth: shell.edgeSize
549 available: !greeter.locked
550 onDashItemSelected: {
552 // Animate if moving between application and dash
554 dash.setCurrentScope("home.scope", true, false)
556 dash.setCurrentScope("home.scope", false, false)
562 dash.setCurrentScope("applications.scope", true, false)
567 onLauncherApplicationSelected:{
569 shell.activateApplication(desktopFile)
573 panel.indicators.hide()
582 model: NotificationBackend.Model
586 bottom: parent.bottom
587 leftMargin: units.gu(1)
588 rightMargin: units.gu(1)
589 topMargin: panel.panelHeight + units.gu(1)
594 when: overlay.width <= units.gu(60)
595 AnchorChanges { target: notifications; anchors.left: parent.left }
599 when: overlay.width > units.gu(60)
600 AnchorChanges { target: notifications; anchors.left: undefined }
601 PropertyChanges { target: notifications; width: units.gu(38) }
612 bottom: parent.bottom
615 width: shell.edgeSize
622 bottom: parent.bottom
625 width: shell.edgeSize
635 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
637 anchors.bottom: parent.bottom
638 anchors.left: parent.left
639 anchors.right: parent.right
640 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
642 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