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 function isExemptFromLifecycle(appId) {
223 for (var i = 0; i < lifecycleExceptions.lifecycleExemptAppids.length; i++) {
224 if (appId === lifecycleExceptions.lifecycleExemptAppids[i]) {
232 target: ApplicationManager
234 // This signal is also fired when we try to focus the current app
235 // again. We rely on this!
236 onFocusedApplicationIdChanged: {
237 var appId = ApplicationManager.focusedApplicationId;
239 if (tutorial.running && appId != "" && appId != "unity8-dash") {
240 // If this happens on first boot, we may be in edge
241 // tutorial or wizard while receiving a call. But a call
242 // is more important than wizard so just bail out of those.
247 if (appId === "dialer-app" && callManager.hasCalls && greeter.locked) {
248 // If we are in the middle of a call, make dialer lockedApp and show it.
249 // This can happen if user backs out of dialer back to greeter, then
250 // launches dialer again.
251 greeter.lockedApp = appId;
253 greeter.notifyAppFocused(appId);
255 panel.indicators.hide();
258 onApplicationAdded: {
261 // Apply lifecycle policy when an app is opened
262 var app = ApplicationManager.findApplication(appId);
264 // We don't bother with a Qt.binding because isTouchApp is
265 // marked as CONSTANT by unity-api, and we neither expect
266 // the gsettings to change on us during the life of the app,
267 // nor does it make a whole lot of sense to adjust the
268 // lifecycle policy while the app is running.
269 app.canSuspend = app.isTouchApp && !stages.isExemptFromLifecycle(appId);
275 id: applicationsDisplayLoader
276 objectName: "applicationsDisplayLoader"
279 // When we have a locked app, we only want to show that one app.
280 // FIXME: do this in a less traumatic way. We currently only allow
281 // locked apps in phone mode (see FIXME in Lockscreen component in
282 // this same file). When that changes, we need to do something
283 // nicer here. But this code is currently just to prevent a
284 // theoretical attack where user enters lockedApp mode, then makes
285 // the screen larger (maybe connects to monitor) and tries to enter
288 property string usageScenario: shell.usageScenario === "phone" || greeter.hasLockedApp
290 : shell.usageScenario
292 if(shell.mode === "greeter") {
293 return "Stages/ShimStage.qml"
294 } else if (applicationsDisplayLoader.usageScenario === "phone") {
295 return "Stages/PhoneStage.qml";
296 } else if (applicationsDisplayLoader.usageScenario === "tablet") {
297 return "Stages/TabletStage.qml";
299 return "Stages/DesktopStage.qml";
303 property bool interactive: tutorial.spreadEnabled
304 && (!greeter || !greeter.shown)
305 && panel.indicators.fullyClosed
306 && launcher.progress == 0
307 && !notifications.useModal
309 onInteractiveChanged: { if (interactive) { focus = true; } }
312 target: applicationsDisplayLoader.item
313 property: "objectName"
317 target: applicationsDisplayLoader.item
318 property: "dragAreaWidth"
319 value: shell.edgeSize
322 target: applicationsDisplayLoader.item
323 property: "maximizedAppTopMargin"
324 // Not just using panel.panelHeight as that changes depending on the focused app.
325 value: panel.indicators.minimizedPanelHeight + units.dp(2) // dp(2) for orange line
328 target: applicationsDisplayLoader.item
329 property: "interactive"
330 value: applicationsDisplayLoader.interactive
333 target: applicationsDisplayLoader.item
334 property: "spreadEnabled"
335 value: tutorial.spreadEnabled && (!greeter || (!greeter.hasLockedApp && !greeter.shown))
338 target: applicationsDisplayLoader.item
339 property: "inverseProgress"
340 value: greeter && greeter.locked ? 0 : launcher.progress
343 target: applicationsDisplayLoader.item
344 property: "shellOrientationAngle"
345 value: shell.orientationAngle
348 target: applicationsDisplayLoader.item
349 property: "shellOrientation"
350 value: shell.orientation
353 target: applicationsDisplayLoader.item
354 property: "background"
355 value: shell.background
358 target: applicationsDisplayLoader.item
359 property: "shellPrimaryOrientation"
360 value: shell.primaryOrientation
363 target: applicationsDisplayLoader.item
364 property: "nativeOrientation"
365 value: shell.nativeOrientation
368 target: applicationsDisplayLoader.item
369 property: "nativeWidth"
370 value: shell.nativeWidth
373 target: applicationsDisplayLoader.item
374 property: "nativeHeight"
375 value: shell.nativeHeight
378 target: applicationsDisplayLoader.item
379 property: "beingResized"
380 value: shell.beingResized
383 target: applicationsDisplayLoader.item
384 property: "keepDashRunning"
385 value: launcher.shown || launcher.dashSwipe
388 target: applicationsDisplayLoader.item
389 property: "suspended"
393 target: applicationsDisplayLoader.item
394 property: "altTabPressed"
395 value: physicalKeysMapper.altTabPressed
401 objectName: "tutorial"
404 // EdgeDragAreas don't work with mice. So to avoid trapping the user,
405 // we skip the tutorial on the Desktop to avoid using them. The
406 // Desktop doesn't use the same spread design anyway. The tutorial is
407 // all a bit of a placeholder on non-phone form factors right now.
408 // When the design team gives us more guidance, we can do something
410 active: usageScenario != "desktop" && AccountsService.demoEdges
412 paused: lightDM.greeter.active
415 edgeSize: shell.edgeSize
418 AccountsService.demoEdges = false;
419 active = false; // for immediate response / if AS is having problems
426 objectName: "inputMethod"
427 anchors { fill: parent; topMargin: panel.panelHeight }
428 z: notifications.useModal || panel.indicators.shown || wizard.active ? overlay.z + 1 : overlay.z - 1
432 target: SessionManager
434 if (!session.parentSession && !session.application) {
435 // nothing is using it. delete it right away
444 anchors.topMargin: panel.panelHeight
445 sourceComponent: shell.mode != "shell" ? integratedGreeter :
446 Qt.createComponent(Qt.resolvedUrl("Greeter/ShimGreeter.qml"));
448 item.objectName = "greeter"
453 id: integratedGreeter
456 hides: [launcher, panel.indicators]
457 tabletMode: shell.usageScenario != "phone"
458 launcherOffset: launcher.progress
459 forcedUnlock: tutorial.running
460 background: shell.background
462 // avoid overlapping with Launcher's edge drag area
463 // FIXME: Fix TouchRegistry & friends and remove this workaround
464 // Issue involves launcher's DDA getting disabled on a long
466 dragHandleLeftMargin: launcher.available ? launcher.dragAreaWidth + 1 : 0
473 if (!tutorial.running) {
478 onEmergencyCall: startLockedApp("dialer-app")
483 // See powerConnection for why this is useful
484 id: showGreeterDelayed
496 if (greeter.locked && callManager.hasCalls && greeter.lockedApp !== "dialer-app") {
497 // We just received an incoming call while locked. The
498 // indicator will have already launched dialer-app for us, but
499 // there is a race between "hasCalls" changing and the dialer
500 // starting up. So in case we lose that race, we'll start/
501 // focus the dialer ourselves here too. Even if the indicator
502 // didn't launch the dialer for some reason (or maybe a call
503 // started via some other means), if an active call is
504 // happening, we want to be in the dialer.
505 startLockedApp("dialer-app")
515 if (Powerd.status === Powerd.Off && reason !== Powerd.Proximity &&
516 !callManager.hasCalls && !tutorial.running) {
517 // We don't want to simply call greeter.showNow() here, because
518 // that will take too long. Qt will delay button event
519 // handling until the greeter is done loading and may think the
520 // user held down the power button the whole time, leading to a
521 // power dialog being shown. Instead, delay showing the
522 // greeter until we've finished handling the event. We could
523 // make the greeter load asynchronously instead, but that
524 // introduces a whole host of timing issues, especially with
525 // its animations. So this is simpler.
526 showGreeterDelayed.start();
531 function showHome() {
532 if (tutorial.running) {
536 greeter.notifyAboutToFocusApp("unity8-dash");
538 var animate = !lightDM.greeter.active && !stages.shown
539 dash.setCurrentScope(0, animate, false)
540 ApplicationManager.requestFocusApplication("unity8-dash")
543 function showDash() {
544 if (greeter.notifyShowingDashFromDrag()) {
548 if (!greeter.locked && ApplicationManager.focusedApplicationId != "unity8-dash") {
549 ApplicationManager.requestFocusApplication("unity8-dash")
563 anchors.fill: parent //because this draws indicator menus
566 available: tutorial.panelEnabled
567 && ((!greeter || !greeter.locked) || AccountsService.enableIndicatorsWhileLocked)
568 && (!greeter || !greeter.hasLockedApp)
569 contentEnabled: tutorial.panelContentEnabled
570 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
572 minimizedPanelHeight: units.gu(3)
573 expandedPanelHeight: units.gu(7)
575 indicatorsModel: Indicators.IndicatorsModel {
576 // tablet and phone both use the same profile
577 profile: shell.usageScenario === "desktop" ? "desktop" : "phone"
578 Component.onCompleted: load();
583 greeterShown: greeter.shown
586 property bool topmostApplicationIsFullscreen:
587 ApplicationManager.focusedApplicationId &&
588 ApplicationManager.findApplication(ApplicationManager.focusedApplicationId).fullscreen
590 fullscreenMode: (topmostApplicationIsFullscreen && !lightDM.greeter.active && launcher.progress == 0)
591 || greeter.hasLockedApp
596 objectName: "launcher"
598 readonly property bool dashSwipe: progress > 0
600 anchors.top: parent.top
601 anchors.topMargin: inverted ? 0 : panel.panelHeight
602 anchors.bottom: parent.bottom
604 dragAreaWidth: shell.edgeSize
605 available: tutorial.launcherEnabled
606 && (!greeter.locked || AccountsService.enableLauncherWhileLocked)
607 && !greeter.hasLockedApp
608 inverted: shell.usageScenario !== "desktop"
609 shadeBackground: !tutorial.running
611 onShowDashHome: showHome()
613 onDashSwipeChanged: {
615 dash.setCurrentScope(0, false, true)
618 onLauncherApplicationSelected: {
619 if (!tutorial.running) {
620 greeter.notifyAboutToFocusApp(appId);
621 shell.activateApplication(appId)
626 panel.indicators.hide()
635 background: shell.background
637 function unlockWhenDoneWithWizard() {
639 Connectivity.unlockAllModems();
643 Component.onCompleted: unlockWhenDoneWithWizard()
644 onActiveChanged: unlockWhenDoneWithWizard()
648 id: modalNotificationBackground
650 visible: notifications.useModal
663 model: NotificationBackend.Model
665 hasMouse: shell.hasMouse
667 y: topmostIsFullscreen ? 0 : panel.panelHeight
668 height: parent.height - (topmostIsFullscreen ? 0 : panel.panelHeight)
673 when: overlay.width <= units.gu(60)
675 target: notifications
676 anchors.left: parent.left
677 anchors.right: parent.right
682 when: overlay.width > units.gu(60)
684 target: notifications
685 anchors.left: undefined
686 anchors.right: parent.right
688 PropertyChanges { target: notifications; width: units.gu(38) }
696 objectName: "dialogs"
699 usageScenario: shell.usageScenario
701 shutdownFadeOutRectangle.enabled = true;
702 shutdownFadeOutRectangle.visible = true;
703 shutdownFadeOut.start();
708 target: SessionBroadcast
709 onShowHome: showHome()
713 id: shutdownFadeOutRectangle
714 z: screenGrabber.z + 10
720 NumberAnimation on opacity {
725 if (shutdownFadeOutRectangle.enabled && shutdownFadeOutRectangle.visible) {
726 DBusUnitySessionService.shutdown();
732 ApplicationsFilterModel {
734 applicationsModel: ApplicationManager
735 filterTouchApps: true
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