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
22import SessionManager 0.1
28import "Components/Math.js" as MathLocal
32import Unity.Notifications 1.0 as NotificationBackend
37 readonly property real panelHeight: panel.panelHeight
39 property bool dashShown: dash.shown
40 property bool stageScreenshotsReady: {
41 if (sideStage.shown) {
42 if (mainStage.applications.count > 0) {
43 return mainStage.usingScreenshots && sideStage.usingScreenshots;
45 return sideStage.usingScreenshots;
48 return mainStage.usingScreenshots;
52 property ListModel searchHistory: SearchHistoryModel {}
54 property var applicationManager: ApplicationManagerWrapper {}
56 Component.onCompleted: {
57 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
59 applicationManager.sideStageEnabled = Qt.binding(function() { return sideStage.enabled })
61 // FIXME: if application focused before shell starts, shell draws on top of it only.
62 // We should detect already running applications on shell start and bring them to the front.
63 applicationManager.unfocusCurrentApplication();
66 readonly property bool fullscreenMode: {
67 if (mainStage.usingScreenshots) { // Window Manager animating so want to re-evaluate fullscreen mode
68 return mainStage.switchingFromFullscreenToFullscreen;
69 } else if (applicationManager.mainStageFocusedApplication) {
70 return applicationManager.mainStageFocusedApplication.fullscreen;
77 target: applicationManager
78 ignoreUnknownSignals: true
80 shell.activateApplication(desktopFile);
84 function activateApplication(desktopFile, argument) {
85 if (applicationManager) {
86 // For newly started applications, as it takes them time to draw their first frame
87 // we add a delay before we hide the animation screenshots to compensate.
88 var addDelay = !applicationManager.getApplicationFromDesktopFile(desktopFile);
91 application = applicationManager.activateApplication(desktopFile, argument);
92 if (application == null) {
95 if (application.stage == ApplicationInfo.MainStage || !sideStage.enabled) {
96 mainStage.activateApplication(desktopFile, addDelay);
98 sideStage.activateApplication(desktopFile, addDelay);
106 objectName: "underlay"
109 // Whether the underlay is fully covered by opaque UI elements.
110 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
112 // Whether the user should see the topmost application surface (if there's one at all).
113 property bool applicationSurfaceShouldBeSeen:
114 (mainStage.applications && mainStage.applications.count > 0)
115 && (!stages.fullyHidden && !mainStage.usingScreenshots)
117 // NB! Application surfaces are stacked behing the shell one. So they can only be seen by the user
118 // through the translucent parts of the shell surface.
119 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
123 objectName: "backgroundImage"
126 source: shell.background
132 opacity: dash.disappearingAnimationProgress
139 hides: [stages, launcher, panel.indicators]
140 shown: disappearingAnimationProgress !== 1.0
141 enabled: disappearingAnimationProgress === 0.0
142 // FIXME: unfocus all applications when going back to the dash
145 shell.applicationManager.unfocusCurrentApplication()
151 topMargin: panel.panelHeight
154 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
155 opacity: 1.0 - disappearingAnimationProgress
156 property real disappearingAnimationProgress: stagesOuterContainer.showProgress
158 // FIXME: only necessary because stagesOuterContainer.showProgress
160 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
165 id: stagesOuterContainer
168 height: parent.height
170 Behavior on x {SmoothedAnimation{velocity: 600}}
172 property real showProgress:
173 MathLocal.clamp(1 - (x + stages.x) / shell.width, 0, 1)
181 property bool fullyShown: shown && x == 0 && parent.x == 0
182 property bool fullyHidden: !shown && x == width
183 hides: [launcher, panel.indicators]
186 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
187 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
190 height: parent.height
192 // close the stages when no focused application remains
194 target: shell.applicationManager
195 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
196 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
197 ignoreUnknownSignals: true
200 function closeIfNoApplications() {
201 if (!shell.applicationManager.mainStageFocusedApplication
202 && !shell.applicationManager.sideStageFocusedApplication
203 && shell.applicationManager.mainStageApplications.count == 0
204 && shell.applicationManager.sideStageApplications.count == 0) {
209 // show the stages when an application gets the focus
211 target: shell.applicationManager
212 onMainStageFocusedApplicationChanged: {
213 if (shell.applicationManager.mainStageFocusedApplication) {
218 onSideStageFocusedApplicationChanged: {
219 if (shell.applicationManager.sideStageFocusedApplication) {
224 ignoreUnknownSignals: true
231 fullyShown: stages.fullyShown
232 fullyHidden: stages.fullyHidden
233 shouldUseScreenshots: !fullyShown
234 rightEdgeEnabled: !sideStage.enabled
236 applicationManager: shell.applicationManager
237 rightEdgeDraggingAreaWidth: shell.edgeSize
238 normalApplicationY: shell.panelHeight
247 // FIXME: workaround the fact that focusing a main stage application
248 // raises its surface on top of all other surfaces including the ones
249 // that belong to side stage applications.
250 onFocusedApplicationChanged: {
251 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
252 shell.applicationManager.focusApplication(sideStage.focusedApplication);
260 applicationManager: shell.applicationManager
261 rightEdgeDraggingAreaWidth: shell.edgeSize
262 normalApplicationY: shell.panelHeight
265 if (!shown && mainStage.applications.count == 0) {
269 // FIXME: when hiding the side stage, refocus the main stage
270 // application so that it goes in front of the side stage
271 // application and hides it
272 onFullyShownChanged: {
273 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
274 shell.applicationManager.focusApplication(mainStage.focusedApplication);
278 enabled: shell.width >= units.gu(60)
280 fullyShown: stages.fullyShown && shown
281 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
282 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
285 hides: [launcher, panel.indicators]
287 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
288 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
291 height: stages.height
292 handleExpanded: sideStageRevealer.pressed
296 id: sideStageRevealer
298 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
299 && sideStage.available
300 direction: Qt.RightToLeft
301 openedValue: parent.width - sideStage.width
302 hintDisplacement: units.gu(3)
303 /* The size of the sidestage handle needs to be bigger than the
304 typical size used for edge detection otherwise it is really
307 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
308 closedValue: parent.width + sideStage.handleSizeCollapsed
310 x: parent.width - width
311 width: sideStage.width + handleSize * 0.7
312 height: sideStage.height
313 orientation: Qt.Horizontal
319 anchors.top: parent.top
320 anchors.bottom: parent.bottom
321 anchors.right: parent.left
323 width: shell.edgeSize
324 direction: Direction.Leftwards
325 property bool haveApps: mainStage.applications.count > 0 || sideStage.applications.count > 0
327 maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
328 // Make autocompletion impossible when !haveApps
329 edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
338 property var previousMainApp: null
339 property var previousSideApp: null
341 function setFocused(focused) {
343 // FIXME: *FocusedApplication are not updated when unfocused, hence the need to check whether
344 // the stage was actually shown
345 if (mainStage.fullyShown) powerConnection.previousMainApp = applicationManager.mainStageFocusedApplication;
346 if (sideStage.fullyShown) powerConnection.previousSideApp = applicationManager.sideStageFocusedApplication;
347 applicationManager.unfocusCurrentApplication();
349 if (powerConnection.previousMainApp) {
350 applicationManager.focusApplication(powerConnection.previousMainApp);
351 powerConnection.previousMainApp = null;
353 if (powerConnection.previousSideApp) {
354 applicationManager.focusApplication(powerConnection.previousSideApp);
355 powerConnection.previousSideApp = null;
360 onPowerStateChange: {
361 if (state == 0) { // suspend
362 powerConnection.setFocused(false);
363 SessionManager.lock();
364 } else if (state == 1) { // active
365 powerConnection.setFocused(true);
377 anchors.fill: parent //because this draws indicator menus
378 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
382 fullscreenMode: shell.fullscreenMode
386 blockInput: panel.indicators.shown
393 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
394 height: parent.height
396 available: !panel.indicators.shown
398 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
399 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
402 target: shell.applicationManager
403 onMainStageFocusedApplicationChanged: hud.hide()
404 onSideStageFocusedApplicationChanged: hud.hide()
409 blockInput: hud.shown
418 anchors.left: hud.left
419 height: parent.height
420 target: hud.revealerTarget
423 direction: Qt.RightToLeft
424 orientation: Qt.Vertical
425 handleSize: hud.handleHeight
426 onCloseClicked: target.hide()
432 enabled: !panel.indicators.shown
433 applicationIsOnForeground: applicationManager.mainStageFocusedApplication
434 || applicationManager.sideStageFocusedApplication
438 blockInput: launcher.shown
441 bottom: parent.bottom
444 width: launcher.width
450 anchors.top: parent.top
451 anchors.bottom: parent.bottom
453 dragAreaWidth: shell.edgeSize
454 onDashItemSelected: {
455 // Animate if moving between application and dash
457 dash.setCurrentScope("home.scope", true, false)
459 dash.setCurrentScope("home.scope", false, false)
465 dash.setCurrentScope("applications.scope", true, false)
470 onLauncherApplicationSelected:{
471 shell.activateApplication(desktopFile)
475 panel.indicators.hide()
484 model: NotificationBackend.Model
488 bottom: parent.bottom
489 leftMargin: units.gu(1)
490 rightMargin: units.gu(1)
491 topMargin: panel.panelHeight + units.gu(1)
496 when: overlay.width <= units.gu(60)
497 AnchorChanges { target: notifications; anchors.left: parent.left }
501 when: overlay.width > units.gu(60)
502 AnchorChanges { target: notifications; anchors.left: undefined }
503 PropertyChanges { target: notifications; width: units.gu(38) }
514 bottom: parent.bottom
517 width: shell.edgeSize
527 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
529 anchors.bottom: parent.bottom
530 anchors.left: parent.left
531 anchors.right: parent.right
532 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
534 enabled: shell.applicationManager && shell.applicationManager.keyboardVisible
538 anchors.centerIn: parent
539 visible: applicationManager.fake
540 text: "EARLY ALPHA\nNOT READY FOR USE"
543 font.weight: Font.Black
544 horizontalAlignment: Text.AlignHCenter
545 verticalAlignment: Text.AlignVCenter
546 fontSizeMode: Text.Fit
548 scale: Math.min(parent.width, parent.height) / width
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