summaryrefslogtreecommitdiffstats
path: root/examples/webengine/quicknanobrowser/BrowserWindow.qml
diff options
context:
space:
mode:
authorAndras Becsi <andras.becsi@digia.com>2015-02-06 19:29:56 +0100
committerAndras Becsi <andras.becsi@theqtcompany.com>2015-02-09 12:45:58 +0000
commitcd307cdb7d4dfbdaf7c9e7a81f9c39e477909621 (patch)
treedc8c909c2dfc22997d3be68c5322a682acf1a9b0 /examples/webengine/quicknanobrowser/BrowserWindow.qml
parent5e0104030ba3210789c5f7203cc7996dcef71cac (diff)
Improve quicknanobrowser example with new public API features
Promote WebEngineDownloadItem and WebEngine singleton to public API and add DownloadView to the browser example. This patch also adds profile support and webengine settings to quicknanobrowser. Change-Id: Ie81fb330e640fad7feec667a8af3afe67050693f Reviewed-by: Michael BrĂ¼ning <michael.bruning@theqtcompany.com>
Diffstat (limited to 'examples/webengine/quicknanobrowser/BrowserWindow.qml')
-rw-r--r--examples/webengine/quicknanobrowser/BrowserWindow.qml73
1 files changed, 73 insertions, 0 deletions
diff --git a/examples/webengine/quicknanobrowser/BrowserWindow.qml b/examples/webengine/quicknanobrowser/BrowserWindow.qml
index 0b8772791..df13f99b9 100644
--- a/examples/webengine/quicknanobrowser/BrowserWindow.qml
+++ b/examples/webengine/quicknanobrowser/BrowserWindow.qml
@@ -46,6 +46,7 @@ import QtQuick.Layouts 1.0
import QtQuick.Window 2.1
import QtQuick.Controls.Private 1.0
import QtQuick.Dialogs 1.2
+import Qt.labs.settings 1.0
ApplicationWindow {
id: browserWindow
@@ -62,6 +63,34 @@ ApplicationWindow {
StyleItem { id: styleItem }
property bool platformIsMac: styleItem.style == "mac"
+ Settings {
+ property alias autoLoadImages: loadImages.checked;
+ property alias javaScriptEnabled: javaScriptEnabled.checked;
+ property alias errorPageEnabled: errorPageEnabled.checked;
+ }
+
+ WebEngineProfile {
+ id: defaultProfile
+ storageName: "Default"
+ httpCacheType: httpDiskCacheEnabled.checked ? WebEngineProfile.DiskHttpCache : WebEngineProfile.MemoryHttpCache;
+ onDownloadRequested: {
+ downloadView.visible = true
+ downloadView.append(download)
+ download.accept()
+ }
+ }
+
+ WebEngineProfile {
+ id: otrProfile
+ offTheRecord: true
+ }
+
+ Action {
+ shortcut: "Ctrl+D"
+ onTriggered: {
+ downloadView.visible = !downloadView.visible
+ }
+ }
Action {
id: focus
shortcut: "Ctrl+L"
@@ -151,6 +180,44 @@ ApplicationWindow {
text: currentWebView && currentWebView.url
onAccepted: currentWebView.url = utils.fromUserInput(text)
}
+ ToolButton {
+ id: settingsMenuButton
+ menu: Menu {
+ MenuItem {
+ id: loadImages
+ text: "Autoload images"
+ checkable: true
+ checked: WebEngine.settings.autoLoadImages
+ onCheckedChanged: WebEngine.settings.autoLoadImages = checked
+ }
+ MenuItem {
+ id: javaScriptEnabled
+ text: "JavaScript On"
+ checkable: true
+ checked: WebEngine.settings.javascriptEnabled
+ onCheckedChanged: WebEngine.settings.javascriptEnabled = checked
+ }
+ MenuItem {
+ id: errorPageEnabled
+ text: "ErrorPage On"
+ checkable: true
+ checked: WebEngine.settings.errorPageEnabled
+ onCheckedChanged: WebEngine.settings.errorPageEnabled = checked
+ }
+ MenuItem {
+ id: offTheRecordEnabled
+ text: "Off The Record"
+ checkable: true
+ checked: false
+ }
+ MenuItem {
+ id: httpDiskCacheEnabled
+ text: "HTTP Disk Cache"
+ checkable: true
+ checked: (defaultProfile.httpCacheType == WebEngineProfile.DiskHttpCache)
+ }
+ }
+ }
}
ProgressBar {
id: progressBar
@@ -190,6 +257,7 @@ ApplicationWindow {
WebEngineView {
id: webEngineView
focus: true
+ profile: offTheRecordEnabled.checked ? otrProfile : defaultProfile
onLinkHovered: {
if (hoveredUrl == "")
@@ -236,6 +304,11 @@ ApplicationWindow {
onAccepted: certError.ignoreCertificateError()
onRejected: certError.rejectCertificate()
}
+ DownloadView {
+ id: downloadView
+ visible: false
+ anchors.fill: parent
+ }
Rectangle {
id: statusBubble
color: "oldlace"