on 6743bb3 help sign in
unity8/src/Dash/main.cpp
92 lines 3.2 kB history raw
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * Authors:
5 * Michael Zanetti <michael.zanetti@canonical.com>
6 *
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.
10 *
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.
15 *
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/>.
18 */
20#include <QtQuick/QQuickView>
21#include <QtGui/QGuiApplication>
22#include <QtQml/QQmlEngine>
23#include <QtQml/QQmlContext>
24#include <QDebug>
25#include <QCommandLineParser>
26#include <QLibrary>
28#include <paths.h>
29#include "../MouseTouchAdaptor.h"
31int main(int argc, const char *argv[])
33 QGuiApplication *application = new QGuiApplication(argc, (char**)argv);
35 QCommandLineParser parser;
36 parser.setApplicationDescription("Description: Unity 8 Shell Dash");
37 parser.addHelpOption();
39 QCommandLineOption mousetouchOption("mousetouch",
40 "Allow the mouse to provide touch input");
41 parser.addOption(mousetouchOption);
43 QCommandLineOption testabilityOption("testability",
44 "Load the testability driver (Alternatively export QT_LOAD_TESTABILITY");
45 parser.addOption(testabilityOption);
47 // Treat args with single dashes the same as arguments with two dashes
48 // Ex: -fullscreen == --fullscreen
49 parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
50 parser.process(*application);
52 if (parser.isSet(testabilityOption) || getenv("QT_LOAD_TESTABILITY")) {
53 QLibrary testLib(QLatin1String("qttestability"));
54 if (testLib.load()) {
55 typedef void (*TasInitialize)(void);
56 TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init");
57 if (initFunction) {
58 initFunction();
59 } else {
60 qCritical("Library qttestability resolve failed!");
61 }
62 } else {
63 qCritical("Library qttestability load failed!");
64 }
65 }
67 QQuickView* view = new QQuickView();
68 view->setResizeMode(QQuickView::SizeRootObjectToView);
69 view->setTitle("Unity Dash");
71 // You will need this if you want to interact with touch-only components using a mouse
72 // Needed only when manually testing on a desktop.
73 MouseTouchAdaptor *mouseTouchAdaptor = 0;
74 if (parser.isSet(mousetouchOption)) {
75 mouseTouchAdaptor = new MouseTouchAdaptor;
76 application->installNativeEventFilter(mouseTouchAdaptor);
77 }
79 QUrl source(::qmlDirectory()+"Dash/DashApplication.qml");
80 prependImportPaths(view->engine(), ::overrideImportPaths());
81 appendImportPaths(view->engine(), ::fallbackImportPaths());
83 view->setSource(source);
84 view->show();
86 int result = application->exec();
88 delete view;
89 delete application;
91 return result;