diff --git a/example/icons/go-next.png b/example/icons/go-next.png new file mode 100644 index 0000000000000000000000000000000000000000..6f3f65d33d303315f0d8d9dd03c7e7e2427d4950 Binary files /dev/null and b/example/icons/go-next.png differ diff --git a/example/icons/go-previous.png b/example/icons/go-previous.png new file mode 100644 index 0000000000000000000000000000000000000000..93be3d1ee6b90843d7df0f517733f63ce72f4611 Binary files /dev/null and b/example/icons/go-previous.png differ diff --git a/example/icons/process-stop.png b/example/icons/process-stop.png new file mode 100644 index 0000000000000000000000000000000000000000..b68290bf1ebf568d8ab080a4e3ec7d75048ec461 Binary files /dev/null and b/example/icons/process-stop.png differ diff --git a/example/icons/view-refresh.png b/example/icons/view-refresh.png new file mode 100644 index 0000000000000000000000000000000000000000..cab4d02c756502f922bbff34df34c0056406bd96 Binary files /dev/null and b/example/icons/view-refresh.png differ diff --git a/example/main.cpp b/example/main.cpp index 01850b8791da74747d10930e5ddef47807944504..129d8c6c1ce7aff628474b3f0993c8ad7f3d5e8a 100644 --- a/example/main.cpp +++ b/example/main.cpp @@ -56,12 +56,11 @@ int mainWidget(int argc, char **argv) int mainQuick(int argc, char **argv) { - QGuiApplication app(argc, argv); + QApplication app(argc, argv); QQuickWebContentsView::registerType(); - QuickWindow window; - window.show(); + ApplicationEngine appEngine; return app.exec(); } diff --git a/example/quickwindow.cpp b/example/quickwindow.cpp index 5b0ed1d9ba31663d5e3b9d147d3a8b26a4ab86eb..018f1c9379f9154a81e236edf97f4d8549d01f80 100644 --- a/example/quickwindow.cpp +++ b/example/quickwindow.cpp @@ -62,10 +62,8 @@ public: #include "quickwindow.moc" -QuickWindow::QuickWindow() +ApplicationEngine::ApplicationEngine() { - engine()->rootContext()->setContextProperty("utils", new Utils(this)); - setSource(QUrl("example/quickwindow.qml")); - setResizeMode(QQuickView::SizeRootObjectToView); - setTitle("QQuick Example"); + rootContext()->setContextProperty("utils", new Utils(this)); + load(QUrl("example/quickwindow.qml")); } diff --git a/example/quickwindow.h b/example/quickwindow.h index 7218d084eb3cd354b6513eb88fa2549ffac2ca83..3f1f944caa3d6a72739f0984767227ed3a31af8e 100644 --- a/example/quickwindow.h +++ b/example/quickwindow.h @@ -42,14 +42,14 @@ #ifndef QUICKWINDOW_H #define QUICKWINDOW_H -#include <QQuickView> +#include <QQmlApplicationEngine> class QWebContentsView; -class QuickWindow : public QQuickView { +class ApplicationEngine : public QQmlApplicationEngine { Q_OBJECT public: - QuickWindow(); + ApplicationEngine(); }; #endif // QUICKWINDOW_H diff --git a/example/quickwindow.qml b/example/quickwindow.qml index 54b82d6c7ef742f3b3506dc614f45a9ebcdca3f8..3fe0389bf466b1da9d71ff59df4efe94844a44d7 100644 --- a/example/quickwindow.qml +++ b/example/quickwindow.qml @@ -1,78 +1,43 @@ import QtQuick 2.0 import QtWebEngine 1.0 +import QtQuick.Controls 1.0 +import QtQuick.Layouts 1.0 -Item { +ApplicationWindow { id: browserWindow - height: 480 - width: 320 + height: 600 + width: 800 + visible: true - Rectangle { + toolBar: ToolBar { id: navigationBar - color: "grey" - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - height: 26 - - Rectangle { - id: backButton - color: "red" - anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.left: parent.left - width: height + RowLayout { + anchors.fill: parent - MouseArea { - anchors.fill: parent - onClicked: { - webContentsView.goBack() - } + ToolButton { + id: backButton + iconName: "go-previous" + iconSource: "icons/go-previous.png" + onClicked: webContentsView.goBack() } - } - Rectangle { - id: forwardButton - color: "green" - anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.left: backButton.right - width: height - - MouseArea { - anchors.fill: parent - onClicked: { - webContentsView.goForward() - } + ToolButton { + id: forwardButton + iconName: "go-next" + iconSource: "icons/go-next.png" + onClicked: webContentsView.goForward() } - } - Rectangle { - id: reloadButton - color: "blue" - anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.left: forwardButton.right - width: height - - MouseArea { - anchors.fill: parent - onClicked: { - webContentsView.reload() - } + ToolButton { + id: reloadButton + iconName: "view-refresh" + iconSource: "icons/view-refresh.png" + onClicked: webContentsView.reload() } - } - TextInput { - id: addressBar - focus: true - anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.left: reloadButton.right - anchors.right: parent.right + TextField { + id: addressBar + focus: true + Layout.fillWidth: true - cursorVisible: true - persistentSelection: true - selectByMouse: true - - onAccepted: { - webContentsView.url = utils.fromUserInput(text) + onAccepted: webContentsView.url = utils.fromUserInput(text) } } } @@ -80,10 +45,7 @@ Item { WebContentsView { id: webContentsView focus: true - anchors.top: navigationBar.bottom - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right + anchors.fill: parent url: "http://qt-project.org/" Binding {