@@ -25,6 +25,7 @@
25#include <QCommandLineParser>
25#include <QCommandLineParser>
26#include <QLibrary>
26#include <QLibrary>
27#include <libintl.h>
27#include <libintl.h>
28+#include <QQmlApplicationEngine>
29#include <paths.h>
30#include <paths.h>
30#include "../qmldebuggerutils.h"
31#include "../qmldebuggerutils.h"
@@ -83,40 +84,40 @@ int main(int argc, const char *argv[])
83 bindtextdomain("unity8", translationDirectory().toUtf8().data());
84 bindtextdomain("unity8", translationDirectory().toUtf8().data());
84 textdomain("unity8");
85 textdomain("unity8");
86− QQuickView* view = new QQuickView();
87+ #ifdef UNITY8_ENABLE_TOUCH_EMULATION
87− view->setResizeMode(QQuickView::SizeRootObjectToView);
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();
96+ QQmlApplicationEngine *engine = new QQmlApplicationEngine(application);
98+ int initialWidth = -1;
99+ int initialHeight = -1;
89 if (parser.isSet(windowGeometryOption) &&
100 if (parser.isSet(windowGeometryOption) &&
90 parser.value(windowGeometryOption).split('x').size() == 2)
101 parser.value(windowGeometryOption).split('x').size() == 2)
92 QStringList geom = parser.value(windowGeometryOption).split('x');
103 QStringList geom = parser.value(windowGeometryOption).split('x');
93 QSize windowSize(geom.at(0).toInt(), geom.at(1).toInt());
104 QSize windowSize(geom.at(0).toInt(), geom.at(1).toInt());
94 if (windowSize.isValid()) {
105 if (windowSize.isValid()) {
95− view->setWidth(windowSize.width());
106+ initialWidth = windowSize.width();
96− view->setHeight(windowSize.height());
107+ initialHeight = windowSize.height();
99−
110+ engine->rootContext()->setContextProperty("initialWidth", initialWidth);
100− view->setTitle(QStringLiteral("Scopes"));
111+ engine->rootContext()->setContextProperty("initialHeight", initialHeight);
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();
111 QUrl source(::qmlDirectory() + "/Dash/DashApplication.qml");
113 QUrl source(::qmlDirectory() + "/Dash/DashApplication.qml");
112− prependImportPaths(view->engine(), ::overrideImportPaths());
114+ prependImportPaths(engine, ::overrideImportPaths());
113− appendImportPaths(view->engine(), ::fallbackImportPaths());
115+ appendImportPaths(engine, ::fallbackImportPaths());
115 CachingNetworkManagerFactory *managerFactory = new CachingNetworkManagerFactory();
117 CachingNetworkManagerFactory *managerFactory = new CachingNetworkManagerFactory();
116− view->engine()->setNetworkAccessManagerFactory(managerFactory);
118+ engine->setNetworkAccessManagerFactory(managerFactory);
118− view->setSource(source);
120+ engine->load(source);
121 UnixSignalHandler signalHandler([]{
122 UnixSignalHandler signalHandler([]{
122 QGuiApplication::exit(0);
123 QGuiApplication::exit(0);
@@ -125,7 +126,7 @@ int main(int argc, const char *argv[])
126 int result = application->exec();
127 int result = application->exec();
128− delete view;
129+ delete engine;
130 #ifdef UNITY8_ENABLE_TOUCH_EMULATION
131 #ifdef UNITY8_ENABLE_TOUCH_EMULATION
131 delete mouseTouchAdaptor;
132 delete mouseTouchAdaptor;