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
|
2021-10-20 09:45:38 +00:00
|
|
|
|
2021-12-07 23:15:17 +00:00
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.controls 1.0
|
2021-10-20 09:45:38 +00:00
|
|
|
|
2021-12-07 23:15:17 +00:00
|
|
|
import utils 1.0
|
2021-10-20 09:45:38 +00:00
|
|
|
|
2021-09-30 09:43:29 +00:00
|
|
|
import "../popups"
|
|
|
|
import "../controls"
|
2020-10-07 20:14:55 +00:00
|
|
|
|
2020-10-08 15:31:53 +00:00
|
|
|
Rectangle {
|
2021-09-30 09:43:29 +00:00
|
|
|
id: browserHeader
|
|
|
|
|
|
|
|
property alias favoriteComponent: favoritesBarLoader.sourceComponent
|
2020-10-08 18:08:50 +00:00
|
|
|
property alias addressBar: addressBar
|
2021-09-30 09:43:29 +00:00
|
|
|
|
2021-12-07 23:15:17 +00:00
|
|
|
property var currentUrl
|
|
|
|
property bool isLoading: false
|
|
|
|
property bool canGoBack: false
|
|
|
|
property bool canGoForward: false
|
2021-09-30 09:43:29 +00:00
|
|
|
property var currentFavorite
|
2021-12-07 23:15:17 +00:00
|
|
|
property bool currentTabConnected: false
|
2021-09-30 09:43:29 +00:00
|
|
|
property string dappBrowserAccName: ""
|
|
|
|
property string dappBrowserAccIcon: ""
|
2021-12-07 23:15:17 +00:00
|
|
|
property var settingMenu
|
|
|
|
property var walletMenu
|
2021-09-30 09:43:29 +00:00
|
|
|
|
|
|
|
signal addNewFavoritelClicked(var xPos)
|
2021-12-07 23:15:17 +00:00
|
|
|
signal launchInBrowser(var url)
|
|
|
|
signal openHistoryPopup(var xPos, var yPos)
|
|
|
|
signal goForward()
|
|
|
|
signal goBack()
|
|
|
|
signal reload()
|
|
|
|
signal stopLoading()
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: _internal
|
|
|
|
readonly property int innerMargin: 12
|
|
|
|
}
|
2020-10-07 20:14:55 +00:00
|
|
|
|
|
|
|
width: parent.width
|
2021-11-17 11:49:03 +00:00
|
|
|
height: barRow.height + (favoritesBarLoader.active ? favoritesBarLoader.height : 0)
|
2020-10-08 15:31:53 +00:00
|
|
|
color: Style.current.background
|
|
|
|
border.width: 0
|
2020-10-07 20:14:55 +00:00
|
|
|
|
|
|
|
RowLayout {
|
2020-12-29 17:10:22 +00:00
|
|
|
id: barRow
|
|
|
|
width: parent.width
|
|
|
|
height: 45
|
2021-12-07 23:15:17 +00:00
|
|
|
spacing: _internal.innerMargin
|
2020-10-07 20:14:55 +00:00
|
|
|
|
2021-12-07 23:15:17 +00:00
|
|
|
StatusFlatRoundButton {
|
2020-10-07 20:14:55 +00:00
|
|
|
id: backButton
|
2021-12-03 13:43:17 +00:00
|
|
|
Layout.preferredWidth: 32
|
|
|
|
Layout.preferredHeight: 32
|
2021-10-18 10:34:16 +00:00
|
|
|
icon.height: 20
|
|
|
|
icon.width: 20
|
2022-06-20 19:14:33 +00:00
|
|
|
icon.name: "arrow-left"
|
2021-10-18 10:34:16 +00:00
|
|
|
icon.disabledColor: Style.current.lightGrey
|
2021-12-07 23:15:17 +00:00
|
|
|
type: StatusFlatRoundButton.Type.Tertiary
|
|
|
|
enabled: canGoBack
|
|
|
|
Layout.leftMargin: _internal.innerMargin
|
|
|
|
onClicked: goBack()
|
2020-10-07 20:14:55 +00:00
|
|
|
onPressAndHold: {
|
2021-12-07 23:15:17 +00:00
|
|
|
if (canGoBack || canGoForward) {
|
|
|
|
openHistoryPopup(backButton.x, backButton.y + backButton.height)
|
2020-10-07 20:14:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-07 23:15:17 +00:00
|
|
|
StatusFlatRoundButton {
|
2020-10-07 20:14:55 +00:00
|
|
|
id: forwardButton
|
2021-12-03 13:43:17 +00:00
|
|
|
Layout.preferredWidth: 32
|
|
|
|
Layout.preferredHeight: 32
|
2021-10-18 10:34:16 +00:00
|
|
|
icon.width: 20
|
|
|
|
icon.height: 20
|
2022-06-20 19:14:33 +00:00
|
|
|
icon.name: "arrow-right"
|
2021-10-18 10:34:16 +00:00
|
|
|
icon.disabledColor: Style.current.lightGrey
|
2021-12-07 23:15:17 +00:00
|
|
|
type: StatusFlatRoundButton.Type.Tertiary
|
|
|
|
enabled: canGoForward
|
|
|
|
Layout.leftMargin: -_internal.innerMargin/2
|
|
|
|
onClicked: goForward()
|
2020-10-07 20:14:55 +00:00
|
|
|
onPressAndHold: {
|
2021-12-07 23:15:17 +00:00
|
|
|
if (canGoBack || canGoForward) {
|
|
|
|
openHistoryPopup(backButton.x, backButton.y + backButton.height)
|
2020-10-07 20:14:55 +00:00
|
|
|
}
|
|
|
|
}
|
2020-10-29 19:02:32 +00:00
|
|
|
}
|
|
|
|
|
2020-10-07 20:14:55 +00:00
|
|
|
StyledTextField {
|
|
|
|
id: addressBar
|
2021-12-03 13:43:17 +00:00
|
|
|
Layout.preferredHeight: 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
|
2021-12-03 13:43:17 +00:00
|
|
|
rightPadding: addFavoriteBtn.width + reloadBtn.width + Style.current.bigPadding
|
2022-04-04 11:26:30 +00:00
|
|
|
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
|
2021-04-19 14:02:59 +00:00
|
|
|
onActiveFocusChanged: {
|
|
|
|
if (activeFocus) {
|
|
|
|
addressBar.selectAll()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-07 20:14:55 +00:00
|
|
|
Keys.onPressed: {
|
2021-01-04 21:32:36 +00:00
|
|
|
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
|
2021-12-07 23:15:17 +00:00
|
|
|
launchInBrowser(text)
|
2020-10-07 20:14:55 +00:00
|
|
|
}
|
|
|
|
}
|
2020-10-08 15:31:53 +00:00
|
|
|
|
2021-12-07 23:15:17 +00:00
|
|
|
StatusFlatRoundButton {
|
2020-10-29 19:02:32 +00:00
|
|
|
id: addFavoriteBtn
|
2021-10-18 10:34:16 +00:00
|
|
|
width: 24
|
|
|
|
height: 24
|
2020-10-29 19:02:32 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.right: reloadBtn.left
|
|
|
|
anchors.rightMargin: Style.current.halfPadding
|
2021-12-07 23:15:17 +00:00
|
|
|
visible: !!currentUrl
|
2021-10-18 10:34:16 +00:00
|
|
|
icon.source: !!browserHeader.currentFavorite ? Style.svg("browser/favoriteActive") : Style.svg("browser/favorite")
|
|
|
|
color: "transparent"
|
2021-12-07 23:15:17 +00:00
|
|
|
type: StatusFlatRoundButton.Type.Tertiary
|
2021-09-30 09:43:29 +00:00
|
|
|
onClicked: addNewFavoritelClicked(addFavoriteBtn.x)
|
2020-10-29 19:02:32 +00:00
|
|
|
}
|
|
|
|
|
2021-12-07 23:15:17 +00:00
|
|
|
StatusFlatRoundButton {
|
2020-10-29 19:02:32 +00:00
|
|
|
id: reloadBtn
|
2021-10-18 10:34:16 +00:00
|
|
|
width: 24
|
|
|
|
height: 24
|
2020-10-08 15:31:53 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.halfPadding
|
2021-12-07 23:15:17 +00:00
|
|
|
icon.name: isLoading ? "close-circle" : "refresh"
|
2021-10-18 10:34:16 +00:00
|
|
|
color: "transparent"
|
2021-12-07 23:15:17 +00:00
|
|
|
type: StatusFlatRoundButton.Type.Tertiary
|
|
|
|
onClicked: isLoading ? stopLoading(): reload()
|
2020-10-08 15:31:53 +00:00
|
|
|
}
|
2020-10-07 20:14:55 +00:00
|
|
|
}
|
|
|
|
|
2020-10-19 20:26:16 +00:00
|
|
|
Loader {
|
|
|
|
active: true
|
|
|
|
sourceComponent: currentTabConnected ? connectedBtnComponent : notConnectedBtnCompoent
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: notConnectedBtnCompoent
|
2021-12-07 23:15:17 +00:00
|
|
|
StatusFlatRoundButton {
|
2020-10-19 20:26:16 +00:00
|
|
|
id: accountBtn
|
2021-10-18 10:34:16 +00:00
|
|
|
width: 24
|
|
|
|
height: 24
|
|
|
|
icon.width: 24
|
|
|
|
icon.height: 24
|
|
|
|
icon.name: "filled-account"
|
2021-12-07 23:15:17 +00:00
|
|
|
type: StatusFlatRoundButton.Type.Tertiary
|
2020-10-19 20:26:16 +00:00
|
|
|
onClicked: {
|
2021-12-07 23:15:17 +00:00
|
|
|
if (walletMenu.opened) {
|
|
|
|
walletMenu.close()
|
2020-10-19 20:26:16 +00:00
|
|
|
} else {
|
2021-12-07 23:15:17 +00:00
|
|
|
walletMenu.open()
|
2020-10-19 20:26:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: connectedBtnComponent
|
2021-12-07 23:15:17 +00:00
|
|
|
StatusFlatButton {
|
2020-10-19 20:26:16 +00:00
|
|
|
id: accountBtnConnected
|
2021-10-20 09:45:38 +00:00
|
|
|
icon.name: "wallet"
|
2020-10-19 20:26:16 +00:00
|
|
|
icon.width: 18
|
|
|
|
icon.height: 18
|
2021-09-30 09:43:29 +00:00
|
|
|
icon.color: dappBrowserAccIcon
|
|
|
|
text: dappBrowserAccName
|
2020-10-19 20:26:16 +00:00
|
|
|
onClicked: {
|
2021-12-07 23:15:17 +00:00
|
|
|
if (walletMenu.opened) {
|
|
|
|
walletMenu.close()
|
2020-10-19 20:26:16 +00:00
|
|
|
} else {
|
2021-12-07 23:15:17 +00:00
|
|
|
walletMenu.open()
|
2020-10-19 20:26:16 +00:00
|
|
|
}
|
2020-10-15 17:05:34 +00:00
|
|
|
}
|
|
|
|
}
|
2020-10-07 20:14:55 +00:00
|
|
|
}
|
|
|
|
|
2021-12-07 23:15:17 +00:00
|
|
|
StatusFlatRoundButton {
|
2020-10-07 20:14:55 +00:00
|
|
|
id: settingsMenuButton
|
2021-12-03 13:43:17 +00:00
|
|
|
Layout.preferredHeight: 32
|
|
|
|
Layout.preferredWidth: 32
|
2021-10-18 10:34:16 +00:00
|
|
|
icon.width: 24
|
|
|
|
icon.height: 24
|
|
|
|
icon.name: "more"
|
2021-12-07 23:15:17 +00:00
|
|
|
type: StatusFlatRoundButton.Type.Tertiary
|
|
|
|
Layout.rightMargin: _internal.innerMargin
|
2020-10-09 17:56:42 +00:00
|
|
|
onClicked: {
|
2021-12-07 23:15:17 +00:00
|
|
|
if (settingMenu.opened) {
|
|
|
|
settingMenu.close()
|
2020-10-09 17:56:42 +00:00
|
|
|
} else {
|
2021-12-07 23:15:17 +00:00
|
|
|
settingMenu.open()
|
2020-10-09 17:56:42 +00:00
|
|
|
}
|
|
|
|
}
|
2020-10-07 20:14:55 +00:00
|
|
|
}
|
|
|
|
}
|
2020-12-29 17:10:22 +00:00
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: favoritesBarLoader
|
2021-10-20 09:50:50 +00:00
|
|
|
active: localAccountSensitiveSettings.shouldShowFavoritesBar
|
2020-12-29 17:10:22 +00:00
|
|
|
anchors.top: barRow.bottom
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: Style.current.smallPadding
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.smallPadding
|
|
|
|
}
|
2020-10-07 20:14:55 +00:00
|
|
|
}
|