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