2 * Copyright (C) 2012 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>
26#include <qpa/qplatformnativeinterface.h>
35#include "MouseTouchAdaptor.h"
36#include "ApplicationArguments.h"
38int startShell(int argc, const char** argv)
40 const bool isMirServer = qgetenv("QT_QPA_PLATFORM") == "mirserver";
42 QGuiApplication::setApplicationName("Unity 8");
43 QGuiApplication *application;
45 QCommandLineParser parser;
46 parser.setApplicationDescription("Description: Unity 8 Shell");
47 parser.addHelpOption();
49 QCommandLineOption fullscreenOption("fullscreen",
51 parser.addOption(fullscreenOption);
53 QCommandLineOption framelessOption("frameless",
54 "Run without window borders");
55 parser.addOption(framelessOption);
57 QCommandLineOption mousetouchOption("mousetouch",
58 "Allow the mouse to provide touch input");
59 parser.addOption(mousetouchOption);
61 QCommandLineOption windowGeometryOption(QStringList() << "windowgeometry",
62 "Specify the window geometry as [<width>x<height>]", "windowgeometry", "1");
63 parser.addOption(windowGeometryOption);
65 QCommandLineOption testabilityOption("testability",
66 "DISCOURAGED: Please set QT_LOAD_TESTABILITY instead. \n \
67Load the testability driver");
68 parser.addOption(testabilityOption);
70 application = new QGuiApplication(argc, (char**)argv);
72 // Treat args with single dashes the same as arguments with two dashes
73 // Ex: -fullscreen == --fullscreen
74 parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
75 parser.process(*application);
77 QString indicatorProfile = qgetenv("UNITY_INDICATOR_PROFILE");
78 if (indicatorProfile.isEmpty()) {
79 indicatorProfile = "phone";
84 ApplicationArguments qmlArgs;
85 if (parser.isSet(windowGeometryOption) &&
86 parser.value(windowGeometryOption).split('x').size() == 2)
88 QStringList geom = parser.value(windowGeometryOption).split('x');
89 qmlArgs.setSize(geom.at(0).toInt(), geom.at(1).toInt());
92 // The testability driver is only loaded by QApplication but not by QGuiApplication.
93 // However, QApplication depends on QWidget which would add some unneeded overhead => Let's load the testability driver on our own.
94 if (parser.isSet(testabilityOption) || getenv("QT_LOAD_TESTABILITY")) {
95 QLibrary testLib(QLatin1String("qttestability"));
97 typedef void (*TasInitialize)(void);
98 TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init");
102 qCritical("Library qttestability resolve failed!");
105 qCritical("Library qttestability load failed!");
109 bindtextdomain("unity8", translationDirectory().toUtf8().data());
111 QQuickView* view = new QQuickView();
112 view->setResizeMode(QQuickView::SizeRootObjectToView);
113 view->setTitle("Qml Phone Shell");
114 view->engine()->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
115 view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
116 view->rootContext()->setContextProperty("indicatorProfile", indicatorProfile);
117 if (parser.isSet(framelessOption)) {
118 view->setFlags(Qt::FramelessWindowHint);
121 // You will need this if you want to interact with touch-only components using a mouse
122 // Needed only when manually testing on a desktop.
123 MouseTouchAdaptor *mouseTouchAdaptor = 0;
124 if (parser.isSet(mousetouchOption)) {
125 mouseTouchAdaptor = new MouseTouchAdaptor;
126 application->installNativeEventFilter(mouseTouchAdaptor);
129 QPlatformNativeInterface* nativeInterface = QGuiApplication::platformNativeInterface();
130 /* Shell is declared as a system session so that it always receives all
132 FIXME: use the enum value corresponding to SYSTEM_SESSION_TYPE (= 1)
133 when it becomes available.
135 nativeInterface->setProperty("ubuntuSessionType", 1);
136 view->setProperty("role", 2); // INDICATOR_ACTOR_ROLE
138 QUrl source(::qmlDirectory()+"OrientedShell.qml");
139 prependImportPaths(view->engine(), ::overrideImportPaths());
141 prependImportPaths(view->engine(), ::nonMirImportPaths());
143 appendImportPaths(view->engine(), ::fallbackImportPaths());
145 view->setSource(source);
147 if (isMirServer || parser.isSet(fullscreenOption)) {
148 view->showFullScreen();
153 int result = application->exec();
156 delete mouseTouchAdaptor;
162int main(int argc, const char *argv[])
164 /* Workaround Qt platform integration plugin not advertising itself
165 as having the following capabilities:
166 - QPlatformIntegration::ThreadedOpenGL
167 - QPlatformIntegration::BufferQueueingOpenGL
169 setenv("QML_FORCE_THREADED_RENDERER", "1", 1);
170 setenv("QML_FIXED_ANIMATION_STEP", "1", 1);
172 if (qgetenv("QT_QPA_PLATFORM") == "ubuntuclient"
173 || qgetenv("QT_QPA_PLATFORM") == "ubuntumirclient") {
174 setenv("QT_QPA_PLATFORM", "mirserver", 1 /* overwrite */);
177 return startShell(argc, argv);
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