refactor: replace StatusRadioButtonRow with RadioButtonSelector

This does a couple of things:

- It remove StatusRadioButton row from ui/shared/status
- Introduces RadioButtonSelector in ui/shared/controls instead
- That component is then built with StatusQ
This commit is contained in:
Pascal Precht 2021-10-27 11:37:58 +02:00 committed by Iuri Matias
parent 4bf23b3048
commit a12d047d77
14 changed files with 165 additions and 186 deletions

View File

@ -3,21 +3,23 @@ import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import utils 1.0
import "../../../../shared"
import "../../../../shared/popups"
import "../../../../shared/status"
// TODO: replace with StatusQ component
StatusRadioButtonRow {
import "../../../../shared/controls"
import "../../../../shared/popups"
RadioButtonSelector {
id: root
property string fleetName: ""
property string newFleet: ""
text: fleetName
buttonGroup: fleetSettings
checked: profileModel.fleets.fleet === text
onRadioCheckedChanged: {
title: fleetName
checked: profileModel.fleets.fleet === root.fleetName
onCheckedChanged: {
if (checked) {
if (profileModel.fleets.fleet === fleetName) return;
newFleet = fleetName;
if (profileModel.fleets.fleet === root.fleetName) return;
root.newFleet = root.fleetName;
openPopup(confirmDialogComponent)
}
}
@ -28,8 +30,8 @@ StatusRadioButtonRow {
//% "Warning!"
header.title: qsTrId("close-app-title")
//% "Change fleet to %1"
confirmationText: qsTrId("change-fleet-to--1").arg(newFleet)
onConfirmButtonClicked: profileModel.fleets.setFleet(newFleet)
confirmationText: qsTrId("change-fleet-to--1").arg(root.newFleet)
onConfirmButtonClicked: profileModel.fleets.setFleet(root.newFleet)
onClosed: {
profileModel.fleets.triggerFleetChange()
destroy();
@ -37,4 +39,3 @@ StatusRadioButtonRow {
}
}
}

View File

@ -3,23 +3,23 @@ import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import utils 1.0
import "../../../../shared"
import "../../../../shared/popups"
import "../../../../shared/status"
// TODO: replace with StatusQ component
StatusRadioButtonRow {
import "../../../../shared/controls"
import "../../../../shared/popups"
RadioButtonSelector {
id: root
property string network: ""
property string networkName: ""
property string newNetwork: ""
id: radioProd
text: networkName == "" ? Utils.getNetworkName(network) : networkName
buttonGroup: networkSettings
checked: profileModel.network.current === network
onRadioCheckedChanged: {
title: networkName == "" ? Utils.getNetworkName(network) : networkName
onCheckedChanged: {
if (checked) {
if (profileModel.network.current === network) return;
newNetwork = network;
if (profileModel.network.current === root.network) return;
root.newNetwork = root.network;
openPopup(confirmDialogComponent)
}
}
@ -33,7 +33,7 @@ StatusRadioButtonRow {
//% "The account will be logged out. When you unlock it again, the selected network will be used"
confirmationText: qsTrId("logout-app-content")
onConfirmButtonClicked: {
profileModel.network.current = newNetwork;
profileModel.network.current = root.newNetwork;
}
onClosed: {
profileModel.network.triggerNetworkChange()

View File

@ -2,9 +2,9 @@ import QtQuick 2.13
import QtQuick.Controls 2.13
import utils 1.0
import "../../../../shared"
import "../../../../shared/controls"
import "../../../../shared/popups"
import "../../../../shared/status"
// TODO: replace with StatusModal
ModalPopup {
@ -29,45 +29,45 @@ ModalPopup {
id: searchEnginGroup
}
StatusRadioButtonRow {
RadioButtonSelector {
//% "None"
text: qsTrId("none")
title: qsTrId("none")
buttonGroup: searchEnginGroup
checked: appSettings.useBrowserEthereumExplorer === Constants.browserEthereumExplorerNone
onRadioCheckedChanged: {
onCheckedChanged: {
if (checked) {
appSettings.useBrowserEthereumExplorer = Constants.browserEthereumExplorerNone
}
}
}
StatusRadioButtonRow {
text: "etherscan.io"
RadioButtonSelector {
title: "etherscan.io"
buttonGroup: searchEnginGroup
checked: appSettings.useBrowserEthereumExplorer === Constants.browserEthereumExplorerEtherscan
onRadioCheckedChanged: {
onCheckedChanged: {
if (checked) {
appSettings.useBrowserEthereumExplorer = Constants.browserEthereumExplorerEtherscan
}
}
}
StatusRadioButtonRow {
text: "ethplorer.io"
RadioButtonSelector {
title: "ethplorer.io"
buttonGroup: searchEnginGroup
checked: appSettings.useBrowserEthereumExplorer === Constants.browserEthereumExplorerEthplorer
onRadioCheckedChanged: {
onCheckedChanged: {
if (checked) {
appSettings.useBrowserEthereumExplorer = Constants.browserEthereumExplorerEthplorer
}
}
}
StatusRadioButtonRow {
text: "blockchair.com"
RadioButtonSelector {
title: "blockchair.com"
buttonGroup: searchEnginGroup
checked: appSettings.useBrowserEthereumExplorer === Constants.browserEthereumExplorerBlockchair
onRadioCheckedChanged: {
onCheckedChanged: {
if (checked) {
appSettings.useBrowserEthereumExplorer = Constants.browserEthereumExplorerBlockchair
}

View File

@ -32,22 +32,27 @@ ModalPopup {
FleetRadioSelector {
fleetName: Constants.eth_prod
buttonGroup: fleetSettings
}
FleetRadioSelector {
fleetName: Constants.eth_staging
buttonGroup: fleetSettings
}
FleetRadioSelector {
fleetName: Constants.eth_test
buttonGroup: fleetSettings
}
FleetRadioSelector {
fleetName: Constants.waku_prod
buttonGroup: fleetSettings
}
FleetRadioSelector {
fleetName: Constants.waku_test
buttonGroup: fleetSettings
}
}
}

View File

@ -2,10 +2,9 @@ import QtQuick 2.13
import QtQuick.Controls 2.13
import utils 1.0
import "../../../../shared"
import "../../../../shared/controls"
import "../../../../shared/popups"
import "../../../../shared/status"
// TODO: replace with StatusModal
ModalPopup {
@ -32,12 +31,12 @@ ModalPopup {
id: homepageGroup
}
StatusRadioButtonRow {
RadioButtonSelector {
//% "Default"
text: qsTrId("default")
title: qsTrId("default")
buttonGroup: homepageGroup
checked: appSettings.browserHomepage === ""
onRadioCheckedChanged: {
onCheckedChanged: {
if (checked) {
appSettings.browserHomepage = ""
customUrl.visible = false
@ -45,12 +44,12 @@ ModalPopup {
}
}
StatusRadioButtonRow {
RadioButtonSelector {
//% "Custom..."
text: qsTrId("custom---")
title: qsTrId("custom---")
buttonGroup: homepageGroup
checked: appSettings.browserHomepage !== "" || customUrl.visible
onRadioCheckedChanged: {
onCheckedChanged: {
if (checked) {
customUrl.visible = true
}

View File

@ -2,9 +2,8 @@ import QtQuick 2.13
import QtQuick.Controls 2.13
import utils 1.0
import "../../../../shared"
import "../../../../shared/controls"
import "../../../../shared/popups"
import "../../../../shared/status"
import "../locales.js" as Locales_JSON
// TODO: replace with StatusQ StatusModal
@ -69,13 +68,14 @@ ModalPopup {
spacing: 0
delegate: Component {
StatusRadioButtonRow {
RadioButtonSelector {
height: 64
anchors.rightMargin: 0
text: modelData.name
anchors.leftMargin: 0
title: modelData.name
buttonGroup: languageGroup
checked: globalSettings.locale === modelData.locale
onRadioCheckedChanged: {
onCheckedChanged: {
if (checked && globalSettings.locale !== modelData.locale) {
globalSettings.locale = modelData.locale
if (Qt.platform.os === Constants.linux) {

View File

@ -88,6 +88,10 @@ ModalPopup {
anchors.leftMargin: Style.current.padding
anchors.rightMargin: Style.current.padding
ButtonGroup {
id: radioGroup
}
StatusSectionHeadline {
//% "Main networks"
@ -97,14 +101,17 @@ ModalPopup {
NetworkRadioSelector {
network: Constants.networkMainnet
buttonGroup: radioGroup
}
NetworkRadioSelector {
network: Constants.networkPOA
buttonGroup: radioGroup
}
NetworkRadioSelector {
network: Constants.networkXDai
buttonGroup: radioGroup
}
StatusSectionHeadline {
@ -116,14 +123,17 @@ ModalPopup {
NetworkRadioSelector {
network: Constants.networkGoerli
buttonGroup: radioGroup
}
NetworkRadioSelector {
network: Constants.networkRinkeby
buttonGroup: radioGroup
}
NetworkRadioSelector {
network: Constants.networkRopsten
buttonGroup: radioGroup
}
StatusSectionHeadline {
@ -138,6 +148,7 @@ ModalPopup {
delegate: NetworkRadioSelector {
networkName: name
network: customNetworkId
buttonGroup: radioGroup
}
}
}

View File

@ -1,9 +1,7 @@
import QtQuick 2.13
import QtQuick.Controls 2.13
import utils 1.0
import "../../../../shared"
import "../../../../shared/controls"
import "../../../../shared/status"
@ -138,14 +136,14 @@ StatusModal {
id: networkChainGroup
}
StatusRadioButtonRow {
RadioButtonSelector {
id: mainnetRadioBtn
//% "Main network"
objectName: "main"
text: qsTrId("mainnet-network")
title: qsTrId("mainnet-network")
buttonGroup: networkChainGroup
checked: true
onRadioCheckedChanged: {
onCheckedChanged: {
if (checked) {
addNetworkPopup.networkId = 1;
addNetworkPopup.networkType = Constants.networkMainnet;
@ -153,11 +151,11 @@ StatusModal {
}
}
StatusRadioButtonRow {
RadioButtonSelector {
//% "Ropsten test network"
text: qsTrId("ropsten-network")
title: qsTrId("ropsten-network")
buttonGroup: networkChainGroup
onRadioCheckedChanged: {
onCheckedChanged: {
if (checked) {
addNetworkPopup.networkId = 3;
addNetworkPopup.networkType = Constants.networkRopsten;
@ -165,11 +163,11 @@ StatusModal {
}
}
StatusRadioButtonRow {
RadioButtonSelector {
//% "Rinkeby test network"
text: qsTrId("rinkeby-network")
title: qsTrId("rinkeby-network")
buttonGroup: networkChainGroup
onRadioCheckedChanged: {
onCheckedChanged: {
if (checked) {
addNetworkPopup.networkId = 4;
addNetworkPopup.networkType = Constants.networkRinkeby;
@ -177,13 +175,13 @@ StatusModal {
}
}
StatusRadioButtonRow {
RadioButtonSelector {
id: customRadioBtn
//% "Custom"
objectName: "custom"
text: qsTrId("custom")
title: qsTrId("custom")
buttonGroup: networkChainGroup
onRadioCheckedChanged: {
onCheckedChanged: {
if (checked) {
addNetworkPopup.networkType = "";
}

View File

@ -2,9 +2,9 @@ import QtQuick 2.13
import QtQuick.Controls 2.13
import utils 1.0
import "../../../../shared"
import "../../../../shared/controls"
import "../../../../shared/popups"
import "../../../../shared/status"
// TODO: replace with StatusModal
ModalPopup {
@ -31,22 +31,22 @@ ModalPopup {
id: openLinksWithGroup
}
StatusRadioButtonRow {
text: "Status"
RadioButtonSelector {
title: "Status"
buttonGroup: openLinksWithGroup
checked: appSettings.openLinksInStatus
onRadioCheckedChanged: {
onCheckedChanged: {
if (checked) {
appSettings.openLinksInStatus = true
}
}
}
StatusRadioButtonRow {
RadioButtonSelector {
//% "My default browser"
text: qsTrId("my-default-browser")
title: qsTrId("my-default-browser")
buttonGroup: openLinksWithGroup
checked: !appSettings.openLinksInStatus
onRadioCheckedChanged: {
onCheckedChanged: {
if (checked) {
appSettings.openLinksInStatus = false
}

View File

@ -2,9 +2,8 @@ import QtQuick 2.13
import QtQuick.Controls 2.13
import utils 1.0
import "../../../../shared"
import "../../../../shared/controls"
import "../../../../shared/popups"
import "../../../../shared/status"
// TODO: replace with StatusModal
ModalPopup {
@ -29,45 +28,45 @@ ModalPopup {
id: searchEnginGroup
}
StatusRadioButtonRow {
RadioButtonSelector {
//% "None"
text: qsTrId("none")
title: qsTrId("none")
buttonGroup: searchEnginGroup
checked: appSettings.shouldShowBrowserSearchEngine === Constants.browserSearchEngineNone
onRadioCheckedChanged: {
onCheckedChanged: {
if (checked) {
appSettings.shouldShowBrowserSearchEngine = Constants.browserSearchEngineNone
}
}
}
StatusRadioButtonRow {
text: "Google"
RadioButtonSelector {
title: "Google"
buttonGroup: searchEnginGroup
checked: appSettings.shouldShowBrowserSearchEngine === Constants.browserSearchEngineGoogle
onRadioCheckedChanged: {
onCheckedChanged: {
if (checked) {
appSettings.shouldShowBrowserSearchEngine = Constants.browserSearchEngineGoogle
}
}
}
StatusRadioButtonRow {
text: "Yahoo!"
RadioButtonSelector {
title: "Yahoo!"
buttonGroup: searchEnginGroup
checked: appSettings.shouldShowBrowserSearchEngine === Constants.browserSearchEngineYahoo
onRadioCheckedChanged: {
onCheckedChanged: {
if (checked) {
appSettings.shouldShowBrowserSearchEngine = Constants.browserSearchEngineYahoo
}
}
}
StatusRadioButtonRow {
text: "DuckDuckGo"
RadioButtonSelector {
title: "DuckDuckGo"
buttonGroup: searchEnginGroup
checked: appSettings.shouldShowBrowserSearchEngine === Constants.browserSearchEngineDuckDuckGo
onRadioCheckedChanged: {
onCheckedChanged: {
if (checked) {
appSettings.shouldShowBrowserSearchEngine = Constants.browserSearchEngineDuckDuckGo
}

View File

@ -2,9 +2,9 @@ import QtQuick 2.13
import QtQuick.Controls 2.13
import utils 1.0
import "../../../../shared"
import "../../../../shared/controls"
import "../../../../shared/popups"
import "../../../../shared/status"
// TODO: replace with StatusModal
ModalPopup {
@ -30,11 +30,11 @@ ModalPopup {
id: openLinksWithGroup
}
StatusRadioButtonRow {
text: qsTr("Store")
RadioButtonSelector {
title: qsTr("Store")
buttonGroup: openLinksWithGroup
checked: accountSettings.storeToKeychain === Constants.storeToKeychainValueStore
onRadioCheckedChanged: {
onCheckedChanged: {
if (checked && accountSettings.storeToKeychain !== Constants.storeToKeychainValueStore) {
var storePassPopup = openPopup(storePasswordModal)
if(storePassPopup)
@ -52,25 +52,25 @@ ModalPopup {
}
}
StatusRadioButtonRow {
RadioButtonSelector {
id: notNowBtn
text: qsTr("Not now")
title: qsTr("Not now")
buttonGroup: openLinksWithGroup
checked: accountSettings.storeToKeychain === Constants.storeToKeychainValueNotNow ||
accountSettings.storeToKeychain === ""
onRadioCheckedChanged: {
onCheckedChanged: {
if (checked) {
accountSettings.storeToKeychain = Constants.storeToKeychainValueNotNow
}
}
}
StatusRadioButtonRow {
RadioButtonSelector {
id: neverBtn
text: qsTr("Never")
title: qsTr("Never")
buttonGroup: openLinksWithGroup
checked: accountSettings.storeToKeychain === Constants.storeToKeychainValueNever
onRadioCheckedChanged: {
onCheckedChanged: {
if (checked) {
accountSettings.storeToKeychain = Constants.storeToKeychainValueNever
}

View File

@ -2,18 +2,19 @@ import QtQuick 2.13
import QtQuick.Controls 2.13
import QtGraphicalEffects 1.13
import QtQuick.Layouts 1.13
import "./"
import utils 1.0
import "../../../../shared"
import "../../../../shared/panels"
import "../../../../shared/status"
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import utils 1.0
import "../../../../shared/controls"
import "../../../../shared/panels"
import "../../../../shared/status"
import "../popups"
import "../panels"
import "./"
ScrollView {
id: root
@ -61,39 +62,36 @@ ScrollView {
anchors.left: parent.left
anchors.right: parent.right
// TODO: replace with StatusListItem
StatusRadioButtonRow {
RadioButtonSelector {
//% "All messages"
text: qsTrId("all-messages")
title: qsTrId("all-messages")
buttonGroup: notificationSetting
checked: appSettings.notificationSetting === Constants.notifyAllMessages
onRadioCheckedChanged: {
onCheckedChanged: {
if (checked) {
appSettings.notificationSetting = Constants.notifyAllMessages
}
}
}
// TODO: replace with StatusListItem
StatusRadioButtonRow {
RadioButtonSelector {
//% "Just @mentions"
text: qsTrId("just--mentions")
title: qsTrId("just--mentions")
buttonGroup: notificationSetting
checked: appSettings.notificationSetting === Constants.notifyJustMentions
onRadioCheckedChanged: {
onCheckedChanged: {
if (checked) {
appSettings.notificationSetting = Constants.notifyJustMentions
}
}
}
// TODO: replace with StatusListItem
StatusRadioButtonRow {
RadioButtonSelector {
//% "Nothing"
text: qsTrId("nothing")
title: qsTrId("nothing")
buttonGroup: notificationSetting
checked: appSettings.notificationSetting === Constants.notifyNone
onRadioCheckedChanged: {
onCheckedChanged: {
if (checked) {
appSettings.notificationSetting = Constants.notifyNone
}

View File

@ -0,0 +1,35 @@
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import StatusQ.Components 0.1
import StatusQ.Controls 0.1
import utils 1.0
import "../popups"
StatusListItem {
id: root
property var buttonGroup
property alias checked: radioButton.checked
implicitHeight: 52
anchors.left: parent.left
anchors.leftMargin: -Style.current.padding
anchors.right: parent.right
anchors.rightMargin: -Style.current.padding
sensor.onClicked: {
radioButton.checked = !radioButton.checked
}
components: [
StatusRadioButton {
id: radioButton
ButtonGroup.group: root.buttonGroup
}
]
}

View File

@ -1,67 +0,0 @@
import QtQuick 2.13
import QtQuick.Controls 2.13
import utils 1.0
import ".."
import "../panels"
import "."
import StatusQ.Controls 0.1
Rectangle {
property alias text: textElement.text
property var buttonGroup
property alias checked: radioButton.checked
property bool isHovered: false
signal radioCheckedChanged(checked: bool)
id: root
height: 52
color: isHovered ? Style.current.backgroundHover : Style.current.transparent
radius: Style.current.radius
border.width: 0
anchors.left: parent.left
anchors.leftMargin: -Style.current.padding
anchors.right: parent.right
anchors.rightMargin: -Style.current.padding
StyledText {
id: textElement
text: ""
font.pixelSize: 15
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: Style.current.padding
}
MouseArea {
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
hoverEnabled: true
onEntered: root.isHovered = true
onExited: root.isHovered = false
onClicked: {
radioButton.checked = true
}
}
StatusRadioButton {
id: radioButton
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: Style.current.padding
ButtonGroup.group: root.buttonGroup
rightPadding: 0
checked: root.checked
onCheckedChanged: root.radioCheckedChanged(checked)
MouseArea {
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
onPressed: mouse.accepted = false
onEntered: root.isHovered = true
}
}
}