summaryrefslogtreecommitdiffstats
path: root/examples/webengine/quicknanobrowser/main.cpp
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>2015-01-15 12:39:43 +0100
committerJocelyn Turcotte <jocelyn.turcotte@digia.com>2015-01-23 12:10:42 +0100
commit5d1883372fe107f70a39c9cea13f584a8cc61e0b (patch)
tree51a71f2d28454620d0820c5f850e99af8c4770be /examples/webengine/quicknanobrowser/main.cpp
parentd95b9295c970401939d2779cbdc9e2a8c7965277 (diff)
Clean the file structure of quicknanobrowser and quicktestbrowser
- Remove the unnecessary intermediate ApplicationEngine class - Rename quickwindow.qml to BrowserWindow.qml - Move the injected Utils QObject into utils.h Change-Id: I3b0551e2bf477fc94640c71736de26c46c1ab633 Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Diffstat (limited to 'examples/webengine/quicknanobrowser/main.cpp')
-rw-r--r--examples/webengine/quicknanobrowser/main.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/examples/webengine/quicknanobrowser/main.cpp b/examples/webengine/quicknanobrowser/main.cpp
index d5a4ade55..bcfec07c5 100644
--- a/examples/webengine/quicknanobrowser/main.cpp
+++ b/examples/webengine/quicknanobrowser/main.cpp
@@ -39,7 +39,8 @@
**
****************************************************************************/
-#include "quickwindow.h"
+#include "utils.h"
+
#ifndef QT_NO_WIDGETS
#include <QtWidgets/QApplication>
typedef QApplication Application;
@@ -47,15 +48,36 @@ typedef QApplication Application;
#include <QtGui/QGuiApplication>
typedef QGuiApplication Application;
#endif
+#include <QtQml/QQmlApplicationEngine>
+#include <QtQml/QQmlContext>
#include <QtWebEngine/qtwebengineglobal.h>
+static QUrl startupUrl()
+{
+ QUrl ret;
+ QStringList args(qApp->arguments());
+ args.takeFirst();
+ Q_FOREACH (const QString& arg, args) {
+ if (arg.startsWith(QLatin1Char('-')))
+ continue;
+ ret = Utils::fromUserInput(arg);
+ if (ret.isValid())
+ return ret;
+ }
+ return QUrl(QStringLiteral("http://qt.io/"));
+}
+
int main(int argc, char **argv)
{
Application app(argc, argv);
QtWebEngine::initialize();
- ApplicationEngine appEngine;
+ QQmlApplicationEngine appEngine;
+ Utils utils;
+ appEngine.rootContext()->setContextProperty("utils", &utils);
+ appEngine.load(QUrl("qrc:/BrowserWindow.qml"));
+ QMetaObject::invokeMethod(appEngine.rootObjects().first(), "load", Q_ARG(QVariant, startupUrl()));
return app.exec();
}