2 * Copyright (C) 2013-2016 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.2
19import AccountsService 0.1
20import Unity.Application 0.1
21import Ubuntu.Components 1.3
22import Ubuntu.Components.Popups 1.3
23import Ubuntu.Gestures 0.1
24import Ubuntu.Telephony 0.1 as Telephony
25import Unity.Connectivity 0.1
26import Unity.Launcher 0.1
27import GlobalShortcut 1.0 // has to be before Utils, because of WindowKeysFilter
30import SessionBroadcast 0.1
39import Unity.Notifications 1.0 as NotificationBackend
40import Unity.Session 0.1
41import Unity.DashCommunicator 0.1
42import Unity.Indicators 0.1 as Indicators
49 // to be set from outside
50 property int orientationAngle: 0
51 property int orientation
52 property Orientations orientations
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 property alias oskEnabled: inputMethod.enabled
60 function updateFocusedAppOrientation() {
61 applicationsDisplayLoader.item.updateFocusedAppOrientation();
63 function updateFocusedAppOrientationAnimated() {
64 applicationsDisplayLoader.item.updateFocusedAppOrientationAnimated();
66 property bool hasMouse: false
68 // to be read from outside
69 readonly property int mainAppWindowOrientationAngle:
70 applicationsDisplayLoader.item ? applicationsDisplayLoader.item.mainAppWindowOrientationAngle : 0
72 readonly property bool orientationChangesEnabled: panel.indicators.fullyClosed
73 && (applicationsDisplayLoader.item && applicationsDisplayLoader.item.orientationChangesEnabled)
74 && (!greeter || !greeter.animating)
76 readonly property bool showingGreeter: greeter && greeter.shown
78 property bool startingUp: true
79 Timer { id: finishStartUpTimer; interval: 500; onTriggered: startingUp = false }
81 property int supportedOrientations: {
83 // Ensure we don't rotate during start up
84 return Qt.PrimaryOrientation;
85 } else if (greeter && greeter.shown) {
86 return Qt.PrimaryOrientation;
87 } else if (applicationsDisplayLoader.item) {
88 return shell.orientations.map(applicationsDisplayLoader.item.supportedOrientations);
91 return Qt.PortraitOrientation
92 | Qt.LandscapeOrientation
93 | Qt.InvertedPortraitOrientation
94 | Qt.InvertedLandscapeOrientation;
98 // For autopilot consumption
99 readonly property string focusedApplicationId: ApplicationManager.focusedApplicationId
101 // internal props from here onwards
102 readonly property var mainApp:
103 applicationsDisplayLoader.item ? applicationsDisplayLoader.item.mainApp : null
105 // Disable everything while greeter is waiting, so that the user can't swipe
106 // the greeter or launcher until we know whether the session is locked.
107 enabled: greeter && !greeter.waiting
109 property real edgeSize: units.gu(2)
112 id: wallpaperResolver
116 readonly property alias greeter: greeterLoader.item
118 function activateApplication(appId) {
119 if (ApplicationManager.findApplication(appId)) {
120 ApplicationManager.requestFocusApplication(appId);
122 var execFlags = shell.usageScenario === "phone" ? ApplicationManager.ForceMainStage
123 : ApplicationManager.NoFlag;
124 ApplicationManager.startApplication(appId, execFlags);
128 function startLockedApp(app) {
129 if (greeter.locked) {
130 greeter.lockedApp = app;
132 shell.activateApplication(app);
136 target: LauncherModel
137 property: "applicationManager"
138 value: ApplicationManager
141 Component.onCompleted: {
142 theme.name = "Ubuntu.Components.Themes.SuruGradient"
143 if (ApplicationManager.count > 0) {
144 ApplicationManager.focusApplication(ApplicationManager.get(0).appId);
146 finishStartUpTimer.start();
149 LightDM{id: lightDM} // Provide backend access
152 indicators: panel.indicators
157 objectName: "dashCommunicator"
161 id: physicalKeysMapper
162 objectName: "physicalKeysMapper"
164 onPowerKeyLongPressed: dialogs.showPowerDialog();
165 onVolumeDownTriggered: volumeControl.volumeDown();
166 onVolumeUpTriggered: volumeControl.volumeUp();
167 onScreenshotTriggered: screenGrabber.capture();
171 // dummy shortcut to force creation of GlobalShortcutRegistry before WindowKeyFilter
175 Keys.onPressed: physicalKeysMapper.onKeyPressed(event, currentEventTimestamp);
176 Keys.onReleased: physicalKeysMapper.onKeyReleased(event, currentEventTimestamp);
180 onHomeKeyActivated: { launcher.fadeOut(); shell.showHome(); }
181 onTouchBegun: { cursor.opacity = 0; }
183 // move the (hidden) cursor to the last known touch position
184 var mappedCoords = mapFromItem(null, pos.x, pos.y);
185 cursor.x = mappedCoords.x;
186 cursor.y = mappedCoords.y;
194 height: parent.height
197 target: ApplicationManager
199 // This signal is also fired when we try to focus the current app
200 // again. We rely on this!
201 onFocusedApplicationIdChanged: {
202 var appId = ApplicationManager.focusedApplicationId;
204 if (tutorial.running && appId != "" && appId != "unity8-dash") {
205 // If this happens on first boot, we may be in edge
206 // tutorial or wizard while receiving a call. But a call
207 // is more important than wizard so just bail out of those.
212 if (appId === "dialer-app" && callManager.hasCalls && greeter.locked) {
213 // If we are in the middle of a call, make dialer lockedApp and show it.
214 // This can happen if user backs out of dialer back to greeter, then
215 // launches dialer again.
216 greeter.lockedApp = appId;
218 greeter.notifyAppFocused(appId);
220 panel.indicators.hide();
223 onApplicationAdded: {
229 id: applicationsDisplayLoader
230 objectName: "applicationsDisplayLoader"
233 // When we have a locked app, we only want to show that one app.
234 // FIXME: do this in a less traumatic way. We currently only allow
235 // locked apps in phone mode (see FIXME in Lockscreen component in
236 // this same file). When that changes, we need to do something
237 // nicer here. But this code is currently just to prevent a
238 // theoretical attack where user enters lockedApp mode, then makes
239 // the screen larger (maybe connects to monitor) and tries to enter
242 property string usageScenario: shell.usageScenario === "phone" || greeter.hasLockedApp
244 : shell.usageScenario
246 if(shell.mode === "greeter") {
247 return "Stages/ShimStage.qml"
248 } else if (applicationsDisplayLoader.usageScenario === "phone") {
249 return "Stages/PhoneStage.qml";
250 } else if (applicationsDisplayLoader.usageScenario === "tablet") {
251 return "Stages/TabletStage.qml";
253 return "Stages/DesktopStage.qml";
257 property bool interactive: tutorial.spreadEnabled
258 && (!greeter || !greeter.shown)
259 && panel.indicators.fullyClosed
260 && launcher.progress == 0
261 && !notifications.useModal
263 onInteractiveChanged: { if (interactive) { focus = true; } }
266 target: applicationsDisplayLoader.item
267 property: "objectName"
271 target: applicationsDisplayLoader.item
272 property: "dragAreaWidth"
273 value: shell.edgeSize
276 target: applicationsDisplayLoader.item
277 property: "maximizedAppTopMargin"
278 // Not just using panel.panelHeight as that changes depending on the focused app.
279 value: panel.indicators.minimizedPanelHeight
282 target: applicationsDisplayLoader.item
283 property: "interactive"
284 value: applicationsDisplayLoader.interactive
287 target: applicationsDisplayLoader.item
288 property: "spreadEnabled"
289 value: tutorial.spreadEnabled && (!greeter || (!greeter.hasLockedApp && !greeter.shown))
292 target: applicationsDisplayLoader.item
293 property: "inverseProgress"
294 value: greeter && greeter.locked ? 0 : launcher.progress
297 target: applicationsDisplayLoader.item
298 property: "shellOrientationAngle"
299 value: shell.orientationAngle
302 target: applicationsDisplayLoader.item
303 property: "shellOrientation"
304 value: shell.orientation
307 target: applicationsDisplayLoader.item
308 property: "orientations"
309 value: shell.orientations
312 target: applicationsDisplayLoader.item
313 property: "background"
314 value: wallpaperResolver.background
317 target: applicationsDisplayLoader.item
318 property: "nativeWidth"
319 value: shell.nativeWidth
322 target: applicationsDisplayLoader.item
323 property: "nativeHeight"
324 value: shell.nativeHeight
327 target: applicationsDisplayLoader.item
328 property: "beingResized"
329 value: shell.beingResized
332 target: applicationsDisplayLoader.item
333 property: "keepDashRunning"
334 value: launcher.shown || launcher.dashSwipe
337 target: applicationsDisplayLoader.item
338 property: "suspended"
342 target: applicationsDisplayLoader.item
343 property: "altTabPressed"
344 value: physicalKeysMapper.altTabPressed
350 objectName: "tutorial"
353 // EdgeDragAreas don't work with mice. So to avoid trapping the user,
354 // we skip the tutorial on the Desktop to avoid using them. The
355 // Desktop doesn't use the same spread design anyway. The tutorial is
356 // all a bit of a placeholder on non-phone form factors right now.
357 // When the design team gives us more guidance, we can do something
359 active: usageScenario != "desktop" && AccountsService.demoEdges
361 paused: lightDM.greeter.active
364 edgeSize: shell.edgeSize
367 AccountsService.demoEdges = false;
368 active = false; // for immediate response / if AS is having problems
375 objectName: "inputMethod"
376 anchors { fill: parent; topMargin: panel.panelHeight }
377 z: notifications.useModal || panel.indicators.shown || wizard.active ? overlay.z + 1 : overlay.z - 1
381 target: SessionManager
383 if (!session.parentSession && !session.application) {
384 // nothing is using it. delete it right away
393 anchors.topMargin: panel.panelHeight
394 sourceComponent: shell.mode != "shell" ? integratedGreeter :
395 Qt.createComponent(Qt.resolvedUrl("Greeter/ShimGreeter.qml"));
397 item.objectName = "greeter"
402 id: integratedGreeter
405 hides: [launcher, panel.indicators]
406 tabletMode: shell.usageScenario != "phone"
407 launcherOffset: launcher.progress
408 forcedUnlock: tutorial.running
409 background: wallpaperResolver.background
411 // avoid overlapping with Launcher's edge drag area
412 // FIXME: Fix TouchRegistry & friends and remove this workaround
413 // Issue involves launcher's DDA getting disabled on a long
415 dragHandleLeftMargin: launcher.available ? launcher.dragAreaWidth + 1 : 0
422 if (!tutorial.running) {
427 onEmergencyCall: startLockedApp("dialer-app")
432 // See powerConnection for why this is useful
433 id: showGreeterDelayed
445 if (greeter.locked && callManager.hasCalls && greeter.lockedApp !== "dialer-app") {
446 // We just received an incoming call while locked. The
447 // indicator will have already launched dialer-app for us, but
448 // there is a race between "hasCalls" changing and the dialer
449 // starting up. So in case we lose that race, we'll start/
450 // focus the dialer ourselves here too. Even if the indicator
451 // didn't launch the dialer for some reason (or maybe a call
452 // started via some other means), if an active call is
453 // happening, we want to be in the dialer.
454 startLockedApp("dialer-app")
464 if (Powerd.status === Powerd.Off && reason !== Powerd.Proximity &&
465 !callManager.hasCalls && !tutorial.running) {
466 // We don't want to simply call greeter.showNow() here, because
467 // that will take too long. Qt will delay button event
468 // handling until the greeter is done loading and may think the
469 // user held down the power button the whole time, leading to a
470 // power dialog being shown. Instead, delay showing the
471 // greeter until we've finished handling the event. We could
472 // make the greeter load asynchronously instead, but that
473 // introduces a whole host of timing issues, especially with
474 // its animations. So this is simpler.
475 showGreeterDelayed.start();
480 function showHome() {
481 if (tutorial.running) {
485 greeter.notifyAboutToFocusApp("unity8-dash");
487 var animate = !lightDM.greeter.active && !stages.shown
488 dash.setCurrentScope(0, animate, false)
489 ApplicationManager.requestFocusApplication("unity8-dash")
492 function showDash() {
493 if (greeter.notifyShowingDashFromDrag()) {
497 if (!greeter.locked && ApplicationManager.focusedApplicationId != "unity8-dash") {
498 ApplicationManager.requestFocusApplication("unity8-dash")
512 anchors.fill: parent //because this draws indicator menus
515 available: tutorial.panelEnabled
516 && ((!greeter || !greeter.locked) || AccountsService.enableIndicatorsWhileLocked)
517 && (!greeter || !greeter.hasLockedApp)
518 contentEnabled: tutorial.panelContentEnabled
519 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
521 minimizedPanelHeight: units.gu(3)
522 expandedPanelHeight: units.gu(7)
524 indicatorsModel: Indicators.IndicatorsModel {
525 // tablet and phone both use the same profile
527 Component.onCompleted: load();
532 greeterShown: greeter.shown
535 readonly property bool topmostApplicationIsFullscreen:
536 ApplicationManager.focusedApplicationId &&
537 ApplicationManager.findApplication(ApplicationManager.focusedApplicationId).fullscreen
539 fullscreenMode: (topmostApplicationIsFullscreen && !lightDM.greeter.active && launcher.progress == 0)
540 || greeter.hasLockedApp
541 locked: greeter && greeter.active
546 objectName: "launcher"
548 readonly property bool dashSwipe: progress > 0
550 anchors.top: parent.top
551 anchors.topMargin: inverted ? 0 : panel.panelHeight
552 anchors.bottom: parent.bottom
554 dragAreaWidth: shell.edgeSize
555 available: tutorial.launcherEnabled
556 && (!greeter.locked || AccountsService.enableLauncherWhileLocked)
557 && !greeter.hasLockedApp
558 inverted: shell.usageScenario !== "desktop"
559 shadeBackground: !tutorial.running
561 onShowDashHome: showHome()
563 onDashSwipeChanged: {
565 dash.setCurrentScope(0, false, true)
568 onLauncherApplicationSelected: {
569 if (!tutorial.running) {
570 greeter.notifyAboutToFocusApp(appId);
571 shell.activateApplication(appId)
576 panel.indicators.hide()
585 background: wallpaperResolver.background
587 function unlockWhenDoneWithWizard() {
589 Connectivity.unlockAllModems();
593 Component.onCompleted: unlockWhenDoneWithWizard()
594 onActiveChanged: unlockWhenDoneWithWizard()
598 id: modalNotificationBackground
600 visible: notifications.useModal
613 model: NotificationBackend.Model
615 hasMouse: shell.hasMouse
616 background: wallpaperResolver.background
618 y: topmostIsFullscreen ? 0 : panel.panelHeight
619 height: parent.height - (topmostIsFullscreen ? 0 : panel.panelHeight)
624 when: overlay.width <= units.gu(60)
626 target: notifications
627 anchors.left: parent.left
628 anchors.right: parent.right
633 when: overlay.width > units.gu(60)
635 target: notifications
636 anchors.left: undefined
637 anchors.right: parent.right
639 PropertyChanges { target: notifications; width: units.gu(38) }
647 objectName: "dialogs"
650 usageScenario: shell.usageScenario
652 shutdownFadeOutRectangle.enabled = true;
653 shutdownFadeOutRectangle.visible = true;
654 shutdownFadeOut.start();
659 target: SessionBroadcast
660 onShowHome: showHome()
665 rotationAngle: -shell.orientationAngle
671 visible: shell.hasMouse
672 z: screenGrabber.z + 1
674 onPushedLeftBoundary: {
675 if (buttons === Qt.NoButton) {
676 launcher.pushEdge(amount);
680 onPushedRightBoundary: {
681 if (buttons === Qt.NoButton && applicationsDisplayLoader.item
682 && applicationsDisplayLoader.item.pushRightEdge) {
683 applicationsDisplayLoader.item.pushRightEdge(amount);
687 onMouseMoved: { cursor.opacity = 1; }
691 id: shutdownFadeOutRectangle
698 NumberAnimation on opacity {
703 if (shutdownFadeOutRectangle.enabled && shutdownFadeOutRectangle.visible) {
704 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