summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZeno Albisser <zeno.albisser@digia.com>2013-06-17 12:59:07 +0200
committerZeno Albisser <zeno.albisser@digia.com>2013-06-17 15:38:05 +0200
commit4a08bd334b661d00a9fd908d054728ab9e9a5d8d (patch)
tree3222477087594435f6640af48c4442c69cb99bf5
parent8fd262f1022990abb29b1523b612048fb13822b9 (diff)
Use QQuickControls for QtQuick browser ui.
-rw-r--r--example/icons/go-next.pngbin0 -> 930 bytes
-rw-r--r--example/icons/go-previous.pngbin0 -> 955 bytes
-rw-r--r--example/icons/process-stop.pngbin0 -> 1272 bytes
-rw-r--r--example/icons/view-refresh.pngbin0 -> 1364 bytes
-rw-r--r--example/main.cpp5
-rw-r--r--example/quickwindow.cpp8
-rw-r--r--example/quickwindow.h6
-rw-r--r--example/quickwindow.qml98
8 files changed, 38 insertions, 79 deletions
diff --git a/example/icons/go-next.png b/example/icons/go-next.png
new file mode 100644
index 000000000..6f3f65d33
--- /dev/null
+++ b/example/icons/go-next.png
Binary files differ
diff --git a/example/icons/go-previous.png b/example/icons/go-previous.png
new file mode 100644
index 000000000..93be3d1ee
--- /dev/null
+++ b/example/icons/go-previous.png
Binary files differ
diff --git a/example/icons/process-stop.png b/example/icons/process-stop.png
new file mode 100644
index 000000000..b68290bf1
--- /dev/null
+++ b/example/icons/process-stop.png
Binary files differ
diff --git a/example/icons/view-refresh.png b/example/icons/view-refresh.png
new file mode 100644
index 000000000..cab4d02c7
--- /dev/null
+++ b/example/icons/view-refresh.png
Binary files differ
diff --git a/example/main.cpp b/example/main.cpp
index 01850b879..129d8c6c1 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 5b0ed1d9b..018f1c937 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 7218d084e..3f1f944ca 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 54b82d6c7..3fe0389bf 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 {