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 qSetMessagePattern(
"[%{time yyyy-mm-dd:hh:mm:ss.zzz}] %{if-category}%{category}: %{endif}%{message}");
40 if (enableQmlDebugger(argc, argv)) {
41 QQmlDebuggingEnabler qQmlEnableDebuggingHelper(
true);
44 QGuiApplication *application =
new QGuiApplication(argc, (
char**)argv);
46 QCommandLineParser parser;
47 parser.setApplicationDescription(QStringLiteral(
"Description: Unity 8 Shell Dash"));
48 parser.addHelpOption();
50 QCommandLineOption mousetouchOption(QStringLiteral(
"mousetouch"),
51 QStringLiteral(
"Allow the mouse to provide touch input"));
52 parser.addOption(mousetouchOption);
54 QCommandLineOption windowGeometryOption(QStringList() << QStringLiteral(
"windowgeometry"),
55 QStringLiteral(
"Specify the window geometry as [<width>x<height>]"), QStringLiteral(
"windowgeometry"), QStringLiteral(
"1"));
56 parser.addOption(windowGeometryOption);
59 QCommandLineOption desktopFileHintOption(QStringLiteral(
"desktop_file_hint"),
60 QStringLiteral(
"The desktop_file_hint option for QtMir"), QStringLiteral(
"hint_file"));
61 parser.addOption(desktopFileHintOption);
65 parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
66 parser.process(*application);
68 if (getenv(
"QT_LOAD_TESTABILITY")) {
69 QLibrary testLib(QStringLiteral(
"qttestability"));
71 typedef void (*TasInitialize)(void);
72 TasInitialize initFunction = (TasInitialize)testLib.resolve(
"qt_testability_init");
76 qCritical(
"Library qttestability resolve failed!");
79 qCritical(
"Library qttestability load failed!");
83 bindtextdomain(
"unity8", translationDirectory().toUtf8().data());
86 QQuickView* view =
new QQuickView();
87 view->setResizeMode(QQuickView::SizeRootObjectToView);
89 if (parser.isSet(windowGeometryOption) &&
90 parser.value(windowGeometryOption).split(
'x').size() == 2)
92 QStringList geom = parser.value(windowGeometryOption).split(
'x');
93 QSize windowSize(geom.at(0).toInt(), geom.at(1).toInt());
94 if (windowSize.isValid()) {
95 view->setWidth(windowSize.width());
96 view->setHeight(windowSize.height());
100 view->setTitle(QStringLiteral(
"Scopes"));
102 #ifdef UNITY8_ENABLE_TOUCH_EMULATION 105 MouseTouchAdaptor *mouseTouchAdaptor = 0;
106 if (parser.isSet(mousetouchOption)) {
107 mouseTouchAdaptor = MouseTouchAdaptor::instance();
111 QUrl source(::qmlDirectory() +
"/Dash/DashApplication.qml");
112 prependImportPaths(view->engine(), ::overrideImportPaths());
113 appendImportPaths(view->engine(), ::fallbackImportPaths());
115 CachingNetworkManagerFactory *managerFactory =
new CachingNetworkManagerFactory();
116 view->engine()->setNetworkAccessManagerFactory(managerFactory);
118 view->setSource(source);
121 UnixSignalHandler signalHandler([]{
122 QGuiApplication::exit(0);
124 signalHandler.setupUnixSignalHandlers();
126 int result = application->exec();
130 #ifdef UNITY8_ENABLE_TOUCH_EMULATION 131 delete mouseTouchAdaptor;