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 <QtQuick/QQuickView>
23#include <QtGui/QGuiApplication>
24#include <QtQml/QQmlEngine>
25#include <QtQml/QQmlContext>
26#include <qpa/qplatformnativeinterface.h>
32#include "MouseTouchAdaptor.h"
33#include "ApplicationArguments.h"
37void prependImportPaths(QQmlEngine *engine, const QStringList &paths)
39 QStringList importPathList = engine->importPathList();
40 for (int i = paths.count() -1; i >= 0; i--) {
42 const QString& path = paths[i];
43 QStringList::iterator iter = qFind(importPathList.begin(), importPathList.end(), path);
44 if (iter == importPathList.end()) {
45 engine->addImportPath(path);
50/* When you append and import path to the list of import paths it will be the *last*
51 place where Qt will search for QML modules.
52 The usual QQmlEngine::addImportPath() actually prepends the given path.*/
53void appendImportPaths(QQmlEngine *engine, const QStringList &paths)
55 QStringList importPathList = engine->importPathList();
56 Q_FOREACH(const QString& path, paths) {
58 QStringList::iterator iter = qFind(importPathList.begin(), importPathList.end(), path);
59 if (iter == importPathList.end()) {
60 importPathList.append(path);
63 engine->setImportPathList(importPathList);
66void resolveIconTheme() {
67 const char *ubuntuIconTheme = getenv("UBUNTU_ICON_THEME");
68 if (ubuntuIconTheme != NULL) {
69 QIcon::setThemeName(ubuntuIconTheme);
74int main(int argc, char** argv)
76 /* Workaround Qt platform integration plugin not advertising itself
77 as having the following capabilities:
78 - QPlatformIntegration::ThreadedOpenGL
79 - QPlatformIntegration::BufferQueueingOpenGL
81 setenv("QML_FORCE_THREADED_RENDERER", "1", 1);
82 setenv("QML_FIXED_ANIMATION_STEP", "1", 1);
84 QGuiApplication::setApplicationName("Unity 8");
85 QGuiApplication application(argc, argv);
89 QStringList args = application.arguments();
90 ApplicationArguments qmlArgs(args);
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 (args.contains(QLatin1String("-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(::shellAppDirectory()));
115 view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
116 if (args.contains(QLatin1String("-frameless"))) {
117 view->setFlags(Qt::FramelessWindowHint);
120 // You will need this if you want to interact with touch-only components using a mouse
121 // Needed only when manually testing on a desktop.
122 MouseTouchAdaptor *mouseTouchAdaptor = 0;
123 if (args.contains(QLatin1String("-mousetouch"))) {
124 mouseTouchAdaptor = new MouseTouchAdaptor;
125 mouseTouchAdaptor->setTargetWindow(view);
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("Shell.qml");
139 prependImportPaths(view->engine(), ::overrideImportPaths());
140 appendImportPaths(view->engine(), ::fallbackImportPaths());
141 view->setSource(source);
142 view->setColor("transparent");
144 if (qgetenv("QT_QPA_PLATFORM") == "ubuntu" || args.contains(QLatin1String("-fullscreen"))) {
145 view->showFullScreen();
150 int result = application.exec();
152 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