Commit b46ba7fd authored by Simon Schmeißer's avatar Simon Schmeißer Committed by Jonah Brüchert
Browse files

Add support for opening new tabs from webview

also requests confirmation for "unwanted popups"
used http://www.popuptest.com for testing
parent 85f5ee20
......@@ -55,12 +55,12 @@ ListView {
function createEmptyTab() {
var t = newTab("");
tabs.currentIndex = tabs.count - 1
return t;
}
function newTab(url) {
tabsModel.append({pageurl: url});
tabs.currentIndex = tabs.count - 1
}
Component.onCompleted: {
......
......@@ -26,7 +26,6 @@ import QtWebEngine 1.7
import org.kde.kirigami 2.4 as Kirigami
WebEngineView {
id: webEngineView
......@@ -145,8 +144,13 @@ WebEngineView {
}
onNewViewRequested: {
newTab(request.requestedUrl.toString())
showPassiveNotification("Website was opened in a new tab")
if (request.userInitiated) {
newTab(request.requestedUrl.toString())
showPassiveNotification("Website was opened in a new tab")
} else {
newTabQuestion.url = request.requestedUrl
newTabQuestion.visible = true
}
}
onContextMenuRequested: {
......
......@@ -99,6 +99,30 @@ Kirigami.ApplicationWindow {
visible: !navigation.textFocus
}
Kirigami.InlineMessage {
id: newTabQuestion
type: Kirigami.MessageType.Warning
text: i18n("Site wants to open a new tab: \n%1", url.toString())
showCloseButton: true
anchors.top: navigation.bottom
anchors.left: parent.left
anchors.right: parent.right
property var url
actions: [
Kirigami.Action {
iconName: "tab-new"
text: i18n("Open")
onTriggered: {
tabs.newTab(newTabQuestion.url.toString())
newTabQuestion.visible = false
}
}
]
}
// Container for the progress bar
Item {
id: progressItem
......@@ -166,6 +190,7 @@ Kirigami.ApplicationWindow {
onTextChanged: urlFilter.setFilterFixedString(text)
}
ListView {
id: completion
property string searchText: navigation.text
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment