diff options
author | Jüri Valdmann <juri.valdmann@qt.io> | 2019-07-02 12:43:52 +0200 |
---|---|---|
committer | Jüri Valdmann <juri.valdmann@qt.io> | 2019-07-02 12:43:52 +0200 |
commit | 57119f16668cf79dec0dbdfbc9a2183f9e5c44fa (patch) | |
tree | a9f6c7ec75d91eb8408d02dd2c16eec4a39e0541 /examples | |
parent | fb430b4e104dd6313a776980b4798f1333193149 (diff) | |
parent | bd864f6418ed164c19a700fc4b6ebab3be431c62 (diff) |
Merge remote-tracking branch 'origin/5.13' into dev
Change-Id: I806417dd7a6d2594a86ee49feedc4ad9ee48add2
Diffstat (limited to 'examples')
-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 29e1a9da7..088b23e59 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 { |