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/>.
22#include <QtQuick/QQuickView>
24#include <QtGui/QGuiApplication>
25#include <QtQml/QQmlEngine>
26#include <QtQml/QQmlContext>
27#include <qpa/qplatformnativeinterface.h>
33#include "MouseTouchAdaptor.h"
34#include "ApplicationArguments.h"
38void prependImportPaths(QQmlEngine *engine, const QStringList &paths)
40 QStringList importPathList = engine->importPathList();
41 for (int i = paths.count() -1; i >= 0; i--) {
43 const QString& path = paths[i];
44 QStringList::iterator iter = qFind(importPathList.begin(), importPathList.end(), path);
45 if (iter == importPathList.end()) {
46 engine->addImportPath(path);
51/* When you append and import path to the list of import paths it will be the *last*
52 place where Qt will search for QML modules.
53 The usual QQmlEngine::addImportPath() actually prepends the given path.*/
54void appendImportPaths(QQmlEngine *engine, const QStringList &paths)
56 QStringList importPathList = engine->importPathList();
57 Q_FOREACH(const QString& path, paths) {
59 QStringList::iterator iter = qFind(importPathList.begin(), importPathList.end(), path);
60 if (iter == importPathList.end()) {
61 importPathList.append(path);
64 engine->setImportPathList(importPathList);
67void resolveIconTheme() {
68 const char *ubuntuIconTheme = getenv("UBUNTU_ICON_THEME");
69 if (ubuntuIconTheme != NULL) {
70 QIcon::setThemeName(ubuntuIconTheme);
75int main(int argc, char** argv)
77 /* Workaround Qt platform integration plugin not advertising itself
78 as having the following capabilities:
79 - QPlatformIntegration::ThreadedOpenGL
80 - QPlatformIntegration::BufferQueueingOpenGL
82 setenv("QML_FORCE_THREADED_RENDERER", "1", 1);
83 setenv("QML_FIXED_ANIMATION_STEP", "1", 1);
85 QGuiApplication::setApplicationName("Unity 8");
86 QGuiApplication application(argc, argv);
90 QStringList args = application.arguments();
91 ApplicationArguments qmlArgs(args);
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 (args.contains(QLatin1String("-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->setTitle("Qml Phone Shell");
115 view->engine()->setBaseUrl(QUrl::fromLocalFile(::shellAppDirectory()));
116 view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
117 if (args.contains(QLatin1String("-frameless"))) {
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 (args.contains(QLatin1String("-mousetouch"))) {
125 mouseTouchAdaptor = new MouseTouchAdaptor;
126 mouseTouchAdaptor->setTargetWindow(view);
127 application.installNativeEventFilter(mouseTouchAdaptor);
130 QPlatformNativeInterface* nativeInterface = QGuiApplication::platformNativeInterface();
131 /* Shell is declared as a system session so that it always receives all
133 FIXME: use the enum value corresponding to SYSTEM_SESSION_TYPE (= 1)
134 when it becomes available.
136 nativeInterface->setProperty("ubuntuSessionType", 1);
137 view->setProperty("role", 2); // INDICATOR_ACTOR_ROLE
139 QUrl source("Shell.qml");
140 prependImportPaths(view->engine(), ::overrideImportPaths());
141 appendImportPaths(view->engine(), ::fallbackImportPaths());
142 view->setSource(source);
143 view->setColor("transparent");
145 if (qgetenv("QT_QPA_PLATFORM") == "ubuntu" || args.contains(QLatin1String("-fullscreen"))) {
146 view->showFullScreen();
151 int result = application.exec();
153 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