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
105 readonly property var mainAppWindow:
106 applicationsDisplayLoader.item ? applicationsDisplayLoader.item.mainAppWindow : null
108 // Disable everything while greeter is waiting, so that the user can't swipe
109 // the greeter or launcher until we know whether the session is locked.
110 enabled: greeter && !greeter.waiting
112 property real edgeSize: units.gu(2)
115 id: wallpaperResolver
119 readonly property alias greeter: greeterLoader.item
121 function activateApplication(appId) {
122 if (ApplicationManager.findApplication(appId)) {
123 ApplicationManager.requestFocusApplication(appId);
125 ApplicationManager.startApplication(appId);
129 function startLockedApp(app) {
130 if (greeter.locked) {
131 greeter.lockedApp = app;
133 shell.activateApplication(app);
137 target: LauncherModel
138 property: "applicationManager"
139 value: ApplicationManager
142 Component.onCompleted: {
143 theme.name = "Ubuntu.Components.Themes.SuruDark"
144 if (ApplicationManager.count > 0) {
145 ApplicationManager.focusApplication(ApplicationManager.get(0).appId);
147 finishStartUpTimer.start();
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 WindowInputFilter
176 Keys.onPressed: physicalKeysMapper.onKeyPressed(event, lastInputTimestamp);
177 Keys.onReleased: physicalKeysMapper.onKeyReleased(event, lastInputTimestamp);
181 onHomeKeyActivated: { launcher.fadeOut(); shell.showHome(); }
182 onTouchBegun: { cursor.opacity = 0; }
184 // move the (hidden) cursor to the last known touch position
185 var mappedCoords = mapFromItem(null, pos.x, pos.y);
186 cursor.x = mappedCoords.x;
187 cursor.y = mappedCoords.y;
193 schema.id: "com.canonical.Unity8"
200 height: parent.height
203 target: ApplicationManager
205 // This signal is also fired when we try to focus the current app
206 // again. We rely on this!
207 onFocusedApplicationIdChanged: {
208 var appId = ApplicationManager.focusedApplicationId;
210 if (wizard.active && appId != "" && appId != "unity8-dash") {
211 // If this happens on first boot, we may be in edge
212 // tutorial or wizard while receiving a call. But a call
213 // is more important than wizard so just bail out of those.
218 if (appId === "dialer-app" && callManager.hasCalls && greeter.locked) {
219 // If we are in the middle of a call, make dialer lockedApp and show it.
220 // This can happen if user backs out of dialer back to greeter, then
221 // launches dialer again.
222 greeter.lockedApp = appId;
224 greeter.notifyAppFocused(appId);
226 panel.indicators.hide();
229 onApplicationAdded: {
235 id: applicationsDisplayLoader
236 objectName: "applicationsDisplayLoader"
239 // When we have a locked app, we only want to show that one app.
240 // FIXME: do this in a less traumatic way. We currently only allow
241 // locked apps in phone mode (see FIXME in Lockscreen component in
242 // this same file). When that changes, we need to do something
243 // nicer here. But this code is currently just to prevent a
244 // theoretical attack where user enters lockedApp mode, then makes
245 // the screen larger (maybe connects to monitor) and tries to enter
248 property string usageScenario: shell.usageScenario === "phone" || greeter.hasLockedApp
250 : shell.usageScenario
251 readonly property string qmlComponent: {
252 if(shell.mode === "greeter") {
253 return "Stages/ShimStage.qml"
254 } else if (applicationsDisplayLoader.usageScenario === "phone") {
255 return "Stages/PhoneStage.qml";
256 } else if (applicationsDisplayLoader.usageScenario === "tablet") {
257 return "Stages/TabletStage.qml";
259 return "Stages/DesktopStage.qml";
262 onQmlComponentChanged: {
263 if (item) item.stageAboutToBeUnloaded();
264 source = qmlComponent;
267 property bool interactive: (!greeter || !greeter.shown)
268 && panel.indicators.fullyClosed
269 && launcher.progress == 0
270 && !notifications.useModal
272 onInteractiveChanged: { if (interactive) { focus = true; } }
275 target: applicationsDisplayLoader.item
276 property: "objectName"
280 target: applicationsDisplayLoader.item
281 property: "dragAreaWidth"
282 value: shell.edgeSize
285 target: applicationsDisplayLoader.item
286 property: "maximizedAppTopMargin"
287 // Not just using panel.panelHeight as that changes depending on the focused app.
288 value: panel.indicators.minimizedPanelHeight
291 target: applicationsDisplayLoader.item
292 property: "interactive"
293 value: applicationsDisplayLoader.interactive
296 target: applicationsDisplayLoader.item
297 property: "spreadEnabled"
298 value: tutorial.spreadEnabled && (!greeter || (!greeter.hasLockedApp && !greeter.shown))
301 target: applicationsDisplayLoader.item
302 property: "inverseProgress"
303 value: greeter && greeter.locked ? 0 : launcher.progress
306 target: applicationsDisplayLoader.item
307 property: "shellOrientationAngle"
308 value: shell.orientationAngle
311 target: applicationsDisplayLoader.item
312 property: "shellOrientation"
313 value: shell.orientation
316 target: applicationsDisplayLoader.item
317 property: "orientations"
318 value: shell.orientations
321 target: applicationsDisplayLoader.item
322 property: "background"
323 value: wallpaperResolver.background
326 target: applicationsDisplayLoader.item
327 property: "nativeWidth"
328 value: shell.nativeWidth
331 target: applicationsDisplayLoader.item
332 property: "nativeHeight"
333 value: shell.nativeHeight
336 target: applicationsDisplayLoader.item
337 property: "beingResized"
338 value: shell.beingResized
341 target: applicationsDisplayLoader.item
342 property: "keepDashRunning"
343 value: launcher.shown || launcher.dashSwipe
346 target: applicationsDisplayLoader.item
347 property: "suspended"
351 target: applicationsDisplayLoader.item
352 property: "altTabPressed"
353 value: physicalKeysMapper.altTabPressed
356 target: applicationsDisplayLoader.item
357 property: "leftMargin"
358 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 = !LightDMService.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 && !LightDMService.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
617 deferred: shell.mode === "greeter"
618 background: wallpaperResolver.background
620 function unlockWhenDoneWithWizard() {
622 Connectivity.unlockAllModems();
626 Component.onCompleted: unlockWhenDoneWithWizard()
627 onActiveChanged: unlockWhenDoneWithWizard()
631 id: modalNotificationBackground
633 visible: notifications.useModal
646 model: NotificationBackend.Model
648 hasMouse: shell.hasMouse
649 inverseMode: panel.indicators.shown
650 background: wallpaperResolver.background
652 y: topmostIsFullscreen ? 0 : panel.panelHeight
653 height: parent.height - (topmostIsFullscreen ? 0 : panel.panelHeight)
658 when: overlay.width <= units.gu(60)
660 target: notifications
661 anchors.left: parent.left
662 anchors.right: parent.right
667 when: overlay.width > units.gu(60)
669 target: notifications
670 anchors.left: undefined
671 anchors.right: parent.right
673 PropertyChanges { target: notifications; width: units.gu(38) }
681 objectName: "dialogs"
684 usageScenario: shell.usageScenario
686 shutdownFadeOutRectangle.enabled = true;
687 shutdownFadeOutRectangle.visible = true;
688 shutdownFadeOut.start();
693 target: SessionBroadcast
694 onShowHome: showHome()
699 rotationAngle: -shell.orientationAngle
705 visible: shell.hasMouse
706 z: screenGrabber.z + 1
708 onPushedLeftBoundary: {
709 if (buttons === Qt.NoButton) {
710 launcher.pushEdge(amount);
714 onPushedRightBoundary: {
715 if (buttons === Qt.NoButton && applicationsDisplayLoader.item
716 && applicationsDisplayLoader.item.pushRightEdge) {
717 applicationsDisplayLoader.item.pushRightEdge(amount);
721 onMouseMoved: { cursor.opacity = 1; }
726 shortcut: Qt.MetaModifier|Qt.Key_Space
727 onTriggered: keymapPriv.nextKeymap()
728 active: keymapPriv.keymapCount > 1
732 shortcut: Qt.MetaModifier|Qt.ShiftModifier|Qt.Key_Space
733 onTriggered: keymapPriv.previousKeymap()
734 active: keymapPriv.keymapCount > 1
740 readonly property var keymaps: AccountsService.keymaps
741 readonly property int keymapCount: keymaps.length
742 property int currentKeymapIndex: 0 // the new one that we're setting
743 onCurrentKeymapIndexChanged: switchToKeymap();
745 function nextKeymap() {
748 if (currentKeymapIndex !== -1 && currentKeymapIndex < keymapCount - 1) {
749 nextIndex = currentKeymapIndex + 1;
751 currentKeymapIndex = nextIndex;
754 function previousKeymap() {
755 var prevIndex = keymapCount - 1;
757 if (currentKeymapIndex > 0) {
758 prevIndex = currentKeymapIndex - 1;
760 currentKeymapIndex = prevIndex;
763 function switchToKeymap() {
765 mainAppWindow.switchToKeymap(keymaps[currentKeymapIndex]);
770 onMainAppWindowChanged: keymapPriv.switchToKeymap()
773 id: shutdownFadeOutRectangle
780 NumberAnimation on opacity {
785 if (shutdownFadeOutRectangle.enabled && shutdownFadeOutRectangle.visible) {
786 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