2 * Copyright (C) 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/>.
17#include "ShellApplication.h"
24#include <QQmlComponent>
28// libandroid-properties
29#include <hybris/properties/properties.h>
33#include "CachingNetworkManagerFactory.h"
34#include "UnityCommandLineParser.h"
35#include "DebuggingController.h"
37ShellApplication::ShellApplication(int & argc, char ** argv, bool isMirServer)
38 : QGuiApplication(argc, argv)
41 setApplicationName(QStringLiteral("unity8"));
42 setOrganizationName(QStringLiteral("Canonical"));
44 setupQmlEngine(isMirServer);
46 if (m_qmlArgs.deviceName().isEmpty()) {
48 property_get("ro.product.device", buffer /* value */, "desktop" /* default_value*/);
49 m_qmlArgs.setDeviceName(QString(buffer));
52 // The testability driver is only loaded by QApplication but not by QGuiApplication.
53 // However, QApplication depends on QWidget which would add some unneeded overhead => Let's load the testability driver on our own.
54 if (m_qmlArgs.hasTestability() || getenv("QT_LOAD_TESTABILITY")) {
55 QLibrary testLib(QStringLiteral("qttestability"));
57 typedef void (*TasInitialize)(void);
58 TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init");
62 qCritical("Library qttestability resolve failed!");
65 qCritical("Library qttestability load failed!");
69 bindtextdomain("unity8", translationDirectory().toUtf8().data());
72 m_qmlEngine->rootContext()->setContextProperty(QStringLiteral("applicationArguments"), &m_qmlArgs);
73 m_qmlEngine->rootContext()->setContextProperty("DebuggingController", new DebuggingController(this));
75 QByteArray pxpguEnv = qgetenv("GRID_UNIT_PX");
77 int pxpgu = pxpguEnv.toInt(&ok);
81 m_qmlEngine->rootContext()->setContextProperty("internalGu", pxpgu);
83 auto component(new QQmlComponent(m_qmlEngine,
84 QUrl::fromLocalFile(::qmlDirectory() + "/ShellApplication.qml")));
86 if (component->status() == QQmlComponent::Error) {
87 m_qmlEngine->rootContext()->setContextProperty(QStringLiteral("errorString"), component->errorString());
88 auto errorComponent(new QQmlComponent(m_qmlEngine,
89 QUrl::fromLocalFile(::qmlDirectory() + "/ErrorApplication.qml")));
90 errorComponent->create();
91 qDebug() << errorComponent->errorString();
95 #ifdef UNITY8_ENABLE_TOUCH_EMULATION
96 // You will need this if you want to interact with touch-only components using a mouse
97 // Needed only when manually testing on a desktop.
98 if (m_qmlArgs.hasMouseToTouch()) {
99 m_mouseTouchAdaptor = MouseTouchAdaptor::instance();
103 if (m_qmlArgs.mode().compare("greeter") == 0) {
104 if (!QProcess::startDetached("initctl emit --no-wait unity8-greeter-started")) {
105 qDebug() << "Unable to send unity8-greeter-started event to Upstart";
110ShellApplication::~ShellApplication()
115void ShellApplication::destroyResources()
117 #ifdef UNITY8_ENABLE_TOUCH_EMULATION
118 delete m_mouseTouchAdaptor;
119 m_mouseTouchAdaptor = nullptr;
123 m_qmlEngine = nullptr;
126void ShellApplication::setupQmlEngine(bool isMirServer)
128 m_qmlEngine = new QQmlEngine(this);
130 m_qmlEngine->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
132 prependImportPaths(m_qmlEngine, ::overrideImportPaths());
134 prependImportPaths(m_qmlEngine, ::nonMirImportPaths());
136 appendImportPaths(m_qmlEngine, ::fallbackImportPaths());
138 m_qmlEngine->setNetworkAccessManagerFactory(new CachingNetworkManagerFactory);
140 QObject::connect(m_qmlEngine, &QQmlEngine::quit, this, &QGuiApplication::quit);
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