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 "UnityApplication.h"
27// libandroid-properties
28#include <hybris/properties/properties.h>
32#include "CachingNetworkManagerFactory.h"
33#include "UnityCommandLineParser.h"
34#include "DebuggingController.h"
35#include "WindowManagementPolicy.h"
41UnityApplication::UnityApplication(int & argc, char ** argv)
42 : qtmir::MirServerApplication(argc, argv, { qtmir::SetWindowManagementPolicy<WindowManagementPolicy>() })
45 setApplicationName(QStringLiteral("unity8"));
46 setOrganizationName(QStringLiteral("Canonical"));
50 if (m_qmlArgs.deviceName().isEmpty()) {
52 property_get("ro.product.device", buffer /* value */, "desktop" /* default_value*/);
53 m_qmlArgs.setDeviceName(QString(buffer));
56 // The testability driver is only loaded by QApplication but not by QGuiApplication.
57 // However, QApplication depends on QWidget which would add some unneeded overhead => Let's load the testability driver on our own.
58 if (m_qmlArgs.hasTestability() || getenv("QT_LOAD_TESTABILITY")) {
59 QLibrary testLib(QStringLiteral("qttestability"));
61 typedef void (*TasInitialize)(void);
62 TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init");
66 qCritical("Library qttestability resolve failed!");
69 qCritical("Library qttestability load failed!");
73 bindtextdomain("unity8", translationDirectory().toUtf8().data());
76 m_qmlEngine->rootContext()->setContextProperty(QStringLiteral("applicationArguments"), &m_qmlArgs);
77 m_qmlEngine->rootContext()->setContextProperty("DebuggingController", new DebuggingController(this));
79 QByteArray pxpguEnv = qgetenv("GRID_UNIT_PX");
81 int pxpgu = pxpguEnv.toInt(&ok);
85 m_qmlEngine->rootContext()->setContextProperty("internalGu", pxpgu);
86 m_qmlEngine->load(m_qmlArgs.qmlfie());
88 #ifdef UNITY8_ENABLE_TOUCH_EMULATION
89 // You will need this if you want to interact with touch-only components using a mouse
90 // Needed only when manually testing on a desktop.
91 if (m_qmlArgs.hasMouseToTouch()) {
92 m_mouseTouchAdaptor = MouseTouchAdaptor::instance();
96 if (m_qmlArgs.mode().compare("greeter") == 0) {
97 if (!QProcess::startDetached("initctl emit --no-wait unity8-greeter-started")) {
98 qDebug() << "Unable to send unity8-greeter-started event to Upstart";
103UnityApplication::~UnityApplication()
108void UnityApplication::destroyResources()
110 #ifdef UNITY8_ENABLE_TOUCH_EMULATION
111 delete m_mouseTouchAdaptor;
112 m_mouseTouchAdaptor = nullptr;
116 m_qmlEngine = nullptr;
119void UnityApplication::setupQmlEngine()
121 m_qmlEngine = new QQmlApplicationEngine(this);
123 m_qmlEngine->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
125 prependImportPaths(m_qmlEngine, ::overrideImportPaths());
126 appendImportPaths(m_qmlEngine, ::fallbackImportPaths());
128 m_qmlEngine->setNetworkAccessManagerFactory(new CachingNetworkManagerFactory);
130 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