summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAndras Becsi <andras.becsi@theqtcompany.com>2015-05-11 11:42:08 +0200
committerAndras Becsi <andras.becsi@theqtcompany.com>2015-05-11 17:02:43 +0200
commita1b6a4c9edab853f06b870d9ef60a50b28ca36a6 (patch)
treeabcdf44e8cb1bed6339de3fd4d28b86e0a7dba4d /examples
parent18cc8aa2893e62f2b2679e67ed4747243e25da35 (diff)
parent76a990cfa3409214530e77d132cdefd9e96685f9 (diff)
Merge remote-tracking branch 'origin/5.5' into dev
Diffstat (limited to 'examples')
-rw-r--r--examples/webengine/quicknanobrowser/ApplicationRoot.qml25
-rw-r--r--examples/webengine/quicknanobrowser/BrowserDialog.qml2
-rw-r--r--examples/webengine/quicknanobrowser/BrowserWindow.qml47
3 files changed, 43 insertions, 31 deletions
diff --git a/examples/webengine/quicknanobrowser/ApplicationRoot.qml b/examples/webengine/quicknanobrowser/ApplicationRoot.qml
index b16ee0078..b409696be 100644
--- a/examples/webengine/quicknanobrowser/ApplicationRoot.qml
+++ b/examples/webengine/quicknanobrowser/ApplicationRoot.qml
@@ -39,9 +39,19 @@
****************************************************************************/
import QtQuick 2.1
+import QtWebEngine 1.1
QtObject {
id: root
+
+ property QtObject defaultProfile: WebEngineProfile {
+ storageName: "Default"
+ }
+
+ property QtObject otrProfile: WebEngineProfile {
+ offTheRecord: true
+ }
+
property Component browserWindowComponent: BrowserWindow {
applicationRoot: root
onClosing: destroy()
@@ -49,10 +59,19 @@ QtObject {
property Component browserDialogComponent: BrowserDialog {
onClosing: destroy()
}
- function createWindow() { return browserWindowComponent.createObject(root) }
- function createDialog() { return browserDialogComponent.createObject(root) }
+ function createWindow(profile) {
+ var newWindow = browserWindowComponent.createObject(root)
+ newWindow.currentWebView.profile = profile
+ profile.downloadRequested.connect(newWindow.onDownloadRequested)
+ return newWindow
+ }
+ function createDialog(profile) {
+ var newDialog = browserDialogComponent.createObject(root)
+ newDialog.currentWebView.profile = profile
+ return newDialog
+ }
function load(url) {
- var browserWindow = createWindow()
+ var browserWindow = createWindow(defaultProfile)
browserWindow.currentWebView.url = url
}
}
diff --git a/examples/webengine/quicknanobrowser/BrowserDialog.qml b/examples/webengine/quicknanobrowser/BrowserDialog.qml
index 302833083..6202d02f7 100644
--- a/examples/webengine/quicknanobrowser/BrowserDialog.qml
+++ b/examples/webengine/quicknanobrowser/BrowserDialog.qml
@@ -40,7 +40,7 @@
import QtQuick 2.1
import QtQuick.Window 2.2
-import QtWebEngine 1.0
+import QtWebEngine 1.1
Window {
property alias currentWebView: webView
diff --git a/examples/webengine/quicknanobrowser/BrowserWindow.qml b/examples/webengine/quicknanobrowser/BrowserWindow.qml
index aa55bd889..0df17f0ee 100644
--- a/examples/webengine/quicknanobrowser/BrowserWindow.qml
+++ b/examples/webengine/quicknanobrowser/BrowserWindow.qml
@@ -85,22 +85,6 @@ ApplicationWindow {
property alias pluginsEnabled: pluginsEnabled.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: {
@@ -125,7 +109,7 @@ ApplicationWindow {
Action {
shortcut: "Ctrl+T"
onTriggered: {
- tabs.createEmptyTab()
+ tabs.createEmptyTab(currentWebView.profile)
tabs.currentIndex = tabs.count - 1
addressBar.forceActiveFocus();
addressBar.selectAll();
@@ -256,13 +240,15 @@ ApplicationWindow {
id: offTheRecordEnabled
text: "Off The Record"
checkable: true
- checked: false
+ checked: currentWebView.profile.offTheRecord
+ onToggled: currentWebView.profile = checked ? otrProfile : defaultProfile;
}
MenuItem {
id: httpDiskCacheEnabled
text: "HTTP Disk Cache"
- checkable: true
- checked: (defaultProfile.httpCacheType == WebEngineProfile.DiskHttpCache)
+ checkable: !currentWebView.profile.offTheRecord
+ checked: (currentWebView.profile.httpCacheType == WebEngineProfile.DiskHttpCache)
+ onToggled: currentWebView.profile.httpCacheType = checked ? WebEngineProfile.DiskHttpCache : WebEngineProfile.MemoryHttpCache
}
}
}
@@ -289,23 +275,23 @@ ApplicationWindow {
TabView {
id: tabs
- function createEmptyTab() {
+ function createEmptyTab(profile) {
var tab = addTab("", tabComponent)
// We must do this first to make sure that tab.active gets set so that tab.item gets instantiated immediately.
tab.active = true
tab.title = Qt.binding(function() { return tab.item.title })
+ tab.item.profile = profile
return tab
}
anchors.fill: parent
- Component.onCompleted: createEmptyTab()
+ Component.onCompleted: createEmptyTab(defaultProfile)
Component {
id: tabComponent
WebEngineView {
id: webEngineView
focus: true
- profile: offTheRecordEnabled.checked ? otrProfile : defaultProfile
onLinkHovered: {
if (hoveredUrl == "")
@@ -344,17 +330,17 @@ ApplicationWindow {
if (!request.userInitiated)
print("Warning: Blocked a popup window.")
else if (request.destination == WebEngineView.NewViewInTab) {
- var tab = tabs.createEmptyTab()
+ var tab = tabs.createEmptyTab(currentWebView.profile)
tabs.currentIndex = tabs.count - 1
request.openIn(tab.item)
} else if (request.destination == WebEngineView.NewViewInBackgroundTab) {
- var tab = tabs.createEmptyTab()
+ var tab = tabs.createEmptyTab(currentWebView.profile)
request.openIn(tab.item)
} else if (request.destination == WebEngineView.NewViewInDialog) {
- var dialog = applicationRoot.createDialog()
+ var dialog = applicationRoot.createDialog(currentWebView.profile)
request.openIn(dialog.currentWebView)
} else {
- var window = applicationRoot.createWindow()
+ var window = applicationRoot.createWindow(currentWebView.profile)
request.openIn(window.currentWebView)
}
}
@@ -409,6 +395,13 @@ ApplicationWindow {
visible: false
anchors.fill: parent
}
+
+ function onDownloadRequested(download) {
+ downloadView.visible = true
+ downloadView.append(download)
+ download.accept()
+ }
+
Rectangle {
id: statusBubble
color: "oldlace"