2 * Copyright (C) 2012-2014 Canonical, Ltd.
5 * Gerry Boland <gerry.boland@canonical.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21#include <QCommandLineParser>
22#include <QtQuick/QQuickView>
23#include <QtGui/QGuiApplication>
24#include <QtQml/QQmlEngine>
25#include <QtQml/QQmlContext>
33#include "MouseTouchAdaptor.h"
34#include "ApplicationArguments.h"
35#include "CachingNetworkManagerFactory.h"
37int main(int argc, const char *argv[])
39 bool isMirServer = false;
40 if (qgetenv("QT_QPA_PLATFORM") == "ubuntumirclient") {
41 setenv("QT_QPA_PLATFORM", "mirserver", 1 /* overwrite */);
45 QGuiApplication::setApplicationName("unity8");
46 QGuiApplication *application;
48 QCommandLineParser parser;
49 parser.setApplicationDescription("Description: Unity 8 Shell");
50 parser.addHelpOption();
52 QCommandLineOption fullscreenOption("fullscreen",
54 parser.addOption(fullscreenOption);
56 QCommandLineOption framelessOption("frameless",
57 "Run without window borders");
58 parser.addOption(framelessOption);
60 QCommandLineOption mousetouchOption("mousetouch",
61 "Allow the mouse to provide touch input");
62 parser.addOption(mousetouchOption);
64 QCommandLineOption windowGeometryOption(QStringList() << "windowgeometry",
65 "Specify the window geometry as [<width>x<height>]", "windowgeometry", "1");
66 parser.addOption(windowGeometryOption);
68 QCommandLineOption testabilityOption("testability",
69 "DISCOURAGED: Please set QT_LOAD_TESTABILITY instead. \n \
70Load the testability driver");
71 parser.addOption(testabilityOption);
73 application = new QGuiApplication(argc, (char**)argv);
75 // Treat args with single dashes the same as arguments with two dashes
76 // Ex: -fullscreen == --fullscreen
77 parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
78 parser.process(*application);
80 QString indicatorProfile = qgetenv("UNITY_INDICATOR_PROFILE");
81 if (indicatorProfile.isEmpty()) {
82 indicatorProfile = "phone";
85 ApplicationArguments qmlArgs;
86 if (parser.isSet(windowGeometryOption) &&
87 parser.value(windowGeometryOption).split('x').size() == 2)
89 QStringList geom = parser.value(windowGeometryOption).split('x');
90 qmlArgs.setSize(geom.at(0).toInt(), geom.at(1).toInt());
93 // The testability driver is only loaded by QApplication but not by QGuiApplication.
94 // However, QApplication depends on QWidget which would add some unneeded overhead => Let's load the testability driver on our own.
95 if (parser.isSet(testabilityOption) || getenv("QT_LOAD_TESTABILITY")) {
96 QLibrary testLib(QLatin1String("qttestability"));
98 typedef void (*TasInitialize)(void);
99 TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init");
103 qCritical("Library qttestability resolve failed!");
106 qCritical("Library qttestability load failed!");
110 bindtextdomain("unity8", translationDirectory().toUtf8().data());
112 QQuickView* view = new QQuickView();
113 view->setResizeMode(QQuickView::SizeRootObjectToView);
114 view->setColor("black");
115 view->setTitle("Unity8 Shell");
116 view->engine()->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
117 view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
118 view->rootContext()->setContextProperty("indicatorProfile", indicatorProfile);
119 if (parser.isSet(framelessOption)) {
120 view->setFlags(Qt::FramelessWindowHint);
123 // You will need this if you want to interact with touch-only components using a mouse
124 // Needed only when manually testing on a desktop.
125 MouseTouchAdaptor *mouseTouchAdaptor = 0;
126 if (parser.isSet(mousetouchOption)) {
127 mouseTouchAdaptor = new MouseTouchAdaptor;
128 application->installNativeEventFilter(mouseTouchAdaptor);
131 QUrl source(::qmlDirectory()+"Shell.qml");
132 prependImportPaths(view->engine(), ::overrideImportPaths());
134 prependImportPaths(view->engine(), ::nonMirImportPaths());
136 appendImportPaths(view->engine(), ::fallbackImportPaths());
138 CachingNetworkManagerFactory *managerFactory = new CachingNetworkManagerFactory();
139 view->engine()->setNetworkAccessManagerFactory(managerFactory);
141 view->setSource(source);
142 QObject::connect(view->engine(), SIGNAL(quit()), application, SLOT(quit()));
144 if (!isMirServer && qEnvironmentVariableIsSet("UNITY_MIR_EMITS_SIGSTOP")) {
145 // Emit SIGSTOP as expected by upstart, under Mir it's qtmir that will raise it.
146 // see http://upstart.ubuntu.com/cookbook/#expect-stop
150 if (isMirServer || parser.isSet(fullscreenOption)) {
151 view->showFullScreen();
156 int result = application->exec();
159 delete mouseTouchAdaptor;
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