2020-09-22 15:12:48 +00:00
import QtQuick 2.13
2020-09-28 18:33:37 +00:00
import QtQuick . Controls 2.13
2020-09-22 15:12:48 +00:00
import QtQuick . Layouts 1.13
2020-09-22 19:16:44 +00:00
import QtWebEngine 1.10
import QtWebChannel 1.13
2020-09-28 18:33:37 +00:00
import Qt . labs . settings 1.0
import QtQuick . Controls . Styles 1.0
import QtQuick . Dialogs 1.2
2021-09-30 09:43:29 +00:00
2021-09-28 15:04:06 +00:00
import utils 1.0
2021-10-27 21:27:49 +00:00
import shared . controls 1.0
2021-09-30 09:43:29 +00:00
2021-10-27 21:27:49 +00:00
import shared 1.0
import shared . status 1.0
2021-12-08 21:20:43 +00:00
import shared . popups 1.0
2021-10-01 15:58:36 +00:00
2021-09-30 09:43:29 +00:00
import "popups"
import "controls"
import "views"
import "panels"
import "stores"
2020-09-22 15:12:48 +00:00
2022-02-09 09:43:23 +00:00
// Code based on https://code.qt.io/cgit/qt/qtwebengine.git/tree/examples/webengine/quicknanobrowser/BrowserWindow.qml?h=5.15
2020-09-28 18:33:37 +00:00
// Licensed under BSD
2020-10-08 18:08:50 +00:00
Rectangle {
2020-09-28 18:33:37 +00:00
id: browserWindow
2021-10-22 20:49:47 +00:00
property var globalStore
2021-12-07 23:15:17 +00:00
property var sendTransactionModal
2020-10-22 17:34:14 +00:00
2021-12-07 23:15:17 +00:00
function openUrlInNewTab ( url ) {
var tab = _internal . addNewTab ( )
tab . item . url = _internal . determineRealURL ( url )
2020-09-28 18:33:37 +00:00
}
2020-11-16 16:44:23 +00:00
2021-12-07 23:15:17 +00:00
QtObject {
id: _internal
2020-11-16 16:44:23 +00:00
2021-12-07 23:15:17 +00:00
property Item currentWebView: tabs . currentIndex < tabs . count ? tabs . getTab ( tabs . currentIndex ) . item : null
2020-09-28 18:33:37 +00:00
2021-12-07 23:15:17 +00:00
property Component browserDialogComponent: BrowserDialog {
onClosing: destroy ( )
}
2020-09-25 19:05:07 +00:00
2021-12-07 23:15:17 +00:00
property Component jsDialogComponent: JSDialogWindow { }
2020-09-25 19:05:07 +00:00
2021-12-07 23:15:17 +00:00
property Component accessDialogComponent: BrowserConnectionModal {
currentTab: tabs . getTab ( tabs . currentIndex ) && tabs . getTab ( tabs . currentIndex ) . item
parent: browserWindow
x: browserWindow . width - width - Style . current . halfPadding
y: browserWindow . y + browserHeader . height + Style . current . halfPadding
web3Response: function ( message ) {
provider . web3Response ( message )
}
}
2020-10-05 16:24:43 +00:00
2021-12-07 23:15:17 +00:00
// TODO we'll need a new dialog at one point because this one is not using the same call, but it's good for now
property Component sendTransactionModalComponent: SignTransactionModal {
2022-02-11 19:34:12 +00:00
anchors.centerIn: parent
2021-12-07 23:15:17 +00:00
store: browserWindow . globalStore
2022-01-04 12:06:05 +00:00
contactsStore: browserWindow . globalStore . profileSectionStore . contactsStore
2022-05-19 08:53:57 +00:00
chainId: browserWindow . globalStore . getChainIdForBrowser ( )
2021-12-07 23:15:17 +00:00
}
2020-10-02 17:30:27 +00:00
2021-12-07 23:15:17 +00:00
property Component signMessageModalComponent: SignMessageModal { }
2020-10-05 16:24:43 +00:00
2021-12-07 23:15:17 +00:00
property MessageDialog sendingError: MessageDialog {
//% "Error sending the transaction"
title: qsTrId ( "error-sending-the-transaction" )
icon: StandardIcon . Critical
standardButtons: StandardButton . Ok
}
2020-09-28 18:33:37 +00:00
2021-12-07 23:15:17 +00:00
property MessageDialog signingError: MessageDialog {
//% "Error signing message"
title: qsTrId ( "error-signing-message" )
icon: StandardIcon . Critical
standardButtons: StandardButton . Ok
}
property QtObject defaultProfile: WebEngineProfile {
storageName: "Profile"
offTheRecord: false
httpUserAgent: {
if ( localAccountSensitiveSettings . compatibilityMode ) {
// Google doesn't let you connect if the user agent is Chrome-ish and doesn't satisfy some sort of hidden requirement
return "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0"
}
return ""
2020-09-28 18:33:37 +00:00
}
2021-12-07 23:15:17 +00:00
useForGlobalCertificateVerification: true
userScripts: [
WebEngineScript {
injectionPoint: WebEngineScript . DocumentCreation
sourceUrl: Qt . resolvedUrl ( "./helpers/provider.js" )
worldId: WebEngineScript . MainWorld // TODO: check https://doc.qt.io/qt-5/qml-qtwebengine-webenginescript.html#worldId-prop
}
]
}
2020-09-28 18:33:37 +00:00
2021-12-07 23:15:17 +00:00
property QtObject otrProfile: WebEngineProfile {
offTheRecord: true
persistentCookiesPolicy: WebEngineProfile . NoPersistentCookies
httpUserAgent: _internal . defaultProfile . httpUserAgent
userScripts: [
WebEngineScript {
injectionPoint: WebEngineScript . DocumentCreation
sourceUrl: Qt . resolvedUrl ( "./helpers/provider.js" )
worldId: WebEngineScript . MainWorld // TODO: check https://doc.qt.io/qt-5/qml-qtwebengine-webenginescript.html#worldId-prop
}
]
}
2020-09-28 18:33:37 +00:00
2021-12-07 23:15:17 +00:00
function addNewDownloadTab ( ) {
tabs . createDownloadTab ( tabs . count !== 0 ? currentWebView.profile : defaultProfile ) ;
tabs . currentIndex = tabs . count - 1 ;
}
2020-11-20 12:45:41 +00:00
2021-12-07 23:15:17 +00:00
function addNewTab ( ) {
var tab = tabs . createEmptyTab ( tabs . count !== 0 ? currentWebView.profile : defaultProfile ) ;
tabs . currentIndex = tabs . count - 1 ;
browserHeader . addressBar . forceActiveFocus ( ) ;
browserHeader . addressBar . selectAll ( ) ;
2021-11-15 12:36:22 +00:00
2021-12-07 23:15:17 +00:00
return tab ;
}
2020-10-08 18:36:44 +00:00
2021-12-07 23:15:17 +00:00
function onDownloadRequested ( download ) {
downloadBar . isVisible = true
download . accept ( ) ;
DownloadsStore . addDownload ( download )
}
2021-04-20 12:09:53 +00:00
2021-12-07 23:15:17 +00:00
function determineRealURL ( url ) {
return Web3ProviderStore . determineRealURL ( url )
}
2021-09-30 09:43:29 +00:00
2021-12-07 23:15:17 +00:00
onCurrentWebViewChanged: {
findBar . reset ( ) ;
browserHeader . addressBar . text = Web3ProviderStore . obtainAddress ( currentWebView . url )
}
2020-09-28 18:33:37 +00:00
}
2020-10-09 17:56:42 +00:00
2021-09-30 09:43:29 +00:00
Layout.fillHeight: true
Layout.fillWidth: true
color: Style . current . inputBackground
border.width: 0
2020-09-28 18:33:37 +00:00
2021-12-07 23:15:17 +00:00
WebProviderObj {
id: provider
createAccessDialogComponent: function ( ) {
return _internal . accessDialogComponent . createObject ( browserWindow )
}
createSendTransactionModalComponent: function ( request ) {
2022-05-16 09:49:40 +00:00
return _internal . sendTransactionModalComponent . createObject ( browserWindow , {
trxData: request . payload . params [ 0 ] . data || "" ,
selectedAccount: {
name: WalletStore . dappBrowserAccount . name ,
address: request . payload . params [ 0 ] . from ,
iconColor: WalletStore . dappBrowserAccount . color ,
assets: WalletStore . dappBrowserAccount . assets
} ,
selectedRecipient: {
address: request . payload . params [ 0 ] . to ,
identicon: "" ,
name: RootStore . activeChannelName ,
type: RecipientSelector . Type . Address
} ,
selectedAsset: {
name: "ETH" ,
symbol: "ETH" ,
address: Constants . zeroAddress
} ,
selectedFiatAmount: "42" , // TODO calculate that
selectedAmount: RootStore . getWei2Eth ( request . payload . params [ 0 ] . value , 18 )
} )
2021-12-07 23:15:17 +00:00
}
createSignMessageModalComponent: function ( request ) {
return _internal . signMessageModalComponent . createObject ( browserWindow , {
request ,
selectedAccount: {
name: WalletStore . dappBrowserAccount . name ,
iconColor: WalletStore . dappBrowserAccount . color
}
} )
}
showSendingError: function ( message ) {
2022-02-09 16:39:10 +00:00
_internal . sendingError . text = message
2021-12-07 23:15:17 +00:00
return _internal . sendingError . open ( )
}
showSigningError: function ( message ) {
2022-02-09 16:39:10 +00:00
_internal . signingError . text = message
2021-12-07 23:15:17 +00:00
return _internal . signingError . open ( )
}
showToastMessage: function ( result ) {
// TODO: WIP under PR https://github.com/status-im/status-desktop/pull/4274
2022-05-05 10:28:54 +00:00
let url = ` $ { WalletStore . getEtherscanLink ( ) } / $ { result } ` ;
Global . displayToastMessage ( qsTr ( "Transaction pending..." ) ,
2022-05-19 08:53:57 +00:00
qsTr ( "View on etherscan" ) ,
2022-05-05 10:28:54 +00:00
"" ,
true ,
Constants . ephemeralNotificationType . normal ,
url ) ;
2021-12-07 23:15:17 +00:00
}
}
2021-09-30 09:43:29 +00:00
BrowserShortcutActions {
id: keyboardShortcutActions
2021-12-07 23:15:17 +00:00
currentWebView: _internal . currentWebView
findBarComponent: findBar
browserHeaderComponent: browserHeader
onAddNewDownloadTab: _internal . addNewDownloadTab ( )
onRemoveView: tabs . removeView ( tabs . currentIndex )
2020-09-28 18:33:37 +00:00
}
2021-09-30 09:43:29 +00:00
WebChannel {
id: channel
registeredObjects: [ provider ]
2020-09-28 18:33:37 +00:00
}
2020-10-07 20:14:55 +00:00
BrowserHeader {
id: browserHeader
2020-10-08 18:08:50 +00:00
anchors.top: parent . top
anchors.topMargin: tabs . tabHeight + tabs . anchors . topMargin
z: 52
2021-09-30 09:43:29 +00:00
favoriteComponent: favoritesBar
2021-12-07 23:15:17 +00:00
currentFavorite: _internal . currentWebView && BookmarksStore . getCurrentFavorite ( _internal . currentWebView . url )
2021-09-30 09:43:29 +00:00
dappBrowserAccName: WalletStore . dappBrowserAccount . name
2021-11-18 23:40:49 +00:00
dappBrowserAccIcon: WalletStore . dappBrowserAccount . color
2021-12-07 23:15:17 +00:00
settingMenu: settingsMenu
walletMenu: browserWalletMenu
currentUrl: _internal . currentWebView . url
isLoading: _internal . currentWebView . loading
canGoBack: _internal . currentWebView . canGoBack
canGoForward: _internal . currentWebView . canGoForward
currentTabConnected: RootStore . currentTabConnected
onOpenHistoryPopup: historyMenu . popup ( xPos , yPos )
onGoBack: _internal . currentWebView . goBack ( )
onGoForward: _internal . currentWebView . goForward ( )
onReload: _internal . currentWebView . reload ( )
onStopLoading: _internal . currentWebView . stop ( )
2021-09-30 09:43:29 +00:00
onAddNewFavoritelClicked: {
2022-01-28 12:02:48 +00:00
Global . openPopup ( addFavoriteModal ,
{
x: xPos - 30 ,
y: browserHeader . y + browserHeader . height + 4 ,
2021-12-14 17:56:59 +00:00
modifiyModal: browserHeader . currentFavorite ,
toolbarMode: true ,
ogUrl: browserHeader . currentFavorite ? browserHeader.currentFavorite.url : _internal . currentWebView . url ,
2022-01-28 12:02:48 +00:00
ogName: browserHeader . currentFavorite ? browserHeader.currentFavorite.name : _internal . currentWebView . title
} )
2020-09-28 18:33:37 +00:00
}
2021-12-07 23:15:17 +00:00
onLaunchInBrowser: {
// TODO: disable browsing local files? file://
if ( localAccountSensitiveSettings . useBrowserEthereumExplorer !== Constants . browserEthereumExplorerNone && url . startsWith ( "0x" ) ) {
_internal . currentWebView . url = RootStore . get0xFormedUrl ( localAccountSensitiveSettings . useBrowserEthereumExplorer , url )
return
}
if ( localAccountSensitiveSettings . shouldShowBrowserSearchEngine !== Constants . browserSearchEngineNone && ! Utils . isURL ( url ) && ! Utils . isURLWithOptionalProtocol ( url ) ) {
_internal . currentWebView . url = RootStore . getFormedUrl ( localAccountSensitiveSettings . shouldShowBrowserSearchEngine , url )
return
} else if ( Utils . isURLWithOptionalProtocol ( url ) ) {
url = "https://" + url
}
_internal . currentWebView . url = _internal . determineRealURL ( url ) ;
}
2021-09-30 09:43:29 +00:00
}
2020-09-28 18:33:37 +00:00
2021-09-30 09:43:29 +00:00
BrowserTabView {
id: tabs
2020-10-08 18:08:50 +00:00
anchors.top: parent . top
anchors.topMargin: Style . current . halfPadding
2020-09-28 18:33:37 +00:00
anchors.bottom: devToolsView . top
2020-10-08 20:13:14 +00:00
anchors.bottomMargin: browserHeader . height
2020-09-28 18:33:37 +00:00
anchors.left: parent . left
anchors.right: parent . right
2021-09-30 09:43:29 +00:00
z: 50
tabComponent: webEngineView
2021-12-07 23:15:17 +00:00
currentWebEngineProfile: _internal . currentWebView . profile
determineRealURL: function ( url ) {
return _internal . determineRealURL ( url )
}
onOpenNewTabTriggered: _internal . addNewTab ( )
Component.onCompleted: {
_internal . defaultProfile . downloadRequested . connect ( _internal . onDownloadRequested ) ;
_internal . otrProfile . downloadRequested . connect ( _internal . onDownloadRequested ) ;
var tab = createEmptyTab ( _internal . defaultProfile ) ;
// For Devs: Uncomment the next lien if you want to use the simpeldapp on first load
// tab.item.url = Web3ProviderStore.determineRealURL("https://simpledapp.eth");
}
2020-10-20 13:54:47 +00:00
}
2020-09-28 18:33:37 +00:00
ProgressBar {
id: progressBar
height: 3
from: 0
to: 100
visible: value != 0 && value != 100
2021-12-07 23:15:17 +00:00
value: ( _internal . currentWebView && _internal . currentWebView . loadProgress < 100 ) ? _internal . currentWebView.loadProgress : 0
2020-09-28 18:33:37 +00:00
anchors.bottom: parent . bottom
anchors.bottomMargin: Style . current . padding
anchors.right: parent . right
anchors.rightMargin: Style . current . padding
}
2020-09-22 19:16:44 +00:00
WebEngineView {
2020-09-28 18:33:37 +00:00
id: devToolsView
2021-10-20 09:50:50 +00:00
visible: localAccountSensitiveSettings . devToolsEnabled
2020-09-28 18:33:37 +00:00
height: visible ? 400 : 0
inspectedView: visible && tabs . currentIndex < tabs . count ? tabs . getTab ( tabs . currentIndex ) . item : null
anchors.left: parent . left
anchors.right: parent . right
anchors.bottom: parent . bottom
2020-09-22 19:16:44 +00:00
onNewViewRequested: function ( request ) {
2021-12-07 23:15:17 +00:00
var tab = tabs . createEmptyTab ( _internal . currentWebView . profile ) ;
2020-09-28 18:33:37 +00:00
tabs . currentIndex = tabs . count - 1 ;
request . openIn ( tab . item ) ;
}
2020-11-19 19:57:37 +00:00
z: 100
2020-09-28 18:33:37 +00:00
}
2021-12-14 17:56:59 +00:00
Component {
2021-09-30 09:43:29 +00:00
id: addFavoriteModal
2021-12-14 17:56:59 +00:00
AddFavoriteModal { }
2021-09-30 09:43:29 +00:00
}
FavoriteMenu {
id: favoriteMenu
openInNewTab: function ( url ) {
browserWindow . openUrlInNewTab ( url )
}
2021-12-14 17:56:59 +00:00
onEditFavoriteTriggered: {
Global . openPopup ( addFavoriteModal , {
modifiyModal: true ,
ogUrl: favoriteMenu . currentFavorite ? favoriteMenu.currentFavorite.url : _internal . currentWebView . url ,
ogName: favoriteMenu . currentFavorite ? favoriteMenu.currentFavorite.name : _internal . currentWebView . title } )
2021-12-07 23:15:17 +00:00
}
2020-10-19 20:16:02 +00:00
}
2020-09-28 18:33:37 +00:00
MessageDialog {
id: sslDialog
property var certErrors: [ ]
icon: StandardIcon . Warning
standardButtons: StandardButton . No | StandardButton . Yes
2021-02-18 16:36:05 +00:00
//% "Server's certificate not trusted"
title: qsTrId ( "server-s-certificate-not-trusted" )
//% "Do you wish to continue?"
text: qsTrId ( "do-you-wish-to-continue-" )
//% "If you wish so, you may continue with an unverified certificate. Accepting an unverified certificate means you may not be connected with the host you tried to connect to.\nDo you wish to override the security check and continue?"
detailedText: qsTrId ( "if-you-wish-so--you-may-continue-with-an-unverified-certificate--accepting-an-unverified-certificate-means-you-may-not-be-connected-with-the-host-you-tried-to-connect-to--ndo-you-wish-to-override-the-security-check-and-continue-" )
2020-09-28 18:33:37 +00:00
onYes: {
certErrors . shift ( ) . ignoreCertificateError ( ) ;
presentError ( ) ;
}
onNo: reject ( )
onRejected: reject ( )
function reject ( ) {
certErrors . shift ( ) . rejectCertificate ( ) ;
presentError ( ) ;
}
function enqueue ( error ) {
certErrors . push ( error ) ;
presentError ( ) ;
}
function presentError ( ) {
visible = certErrors . length > 0
}
}
2020-10-22 17:34:14 +00:00
DownloadBar {
id: downloadBar
anchors.bottom: parent . bottom
z: 60
2021-09-30 09:43:29 +00:00
downloadsModel: DownloadsStore . downloadModel
2021-12-07 23:15:17 +00:00
downloadsMenu: downloadMenu
2021-09-30 09:43:29 +00:00
onOpenDownloadClicked: {
if ( downloadComplete ) {
return DownloadsStore . openFile ( index )
}
DownloadsStore . openDirectory ( index )
}
2021-12-07 23:15:17 +00:00
onAddNewDownloadTab: _internal . addNewDownloadTab ( )
2020-10-22 17:34:14 +00:00
}
2020-09-28 18:33:37 +00:00
FindBar {
id: findBar
visible: false
anchors.right: parent . right
2020-10-09 17:56:42 +00:00
anchors.top: browserHeader . bottom
z: 60
2020-09-28 18:33:37 +00:00
onFindNext: {
if ( text )
2021-12-07 23:15:17 +00:00
_internal . currentWebView && _internal . currentWebView . findText ( text ) ;
2020-09-28 18:33:37 +00:00
else if ( ! visible )
visible = true ;
}
onFindPrevious: {
if ( text )
2021-12-07 23:15:17 +00:00
_internal . currentWebView && _internal . currentWebView . findText ( text , WebEngineView . FindBackward ) ;
2020-09-28 18:33:37 +00:00
else if ( ! visible )
visible = true ;
}
}
Rectangle {
id: statusBubble
color: "oldlace"
property int padding: 8
visible: false
anchors.left: parent . left
anchors.bottom: parent . bottom
width: statusText . paintedWidth + padding
height: statusText . paintedHeight + padding
Text {
id: statusText
anchors.centerIn: statusBubble
elide: Qt . ElideMiddle
Timer {
id: hideStatusText
interval: 750
onTriggered: {
statusText . text = "" ;
statusBubble . visible = false ;
}
}
2020-09-22 19:16:44 +00:00
}
2020-09-22 15:12:48 +00:00
}
2021-09-30 09:43:29 +00:00
DownloadMenu {
id: downloadMenu
}
2021-12-07 23:15:17 +00:00
BrowserSettingsMenu {
id: settingsMenu
x: parent . width - width
y: browserHeader . y + ( localAccountSensitiveSettings . shouldShowFavoritesBar ? browserHeader . height - 38 : browserHeader . height )
isIncognito: _internal . currentWebView && _internal . currentWebView . profile === _internal . otrProfile
onAddNewTab: _internal . addNewTab ( )
onGoIncognito: {
if ( _internal . currentWebView ) {
_internal . currentWebView . profile = checked ? _internal . otrProfile : _internal . defaultProfile ;
}
}
onZoomIn: {
const newZoom = _internal . currentWebView . zoomFactor + 0.1
_internal . currentWebView . changeZoomFactor ( newZoom )
}
onZoomOut: {
const newZoom = currentWebView . zoomFactor - 0.1
_internal . currentWebView . changeZoomFactor ( newZoom )
}
onChangeZoomFactor: _internal . currentWebView . changeZoomFactor ( 1.0 )
onLaunchFindBar: {
if ( ! findBar . visible ) {
findBar . visible = true ;
findBar . forceActiveFocus ( )
}
}
onToggleCompatibilityMode: {
for ( let i = 0 ; i < tabs . count ; ++ i ) {
tabs . getTab ( i ) . item . stop ( ) // Stop all loading tabs
}
localAccountSensitiveSettings . compatibilityMode = checked ;
for ( let i = 0 ; i < tabs . count ; ++ i ) {
tabs . getTab ( i ) . item . reload ( ) // Reload them with new user agent
}
}
onLaunchBrowserSettings: {
2022-02-25 13:32:46 +00:00
Global . changeAppSectionBySectionType ( Constants . appSection . profile , Constants . settingsSubsection . browserSettings ) ;
2021-12-07 23:15:17 +00:00
}
}
BrowserWalletMenu {
id: browserWalletMenu
y: browserHeader . height + browserHeader . anchors . topMargin
x: parent . width - width - Style . current . halfPadding
onSendTriggered: {
sendTransactionModal . selectedAccount = selectedAccount
sendTransactionModal . open ( )
}
onReload: {
for ( let i = 0 ; i < tabs . count ; ++ i ) {
tabs . getTab ( i ) . item . reload ( ) ;
}
}
onDisconnect: {
2022-03-17 12:48:56 +00:00
Web3ProviderStore . disconnect ( Utils . getHostname ( browserHeader . addressBar . text ) )
2022-02-09 10:22:24 +00:00
provider . postMessage ( "web3-disconnect-account" , "{}" ) ;
2022-03-14 12:32:21 +00:00
_internal . currentWebView . reload ( )
2021-12-07 23:15:17 +00:00
close ( )
}
}
Menu {
id: historyMenu
Instantiator {
model: _internal . currentWebView && _internal . currentWebView . navigationHistory . items
MenuItem {
text: model . title
onTriggered: _internal . 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 )
}
}
}
2021-09-30 09:43:29 +00:00
Component {
id: favoritesBar
FavoritesBar {
bookmarkModel: BookmarksStore . bookmarksModel
2021-12-07 23:15:17 +00:00
favoritesMenu: favoriteMenu
setAsCurrentWebUrl: function ( url ) {
_internal . currentWebView . url = _internal . determineRealURL ( url )
}
addFavModal: function ( ) {
2021-12-14 17:56:59 +00:00
Global . openPopup ( addFavoriteModal , { toolbarMode: true ,
ogUrl: browserHeader . currentFavorite ? browserHeader.currentFavorite.url : _internal . currentWebView . url ,
ogName: browserHeader . currentFavorite ? browserHeader.currentFavorite.name : _internal . currentWebView . title } )
2021-12-07 23:15:17 +00:00
}
2021-09-30 09:43:29 +00:00
}
}
Component {
id: webEngineView
2021-12-07 23:15:17 +00:00
BrowserWebEngineView {
anchors.top: parent . top
anchors.topMargin: browserHeader . height
currentWebView: _internal . currentWebView
webChannel: channel
findBarComp: findBar
favMenu: favoriteMenu
addFavModal: addFavoriteModal
downloadsMenu: downloadMenu
determineRealURLFn: function ( url ) {
return _internal . determineRealURL ( url )
}
onLinkHovered: function ( hoveredUrl ) {
if ( hoveredUrl === "" )
hideStatusText . start ( ) ;
else {
statusText . text = hoveredUrl ;
statusBubble . visible = true ;
hideStatusText . stop ( ) ;
}
}
onSetCurrentWebUrl: {
_internal . currentWebView . url = url
}
onWindowCloseRequested: tabs . removeView ( tabs . indexOfView ( webEngineView ) )
onNewViewRequested: function ( request ) {
if ( ! request . userInitiated ) {
print ( "Warning: Blocked a popup window." ) ;
} else if ( request . destination === WebEngineView . NewViewInTab ) {
var tab = tabs . createEmptyTab ( _internal . currentWebView . profile ) ;
tabs . currentIndex = tabs . count - 1 ;
request . openIn ( tab . item ) ;
} else if ( request . destination === WebEngineView . NewViewInBackgroundTab ) {
var backgroundTab = tabs . createEmptyTab ( _internal . currentWebView . profile ) ;
request . openIn ( backgroundTab . item ) ;
// Disabling popups temporarily since we need to set that webengineview settings / channel and other properties
/ * } e l s e i f ( r e q u e s t . d e s t i n a t i o n = = = W e b E n g i n e V i e w . N e w V i e w I n D i a l o g ) {
var dialog = browserDialogComponent . createObject ( ) ;
dialog . currentWebView . profile = currentWebView . profile ;
dialog . currentWebView . webChannel = channel ;
request . openIn ( dialog . currentWebView ) ; * /
} else {
// Instead of opening a new window, we open a new tab
// TODO: remove "open in new window" from context menu
var tab = tabs . createEmptyTab ( _internal . currentWebView . profile ) ;
tabs . currentIndex = tabs . count - 1 ;
request . openIn ( tab . item ) ;
}
}
onCertificateError: function ( error ) {
error . defer ( ) ;
sslDialog . enqueue ( error ) ;
}
onJavaScriptDialogRequested: function ( request ) {
request . accepted = true ;
var dialog = _internal . jsDialogComponent . createObject ( browserWindow , { "request" : request } ) ;
dialog . open ( ) ;
}
}
2021-09-30 09:43:29 +00:00
}
Connections {
2021-12-07 23:15:17 +00:00
target: _internal . currentWebView
2021-09-30 09:43:29 +00:00
onUrlChanged: {
2021-12-07 23:15:17 +00:00
browserHeader . addressBar . text = Web3ProviderStore . obtainAddress ( _internal . currentWebView . url )
2022-03-14 12:32:21 +00:00
RootStore . currentTabConnected = Web3ProviderStore . hasWalletConnected ( Utils . getHostname ( _internal . currentWebView . url ) )
2021-09-30 09:43:29 +00:00
}
}
Connections {
2021-10-14 14:29:33 +00:00
target: BookmarksStore . bookmarksModel
onModelChanged: {
2021-12-07 23:15:17 +00:00
browserHeader . currentFavorite = Qt . binding ( function ( ) { return BookmarksStore . getCurrentFavorite ( _internal . currentWebView . url ) } )
2021-09-30 09:43:29 +00:00
}
}
2022-03-17 16:24:50 +00:00
Connections {
target: browserSection
onOpenUrl: {
browserWindow . openUrlInNewTab ( url ) ;
}
}
2020-09-22 15:12:48 +00:00
}