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 Ubuntu.Gestures 0.1
21import SessionManager 0.1
27import "Components/Math.js" as MathLocal
31import Unity.Notifications 1.0 as NotificationBackend
36 readonly property real panelHeight: panel.panelHeight
38 property bool dashShown: dash.shown
39 property bool stageScreenshotsReady: {
40 if (sideStage.shown) {
41 if (mainStage.applications.count > 0) {
42 return mainStage.usingScreenshots && sideStage.usingScreenshots;
44 return sideStage.usingScreenshots;
47 return mainStage.usingScreenshots;
51 property ListModel searchHistory: SearchHistoryModel {}
53 property var applicationManager: ApplicationManagerWrapper {}
55 Component.onCompleted: {
56 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
58 applicationManager.sideStageEnabled = Qt.binding(function() { return sideStage.enabled })
60 // FIXME: if application focused before shell starts, shell draws on top of it only.
61 // We should detect already running applications on shell start and bring them to the front.
62 applicationManager.unfocusCurrentApplication();
65 readonly property bool fullscreenMode: {
66 if (mainStage.usingScreenshots) { // Window Manager animating so want to re-evaluate fullscreen mode
67 return mainStage.switchingFromFullscreenToFullscreen;
68 } else if (applicationManager.mainStageFocusedApplication) {
69 return applicationManager.mainStageFocusedApplication.fullscreen;
76 target: applicationManager
77 ignoreUnknownSignals: true
79 shell.activateApplication(desktopFile);
83 function activateApplication(desktopFile, argument) {
84 if (applicationManager) {
85 // For newly started applications, as it takes them time to draw their first frame
86 // we add a delay before we hide the animation screenshots to compensate.
87 var addDelay = !applicationManager.getApplicationFromDesktopFile(desktopFile);
90 application = applicationManager.activateApplication(desktopFile, argument);
91 if (application == null) {
94 if (application.stage == ApplicationInfo.MainStage || !sideStage.enabled) {
95 mainStage.activateApplication(desktopFile, addDelay);
97 sideStage.activateApplication(desktopFile, addDelay);
104 if (event.key == Qt.Key_PowerOff) {
105 SessionManager.lock()
111 objectName: "underlay"
114 // Whether the underlay is fully covered by opaque UI elements.
115 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
117 // Whether the user should see the topmost application surface (if there's one at all).
118 property bool applicationSurfaceShouldBeSeen:
119 (mainStage.applications && mainStage.applications.count > 0)
120 && (!stages.fullyHidden && !mainStage.usingScreenshots)
122 // NB! Application surfaces are stacked behing the shell one. So they can only be seen by the user
123 // through the translucent parts of the shell surface.
124 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
128 source: shell.background
129 sourceSize.width: parent.width
130 sourceSize.height: parent.height
137 opacity: dash.disappearingAnimationProgress
144 hides: [stages, launcher, panel.indicators]
145 shown: disappearingAnimationProgress !== 1.0
146 enabled: disappearingAnimationProgress === 0.0
147 // FIXME: unfocus all applications when going back to the dash
150 shell.applicationManager.unfocusCurrentApplication()
156 topMargin: panel.panelHeight
159 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
160 opacity: 1.0 - disappearingAnimationProgress
161 property real disappearingAnimationProgress: stagesOuterContainer.showProgress
163 // FIXME: only necessary because stagesOuterContainer.showProgress
165 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
171 id: stagesOuterContainer
174 height: parent.height
176 Behavior on x {SmoothedAnimation{velocity: 600}}
178 property real showProgress:
179 MathLocal.clamp(1 - (x + stages.x) / shell.width, 0, 1)
187 property bool fullyShown: shown && x == 0 && parent.x == 0
188 property bool fullyHidden: !shown && x == width
189 hides: [launcher, panel.indicators]
192 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
193 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
196 height: parent.height
198 // close the stages when no focused application remains
200 target: shell.applicationManager
201 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
202 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
203 ignoreUnknownSignals: true
206 function closeIfNoApplications() {
207 if (!shell.applicationManager.mainStageFocusedApplication
208 && !shell.applicationManager.sideStageFocusedApplication
209 && shell.applicationManager.mainStageApplications.count == 0
210 && shell.applicationManager.sideStageApplications.count == 0) {
215 // show the stages when an application gets the focus
217 target: shell.applicationManager
218 onMainStageFocusedApplicationChanged: {
219 if (shell.applicationManager.mainStageFocusedApplication) {
224 onSideStageFocusedApplicationChanged: {
225 if (shell.applicationManager.sideStageFocusedApplication) {
230 ignoreUnknownSignals: true
238 fullyShown: stages.fullyShown
239 fullyHidden: stages.fullyHidden
240 shouldUseScreenshots: !fullyShown
241 rightEdgeEnabled: !sideStage.enabled
243 applicationManager: shell.applicationManager
244 rightEdgeDraggingAreaWidth: shell.edgeSize
245 normalApplicationY: shell.panelHeight
254 // FIXME: workaround the fact that focusing a main stage application
255 // raises its surface on top of all other surfaces including the ones
256 // that belong to side stage applications.
257 onFocusedApplicationChanged: {
258 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
259 shell.applicationManager.focusApplication(sideStage.focusedApplication);
267 applicationManager: shell.applicationManager
268 rightEdgeDraggingAreaWidth: shell.edgeSize
269 normalApplicationY: shell.panelHeight
272 if (!shown && mainStage.applications.count == 0) {
276 // FIXME: when hiding the side stage, refocus the main stage
277 // application so that it goes in front of the side stage
278 // application and hides it
279 onFullyShownChanged: {
280 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
281 shell.applicationManager.focusApplication(mainStage.focusedApplication);
285 enabled: shell.width >= units.gu(60)
287 fullyShown: stages.fullyShown && shown
288 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
289 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
292 hides: [launcher, panel.indicators]
294 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
295 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
298 height: stages.height
299 handleExpanded: sideStageRevealer.pressed
303 id: sideStageRevealer
305 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
306 && sideStage.available
307 direction: Qt.RightToLeft
308 openedValue: parent.width - sideStage.width
309 hintDisplacement: units.gu(3)
310 /* The size of the sidestage handle needs to be bigger than the
311 typical size used for edge detection otherwise it is really
314 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
315 closedValue: parent.width + sideStage.handleSizeCollapsed
317 x: parent.width - width
318 width: sideStage.width + handleSize * 0.7
319 height: sideStage.height
320 orientation: Qt.Horizontal
326 anchors.top: parent.top
327 anchors.bottom: parent.bottom
328 anchors.right: parent.left
330 width: shell.edgeSize
331 direction: Direction.Leftwards
332 property bool haveApps: mainStage.applications.count > 0 || sideStage.applications.count > 0
334 maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
335 // Make autocompletion impossible when !haveApps
336 edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
348 anchors.fill: parent //because this draws indicator menus
349 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
353 fullscreenMode: shell.fullscreenMode
357 blockInput: panel.indicators.shown
364 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
365 height: parent.height
367 available: !panel.indicators.shown
369 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
370 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
373 target: shell.applicationManager
374 onMainStageFocusedApplicationChanged: hud.hide()
375 onSideStageFocusedApplicationChanged: hud.hide()
380 blockInput: hud.shown
389 anchors.left: hud.left
390 height: parent.height
391 target: hud.revealerTarget
394 direction: Qt.RightToLeft
395 orientation: Qt.Vertical
396 handleSize: hud.handleHeight
397 onCloseClicked: target.hide()
403 enabled: !panel.indicators.shown
404 applicationIsOnForeground: applicationManager.mainStageFocusedApplication
405 || applicationManager.sideStageFocusedApplication
409 blockInput: launcher.shown
412 bottom: parent.bottom
415 width: launcher.width
421 anchors.top: parent.top
422 anchors.bottom: parent.bottom
424 dragAreaWidth: shell.edgeSize
425 onDashItemSelected: {
426 // Animate if moving between application and dash
428 dash.setCurrentScope("home.scope", true, false)
430 dash.setCurrentScope("home.scope", false, false)
436 dash.setCurrentScope("applications.scope", true, false)
441 onLauncherApplicationSelected:{
442 shell.activateApplication(desktopFile)
446 panel.indicators.hide()
455 model: NotificationBackend.Model
459 bottom: parent.bottom
460 leftMargin: units.gu(1)
461 rightMargin: units.gu(1)
462 topMargin: panel.panelHeight + units.gu(1)
467 when: overlay.width <= units.gu(60)
468 AnchorChanges { target: notifications; anchors.left: parent.left }
472 when: overlay.width > units.gu(60)
473 AnchorChanges { target: notifications; anchors.left: undefined }
474 PropertyChanges { target: notifications; width: units.gu(38) }
485 bottom: parent.bottom
488 width: shell.edgeSize
498 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
500 anchors.bottom: parent.bottom
501 anchors.left: parent.left
502 anchors.right: parent.right
503 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
505 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