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.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
28import 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
49 // to be set from outside
50 property int orientationAngle: 0
51 property int orientation
52 property int primaryOrientation
53 property int nativeOrientation
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 function updateFocusedAppOrientation() {
61 applicationsDisplayLoader.item.updateFocusedAppOrientation();
63 function updateFocusedAppOrientationAnimated() {
64 applicationsDisplayLoader.item.updateFocusedAppOrientationAnimated();
66 property bool hasMouse
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;
88 return mainApp.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)
110 property url defaultBackground: Qt.resolvedUrl(shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg")
111 property url background: asImageTester.status == Image.Ready ? asImageTester.source
112 : gsImageTester.status == Image.Ready ? gsImageTester.source : defaultBackground
114 readonly property alias greeter: greeterLoader.item
116 function activateApplication(appId) {
117 if (ApplicationManager.findApplication(appId)) {
118 ApplicationManager.requestFocusApplication(appId);
120 var execFlags = shell.usageScenario === "phone" ? ApplicationManager.ForceMainStage
121 : ApplicationManager.NoFlag;
122 ApplicationManager.startApplication(appId, execFlags);
126 function startLockedApp(app) {
127 if (greeter.locked) {
128 greeter.lockedApp = app;
130 shell.activateApplication(app);
133 // This is a dummy image to detect if the custom AS set wallpaper loads successfully.
136 source: AccountsService.backgroundFile != undefined && AccountsService.backgroundFile.length > 0 ? AccountsService.backgroundFile : ""
144 id: backgroundSettings
145 schema.id: "org.gnome.desktop.background"
148 // This is a dummy image to detect if the custom GSettings set wallpaper loads successfully.
151 source: backgroundSettings.pictureUri && backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : ""
159 target: LauncherModel
160 property: "applicationManager"
161 value: ApplicationManager
164 Component.onCompleted: {
165 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
166 if (ApplicationManager.count > 0) {
167 ApplicationManager.focusApplication(ApplicationManager.get(0).appId);
169 finishStartUpTimer.start();
172 LightDM{id: lightDM} // Provide backend access
175 indicators: panel.indicators
180 objectName: "dashCommunicator"
184 id: physicalKeysMapper
185 objectName: "physicalKeysMapper"
187 onPowerKeyLongPressed: dialogs.showPowerDialog();
188 onVolumeDownTriggered: volumeControl.volumeDown();
189 onVolumeUpTriggered: volumeControl.volumeUp();
190 onScreenshotTriggered: screenGrabber.capture();
199 // dummy shortcut to force creation of GlobalShortcutRegistry before WindowKeyFilter
203 Keys.onPressed: physicalKeysMapper.onKeyPressed(event);
204 Keys.onReleased: physicalKeysMapper.onKeyReleased(event);
208 onActivated: { launcher.fadeOut(); shell.showHome(); }
215 height: parent.height
218 id: lifecycleExceptions
219 schema.id: "com.canonical.qtmir"
222 // Used by stage code
223 function isExemptFromLifecycle(appId) {
224 var shortAppId = appId.split('_')[0];
225 for (var i = 0; i < lifecycleExceptions.lifecycleExemptAppids.length; i++) {
226 if (shortAppId === lifecycleExceptions.lifecycleExemptAppids[i]) {
234 target: ApplicationManager
236 // This signal is also fired when we try to focus the current app
237 // again. We rely on this!
238 onFocusedApplicationIdChanged: {
239 var appId = ApplicationManager.focusedApplicationId;
241 if (tutorial.running && appId != "" && appId != "unity8-dash") {
242 // If this happens on first boot, we may be in edge
243 // tutorial or wizard while receiving a call. But a call
244 // is more important than wizard so just bail out of those.
249 if (appId === "dialer-app" && callManager.hasCalls && greeter.locked) {
250 // If we are in the middle of a call, make dialer lockedApp and show it.
251 // This can happen if user backs out of dialer back to greeter, then
252 // launches dialer again.
253 greeter.lockedApp = appId;
255 greeter.notifyAppFocused(appId);
257 panel.indicators.hide();
260 onApplicationAdded: {
266 id: applicationsDisplayLoader
267 objectName: "applicationsDisplayLoader"
270 // When we have a locked app, we only want to show that one app.
271 // FIXME: do this in a less traumatic way. We currently only allow
272 // locked apps in phone mode (see FIXME in Lockscreen component in
273 // this same file). When that changes, we need to do something
274 // nicer here. But this code is currently just to prevent a
275 // theoretical attack where user enters lockedApp mode, then makes
276 // the screen larger (maybe connects to monitor) and tries to enter
279 property string usageScenario: shell.usageScenario === "phone" || greeter.hasLockedApp
281 : shell.usageScenario
283 if(shell.mode === "greeter") {
284 return "Stages/ShimStage.qml"
285 } else if (applicationsDisplayLoader.usageScenario === "phone") {
286 return "Stages/PhoneStage.qml";
287 } else if (applicationsDisplayLoader.usageScenario === "tablet") {
288 return "Stages/TabletStage.qml";
290 return "Stages/DesktopStage.qml";
294 property bool interactive: tutorial.spreadEnabled
295 && (!greeter || !greeter.shown)
296 && panel.indicators.fullyClosed
297 && launcher.progress == 0
298 && !notifications.useModal
300 onInteractiveChanged: { if (interactive) { focus = true; } }
303 target: applicationsDisplayLoader.item
304 property: "objectName"
308 target: applicationsDisplayLoader.item
309 property: "dragAreaWidth"
310 value: shell.edgeSize
313 target: applicationsDisplayLoader.item
314 property: "maximizedAppTopMargin"
315 // Not just using panel.panelHeight as that changes depending on the focused app.
316 value: panel.indicators.minimizedPanelHeight + units.dp(2) // dp(2) for orange line
319 target: applicationsDisplayLoader.item
320 property: "interactive"
321 value: applicationsDisplayLoader.interactive
324 target: applicationsDisplayLoader.item
325 property: "spreadEnabled"
326 value: tutorial.spreadEnabled && (!greeter || (!greeter.hasLockedApp && !greeter.shown))
329 target: applicationsDisplayLoader.item
330 property: "inverseProgress"
331 value: greeter && greeter.locked ? 0 : launcher.progress
334 target: applicationsDisplayLoader.item
335 property: "shellOrientationAngle"
336 value: shell.orientationAngle
339 target: applicationsDisplayLoader.item
340 property: "shellOrientation"
341 value: shell.orientation
344 target: applicationsDisplayLoader.item
345 property: "background"
346 value: shell.background
349 target: applicationsDisplayLoader.item
350 property: "shellPrimaryOrientation"
351 value: shell.primaryOrientation
354 target: applicationsDisplayLoader.item
355 property: "nativeOrientation"
356 value: shell.nativeOrientation
359 target: applicationsDisplayLoader.item
360 property: "nativeWidth"
361 value: shell.nativeWidth
364 target: applicationsDisplayLoader.item
365 property: "nativeHeight"
366 value: shell.nativeHeight
369 target: applicationsDisplayLoader.item
370 property: "beingResized"
371 value: shell.beingResized
374 target: applicationsDisplayLoader.item
375 property: "keepDashRunning"
376 value: launcher.shown || launcher.dashSwipe
379 target: applicationsDisplayLoader.item
380 property: "suspended"
384 target: applicationsDisplayLoader.item
385 property: "altTabPressed"
386 value: physicalKeysMapper.altTabPressed
392 objectName: "tutorial"
395 // EdgeDragAreas don't work with mice. So to avoid trapping the user,
396 // we skip the tutorial on the Desktop to avoid using them. The
397 // Desktop doesn't use the same spread design anyway. The tutorial is
398 // all a bit of a placeholder on non-phone form factors right now.
399 // When the design team gives us more guidance, we can do something
401 active: usageScenario != "desktop" && AccountsService.demoEdges
403 paused: lightDM.greeter.active
406 edgeSize: shell.edgeSize
409 AccountsService.demoEdges = false;
410 active = false; // for immediate response / if AS is having problems
417 objectName: "inputMethod"
418 anchors { fill: parent; topMargin: panel.panelHeight }
419 z: notifications.useModal || panel.indicators.shown || wizard.active ? overlay.z + 1 : overlay.z - 1
423 target: SessionManager
425 if (!session.parentSession && !session.application) {
426 // nothing is using it. delete it right away
435 anchors.topMargin: panel.panelHeight
436 sourceComponent: shell.mode != "shell" ? integratedGreeter :
437 Qt.createComponent(Qt.resolvedUrl("Greeter/ShimGreeter.qml"));
439 item.objectName = "greeter"
444 id: integratedGreeter
447 hides: [launcher, panel.indicators]
448 tabletMode: shell.usageScenario != "phone"
449 launcherOffset: launcher.progress
450 forcedUnlock: tutorial.running
451 background: shell.background
453 // avoid overlapping with Launcher's edge drag area
454 // FIXME: Fix TouchRegistry & friends and remove this workaround
455 // Issue involves launcher's DDA getting disabled on a long
457 dragHandleLeftMargin: launcher.available ? launcher.dragAreaWidth + 1 : 0
464 if (!tutorial.running) {
469 onEmergencyCall: startLockedApp("dialer-app")
474 // See powerConnection for why this is useful
475 id: showGreeterDelayed
487 if (greeter.locked && callManager.hasCalls && greeter.lockedApp !== "dialer-app") {
488 // We just received an incoming call while locked. The
489 // indicator will have already launched dialer-app for us, but
490 // there is a race between "hasCalls" changing and the dialer
491 // starting up. So in case we lose that race, we'll start/
492 // focus the dialer ourselves here too. Even if the indicator
493 // didn't launch the dialer for some reason (or maybe a call
494 // started via some other means), if an active call is
495 // happening, we want to be in the dialer.
496 startLockedApp("dialer-app")
506 if (Powerd.status === Powerd.Off && reason !== Powerd.Proximity &&
507 !callManager.hasCalls && !tutorial.running) {
508 // We don't want to simply call greeter.showNow() here, because
509 // that will take too long. Qt will delay button event
510 // handling until the greeter is done loading and may think the
511 // user held down the power button the whole time, leading to a
512 // power dialog being shown. Instead, delay showing the
513 // greeter until we've finished handling the event. We could
514 // make the greeter load asynchronously instead, but that
515 // introduces a whole host of timing issues, especially with
516 // its animations. So this is simpler.
517 showGreeterDelayed.start();
522 function showHome() {
523 if (tutorial.running) {
527 greeter.notifyAboutToFocusApp("unity8-dash");
529 var animate = !lightDM.greeter.active && !stages.shown
530 dash.setCurrentScope(0, animate, false)
531 ApplicationManager.requestFocusApplication("unity8-dash")
534 function showDash() {
535 if (greeter.notifyShowingDashFromDrag()) {
539 if (!greeter.locked && ApplicationManager.focusedApplicationId != "unity8-dash") {
540 ApplicationManager.requestFocusApplication("unity8-dash")
554 anchors.fill: parent //because this draws indicator menus
557 available: tutorial.panelEnabled
558 && ((!greeter || !greeter.locked) || AccountsService.enableIndicatorsWhileLocked)
559 && (!greeter || !greeter.hasLockedApp)
560 contentEnabled: tutorial.panelContentEnabled
561 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
563 minimizedPanelHeight: units.gu(3)
564 expandedPanelHeight: units.gu(7)
566 indicatorsModel: Indicators.IndicatorsModel {
567 // tablet and phone both use the same profile
568 profile: shell.usageScenario === "desktop" ? "desktop" : "phone"
569 Component.onCompleted: load();
574 greeterShown: greeter.shown
577 property bool topmostApplicationIsFullscreen:
578 ApplicationManager.focusedApplicationId &&
579 ApplicationManager.findApplication(ApplicationManager.focusedApplicationId).fullscreen
581 fullscreenMode: (topmostApplicationIsFullscreen && !lightDM.greeter.active && launcher.progress == 0)
582 || greeter.hasLockedApp
587 objectName: "launcher"
589 readonly property bool dashSwipe: progress > 0
591 anchors.top: parent.top
592 anchors.topMargin: inverted ? 0 : panel.panelHeight
593 anchors.bottom: parent.bottom
595 dragAreaWidth: shell.edgeSize
596 available: tutorial.launcherEnabled
597 && (!greeter.locked || AccountsService.enableLauncherWhileLocked)
598 && !greeter.hasLockedApp
599 inverted: shell.usageScenario !== "desktop"
600 shadeBackground: !tutorial.running
602 onShowDashHome: showHome()
604 onDashSwipeChanged: {
606 dash.setCurrentScope(0, false, true)
609 onLauncherApplicationSelected: {
610 if (!tutorial.running) {
611 greeter.notifyAboutToFocusApp(appId);
612 shell.activateApplication(appId)
617 panel.indicators.hide()
626 background: shell.background
628 function unlockWhenDoneWithWizard() {
630 Connectivity.unlockAllModems();
634 Component.onCompleted: unlockWhenDoneWithWizard()
635 onActiveChanged: unlockWhenDoneWithWizard()
639 id: modalNotificationBackground
641 visible: notifications.useModal
654 model: NotificationBackend.Model
656 hasMouse: shell.hasMouse
658 y: topmostIsFullscreen ? 0 : panel.panelHeight
659 height: parent.height - (topmostIsFullscreen ? 0 : panel.panelHeight)
664 when: overlay.width <= units.gu(60)
666 target: notifications
667 anchors.left: parent.left
668 anchors.right: parent.right
673 when: overlay.width > units.gu(60)
675 target: notifications
676 anchors.left: undefined
677 anchors.right: parent.right
679 PropertyChanges { target: notifications; width: units.gu(38) }
687 objectName: "dialogs"
690 usageScenario: shell.usageScenario
692 shutdownFadeOutRectangle.enabled = true;
693 shutdownFadeOutRectangle.visible = true;
694 shutdownFadeOut.start();
699 target: SessionBroadcast
700 onShowHome: showHome()
704 id: shutdownFadeOutRectangle
705 z: screenGrabber.z + 10
711 NumberAnimation on opacity {
716 if (shutdownFadeOutRectangle.enabled && shutdownFadeOutRectangle.visible) {
717 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