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 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 // Disable everything while greeter is waiting, so that the user can't swipe
49 // the greeter or launcher until we know whether the session is locked.
50 enabled: !greeter.waiting
52 // this is only here to select the width / height of the window if not running fullscreen
53 property bool tablet: false
54 width: tablet ? units.gu(160) : applicationArguments.hasGeometry() ? applicationArguments.width() : units.gu(40)
55 height: tablet ? units.gu(100) : applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(71)
57 property real edgeSize: units.gu(2)
58 property url defaultBackground: Qt.resolvedUrl(shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg")
59 property url background: asImageTester.status == Image.Ready ? asImageTester.source
60 : gsImageTester.status == Image.Ready ? gsImageTester.source : defaultBackground
62 property bool sideStageEnabled: shell.width >= units.gu(100)
63 readonly property string focusedApplicationId: ApplicationManager.focusedApplicationId
65 property int orientation
66 readonly property int deviceOrientationAngle: Screen.angleBetween(Screen.primaryOrientation, Screen.orientation)
67 onDeviceOrientationAngleChanged: {
68 if (!OrientationLock.enabled) {
69 orientation = Screen.orientation;
72 readonly property bool orientationLockEnabled: OrientationLock.enabled
73 onOrientationLockEnabledChanged: {
74 if (orientationLockEnabled) {
75 OrientationLock.savedOrientation = Screen.orientation;
77 orientation = Screen.orientation;
81 // This is _only_ used to expose the property to autopilot tests
82 readonly property string testShellMode: shellMode
84 function activateApplication(appId) {
85 if (ApplicationManager.findApplication(appId)) {
86 ApplicationManager.requestFocusApplication(appId);
88 var execFlags = shell.sideStageEnabled ? ApplicationManager.NoFlag : ApplicationManager.ForceMainStage;
89 ApplicationManager.startApplication(appId, execFlags);
93 function startLockedApp(app) {
95 greeter.lockedApp = app;
97 shell.activateApplication(app);
100 // This is a dummy image to detect if the custom AS set wallpaper loads successfully.
103 source: AccountsService.backgroundFile != undefined && AccountsService.backgroundFile.length > 0 ? AccountsService.backgroundFile : ""
111 id: backgroundSettings
112 schema.id: "org.gnome.desktop.background"
115 // This is a dummy image to detect if the custom GSettings set wallpaper loads successfully.
118 source: backgroundSettings.pictureUri != undefined && backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : ""
126 id: usageModeSettings
127 schema.id: "com.canonical.Unity8"
131 target: LauncherModel
132 property: "applicationManager"
133 value: ApplicationManager
136 Component.onCompleted: {
137 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
138 if (ApplicationManager.count > 0) {
139 ApplicationManager.focusApplication(ApplicationManager.get(0).appId);
141 if (orientationLockEnabled) {
142 orientation = OrientationLock.savedOrientation;
152 objectName: "dashCommunicator"
156 id: physicalKeysMapper
158 onPowerKeyLongPressed: dialogs.showPowerDialog()
159 onVolumeDownTriggered: volumeControl.volumeDown();
160 onVolumeUpTriggered: volumeControl.volumeUp();
161 onScreenshotTriggered: screenGrabber.capture();
167 enabled: Powerd.status === Powerd.On
171 target: ApplicationManager
172 property: "forceDashActive"
173 value: launcher.shown || launcher.dashSwipe
177 Keys.onPressed: physicalKeysMapper.onKeyPressed(event);
178 Keys.onReleased: physicalKeysMapper.onKeyReleased(event);
182 onActivated: { launcher.fadeOut(); shell.showHome(); }
189 height: parent.height
192 target: ApplicationManager
194 // This signal is also fired when we try to focus the current app
195 // again. We rely on this!
196 onFocusedApplicationIdChanged: {
197 var appId = ApplicationManager.focusedApplicationId;
199 if (tutorial.running && appId != "" && appId != "unity8-dash") {
200 // If this happens on first boot, we may be in edge
201 // tutorial or wizard while receiving a call. But a call
202 // is more important than wizard so just bail out of those.
207 if (appId === "dialer-app" && callManager.hasCalls && greeter.locked) {
208 // If we are in the middle of a call, make dialer lockedApp and show it.
209 // This can happen if user backs out of dialer back to greeter, then
210 // launches dialer again.
211 greeter.lockedApp = appId;
213 greeter.notifyAppFocused(appId);
215 panel.indicators.hide();
218 onApplicationAdded: {
224 id: applicationsDisplayLoader
225 objectName: "applicationsDisplayLoader"
228 // When we have a locked app, we only want to show that one app.
229 // FIXME: do this in a less traumatic way. We currently only allow
230 // locked apps in phone mode (see FIXME in Lockscreen component in
231 // this same file). When that changes, we need to do something
232 // nicer here. But this code is currently just to prevent a
233 // theoretical attack where user enters lockedApp mode, then makes
234 // the screen larger (maybe connects to monitor) and tries to enter
236 property bool tabletMode: shell.sideStageEnabled && !greeter.hasLockedApp
237 source: usageModeSettings.usageMode === "Windowed" ? "Stages/DesktopStage.qml"
238 : tabletMode ? "Stages/TabletStage.qml" : "Stages/PhoneStage.qml"
240 property bool interactive: tutorial.spreadEnabled
242 && panel.indicators.fullyClosed
243 && launcher.progress == 0
244 && !notifications.useModal
246 onInteractiveChanged: { if (interactive) { focus = true; } }
249 target: applicationsDisplayLoader.item
250 property: "objectName"
254 target: applicationsDisplayLoader.item
255 property: "dragAreaWidth"
256 value: shell.edgeSize
259 target: applicationsDisplayLoader.item
260 property: "maximizedAppTopMargin"
261 // Not just using panel.panelHeight as that changes depending on the focused app.
262 value: panel.indicators.minimizedPanelHeight + units.dp(2) // dp(2) for orange line
265 target: applicationsDisplayLoader.item
266 property: "interactive"
267 value: applicationsDisplayLoader.interactive
270 target: applicationsDisplayLoader.item
271 property: "spreadEnabled"
272 value: tutorial.spreadEnabled && !greeter.hasLockedApp
275 target: applicationsDisplayLoader.item
276 property: "inverseProgress"
277 value: greeter.locked ? 0 : launcher.progress
280 target: applicationsDisplayLoader.item
281 property: "orientation"
282 value: shell.orientation
285 target: applicationsDisplayLoader.item
286 property: "background"
287 value: shell.background
293 objectName: "tutorial"
295 active: AccountsService.demoEdges
296 paused: LightDM.Greeter.active
299 edgeSize: shell.edgeSize
301 // EdgeDragAreas don't work with mice. So to avoid trapping the user,
302 // we'll tell the tutorial to avoid using them on the Desktop. The
303 // Desktop doesn't use the same spread design anyway. The tutorial is
304 // all a bit of a placeholder on non-phone form factors right now.
305 // When the design team gives us more guidance, we can do something
307 // TODO: use DeviceConfiguration instead of checking source
308 useEdgeDragArea: applicationsDisplayLoader.source != Qt.resolvedUrl("Stages/DesktopStage.qml")
311 AccountsService.demoEdges = false;
312 active = false; // for immediate response / if AS is having problems
319 objectName: "inputMethod"
320 anchors { fill: parent; topMargin: panel.panelHeight }
321 z: notifications.useModal || panel.indicators.shown || wizard.active ? overlay.z + 1 : overlay.z - 1
325 target: SurfaceManager
327 if (surface.type == MirSurfaceItem.InputMethod) {
328 inputMethod.surface = surface;
332 onSurfaceDestroyed: {
333 if (inputMethod.surface == surface) {
334 inputMethod.surface = null;
335 surface.parent = null;
337 if (!surface.parent) {
338 // there's no one displaying it. delete it right away
344 target: SessionManager
346 if (!session.parentSession && !session.application) {
347 // nothing is using it. delete it right away
355 objectName: "greeter"
357 hides: [launcher, panel.indicators]
358 tabletMode: shell.sideStageEnabled
359 launcherOffset: launcher.progress
360 forcedUnlock: tutorial.running
361 background: shell.background
364 anchors.topMargin: panel.panelHeight
366 // avoid overlapping with Launcher's edge drag area
367 // FIXME: Fix TouchRegistry & friends and remove this workaround
368 // Issue involves launcher's DDA getting disabled on a long
370 dragHandleLeftMargin: launcher.available ? launcher.dragAreaWidth + 1 : 0
377 if (!tutorial.running) {
382 onEmergencyCall: startLockedApp("dialer-app")
385 // See powerConnection for why this is useful
386 id: showGreeterDelayed
394 target: ApplicationManager
395 property: "suspended"
405 if (greeter.locked && callManager.hasCalls && greeter.lockedApp !== "dialer-app") {
406 // We just received an incoming call while locked. The
407 // indicator will have already launched dialer-app for us, but
408 // there is a race between "hasCalls" changing and the dialer
409 // starting up. So in case we lose that race, we'll start/
410 // focus the dialer ourselves here too. Even if the indicator
411 // didn't launch the dialer for some reason (or maybe a call
412 // started via some other means), if an active call is
413 // happening, we want to be in the dialer.
414 startLockedApp("dialer-app")
424 if (Powerd.status === Powerd.Off && reason !== Powerd.Proximity &&
425 !callManager.hasCalls && !tutorial.running) {
426 // We don't want to simply call greeter.showNow() here, because
427 // that will take too long. Qt will delay button event
428 // handling until the greeter is done loading and may think the
429 // user held down the power button the whole time, leading to a
430 // power dialog being shown. Instead, delay showing the
431 // greeter until we've finished handling the event. We could
432 // make the greeter load asynchronously instead, but that
433 // introduces a whole host of timing issues, especially with
434 // its animations. So this is simpler.
435 showGreeterDelayed.start();
440 function showHome() {
441 if (tutorial.running) {
445 greeter.notifyAboutToFocusApp("unity8-dash");
447 var animate = !LightDM.Greeter.active && !stages.shown
448 dash.setCurrentScope(0, animate, false)
449 ApplicationManager.requestFocusApplication("unity8-dash")
452 function showDash() {
453 if (greeter.notifyShowingDashFromDrag()) {
457 if (!greeter.locked && ApplicationManager.focusedApplicationId != "unity8-dash") {
458 ApplicationManager.requestFocusApplication("unity8-dash")
472 anchors.fill: parent //because this draws indicator menus
475 available: tutorial.panelEnabled
476 && (!greeter.locked || AccountsService.enableIndicatorsWhileLocked)
477 && !greeter.hasLockedApp
478 contentEnabled: tutorial.panelContentEnabled
479 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
481 minimizedPanelHeight: units.gu(3)
482 expandedPanelHeight: units.gu(7)
484 indicatorsModel: Indicators.IndicatorsModel {
485 // TODO: This should be sourced by device type (e.g. "desktop", "tablet", "phone"...)
486 profile: indicatorProfile
487 Component.onCompleted: load()
491 greeterShown: greeter.shown
494 property bool topmostApplicationIsFullscreen:
495 ApplicationManager.focusedApplicationId &&
496 ApplicationManager.findApplication(ApplicationManager.focusedApplicationId).fullscreen
498 fullscreenMode: (topmostApplicationIsFullscreen && !LightDM.Greeter.active && launcher.progress == 0)
499 || greeter.hasLockedApp
504 objectName: "launcher"
506 readonly property bool dashSwipe: progress > 0
508 anchors.top: parent.top
509 anchors.topMargin: inverted ? 0 : panel.panelHeight
510 anchors.bottom: parent.bottom
512 dragAreaWidth: shell.edgeSize
513 available: tutorial.launcherEnabled
514 && (!greeter.locked || AccountsService.enableLauncherWhileLocked)
515 && !greeter.hasLockedApp
516 inverted: usageModeSettings.usageMode === "Staged"
517 shadeBackground: !tutorial.running
519 onShowDashHome: showHome()
521 onDashSwipeChanged: {
523 dash.setCurrentScope(0, false, true)
526 onLauncherApplicationSelected: {
527 if (!tutorial.running) {
528 greeter.notifyAboutToFocusApp(appId);
529 shell.activateApplication(appId)
534 panel.indicators.hide()
543 background: shell.background
545 function unlockWhenDoneWithWizard() {
547 Connectivity.unlockAllModems();
551 Component.onCompleted: unlockWhenDoneWithWizard()
552 onActiveChanged: unlockWhenDoneWithWizard()
556 id: modalNotificationBackground
558 visible: notifications.useModal && (notifications.state == "narrow")
571 model: NotificationBackend.Model
574 y: topmostIsFullscreen ? 0 : panel.panelHeight
575 height: parent.height - (topmostIsFullscreen ? 0 : panel.panelHeight)
580 when: overlay.width <= units.gu(60)
582 target: notifications
583 anchors.left: parent.left
584 anchors.right: parent.right
589 when: overlay.width > units.gu(60)
591 target: notifications
592 anchors.left: undefined
593 anchors.right: parent.right
595 PropertyChanges { target: notifications; width: units.gu(38) }
606 shutdownFadeOutRectangle.enabled = true;
607 shutdownFadeOutRectangle.visible = true;
608 shutdownFadeOut.start();
613 target: SessionBroadcast
614 onShowHome: showHome()
618 id: shutdownFadeOutRectangle
619 z: screenGrabber.z + 10
625 NumberAnimation on opacity {
630 if (shutdownFadeOutRectangle.enabled && shutdownFadeOutRectangle.visible) {
631 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