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 AccountsService 0.1
20import Unity.Application 0.1
21import Ubuntu.Components 0.1
22import Ubuntu.Gestures 0.1
23import Unity.Launcher 0.1
25import SessionBroadcast 0.1
26import SessionManager 0.1
32import "Components/Math.js" as MathLocal
36import Unity.Notifications 1.0 as NotificationBackend
41 readonly property real panelHeight: panel.panelHeight
43 property bool dashShown: dash.shown
44 property bool stageScreenshotsReady: {
45 if (sideStage.shown) {
46 if (mainStage.applications.count > 0) {
47 return mainStage.usingScreenshots && sideStage.usingScreenshots;
49 return sideStage.usingScreenshots;
52 return mainStage.usingScreenshots;
56 property ListModel searchHistory: SearchHistoryModel {}
58 property var applicationManager: ApplicationManagerWrapper {}
62 property: "applicationManager"
63 value: ApplicationManager
66 Component.onCompleted: {
67 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
69 applicationManager.sideStageEnabled = Qt.binding(function() { return sideStage.enabled })
71 // FIXME: if application focused before shell starts, shell draws on top of it only.
72 // We should detect already running applications on shell start and bring them to the front.
73 applicationManager.unfocusCurrentApplication();
76 readonly property bool applicationFocused: !!applicationManager.mainStageFocusedApplication
77 || !!applicationManager.sideStageFocusedApplication
78 // Used for autopilot testing.
79 readonly property string currentFocusedAppId: ApplicationManager.focusedApplicationId
81 readonly property bool fullscreenMode: {
82 if (mainStage.usingScreenshots) { // Window Manager animating so want to re-evaluate fullscreen mode
83 return mainStage.switchingFromFullscreenToFullscreen;
84 } else if (applicationManager.mainStageFocusedApplication) {
85 return applicationManager.mainStageFocusedApplication.fullscreen;
91 function activateApplication(desktopFile, argument) {
92 if (applicationManager) {
93 // For newly started applications, as it takes them time to draw their first frame
94 // we add a delay before we hide the animation screenshots to compensate.
95 var addDelay = !applicationManager.getApplicationFromDesktopFile(desktopFile);
98 application = applicationManager.activateApplication(desktopFile, argument);
99 if (application == null) {
102 if (application.stage == ApplicationInfo.MainStage || !sideStage.enabled) {
103 mainStage.activateApplication(desktopFile, addDelay);
105 sideStage.activateApplication(desktopFile, addDelay);
112 id: backgroundSettings
113 schema.id: "org.gnome.desktop.background"
115 backgroundSource: backgroundSettings.pictureUri
119 objectName: "underlay"
122 // Whether the underlay is fully covered by opaque UI elements.
123 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
125 readonly property bool applicationRunning: ((mainStage.applications && mainStage.applications.count > 0)
126 || (sideStage.applications && sideStage.applications.count > 0))
128 // Whether the user should see the topmost application surface (if there's one at all).
129 readonly property bool applicationSurfaceShouldBeSeen: applicationRunning && !stages.fullyHidden
130 && !mainStage.usingScreenshots // but want sideStage animating over app surface
134 // NB! Application surfaces are stacked behing the shell one. So they can only be seen by the user
135 // through the translucent parts of the shell surface.
136 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
140 objectName: "backgroundImage"
143 source: shell.background
144 fillMode: Image.PreserveAspectCrop
150 opacity: dash.disappearingAnimationProgress
157 hides: [stages, launcher, panel.indicators]
158 shown: disappearingAnimationProgress !== 1.0
159 enabled: disappearingAnimationProgress === 0.0 && edgeDemo.dashEnabled
160 // FIXME: unfocus all applications when going back to the dash
163 shell.applicationManager.unfocusCurrentApplication()
169 topMargin: panel.panelHeight
172 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
173 opacity: 1.0 - disappearingAnimationProgress
174 property real disappearingAnimationProgress: stagesOuterContainer.showProgress
176 // FIXME: only necessary because stagesOuterContainer.showProgress
178 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
183 id: stagesOuterContainer
186 height: parent.height
188 Behavior on x {SmoothedAnimation{velocity: 600}}
190 property real showProgress:
191 MathLocal.clamp(1 - (x + stages.x) / shell.width, 0, 1)
199 property bool fullyShown: shown && x == 0 && parent.x == 0
200 property bool fullyHidden: !shown && x == width
201 hides: [panel.indicators]
204 showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
205 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
208 height: parent.height
210 // close the stages when no focused application remains
212 target: shell.applicationManager
213 onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
214 onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
215 ignoreUnknownSignals: true
218 function closeIfNoApplications() {
219 if (!shell.applicationManager.mainStageFocusedApplication
220 && !shell.applicationManager.sideStageFocusedApplication
221 && shell.applicationManager.mainStageApplications.count == 0
222 && shell.applicationManager.sideStageApplications.count == 0) {
227 // show the stages when an application gets the focus
229 target: shell.applicationManager
230 onMainStageFocusedApplicationChanged: {
231 if (shell.applicationManager.mainStageFocusedApplication) {
236 onSideStageFocusedApplicationChanged: {
237 if (shell.applicationManager.sideStageFocusedApplication) {
242 ignoreUnknownSignals: true
249 fullyShown: stages.fullyShown
250 fullyHidden: stages.fullyHidden
251 shouldUseScreenshots: !fullyShown
252 rightEdgeEnabled: !sideStage.enabled
254 applicationManager: shell.applicationManager
255 rightEdgeDraggingAreaWidth: shell.edgeSize
256 normalApplicationY: shell.panelHeight
265 // FIXME: workaround the fact that focusing a main stage application
266 // raises its surface on top of all other surfaces including the ones
267 // that belong to side stage applications.
268 onFocusedApplicationChanged: {
269 if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
270 shell.applicationManager.focusApplication(sideStage.focusedApplication);
278 applicationManager: shell.applicationManager
279 rightEdgeDraggingAreaWidth: shell.edgeSize
280 normalApplicationY: shell.panelHeight
283 if (!shown && mainStage.applications.count == 0) {
287 // FIXME: when hiding the side stage, refocus the main stage
288 // application so that it goes in front of the side stage
289 // application and hides it
290 onFullyShownChanged: {
291 if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
292 shell.applicationManager.focusApplication(mainStage.focusedApplication);
296 enabled: shell.width >= units.gu(60)
298 fullyShown: stages.fullyShown && shown
299 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
300 shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
303 hides: [launcher, panel.indicators]
305 showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
306 hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
309 height: stages.height
310 handleExpanded: sideStageRevealer.pressed
314 id: sideStageRevealer
316 enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
317 && sideStage.available
318 direction: Qt.RightToLeft
319 openedValue: parent.width - sideStage.width
320 hintDisplacement: units.gu(3)
321 /* The size of the sidestage handle needs to be bigger than the
322 typical size used for edge detection otherwise it is really
325 handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
326 closedValue: parent.width + sideStage.handleSizeCollapsed
328 x: parent.width - width
329 width: sideStage.width + handleSize * 0.7
330 height: sideStage.height
331 orientation: Qt.Horizontal
337 anchors.top: parent.top
338 anchors.bottom: parent.bottom
339 anchors.right: parent.left
341 width: shell.edgeSize
342 direction: Direction.Leftwards
343 enabled: greeter.showProgress == 0 && edgeDemo.dashEnabled
344 property bool haveApps: mainStage.applications.count > 0 || sideStage.applications.count > 0
346 maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
347 // Make autocompletion impossible when !haveApps
348 edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
355 blockInput: !applicationFocused || launcher.shown
356 || panel.indicators.shown || hud.shown
360 id: sessionConnection
361 target: SessionManager
363 property var previousMainApp: null
364 property var previousSideApp: null
366 function removeApplicationFocus() {
367 sessionConnection.previousMainApp = applicationManager.mainStageFocusedApplication;
368 sessionConnection.previousSideApp = applicationManager.sideStageFocusedApplication;
369 applicationManager.unfocusCurrentApplication();
372 function restoreApplicationFocus() {
373 if (sessionConnection.previousMainApp) {
374 applicationManager.focusApplication(sessionConnection.previousMainApp);
375 sessionConnection.previousMainApp = null;
377 if (sessionConnection.previousSideApp) {
378 applicationManager.focusApplication(sessionConnection.previousSideApp);
379 sessionConnection.previousSideApp = null;
384 if (SessionManager.active) {
385 restoreApplicationFocus();
387 removeApplicationFocus();
396 onDisplayPowerStateChange: {
397 // We ignore any display-off signals when the proximity sensor
398 // is active. This usually indicates something like a phone call.
399 if (status == Powerd.Off && (flags & Powerd.UseProximity) == 0) {
400 SessionManager.lock();
403 // No reason to chew demo CPU when user isn't watching
404 if (status == Powerd.Off) {
405 edgeDemo.paused = true;
406 } else if (status == Powerd.On) {
407 edgeDemo.paused = false;
412 function showHome(fromLauncher) {
413 var animate = fromLauncher && !stages.shown
414 dash.setCurrentScope("home.scope", animate, false)
425 anchors.fill: parent //because this draws indicator menus
426 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
429 available: edgeDemo.panelEnabled
430 contentEnabled: edgeDemo.panelContentEnabled
432 fullscreenMode: shell.fullscreenMode
433 searchVisible: dash.shown
441 height: (panel.fullscreenMode) ? shell.edgeSize : panel.panelHeight
449 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
450 height: parent.height
452 available: !panel.indicators.shown && edgeDemo.dashEnabled
454 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
455 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
458 target: shell.applicationManager
459 onMainStageFocusedApplicationChanged: hud.hide()
460 onSideStageFocusedApplicationChanged: hud.hide()
469 anchors.left: hud.left
470 height: parent.height
471 target: hud.revealerTarget
474 direction: Qt.RightToLeft
475 orientation: Qt.Vertical
476 handleSize: hud.handleHeight
477 onCloseClicked: target.hide()
484 enabled: hud.available
485 applicationIsOnForeground: applicationFocused
489 blockInput: launcher.shown
492 bottom: parent.bottom
495 width: launcher.width
501 anchors.top: parent.top
502 anchors.bottom: parent.bottom
504 dragAreaWidth: shell.edgeSize
505 available: edgeDemo.launcherEnabled
506 onDashItemSelected: showHome(true)
509 dash.setCurrentScope("applications.scope", true /* animate */, true /* reset */)
514 onLauncherApplicationSelected:{
515 shell.activateApplication(appId)
519 panel.indicators.hide()
529 model: NotificationBackend.Model
533 bottom: parent.bottom
534 leftMargin: units.gu(1)
535 rightMargin: units.gu(1)
536 topMargin: panel.panelHeight + units.gu(1)
541 when: overlay.width <= units.gu(60)
542 AnchorChanges { target: notifications; anchors.left: parent.left }
546 when: overlay.width > units.gu(60)
547 AnchorChanges { target: notifications; anchors.left: undefined }
548 PropertyChanges { target: notifications; width: units.gu(38) }
553 anchors { left: parent.left; right: parent.right }
554 height: parent.contentHeight
555 blockInput: height > 0
561 onFocusChanged: if (!focus) forceActiveFocus();
566 bottom: parent.bottom
569 width: shell.edgeSize
580 anchors.topMargin: panel.panelHeight
581 anchors.fill: parent // as needs to know the geometry of the shell
584 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
586 anchors.bottom: parent.bottom
587 anchors.left: parent.left
588 anchors.right: parent.right
589 height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
591 enabled: shell.applicationManager && shell.applicationManager.keyboardVisible
595 anchors.centerIn: parent
596 visible: applicationManager.fake
597 text: "EARLY ALPHA\nNOT READY FOR USE"
600 font.weight: Font.Black
601 horizontalAlignment: Text.AlignHCenter
602 verticalAlignment: Text.AlignVCenter
603 fontSizeMode: Text.Fit
605 scale: Math.min(parent.width, parent.height) / width
612 indicators: panel.indicators
617 target: SessionBroadcast
618 onShowHome: showHome(false)
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