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"
38#include <qtmir/windowmanagementpolicy.h>
40class WindowManagementPolicy : public qtmir::WindowManagementPolicy
43 WindowManagementPolicy(const miral::WindowManagerTools &tools, qtmir::WindowManagementPolicyPrivate& dd)
44 : qtmir::WindowManagementPolicy(tools, dd)
47// virtual void advise_adding_to_workspace(
48// std::shared_ptr<miral::Workspace> const& workspace,
49// std::vector<miral::Window> const& windows) override
53// virtual void advise_removing_from_workspace(
54// std::shared_ptr<miral::Workspace> const& workspace,
55// std::vector<miral::Window> const& windows) override
61ShellApplication::ShellApplication(int & argc, char ** argv)
62 : qtmir::MirServerApplication(argc, argv, {})
65 setApplicationName(QStringLiteral("unity8"));
66 setOrganizationName(QStringLiteral("Canonical"));
70 if (m_qmlArgs.deviceName().isEmpty()) {
72 property_get("ro.product.device", buffer /* value */, "desktop" /* default_value*/);
73 m_qmlArgs.setDeviceName(QString(buffer));
76 // The testability driver is only loaded by QApplication but not by QGuiApplication.
77 // However, QApplication depends on QWidget which would add some unneeded overhead => Let's load the testability driver on our own.
78 if (m_qmlArgs.hasTestability() || getenv("QT_LOAD_TESTABILITY")) {
79 QLibrary testLib(QStringLiteral("qttestability"));
81 typedef void (*TasInitialize)(void);
82 TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init");
86 qCritical("Library qttestability resolve failed!");
89 qCritical("Library qttestability load failed!");
93 bindtextdomain("unity8", translationDirectory().toUtf8().data());
96 m_qmlEngine->rootContext()->setContextProperty(QStringLiteral("applicationArguments"), &m_qmlArgs);
97 m_qmlEngine->rootContext()->setContextProperty("DebuggingController", new DebuggingController(this));
99 QByteArray pxpguEnv = qgetenv("GRID_UNIT_PX");
101 int pxpgu = pxpguEnv.toInt(&ok);
105 m_qmlEngine->rootContext()->setContextProperty("internalGu", pxpgu);
106 m_qmlEngine->load(::qmlDirectory() + "/ShellApplication.qml");
108 #ifdef UNITY8_ENABLE_TOUCH_EMULATION
109 // You will need this if you want to interact with touch-only components using a mouse
110 // Needed only when manually testing on a desktop.
111 if (m_qmlArgs.hasMouseToTouch()) {
112 m_mouseTouchAdaptor = MouseTouchAdaptor::instance();
116 if (m_qmlArgs.mode().compare("greeter") == 0) {
117 if (!QProcess::startDetached("initctl emit --no-wait unity8-greeter-started")) {
118 qDebug() << "Unable to send unity8-greeter-started event to Upstart";
123ShellApplication::~ShellApplication()
128void ShellApplication::destroyResources()
130 #ifdef UNITY8_ENABLE_TOUCH_EMULATION
131 delete m_mouseTouchAdaptor;
132 m_mouseTouchAdaptor = nullptr;
136 m_qmlEngine = nullptr;
139void ShellApplication::setupQmlEngine()
141 m_qmlEngine = new QQmlApplicationEngine(this);
143 m_qmlEngine->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
145 prependImportPaths(m_qmlEngine, ::overrideImportPaths());
146 appendImportPaths(m_qmlEngine, ::fallbackImportPaths());
148 m_qmlEngine->setNetworkAccessManagerFactory(new CachingNetworkManagerFactory);
150 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