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
34import Unity.Notifications 1.0 as NotificationBackend
35import Unity.Session 0.1
40 property int supportedScreenOrientations: {
41 // check device name and fix orientation if necessary
42 var deviceOrientations;
43 if (applicationArguments.device() === "flo") {
44 deviceOrientations = Qt.InvertedLandscapeOrientation;
45 } else if (applicationArguments.device() === "manta") {
46 deviceOrientations = Qt.LandscapeOrientation;
47 } else if (applicationArguments.device() === "mako") {
48 deviceOrientations = Qt.PortraitOrientation
49 | Qt.InvertedPortraitOrientation
50 | Qt.LandscapeOrientation
51 | Qt.InvertedLandscapeOrientation;
54 if (stages.shown && ApplicationManager.topmostApplication) {
55 return deviceOrientations & ApplicationManager.topmostApplication.supportedOrientations;
57 return deviceOrientations;
60 property bool dashShown: dash.shown && dash.available && underlay.visible
62 property real edgeSize: units.gu(2)
63 property url defaultBackground: Qt.resolvedUrl(shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg")
64 property url background
65 readonly property real panelHeight: panel.panelHeight
67 // this is only here to select the width / height of the window if not running fullscreen
68 property bool tablet: false
69 width: tablet ? units.gu(160) : applicationArguments.hasGeometry() ? applicationArguments.width() : units.gu(40)
70 height: tablet ? units.gu(100) : applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(71)
72 property bool sideStageEnabled: shell.width >= units.gu(100)
74 function activateApplication(appId) {
75 if (ApplicationManager.findApplication(appId)) {
76 ApplicationManager.requestFocusApplication(appId);
78 var execFlags = shell.sideStageEnabled ? ApplicationManager.NoFlag : ApplicationManager.ForceMainStage;
79 ApplicationManager.startApplication(appId, execFlags);
86 property: "applicationManager"
87 value: ApplicationManager
90 Component.onCompleted: {
91 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
95 id: backgroundSettings
96 schema.id: "org.gnome.desktop.background"
98 property url gSettingsPicture: backgroundSettings.pictureUri != undefined && backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : shell.defaultBackground
99 onGSettingsPictureChanged: {
100 shell.background = gSettingsPicture
107 Keys.onVolumeUpPressed: volumeControl.volumeUp()
108 Keys.onVolumeDownPressed: volumeControl.volumeDown()
112 objectName: "underlay"
115 // Whether the underlay is fully covered by opaque UI elements.
116 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
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
125 opacity: dash.disappearingAnimationProgress
130 source: shell.width > shell.height ? "Dash/graphics/paper_landscape.png" : "Dash/graphics/paper_portrait.png"
131 fillMode: Image.PreserveAspectCrop
132 horizontalAlignment: Image.AlignRight
133 verticalAlignment: Image.AlignTop
140 available: !greeter.shown && !lockscreen.shown
141 hides: [stages, launcher, panel.indicators]
142 shown: disappearingAnimationProgress !== 1.0 && greeterWrapper.showProgress !== 1.0
143 enabled: disappearingAnimationProgress === 0.0 && greeterWrapper.showProgress === 0.0 && edgeDemo.dashEnabled
147 topMargin: panel.panelHeight
150 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
151 opacity: 1.0 - disappearingAnimationProgress
152 property real disappearingAnimationProgress: stages.showProgress
154 // FIXME: only necessary because stages.showProgress is not animated
155 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
161 direction: Direction.Leftwards
163 anchors { top: parent.top; right: parent.right; bottom: parent.bottom }
164 width: shell.edgeSize
166 property real progress: stages.width
169 if (status == DirectionalDragArea.Recognized) {
170 if (ApplicationManager.empty) {
171 progress = Math.max(stages.width - stagesDragArea.width + touchX, stages.width * .3);
173 progress = stages.width - stagesDragArea.width + touchX;
180 if (!ApplicationManager.empty && progress < stages.width - units.gu(10)) {
183 stagesDragArea.progress = Qt.binding(function () { return stages.width; });
192 height: parent.height
194 visible: !fullyHidden && !ApplicationManager.empty
196 x: shown ? launcher.progress : stagesDragArea.progress
197 Behavior on x { SmoothedAnimation { velocity: 600; duration: UbuntuAnimation.FastDuration } }
199 property bool shown: false
202 if (ApplicationManager.topmostApplication) {
203 ApplicationManager.focusApplication(ApplicationManager.topmostApplication.appId);
206 if (ApplicationManager.focusedApplicationId) {
207 ApplicationManager.updateScreenshot(ApplicationManager.focusedApplicationId);
208 ApplicationManager.unfocusCurrentApplication();
213 // Avoid a silent "divide by zero -> NaN" situation during init as shell.width will be
214 // zero. That breaks the property binding and the function won't be reevaluated once
215 // shell.width is set, with the NaN result staying there for good.
216 property real showProgress: shell.width ? MathUtils.clamp(1 - x / shell.width, 0, 1) : 0
218 property bool fullyShown: x == 0
219 property bool fullyHidden: x == width
221 // It might technically not be fullyShown but visually it just looks so.
222 property bool roughlyFullyShown: x >= 0 && x <= units.gu(1)
233 target: ApplicationManager
241 onApplicationAdded: {
248 if (ApplicationManager.empty) {
255 target: DBusUnitySessionService
257 function closeAllApps() {
259 var app = ApplicationManager.get(0);
263 ApplicationManager.stopApplication(app.appId);
268 // TODO: Display a dialog to ask the user to confirm.
269 DBusUnitySessionService.Logout();
279 id: applicationsDisplayLoader
282 source: shell.sideStageEnabled ? "Stages/TabletStage.qml" : "Stages/PhoneStage.qml"
285 target: applicationsDisplayLoader.item
286 property: "dragAreaWidth"
287 value: shell.edgeSize
290 target: applicationsDisplayLoader.item
291 property: "maximizedAppTopMargin"
292 value: panel.panelHeight
295 target: applicationsDisplayLoader.item
296 property: "interactive"
297 value: stages.roughlyFullyShown
305 z: notifications.useModal || panel.indicators.shown ? overlay.z + 1 : overlay.z - 1
309 target: SurfaceManager
311 if (surface.type == MirSurfaceItem.InputMethod) {
312 inputMethod.surface = surface;
318 onSurfaceDestroyed: {
319 if (inputMethod.surface == surface) {
320 inputMethod.surface = null;
321 surface.parent = null;
323 if (!surface.parent) {
324 // there's no one displaying it. delete it right away
332 objectName: "lockscreen"
334 readonly property int backgroundTopMargin: -panel.panelHeight
336 hides: [launcher, panel.indicators]
339 showAnimation: StandardAnimation { property: "opacity"; to: 1 }
340 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
342 x: required ? 0 : - width
344 height: parent.height - panel.panelHeight
345 //background: shell.background // FIXME: Commenting out as Qt was complaining about this line
349 onEntered: LightDM.Greeter.respond(passphrase);
350 onCancel: greeter.show()
352 Component.onCompleted: {
353 if (LightDM.Users.count == 1) {
354 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
360 target: LightDM.Greeter
363 if (LightDM.Users.count == 1) {
364 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
366 lockscreen.alphaNumeric = false
368 lockscreen.alphaNumeric = true
370 lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
375 onAuthenticationComplete: {
376 if (LightDM.Greeter.promptless) {
379 if (LightDM.Greeter.authenticated) {
382 lockscreen.clear(true);
390 opacity: greeterWrapper.showProgress * 0.8
394 // Just a tiny wrapper to adjust greeter's x without messing with its own dragging
399 height: parent.height - panel.panelHeight
402 enabled: !launcher.dashSwipe
406 readonly property real showProgress: MathUtils.clamp((1 - x/width) + greeter.showProgress - 1, 0, 1)
410 objectName: "greeter"
413 hides: [launcher, panel.indicators]
416 defaultBackground: shell.background
419 height: parent.height
421 dragHandleWidth: shell.edgeSize
426 // If there is only one user, we start authenticating with that one here.
427 // If there are more users, the Greeter will handle that
428 if (LightDM.Users.count == 1) {
429 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
431 greeter.forceActiveFocus();
435 onUnlocked: greeter.hide()
437 // Update launcher items for new user
438 var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);
439 AccountsService.user = user;
440 LauncherModel.setUser(user);
443 onTease: launcher.tease()
446 target: ApplicationManager
447 property: "suspended"
448 value: greeter.shown && greeterWrapper.showProgress == 1
457 onDisplayPowerStateChange: {
458 // We ignore any display-off signals when the proximity sensor
459 // is active. This usually indicates something like a phone call.
460 if (status == Powerd.Off && reason != Powerd.Proximity) {
464 // No reason to chew demo CPU when user isn't watching
465 if (status == Powerd.Off) {
466 edgeDemo.paused = true;
467 } else if (status == Powerd.On) {
468 edgeDemo.paused = false;
473 function showHome() {
474 var animate = !greeter.shown && !stages.shown
476 dash.setCurrentScope("clickscope", animate, false)
480 function hideIndicatorMenu(delay) {
481 panel.hideIndicatorMenu(delay);
492 anchors.fill: parent //because this draws indicator menus
493 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
496 available: edgeDemo.panelEnabled
497 contentEnabled: edgeDemo.panelContentEnabled
500 property bool topmostApplicationIsFullscreen:
501 ApplicationManager.topmostApplication &&
502 ApplicationManager.topmostApplication.fullscreen
504 fullscreenMode: stages.roughlyFullyShown && topmostApplicationIsFullscreen
505 && !greeter.shown && !lockscreen.shown
507 searchVisible: !greeter.shown && !lockscreen.shown && dash.shown && dash.searchable
513 readonly property bool dashSwipe: progress > 0
515 anchors.top: parent.top
516 anchors.bottom: parent.bottom
518 dragAreaWidth: shell.edgeSize
519 available: edgeDemo.launcherEnabled
522 if (edgeDemo.running)
528 if (!stages.locked) {
537 onDashSwipeChanged: if (dashSwipe && stages.shown) dash.setCurrentScope("clickscope", false, true)
538 onLauncherApplicationSelected: {
539 if (!edgeDemo.running)
540 shell.activateApplication(appId)
544 panel.indicators.hide()
550 id: modalNotificationBackground
552 visible: notifications.useModal && !greeter.shown && (notifications.state == "narrow")
565 model: NotificationBackend.Model
571 bottom: parent.bottom
572 topMargin: panel.panelHeight
577 when: overlay.width <= units.gu(60)
578 AnchorChanges { target: notifications; anchors.left: parent.left }
582 when: overlay.width > units.gu(60)
583 AnchorChanges { target: notifications; anchors.left: undefined }
584 PropertyChanges { target: notifications; width: units.gu(38) }
591 onFocusChanged: if (!focus) forceActiveFocus();
600 id: alphaDisclaimerLabel
601 anchors.centerIn: parent
602 visible: ApplicationManager.fake ? ApplicationManager.fake : false
604 text: "EARLY ALPHA\nNOT READY FOR USE"
607 font.weight: Font.Black
608 horizontalAlignment: Text.AlignHCenter
609 verticalAlignment: Text.AlignVCenter
610 fontSizeMode: Text.Fit
612 scale: Math.min(parent.width, parent.height) / width
617 z: alphaDisclaimerLabel.z + 10
621 indicators: panel.indicators
626 target: SessionBroadcast
627 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