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
29import LightDM 0.1 as LightDM
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
48 // to be set from outside
49 property int orientationAngle: 0
50 property int orientation
51 property int primaryOrientation
52 property int nativeOrientation
53 property real nativeWidth
54 property real nativeHeight
55 property alias indicatorAreaShowProgress: panel.indicatorAreaShowProgress
56 property bool beingResized
57 property string usageScenario: "phone" // supported values: "phone", "tablet" or "desktop"
58 function updateFocusedAppOrientation() {
59 applicationsDisplayLoader.item.updateFocusedAppOrientation();
61 function updateFocusedAppOrientationAnimated() {
62 applicationsDisplayLoader.item.updateFocusedAppOrientationAnimated();
65 // to be read from outside
66 readonly property int mainAppWindowOrientationAngle:
67 applicationsDisplayLoader.item ? applicationsDisplayLoader.item.mainAppWindowOrientationAngle : 0
69 readonly property bool orientationChangesEnabled: panel.indicators.fullyClosed
70 && (applicationsDisplayLoader.item && applicationsDisplayLoader.item.orientationChangesEnabled)
73 readonly property bool showingGreeter: greeter.shown
75 property bool startingUp: true
76 Timer { id: finishStartUpTimer; interval: 500; onTriggered: startingUp = false }
78 property int supportedOrientations: {
80 // Ensure we don't rotate during start up
81 return Qt.PrimaryOrientation;
82 } else if (greeter.shown) {
83 return Qt.PrimaryOrientation;
85 return mainApp.supportedOrientations;
88 return Qt.PortraitOrientation
89 | Qt.LandscapeOrientation
90 | Qt.InvertedPortraitOrientation
91 | Qt.InvertedLandscapeOrientation;
95 // For autopilot consumption
96 readonly property string focusedApplicationId: ApplicationManager.focusedApplicationId
98 // internal props from here onwards
99 readonly property var mainApp:
100 applicationsDisplayLoader.item ? applicationsDisplayLoader.item.mainApp : null
102 // Disable everything while greeter is waiting, so that the user can't swipe
103 // the greeter or launcher until we know whether the session is locked.
104 enabled: !greeter.waiting
106 property real edgeSize: units.gu(2)
107 property url defaultBackground: Qt.resolvedUrl(shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg")
108 property url background: asImageTester.status == Image.Ready ? asImageTester.source
109 : gsImageTester.status == Image.Ready ? gsImageTester.source : defaultBackground
111 // This is _only_ used to expose the property to autopilot tests
112 readonly property string testShellMode: shellMode
114 function activateApplication(appId) {
115 if (ApplicationManager.findApplication(appId)) {
116 ApplicationManager.requestFocusApplication(appId);
118 var execFlags = shell.usageScenario === "phone" ? ApplicationManager.ForceMainStage
119 : ApplicationManager.NoFlag;
120 ApplicationManager.startApplication(appId, execFlags);
124 function startLockedApp(app) {
125 if (greeter.locked) {
126 greeter.lockedApp = app;
128 shell.activateApplication(app);
131 // This is a dummy image to detect if the custom AS set wallpaper loads successfully.
134 source: AccountsService.backgroundFile != undefined && AccountsService.backgroundFile.length > 0 ? AccountsService.backgroundFile : ""
142 id: backgroundSettings
143 schema.id: "org.gnome.desktop.background"
146 // This is a dummy image to detect if the custom GSettings set wallpaper loads successfully.
149 source: backgroundSettings.pictureUri != undefined && backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : ""
157 target: LauncherModel
158 property: "applicationManager"
159 value: ApplicationManager
162 Component.onCompleted: {
163 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
164 if (ApplicationManager.count > 0) {
165 ApplicationManager.focusApplication(ApplicationManager.get(0).appId);
167 finishStartUpTimer.start();
176 objectName: "dashCommunicator"
180 id: physicalKeysMapper
182 onPowerKeyLongPressed: dialogs.showPowerDialog()
183 onVolumeDownTriggered: volumeControl.volumeDown();
184 onVolumeUpTriggered: volumeControl.volumeUp();
185 onScreenshotTriggered: screenGrabber.capture();
191 enabled: Powerd.status === Powerd.On
195 target: ApplicationManager
196 property: "forceDashActive"
197 value: launcher.shown || launcher.dashSwipe
201 Keys.onPressed: physicalKeysMapper.onKeyPressed(event);
202 Keys.onReleased: physicalKeysMapper.onKeyReleased(event);
206 onActivated: { launcher.fadeOut(); shell.showHome(); }
213 height: parent.height
216 target: ApplicationManager
218 // This signal is also fired when we try to focus the current app
219 // again. We rely on this!
220 onFocusedApplicationIdChanged: {
221 var appId = ApplicationManager.focusedApplicationId;
223 if (tutorial.running && appId != "" && appId != "unity8-dash") {
224 // If this happens on first boot, we may be in edge
225 // tutorial or wizard while receiving a call. But a call
226 // is more important than wizard so just bail out of those.
231 if (appId === "dialer-app" && callManager.hasCalls && greeter.locked) {
232 // If we are in the middle of a call, make dialer lockedApp and show it.
233 // This can happen if user backs out of dialer back to greeter, then
234 // launches dialer again.
235 greeter.lockedApp = appId;
237 greeter.notifyAppFocused(appId);
239 panel.indicators.hide();
242 onApplicationAdded: {
248 id: applicationsDisplayLoader
249 objectName: "applicationsDisplayLoader"
252 // When we have a locked app, we only want to show that one app.
253 // FIXME: do this in a less traumatic way. We currently only allow
254 // locked apps in phone mode (see FIXME in Lockscreen component in
255 // this same file). When that changes, we need to do something
256 // nicer here. But this code is currently just to prevent a
257 // theoretical attack where user enters lockedApp mode, then makes
258 // the screen larger (maybe connects to monitor) and tries to enter
261 property string usageScenario: shell.usageScenario === "phone" || greeter.hasLockedApp
263 : shell.usageScenario
265 if (applicationsDisplayLoader.usageScenario === "phone") {
266 return "Stages/PhoneStage.qml";
267 } else if (applicationsDisplayLoader.usageScenario === "tablet") {
268 return "Stages/TabletStage.qml";
270 return "Stages/DesktopStage.qml";
274 property bool interactive: tutorial.spreadEnabled
276 && panel.indicators.fullyClosed
277 && launcher.progress == 0
278 && !notifications.useModal
280 onInteractiveChanged: { if (interactive) { focus = true; } }
283 target: applicationsDisplayLoader.item
284 property: "objectName"
288 target: applicationsDisplayLoader.item
289 property: "dragAreaWidth"
290 value: shell.edgeSize
293 target: applicationsDisplayLoader.item
294 property: "maximizedAppTopMargin"
295 // Not just using panel.panelHeight as that changes depending on the focused app.
296 value: panel.indicators.minimizedPanelHeight + units.dp(2) // dp(2) for orange line
299 target: applicationsDisplayLoader.item
300 property: "interactive"
301 value: applicationsDisplayLoader.interactive
304 target: applicationsDisplayLoader.item
305 property: "spreadEnabled"
306 value: tutorial.spreadEnabled && !greeter.hasLockedApp
309 target: applicationsDisplayLoader.item
310 property: "inverseProgress"
311 value: greeter.locked ? 0 : launcher.progress
314 target: applicationsDisplayLoader.item
315 property: "shellOrientationAngle"
316 value: shell.orientationAngle
319 target: applicationsDisplayLoader.item
320 property: "shellOrientation"
321 value: shell.orientation
324 target: applicationsDisplayLoader.item
325 property: "background"
326 value: shell.background
329 target: applicationsDisplayLoader.item
330 property: "shellPrimaryOrientation"
331 value: shell.primaryOrientation
334 target: applicationsDisplayLoader.item
335 property: "nativeOrientation"
336 value: shell.nativeOrientation
339 target: applicationsDisplayLoader.item
340 property: "nativeWidth"
341 value: shell.nativeWidth
344 target: applicationsDisplayLoader.item
345 property: "nativeHeight"
346 value: shell.nativeHeight
349 target: applicationsDisplayLoader.item
350 property: "beingResized"
351 value: shell.beingResized
357 objectName: "tutorial"
359 active: AccountsService.demoEdges
360 paused: LightDM.Greeter.active
363 edgeSize: shell.edgeSize
365 // EdgeDragAreas don't work with mice. So to avoid trapping the user,
366 // we'll tell the tutorial to avoid using them on the Desktop. The
367 // Desktop doesn't use the same spread design anyway. The tutorial is
368 // all a bit of a placeholder on non-phone form factors right now.
369 // When the design team gives us more guidance, we can do something
371 // TODO: use DeviceConfiguration instead of checking source
372 useEdgeDragArea: applicationsDisplayLoader.source != Qt.resolvedUrl("Stages/DesktopStage.qml")
375 AccountsService.demoEdges = false;
376 active = false; // for immediate response / if AS is having problems
383 objectName: "inputMethod"
384 anchors { fill: parent; topMargin: panel.panelHeight }
385 z: notifications.useModal || panel.indicators.shown || wizard.active ? overlay.z + 1 : overlay.z - 1
389 target: SurfaceManager
391 if (surface.type == MirSurfaceItem.InputMethod) {
392 inputMethod.surface = surface;
396 onSurfaceDestroyed: {
397 if (inputMethod.surface == surface) {
398 inputMethod.surface = null;
399 surface.parent = null;
401 if (!surface.parent) {
402 // there's no one displaying it. delete it right away
408 target: SessionManager
410 if (!session.parentSession && !session.application) {
411 // nothing is using it. delete it right away
419 objectName: "greeter"
421 hides: [launcher, panel.indicators]
422 tabletMode: shell.usageScenario !== "phone"
423 launcherOffset: launcher.progress
424 forcedUnlock: tutorial.running
425 background: shell.background
428 anchors.topMargin: panel.panelHeight
430 // avoid overlapping with Launcher's edge drag area
431 // FIXME: Fix TouchRegistry & friends and remove this workaround
432 // Issue involves launcher's DDA getting disabled on a long
434 dragHandleLeftMargin: launcher.available ? launcher.dragAreaWidth + 1 : 0
441 if (!tutorial.running) {
446 onEmergencyCall: startLockedApp("dialer-app")
449 // See powerConnection for why this is useful
450 id: showGreeterDelayed
458 target: ApplicationManager
459 property: "suspended"
469 if (greeter.locked && callManager.hasCalls && greeter.lockedApp !== "dialer-app") {
470 // We just received an incoming call while locked. The
471 // indicator will have already launched dialer-app for us, but
472 // there is a race between "hasCalls" changing and the dialer
473 // starting up. So in case we lose that race, we'll start/
474 // focus the dialer ourselves here too. Even if the indicator
475 // didn't launch the dialer for some reason (or maybe a call
476 // started via some other means), if an active call is
477 // happening, we want to be in the dialer.
478 startLockedApp("dialer-app")
488 if (Powerd.status === Powerd.Off && reason !== Powerd.Proximity &&
489 !callManager.hasCalls && !tutorial.running) {
490 // We don't want to simply call greeter.showNow() here, because
491 // that will take too long. Qt will delay button event
492 // handling until the greeter is done loading and may think the
493 // user held down the power button the whole time, leading to a
494 // power dialog being shown. Instead, delay showing the
495 // greeter until we've finished handling the event. We could
496 // make the greeter load asynchronously instead, but that
497 // introduces a whole host of timing issues, especially with
498 // its animations. So this is simpler.
499 showGreeterDelayed.start();
504 function showHome() {
505 if (tutorial.running) {
509 greeter.notifyAboutToFocusApp("unity8-dash");
511 var animate = !LightDM.Greeter.active && !stages.shown
512 dash.setCurrentScope(0, animate, false)
513 ApplicationManager.requestFocusApplication("unity8-dash")
516 function showDash() {
517 if (greeter.notifyShowingDashFromDrag()) {
521 if (!greeter.locked && ApplicationManager.focusedApplicationId != "unity8-dash") {
522 ApplicationManager.requestFocusApplication("unity8-dash")
536 anchors.fill: parent //because this draws indicator menus
539 available: tutorial.panelEnabled
540 && (!greeter.locked || AccountsService.enableIndicatorsWhileLocked)
541 && !greeter.hasLockedApp
542 contentEnabled: tutorial.panelContentEnabled
543 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
545 minimizedPanelHeight: units.gu(3)
546 expandedPanelHeight: units.gu(7)
548 indicatorsModel: Indicators.IndicatorsModel {
549 // tablet and phone both use the same profile
550 profile: shell.usageScenario === "desktop" ? "desktop" : "phone"
551 Component.onCompleted: load();
556 greeterShown: greeter.shown
559 property bool mainAppIsFullscreen: shell.mainApp && shell.mainApp.fullscreen
560 fullscreenMode: (mainAppIsFullscreen && !LightDM.Greeter.active && launcher.progress == 0)
561 || greeter.hasLockedApp
566 objectName: "launcher"
568 readonly property bool dashSwipe: progress > 0
570 anchors.top: parent.top
571 anchors.topMargin: inverted ? 0 : panel.panelHeight
572 anchors.bottom: parent.bottom
574 dragAreaWidth: shell.edgeSize
575 available: tutorial.launcherEnabled
576 && (!greeter.locked || AccountsService.enableLauncherWhileLocked)
577 && !greeter.hasLockedApp
578 inverted: shell.usageScenario !== "desktop"
579 shadeBackground: !tutorial.running
581 onShowDashHome: showHome()
583 onDashSwipeChanged: {
585 dash.setCurrentScope(0, false, true)
588 onLauncherApplicationSelected: {
589 if (!tutorial.running) {
590 greeter.notifyAboutToFocusApp(appId);
591 shell.activateApplication(appId)
596 panel.indicators.hide()
605 background: shell.background
607 function unlockWhenDoneWithWizard() {
609 Connectivity.unlockAllModems();
613 Component.onCompleted: unlockWhenDoneWithWizard()
614 onActiveChanged: unlockWhenDoneWithWizard()
618 id: modalNotificationBackground
620 visible: notifications.useModal
633 model: NotificationBackend.Model
636 y: topmostIsFullscreen ? 0 : panel.panelHeight
637 height: parent.height - (topmostIsFullscreen ? 0 : panel.panelHeight)
642 when: overlay.width <= units.gu(60)
644 target: notifications
645 anchors.left: parent.left
646 anchors.right: parent.right
651 when: overlay.width > units.gu(60)
653 target: notifications
654 anchors.left: undefined
655 anchors.right: parent.right
657 PropertyChanges { target: notifications; width: units.gu(38) }
665 objectName: "dialogs"
669 shutdownFadeOutRectangle.enabled = true;
670 shutdownFadeOutRectangle.visible = true;
671 shutdownFadeOut.start();
676 target: SessionBroadcast
677 onShowHome: showHome()
681 id: shutdownFadeOutRectangle
682 z: screenGrabber.z + 10
688 NumberAnimation on opacity {
693 if (shutdownFadeOutRectangle.enabled && shutdownFadeOutRectangle.visible) {
694 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