20 #include <QtQuick/QQuickView>
21 #include <QtGui/QGuiApplication>
22 #include <QtQml/QQmlEngine>
23 #include <QtQml/QQmlContext>
25 #include <QCommandLineParser>
30 #include "../MouseTouchAdaptor.h"
31 #include "../ApplicationArguments.h"
32 #include "../CachingNetworkManagerFactory.h"
34 int main(
int argc,
const char *argv[])
36 QGuiApplication *application =
new QGuiApplication(argc, (
char**)argv);
38 QCommandLineParser parser;
39 parser.setApplicationDescription(QStringLiteral(
"Description: Unity 8 Shell Dash"));
40 parser.addHelpOption();
42 QCommandLineOption mousetouchOption(QStringLiteral(
"mousetouch"),
43 QStringLiteral(
"Allow the mouse to provide touch input"));
44 parser.addOption(mousetouchOption);
46 QCommandLineOption windowGeometryOption(QStringList() << QStringLiteral(
"windowgeometry"),
47 QStringLiteral(
"Specify the window geometry as [<width>x<height>]"), QStringLiteral(
"windowgeometry"), QStringLiteral(
"1"));
48 parser.addOption(windowGeometryOption);
51 QCommandLineOption desktopFileHintOption(QStringLiteral(
"desktop_file_hint"),
52 QStringLiteral(
"The desktop_file_hint option for QtMir"), QStringLiteral(
"hint_file"));
53 parser.addOption(desktopFileHintOption);
57 parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
58 parser.process(*application);
60 ApplicationArguments qmlArgs;
62 if (getenv(
"QT_LOAD_TESTABILITY")) {
63 QLibrary testLib(QStringLiteral(
"qttestability"));
65 typedef void (*TasInitialize)(void);
66 TasInitialize initFunction = (TasInitialize)testLib.resolve(
"qt_testability_init");
70 qCritical(
"Library qttestability resolve failed!");
73 qCritical(
"Library qttestability load failed!");
77 bindtextdomain(
"unity8", translationDirectory().toUtf8().data());
80 QQuickView* view =
new QQuickView();
81 view->setResizeMode(QQuickView::SizeRootObjectToView);
83 if (parser.isSet(windowGeometryOption) &&
84 parser.value(windowGeometryOption).split(
'x').size() == 2)
86 QStringList geom = parser.value(windowGeometryOption).split(
'x');
87 QSize windowSize(geom.at(0).toInt(), geom.at(1).toInt());
88 if (windowSize.isValid()) {
89 view->setWidth(windowSize.width());
90 view->setHeight(windowSize.height());
94 view->setTitle(QStringLiteral(
"Scopes"));
95 view->rootContext()->setContextProperty(QStringLiteral(
"applicationArguments"), &qmlArgs);
99 MouseTouchAdaptor *mouseTouchAdaptor = 0;
100 if (parser.isSet(mousetouchOption)) {
101 mouseTouchAdaptor = MouseTouchAdaptor::instance();
104 QUrl source(::qmlDirectory() +
"/Dash/DashApplication.qml");
105 prependImportPaths(view->engine(), ::overrideImportPaths());
106 appendImportPaths(view->engine(), ::fallbackImportPaths());
108 CachingNetworkManagerFactory *managerFactory =
new CachingNetworkManagerFactory();
109 view->engine()->setNetworkAccessManagerFactory(managerFactory);
111 view->setSource(source);
114 int result = application->exec();
117 delete mouseTouchAdaptor;