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 LightDM 0.1 as LightDM
27import "Components/Math.js" as MathLocal
34 // this is only here to select the width / height of the window if not running fullscreen
35 property bool tablet: false
36 width: tablet ? units.gu(160) : units.gu(40)
37 height: tablet ? units.gu(100) : units.gu(71)
39 property real edgeSize: units.gu(2)
40 property url default_background: shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg"
41 property url background: default_background
42 readonly property real panelHeight: panel.panelHeight
44 property bool dashShown: dash.shown
45 property bool stageScreenshotsReady: {
46 if (sideStage.shown) {
47 if (mainStage.applications.count > 0) {
48 return mainStage.usingScreenshots && sideStage.usingScreenshots;
50 return sideStage.usingScreenshots;
53 return mainStage.usingScreenshots;
57 property ListModel searchHistory: SearchHistoryModel {}
59 property var applicationManager: ApplicationManagerWrapper {}
61 Component.onCompleted: {
62 applicationManager.sideStageEnabled = Qt.binding(function() { return sideStage.enabled })
64 // FIXME: if application focused before shell starts, shell draws on top of it only.
65 // We should detect already running applications on shell start and bring them to the front.
66 applicationManager.unfocusCurrentApplication();
69 readonly property bool fullscreenMode: {
70 if (greeter.shown || lockscreen.shown) {
72 } else if (mainStage.usingScreenshots) { // Window Manager animating so want to re-evaluate fullscreen mode
73 return mainStage.switchingFromFullscreenToFullscreen;
74 } else if (applicationManager.mainStageFocusedApplication) {
75 return applicationManager.mainStageFocusedApplication.fullscreen;
82 target: applicationManager
83 ignoreUnknownSignals: true
85 // TODO: this should be protected to only unlock for certain applications / certain usecases
86 // potentially only in connection with a notification
88 shell.activateApplication(desktopFile);
92 function activateApplication(desktopFile, argument) {
93 if (applicationManager) {
94 // For newly started applications, as it takes them time to draw their first frame
95 // we add a delay before we hide the animation screenshots to compensate.
96 var addDelay = !applicationManager.getApplicationFromDesktopFile(desktopFile);
99 application = applicationManager.activateApplication(desktopFile, argument);
100 if (application == null) {
103 if (application.stage == ApplicationInfo.MainStage || !sideStage.enabled) {
104 mainStage.activateApplication(desktopFile, addDelay);
106 sideStage.activateApplication(desktopFile, addDelay);
116 Keys.onVolumeUpPressed: volumeControl.volumeUp()
117 Keys.onVolumeDownPressed: volumeControl.volumeDown()
120 if (event.key == Qt.Key_PowerOff) {
128 visible: !(panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth)
129 && (stages.fullyHidden
130 || (stages.fullyShown && mainStage.usingScreenshots)
131 || !stages.fullyShown && (mainStage.usingScreenshots || (sideStage.shown && sideStage.usingScreenshots)))
135 source: shell.background
136 sourceSize.width: parent.width
137 sourceSize.height: parent.height
144 opacity: dash.disappearingAnimationProgress
150 available: !greeter.shown && !lockscreen.shown
151 hides: [stages, launcher, panel.indicators]
152 shown: disappearingAnimationProgress !== 1.0
153 enabled: disappearingAnimationProgress === 0.0
154 // FIXME: unfocus all applications when going back to the dash
157 shell.applicationManager.unfocusCurrentApplication()
163 topMargin: panel.panelHeight
166 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
167 opacity: 1.0 - disappearingAnimationProgress
168 property real disappearingAnimationProgress: ((greeter.shown) ? greeterRevealer.animatedProgress : stagesRevealer.animatedProgress)
169 // FIXME: only necessary because stagesRevealer.animatedProgress and
170 // greeterRevealer.animatedProgress are not animated
171 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
179 height: parent.height
181 Behavior on x {SmoothedAnimation{velocity: 600}}
187 property bool fullyShown: shown && stages[stagesRevealer.boundProperty] == stagesRevealer.openedValue
189 property bool fullyHidden: !shown && stages[stagesRevealer.boundProperty] == stagesRevealer.closedValue
190 available: !greeter.shown
191 hides: [launcher, panel.indicators]
194 showAnimation: StandardAnimation { property: "x"; duration: 350; to: stagesRevealer.openedValue; easing.type: Easing.OutCubic }
195 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: stagesRevealer.closedValue; easing.type: Easing.OutCubic }
198 height: parent.height
200 // close the stages when no focused application remains
202 target: shell.applicationManager
203 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
204 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
205 ignoreUnknownSignals: true
208 function closeIfNoApplications() {
209 if (!shell.applicationManager.mainStageFocusedApplication
210 && !shell.applicationManager.sideStageFocusedApplication
211 && shell.applicationManager.mainStageApplications.count == 0
212 && shell.applicationManager.sideStageApplications.count == 0) {
217 // show the stages when an application gets the focus
219 target: shell.applicationManager
220 onMainStageFocusedApplicationChanged: {
221 handleFocusedApplicationChange(mainStage, shell.applicationManager.mainStageFocusedApplication);
223 onSideStageFocusedApplicationChanged: {
224 handleFocusedApplicationChange(sideStage, shell.applicationManager.sideStageFocusedApplication);
226 ignoreUnknownSignals: true
228 function handleFocusedApplicationChange(stage, application) {
235 // focus changed while shell in foreground, ensure app remains unfocused
237 shell.applicationManager.unfocusCurrentApplication();
248 fullyShown: stages.fullyShown
249 shouldUseScreenshots: !fullyShown
250 rightEdgeEnabled: !sideStage.enabled
252 applicationManager: shell.applicationManager
253 rightEdgeDraggingAreaWidth: shell.edgeSize
254 normalApplicationY: shell.panelHeight
260 function showWithoutAnimation() {
261 stages.showWithoutAnimation();
266 // FIXME: workaround the fact that focusing a main stage application
267 // raises its surface on top of all other surfaces including the ones
268 // that belong to side stage applications.
269 onFocusedApplicationChanged: {
270 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
271 shell.applicationManager.focusApplication(sideStage.focusedApplication);
279 applicationManager: shell.applicationManager
280 rightEdgeDraggingAreaWidth: shell.edgeSize
281 normalApplicationY: shell.panelHeight
284 if (!shown && mainStage.applications.count == 0) {
288 // FIXME: when hiding the side stage, refocus the main stage
289 // application so that it goes in front of the side stage
290 // application and hides it
291 onFullyShownChanged: {
292 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
293 shell.applicationManager.focusApplication(mainStage.focusedApplication);
297 enabled: shell.width >= units.gu(60)
299 fullyShown: stages.fullyShown && shown
300 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
301 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
303 available: !greeter.shown && !lockscreen.shown && enabled
304 hides: [launcher, panel.indicators]
306 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
307 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
310 height: stages.height
311 handleExpanded: sideStageRevealer.pressed
315 id: sideStageRevealer
317 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
318 && sideStage.available
319 direction: Qt.RightToLeft
320 openedValue: parent.width - sideStage.width
321 hintDisplacement: units.gu(3)
322 /* The size of the sidestage handle needs to be bigger than the
323 typical size used for edge detection otherwise it is really
326 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
327 closedValue: parent.width + sideStage.handleSizeCollapsed
329 x: parent.width - width
330 width: sideStage.width + handleSize * 0.7
331 height: sideStage.height
332 orientation: Qt.Horizontal
341 property real animatedProgress: MathLocal.clamp((-dragPosition - launcher.progress) / closedValue, 0, 1)
342 enabled: mainStage.applications.count > 0 || sideStage.applications.count > 0
343 direction: Qt.RightToLeft
345 hintDisplacement: units.gu(3)
346 handleSize: shell.edgeSize
350 height: stages.height
351 orientation: Qt.Horizontal
356 hides: [launcher, panel.indicators, hud]
359 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
360 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
362 x: required ? 0 : - width
364 height: parent.height - panel.panelHeight
365 background: shell.background
367 onUnlocked: lockscreen.hide()
368 onCancel: greeter.show()
370 Component.onCompleted: {
371 if (LightDM.Users.count == 1) {
372 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
378 target: LightDM.Greeter
381 if (LightDM.Users.count == 1) {
382 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
384 lockscreen.alphaNumeric = false
386 lockscreen.alphaNumeric = true
388 lockscreen.placeholderText = i18n.tr("Please enter %1:").arg(text);
398 hides: [launcher, panel.indicators, hud]
400 showAnimation: StandardAnimation { property: "x"; to: greeterRevealer.openedValue }
401 hideAnimation: StandardAnimation { property: "x"; to: greeterRevealer.closedValue }
404 height: parent.height - panel.panelHeight
406 property var previousMainApp: null
407 property var previousSideApp: null
412 // If there is only one user, we start authenticating with that one here.
413 // If there are more users, the Greeter will handle that
414 if (LightDM.Users.count == 1) {
415 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
417 greeter.forceActiveFocus();
418 // FIXME: *FocusedApplication are not updated when unfocused, hence the need to check whether
419 // the stage was actually shown
420 if (mainStage.fullyShown) greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
421 if (sideStage.fullyShown) greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
422 applicationManager.unfocusCurrentApplication();
424 if (greeter.previousMainApp) {
425 applicationManager.focusApplication(greeter.previousMainApp);
426 greeter.previousMainApp = null;
428 if (greeter.previousSideApp) {
429 applicationManager.focusApplication(greeter.previousSideApp);
430 greeter.previousSideApp = null;
435 onUnlocked: greeter.hide()
437 var bgPath = greeter.model.data(uid, LightDM.UserRoles.BackgroundPathRole)
438 shell.background = bgPath ? bgPath : default_background
444 blockInput: greeter.shown || lockscreen.shown
450 property real animatedProgress: MathLocal.clamp(-dragPosition / closedValue, 0, 1)
453 height: greeter.height
454 handleSize: shell.edgeSize
455 orientation: Qt.Horizontal
456 visible: greeter.shown
457 enabled: !greeter.locked
467 anchors.fill: parent //because this draws indicator menus
468 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
472 fullscreenMode: shell.fullscreenMode
473 searchVisible: !greeter.shown && !lockscreen.shown
477 blockInput: panel.indicators.shown
484 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
485 height: parent.height
487 available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown
489 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
490 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
493 target: shell.applicationManager
494 onMainStageFocusedApplicationChanged: hud.hide()
495 onSideStageFocusedApplicationChanged: hud.hide()
500 blockInput: hud.shown
509 anchors.left: hud.left
510 height: parent.height
511 target: hud.revealerTarget
514 direction: Qt.RightToLeft
515 orientation: Qt.Vertical
516 handleSize: hud.handleHeight
517 onCloseClicked: target.hide()
523 enabled: !panel.indicators.shown
527 blockInput: launcher.shown
530 bottom: parent.bottom
533 width: launcher.width
539 anchors.top: parent.top
540 anchors.bottom: parent.bottom
542 dragAreaWidth: shell.edgeSize
543 available: !greeter.locked
544 teasing: available && greeter.leftTeaserPressed
545 onDashItemSelected: {
547 // Animate if moving between application and dash
549 dash.setCurrentLens("home.lens", true, false)
551 dash.setCurrentLens("home.lens", false, false)
556 dash.setCurrentLens("applications.lens", true, false)
559 onLauncherApplicationSelected:{
561 shell.activateApplication(desktopFile)
565 panel.indicators.hide()
577 bottom: parent.bottom
580 width: shell.edgeSize
587 bottom: parent.bottom
590 width: shell.edgeSize
600 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
602 anchors.bottom: parent.bottom
603 anchors.left: parent.left
604 anchors.right: parent.right
605 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
607 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