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 Unity.Launcher 0.1
23import SessionManager 0.1
29import "Components/Math.js" as MathLocal
33import Unity.Notifications 1.0 as NotificationBackend
38 readonly property real panelHeight: panel.panelHeight
40 property bool dashShown: dash.shown
41 property bool stageScreenshotsReady: {
42 if (sideStage.shown) {
43 if (mainStage.applications.count > 0) {
44 return mainStage.usingScreenshots && sideStage.usingScreenshots;
46 return sideStage.usingScreenshots;
49 return mainStage.usingScreenshots;
53 property ListModel searchHistory: SearchHistoryModel {}
55 property var applicationManager: ApplicationManagerWrapper {}
57 Component.onCompleted: {
58 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
60 applicationManager.sideStageEnabled = Qt.binding(function() { return sideStage.enabled })
62 // FIXME: if application focused before shell starts, shell draws on top of it only.
63 // We should detect already running applications on shell start and bring them to the front.
64 applicationManager.unfocusCurrentApplication();
67 readonly property bool fullscreenMode: {
68 if (mainStage.usingScreenshots) { // Window Manager animating so want to re-evaluate fullscreen mode
69 return mainStage.switchingFromFullscreenToFullscreen;
70 } else if (applicationManager.mainStageFocusedApplication) {
71 return applicationManager.mainStageFocusedApplication.fullscreen;
78 target: applicationManager
79 ignoreUnknownSignals: true
81 shell.activateApplication(desktopFile);
85 function activateApplication(desktopFile, argument) {
86 if (applicationManager) {
87 // For newly started applications, as it takes them time to draw their first frame
88 // we add a delay before we hide the animation screenshots to compensate.
89 var addDelay = !applicationManager.getApplicationFromDesktopFile(desktopFile);
92 application = applicationManager.activateApplication(desktopFile, argument);
93 if (application == null) {
96 if (application.stage == ApplicationInfo.MainStage || !sideStage.enabled) {
97 mainStage.activateApplication(desktopFile, addDelay);
99 sideStage.activateApplication(desktopFile, addDelay);
107 objectName: "underlay"
110 // Whether the underlay is fully covered by opaque UI elements.
111 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
113 readonly property bool applicationRunning: ((mainStage.applications && mainStage.applications.count > 0)
114 || (sideStage.applications && sideStage.applications.count > 0))
116 // Whether the user should see the topmost application surface (if there's one at all).
117 readonly property bool applicationSurfaceShouldBeSeen: applicationRunning && !stages.fullyHidden
118 && !mainStage.usingScreenshots // but want sideStage animating over app surface
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 objectName: "backgroundImage"
131 source: shell.background
137 opacity: dash.disappearingAnimationProgress
144 hides: [stages, launcher, panel.indicators]
145 shown: disappearingAnimationProgress !== 1.0
146 enabled: disappearingAnimationProgress === 0.0 && edgeDemo.dashEnabled
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 }}
170 id: stagesOuterContainer
173 height: parent.height
175 Behavior on x {SmoothedAnimation{velocity: 600}}
177 property real showProgress:
178 MathLocal.clamp(1 - (x + stages.x) / shell.width, 0, 1)
186 property bool fullyShown: shown && x == 0 && parent.x == 0
187 property bool fullyHidden: !shown && x == width
188 hides: [launcher, panel.indicators]
191 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
192 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
195 height: parent.height
197 // close the stages when no focused application remains
199 target: shell.applicationManager
200 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
201 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
202 ignoreUnknownSignals: true
205 function closeIfNoApplications() {
206 if (!shell.applicationManager.mainStageFocusedApplication
207 && !shell.applicationManager.sideStageFocusedApplication
208 && shell.applicationManager.mainStageApplications.count == 0
209 && shell.applicationManager.sideStageApplications.count == 0) {
214 // show the stages when an application gets the focus
216 target: shell.applicationManager
217 onMainStageFocusedApplicationChanged: {
218 if (shell.applicationManager.mainStageFocusedApplication) {
223 onSideStageFocusedApplicationChanged: {
224 if (shell.applicationManager.sideStageFocusedApplication) {
229 ignoreUnknownSignals: true
236 fullyShown: stages.fullyShown
237 fullyHidden: stages.fullyHidden
238 shouldUseScreenshots: !fullyShown
239 rightEdgeEnabled: !sideStage.enabled
241 applicationManager: shell.applicationManager
242 rightEdgeDraggingAreaWidth: shell.edgeSize
243 normalApplicationY: shell.panelHeight
252 // FIXME: workaround the fact that focusing a main stage application
253 // raises its surface on top of all other surfaces including the ones
254 // that belong to side stage applications.
255 onFocusedApplicationChanged: {
256 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
257 shell.applicationManager.focusApplication(sideStage.focusedApplication);
265 applicationManager: shell.applicationManager
266 rightEdgeDraggingAreaWidth: shell.edgeSize
267 normalApplicationY: shell.panelHeight
270 if (!shown && mainStage.applications.count == 0) {
274 // FIXME: when hiding the side stage, refocus the main stage
275 // application so that it goes in front of the side stage
276 // application and hides it
277 onFullyShownChanged: {
278 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
279 shell.applicationManager.focusApplication(mainStage.focusedApplication);
283 enabled: shell.width >= units.gu(60)
285 fullyShown: stages.fullyShown && shown
286 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
287 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
290 hides: [launcher, panel.indicators]
292 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
293 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
296 height: stages.height
297 handleExpanded: sideStageRevealer.pressed
301 id: sideStageRevealer
303 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
304 && sideStage.available
305 direction: Qt.RightToLeft
306 openedValue: parent.width - sideStage.width
307 hintDisplacement: units.gu(3)
308 /* The size of the sidestage handle needs to be bigger than the
309 typical size used for edge detection otherwise it is really
312 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
313 closedValue: parent.width + sideStage.handleSizeCollapsed
315 x: parent.width - width
316 width: sideStage.width + handleSize * 0.7
317 height: sideStage.height
318 orientation: Qt.Horizontal
324 anchors.top: parent.top
325 anchors.bottom: parent.bottom
326 anchors.right: parent.left
328 width: shell.edgeSize
329 direction: Direction.Leftwards
330 enabled: edgeDemo.dashEnabled
331 property bool haveApps: mainStage.applications.count > 0 || sideStage.applications.count > 0
333 maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
334 // Make autocompletion impossible when !haveApps
335 edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
344 property var previousMainApp: null
345 property var previousSideApp: null
347 function setFocused(focused) {
349 // FIXME: *FocusedApplication are not updated when unfocused, hence the need to check whether
350 // the stage was actually shown
351 if (mainStage.fullyShown) powerConnection.previousMainApp = applicationManager.mainStageFocusedApplication;
352 if (sideStage.fullyShown) powerConnection.previousSideApp = applicationManager.sideStageFocusedApplication;
353 applicationManager.unfocusCurrentApplication();
355 if (powerConnection.previousMainApp) {
356 applicationManager.focusApplication(powerConnection.previousMainApp);
357 powerConnection.previousMainApp = null;
359 if (powerConnection.previousSideApp) {
360 applicationManager.focusApplication(powerConnection.previousSideApp);
361 powerConnection.previousSideApp = null;
366 onDisplayPowerStateChange: {
367 // We ignore any display-off signals when the proximity sensor
368 // is active. This usually indicates something like a phone call.
369 if (status == Powerd.Off && (flags & Powerd.UseProximity) == 0) {
370 powerConnection.setFocused(false);
371 SessionManager.lock();
372 } else if (status == Powerd.On) {
373 powerConnection.setFocused(true);
376 // No reason to chew demo CPU when user isn't watching
377 if (status == Powerd.Off) {
378 edgeDemo.paused = true;
379 } else if (status == Powerd.On) {
380 edgeDemo.paused = false;
392 anchors.fill: parent //because this draws indicator menus
393 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
396 available: edgeDemo.panelEnabled
397 contentEnabled: edgeDemo.panelContentEnabled
399 fullscreenMode: shell.fullscreenMode
403 blockInput: panel.indicators.shown
410 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
411 height: parent.height
413 available: !panel.indicators.shown && edgeDemo.dashEnabled
415 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
416 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
419 target: shell.applicationManager
420 onMainStageFocusedApplicationChanged: hud.hide()
421 onSideStageFocusedApplicationChanged: hud.hide()
426 blockInput: hud.shown
435 anchors.left: hud.left
436 height: parent.height
437 target: hud.revealerTarget
440 direction: Qt.RightToLeft
441 orientation: Qt.Vertical
442 handleSize: hud.handleHeight
443 onCloseClicked: target.hide()
449 enabled: !panel.indicators.shown
450 applicationIsOnForeground: applicationManager.mainStageFocusedApplication
451 || applicationManager.sideStageFocusedApplication
455 blockInput: launcher.shown
458 bottom: parent.bottom
461 width: launcher.width
467 anchors.top: parent.top
468 anchors.bottom: parent.bottom
470 dragAreaWidth: shell.edgeSize
471 available: edgeDemo.launcherEnabled
472 onDashItemSelected: {
473 // Animate if moving between application and dash
475 dash.setCurrentScope("home.scope", true, false)
477 dash.setCurrentScope("home.scope", false, false)
483 dash.setCurrentScope("applications.scope", true, false)
488 onLauncherApplicationSelected:{
489 shell.activateApplication(desktopFile)
493 panel.indicators.hide()
502 model: NotificationBackend.Model
506 bottom: parent.bottom
507 leftMargin: units.gu(1)
508 rightMargin: units.gu(1)
509 topMargin: panel.panelHeight + units.gu(1)
514 when: overlay.width <= units.gu(60)
515 AnchorChanges { target: notifications; anchors.left: parent.left }
519 when: overlay.width > units.gu(60)
520 AnchorChanges { target: notifications; anchors.left: undefined }
521 PropertyChanges { target: notifications; width: units.gu(38) }
532 bottom: parent.bottom
535 width: shell.edgeSize
545 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
547 anchors.bottom: parent.bottom
548 anchors.left: parent.left
549 anchors.right: parent.right
550 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
552 enabled: shell.applicationManager && shell.applicationManager.keyboardVisible
556 anchors.centerIn: parent
557 visible: applicationManager.fake
558 text: "EARLY ALPHA\nNOT READY FOR USE"
561 font.weight: Font.Black
562 horizontalAlignment: Text.AlignHCenter
563 verticalAlignment: Text.AlignVCenter
564 fontSizeMode: Text.Fit
566 scale: Math.min(parent.width, parent.height) / width
573 indicators: panel.indicators
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