20 #include <QtQuick/QQuickView> 21 #include <QtGui/QGuiApplication> 22 #include <QtQml/QQmlEngine> 23 #include <QtQml/QQmlContext> 25 #include <QCommandLineParser> 30 #include "../qmldebuggerutils.h" 31 #ifdef UNITY8_ENABLE_TOUCH_EMULATION 32 #include "../MouseTouchAdaptor.h" 34 #include "../CachingNetworkManagerFactory.h" 35 #include "../UnixSignalHandler.h" 37 int main(
int argc,
const char *argv[])
39 if (enableQmlDebugger(argc, argv)) {
40 QQmlDebuggingEnabler qQmlEnableDebuggingHelper(
true);
43 QGuiApplication *application =
new QGuiApplication(argc, (
char**)argv);
45 QCommandLineParser parser;
46 parser.setApplicationDescription(QStringLiteral(
"Description: Unity 8 Shell Dash"));
47 parser.addHelpOption();
49 QCommandLineOption mousetouchOption(QStringLiteral(
"mousetouch"),
50 QStringLiteral(
"Allow the mouse to provide touch input"));
51 parser.addOption(mousetouchOption);
53 QCommandLineOption windowGeometryOption(QStringList() << QStringLiteral(
"windowgeometry"),
54 QStringLiteral(
"Specify the window geometry as [<width>x<height>]"), QStringLiteral(
"windowgeometry"), QStringLiteral(
"1"));
55 parser.addOption(windowGeometryOption);
58 QCommandLineOption desktopFileHintOption(QStringLiteral(
"desktop_file_hint"),
59 QStringLiteral(
"The desktop_file_hint option for QtMir"), QStringLiteral(
"hint_file"));
60 parser.addOption(desktopFileHintOption);
64 parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
65 parser.process(*application);
67 if (getenv(
"QT_LOAD_TESTABILITY")) {
68 QLibrary testLib(QStringLiteral(
"qttestability"));
70 typedef void (*TasInitialize)(void);
71 TasInitialize initFunction = (TasInitialize)testLib.resolve(
"qt_testability_init");
75 qCritical(
"Library qttestability resolve failed!");
78 qCritical(
"Library qttestability load failed!");
82 bindtextdomain(
"unity8", translationDirectory().toUtf8().data());
85 QQuickView* view =
new QQuickView();
86 view->setResizeMode(QQuickView::SizeRootObjectToView);
88 if (parser.isSet(windowGeometryOption) &&
89 parser.value(windowGeometryOption).split(
'x').size() == 2)
91 QStringList geom = parser.value(windowGeometryOption).split(
'x');
92 QSize windowSize(geom.at(0).toInt(), geom.at(1).toInt());
93 if (windowSize.isValid()) {
94 view->setWidth(windowSize.width());
95 view->setHeight(windowSize.height());
99 view->setTitle(QStringLiteral(
"Scopes"));
101 #ifdef UNITY8_ENABLE_TOUCH_EMULATION 104 MouseTouchAdaptor *mouseTouchAdaptor = 0;
105 if (parser.isSet(mousetouchOption)) {
106 mouseTouchAdaptor = MouseTouchAdaptor::instance();
110 QUrl source(::qmlDirectory() +
"/Dash/DashApplication.qml");
111 prependImportPaths(view->engine(), ::overrideImportPaths());
112 appendImportPaths(view->engine(), ::fallbackImportPaths());
114 CachingNetworkManagerFactory *managerFactory =
new CachingNetworkManagerFactory();
115 view->engine()->setNetworkAccessManagerFactory(managerFactory);
117 view->setSource(source);
120 UnixSignalHandler signalHandler([]{
121 QGuiApplication::exit(0);
123 signalHandler.setupUnixSignalHandlers();
125 int result = application->exec();
129 #ifdef UNITY8_ENABLE_TOUCH_EMULATION 130 delete mouseTouchAdaptor;