From 6ed0d30fc544f1969b67d26efd6ab36576b1b4e8 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Mon, 4 Jan 2021 16:23:20 -0500 Subject: [PATCH] feat: add ethereum explorer setting in the profile --- .../Profile/Sections/BrowserContainer.qml | 13 +++- .../BrowserModals/EthereumExplorerModal.qml | 69 +++++++++++++++++++ ui/imports/Constants.qml | 5 ++ ui/main.qml | 2 + ui/nim-status-client.pro | 1 + 5 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 ui/app/AppLayouts/Profile/Sections/BrowserModals/EthereumExplorerModal.qml diff --git a/ui/app/AppLayouts/Profile/Sections/BrowserContainer.qml b/ui/app/AppLayouts/Profile/Sections/BrowserContainer.qml index ddc6171471..83f6a65bcb 100644 --- a/ui/app/AppLayouts/Profile/Sections/BrowserContainer.qml +++ b/ui/app/AppLayouts/Profile/Sections/BrowserContainer.qml @@ -16,6 +16,7 @@ Item { } property Component homePagePopup: HomepageModal {} property Component searchEngineModal: SearchEngineModal {} + property Component ethereumExplorerModal: EthereumExplorerModal {} Column { id: generalColumn @@ -67,10 +68,16 @@ Item { StatusSettingsLineButton { id: ethereumExplorerBtn text: qsTr("Ethereum explorer used in the address bar") - currentValue: qsTr("None") - onClicked: function () { - console.log('Change ethereum explorer') + currentValue: { + switch (appSettings.browserEthereumExplorer) { + case Constants.browserEthereumExplorerEtherscan: return "etherscan.io" + case Constants.browserEthereumExplorerEthplorer: return "ethplorer.io" + case Constants.browserEthereumExplorerBlockchair: return "blockchair.com" + case Constants.browserSearchEngineNone: + default: return qsTr("None") + } } + onClicked: ethereumExplorerModal.createObject(root).open() } StyledText { text: qsTr("Open an ethereum explorer after a transaction hash or an address is entered") diff --git a/ui/app/AppLayouts/Profile/Sections/BrowserModals/EthereumExplorerModal.qml b/ui/app/AppLayouts/Profile/Sections/BrowserModals/EthereumExplorerModal.qml new file mode 100644 index 0000000000..00f396fcf7 --- /dev/null +++ b/ui/app/AppLayouts/Profile/Sections/BrowserModals/EthereumExplorerModal.qml @@ -0,0 +1,69 @@ +import QtQuick 2.13 +import QtQuick.Controls 2.13 +import "../../../../../imports" +import "../../../../../shared" +import "../../../../../shared/status" + +ModalPopup { + id: popup + + title: qsTr("Ethereum explorer") + + onClosed: { + destroy() + } + + Column { + spacing: Style.current.bigPadding + width: parent.width + + ButtonGroup { + id: searchEnginGroup + } + + StatusRadioButton { + text: qsTr("None") + ButtonGroup.group: searchEnginGroup + checked: appSettings.browserEthereumExplorer === Constants.browserEthereumExplorerNone + onCheckedChanged: { + if (checked) { + appSettings.browserEthereumExplorer = Constants.browserEthereumExplorerNone + } + } + } + + StatusRadioButton { + text: "etherscan.io" + ButtonGroup.group: searchEnginGroup + checked: appSettings.browserEthereumExplorer === Constants.browserEthereumExplorerEtherscan + onCheckedChanged: { + if (checked) { + appSettings.browserEthereumExplorer = Constants.browserEthereumExplorerEtherscan + } + } + } + + StatusRadioButton { + text: "ethplorer.io" + ButtonGroup.group: searchEnginGroup + checked: appSettings.browserEthereumExplorer === Constants.browserEthereumExplorerEthplorer + onCheckedChanged: { + if (checked) { + appSettings.browserEthereumExplorer = Constants.browserEthereumExplorerEthplorer + } + } + } + + StatusRadioButton { + text: "blockchair.com" + ButtonGroup.group: searchEnginGroup + checked: appSettings.browserEthereumExplorer === Constants.browserEthereumExplorerBlockchair + onCheckedChanged: { + if (checked) { + appSettings.browserEthereumExplorer = Constants.browserEthereumExplorerBlockchair + } + } + } + } +} + diff --git a/ui/imports/Constants.qml b/ui/imports/Constants.qml index 0e50f42bdd..45e68dadf8 100644 --- a/ui/imports/Constants.qml +++ b/ui/imports/Constants.qml @@ -105,4 +105,9 @@ QtObject { readonly property int browserSearchEngineGoogle: 1 readonly property int browserSearchEngineYahoo: 2 readonly property int browserSearchEngineDuckDuckGo: 3 + + readonly property int browserEthereumExplorerNone: 0 + readonly property int browserEthereumExplorerEtherscan: 1 + readonly property int browserEthereumExplorerEthplorer: 2 + readonly property int browserEthereumExplorerBlockchair: 3 } diff --git a/ui/main.qml b/ui/main.qml index 2128438559..ac2b1098d7 100644 --- a/ui/main.qml +++ b/ui/main.qml @@ -119,6 +119,7 @@ ApplicationWindow { property bool showFavoritesBar: false property string browserHomepage: "" property int browserSearchEngine: Constants.browserSearchEngineNone + property int browserEthereumExplorer: Constants.browserEthereumExplorerNone property bool autoLoadImages: true property bool javaScriptEnabled: true property bool errorPageEnabled: true @@ -162,6 +163,7 @@ ApplicationWindow { property bool showFavoritesBar: defaultAppSettings.showFavoritesBar property string browserHomepage: defaultAppSettings.browserHomepage property int browserSearchEngine: defaultAppSettings.browserSearchEngine + property int browserEthereumExplorer: defaultAppSettings.browserEthereumExplorer property bool autoLoadImages: defaultAppSettings.autoLoadImages property bool javaScriptEnabled: defaultAppSettings.javaScriptEnabled property bool errorPageEnabled: defaultAppSettings.errorPageEnabled diff --git a/ui/nim-status-client.pro b/ui/nim-status-client.pro index d3c0020e4c..05eb040e1e 100644 --- a/ui/nim-status-client.pro +++ b/ui/nim-status-client.pro @@ -185,6 +185,7 @@ DISTFILES += \ app/AppLayouts/Profile/Sections/AppearanceContainer.qml \ app/AppLayouts/Profile/Sections/BackupSeedModal.qml \ app/AppLayouts/Profile/Sections/BrowserContainer.qml \ + app/AppLayouts/Profile/Sections/BrowserModals/EthereumExplorerModal.qml \ app/AppLayouts/Profile/Sections/BrowserModals/HomepageModal.qml \ app/AppLayouts/Profile/Sections/BrowserModals/SearchEngineModal.qml \ app/AppLayouts/Profile/Sections/ChangeProfilePicModal.qml \