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 property string mode: "full-greeter"
59 function updateFocusedAppOrientation() {
60 applicationsDisplayLoader.item.updateFocusedAppOrientation();
62 function updateFocusedAppOrientationAnimated() {
63 applicationsDisplayLoader.item.updateFocusedAppOrientationAnimated();
66 // to be read from outside
67 readonly property int mainAppWindowOrientationAngle:
68 applicationsDisplayLoader.item ? applicationsDisplayLoader.item.mainAppWindowOrientationAngle : 0
70 readonly property bool orientationChangesEnabled: panel.indicators.fullyClosed
71 && (applicationsDisplayLoader.item && applicationsDisplayLoader.item.orientationChangesEnabled)
72 && (!greeter || !greeter.animating)
74 readonly property bool showingGreeter: greeter && greeter.shown
76 property bool startingUp: true
77 Timer { id: finishStartUpTimer; interval: 500; onTriggered: startingUp = false }
79 property int supportedOrientations: {
81 // Ensure we don't rotate during start up
82 return Qt.PrimaryOrientation;
83 } else if (greeter && greeter.shown) {
84 return Qt.PrimaryOrientation;
86 return mainApp.supportedOrientations;
89 return Qt.PortraitOrientation
90 | Qt.LandscapeOrientation
91 | Qt.InvertedPortraitOrientation
92 | Qt.InvertedLandscapeOrientation;
96 // For autopilot consumption
97 readonly property string focusedApplicationId: ApplicationManager.focusedApplicationId
99 // internal props from here onwards
100 readonly property var mainApp:
101 applicationsDisplayLoader.item ? applicationsDisplayLoader.item.mainApp : null
103 // Disable everything while greeter is waiting, so that the user can't swipe
104 // the greeter or launcher until we know whether the session is locked.
105 enabled: greeter && !greeter.waiting
107 property real edgeSize: units.gu(2)
108 property url defaultBackground: Qt.resolvedUrl(shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg")
109 property url background: asImageTester.status == Image.Ready ? asImageTester.source
110 : gsImageTester.status == Image.Ready ? gsImageTester.source : defaultBackground
112 readonly property alias greeter: greeterLoader.item
114 function activateApplication(appId) {
115 if (ApplicationManager.findApplication(appId)) {
116 ApplicationManager.requestFocusApplication(appId);
118 var execFlags = shell.usageScenario === "phone" ? ApplicationManager.ForceMainStage
119 : ApplicationManager.NoFlag;
120 ApplicationManager.startApplication(appId, execFlags);
124 function startLockedApp(app) {
125 if (greeter.locked) {
126 greeter.lockedApp = app;
128 shell.activateApplication(app);
131 // This is a dummy image to detect if the custom AS set wallpaper loads successfully.
134 source: AccountsService.backgroundFile != undefined && AccountsService.backgroundFile.length > 0 ? AccountsService.backgroundFile : ""
142 id: backgroundSettings
143 schema.id: "org.gnome.desktop.background"
146 // This is a dummy image to detect if the custom GSettings set wallpaper loads successfully.
149 source: backgroundSettings.pictureUri != undefined && backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : ""
157 target: LauncherModel
158 property: "applicationManager"
159 value: ApplicationManager
162 Component.onCompleted: {
163 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
164 if (ApplicationManager.count > 0) {
165 ApplicationManager.focusApplication(ApplicationManager.get(0).appId);
167 finishStartUpTimer.start();
176 objectName: "dashCommunicator"
180 id: physicalKeysMapper
182 onPowerKeyLongPressed: dialogs.showPowerDialog()
183 onVolumeDownTriggered: volumeControl.volumeDown();
184 onVolumeUpTriggered: volumeControl.volumeUp();
185 onScreenshotTriggered: screenGrabber.capture();
191 enabled: Powerd.status === Powerd.On
195 Keys.onPressed: physicalKeysMapper.onKeyPressed(event);
196 Keys.onReleased: physicalKeysMapper.onKeyReleased(event);
200 onActivated: { launcher.fadeOut(); shell.showHome(); }
207 height: parent.height
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(shell.mode === "greeter") {
260 return "Stages/ShimStage.qml"
261 } else if (applicationsDisplayLoader.usageScenario === "phone") {
262 return "Stages/PhoneStage.qml";
263 } else if (applicationsDisplayLoader.usageScenario === "tablet") {
264 return "Stages/TabletStage.qml";
266 return "Stages/DesktopStage.qml";
270 property bool interactive: tutorial.spreadEnabled
271 && (!greeter || !greeter.shown)
272 && panel.indicators.fullyClosed
273 && launcher.progress == 0
274 && !notifications.useModal
276 onInteractiveChanged: { if (interactive) { focus = true; } }
279 target: applicationsDisplayLoader.item
280 property: "objectName"
284 target: applicationsDisplayLoader.item
285 property: "dragAreaWidth"
286 value: shell.edgeSize
289 target: applicationsDisplayLoader.item
290 property: "maximizedAppTopMargin"
291 // Not just using panel.panelHeight as that changes depending on the focused app.
292 value: panel.indicators.minimizedPanelHeight + units.dp(2) // dp(2) for orange line
295 target: applicationsDisplayLoader.item
296 property: "interactive"
297 value: applicationsDisplayLoader.interactive
300 target: applicationsDisplayLoader.item
301 property: "spreadEnabled"
302 value: tutorial.spreadEnabled && (!greeter || (!greeter.hasLockedApp && !greeter.shown))
305 target: applicationsDisplayLoader.item
306 property: "inverseProgress"
307 value: greeter && greeter.locked ? 0 : launcher.progress
310 target: applicationsDisplayLoader.item
311 property: "shellOrientationAngle"
312 value: shell.orientationAngle
315 target: applicationsDisplayLoader.item
316 property: "shellOrientation"
317 value: shell.orientation
320 target: applicationsDisplayLoader.item
321 property: "background"
322 value: shell.background
325 target: applicationsDisplayLoader.item
326 property: "shellPrimaryOrientation"
327 value: shell.primaryOrientation
330 target: applicationsDisplayLoader.item
331 property: "nativeOrientation"
332 value: shell.nativeOrientation
335 target: applicationsDisplayLoader.item
336 property: "nativeWidth"
337 value: shell.nativeWidth
340 target: applicationsDisplayLoader.item
341 property: "nativeHeight"
342 value: shell.nativeHeight
345 target: applicationsDisplayLoader.item
346 property: "beingResized"
347 value: shell.beingResized
350 target: applicationsDisplayLoader.item
351 property: "keepDashRunning"
352 value: launcher.shown || launcher.dashSwipe
355 target: applicationsDisplayLoader.item
356 property: "suspended"
363 objectName: "tutorial"
365 active: AccountsService.demoEdges
366 paused: LightDM.Greeter.active
369 edgeSize: shell.edgeSize
371 // EdgeDragAreas don't work with mice. So to avoid trapping the user,
372 // we'll tell the tutorial to avoid using them on the Desktop. The
373 // Desktop doesn't use the same spread design anyway. The tutorial is
374 // all a bit of a placeholder on non-phone form factors right now.
375 // When the design team gives us more guidance, we can do something
377 // TODO: use DeviceConfiguration instead of checking source
378 useEdgeDragArea: applicationsDisplayLoader.source != Qt.resolvedUrl("Stages/DesktopStage.qml")
381 AccountsService.demoEdges = false;
382 active = false; // for immediate response / if AS is having problems
389 objectName: "inputMethod"
390 anchors { fill: parent; topMargin: panel.panelHeight }
391 z: notifications.useModal || panel.indicators.shown || wizard.active ? overlay.z + 1 : overlay.z - 1
395 target: SurfaceManager
397 if (surface.type == MirSurfaceItem.InputMethod) {
398 inputMethod.surface = surface;
402 onSurfaceDestroyed: {
403 if (inputMethod.surface == surface) {
404 inputMethod.surface = null;
405 surface.parent = null;
407 if (!surface.parent) {
408 // there's no one displaying it. delete it right away
414 target: SessionManager
416 if (!session.parentSession && !session.application) {
417 // nothing is using it. delete it right away
426 anchors.topMargin: panel.panelHeight
427 sourceComponent: shell.mode != "shell" ? integratedGreeter :
428 Qt.createComponent(Qt.resolvedUrl("Greeter/ShimGreeter.qml"));
430 item.objectName = "greeter"
435 id: integratedGreeter
438 hides: [launcher, panel.indicators]
439 tabletMode: shell.usageScenario != "phone"
440 launcherOffset: launcher.progress
441 forcedUnlock: tutorial.running
442 background: shell.background
444 // avoid overlapping with Launcher's edge drag area
445 // FIXME: Fix TouchRegistry & friends and remove this workaround
446 // Issue involves launcher's DDA getting disabled on a long
448 dragHandleLeftMargin: launcher.available ? launcher.dragAreaWidth + 1 : 0
455 if (!tutorial.running) {
460 onEmergencyCall: startLockedApp("dialer-app")
465 // See powerConnection for why this is useful
466 id: showGreeterDelayed
478 if (greeter.locked && callManager.hasCalls && greeter.lockedApp !== "dialer-app") {
479 // We just received an incoming call while locked. The
480 // indicator will have already launched dialer-app for us, but
481 // there is a race between "hasCalls" changing and the dialer
482 // starting up. So in case we lose that race, we'll start/
483 // focus the dialer ourselves here too. Even if the indicator
484 // didn't launch the dialer for some reason (or maybe a call
485 // started via some other means), if an active call is
486 // happening, we want to be in the dialer.
487 startLockedApp("dialer-app")
497 if (Powerd.status === Powerd.Off && reason !== Powerd.Proximity &&
498 !callManager.hasCalls && !tutorial.running) {
499 // We don't want to simply call greeter.showNow() here, because
500 // that will take too long. Qt will delay button event
501 // handling until the greeter is done loading and may think the
502 // user held down the power button the whole time, leading to a
503 // power dialog being shown. Instead, delay showing the
504 // greeter until we've finished handling the event. We could
505 // make the greeter load asynchronously instead, but that
506 // introduces a whole host of timing issues, especially with
507 // its animations. So this is simpler.
508 showGreeterDelayed.start();
513 function showHome() {
514 if (tutorial.running) {
518 greeter.notifyAboutToFocusApp("unity8-dash");
520 var animate = !LightDM.Greeter.active && !stages.shown
521 dash.setCurrentScope(0, animate, false)
522 ApplicationManager.requestFocusApplication("unity8-dash")
525 function showDash() {
526 if (greeter.notifyShowingDashFromDrag()) {
530 if (!greeter.locked && ApplicationManager.focusedApplicationId != "unity8-dash") {
531 ApplicationManager.requestFocusApplication("unity8-dash")
545 anchors.fill: parent //because this draws indicator menus
548 available: tutorial.panelEnabled
549 && ((!greeter || !greeter.locked) || AccountsService.enableIndicatorsWhileLocked)
550 && (!greeter || !greeter.hasLockedApp)
551 contentEnabled: tutorial.panelContentEnabled
552 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
554 minimizedPanelHeight: units.gu(3)
555 expandedPanelHeight: units.gu(7)
557 indicatorsModel: Indicators.IndicatorsModel {
558 // tablet and phone both use the same profile
559 profile: shell.usageScenario === "desktop" ? "desktop" : "phone"
560 Component.onCompleted: load();
565 greeterShown: greeter.shown
568 property bool mainAppIsFullscreen: shell.mainApp && shell.mainApp.fullscreen
569 fullscreenMode: (mainAppIsFullscreen && !LightDM.Greeter.active && launcher.progress == 0)
570 || greeter.hasLockedApp
575 objectName: "launcher"
577 readonly property bool dashSwipe: progress > 0
579 anchors.top: parent.top
580 anchors.topMargin: inverted ? 0 : panel.panelHeight
581 anchors.bottom: parent.bottom
583 dragAreaWidth: shell.edgeSize
584 available: tutorial.launcherEnabled
585 && (!greeter.locked || AccountsService.enableLauncherWhileLocked)
586 && !greeter.hasLockedApp
587 inverted: shell.usageScenario !== "desktop"
588 shadeBackground: !tutorial.running
590 onShowDashHome: showHome()
592 onDashSwipeChanged: {
594 dash.setCurrentScope(0, false, true)
597 onLauncherApplicationSelected: {
598 if (!tutorial.running) {
599 greeter.notifyAboutToFocusApp(appId);
600 shell.activateApplication(appId)
605 panel.indicators.hide()
614 background: shell.background
616 function unlockWhenDoneWithWizard() {
618 Connectivity.unlockAllModems();
622 Component.onCompleted: unlockWhenDoneWithWizard()
623 onActiveChanged: unlockWhenDoneWithWizard()
627 id: modalNotificationBackground
629 visible: notifications.useModal
642 model: NotificationBackend.Model
645 y: topmostIsFullscreen ? 0 : panel.panelHeight
646 height: parent.height - (topmostIsFullscreen ? 0 : panel.panelHeight)
651 when: overlay.width <= units.gu(60)
653 target: notifications
654 anchors.left: parent.left
655 anchors.right: parent.right
660 when: overlay.width > units.gu(60)
662 target: notifications
663 anchors.left: undefined
664 anchors.right: parent.right
666 PropertyChanges { target: notifications; width: units.gu(38) }
674 objectName: "dialogs"
678 shutdownFadeOutRectangle.enabled = true;
679 shutdownFadeOutRectangle.visible = true;
680 shutdownFadeOut.start();
685 target: SessionBroadcast
686 onShowHome: showHome()
690 id: shutdownFadeOutRectangle
691 z: screenGrabber.z + 10
697 NumberAnimation on opacity {
702 if (shutdownFadeOutRectangle.enabled && shutdownFadeOutRectangle.visible) {
703 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