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 source: shell.background
124 sourceSize.width: parent.width
125 sourceSize.height: parent.height
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 }}
166 id: stagesOuterContainer
169 height: parent.height
171 Behavior on x {SmoothedAnimation{velocity: 600}}
173 property real showProgress:
174 MathLocal.clamp(1 - (x + stages.x) / shell.width, 0, 1)
182 property bool fullyShown: shown && x == 0 && parent.x == 0
183 property bool fullyHidden: !shown && x == width
184 hides: [launcher, panel.indicators]
187 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
188 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
191 height: parent.height
193 // close the stages when no focused application remains
195 target: shell.applicationManager
196 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
197 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
198 ignoreUnknownSignals: true
201 function closeIfNoApplications() {
202 if (!shell.applicationManager.mainStageFocusedApplication
203 && !shell.applicationManager.sideStageFocusedApplication
204 && shell.applicationManager.mainStageApplications.count == 0
205 && shell.applicationManager.sideStageApplications.count == 0) {
210 // show the stages when an application gets the focus
212 target: shell.applicationManager
213 onMainStageFocusedApplicationChanged: {
214 if (shell.applicationManager.mainStageFocusedApplication) {
219 onSideStageFocusedApplicationChanged: {
220 if (shell.applicationManager.sideStageFocusedApplication) {
225 ignoreUnknownSignals: true
233 fullyShown: stages.fullyShown
234 fullyHidden: stages.fullyHidden
235 shouldUseScreenshots: !fullyShown
236 rightEdgeEnabled: !sideStage.enabled
238 applicationManager: shell.applicationManager
239 rightEdgeDraggingAreaWidth: shell.edgeSize
240 normalApplicationY: shell.panelHeight
249 // FIXME: workaround the fact that focusing a main stage application
250 // raises its surface on top of all other surfaces including the ones
251 // that belong to side stage applications.
252 onFocusedApplicationChanged: {
253 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
254 shell.applicationManager.focusApplication(sideStage.focusedApplication);
262 applicationManager: shell.applicationManager
263 rightEdgeDraggingAreaWidth: shell.edgeSize
264 normalApplicationY: shell.panelHeight
267 if (!shown && mainStage.applications.count == 0) {
271 // FIXME: when hiding the side stage, refocus the main stage
272 // application so that it goes in front of the side stage
273 // application and hides it
274 onFullyShownChanged: {
275 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
276 shell.applicationManager.focusApplication(mainStage.focusedApplication);
280 enabled: shell.width >= units.gu(60)
282 fullyShown: stages.fullyShown && shown
283 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
284 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
287 hides: [launcher, panel.indicators]
289 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
290 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
293 height: stages.height
294 handleExpanded: sideStageRevealer.pressed
298 id: sideStageRevealer
300 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
301 && sideStage.available
302 direction: Qt.RightToLeft
303 openedValue: parent.width - sideStage.width
304 hintDisplacement: units.gu(3)
305 /* The size of the sidestage handle needs to be bigger than the
306 typical size used for edge detection otherwise it is really
309 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
310 closedValue: parent.width + sideStage.handleSizeCollapsed
312 x: parent.width - width
313 width: sideStage.width + handleSize * 0.7
314 height: sideStage.height
315 orientation: Qt.Horizontal
321 anchors.top: parent.top
322 anchors.bottom: parent.bottom
323 anchors.right: parent.left
325 width: shell.edgeSize
326 direction: Direction.Leftwards
327 property bool haveApps: mainStage.applications.count > 0 || sideStage.applications.count > 0
329 maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
330 // Make autocompletion impossible when !haveApps
331 edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
340 property var previousMainApp: null
341 property var previousSideApp: null
343 function setFocused(focused) {
345 // FIXME: *FocusedApplication are not updated when unfocused, hence the need to check whether
346 // the stage was actually shown
347 if (mainStage.fullyShown) powerConnection.previousMainApp = applicationManager.mainStageFocusedApplication;
348 if (sideStage.fullyShown) powerConnection.previousSideApp = applicationManager.sideStageFocusedApplication;
349 applicationManager.unfocusCurrentApplication();
351 if (powerConnection.previousMainApp) {
352 applicationManager.focusApplication(powerConnection.previousMainApp);
353 powerConnection.previousMainApp = null;
355 if (powerConnection.previousSideApp) {
356 applicationManager.focusApplication(powerConnection.previousSideApp);
357 powerConnection.previousSideApp = null;
362 onPowerStateChange: {
363 if (state == 0) { // suspend
364 powerConnection.setFocused(false);
365 SessionManager.lock();
366 } else if (state == 1) { // active
367 powerConnection.setFocused(true);
379 anchors.fill: parent //because this draws indicator menus
380 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
384 fullscreenMode: shell.fullscreenMode
388 blockInput: panel.indicators.shown
395 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
396 height: parent.height
398 available: !panel.indicators.shown
400 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
401 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
404 target: shell.applicationManager
405 onMainStageFocusedApplicationChanged: hud.hide()
406 onSideStageFocusedApplicationChanged: hud.hide()
411 blockInput: hud.shown
420 anchors.left: hud.left
421 height: parent.height
422 target: hud.revealerTarget
425 direction: Qt.RightToLeft
426 orientation: Qt.Vertical
427 handleSize: hud.handleHeight
428 onCloseClicked: target.hide()
434 enabled: !panel.indicators.shown
435 applicationIsOnForeground: applicationManager.mainStageFocusedApplication
436 || applicationManager.sideStageFocusedApplication
440 blockInput: launcher.shown
443 bottom: parent.bottom
446 width: launcher.width
452 anchors.top: parent.top
453 anchors.bottom: parent.bottom
455 dragAreaWidth: shell.edgeSize
456 onDashItemSelected: {
457 // Animate if moving between application and dash
459 dash.setCurrentScope("home.scope", true, false)
461 dash.setCurrentScope("home.scope", false, false)
467 dash.setCurrentScope("applications.scope", true, false)
472 onLauncherApplicationSelected:{
473 shell.activateApplication(desktopFile)
477 panel.indicators.hide()
486 model: NotificationBackend.Model
490 bottom: parent.bottom
491 leftMargin: units.gu(1)
492 rightMargin: units.gu(1)
493 topMargin: panel.panelHeight + units.gu(1)
498 when: overlay.width <= units.gu(60)
499 AnchorChanges { target: notifications; anchors.left: parent.left }
503 when: overlay.width > units.gu(60)
504 AnchorChanges { target: notifications; anchors.left: undefined }
505 PropertyChanges { target: notifications; width: units.gu(38) }
516 bottom: parent.bottom
519 width: shell.edgeSize
529 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
531 anchors.bottom: parent.bottom
532 anchors.left: parent.left
533 anchors.right: parent.right
534 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
536 enabled: shell.applicationManager && shell.applicationManager.keyboardVisible
541 visible: applicationManager.fake
542 text: "EARLY ALPHA\nNOT READY FOR USE"
545 font.weight: Font.Black
546 horizontalAlignment: Text.AlignHCenter
547 verticalAlignment: Text.AlignVCenter
548 fontSizeMode: Text.Fit
549 font.pixelSize: height/2
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