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