Verified Commit d1dd9c1c authored by Jonah Brüchert's avatar Jonah Brüchert
Browse files

Load as much as possible after startup using loaders

parent 2fcbd9ba
import QtQuick 2.0
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.2 as Controls
import org.kde.kirigami 2.5 as Kirigami
Kirigami.OverlaySheet {
id: authSheet
property var request
Kirigami.FormLayout {
Layout.fillWidth: true
Kirigami.Heading {
elide: Text.ElideRight
wrapMode: Text.WordWrap
Layout.fillWidth: true
text: i18n("Authentication required")
}
Controls.TextField {
id: usernameField
Kirigami.FormData.label: i18n("Username")
Layout.fillWidth: true
}
Controls.TextField {
id: passwordField
echoMode: TextInput.Password
Kirigami.FormData.label: i18n("Password")
Layout.fillWidth: true
}
RowLayout {
Layout.fillWidth: true
Controls.Button {
Layout.fillWidth: true
text: i18n("Accept")
onClicked: {
authSheet.request.dialogAccept(usernameField.text, passwordField.text)
authSheet.close()
}
}
Controls.Button {
Layout.fillWidth: true
text: i18n("Cancel")
onClicked: {
authSheet.request.dialogReject()
authSheet.close()
}
}
}
}
}
import QtQuick 2.0
import org.kde.kirigami 2.4 as Kirigami
Kirigami.InlineMessage {
id: downloadQuestion
text: i18n("Do you want to download this file?")
showCloseButton: false
property var download
actions: [
Kirigami.Action {
iconName: "download"
text: i18n("Download")
onTriggered: {
downloadQuestion.download.resume()
downloadQuestion.visible = false
}
},
Kirigami.Action {
icon.name: "dialog-cancel"
text: i18n("Cancel")
onTriggered: {
downloadQuestion.download.cancel()
downloadQuestion.visible = false
}
}
]
}
InputSheet {
id: findSheet
title: i18n("Find in page")
placeholderText: i18n("Find...")
description: i18n("Highlight text on the current website")
onAccepted: currentWebView.findText(findSheet.text)
}
import QtQuick 2.0
import org.kde.kirigami 2.4 as Kirigami
Kirigami.InlineMessage {
id: newTabQuestion
type: Kirigami.MessageType.Warning
text: url? i18n("Site wants to open a new tab: \n%1", url.toString()) : ""
showCloseButton: true
property var url
actions: [
Kirigami.Action {
icon.name: "tab-new"
text: i18n("Open")
onTriggered: {
tabs.newTab(newTabQuestion.url.toString())
newTabQuestion.visible = false
}
}
]
}
import org.kde.kirigami 2.4 as Kirigami
import QtWebEngine 1.5
Kirigami.InlineMessage {
property int permission
property string origin
id: permissionQuestion
text: {
if (permission === WebEngineView.Geolocation)
i18n("Do you want to allow the website to access the geo location?")
else if (permission === WebEngineView.MediaAudioCapture)
i18n("Do you want to allow the website to access the microphone?")
else if (permission === WebEngineView.MediaVideoCapture)
i18n("Do you want to allow the website to access the camera?")
else if (permission === WebEngineView.MediaAudioVideoCapture)
i18n("Do you want to allow the website to access the camera and the microphone?")
}
showCloseButton: false
actions: [
Kirigami.Action {
icon.name: "dialog-ok-apply"
text: i18n("Accept")
onTriggered: {
currentWebView.grantFeaturePermission(
permissionQuestion.origin,
permissionQuestion.permission, true)
permissionQuestion.visible = false
}
},
Kirigami.Action {
icon.name: "dialog-cancel"
text: i18n("Decline")
onTriggered: {
currentWebView.grantFeaturePermission(
permissionQuestion.origin,
permissionQuestion.permission, false)
downloadQuestion.visible = false
}
}
]
}
......@@ -35,6 +35,7 @@ Kirigami.OverlaySheet {
id: view
pluginType: "ShareUrl"
implicitHeight: initialItem.contentHeight
clip: true
delegate: Kirigami.BasicListItem {
label: model.display
......
......@@ -57,7 +57,7 @@ Kirigami.ScrollablePage {
//live: true
anchors.fill: parent
anchors.margins: Kirigami.Units.gridUnit / 2
anchors.margins: Kirigami.Units.gridUnit * 0.5
sourceRect: Qt.rect(0, 0, width * 2, height * 2)
......
......@@ -64,8 +64,10 @@ WebEngineView {
// therefore just stop the download again as quickly as possible,
// and ask the user for confirmation
download.pause()
downloadQuestion.download = download
downloadQuestion.visible = true
questionLoader.setSource("DownloadQuestion.qml")
questionLoader.item.download = download
questionLoader.item.visible = true
}
onDownloadFinished: {
......@@ -110,7 +112,7 @@ WebEngineView {
Controls.MenuItem {
enabled: contextMenu.request.linkUrl !== ""
text: i18n("Copy Url")
onTriggered: webEngineView.triggerWebAction(WebEngineView.CopyLinkToClipboard)
onTriggered: webEngineView.triggerWebAction(WebEngineView.CopyLinkToClipboard)
}
Controls.MenuItem {
text: i18n("View source")
......@@ -127,61 +129,6 @@ WebEngineView {
}
}
Kirigami.OverlaySheet {
id: authSheet
property var request
Kirigami.FormLayout {
Layout.fillWidth: true
Kirigami.Heading {
elide: Text.ElideRight
wrapMode: Text.WordWrap
Layout.fillWidth: true
text: i18n("Authentication required")
}
Controls.TextField {
id: usernameField
Kirigami.FormData.label: i18n("Username")
Layout.fillWidth: true
}
Controls.TextField {
id: passwordField
echoMode: TextInput.Password
Kirigami.FormData.label: i18n("Password")
Layout.fillWidth: true
}
RowLayout {
Layout.fillWidth: true
Controls.Button {
Layout.fillWidth: true
text: i18n("Accept")
onClicked: {
authSheet.request.dialogAccept(usernameField.text, passwordField.text)
authSheet.close()
}
}
Controls.Button {
Layout.fillWidth: true
text: i18n("Cancel")
onClicked: {
authSheet.request.dialogReject()
authSheet.close()
}
}
}
}
}
//Rectangle { color: "yellow"; opacity: 0.3; anchors.fill: parent }
focus: true
onLoadingChanged: {
//print("Loading: " + loading);
......@@ -227,8 +174,9 @@ WebEngineView {
newTab(request.requestedUrl.toString())
showPassiveNotification(i18n("Website was opened in a new tab"))
} else {
newTabQuestion.url = request.requestedUrl
newTabQuestion.visible = true
questionLoader.setSource("NewTabQuestion.qml")
questionLoader.item.url = request.requestedUrl
questionLoader.item.visible = true
}
}
......@@ -250,13 +198,15 @@ WebEngineView {
onAuthenticationDialogRequested: {
request.accepted = true
authSheet.request = request
authSheet.open()
sheetLoader.setSource("AuthSheet.qml")
sheetLoader.item.request = request
sheetLoader.item.open()
}
onFeaturePermissionRequested: {
permissionQuestion.permission = feature
permissionQuestion.origin = securityOrigin
permissionQuestion.visible = true
questionLoader.setSource("PermissionQuestion.qml")
questionLoader.item.permission = feature
questionLoader.item.origin = securityOrigin
questionLoader.item.visible = true
}
}
......@@ -172,98 +172,12 @@ Kirigami.ApplicationWindow {
visible: currentWebView.errorCode !== ""
}
Kirigami.InlineMessage {
id: newTabQuestion
type: Kirigami.MessageType.Warning
text: url? i18n("Site wants to open a new tab: \n%1", url.toString()) : ""
showCloseButton: true
anchors.bottom: navigation.top
anchors.left: parent.left
anchors.right: parent.right
property var url
actions: [
Kirigami.Action {
icon.name: "tab-new"
text: i18n("Open")
onTriggered: {
tabs.newTab(newTabQuestion.url.toString())
newTabQuestion.visible = false
}
}
Loader {
id: questionLoader
]
}
Kirigami.InlineMessage {
id: downloadQuestion
text: i18n("Do you want to download this file?")
showCloseButton: false
anchors.bottom: navigation.top
anchors.left: parent.left
anchors.right: parent.right
property var download
actions: [
Kirigami.Action {
iconName: "download"
text: i18n("Download")
onTriggered: {
downloadQuestion.download.resume()
downloadQuestion.visible = false
}
},
Kirigami.Action {
icon.name: "dialog-cancel"
text: i18n("Cancel")
onTriggered: {
downloadQuestion.download.cancel()
downloadQuestion.visible = false
}
}
]
}
Kirigami.InlineMessage {
property int permission
property string origin
id: permissionQuestion
text: {
if (permission === WebEngineView.Geolocation)
i18n("Do you want to allow the website to access the geo location?")
else if (permission === WebEngineView.MediaAudioCapture)
i18n("Do you want to allow the website to access the microphone?")
else if (permission === WebEngineView.MediaVideoCapture)
i18n("Do you want to allow the website to access the camera?")
else if (permission === WebEngineView.MediaAudioVideoCapture)
i18n("Do you want to allow the website to access the camera and the microphone?")
}
showCloseButton: false
anchors.bottom: navigation.top
anchors.left: parent.left
anchors.right: parent.right
actions: [
Kirigami.Action {
icon.name: "dialog-ok-apply"
text: i18n("Accept")
onTriggered: {
currentWebView.grantFeaturePermission(permissionQuestion.origin, permissionQuestion.permission, true)
permissionQuestion.visible = false
}
},
Kirigami.Action {
icon.name: "dialog-cancel"
text: i18n("Decline")
onTriggered: {
currentWebView.grantFeaturePermission(permissionQuestion.origin, permissionQuestion.permission, false)
downloadQuestion.visible = false
}
}
]
}
// Container for the progress bar
......@@ -292,37 +206,30 @@ Kirigami.ApplicationWindow {
bottom: parent.bottom
}
}
}
// Find in page
InputSheet {
id: findSheet
title: i18n("Find in page")
placeholderText: i18n("Find...")
description: i18n("Highlight text on the current website")
onAccepted: currentWebView.findText(findSheet.text)
}
// Share page
ShareSheet {
id: shareSheet
Loader {
id: sheetLoader
}
// The menu at the bottom right
contextualActions: [
Kirigami.Action {
icon.name: "edit-find"
onTriggered: findSheet.open()
onTriggered: {
sheetLoader.setSource("FindInPageSheet.qml")
sheetLoader.item.open()
}
text: i18n("Find in page")
},
Kirigami.Action {
icon.name: "document-share"
text: i18n("Share page")
onTriggered: {
shareSheet.url = currentWebView.url
shareSheet.title = currentWebView.title
shareSheet.open()
sheetLoader.setSource("ShareSheet.qml")
sheetLoader.item.url = currentWebView.url
sheetLoader.item.title = currentWebView.title
sheetLoader.item.open()
}
},
Kirigami.Action {
......
......@@ -14,5 +14,10 @@
<file alias="InputSheet.qml">contents/ui/InputSheet.qml</file>
<file alias="ShareSheet.qml">contents/ui/ShareSheet.qml</file>
<file alias="Completion.qml">contents/ui/Completion.qml</file>
<file alias="AuthSheet.qml">contents/ui/AuthSheet.qml</file>
<file alias="NewTabQuestion.qml">contents/ui/NewTabQuestion.qml</file>
<file alias="DownloadQuestion.qml">contents/ui/DownloadQuestion.qml</file>
<file alias="PermissionQuestion.qml">contents/ui/PermissionQuestion.qml</file>
<file alias="FindInPageSheet.qml">contents/ui/FindInPageSheet.qml</file>
</qresource>
</RCC>
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