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
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
47 // to be set from outside
48 property int orientationAngle: 0
49 property int orientation
50 property int primaryOrientation
51 property int nativeOrientation
52 property real nativeWidth
53 property real nativeHeight
54 property alias indicatorAreaShowProgress: panel.indicatorAreaShowProgress
55 property bool beingResized
56 property string usageScenario: "phone" // supported values: "phone", "tablet" or "desktop"
57 function updateFocusedAppOrientation() {
58 applicationsDisplayLoader.item.updateFocusedAppOrientation();
60 function updateFocusedAppOrientationAnimated() {
61 applicationsDisplayLoader.item.updateFocusedAppOrientationAnimated();
64 // to be read from outside
65 readonly property int mainAppWindowOrientationAngle:
66 applicationsDisplayLoader.item ? applicationsDisplayLoader.item.mainAppWindowOrientationAngle : 0
68 readonly property bool orientationChangesEnabled: panel.indicators.fullyClosed
69 && (applicationsDisplayLoader.item && applicationsDisplayLoader.item.orientationChangesEnabled)
72 readonly property bool showingGreeter: greeter.shown
74 property bool startingUp: true
75 Timer { id: finishStartUpTimer; interval: 500; onTriggered: startingUp = false }
77 property int supportedOrientations: {
79 // Ensure we don't rotate during start up
80 return Qt.PrimaryOrientation;
81 } else if (greeter.shown) {
82 return Qt.PrimaryOrientation;
84 return mainApp.supportedOrientations;
87 return Qt.PortraitOrientation
88 | Qt.LandscapeOrientation
89 | Qt.InvertedPortraitOrientation
90 | Qt.InvertedLandscapeOrientation;
94 // For autopilot consumption
95 readonly property string focusedApplicationId: ApplicationManager.focusedApplicationId
97 // internal props from here onwards
98 readonly property var mainApp:
99 applicationsDisplayLoader.item ? applicationsDisplayLoader.item.mainApp : null
101 // Disable everything while greeter is waiting, so that the user can't swipe
102 // the greeter or launcher until we know whether the session is locked.
103 enabled: !greeter.waiting
105 property real edgeSize: units.gu(2)
106 property url defaultBackground: Qt.resolvedUrl(shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg")
107 property url background: asImageTester.status == Image.Ready ? asImageTester.source
108 : gsImageTester.status == Image.Ready ? gsImageTester.source : defaultBackground
110 // This is _only_ used to expose the property to autopilot tests
111 readonly property string testShellMode: shellMode
113 readonly property alias greeter: greeterLoader.item
115 function activateApplication(appId) {
116 if (ApplicationManager.findApplication(appId)) {
117 ApplicationManager.requestFocusApplication(appId);
119 var execFlags = shell.usageScenario === "phone" ? ApplicationManager.ForceMainStage
120 : ApplicationManager.NoFlag;
121 ApplicationManager.startApplication(appId, execFlags);
125 function startLockedApp(app) {
126 if (greeter.locked) {
127 greeter.lockedApp = app;
129 shell.activateApplication(app);
132 // This is a dummy image to detect if the custom AS set wallpaper loads successfully.
135 source: AccountsService.backgroundFile != undefined && AccountsService.backgroundFile.length > 0 ? AccountsService.backgroundFile : ""
143 id: backgroundSettings
144 schema.id: "org.gnome.desktop.background"
147 // This is a dummy image to detect if the custom GSettings set wallpaper loads successfully.
150 source: backgroundSettings.pictureUri != undefined && backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : ""
158 target: LauncherModel
159 property: "applicationManager"
160 value: ApplicationManager
163 Component.onCompleted: {
164 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
165 if (ApplicationManager.count > 0) {
166 ApplicationManager.focusApplication(ApplicationManager.get(0).appId);
168 finishStartUpTimer.start();
171 LightDM{id: lightDM} // Provide backend access
178 objectName: "dashCommunicator"
182 id: physicalKeysMapper
184 onPowerKeyLongPressed: dialogs.showPowerDialog()
185 onVolumeDownTriggered: volumeControl.volumeDown();
186 onVolumeUpTriggered: volumeControl.volumeUp();
187 onScreenshotTriggered: screenGrabber.capture();
193 enabled: Powerd.status === Powerd.On
197 target: ApplicationManager
198 property: "forceDashActive"
199 value: launcher.shown || launcher.dashSwipe
203 Keys.onPressed: physicalKeysMapper.onKeyPressed(event);
204 Keys.onReleased: physicalKeysMapper.onKeyReleased(event);
208 onActivated: { launcher.fadeOut(); shell.showHome(); }
215 height: parent.height
218 target: ApplicationManager
220 // This signal is also fired when we try to focus the current app
221 // again. We rely on this!
222 onFocusedApplicationIdChanged: {
223 var appId = ApplicationManager.focusedApplicationId;
225 if (tutorial.running && appId != "" && appId != "unity8-dash") {
226 // If this happens on first boot, we may be in edge
227 // tutorial or wizard while receiving a call. But a call
228 // is more important than wizard so just bail out of those.
233 if (appId === "dialer-app" && callManager.hasCalls && greeter.locked) {
234 // If we are in the middle of a call, make dialer lockedApp and show it.
235 // This can happen if user backs out of dialer back to greeter, then
236 // launches dialer again.
237 greeter.lockedApp = appId;
239 greeter.notifyAppFocused(appId);
241 panel.indicators.hide();
244 onApplicationAdded: {
250 id: applicationsDisplayLoader
251 objectName: "applicationsDisplayLoader"
254 // When we have a locked app, we only want to show that one app.
255 // FIXME: do this in a less traumatic way. We currently only allow
256 // locked apps in phone mode (see FIXME in Lockscreen component in
257 // this same file). When that changes, we need to do something
258 // nicer here. But this code is currently just to prevent a
259 // theoretical attack where user enters lockedApp mode, then makes
260 // the screen larger (maybe connects to monitor) and tries to enter
263 property string usageScenario: shell.usageScenario === "phone" || greeter.hasLockedApp
265 : shell.usageScenario
267 if(shellMode === "greeter") {
268 return "Stages/ShimStage.qml"
269 } else if (applicationsDisplayLoader.usageScenario === "phone") {
270 return "Stages/PhoneStage.qml";
271 } else if (applicationsDisplayLoader.usageScenario === "tablet") {
272 return "Stages/TabletStage.qml";
274 return "Stages/DesktopStage.qml";
278 property bool interactive: tutorial.spreadEnabled
280 && panel.indicators.fullyClosed
281 && launcher.progress == 0
282 && !notifications.useModal
284 onInteractiveChanged: { if (interactive) { focus = true; } }
287 target: applicationsDisplayLoader.item
288 property: "objectName"
292 target: applicationsDisplayLoader.item
293 property: "dragAreaWidth"
294 value: shell.edgeSize
297 target: applicationsDisplayLoader.item
298 property: "maximizedAppTopMargin"
299 // Not just using panel.panelHeight as that changes depending on the focused app.
300 value: panel.indicators.minimizedPanelHeight + units.dp(2) // dp(2) for orange line
303 target: applicationsDisplayLoader.item
304 property: "interactive"
305 value: applicationsDisplayLoader.interactive
308 target: applicationsDisplayLoader.item
309 property: "spreadEnabled"
310 value: tutorial.spreadEnabled && !greeter.hasLockedApp
313 target: applicationsDisplayLoader.item
314 property: "inverseProgress"
315 value: greeter.locked ? 0 : launcher.progress
318 target: applicationsDisplayLoader.item
319 property: "shellOrientationAngle"
320 value: shell.orientationAngle
323 target: applicationsDisplayLoader.item
324 property: "shellOrientation"
325 value: shell.orientation
328 target: applicationsDisplayLoader.item
329 property: "background"
330 value: shell.background
333 target: applicationsDisplayLoader.item
334 property: "shellPrimaryOrientation"
335 value: shell.primaryOrientation
338 target: applicationsDisplayLoader.item
339 property: "nativeOrientation"
340 value: shell.nativeOrientation
343 target: applicationsDisplayLoader.item
344 property: "nativeWidth"
345 value: shell.nativeWidth
348 target: applicationsDisplayLoader.item
349 property: "nativeHeight"
350 value: shell.nativeHeight
353 target: applicationsDisplayLoader.item
354 property: "beingResized"
355 value: shell.beingResized
361 objectName: "tutorial"
363 active: AccountsService.demoEdges
364 paused: lightDM.greeter.active
367 edgeSize: shell.edgeSize
369 // EdgeDragAreas don't work with mice. So to avoid trapping the user,
370 // we'll tell the tutorial to avoid using them on the Desktop. The
371 // Desktop doesn't use the same spread design anyway. The tutorial is
372 // all a bit of a placeholder on non-phone form factors right now.
373 // When the design team gives us more guidance, we can do something
375 // TODO: use DeviceConfiguration instead of checking source
376 useEdgeDragArea: applicationsDisplayLoader.source != Qt.resolvedUrl("Stages/DesktopStage.qml")
379 AccountsService.demoEdges = false;
380 active = false; // for immediate response / if AS is having problems
387 objectName: "inputMethod"
388 anchors { fill: parent; topMargin: panel.panelHeight }
389 z: notifications.useModal || panel.indicators.shown || wizard.active ? overlay.z + 1 : overlay.z - 1
393 target: SurfaceManager
395 if (surface.type == MirSurfaceItem.InputMethod) {
396 inputMethod.surface = surface;
400 onSurfaceDestroyed: {
401 if (inputMethod.surface == surface) {
402 inputMethod.surface = null;
403 surface.parent = null;
405 if (!surface.parent) {
406 // there's no one displaying it. delete it right away
412 target: SessionManager
414 if (!session.parentSession && !session.application) {
415 // nothing is using it. delete it right away
424 anchors.topMargin: panel.panelHeight
425 sourceComponent: shellMode != "shell" ? integratedGreeter :
426 Qt.createComponent(Qt.resolvedUrl("Greeter/ShimGreeter.qml"));
428 item.objectName = "greeter"
433 id: integratedGreeter
436 hides: [launcher, panel.indicators]
437 tabletMode: shell.sideStageEnabled
438 launcherOffset: launcher.progress
439 forcedUnlock: tutorial.running
440 background: shell.background
442 // avoid overlapping with Launcher's edge drag area
443 // FIXME: Fix TouchRegistry & friends and remove this workaround
444 // Issue involves launcher's DDA getting disabled on a long
446 dragHandleLeftMargin: launcher.available ? launcher.dragAreaWidth + 1 : 0
453 if (!tutorial.running) {
458 onEmergencyCall: startLockedApp("dialer-app")
461 target: ApplicationManager
462 property: "suspended"
469 // See powerConnection for why this is useful
470 id: showGreeterDelayed
482 if (greeter.locked && callManager.hasCalls && greeter.lockedApp !== "dialer-app") {
483 // We just received an incoming call while locked. The
484 // indicator will have already launched dialer-app for us, but
485 // there is a race between "hasCalls" changing and the dialer
486 // starting up. So in case we lose that race, we'll start/
487 // focus the dialer ourselves here too. Even if the indicator
488 // didn't launch the dialer for some reason (or maybe a call
489 // started via some other means), if an active call is
490 // happening, we want to be in the dialer.
491 startLockedApp("dialer-app")
501 if (Powerd.status === Powerd.Off && reason !== Powerd.Proximity &&
502 !callManager.hasCalls && !tutorial.running) {
503 // We don't want to simply call greeter.showNow() here, because
504 // that will take too long. Qt will delay button event
505 // handling until the greeter is done loading and may think the
506 // user held down the power button the whole time, leading to a
507 // power dialog being shown. Instead, delay showing the
508 // greeter until we've finished handling the event. We could
509 // make the greeter load asynchronously instead, but that
510 // introduces a whole host of timing issues, especially with
511 // its animations. So this is simpler.
512 showGreeterDelayed.start();
517 function showHome() {
518 if (tutorial.running) {
522 greeter.notifyAboutToFocusApp("unity8-dash");
524 var animate = !lightDM.greeter.active && !stages.shown
525 dash.setCurrentScope(0, animate, false)
526 ApplicationManager.requestFocusApplication("unity8-dash")
529 function showDash() {
530 if (greeter.notifyShowingDashFromDrag()) {
534 if (!greeter.locked && ApplicationManager.focusedApplicationId != "unity8-dash") {
535 ApplicationManager.requestFocusApplication("unity8-dash")
549 anchors.fill: parent //because this draws indicator menus
552 available: tutorial.panelEnabled
553 && (!greeter.locked || AccountsService.enableIndicatorsWhileLocked)
554 && !greeter.hasLockedApp
555 contentEnabled: tutorial.panelContentEnabled
556 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
558 minimizedPanelHeight: units.gu(3)
559 expandedPanelHeight: units.gu(7)
561 indicatorsModel: Indicators.IndicatorsModel {
562 // tablet and phone both use the same profile
563 profile: shell.usageScenario === "desktop" ? "desktop" : "phone"
564 Component.onCompleted: load();
569 greeterShown: greeter.shown
572 property bool mainAppIsFullscreen: shell.mainApp && shell.mainApp.fullscreen
573 fullscreenMode: (mainAppIsFullscreen && !LightDM.Greeter.active && launcher.progress == 0)
574 || greeter.hasLockedApp
579 objectName: "launcher"
581 readonly property bool dashSwipe: progress > 0
583 anchors.top: parent.top
584 anchors.topMargin: inverted ? 0 : panel.panelHeight
585 anchors.bottom: parent.bottom
587 dragAreaWidth: shell.edgeSize
588 available: tutorial.launcherEnabled
589 && (!greeter.locked || AccountsService.enableLauncherWhileLocked)
590 && !greeter.hasLockedApp
591 inverted: shell.usageScenario !== "desktop"
592 shadeBackground: !tutorial.running
594 onShowDashHome: showHome()
596 onDashSwipeChanged: {
598 dash.setCurrentScope(0, false, true)
601 onLauncherApplicationSelected: {
602 if (!tutorial.running) {
603 greeter.notifyAboutToFocusApp(appId);
604 shell.activateApplication(appId)
609 panel.indicators.hide()
618 background: shell.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
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"
682 shutdownFadeOutRectangle.enabled = true;
683 shutdownFadeOutRectangle.visible = true;
684 shutdownFadeOut.start();
689 target: SessionBroadcast
690 onShowHome: showHome()
694 id: shutdownFadeOutRectangle
695 z: screenGrabber.z + 10
701 NumberAnimation on opacity {
706 if (shutdownFadeOutRectangle.enabled && shutdownFadeOutRectangle.visible) {
707 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