on e700c19 help sign in
unity8/src/Dash/main.cpp
96 lines 3.3 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>
27#include <libintl.h>
29#include <paths.h>
30#include "../MouseTouchAdaptor.h"
32int main(int argc, const char *argv[])
34 QGuiApplication *application = new QGuiApplication(argc, (char**)argv);
36 QCommandLineParser parser;
37 parser.setApplicationDescription("Description: Unity 8 Shell Dash");
38 parser.addHelpOption();
40 QCommandLineOption mousetouchOption("mousetouch",
41 "Allow the mouse to provide touch input");
42 parser.addOption(mousetouchOption);
44 // FIXME Remove once we drop the need of the hint
45 QCommandLineOption desktopFileHintOption("desktop_file_hint",
46 "The desktop_file_hint option for QtMir", "hint_file");
47 parser.addOption(desktopFileHintOption);
49 // Treat args with single dashes the same as arguments with two dashes
50 // Ex: -fullscreen == --fullscreen
51 parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
52 parser.process(*application);
54 if (getenv("QT_LOAD_TESTABILITY")) {
55 QLibrary testLib(QLatin1String("qttestability"));
56 if (testLib.load()) {
57 typedef void (*TasInitialize)(void);
58 TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init");
59 if (initFunction) {
60 initFunction();
61 } else {
62 qCritical("Library qttestability resolve failed!");
63 }
64 } else {
65 qCritical("Library qttestability load failed!");
66 }
67 }
69 bindtextdomain("unity8", translationDirectory().toUtf8().data());
71 QQuickView* view = new QQuickView();
72 view->setResizeMode(QQuickView::SizeRootObjectToView);
73 view->setTitle("Unity Dash");
75 // You will need this if you want to interact with touch-only components using a mouse
76 // Needed only when manually testing on a desktop.
77 MouseTouchAdaptor *mouseTouchAdaptor = 0;
78 if (parser.isSet(mousetouchOption)) {
79 mouseTouchAdaptor = new MouseTouchAdaptor;
80 application->installNativeEventFilter(mouseTouchAdaptor);
81 }
83 QUrl source(::qmlDirectory()+"Dash/DashApplication.qml");
84 prependImportPaths(view->engine(), ::overrideImportPaths());
85 appendImportPaths(view->engine(), ::fallbackImportPaths());
87 view->setSource(source);
88 view->show();
90 int result = application->exec();
92 delete view;
93 delete application;
95 return result;