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
190 property bool fullyHidden: !shown && stages[stagesRevealer.boundProperty] == stagesRevealer.closedValue
191 available: !greeter.shown
192 hides: [launcher, panel.indicators]
195 showAnimation: StandardAnimation { property: "x"; duration: 350; to: stagesRevealer.openedValue; easing.type: Easing.OutCubic }
196 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: stagesRevealer.closedValue; easing.type: Easing.OutCubic }
199 height: parent.height
201 // close the stages when no focused application remains
203 target: shell.applicationManager
204 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
205 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
206 ignoreUnknownSignals: true
209 function closeIfNoApplications() {
210 if (!shell.applicationManager.mainStageFocusedApplication
211 && !shell.applicationManager.sideStageFocusedApplication
212 && shell.applicationManager.mainStageApplications.count == 0
213 && shell.applicationManager.sideStageApplications.count == 0) {
218 // show the stages when an application gets the focus
220 target: shell.applicationManager
221 onMainStageFocusedApplicationChanged: {
222 if (shell.applicationManager.mainStageFocusedApplication) {
227 onSideStageFocusedApplicationChanged: {
228 if (shell.applicationManager.sideStageFocusedApplication) {
233 ignoreUnknownSignals: true
241 fullyShown: stages.fullyShown
242 shouldUseScreenshots: !fullyShown
243 rightEdgeEnabled: !sideStage.enabled
245 applicationManager: shell.applicationManager
246 rightEdgeDraggingAreaWidth: shell.edgeSize
247 normalApplicationY: shell.panelHeight
253 function showWithoutAnimation() {
254 stages.showWithoutAnimation();
259 // FIXME: workaround the fact that focusing a main stage application
260 // raises its surface on top of all other surfaces including the ones
261 // that belong to side stage applications.
262 onFocusedApplicationChanged: {
263 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
264 shell.applicationManager.focusApplication(sideStage.focusedApplication);
272 applicationManager: shell.applicationManager
273 rightEdgeDraggingAreaWidth: shell.edgeSize
274 normalApplicationY: shell.panelHeight
277 if (!shown && mainStage.applications.count == 0) {
281 // FIXME: when hiding the side stage, refocus the main stage
282 // application so that it goes in front of the side stage
283 // application and hides it
284 onFullyShownChanged: {
285 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
286 shell.applicationManager.focusApplication(mainStage.focusedApplication);
290 enabled: shell.width >= units.gu(60)
292 fullyShown: stages.fullyShown && shown
293 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
294 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
296 available: !greeter.shown && !lockscreen.shown && enabled
297 hides: [launcher, panel.indicators]
299 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
300 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
303 height: stages.height
304 handleExpanded: sideStageRevealer.pressed
308 id: sideStageRevealer
310 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
311 && sideStage.available
312 direction: Qt.RightToLeft
313 openedValue: parent.width - sideStage.width
314 hintDisplacement: units.gu(3)
315 /* The size of the sidestage handle needs to be bigger than the
316 typical size used for edge detection otherwise it is really
319 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
320 closedValue: parent.width + sideStage.handleSizeCollapsed
322 x: parent.width - width
323 width: sideStage.width + handleSize * 0.7
324 height: sideStage.height
325 orientation: Qt.Horizontal
334 property real animatedProgress: MathLocal.clamp((-dragPosition - launcher.progress) / closedValue, 0, 1)
335 enabled: mainStage.applications.count > 0 || sideStage.applications.count > 0
336 direction: Qt.RightToLeft
338 hintDisplacement: units.gu(3)
339 handleSize: shell.edgeSize
343 height: stages.height
344 orientation: Qt.Horizontal
349 hides: [launcher, panel.indicators, hud]
352 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
353 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
355 x: required ? 0 : - width
357 height: parent.height - panel.panelHeight
358 background: shell.background
360 onUnlocked: lockscreen.hide()
361 onCancel: greeter.show()
363 Component.onCompleted: {
364 if (LightDM.Users.count == 1) {
365 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
371 target: LightDM.Greeter
374 if (LightDM.Users.count == 1) {
375 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
377 lockscreen.alphaNumeric = false
379 lockscreen.alphaNumeric = true
381 lockscreen.placeholderText = i18n.tr("Please enter %1:").arg(text);
391 hides: [launcher, panel.indicators, hud]
393 showAnimation: StandardAnimation { property: "x"; to: greeterRevealer.openedValue }
394 hideAnimation: StandardAnimation { property: "x"; to: greeterRevealer.closedValue }
397 height: parent.height - panel.panelHeight
399 property var previousMainApp: null
400 property var previousSideApp: null
405 // If there is only one user, we start authenticating with that one here.
406 // If there are more users, the Greeter will handle that
407 if (LightDM.Users.count == 1) {
408 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
410 greeter.forceActiveFocus();
411 // FIXME: *FocusedApplication are not updated when unfocused, hence the need to check whether
412 // the stage was actually shown
413 if (mainStage.fullyShown) greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
414 if (sideStage.fullyShown) greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
415 applicationManager.unfocusCurrentApplication();
417 if (greeter.previousMainApp) {
418 applicationManager.focusApplication(greeter.previousMainApp);
419 greeter.previousMainApp = null;
421 if (greeter.previousSideApp) {
422 applicationManager.focusApplication(greeter.previousSideApp);
423 greeter.previousSideApp = null;
428 onUnlocked: greeter.hide()
430 var bgPath = greeter.model.data(uid, LightDM.UserRoles.BackgroundPathRole)
431 shell.background = bgPath ? bgPath : default_background
437 blockInput: greeter.shown || lockscreen.shown
443 property real animatedProgress: MathLocal.clamp(-dragPosition / closedValue, 0, 1)
446 height: greeter.height
447 handleSize: shell.edgeSize
448 orientation: Qt.Horizontal
449 visible: greeter.shown
450 enabled: !greeter.locked
460 anchors.fill: parent //because this draws indicator menus
461 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
465 fullscreenMode: shell.fullscreenMode
466 searchVisible: !greeter.shown && !lockscreen.shown
470 blockInput: panel.indicators.shown
477 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
478 height: parent.height
480 available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown
482 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
483 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
486 target: shell.applicationManager
487 onMainStageFocusedApplicationChanged: hud.hide()
488 onSideStageFocusedApplicationChanged: hud.hide()
493 blockInput: hud.shown
502 anchors.left: hud.left
503 height: parent.height
504 target: hud.revealerTarget
507 direction: Qt.RightToLeft
508 orientation: Qt.Vertical
509 handleSize: hud.handleHeight
510 onCloseClicked: target.hide()
516 enabled: !panel.indicators.shown
517 applicationIsOnForeground: applicationManager.mainStageFocusedApplication
518 || applicationManager.sideStageFocusedApplication
522 blockInput: launcher.shown
525 bottom: parent.bottom
528 width: launcher.width
534 anchors.top: parent.top
535 anchors.bottom: parent.bottom
537 dragAreaWidth: shell.edgeSize
538 available: !greeter.locked
539 teasing: available && greeter.leftTeaserPressed
540 onDashItemSelected: {
542 // Animate if moving between application and dash
544 dash.setCurrentLens("home.lens", true, false)
546 dash.setCurrentLens("home.lens", false, false)
551 dash.setCurrentLens("applications.lens", true, false)
554 onLauncherApplicationSelected:{
556 shell.activateApplication(desktopFile)
560 panel.indicators.hide()
572 bottom: parent.bottom
575 width: shell.edgeSize
582 bottom: parent.bottom
585 width: shell.edgeSize
595 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
597 anchors.bottom: parent.bottom
598 anchors.left: parent.left
599 anchors.right: parent.right
600 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
602 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