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
24import LightDM 0.1 as LightDM
26import SessionBroadcast 0.1
35import Unity.Notifications 1.0 as NotificationBackend
40 // this is only here to select the width / height of the window if not running fullscreen
41 property bool tablet: false
42 width: tablet ? units.gu(160) : applicationArguments.hasGeometry() ? applicationArguments.width() : units.gu(40)
43 height: tablet ? units.gu(100) : applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(71)
45 property real edgeSize: units.gu(2)
46 property url defaultBackground: Qt.resolvedUrl(shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg")
47 property url background
48 readonly property real panelHeight: panel.panelHeight
50 property bool dashShown: dash.shown
52 property bool sideStageEnabled: shell.width >= units.gu(100)
53 readonly property string focusedApplicationId: ApplicationManager.focusedApplicationId
55 function activateApplication(appId) {
56 if (ApplicationManager.findApplication(appId)) {
57 ApplicationManager.requestFocusApplication(appId);
59 if (stages.locked && ApplicationManager.focusedApplicationId == appId) {
60 applicationsDisplayLoader.item.select(appId);
63 var execFlags = shell.sideStageEnabled ? ApplicationManager.NoFlag : ApplicationManager.ForceMainStage;
64 ApplicationManager.startApplication(appId, execFlags);
71 property: "applicationManager"
72 value: ApplicationManager
75 Component.onCompleted: {
76 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
80 id: backgroundSettings
81 schema.id: "org.gnome.desktop.background"
83 property url gSettingsPicture: backgroundSettings.pictureUri != undefined && backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : shell.defaultBackground
84 onGSettingsPictureChanged: {
85 shell.background = gSettingsPicture
92 Keys.onVolumeUpPressed: volumeControl.volumeUp()
93 Keys.onVolumeDownPressed: volumeControl.volumeDown()
98 anchors.rightMargin: stages.overlayWidth
99 clip: stages.overlayMode && !stages.painting
103 blockInput: parent.clip
108 objectName: "underlay"
110 anchors.rightMargin: -parent.anchors.rightMargin
112 // Whether the underlay is fully covered by opaque UI elements.
113 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
115 // Whether the user should see the topmost application surface (if there's one at all).
116 readonly property bool applicationSurfaceShouldBeSeen: stages.shown && !stages.painting && !stages.overlayMode
118 // NB! Application surfaces are stacked behind the shell one. So they can only be seen by the user
119 // through the translucent parts of the shell surface.
120 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
124 objectName: "backgroundImage"
127 source: shell.background
128 fillMode: Image.PreserveAspectCrop
134 opacity: dash.disappearingAnimationProgress
139 source: shell.width > shell.height ? "Dash/graphics/paper_landscape.png" : "Dash/graphics/paper_portrait.png"
140 fillMode: Image.PreserveAspectCrop
141 horizontalAlignment: Image.AlignRight
142 verticalAlignment: Image.AlignTop
149 available: !greeter.shown && !lockscreen.shown
150 hides: [stages, launcher, panel.indicators]
151 shown: disappearingAnimationProgress !== 1.0
152 enabled: disappearingAnimationProgress === 0.0 && edgeDemo.dashEnabled
156 topMargin: panel.panelHeight
159 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
160 opacity: 1.0 - disappearingAnimationProgress
161 property real disappearingAnimationProgress: {
163 return greeter.showProgress;
165 if (stages.overlayMode) {
168 return stages.showProgress
172 // FIXME: only necessary because stages.showProgress and
173 // greeterRevealer.animatedProgress are not animated
174 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
181 direction: Direction.Leftwards
183 anchors { top: parent.top; right: parent.right; bottom: parent.bottom }
184 width: shell.edgeSize
186 property real progress: stages.width
189 if (status == DirectionalDragArea.Recognized) {
190 if (ApplicationManager.count == 0) {
191 progress = Math.max(stages.width - stagesDragHandle.width + touchX, stages.width * .3)
193 progress = stages.width - stagesDragHandle.width + touchX
200 if (ApplicationManager.count > 0 && progress < stages.width - units.gu(10)) {
203 stagesDragHandle.progress = stages.width;
212 height: parent.height
216 if (overlayMode || locked) {
219 return launcher.progress
221 return stagesDragHandle.progress
225 Behavior on x { SmoothedAnimation { velocity: 600; duration: UbuntuAnimation.FastDuration } }
227 property bool shown: false
229 property real showProgress: overlayMode ? 0 : MathUtils.clamp(1 - x / shell.width, 0, 1)
231 property bool fullyShown: x == 0
232 property bool fullyHidden: x == width
234 property bool painting: applicationsDisplayLoader.item ? applicationsDisplayLoader.item.painting : false
235 property bool fullscreen: applicationsDisplayLoader.item ? applicationsDisplayLoader.item.fullscreen : false
236 property bool overlayMode: applicationsDisplayLoader.item ? applicationsDisplayLoader.item.overlayMode : false
237 property int overlayWidth: applicationsDisplayLoader.item ? applicationsDisplayLoader.item.overlayWidth : false
238 property bool locked: applicationsDisplayLoader.item ? applicationsDisplayLoader.item.locked : false
240 function show(focusApp) {
242 panel.indicators.hide();
243 if (!ApplicationManager.focusedApplicationId && ApplicationManager.count > 0 && focusApp) {
244 ApplicationManager.focusApplication(ApplicationManager.get(0).appId);
250 if (ApplicationManager.focusedApplicationId) {
251 ApplicationManager.unfocusCurrentApplication();
256 target: ApplicationManager
262 onFocusedApplicationIdChanged: {
263 if (ApplicationManager.focusedApplicationId.length > 0) {
266 if (!stages.overlayMode) {
271 // If any app is focused when greeter is open, it's due to a user action
272 // like a snap decision (say, an incoming call).
273 // TODO: these should be protected to only unlock for certain applications / certain usecases
274 // potentially only in connection with a notification.
278 onApplicationAdded: {
282 onApplicationRemoved: {
283 if (ApplicationManager.focusedApplicationId.length == 0) {
290 id: applicationsDisplayLoader
293 source: shell.sideStageEnabled ? "Stages/StageWithSideStage.qml" : "Stages/PhoneStage.qml"
296 target: applicationsDisplayLoader.item
298 value: !stages.fullyShown
301 target: applicationsDisplayLoader.item
306 target: applicationsDisplayLoader.item
307 property: "dragAreaWidth"
308 value: shell.edgeSize
315 objectName: "lockscreen"
317 readonly property int backgroundTopMargin: -panel.panelHeight
319 hides: [launcher, panel.indicators, hud]
322 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
323 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
325 x: required ? 0 : - width
327 height: parent.height - panel.panelHeight
328 background: shell.background
331 onEntered: LightDM.Greeter.respond(passphrase);
332 onCancel: greeter.show()
334 Component.onCompleted: {
335 if (LightDM.Users.count == 1) {
336 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
342 target: LightDM.Greeter
345 if (LightDM.Users.count == 1) {
346 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
348 lockscreen.alphaNumeric = false
350 lockscreen.alphaNumeric = true
352 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
357 onAuthenticationComplete: {
358 if (LightDM.Greeter.promptless) {
361 if (LightDM.Greeter.authenticated) {
364 lockscreen.clear(true);
371 objectName: "greeter"
374 hides: [launcher, panel.indicators, hud]
377 defaultBackground: shell.background
381 height: parent.height - panel.panelHeight
383 dragHandleWidth: shell.edgeSize
388 // If there is only one user, we start authenticating with that one here.
389 // If there are more users, the Greeter will handle that
390 if (LightDM.Users.count == 1) {
391 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
393 greeter.forceActiveFocus();
397 onUnlocked: greeter.hide()
399 // Update launcher items for new user
400 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);
401 AccountsService.user = user;
402 LauncherModel.setUser(user);
405 onLeftTeaserPressedChanged: {
406 if (leftTeaserPressed) {
412 target: ApplicationManager
413 property: "suspended"
414 value: greeter.shown && greeter.showProgress == 1
420 blockInput: ApplicationManager.focusedApplicationId.length === 0 || greeter.shown || lockscreen.shown || launcher.shown
421 || panel.indicators.shown || hud.shown
428 onDisplayPowerStateChange: {
429 // We ignore any display-off signals when the proximity sensor
430 // is active. This usually indicates something like a phone call.
431 if (status == Powerd.Off && (flags & Powerd.UseProximity) == 0) {
435 // No reason to chew demo CPU when user isn't watching
436 if (status == Powerd.Off) {
437 edgeDemo.paused = true;
438 } else if (status == Powerd.On) {
439 edgeDemo.paused = false;
444 function showHome() {
445 var animate = !greeter.shown && !stages.shown
447 dash.setCurrentScope("clickscope", animate, false)
451 function hideIndicatorMenu(delay) {
452 panel.hideIndicatorMenu(delay);
462 anchors.fill: parent //because this draws indicator menus
463 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
466 available: edgeDemo.panelEnabled
467 contentEnabled: edgeDemo.panelContentEnabled
469 property string focusedAppId: ApplicationManager.focusedApplicationId
470 property var focusedApplication: ApplicationManager.findApplication(focusedAppId)
471 fullscreenMode: focusedApplication && stages.fullscreen && !greeter.shown && !lockscreen.shown
472 searchVisible: !greeter.shown && !lockscreen.shown && dash.shown && dash.searchable
480 height: (panel.fullscreenMode) ? shell.edgeSize : panel.panelHeight
488 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
489 height: parent.height
491 available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown && edgeDemo.dashEnabled
493 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
494 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
497 target: ApplicationManager
498 onFocusedApplicationIdChanged: hud.hide()
507 anchors.left: hud.left
508 height: parent.height
509 target: hud.revealerTarget
512 direction: Qt.RightToLeft
513 orientation: Qt.Vertical
514 handleSize: hud.handleHeight
515 onCloseClicked: target.hide()
522 enabled: hud.available
523 applicationIsOnForeground: ApplicationManager.focusedApplicationId
527 blockInput: launcher.shown
530 bottom: parent.bottom
533 width: launcher.width
539 readonly property bool dashSwipe: progress > 0
541 anchors.top: parent.top
542 anchors.bottom: parent.bottom
544 dragAreaWidth: shell.edgeSize
545 available: (!greeter.shown || greeter.narrowMode) && edgeDemo.launcherEnabled
548 if (edgeDemo.running)
554 if (stages.shown && !stages.overlayMode) {
555 if (!stages.locked) {
561 onDashSwipeChanged: if (dashSwipe && stages.shown) dash.setCurrentScope("clickscope", false, true)
562 onLauncherApplicationSelected:{
563 if (edgeDemo.running)
567 shell.activateApplication(appId)
571 panel.indicators.hide()
581 model: NotificationBackend.Model
587 bottom: parent.bottom
588 topMargin: panel.panelHeight
593 when: overlay.width <= units.gu(60)
594 AnchorChanges { target: notifications; anchors.left: parent.left }
598 when: overlay.width > units.gu(60)
599 AnchorChanges { target: notifications; anchors.left: undefined }
600 PropertyChanges { target: notifications; width: units.gu(38) }
605 anchors { left: parent.left; right: parent.right }
606 height: parent.contentHeight
607 blockInput: height > 0
613 onFocusChanged: if (!focus) forceActiveFocus();
618 bottom: parent.bottom
621 width: shell.edgeSize
628 bottom: parent.bottom
631 width: shell.edgeSize
642 anchors.topMargin: panel.panelHeight
643 anchors.fill: parent // as needs to know the geometry of the shell
646 //FIXME: This should be handled in the input stack, keyboard shouldnt propagate
648 anchors.bottom: parent.bottom
649 anchors.left: parent.left
650 anchors.right: parent.right
651 height: ApplicationManager.keyboardVisible ? ApplicationManager.keyboardHeight : 0
653 enabled: ApplicationManager.keyboardVisible
657 anchors.centerIn: parent
658 visible: ApplicationManager.fake ? ApplicationManager.fake : false
659 text: "EARLY ALPHA\nNOT READY FOR USE"
662 font.weight: Font.Black
663 horizontalAlignment: Text.AlignHCenter
664 verticalAlignment: Text.AlignVCenter
665 fontSizeMode: Text.Fit
667 scale: Math.min(parent.width, parent.height) / width
675 indicators: panel.indicators
680 target: SessionBroadcast
681 onShowHome: showHome()
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