2020-10-07 20:14:55 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
import Qt.labs.settings 1.0
|
|
|
|
import QtQuick.Controls.Styles 1.0
|
2020-10-08 15:31:53 +00:00
|
|
|
import QtWebEngine 1.10
|
2020-10-07 20:14:55 +00:00
|
|
|
import "../../../shared"
|
2020-10-08 15:31:53 +00:00
|
|
|
import "../../../shared/status"
|
2020-10-07 20:14:55 +00:00
|
|
|
import "../../../imports"
|
|
|
|
|
2020-10-08 15:31:53 +00:00
|
|
|
Rectangle {
|
2020-10-07 20:14:55 +00:00
|
|
|
property alias browserSettings: browserSettings
|
2020-10-08 18:08:50 +00:00
|
|
|
property alias addressBar: addressBar
|
2020-10-08 15:31:53 +00:00
|
|
|
readonly property int innerMargin: 12
|
2020-10-07 20:14:55 +00:00
|
|
|
|
|
|
|
id: root
|
|
|
|
width: parent.width
|
|
|
|
height: 45
|
2020-10-08 15:31:53 +00:00
|
|
|
color: Style.current.background
|
|
|
|
border.width: 0
|
2020-10-07 20:14:55 +00:00
|
|
|
|
|
|
|
Settings {
|
|
|
|
id : browserSettings
|
|
|
|
property alias autoLoadImages: loadImages.checked
|
|
|
|
property alias javaScriptEnabled: javaScriptEnabled.checked
|
|
|
|
property alias errorPageEnabled: errorPageEnabled.checked
|
|
|
|
property alias pluginsEnabled: pluginsEnabled.checked
|
|
|
|
property alias autoLoadIconsForPage: autoLoadIconsForPage.checked
|
|
|
|
property alias touchIconsEnabled: touchIconsEnabled.checked
|
|
|
|
property alias webRTCPublicInterfacesOnly : webRTCPublicInterfacesOnly.checked
|
|
|
|
property alias devToolsEnabled: devToolsEnabled.checked
|
|
|
|
property alias pdfViewerEnabled: pdfViewerEnabled.checked
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
anchors.fill: parent
|
2020-10-08 15:31:53 +00:00
|
|
|
spacing: root.innerMargin
|
2020-10-07 20:14:55 +00:00
|
|
|
|
|
|
|
Menu {
|
|
|
|
id: historyMenu
|
|
|
|
Instantiator {
|
|
|
|
model: currentWebView && currentWebView.navigationHistory.items
|
|
|
|
MenuItem {
|
|
|
|
text: model.title
|
|
|
|
onTriggered: currentWebView.goBackOrForward(model.offset)
|
|
|
|
checkable: !enabled
|
|
|
|
checked: !enabled
|
|
|
|
enabled: model.offset
|
|
|
|
}
|
|
|
|
onObjectAdded: function(index, object) {
|
|
|
|
historyMenu.insertItem(index, object)
|
|
|
|
}
|
|
|
|
onObjectRemoved: function(index, object) {
|
|
|
|
historyMenu.removeItem(object)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-08 15:31:53 +00:00
|
|
|
StatusIconButton {
|
2020-10-07 20:14:55 +00:00
|
|
|
id: backButton
|
2020-10-08 15:31:53 +00:00
|
|
|
icon.name: "leave_chat"
|
|
|
|
disabledColor: Style.current.lightGrey
|
2020-10-07 20:14:55 +00:00
|
|
|
onClicked: currentWebView.goBack()
|
|
|
|
onPressAndHold: {
|
|
|
|
if (currentWebView && (currentWebView.canGoBack || currentWebView.canGoForward)){
|
|
|
|
historyMenu.popup(backButton.x, backButton.y + backButton.height)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
enabled: currentWebView && currentWebView.canGoBack
|
2020-10-08 15:31:53 +00:00
|
|
|
width: 24
|
|
|
|
height: 24
|
|
|
|
Layout.leftMargin: root.innerMargin
|
|
|
|
padding: 6
|
2020-10-07 20:14:55 +00:00
|
|
|
}
|
|
|
|
|
2020-10-08 15:31:53 +00:00
|
|
|
StatusIconButton {
|
2020-10-07 20:14:55 +00:00
|
|
|
id: forwardButton
|
2020-10-08 15:31:53 +00:00
|
|
|
icon.name: "leave_chat"
|
|
|
|
iconRotation: 180
|
|
|
|
disabledColor: Style.current.lightGrey
|
2020-10-07 20:14:55 +00:00
|
|
|
onClicked: currentWebView.goForward()
|
|
|
|
onPressAndHold: {
|
|
|
|
if (currentWebView && (currentWebView.canGoBack || currentWebView.canGoForward)){
|
|
|
|
historyMenu.popup(forwardButton.x, forwardButton.y + forwardButton.height)
|
|
|
|
}
|
|
|
|
}
|
2020-10-08 15:31:53 +00:00
|
|
|
enabled: currentWebView && currentWebView.canGoForward
|
|
|
|
width: 24
|
|
|
|
height: 24
|
|
|
|
Layout.leftMargin: -root.innerMargin/2
|
2020-10-07 20:14:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StyledTextField {
|
|
|
|
id: addressBar
|
2020-10-08 15:31:53 +00:00
|
|
|
height: 40
|
2020-10-07 20:14:55 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
background: Rectangle {
|
2020-10-08 15:31:53 +00:00
|
|
|
color: Style.current.inputBackground
|
|
|
|
border.color: Style.current.inputBorderFocus
|
|
|
|
border.width: activeFocus ? 1 : 0
|
|
|
|
radius: 20
|
2020-10-07 20:14:55 +00:00
|
|
|
}
|
2020-10-08 15:31:53 +00:00
|
|
|
leftPadding: Style.current.padding
|
|
|
|
placeholderText: qsTr("Enter URL")
|
2020-10-07 20:14:55 +00:00
|
|
|
focus: true
|
|
|
|
text: ""
|
2020-10-08 15:31:53 +00:00
|
|
|
color: Style.current.textColor
|
2020-10-07 20:14:55 +00:00
|
|
|
Keys.onPressed: {
|
|
|
|
// TODO: disable browsing local files? file://
|
|
|
|
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return){
|
|
|
|
currentWebView.url = determineRealURL(text);
|
|
|
|
}
|
|
|
|
}
|
2020-10-08 15:31:53 +00:00
|
|
|
|
|
|
|
StatusIconButton {
|
|
|
|
id: chatCommandsBtn
|
|
|
|
icon.name: currentWebView && currentWebView.loading ? "close" : "browser/refresh"
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.halfPadding
|
|
|
|
onClicked: currentWebView && currentWebView.loading ? currentWebView.stop() : currentWebView.reload()
|
|
|
|
width: 24
|
|
|
|
height: 24
|
|
|
|
}
|
2020-10-07 20:14:55 +00:00
|
|
|
}
|
|
|
|
|
2020-10-15 17:05:34 +00:00
|
|
|
BrowserWalletMenu {
|
|
|
|
id: browserWalletMenu
|
|
|
|
y: root.height + root.anchors.topMargin
|
|
|
|
x: parent.width - width - Style.current.halfPadding
|
|
|
|
}
|
|
|
|
|
2020-10-08 15:31:53 +00:00
|
|
|
StatusIconButton {
|
2020-10-07 20:14:55 +00:00
|
|
|
id: accountBtn
|
2020-10-08 15:31:53 +00:00
|
|
|
icon.name: "walletIcon"
|
2020-10-15 17:05:34 +00:00
|
|
|
onClicked: {
|
|
|
|
if (browserWalletMenu.opened) {
|
|
|
|
browserWalletMenu.close()
|
|
|
|
} else {
|
|
|
|
browserWalletMenu.open()
|
|
|
|
}
|
|
|
|
}
|
2020-10-08 15:31:53 +00:00
|
|
|
width: 24
|
|
|
|
height: 24
|
|
|
|
padding: 6
|
2020-10-07 20:14:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Menu {
|
|
|
|
id: settingsMenu
|
|
|
|
y: settingsMenuButton.height
|
|
|
|
x: settingsMenuButton.x
|
|
|
|
MenuItem {
|
|
|
|
id: loadImages
|
|
|
|
text: "Autoload images"
|
|
|
|
checkable: true
|
|
|
|
checked: WebEngine.settings.autoLoadImages
|
|
|
|
}
|
|
|
|
MenuItem {
|
|
|
|
id: javaScriptEnabled
|
|
|
|
text: "JavaScript On"
|
|
|
|
checkable: true
|
|
|
|
checked: WebEngine.settings.javascriptEnabled
|
|
|
|
}
|
|
|
|
MenuItem {
|
|
|
|
id: errorPageEnabled
|
|
|
|
text: "ErrorPage On"
|
|
|
|
checkable: true
|
|
|
|
checked: WebEngine.settings.errorPageEnabled
|
|
|
|
}
|
|
|
|
MenuItem {
|
|
|
|
id: pluginsEnabled
|
|
|
|
text: "Plugins On"
|
|
|
|
checkable: true
|
|
|
|
checked: true
|
|
|
|
}
|
|
|
|
MenuItem {
|
|
|
|
id: offTheRecordEnabled
|
|
|
|
text: "Off The Record"
|
|
|
|
checkable: true
|
|
|
|
checked: currentWebView && currentWebView.profile === otrProfile
|
|
|
|
onToggled: function(checked) {
|
|
|
|
if (currentWebView) {
|
|
|
|
currentWebView.profile = checked ? otrProfile : defaultProfile;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MenuItem {
|
|
|
|
id: httpDiskCacheEnabled
|
|
|
|
text: "HTTP Disk Cache"
|
|
|
|
checkable: currentWebView && !currentWebView.profile.offTheRecord
|
|
|
|
checked: currentWebView && (currentWebView.profile.httpCacheType === WebEngineProfile.DiskHttpCache)
|
|
|
|
onToggled: function(checked) {
|
|
|
|
if (currentWebView) {
|
|
|
|
currentWebView.profile.httpCacheType = checked ? WebEngineProfile.DiskHttpCache : WebEngineProfile.MemoryHttpCache;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MenuItem {
|
|
|
|
id: autoLoadIconsForPage
|
|
|
|
text: "Icons On"
|
|
|
|
checkable: true
|
|
|
|
checked: WebEngine.settings.autoLoadIconsForPage
|
|
|
|
}
|
|
|
|
MenuItem {
|
|
|
|
id: touchIconsEnabled
|
|
|
|
text: "Touch Icons On"
|
|
|
|
checkable: true
|
|
|
|
checked: WebEngine.settings.touchIconsEnabled
|
|
|
|
enabled: autoLoadIconsForPage.checked
|
|
|
|
}
|
|
|
|
MenuItem {
|
|
|
|
id: webRTCPublicInterfacesOnly
|
|
|
|
text: "WebRTC Public Interfaces Only"
|
|
|
|
checkable: true
|
|
|
|
checked: WebEngine.settings.webRTCPublicInterfacesOnly
|
|
|
|
}
|
|
|
|
MenuItem {
|
|
|
|
id: devToolsEnabled
|
|
|
|
text: "Open DevTools"
|
|
|
|
checkable: true
|
|
|
|
checked: false
|
|
|
|
}
|
|
|
|
MenuItem {
|
|
|
|
id: pdfViewerEnabled
|
|
|
|
text: "PDF viewer enabled"
|
|
|
|
checkable: true
|
|
|
|
checked: WebEngine.settings.pdfViewerEnabled
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-08 15:31:53 +00:00
|
|
|
StatusIconButton {
|
2020-10-07 20:14:55 +00:00
|
|
|
id: settingsMenuButton
|
2020-10-08 15:31:53 +00:00
|
|
|
icon.name: "dots-icon"
|
2020-10-07 20:14:55 +00:00
|
|
|
onClicked: settingsMenu.open()
|
2020-10-08 15:31:53 +00:00
|
|
|
width: 24
|
|
|
|
height: 24
|
|
|
|
Layout.rightMargin: root.innerMargin
|
|
|
|
padding: 6
|
2020-10-07 20:14:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-08 15:31:53 +00:00
|
|
|
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
|
|
|
D{i:0;width:700}
|
|
|
|
}
|
|
|
|
##^##*/
|