@@ -25,6 +25,7 @@
2525#include <QCommandLineParser>
2626#include <QLibrary>
2727#include <libintl.h>
28+#include <QQmlApplicationEngine>
2829
2930#include <paths.h>
3031#include "../qmldebuggerutils.h"
@@ -83,40 +84,40 @@ int main(int argc, const char *argv[])
8384 bindtextdomain("unity8", translationDirectory().toUtf8().data());
8485 textdomain("unity8");
8586
86− QQuickView* view = new QQuickView();
87− view->setResizeMode(QQuickView::SizeRootObjectToView);
87+ #ifdef UNITY8_ENABLE_TOUCH_EMULATION
88+ // You will need this if you want to interact with touch-only components using a mouse
89+ // Needed only when manually testing on a desktop.
90+ MouseTouchAdaptor *mouseTouchAdaptor = 0;
91+ if (parser.isSet(mousetouchOption)) {
92+ mouseTouchAdaptor = MouseTouchAdaptor::instance();
93+ }
94+ #endif
8895
96+ QQmlApplicationEngine *engine = new QQmlApplicationEngine(application);
97+
98+ int initialWidth = -1;
99+ int initialHeight = -1;
89100 if (parser.isSet(windowGeometryOption) &&
90101 parser.value(windowGeometryOption).split('x').size() == 2)
91102 {
92103 QStringList geom = parser.value(windowGeometryOption).split('x');
93104 QSize windowSize(geom.at(0).toInt(), geom.at(1).toInt());
94105 if (windowSize.isValid()) {
95− view->setWidth(windowSize.width());
96− view->setHeight(windowSize.height());
106+ initialWidth = windowSize.width();
107+ initialHeight = windowSize.height();
97108 }
98109 }
99−
100− view->setTitle(QStringLiteral("Scopes"));
101−
102− #ifdef UNITY8_ENABLE_TOUCH_EMULATION
103− // You will need this if you want to interact with touch-only components using a mouse
104− // Needed only when manually testing on a desktop.
105− MouseTouchAdaptor *mouseTouchAdaptor = 0;
106− if (parser.isSet(mousetouchOption)) {
107− mouseTouchAdaptor = MouseTouchAdaptor::instance();
108− }
109− #endif
110+ engine->rootContext()->setContextProperty("initialWidth", initialWidth);
111+ engine->rootContext()->setContextProperty("initialHeight", initialHeight);
110112
111113 QUrl source(::qmlDirectory() + "/Dash/DashApplication.qml");
112− prependImportPaths(view->engine(), ::overrideImportPaths());
113− appendImportPaths(view->engine(), ::fallbackImportPaths());
114+ prependImportPaths(engine, ::overrideImportPaths());
115+ appendImportPaths(engine, ::fallbackImportPaths());
114116
115117 CachingNetworkManagerFactory *managerFactory = new CachingNetworkManagerFactory();
116− view->engine()->setNetworkAccessManagerFactory(managerFactory);
118+ engine->setNetworkAccessManagerFactory(managerFactory);
117119
118− view->setSource(source);
119− view->show();
120+ engine->load(source);
120121
121122 UnixSignalHandler signalHandler([]{
122123 QGuiApplication::exit(0);
@@ -125,7 +126,7 @@ int main(int argc, const char *argv[])
125126
126127 int result = application->exec();
127128
128− delete view;
129+ delete engine;
129130
130131 #ifdef UNITY8_ENABLE_TOUCH_EMULATION
131132 delete mouseTouchAdaptor;