diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-06-11 12:57:07 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-06-11 12:57:42 +0200 |
commit | 147d70f330648acd105d6eb62493366fcf1e3abd (patch) | |
tree | b47c0939bc7dfa155b787448da5102a10a156cfe /examples/webengine/quicknanobrowser/BrowserWindow.qml | |
parent | 7f89badd0e1b71dabb5a88d1330b08ce9d8b6eb7 (diff) | |
parent | af1c0087e51b6e2ad905259bb7a1d50101735d2d (diff) |
Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
.qmake.conf
src/3rdparty
src/core/configure.json
src/core/profile_io_data_qt.cpp
tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
Change-Id: Ie8ae4aa03881a0733ff497fff46e3f7040735650
Diffstat (limited to 'examples/webengine/quicknanobrowser/BrowserWindow.qml')
-rw-r--r-- | examples/webengine/quicknanobrowser/BrowserWindow.qml | 62 |
1 files changed, 56 insertions, 6 deletions
diff --git a/examples/webengine/quicknanobrowser/BrowserWindow.qml b/examples/webengine/quicknanobrowser/BrowserWindow.qml index d3d597e2b..d095703fb 100644 --- a/examples/webengine/quicknanobrowser/BrowserWindow.qml +++ b/examples/webengine/quicknanobrowser/BrowserWindow.qml @@ -116,7 +116,7 @@ ApplicationWindow { Action { shortcut: StandardKey.AddTab onTriggered: { - tabs.createEmptyTab(currentWebView.profile); + tabs.createEmptyTab(tabs.count != 0 ? currentWebView.profile : defaultProfile); tabs.currentIndex = tabs.count - 1; addressBar.forceActiveFocus(); addressBar.selectAll(); @@ -295,18 +295,22 @@ ApplicationWindow { id: offTheRecordEnabled text: "Off The Record" checkable: true - checked: currentWebView.profile === otrProfile + checked: currentWebView && currentWebView.profile === otrProfile onToggled: function(checked) { - currentWebView.profile = checked ? otrProfile : defaultProfile; + if (currentWebView) { + currentWebView.profile = checked ? otrProfile : defaultProfile; + } } } MenuItem { id: httpDiskCacheEnabled text: "HTTP Disk Cache" - checkable: !currentWebView.profile.offTheRecord - checked: (currentWebView.profile.httpCacheType === WebEngineProfile.DiskHttpCache) + checkable: currentWebView && !currentWebView.profile.offTheRecord + checked: currentWebView && (currentWebView.profile.httpCacheType === WebEngineProfile.DiskHttpCache) onToggled: function(checked) { - currentWebView.profile.httpCacheType = checked ? WebEngineProfile.DiskHttpCache : WebEngineProfile.MemoryHttpCache; + if (currentWebView) { + currentWebView.profile.httpCacheType = checked ? WebEngineProfile.DiskHttpCache : WebEngineProfile.MemoryHttpCache; + } } } MenuItem { @@ -380,6 +384,52 @@ ApplicationWindow { anchors.right: parent.right Component.onCompleted: createEmptyTab(defaultProfile) + // Add custom tab view style so we can customize the tabs to include a close button + style: TabViewStyle { + property color frameColor: "#999" + property color fillColor: "#eee" + property color nonSelectedColor: "#ddd" + frameOverlap: 1 + frame: Rectangle { + color: "#eee" + border.color: frameColor + } + tab: Rectangle { + id: tabRectangle + color: styleData.selected ? fillColor : nonSelectedColor + border.width: 1 + border.color: frameColor + implicitWidth: Math.max(text.width + 30, 80) + implicitHeight: Math.max(text.height + 10, 20) + Rectangle { height: 1 ; width: parent.width ; color: frameColor} + Rectangle { height: parent.height ; width: 1; color: frameColor} + Rectangle { x: parent.width - 2; height: parent.height ; width: 1; color: frameColor} + Text { + id: text + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + anchors.leftMargin: 6 + text: styleData.title + elide: Text.ElideRight + color: styleData.selected ? "black" : frameColor + } + Button { + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + anchors.rightMargin: 4 + height: 12 + style: ButtonStyle { + background: Rectangle { + implicitWidth: 12 + implicitHeight: 12 + color: control.hovered ? "#ccc" : tabRectangle.color + Text {text: "x" ; anchors.centerIn: parent ; color: "gray"} + }} + onClicked: tabs.removeTab(styleData.index); + } + } + } + Component { id: tabComponent WebEngineView { |