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"
36void prependImportPaths(QQmlEngine *engine, const QStringList &paths)
38 QStringList importPathList = engine->importPathList();
39 for (int i = paths.count() -1; i >= 0; i--) {
41 const QString& path = paths[i];
42 QStringList::iterator iter = qFind(importPathList.begin(), importPathList.end(), path);
43 if (iter == importPathList.end()) {
44 engine->addImportPath(path);
49/* When you append and import path to the list of import paths it will be the *last*
50 place where Qt will search for QML modules.
51 The usual QQmlEngine::addImportPath() actually prepends the given path.*/
52void appendImportPaths(QQmlEngine *engine, const QStringList &paths)
54 QStringList importPathList = engine->importPathList();
55 Q_FOREACH(const QString& path, paths) {
57 QStringList::iterator iter = qFind(importPathList.begin(), importPathList.end(), path);
58 if (iter == importPathList.end()) {
59 importPathList.append(path);
62 engine->setImportPathList(importPathList);
65void resolveIconTheme() {
66 const char *ubuntuIconTheme = getenv("UBUNTU_ICON_THEME");
67 if (ubuntuIconTheme != NULL) {
68 QIcon::setThemeName(ubuntuIconTheme);
73int main(int argc, char** argv)
75 /* Workaround Qt platform integration plugin not advertising itself
76 as having the following capabilities:
77 - QPlatformIntegration::ThreadedOpenGL
78 - QPlatformIntegration::BufferQueueingOpenGL
80 setenv("QML_FORCE_THREADED_RENDERER", "1", 1);
81 setenv("QML_FIXED_ANIMATION_STEP", "1", 1);
83 QGuiApplication::setApplicationName("Unity 8");
84 QGuiApplication application(argc, argv);
88 QStringList args = application.arguments();
90 // The testability driver is only loaded by QApplication but not by QGuiApplication.
91 // However, QApplication depends on QWidget which would add some unneeded overhead => Let's load the testability driver on our own.
92 if (args.contains(QLatin1String("-testability"))) {
93 QLibrary testLib(QLatin1String("qttestability"));
95 typedef void (*TasInitialize)(void);
96 TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init");
100 qCritical("Library qttestability resolve failed!");
103 qCritical("Library qttestability load failed!");
107 bindtextdomain("unity8", translationDirectory().toUtf8().data());
109 QQuickView* view = new QQuickView();
110 view->setResizeMode(QQuickView::SizeRootObjectToView);
111 view->setTitle("Qml Phone Shell");
112 view->engine()->setBaseUrl(QUrl::fromLocalFile(::shellAppDirectory()));
113 if (args.contains(QLatin1String("-frameless"))) {
114 view->setFlags(Qt::FramelessWindowHint);
117 // You will need this if you want to interact with touch-only components using a mouse
118 // Needed only when manually testing on a desktop.
119 MouseTouchAdaptor *mouseTouchAdaptor = 0;
120 if (args.contains(QLatin1String("-mousetouch"))) {
121 mouseTouchAdaptor = new MouseTouchAdaptor;
122 mouseTouchAdaptor->setTargetWindow(view);
123 application.installNativeEventFilter(mouseTouchAdaptor);
126 QPlatformNativeInterface* nativeInterface = QGuiApplication::platformNativeInterface();
127 /* Shell is declared as a system session so that it always receives all
129 FIXME: use the enum value corresponding to SYSTEM_SESSION_TYPE (= 1)
130 when it becomes available.
132 nativeInterface->setProperty("ubuntuSessionType", 1);
133 view->setProperty("role", 2); // INDICATOR_ACTOR_ROLE
135 QUrl source("Shell.qml");
136 prependImportPaths(view->engine(), ::overrideImportPaths());
137 appendImportPaths(view->engine(), ::fallbackImportPaths());
138 view->setSource(source);
139 view->setColor("transparent");
141 if (qgetenv("QT_QPA_PLATFORM") == "ubuntu" || args.contains(QLatin1String("-fullscreen"))) {
142 view->showFullScreen();
144 if (args.contains(QLatin1String("-geometry")) && args.size() > args.indexOf(QLatin1String("-geometry")) + 1) {
145 QStringList geometryArg = args.at(args.indexOf(QLatin1String("-geometry")) + 1).split('x');
146 if (geometryArg.size() == 2) {
147 view->resize(geometryArg.at(0).toInt(), geometryArg.at(1).toInt());
153 int result = application.exec();
155 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