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: {
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) {
129 visible: !(panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth)
130 && (stages.fullyHidden
131 || (stages.fullyShown && mainStage.usingScreenshots)
132 || !stages.fullyShown && (mainStage.usingScreenshots || (sideStage.shown && sideStage.usingScreenshots)))
136 source: shell.background
137 sourceSize.width: parent.width
138 sourceSize.height: parent.height
145 opacity: dash.disappearingAnimationProgress
151 available: !greeter.shown
152 hides: [stages, launcher, panel.indicators]
153 shown: disappearingAnimationProgress !== 1.0
154 enabled: disappearingAnimationProgress === 0.0
155 // FIXME: unfocus all applications when going back to the dash
158 shell.applicationManager.unfocusCurrentApplication()
164 topMargin: panel.panelHeight
167 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
168 opacity: 1.0 - disappearingAnimationProgress
169 property real disappearingAnimationProgress: ((greeter.shown) ? greeterRevealer.animatedProgress : stagesRevealer.animatedProgress)
170 // FIXME: only necessary because stagesRevealer.animatedProgress and
171 // greeterRevealer.animatedProgress are not animated
172 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
180 height: parent.height
182 Behavior on x {SmoothedAnimation{velocity: 600}}
188 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 handleFocusedApplicationChange(mainStage, shell.applicationManager.mainStageFocusedApplication);
224 onSideStageFocusedApplicationChanged: {
225 handleFocusedApplicationChange(sideStage, shell.applicationManager.sideStageFocusedApplication);
227 ignoreUnknownSignals: true
229 function handleFocusedApplicationChange(stage, application) {
236 // focus changed while shell in foreground, ensure app remains unfocused
238 shell.applicationManager.unfocusCurrentApplication();
249 fullyShown: stages.fullyShown
250 shouldUseScreenshots: !fullyShown
251 rightEdgeEnabled: !sideStage.enabled
253 applicationManager: shell.applicationManager
254 rightEdgeDraggingAreaWidth: shell.edgeSize
255 normalApplicationY: shell.panelHeight
261 function showWithoutAnimation() {
262 stages.showWithoutAnimation();
267 // FIXME: workaround the fact that focusing a main stage application
268 // raises its surface on top of all other surfaces including the ones
269 // that belong to side stage applications.
270 onFocusedApplicationChanged: {
271 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
272 shell.applicationManager.focusApplication(sideStage.focusedApplication);
280 applicationManager: shell.applicationManager
281 rightEdgeDraggingAreaWidth: shell.edgeSize
282 normalApplicationY: shell.panelHeight
285 if (!shown && mainStage.applications.count == 0) {
289 // FIXME: when hiding the side stage, refocus the main stage
290 // application so that it goes in front of the side stage
291 // application and hides it
292 onFullyShownChanged: {
293 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
294 shell.applicationManager.focusApplication(mainStage.focusedApplication);
298 enabled: shell.width >= units.gu(60)
300 fullyShown: stages.fullyShown && shown
301 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
302 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
304 available: !greeter.shown && enabled
305 hides: [launcher, panel.indicators]
307 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
308 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
311 height: stages.height
312 handleExpanded: sideStageRevealer.pressed
316 id: sideStageRevealer
318 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
319 && sideStage.available
320 direction: Qt.RightToLeft
321 openedValue: parent.width - sideStage.width
322 hintDisplacement: units.gu(3)
323 /* The size of the sidestage handle needs to be bigger than the
324 typical size used for edge detection otherwise it is really
327 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
328 closedValue: parent.width + sideStage.handleSizeCollapsed
330 x: parent.width - width
331 width: sideStage.width + handleSize * 0.7
332 height: sideStage.height
333 orientation: Qt.Horizontal
342 property real animatedProgress: MathLocal.clamp((-dragPosition - launcher.progress) / closedValue, 0, 1)
343 enabled: mainStage.applications.count > 0 || sideStage.applications.count > 0
344 direction: Qt.RightToLeft
346 hintDisplacement: units.gu(3)
347 handleSize: shell.edgeSize
351 height: stages.height
352 orientation: Qt.Horizontal
359 hides: [launcher, panel.indicators, hud]
361 showAnimation: StandardAnimation { property: "x"; to: greeterRevealer.openedValue }
362 hideAnimation: StandardAnimation { property: "x"; to: greeterRevealer.closedValue }
366 height: parent.height - panel.panelHeight
368 property var previousMainApp: null
369 property var previousSideApp: null
373 greeter.forceActiveFocus();
374 // FIXME: *FocusedApplication are not updated when unfocused, hence the need to check whether
375 // the stage was actually shown
376 if (mainStage.fullyShown) greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
377 if (sideStage.fullyShown) greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
378 applicationManager.unfocusCurrentApplication();
380 if (greeter.previousMainApp) {
381 applicationManager.focusApplication(greeter.previousMainApp);
382 greeter.previousMainApp = null;
384 if (greeter.previousSideApp) {
385 applicationManager.focusApplication(greeter.previousSideApp);
386 greeter.previousSideApp = null;
391 onUnlocked: greeter.hide()
393 var bgPath = greeter.model.data(uid, LightDM.UserRoles.BackgroundPathRole)
394 shell.background = bgPath ? bgPath : default_background
400 blockInput: greeter.shown
406 property real animatedProgress: MathLocal.clamp(-dragPosition / closedValue, 0, 1)
409 height: greeter.height
410 handleSize: shell.edgeSize
411 orientation: Qt.Horizontal
412 visible: greeter.shown
413 enabled: !greeter.locked
423 anchors.fill: parent //because this draws indicator menus
424 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
428 fullscreenMode: shell.fullscreenMode
429 searchVisible: !greeter.shown
433 blockInput: panel.indicators.shown
440 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
441 height: parent.height
443 available: !greeter.shown && !panel.indicators.shown
445 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
446 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
449 target: shell.applicationManager
450 onMainStageFocusedApplicationChanged: hud.hide()
451 onSideStageFocusedApplicationChanged: hud.hide()
456 blockInput: hud.shown
465 anchors.left: hud.left
466 height: parent.height
467 target: hud.revealerTarget
470 direction: Qt.RightToLeft
471 orientation: Qt.Vertical
472 handleSize: hud.handleHeight
473 onCloseClicked: target.hide()
479 enabled: !panel.indicators.shown
483 blockInput: launcher.shown
486 bottom: parent.bottom
489 width: launcher.width
495 anchors.top: parent.top
496 anchors.bottom: parent.bottom
498 dragAreaWidth: shell.edgeSize
499 available: !greeter.locked
500 teasing: available && greeter.leftTeaserPressed
501 onDashItemSelected: {
503 // Animate if moving between application and dash
505 dash.setCurrentLens("home.lens", true, false)
507 dash.setCurrentLens("home.lens", false, false)
512 dash.setCurrentLens("applications.lens", true, false)
515 onLauncherApplicationSelected:{
517 shell.activateApplication(desktopFile)
521 panel.indicators.hide()
533 bottom: parent.bottom
536 width: shell.edgeSize
543 bottom: parent.bottom
546 width: shell.edgeSize
556 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
558 anchors.bottom: parent.bottom
559 anchors.left: parent.left
560 anchors.right: parent.right
561 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
563 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