2 * Copyright (C) 2013-2015 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 QtQuick.Window 2.0
19import AccountsService 0.1
21import Unity.Application 0.1
22import Ubuntu.Components 0.1
23import Ubuntu.Components.Popups 1.0
24import Ubuntu.Gestures 0.1
25import Ubuntu.Telephony 0.1 as Telephony
26import Unity.Connectivity 0.1
27import Unity.Launcher 0.1
29import LightDM 0.1 as LightDM
31import SessionBroadcast 0.1
40import Unity.Notifications 1.0 as NotificationBackend
41import Unity.Session 0.1
42import Unity.DashCommunicator 0.1
43import Unity.Indicators 0.1 as Indicators
48 // to be set from outside
49 property int orientationAngle: 0
50 property int orientation
51 property int primaryOrientation
52 property int nativeOrientation
53 property real nativeWidth
54 property real nativeHeight
55 property alias indicatorAreaShowProgress: panel.indicatorAreaShowProgress
56 property bool beingResized
57 property string usageScenario: "phone" // supported values: "phone", "tablet" or "desktop"
58 function updateFocusedAppOrientation() {
59 applicationsDisplayLoader.item.updateFocusedAppOrientation();
61 function updateFocusedAppOrientationAnimated() {
62 applicationsDisplayLoader.item.updateFocusedAppOrientationAnimated();
65 // to be read from outside
66 readonly property int mainAppWindowOrientationAngle:
67 applicationsDisplayLoader.item ? applicationsDisplayLoader.item.mainAppWindowOrientationAngle : 0
69 readonly property bool orientationChangesEnabled: panel.indicators.fullyClosed
70 && (applicationsDisplayLoader.item && applicationsDisplayLoader.item.orientationChangesEnabled)
73 property bool startingUp: true
74 Timer { id: finishStartUpTimer; interval: 500; onTriggered: startingUp = false }
76 property int supportedOrientations: {
78 // Ensure we don't rotate during start up
79 return Qt.PrimaryOrientation;
80 } else if (greeter.shown) {
81 return Qt.PrimaryOrientation;
83 return mainApp.supportedOrientations;
86 return Qt.PortraitOrientation
87 | Qt.LandscapeOrientation
88 | Qt.InvertedPortraitOrientation
89 | Qt.InvertedLandscapeOrientation;
93 // For autopilot consumption
94 readonly property string focusedApplicationId: ApplicationManager.focusedApplicationId
96 // internal props from here onwards
97 readonly property var mainApp:
98 applicationsDisplayLoader.item ? applicationsDisplayLoader.item.mainApp : null
100 // Disable everything while greeter is waiting, so that the user can't swipe
101 // the greeter or launcher until we know whether the session is locked.
102 enabled: !greeter.waiting
104 property real edgeSize: units.gu(2)
105 property url defaultBackground: Qt.resolvedUrl(shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg")
106 property url background: asImageTester.status == Image.Ready ? asImageTester.source
107 : gsImageTester.status == Image.Ready ? gsImageTester.source : defaultBackground
108 readonly property real panelHeight: panel.panelHeight
110 function activateApplication(appId) {
111 if (ApplicationManager.findApplication(appId)) {
112 ApplicationManager.requestFocusApplication(appId);
114 var execFlags = shell.usageScenario === "phone" ? ApplicationManager.ForceMainStage
115 : ApplicationManager.NoFlag;
116 ApplicationManager.startApplication(appId, execFlags);
120 function startLockedApp(app) {
121 if (greeter.locked) {
122 greeter.lockedApp = app;
124 shell.activateApplication(app);
127 // This is a dummy image to detect if the custom AS set wallpaper loads successfully.
130 source: AccountsService.backgroundFile != undefined && AccountsService.backgroundFile.length > 0 ? AccountsService.backgroundFile : ""
138 id: backgroundSettings
139 objectName: "backgroundSettings"
140 schema.id: "org.gnome.desktop.background"
143 // This is a dummy image to detect if the custom GSettings set wallpaper loads successfully.
146 source: backgroundSettings.pictureUri != undefined && backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : ""
154 target: LauncherModel
155 property: "applicationManager"
156 value: ApplicationManager
159 Component.onCompleted: {
160 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
161 if (ApplicationManager.count > 0) {
162 ApplicationManager.focusApplication(ApplicationManager.get(0).appId);
164 finishStartUpTimer.start();
173 objectName: "dashCommunicator"
177 id: physicalKeysMapper
179 onPowerKeyLongPressed: dialogs.showPowerDialog()
180 onVolumeDownTriggered: volumeControl.volumeDown();
181 onVolumeUpTriggered: volumeControl.volumeUp();
182 onScreenshotTriggered: screenGrabber.capture();
188 enabled: Powerd.status === Powerd.On
192 target: ApplicationManager
193 property: "forceDashActive"
194 value: launcher.shown || launcher.dashSwipe
198 Keys.onPressed: physicalKeysMapper.onKeyPressed(event);
199 Keys.onReleased: physicalKeysMapper.onKeyReleased(event);
206 height: parent.height
207 visible: !ApplicationManager.empty
210 target: ApplicationManager
212 // This signal is also fired when we try to focus the current app
213 // again. We rely on this!
214 onFocusedApplicationIdChanged: {
215 var appId = ApplicationManager.focusedApplicationId;
217 if (tutorial.running && appId != "" && appId != "unity8-dash") {
218 // If this happens on first boot, we may be in edge
219 // tutorial or wizard while receiving a call. But a call
220 // is more important than wizard so just bail out of those.
225 if (appId === "dialer-app" && callManager.hasCalls && greeter.locked) {
226 // If we are in the middle of a call, make dialer lockedApp and show it.
227 // This can happen if user backs out of dialer back to greeter, then
228 // launches dialer again.
229 greeter.lockedApp = appId;
231 greeter.notifyAppFocused(appId);
233 panel.indicators.hide();
236 onApplicationAdded: {
242 id: applicationsDisplayLoader
243 objectName: "applicationsDisplayLoader"
246 // When we have a locked app, we only want to show that one app.
247 // FIXME: do this in a less traumatic way. We currently only allow
248 // locked apps in phone mode (see FIXME in Lockscreen component in
249 // this same file). When that changes, we need to do something
250 // nicer here. But this code is currently just to prevent a
251 // theoretical attack where user enters lockedApp mode, then makes
252 // the screen larger (maybe connects to monitor) and tries to enter
255 property string usageScenario: shell.usageScenario === "phone" || greeter.hasLockedApp
257 : shell.usageScenario
259 if (applicationsDisplayLoader.usageScenario === "phone") {
260 return "Stages/PhoneStage.qml";
261 } else if (applicationsDisplayLoader.usageScenario === "tablet") {
262 return "Stages/TabletStage.qml";
264 return "Stages/DesktopStage.qml";
268 property bool interactive: tutorial.spreadEnabled
270 && panel.indicators.fullyClosed
271 && launcher.progress == 0
272 && !notifications.useModal
274 onInteractiveChanged: { if (interactive) { focus = true; } }
277 target: applicationsDisplayLoader.item
278 property: "objectName"
282 target: applicationsDisplayLoader.item
283 property: "dragAreaWidth"
284 value: shell.edgeSize
287 target: applicationsDisplayLoader.item
288 property: "maximizedAppTopMargin"
289 // Not just using panel.panelHeight as that changes depending on the focused app.
290 value: panel.indicators.minimizedPanelHeight + units.dp(2) // dp(2) for orange line
293 target: applicationsDisplayLoader.item
294 property: "interactive"
295 value: applicationsDisplayLoader.interactive
298 target: applicationsDisplayLoader.item
299 property: "spreadEnabled"
300 value: tutorial.spreadEnabled && !greeter.hasLockedApp
303 target: applicationsDisplayLoader.item
304 property: "inverseProgress"
305 value: greeter.locked ? 0 : launcher.progress
308 target: applicationsDisplayLoader.item
309 property: "shellOrientationAngle"
310 value: shell.orientationAngle
313 target: applicationsDisplayLoader.item
314 property: "shellOrientation"
315 value: shell.orientation
318 target: applicationsDisplayLoader.item
319 property: "background"
320 value: shell.background
323 target: applicationsDisplayLoader.item
324 property: "shellPrimaryOrientation"
325 value: shell.primaryOrientation
328 target: applicationsDisplayLoader.item
329 property: "nativeOrientation"
330 value: shell.nativeOrientation
333 target: applicationsDisplayLoader.item
334 property: "nativeWidth"
335 value: shell.nativeWidth
338 target: applicationsDisplayLoader.item
339 property: "nativeHeight"
340 value: shell.nativeHeight
343 target: applicationsDisplayLoader.item
344 property: "beingResized"
345 value: shell.beingResized
352 objectName: "inputMethod"
353 anchors { fill: parent; topMargin: panel.panelHeight }
354 z: notifications.useModal || panel.indicators.shown || wizard.active ? overlay.z + 1 : overlay.z - 1
358 target: SurfaceManager
360 if (surface.type == MirSurfaceItem.InputMethod) {
361 inputMethod.surface = surface;
365 onSurfaceDestroyed: {
366 if (inputMethod.surface == surface) {
367 inputMethod.surface = null;
368 surface.parent = null;
370 if (!surface.parent) {
371 // there's no one displaying it. delete it right away
377 target: SessionManager
379 if (!session.parentSession && !session.application) {
380 // nothing is using it. delete it right away
388 objectName: "greeter"
390 hides: [launcher, panel.indicators]
391 tabletMode: shell.usageScenario !== "phone"
392 launcherOffset: launcher.progress
393 forcedUnlock: tutorial.running
394 background: shell.background
397 anchors.topMargin: panel.panelHeight
399 // avoid overlapping with Launcher's edge drag area
400 // FIXME: Fix TouchRegistry & friends and remove this workaround
401 // Issue involves launcher's DDA getting disabled on a long
403 dragHandleLeftMargin: launcher.available ? launcher.dragAreaWidth + 1 : 0
410 if (!tutorial.running) {
415 onEmergencyCall: startLockedApp("dialer-app")
418 // See powerConnection for why this is useful
419 id: showGreeterDelayed
427 target: ApplicationManager
428 property: "suspended"
438 if (greeter.locked && callManager.hasCalls && greeter.lockedApp !== "dialer-app") {
439 // We just received an incoming call while locked. The
440 // indicator will have already launched dialer-app for us, but
441 // there is a race between "hasCalls" changing and the dialer
442 // starting up. So in case we lose that race, we'll start/
443 // focus the dialer ourselves here too. Even if the indicator
444 // didn't launch the dialer for some reason (or maybe a call
445 // started via some other means), if an active call is
446 // happening, we want to be in the dialer.
447 startLockedApp("dialer-app")
457 if (Powerd.status === Powerd.Off && reason !== Powerd.Proximity &&
458 !callManager.hasCalls && !tutorial.running) {
459 // We don't want to simply call greeter.showNow() here, because
460 // that will take too long. Qt will delay button event
461 // handling until the greeter is done loading and may think the
462 // user held down the power button the whole time, leading to a
463 // power dialog being shown. Instead, delay showing the
464 // greeter until we've finished handling the event. We could
465 // make the greeter load asynchronously instead, but that
466 // introduces a whole host of timing issues, especially with
467 // its animations. So this is simpler.
468 showGreeterDelayed.start();
473 function showHome() {
474 if (tutorial.running) {
478 greeter.notifyAboutToFocusApp("unity8-dash");
480 var animate = !LightDM.Greeter.active && !stages.shown
481 dash.setCurrentScope(0, animate, false)
482 ApplicationManager.requestFocusApplication("unity8-dash")
485 function showDash() {
486 if (greeter.notifyShowingDashFromDrag()) {
490 if (!greeter.locked && ApplicationManager.focusedApplicationId != "unity8-dash") {
491 ApplicationManager.requestFocusApplication("unity8-dash")
505 anchors.fill: parent //because this draws indicator menus
508 available: tutorial.panelEnabled
509 && (!greeter.locked || AccountsService.enableIndicatorsWhileLocked)
510 && !greeter.hasLockedApp
511 contentEnabled: tutorial.panelContentEnabled
512 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
514 minimizedPanelHeight: units.gu(3)
515 expandedPanelHeight: units.gu(7)
517 indicatorsModel: Indicators.IndicatorsModel {
518 // tablet and phone both use the same profile
519 profile: shell.usageScenario === "desktop" ? "desktop" : "phone"
520 Component.onCompleted: load();
525 greeterShown: greeter.shown
528 property bool mainAppIsFullscreen: shell.mainApp && shell.mainApp.fullscreen
529 fullscreenMode: (mainAppIsFullscreen && !LightDM.Greeter.active && launcher.progress == 0)
530 || greeter.hasLockedApp
535 objectName: "launcher"
537 readonly property bool dashSwipe: progress > 0
539 anchors.top: parent.top
540 anchors.topMargin: inverted ? 0 : panel.panelHeight
541 anchors.bottom: parent.bottom
543 dragAreaWidth: shell.edgeSize
544 available: tutorial.launcherEnabled
545 && (!greeter.locked || AccountsService.enableLauncherWhileLocked)
546 && !greeter.hasLockedApp
547 inverted: shell.usageScenario !== "desktop"
548 shadeBackground: !tutorial.running
550 onShowDashHome: showHome()
552 onDashSwipeChanged: {
554 dash.setCurrentScope(0, false, true)
557 onLauncherApplicationSelected: {
558 if (!tutorial.running) {
559 greeter.notifyAboutToFocusApp(appId);
560 shell.activateApplication(appId)
565 panel.indicators.hide()
574 background: shell.background
576 function unlockWhenDoneWithWizard() {
578 Connectivity.unlockAllModems();
582 Component.onCompleted: unlockWhenDoneWithWizard()
583 onActiveChanged: unlockWhenDoneWithWizard()
587 id: modalNotificationBackground
589 visible: notifications.useModal
602 model: NotificationBackend.Model
605 y: topmostIsFullscreen ? 0 : panel.panelHeight
606 height: parent.height - (topmostIsFullscreen ? 0 : panel.panelHeight)
611 when: overlay.width <= units.gu(60)
613 target: notifications
614 anchors.left: parent.left
615 anchors.right: parent.right
620 when: overlay.width > units.gu(60)
622 target: notifications
623 anchors.left: undefined
624 anchors.right: parent.right
626 PropertyChanges { target: notifications; width: units.gu(38) }
634 objectName: "dialogs"
638 shutdownFadeOutRectangle.enabled = true;
639 shutdownFadeOutRectangle.visible = true;
640 shutdownFadeOut.start();
646 objectName: "tutorial"
647 active: AccountsService.demoEdges
648 paused: LightDM.Greeter.active
653 edgeSize: shell.edgeSize
656 AccountsService.demoEdges = false;
657 active = false; // for immediate response / if AS is having problems
662 target: SessionBroadcast
663 onShowHome: showHome()
667 id: shutdownFadeOutRectangle
668 z: screenGrabber.z + 10
674 NumberAnimation on opacity {
679 if (shutdownFadeOutRectangle.enabled && shutdownFadeOutRectangle.visible) {
680 DBusUnitySessionService.Shutdown();
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