2021-09-30 09:43:29 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtWebEngine 1.10
|
|
|
|
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.controls 1.0
|
2021-09-30 09:43:29 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
2021-12-07 23:15:17 +00:00
|
|
|
import "../panels"
|
|
|
|
import "../stores"
|
|
|
|
|
2021-09-30 09:43:29 +00:00
|
|
|
WebEngineView {
|
|
|
|
id: webEngineView
|
2021-12-07 23:15:17 +00:00
|
|
|
|
|
|
|
property var currentWebView
|
|
|
|
property var findBarComp
|
|
|
|
property var favMenu
|
|
|
|
property var addFavModal
|
|
|
|
property var downloadsMenu
|
|
|
|
property var determineRealURLFn: function(url){}
|
|
|
|
|
|
|
|
signal setCurrentWebUrl(var url)
|
|
|
|
|
2021-09-30 09:43:29 +00:00
|
|
|
focus: true
|
|
|
|
|
|
|
|
function changeZoomFactor(newFactor) {
|
|
|
|
// FIXME there seems to be a bug in the WebEngine where the zoomFactor only update 1/2 times
|
|
|
|
zoomFactor = newFactor
|
|
|
|
zoomFactor = newFactor
|
|
|
|
zoomFactor = newFactor
|
|
|
|
}
|
|
|
|
|
2021-10-20 09:50:50 +00:00
|
|
|
settings.autoLoadImages: localAccountSensitiveSettings.autoLoadImages
|
|
|
|
settings.javascriptEnabled: localAccountSensitiveSettings.javaScriptEnabled
|
|
|
|
settings.errorPageEnabled: localAccountSensitiveSettings.errorPageEnabled
|
|
|
|
settings.pluginsEnabled: localAccountSensitiveSettings.pluginsEnabled
|
|
|
|
settings.autoLoadIconsForPage: localAccountSensitiveSettings.autoLoadIconsForPage
|
|
|
|
settings.touchIconsEnabled: localAccountSensitiveSettings.touchIconsEnabled
|
|
|
|
settings.webRTCPublicInterfacesOnly: localAccountSensitiveSettings.webRTCPublicInterfacesOnly
|
|
|
|
settings.pdfViewerEnabled: localAccountSensitiveSettings.pdfViewerEnabled
|
2021-09-30 09:43:29 +00:00
|
|
|
settings.focusOnNavigationEnabled: true
|
|
|
|
|
|
|
|
onQuotaRequested: function(request) {
|
|
|
|
if (request.requestedSize <= 5 * 1024 * 1024)
|
|
|
|
request.accept();
|
|
|
|
else
|
|
|
|
request.reject();
|
|
|
|
}
|
|
|
|
|
|
|
|
onRegisterProtocolHandlerRequested: function(request) {
|
|
|
|
console.log("accepting registerProtocolHandler request for "
|
|
|
|
+ request.scheme + " from " + request.origin);
|
|
|
|
request.accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
onRenderProcessTerminated: function(terminationStatus, exitCode) {
|
|
|
|
var status = "";
|
|
|
|
switch (terminationStatus) {
|
|
|
|
case WebEngineView.NormalTerminationStatus:
|
|
|
|
status = "(normal exit)";
|
|
|
|
break;
|
|
|
|
case WebEngineView.AbnormalTerminationStatus:
|
|
|
|
status = "(abnormal exit)";
|
|
|
|
break;
|
|
|
|
case WebEngineView.CrashedTerminationStatus:
|
|
|
|
status = "(crashed)";
|
|
|
|
break;
|
|
|
|
case WebEngineView.KilledTerminationStatus:
|
|
|
|
status = "(killed)";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
print("Render process exited with code " + exitCode + " " + status);
|
|
|
|
reloadTimer.running = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
onSelectClientCertificate: function(selection) {
|
|
|
|
selection.certificates[0].select();
|
|
|
|
}
|
|
|
|
|
|
|
|
onFindTextFinished: function(result) {
|
2021-12-07 23:15:17 +00:00
|
|
|
if (!findBarComp.visible)
|
|
|
|
findBarComp.visible = true;
|
2021-09-30 09:43:29 +00:00
|
|
|
|
2021-12-07 23:15:17 +00:00
|
|
|
findBarComp.numberOfMatches = result.numberOfMatches;
|
|
|
|
findBarComp.activeMatch = result.activeMatch;
|
2021-09-30 09:43:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onLoadingChanged: function(loadRequest) {
|
|
|
|
if (loadRequest.status === WebEngineView.LoadStartedStatus)
|
2021-12-07 23:15:17 +00:00
|
|
|
findBarComp.reset();
|
2021-09-30 09:43:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onNavigationRequested: {
|
|
|
|
if(request.url.toString().startsWith("file://")){
|
|
|
|
console.log("Local file browsing is disabled" )
|
|
|
|
request.action = WebEngineNavigationRequest.IgnoreRequest;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
active: webEngineView.url.toString() === "status://downloads"
|
|
|
|
width: parent.width
|
|
|
|
height: parent.height
|
|
|
|
z: 54
|
|
|
|
sourceComponent: DownloadView {
|
|
|
|
id: downloadView
|
|
|
|
downloadsModel: DownloadsStore.downloadModel
|
2021-12-07 23:15:17 +00:00
|
|
|
downloadsMenu: webEngineView.downloadsMenu
|
2021-09-30 09:43:29 +00:00
|
|
|
onOpenDownloadClicked: {
|
|
|
|
if (downloadComplete) {
|
|
|
|
return DownloadsStore.openFile(index)
|
|
|
|
}
|
|
|
|
DownloadsStore.openDirectory(index)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
active: !webEngineView.url.toString()
|
|
|
|
width: parent.width
|
|
|
|
height: parent.height
|
|
|
|
z: 54
|
|
|
|
|
|
|
|
sourceComponent: Item {
|
|
|
|
width: parent.width
|
|
|
|
height: parent.height
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: emptyPageImage
|
|
|
|
source: Style.png("browser/compass")
|
|
|
|
width: 294
|
|
|
|
height: 294
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 60
|
2023-04-26 15:33:24 +00:00
|
|
|
cache: false
|
2021-09-30 09:43:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
FavoritesList {
|
|
|
|
id: bookmarkListContainer
|
|
|
|
anchors.horizontalCenter: emptyPageImage.horizontalCenter
|
|
|
|
anchors.top: emptyPageImage.bottom
|
|
|
|
anchors.topMargin: 30
|
|
|
|
width: (parent.width < 700) ? (Math.floor(parent.width/cellWidth)*cellWidth) : 700
|
|
|
|
height: parent.height - emptyPageImage.height - 20
|
|
|
|
model: BookmarksStore.bookmarksModel
|
2021-12-07 23:15:17 +00:00
|
|
|
favMenu: webEngineView.favMenu
|
|
|
|
addFavModal: webEngineView.addFavModal
|
|
|
|
determineRealURLFn: function(url) {
|
|
|
|
return webEngineView.determineRealURLFn(url)
|
|
|
|
}
|
|
|
|
setAsCurrentWebUrl: function(url) {
|
|
|
|
webEngineView.setCurrentWebUrl(url)
|
|
|
|
}
|
2021-09-30 09:43:29 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
// Add fav button at the end of the grid
|
2021-11-12 12:37:05 +00:00
|
|
|
var index = BookmarksStore.getBookmarkIndexByUrl(Constants.newBookmark)
|
|
|
|
if (index !== -1) { BookmarksStore.deleteBookmark(Constants.newBookmark) }
|
|
|
|
BookmarksStore.addBookmark(Constants.newBookmark, qsTr("Add Favorite"))
|
2021-09-30 09:43:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Timer {
|
|
|
|
id: reloadTimer
|
|
|
|
interval: 0
|
|
|
|
running: false
|
|
|
|
repeat: false
|
|
|
|
onTriggered: currentWebView.reload()
|
|
|
|
}
|
|
|
|
}
|