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.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
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 bool cursorVisible: false
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;
89 return shell.orientations.map(mainApp.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 var execFlags = shell.usageScenario === "phone" ? ApplicationManager.ForceMainStage
124 : ApplicationManager.NoFlag;
125 ApplicationManager.startApplication(appId, execFlags);
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.SuruGradient"
144 if (ApplicationManager.count > 0) {
145 ApplicationManager.focusApplication(ApplicationManager.get(0).appId);
147 finishStartUpTimer.start();
150 LightDM{id: lightDM} // Provide backend access
153 indicators: panel.indicators
158 objectName: "dashCommunicator"
162 id: physicalKeysMapper
163 objectName: "physicalKeysMapper"
165 onPowerKeyLongPressed: dialogs.showPowerDialog();
166 onVolumeDownTriggered: volumeControl.volumeDown();
167 onVolumeUpTriggered: volumeControl.volumeUp();
168 onScreenshotTriggered: screenGrabber.capture();
172 // dummy shortcut to force creation of GlobalShortcutRegistry before WindowKeyFilter
176 Keys.onPressed: physicalKeysMapper.onKeyPressed(event, currentEventTimestamp);
177 Keys.onReleased: physicalKeysMapper.onKeyReleased(event, currentEventTimestamp);
181 onActivated: { launcher.fadeOut(); shell.showHome(); }
188 height: parent.height
191 target: ApplicationManager
193 // This signal is also fired when we try to focus the current app
194 // again. We rely on this!
195 onFocusedApplicationIdChanged: {
196 var appId = ApplicationManager.focusedApplicationId;
198 if (tutorial.running && appId != "" && appId != "unity8-dash") {
199 // If this happens on first boot, we may be in edge
200 // tutorial or wizard while receiving a call. But a call
201 // is more important than wizard so just bail out of those.
206 if (appId === "dialer-app" && callManager.hasCalls && greeter.locked) {
207 // If we are in the middle of a call, make dialer lockedApp and show it.
208 // This can happen if user backs out of dialer back to greeter, then
209 // launches dialer again.
210 greeter.lockedApp = appId;
212 greeter.notifyAppFocused(appId);
214 panel.indicators.hide();
217 onApplicationAdded: {
223 id: applicationsDisplayLoader
224 objectName: "applicationsDisplayLoader"
227 // When we have a locked app, we only want to show that one app.
228 // FIXME: do this in a less traumatic way. We currently only allow
229 // locked apps in phone mode (see FIXME in Lockscreen component in
230 // this same file). When that changes, we need to do something
231 // nicer here. But this code is currently just to prevent a
232 // theoretical attack where user enters lockedApp mode, then makes
233 // the screen larger (maybe connects to monitor) and tries to enter
236 property string usageScenario: shell.usageScenario === "phone" || greeter.hasLockedApp
238 : shell.usageScenario
240 if(shell.mode === "greeter") {
241 return "Stages/ShimStage.qml"
242 } else if (applicationsDisplayLoader.usageScenario === "phone") {
243 return "Stages/PhoneStage.qml";
244 } else if (applicationsDisplayLoader.usageScenario === "tablet") {
245 return "Stages/TabletStage.qml";
247 return "Stages/DesktopStage.qml";
251 property bool interactive: tutorial.spreadEnabled
252 && (!greeter || !greeter.shown)
253 && panel.indicators.fullyClosed
254 && launcher.progress == 0
255 && !notifications.useModal
257 onInteractiveChanged: { if (interactive) { focus = true; } }
260 target: applicationsDisplayLoader.item
261 property: "objectName"
265 target: applicationsDisplayLoader.item
266 property: "dragAreaWidth"
267 value: shell.edgeSize
270 target: applicationsDisplayLoader.item
271 property: "maximizedAppTopMargin"
272 // Not just using panel.panelHeight as that changes depending on the focused app.
273 value: panel.indicators.minimizedPanelHeight
276 target: applicationsDisplayLoader.item
277 property: "interactive"
278 value: applicationsDisplayLoader.interactive
281 target: applicationsDisplayLoader.item
282 property: "spreadEnabled"
283 value: tutorial.spreadEnabled && (!greeter || (!greeter.hasLockedApp && !greeter.shown))
286 target: applicationsDisplayLoader.item
287 property: "inverseProgress"
288 value: greeter && greeter.locked ? 0 : launcher.progress
291 target: applicationsDisplayLoader.item
292 property: "shellOrientationAngle"
293 value: shell.orientationAngle
296 target: applicationsDisplayLoader.item
297 property: "shellOrientation"
298 value: shell.orientation
301 target: applicationsDisplayLoader.item
302 property: "orientations"
303 value: shell.orientations
306 target: applicationsDisplayLoader.item
307 property: "background"
308 value: wallpaperResolver.background
311 target: applicationsDisplayLoader.item
312 property: "nativeWidth"
313 value: shell.nativeWidth
316 target: applicationsDisplayLoader.item
317 property: "nativeHeight"
318 value: shell.nativeHeight
321 target: applicationsDisplayLoader.item
322 property: "beingResized"
323 value: shell.beingResized
326 target: applicationsDisplayLoader.item
327 property: "keepDashRunning"
328 value: launcher.shown || launcher.dashSwipe
331 target: applicationsDisplayLoader.item
332 property: "suspended"
336 target: applicationsDisplayLoader.item
337 property: "altTabPressed"
338 value: physicalKeysMapper.altTabPressed
341 target: applicationsDisplayLoader.item
342 property: "leftMargin"
343 value: launcher.lockedVisible ? launcher.panelWidth: 0
349 objectName: "tutorial"
352 // EdgeDragAreas don't work with mice. So to avoid trapping the user,
353 // we skip the tutorial on the Desktop to avoid using them. The
354 // Desktop doesn't use the same spread design anyway. The tutorial is
355 // all a bit of a placeholder on non-phone form factors right now.
356 // When the design team gives us more guidance, we can do something
358 active: usageScenario != "desktop" && AccountsService.demoEdges
360 paused: lightDM.greeter.active
363 edgeSize: shell.edgeSize
366 AccountsService.demoEdges = false;
367 active = false; // for immediate response / if AS is having problems
374 objectName: "inputMethod"
377 topMargin: panel.panelHeight
378 leftMargin: launcher.lockedVisible ? launcher.panelWidth : 0
380 z: notifications.useModal || panel.indicators.shown || wizard.active ? overlay.z + 1 : overlay.z - 1
384 target: SessionManager
386 if (!session.parentSession && !session.application) {
387 // nothing is using it. delete it right away
396 anchors.topMargin: panel.panelHeight
397 sourceComponent: shell.mode != "shell" ? integratedGreeter :
398 Qt.createComponent(Qt.resolvedUrl("Greeter/ShimGreeter.qml"));
400 item.objectName = "greeter"
405 id: integratedGreeter
408 hides: [launcher, panel.indicators]
409 tabletMode: shell.usageScenario != "phone"
410 launcherOffset: launcher.progress
411 forcedUnlock: tutorial.running
412 background: wallpaperResolver.background
414 // avoid overlapping with Launcher's edge drag area
415 // FIXME: Fix TouchRegistry & friends and remove this workaround
416 // Issue involves launcher's DDA getting disabled on a long
418 dragHandleLeftMargin: launcher.available ? launcher.dragAreaWidth + 1 : 0
425 if (!tutorial.running) {
430 onEmergencyCall: startLockedApp("dialer-app")
435 // See powerConnection for why this is useful
436 id: showGreeterDelayed
448 if (greeter.locked && callManager.hasCalls && greeter.lockedApp !== "dialer-app") {
449 // We just received an incoming call while locked. The
450 // indicator will have already launched dialer-app for us, but
451 // there is a race between "hasCalls" changing and the dialer
452 // starting up. So in case we lose that race, we'll start/
453 // focus the dialer ourselves here too. Even if the indicator
454 // didn't launch the dialer for some reason (or maybe a call
455 // started via some other means), if an active call is
456 // happening, we want to be in the dialer.
457 startLockedApp("dialer-app")
467 if (Powerd.status === Powerd.Off && reason !== Powerd.Proximity &&
468 !callManager.hasCalls && !tutorial.running) {
469 // We don't want to simply call greeter.showNow() here, because
470 // that will take too long. Qt will delay button event
471 // handling until the greeter is done loading and may think the
472 // user held down the power button the whole time, leading to a
473 // power dialog being shown. Instead, delay showing the
474 // greeter until we've finished handling the event. We could
475 // make the greeter load asynchronously instead, but that
476 // introduces a whole host of timing issues, especially with
477 // its animations. So this is simpler.
478 showGreeterDelayed.start();
483 function showHome() {
484 if (tutorial.running) {
488 greeter.notifyAboutToFocusApp("unity8-dash");
490 var animate = !lightDM.greeter.active && !stages.shown
491 dash.setCurrentScope(0, animate, false)
492 ApplicationManager.requestFocusApplication("unity8-dash")
495 function showDash() {
496 if (greeter.notifyShowingDashFromDrag()) {
500 if (!greeter.locked && ApplicationManager.focusedApplicationId != "unity8-dash") {
501 ApplicationManager.requestFocusApplication("unity8-dash")
515 anchors.fill: parent //because this draws indicator menus
518 available: tutorial.panelEnabled
519 && ((!greeter || !greeter.locked) || AccountsService.enableIndicatorsWhileLocked)
520 && (!greeter || !greeter.hasLockedApp)
521 contentEnabled: tutorial.panelContentEnabled
522 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
524 minimizedPanelHeight: units.gu(3)
525 expandedPanelHeight: units.gu(7)
527 indicatorsModel: Indicators.IndicatorsModel {
528 // tablet and phone both use the same profile
529 profile: shell.usageScenario === "desktop" ? "desktop" : "phone"
530 Component.onCompleted: load();
535 greeterShown: greeter.shown
538 property bool topmostApplicationIsFullscreen:
539 ApplicationManager.focusedApplicationId &&
540 ApplicationManager.findApplication(ApplicationManager.focusedApplicationId).fullscreen
542 fullscreenMode: (topmostApplicationIsFullscreen && !lightDM.greeter.active && launcher.progress == 0)
543 || greeter.hasLockedApp
544 locked: greeter && greeter.active
549 objectName: "launcher"
551 readonly property bool dashSwipe: progress > 0
553 anchors.top: parent.top
554 anchors.topMargin: inverted ? 0 : panel.panelHeight
555 anchors.bottom: parent.bottom
557 dragAreaWidth: shell.edgeSize
558 available: tutorial.launcherEnabled
559 && (!greeter.locked || AccountsService.enableLauncherWhileLocked)
560 && !greeter.hasLockedApp
561 inverted: shell.usageScenario !== "desktop"
562 shadeBackground: !tutorial.running
563 superPressed: physicalKeysMapper.superPressed
564 superTabPressed: physicalKeysMapper.superTabPressed
565 panelWidth: units.gu(launcherSettings.launcherWidth)
566 lockedVisible: shell.usageScenario == "desktop" && !launcherSettings.autohideLauncher
570 schema.id: "com.canonical.Unity8"
573 onShowDashHome: showHome()
575 onDashSwipeChanged: {
577 dash.setCurrentScope(0, false, true)
580 onLauncherApplicationSelected: {
581 if (!tutorial.running) {
582 greeter.notifyAboutToFocusApp(appId);
583 shell.activateApplication(appId)
588 panel.indicators.hide()
593 applicationsDisplayLoader.focus = true;
598 shortcut: Qt.AltModifier | Qt.Key_F1
600 launcher.openForKeyboardNavigation();
604 shortcut: Qt.MetaModifier | Qt.Key_0
606 if (LauncherModel.get(9)) {
607 activateApplication(LauncherModel.get(9).appId);
614 shortcut: Qt.MetaModifier | (Qt.Key_1 + index)
616 if (LauncherModel.get(index)) {
617 activateApplication(LauncherModel.get(index).appId);
628 background: wallpaperResolver.background
630 function unlockWhenDoneWithWizard() {
632 Connectivity.unlockAllModems();
636 Component.onCompleted: unlockWhenDoneWithWizard()
637 onActiveChanged: unlockWhenDoneWithWizard()
641 id: modalNotificationBackground
643 visible: notifications.useModal
656 model: NotificationBackend.Model
658 hasMouse: shell.hasMouse
659 background: wallpaperResolver.background
661 y: topmostIsFullscreen ? 0 : panel.panelHeight
662 height: parent.height - (topmostIsFullscreen ? 0 : panel.panelHeight)
667 when: overlay.width <= units.gu(60)
669 target: notifications
670 anchors.left: parent.left
671 anchors.right: parent.right
676 when: overlay.width > units.gu(60)
678 target: notifications
679 anchors.left: undefined
680 anchors.right: parent.right
682 PropertyChanges { target: notifications; width: units.gu(38) }
690 objectName: "dialogs"
693 usageScenario: shell.usageScenario
695 shutdownFadeOutRectangle.enabled = true;
696 shutdownFadeOutRectangle.visible = true;
697 shutdownFadeOut.start();
702 target: SessionBroadcast
703 onShowHome: showHome()
708 rotationAngle: -shell.orientationAngle
714 visible: shell.hasMouse
715 z: screenGrabber.z + 1
717 onPushedLeftBoundary: {
718 if (buttons === Qt.NoButton) {
719 launcher.pushEdge(amount);
723 onPushedRightBoundary: {
724 if (buttons === Qt.NoButton && applicationsDisplayLoader.item
725 && applicationsDisplayLoader.item.pushRightEdge) {
726 applicationsDisplayLoader.item.pushRightEdge(amount);
732 id: shutdownFadeOutRectangle
739 NumberAnimation on opacity {
744 if (shutdownFadeOutRectangle.enabled && shutdownFadeOutRectangle.visible) {
745 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