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"
27// libandroid-properties
28#include <hybris/properties/properties.h>
32#include "CachingNetworkManagerFactory.h"
33#include "UnityCommandLineParser.h"
34#include "DebuggingController.h"
36ShellApplication::ShellApplication(int & argc, char ** argv, bool isMirServer)
37 : QGuiApplication(argc, argv)
40 setApplicationName(QStringLiteral("unity8"));
41 setOrganizationName(QStringLiteral("Canonical"));
43 setupQmlEngine(isMirServer);
45 if (m_qmlArgs.deviceName().isEmpty()) {
47 property_get("ro.product.device", buffer /* value */, "desktop" /* default_value*/);
48 m_qmlArgs.setDeviceName(QString(buffer));
51 // The testability driver is only loaded by QApplication but not by QGuiApplication.
52 // However, QApplication depends on QWidget which would add some unneeded overhead => Let's load the testability driver on our own.
53 if (m_qmlArgs.hasTestability() || getenv("QT_LOAD_TESTABILITY")) {
54 QLibrary testLib(QStringLiteral("qttestability"));
56 typedef void (*TasInitialize)(void);
57 TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init");
61 qCritical("Library qttestability resolve failed!");
64 qCritical("Library qttestability load failed!");
68 bindtextdomain("unity8", translationDirectory().toUtf8().data());
71 m_qmlEngine->rootContext()->setContextProperty(QStringLiteral("applicationArguments"), &m_qmlArgs);
73 QByteArray pxpguEnv = qgetenv("GRID_UNIT_PX");
75 int pxpgu = pxpguEnv.toInt(&ok);
79 m_qmlEngine->rootContext()->setContextProperty("internalGu", pxpgu);
80 m_qmlEngine->load(::qmlDirectory() + "/ShellApplication.qml");
82 #ifdef UNITY8_ENABLE_TOUCH_EMULATION
83 // You will need this if you want to interact with touch-only components using a mouse
84 // Needed only when manually testing on a desktop.
85 if (m_qmlArgs.hasMouseToTouch()) {
86 m_mouseTouchAdaptor = MouseTouchAdaptor::instance();
90 m_qmlEngine->rootContext()->setContextProperty("DebuggingController", new DebuggingController(this));
92// if (parser.mode().compare("greeter") == 0) {
93// QSize primaryScreenSize = this->primaryScreen()->size();
94// m_shellView->setHeight(primaryScreenSize.height());
95// m_shellView->setWidth(primaryScreenSize.width());
96// m_shellView->show();
97// m_shellView->requestActivate();
98// if (!QProcess::startDetached("initctl emit --no-wait unity8-greeter-started")) {
99// qDebug() << "Unable to send unity8-greeter-started event to Upstart";
101// } else if (isMirServer || parser.hasFullscreen()) {
102// m_shellView->showFullScreen();
104// m_shellView->show();
108ShellApplication::~ShellApplication()
113void ShellApplication::destroyResources()
115 #ifdef UNITY8_ENABLE_TOUCH_EMULATION
116 delete m_mouseTouchAdaptor;
117 m_mouseTouchAdaptor = nullptr;
121 m_qmlEngine = nullptr;
124void ShellApplication::setupQmlEngine(bool isMirServer)
126 m_qmlEngine = new QQmlApplicationEngine(this);
128 m_qmlEngine->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
130 prependImportPaths(m_qmlEngine, ::overrideImportPaths());
132 prependImportPaths(m_qmlEngine, ::nonMirImportPaths());
134 appendImportPaths(m_qmlEngine, ::fallbackImportPaths());
136 m_qmlEngine->setNetworkAccessManagerFactory(new CachingNetworkManagerFactory);
138 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