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 if (shell.applicationManager.mainStageFocusedApplication) {
226 onSideStageFocusedApplicationChanged: {
227 if (shell.applicationManager.sideStageFocusedApplication) {
232 ignoreUnknownSignals: true
240 fullyShown: stages.fullyShown
241 shouldUseScreenshots: !fullyShown
242 rightEdgeEnabled: !sideStage.enabled
244 applicationManager: shell.applicationManager
245 rightEdgeDraggingAreaWidth: shell.edgeSize
246 normalApplicationY: shell.panelHeight
252 function showWithoutAnimation() {
253 stages.showWithoutAnimation();
258 // FIXME: workaround the fact that focusing a main stage application
259 // raises its surface on top of all other surfaces including the ones
260 // that belong to side stage applications.
261 onFocusedApplicationChanged: {
262 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
263 shell.applicationManager.focusApplication(sideStage.focusedApplication);
271 applicationManager: shell.applicationManager
272 rightEdgeDraggingAreaWidth: shell.edgeSize
273 normalApplicationY: shell.panelHeight
276 if (!shown && mainStage.applications.count == 0) {
280 // FIXME: when hiding the side stage, refocus the main stage
281 // application so that it goes in front of the side stage
282 // application and hides it
283 onFullyShownChanged: {
284 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
285 shell.applicationManager.focusApplication(mainStage.focusedApplication);
289 enabled: shell.width >= units.gu(60)
291 fullyShown: stages.fullyShown && shown
292 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
293 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
295 available: !greeter.shown && !lockscreen.shown && enabled
296 hides: [launcher, panel.indicators]
298 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
299 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
302 height: stages.height
303 handleExpanded: sideStageRevealer.pressed
307 id: sideStageRevealer
309 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
310 && sideStage.available
311 direction: Qt.RightToLeft
312 openedValue: parent.width - sideStage.width
313 hintDisplacement: units.gu(3)
314 /* The size of the sidestage handle needs to be bigger than the
315 typical size used for edge detection otherwise it is really
318 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
319 closedValue: parent.width + sideStage.handleSizeCollapsed
321 x: parent.width - width
322 width: sideStage.width + handleSize * 0.7
323 height: sideStage.height
324 orientation: Qt.Horizontal
333 property real animatedProgress: MathLocal.clamp((-dragPosition - launcher.progress) / closedValue, 0, 1)
334 enabled: mainStage.applications.count > 0 || sideStage.applications.count > 0
335 direction: Qt.RightToLeft
337 hintDisplacement: units.gu(3)
338 handleSize: shell.edgeSize
342 height: stages.height
343 orientation: Qt.Horizontal
348 hides: [launcher, panel.indicators, hud]
351 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
352 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
354 x: required ? 0 : - width
356 height: parent.height - panel.panelHeight
357 background: shell.background
359 onUnlocked: lockscreen.hide()
360 onCancel: greeter.show()
362 Component.onCompleted: {
363 if (LightDM.Users.count == 1) {
364 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
370 target: LightDM.Greeter
373 if (LightDM.Users.count == 1) {
374 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
376 lockscreen.alphaNumeric = false
378 lockscreen.alphaNumeric = true
380 lockscreen.placeholderText = i18n.tr("Please enter %1:").arg(text);
390 hides: [launcher, panel.indicators, hud]
392 showAnimation: StandardAnimation { property: "x"; to: greeterRevealer.openedValue }
393 hideAnimation: StandardAnimation { property: "x"; to: greeterRevealer.closedValue }
396 height: parent.height - panel.panelHeight
398 property var previousMainApp: null
399 property var previousSideApp: null
404 // If there is only one user, we start authenticating with that one here.
405 // If there are more users, the Greeter will handle that
406 if (LightDM.Users.count == 1) {
407 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
409 greeter.forceActiveFocus();
410 // FIXME: *FocusedApplication are not updated when unfocused, hence the need to check whether
411 // the stage was actually shown
412 if (mainStage.fullyShown) greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
413 if (sideStage.fullyShown) greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
414 applicationManager.unfocusCurrentApplication();
416 if (greeter.previousMainApp) {
417 applicationManager.focusApplication(greeter.previousMainApp);
418 greeter.previousMainApp = null;
420 if (greeter.previousSideApp) {
421 applicationManager.focusApplication(greeter.previousSideApp);
422 greeter.previousSideApp = null;
427 onUnlocked: greeter.hide()
429 var bgPath = greeter.model.data(uid, LightDM.UserRoles.BackgroundPathRole)
430 shell.background = bgPath ? bgPath : default_background
436 blockInput: greeter.shown || lockscreen.shown
442 property real animatedProgress: MathLocal.clamp(-dragPosition / closedValue, 0, 1)
445 height: greeter.height
446 handleSize: shell.edgeSize
447 orientation: Qt.Horizontal
448 visible: greeter.shown
449 enabled: !greeter.locked
459 anchors.fill: parent //because this draws indicator menus
460 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
464 fullscreenMode: shell.fullscreenMode
465 searchVisible: !greeter.shown && !lockscreen.shown
469 blockInput: panel.indicators.shown
476 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
477 height: parent.height
479 available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown
481 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
482 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
485 target: shell.applicationManager
486 onMainStageFocusedApplicationChanged: hud.hide()
487 onSideStageFocusedApplicationChanged: hud.hide()
492 blockInput: hud.shown
501 anchors.left: hud.left
502 height: parent.height
503 target: hud.revealerTarget
506 direction: Qt.RightToLeft
507 orientation: Qt.Vertical
508 handleSize: hud.handleHeight
509 onCloseClicked: target.hide()
515 enabled: !panel.indicators.shown
519 blockInput: launcher.shown
522 bottom: parent.bottom
525 width: launcher.width
531 anchors.top: parent.top
532 anchors.bottom: parent.bottom
534 dragAreaWidth: shell.edgeSize
535 available: !greeter.locked
536 teasing: available && greeter.leftTeaserPressed
537 onDashItemSelected: {
539 // Animate if moving between application and dash
541 dash.setCurrentScope("home.scope", true, false)
543 dash.setCurrentScope("home.scope", false, false)
548 dash.setCurrentScope("applications.scope", true, false)
551 onLauncherApplicationSelected:{
553 shell.activateApplication(desktopFile)
557 panel.indicators.hide()
569 bottom: parent.bottom
572 width: shell.edgeSize
579 bottom: parent.bottom
582 width: shell.edgeSize
592 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
594 anchors.bottom: parent.bottom
595 anchors.left: parent.left
596 anchors.right: parent.right
597 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
599 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