on 9463568 help sign in
unity8/src/Dash/main.cpp
74 lines 2.4 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>
30int main(int argc, const char *argv[])
32 QGuiApplication *application = new QGuiApplication(argc, (char**)argv);
34 QCommandLineParser parser;
35 parser.setApplicationDescription("Description: Unity 8 Shell Dash");
36 parser.addHelpOption();
38 QCommandLineOption testabilityOption("testability",
39 "Load the testability driver (Alternatively export QT_LOAD_TESTABILITY");
40 parser.addOption(testabilityOption);
42 if (parser.isSet(testabilityOption) || getenv("QT_LOAD_TESTABILITY")) {
43 QLibrary testLib(QLatin1String("qttestability"));
44 if (testLib.load()) {
45 typedef void (*TasInitialize)(void);
46 TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init");
47 if (initFunction) {
48 initFunction();
49 } else {
50 qCritical("Library qttestability resolve failed!");
51 }
52 } else {
53 qCritical("Library qttestability load failed!");
54 }
55 }
57 QQuickView* view = new QQuickView();
58 view->setResizeMode(QQuickView::SizeRootObjectToView);
59 view->setTitle("Unity Dash");
61 QUrl source(::qmlDirectory()+"Dash/DashApplication.qml");
62 prependImportPaths(view->engine(), ::overrideImportPaths());
63 appendImportPaths(view->engine(), ::fallbackImportPaths());
65 view->setSource(source);
66 view->show();
68 int result = application->exec();
70 delete view;
71 delete application;
73 return result;