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 WindowInputFilter
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
50 // to be set from outside
51 property int orientationAngle: 0
52 property int orientation
53 property Orientations orientations
54 property real nativeWidth
55 property real nativeHeight
56 property alias indicatorAreaShowProgress: panel.indicatorAreaShowProgress
57 property bool beingResized
58 property string usageScenario: "phone" // supported values: "phone", "tablet" or "desktop"
59 property string mode: "full-greeter"
60 property alias oskEnabled: inputMethod.enabled
61 function updateFocusedAppOrientation() {
62 applicationsDisplayLoader.item.updateFocusedAppOrientation();
64 function updateFocusedAppOrientationAnimated() {
65 applicationsDisplayLoader.item.updateFocusedAppOrientationAnimated();
67 property bool hasMouse: false
69 // to be read from outside
70 readonly property int mainAppWindowOrientationAngle:
71 applicationsDisplayLoader.item ? applicationsDisplayLoader.item.mainAppWindowOrientationAngle : 0
73 readonly property bool orientationChangesEnabled: panel.indicators.fullyClosed
74 && (applicationsDisplayLoader.item && applicationsDisplayLoader.item.orientationChangesEnabled)
75 && (!greeter || !greeter.animating)
77 readonly property bool showingGreeter: greeter && greeter.shown
79 property bool startingUp: true
80 Timer { id: finishStartUpTimer; interval: 500; onTriggered: startingUp = false }
82 property int supportedOrientations: {
84 // Ensure we don't rotate during start up
85 return Qt.PrimaryOrientation;
86 } else if (greeter && greeter.shown) {
87 return Qt.PrimaryOrientation;
88 } else if (applicationsDisplayLoader.item) {
89 return shell.orientations.map(applicationsDisplayLoader.item.supportedOrientations);
92 return Qt.PortraitOrientation
93 | Qt.LandscapeOrientation
94 | Qt.InvertedPortraitOrientation
95 | Qt.InvertedLandscapeOrientation;
99 // For autopilot consumption
100 readonly property string focusedApplicationId: ApplicationManager.focusedApplicationId
102 // internal props from here onwards
103 readonly property var mainApp:
104 applicationsDisplayLoader.item ? applicationsDisplayLoader.item.mainApp : null
106 // Disable everything while greeter is waiting, so that the user can't swipe
107 // the greeter or launcher until we know whether the session is locked.
108 enabled: greeter && !greeter.waiting
110 property real edgeSize: units.gu(2)
113 id: wallpaperResolver
117 readonly property alias greeter: greeterLoader.item
119 function activateApplication(appId) {
120 if (ApplicationManager.findApplication(appId)) {
121 ApplicationManager.requestFocusApplication(appId);
123 ApplicationManager.startApplication(appId);
127 function startLockedApp(app) {
128 if (greeter.locked) {
129 greeter.lockedApp = app;
131 shell.activateApplication(app);
135 target: LauncherModel
136 property: "applicationManager"
137 value: ApplicationManager
140 Component.onCompleted: {
141 theme.name = "Ubuntu.Components.Themes.SuruDark"
142 if (ApplicationManager.count > 0) {
143 ApplicationManager.focusApplication(ApplicationManager.get(0).appId);
145 finishStartUpTimer.start();
148 LightDM{id: lightDM} // Provide backend access
151 indicators: panel.indicators
156 objectName: "dashCommunicator"
160 id: physicalKeysMapper
161 objectName: "physicalKeysMapper"
163 onPowerKeyLongPressed: dialogs.showPowerDialog();
164 onVolumeDownTriggered: volumeControl.volumeDown();
165 onVolumeUpTriggered: volumeControl.volumeUp();
166 onScreenshotTriggered: screenGrabber.capture();
170 // dummy shortcut to force creation of GlobalShortcutRegistry before WindowInputFilter
175 Keys.onPressed: physicalKeysMapper.onKeyPressed(event, lastInputTimestamp);
176 Keys.onReleased: physicalKeysMapper.onKeyReleased(event, lastInputTimestamp);
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;
192 schema.id: "com.canonical.Unity8"
199 height: parent.height
202 target: ApplicationManager
204 // This signal is also fired when we try to focus the current app
205 // again. We rely on this!
206 onFocusedApplicationIdChanged: {
207 var appId = ApplicationManager.focusedApplicationId;
209 if (wizard.active && appId != "" && appId != "unity8-dash") {
210 // If this happens on first boot, we may be in edge
211 // tutorial or wizard while receiving a call. But a call
212 // is more important than wizard so just bail out of those.
217 if (appId === "dialer-app" && callManager.hasCalls && greeter.locked) {
218 // If we are in the middle of a call, make dialer lockedApp and show it.
219 // This can happen if user backs out of dialer back to greeter, then
220 // launches dialer again.
221 greeter.lockedApp = appId;
223 greeter.notifyAppFocused(appId);
225 panel.indicators.hide();
228 onApplicationAdded: {
234 id: applicationsDisplayLoader
235 objectName: "applicationsDisplayLoader"
238 // When we have a locked app, we only want to show that one app.
239 // FIXME: do this in a less traumatic way. We currently only allow
240 // locked apps in phone mode (see FIXME in Lockscreen component in
241 // this same file). When that changes, we need to do something
242 // nicer here. But this code is currently just to prevent a
243 // theoretical attack where user enters lockedApp mode, then makes
244 // the screen larger (maybe connects to monitor) and tries to enter
247 property string usageScenario: shell.usageScenario === "phone" || greeter.hasLockedApp
249 : shell.usageScenario
250 readonly property string qmlComponent: {
251 if(shell.mode === "greeter") {
252 return "Stages/ShimStage.qml"
253 } else if (applicationsDisplayLoader.usageScenario === "phone") {
254 return "Stages/PhoneStage.qml";
255 } else if (applicationsDisplayLoader.usageScenario === "tablet") {
256 return "Stages/TabletStage.qml";
258 return "Stages/DesktopStage.qml";
261 onQmlComponentChanged: {
262 if (item) item.stageAboutToBeUnloaded();
263 source = qmlComponent;
266 property bool interactive: (!greeter || !greeter.shown)
267 && panel.indicators.fullyClosed
268 && launcher.progress == 0
269 && !notifications.useModal
271 onInteractiveChanged: { if (interactive) { focus = true; } }
274 target: applicationsDisplayLoader.item
275 property: "objectName"
279 target: applicationsDisplayLoader.item
280 property: "dragAreaWidth"
281 value: shell.edgeSize
284 target: applicationsDisplayLoader.item
285 property: "maximizedAppTopMargin"
286 // Not just using panel.panelHeight as that changes depending on the focused app.
287 value: panel.indicators.minimizedPanelHeight
290 target: applicationsDisplayLoader.item
291 property: "interactive"
292 value: applicationsDisplayLoader.interactive
295 target: applicationsDisplayLoader.item
296 property: "spreadEnabled"
297 value: tutorial.spreadEnabled && (!greeter || (!greeter.hasLockedApp && !greeter.shown))
300 target: applicationsDisplayLoader.item
301 property: "inverseProgress"
302 value: greeter && greeter.locked ? 0 : launcher.progress
305 target: applicationsDisplayLoader.item
306 property: "shellOrientationAngle"
307 value: shell.orientationAngle
310 target: applicationsDisplayLoader.item
311 property: "shellOrientation"
312 value: shell.orientation
315 target: applicationsDisplayLoader.item
316 property: "orientations"
317 value: shell.orientations
320 target: applicationsDisplayLoader.item
321 property: "background"
322 value: wallpaperResolver.background
325 target: applicationsDisplayLoader.item
326 property: "nativeWidth"
327 value: shell.nativeWidth
330 target: applicationsDisplayLoader.item
331 property: "nativeHeight"
332 value: shell.nativeHeight
335 target: applicationsDisplayLoader.item
336 property: "beingResized"
337 value: shell.beingResized
340 target: applicationsDisplayLoader.item
341 property: "keepDashRunning"
342 value: launcher.shown || launcher.dashSwipe
345 target: applicationsDisplayLoader.item
346 property: "suspended"
350 target: applicationsDisplayLoader.item
351 property: "altTabPressed"
352 value: physicalKeysMapper.altTabPressed
355 target: applicationsDisplayLoader.item
356 property: "leftMargin"
357 value: shell.usageScenario == "desktop" && !settings.autohideLauncher ? launcher.panelWidth: 0
364 objectName: "inputMethod"
367 topMargin: panel.panelHeight
368 leftMargin: launcher.lockedVisible ? launcher.panelWidth : 0
370 z: notifications.useModal || panel.indicators.shown || wizard.active || tutorial.running ? overlay.z + 1 : overlay.z - 1
374 target: SessionManager
376 if (!session.parentSession && !session.application) {
377 // nothing is using it. delete it right away
386 anchors.topMargin: panel.panelHeight
387 sourceComponent: shell.mode != "shell" ? integratedGreeter :
388 Qt.createComponent(Qt.resolvedUrl("Greeter/ShimGreeter.qml"));
390 item.objectName = "greeter"
395 id: integratedGreeter
398 hides: [launcher, panel.indicators]
399 tabletMode: shell.usageScenario != "phone"
400 launcherOffset: launcher.progress
401 forcedUnlock: wizard.active
402 background: wallpaperResolver.background
404 // avoid overlapping with Launcher's edge drag area
405 // FIXME: Fix TouchRegistry & friends and remove this workaround
406 // Issue involves launcher's DDA getting disabled on a long
408 dragHandleLeftMargin: launcher.available ? launcher.dragAreaWidth + 1 : 0
415 if (!tutorial.running) {
420 onEmergencyCall: startLockedApp("dialer-app")
425 // See powerConnection for why this is useful
426 id: showGreeterDelayed
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 && !wizard.active) {
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 greeter.notifyAboutToFocusApp("unity8-dash");
476 var animate = !lightDM.greeter.active && !stages.shown
477 dash.setCurrentScope(0, animate, false)
478 ApplicationManager.requestFocusApplication("unity8-dash")
481 function showDash() {
482 if (greeter.notifyShowingDashFromDrag()) {
486 if (!greeter.locked && ApplicationManager.focusedApplicationId != "unity8-dash") {
487 ApplicationManager.requestFocusApplication("unity8-dash")
501 anchors.fill: parent //because this draws indicator menus
504 available: tutorial.panelEnabled
505 && ((!greeter || !greeter.locked) || AccountsService.enableIndicatorsWhileLocked)
506 && (!greeter || !greeter.hasLockedApp)
507 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
509 minimizedPanelHeight: units.gu(3)
510 expandedPanelHeight: units.gu(7)
512 indicatorsModel: Indicators.IndicatorsModel {
513 // tablet and phone both use the same profile
515 Component.onCompleted: load();
520 greeterShown: greeter.shown
523 readonly property bool topmostApplicationIsFullscreen: mainApp && mainApp.fullscreen
525 fullscreenMode: (topmostApplicationIsFullscreen && !lightDM.greeter.active && launcher.progress == 0)
526 || greeter.hasLockedApp
527 locked: greeter && greeter.active
532 objectName: "launcher"
534 readonly property bool dashSwipe: progress > 0
536 anchors.top: parent.top
537 anchors.topMargin: inverted ? 0 : panel.panelHeight
538 anchors.bottom: parent.bottom
540 dragAreaWidth: shell.edgeSize
541 available: tutorial.launcherEnabled
542 && (!greeter.locked || AccountsService.enableLauncherWhileLocked)
543 && !greeter.hasLockedApp
544 inverted: shell.usageScenario !== "desktop"
545 superPressed: physicalKeysMapper.superPressed
546 superTabPressed: physicalKeysMapper.superTabPressed
547 panelWidth: units.gu(settings.launcherWidth)
548 lockedVisible: shell.usageScenario == "desktop" && !settings.autohideLauncher && !panel.fullscreenMode
550 onShowDashHome: showHome()
552 onDashSwipeChanged: {
554 dash.setCurrentScope(0, false, true)
557 onLauncherApplicationSelected: {
558 greeter.notifyAboutToFocusApp(appId);
559 shell.activateApplication(appId);
563 panel.indicators.hide()
568 applicationsDisplayLoader.focus = true;
573 shortcut: Qt.AltModifier | Qt.Key_F1
575 launcher.openForKeyboardNavigation();
579 shortcut: Qt.MetaModifier | Qt.Key_0
581 if (LauncherModel.get(9)) {
582 activateApplication(LauncherModel.get(9).appId);
589 shortcut: Qt.MetaModifier | (Qt.Key_1 + index)
591 if (LauncherModel.get(index)) {
592 activateApplication(LauncherModel.get(index).appId);
601 objectName: "tutorial"
604 paused: callManager.hasCalls || greeter.shown
605 keyboardVisible: inputMethod.state === "shown"
606 usageScenario: shell.usageScenario
607 lastInputTimestamp: inputFilter.lastInputTimestamp
610 stage: applicationsDisplayLoader.item
618 function unlockWhenDoneWithWizard() {
620 Connectivity.unlockAllModems();
624 Component.onCompleted: unlockWhenDoneWithWizard()
625 onActiveChanged: unlockWhenDoneWithWizard()
629 id: modalNotificationBackground
631 visible: notifications.useModal
644 model: NotificationBackend.Model
646 hasMouse: shell.hasMouse
647 background: wallpaperResolver.background
649 y: topmostIsFullscreen ? 0 : panel.panelHeight
650 height: parent.height - (topmostIsFullscreen ? 0 : panel.panelHeight)
655 when: overlay.width <= units.gu(60)
657 target: notifications
658 anchors.left: parent.left
659 anchors.right: parent.right
664 when: overlay.width > units.gu(60)
666 target: notifications
667 anchors.left: undefined
668 anchors.right: parent.right
670 PropertyChanges { target: notifications; width: units.gu(38) }
678 objectName: "dialogs"
681 usageScenario: shell.usageScenario
683 shutdownFadeOutRectangle.enabled = true;
684 shutdownFadeOutRectangle.visible = true;
685 shutdownFadeOut.start();
690 target: SessionBroadcast
691 onShowHome: showHome()
696 rotationAngle: -shell.orientationAngle
702 visible: shell.hasMouse
703 z: screenGrabber.z + 1
705 onPushedLeftBoundary: {
706 if (buttons === Qt.NoButton) {
707 launcher.pushEdge(amount);
711 onPushedRightBoundary: {
712 if (buttons === Qt.NoButton && applicationsDisplayLoader.item
713 && applicationsDisplayLoader.item.pushRightEdge) {
714 applicationsDisplayLoader.item.pushRightEdge(amount);
718 onMouseMoved: { cursor.opacity = 1; }
722 id: shutdownFadeOutRectangle
729 NumberAnimation on opacity {
734 if (shutdownFadeOutRectangle.enabled && shutdownFadeOutRectangle.visible) {
735 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