complete and refactor Fx preferences and use in Send/Receive tabs
This commit is contained in:
@@ -35,12 +35,20 @@ Pane {
|
||||
ComboBox {
|
||||
id: baseUnit
|
||||
model: ['BTC','mBTC','bits','sat']
|
||||
onCurrentValueChanged: {
|
||||
if (activeFocus)
|
||||
Config.baseUnit = currentValue
|
||||
}
|
||||
}
|
||||
|
||||
CheckBox {
|
||||
id: thousands
|
||||
Layout.columnSpan: 2
|
||||
text: qsTr('Add thousands separators to bitcoin amounts')
|
||||
onCheckedChanged: {
|
||||
if (activeFocus)
|
||||
Config.thousandsSeparator = checked
|
||||
}
|
||||
}
|
||||
|
||||
CheckBox {
|
||||
@@ -50,45 +58,58 @@ Pane {
|
||||
enabled: false
|
||||
}
|
||||
|
||||
CheckBox {
|
||||
id: writeLogs
|
||||
Layout.columnSpan: 2
|
||||
text: qsTr('Write logs to file')
|
||||
enabled: false
|
||||
}
|
||||
|
||||
Label {
|
||||
text: qsTr('Fiat Currency')
|
||||
}
|
||||
|
||||
ComboBox {
|
||||
id: currencies
|
||||
model: Daemon.currencies
|
||||
model: Daemon.fx.currencies
|
||||
onCurrentValueChanged: {
|
||||
if (activeFocus)
|
||||
Daemon.fx.fiatCurrency = currentValue
|
||||
}
|
||||
}
|
||||
|
||||
CheckBox {
|
||||
id: historyRates
|
||||
text: qsTr('History rates')
|
||||
enabled: currencies.currentValue != ''
|
||||
Layout.columnSpan: 2
|
||||
onCheckStateChanged: {
|
||||
if (activeFocus)
|
||||
Daemon.fx.historyRates = checked
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
text: qsTr('Source')
|
||||
enabled: currencies.currentValue != ''
|
||||
}
|
||||
|
||||
ComboBox {
|
||||
id: rateSources
|
||||
enabled: currencies.currentValue != ''
|
||||
model: Daemon.fx.rateSources
|
||||
onModelChanged: {
|
||||
currentIndex = rateSources.indexOfValue(Daemon.fx.rateSource)
|
||||
}
|
||||
onCurrentValueChanged: {
|
||||
if (activeFocus)
|
||||
Daemon.fx.rateSource = currentValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
Button {
|
||||
text: qsTr('Save')
|
||||
onClicked: save()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function save() {
|
||||
Config.baseUnit = baseUnit.currentValue
|
||||
Config.thousandsSeparator = thousands.checked
|
||||
Config.fiatCurrency = currencies.currentValue ? currencies.currentValue : ''
|
||||
app.stack.pop()
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
baseUnit.currentIndex = ['BTC','mBTC','bits','sat'].indexOf(Config.baseUnit)
|
||||
thousands.checked = Config.thousandsSeparator
|
||||
currencies.currentIndex = currencies.indexOfValue(Config.fiatCurrency)
|
||||
currencies.currentIndex = currencies.indexOfValue(Daemon.fx.fiatCurrency)
|
||||
historyRates.checked = Daemon.fx.historyRates
|
||||
rateSources.currentIndex = rateSources.indexOfValue(Daemon.fx.rateSource)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,19 +81,19 @@ Pane {
|
||||
|
||||
TextField {
|
||||
id: amountFiat
|
||||
visible: Config.fiatCurrency != ''
|
||||
visible: Daemon.fx.fiatCurrency != ''
|
||||
font.family: FixedFont
|
||||
Layout.fillWidth: true
|
||||
inputMethodHints: Qt.ImhDigitsOnly
|
||||
}
|
||||
|
||||
Label {
|
||||
visible: Config.fiatCurrency != ''
|
||||
text: Config.fiatCurrency
|
||||
visible: Daemon.fx.fiatCurrency != ''
|
||||
text: Daemon.fx.fiatCurrency
|
||||
color: Material.accentColor
|
||||
}
|
||||
|
||||
Item { visible: Config.fiatCurrency == ''; width: 1; height: 1; Layout.columnSpan: 2 }
|
||||
Item { visible: Daemon.fx.fiatCurrency == ''; width: 1; height: 1; Layout.columnSpan: 2 }
|
||||
|
||||
RowLayout {
|
||||
Layout.columnSpan: 4
|
||||
@@ -356,22 +356,22 @@ Pane {
|
||||
if (amountFiat.activeFocus)
|
||||
return
|
||||
var a = Config.unitsToSats(amount.text)
|
||||
amountFiat.text = Daemon.fiatValue(a)
|
||||
amountFiat.text = Daemon.fx.fiatValue(a)
|
||||
}
|
||||
}
|
||||
Connections {
|
||||
target: amountFiat
|
||||
function onTextChanged() {
|
||||
if (amountFiat.activeFocus) {
|
||||
amount.text = Daemon.satoshiValue(amountFiat.text)
|
||||
amount.text = Daemon.fx.satoshiValue(amountFiat.text)
|
||||
}
|
||||
}
|
||||
}
|
||||
Connections {
|
||||
target: Network
|
||||
function onFiatUpdated() {
|
||||
target: Daemon.fx
|
||||
function onQuotesUpdated() {
|
||||
var a = Config.unitsToSats(amount.text)
|
||||
amountFiat.text = Daemon.fiatValue(a)
|
||||
amountFiat.text = Daemon.fx.fiatValue(a)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,19 +52,19 @@ Pane {
|
||||
|
||||
TextField {
|
||||
id: amountFiat
|
||||
visible: Config.fiatCurrency != ''
|
||||
visible: Daemon.fx.fiatCurrency != ''
|
||||
font.family: FixedFont
|
||||
placeholderText: qsTr('Amount')
|
||||
inputMethodHints: Qt.ImhPreferNumbers
|
||||
}
|
||||
|
||||
Label {
|
||||
visible: Config.fiatCurrency != ''
|
||||
text: Config.fiatCurrency
|
||||
visible: Daemon.fx.fiatCurrency != ''
|
||||
text: Daemon.fx.fiatCurrency
|
||||
color: Material.accentColor
|
||||
}
|
||||
|
||||
Item { visible: Config.fiatCurrency == ''; height: 1; Layout.columnSpan: 2; Layout.fillWidth: true }
|
||||
Item { visible: Daemon.fx.fiatCurrency == ''; height: 1; Layout.columnSpan: 2; Layout.fillWidth: true }
|
||||
|
||||
Item { width: 1; height: 1 } // workaround colspan on baseunit messing up row above
|
||||
|
||||
@@ -115,22 +115,22 @@ Pane {
|
||||
if (amountFiat.activeFocus)
|
||||
return
|
||||
var a = Config.unitsToSats(amount.text)
|
||||
amountFiat.text = Daemon.fiatValue(a)
|
||||
amountFiat.text = Daemon.fx.fiatValue(a)
|
||||
}
|
||||
}
|
||||
Connections {
|
||||
target: amountFiat
|
||||
function onTextChanged() {
|
||||
if (amountFiat.activeFocus) {
|
||||
amount.text = Daemon.satoshiValue(amountFiat.text)
|
||||
amount.text = Daemon.fx.satoshiValue(amountFiat.text)
|
||||
}
|
||||
}
|
||||
}
|
||||
Connections {
|
||||
target: Network
|
||||
function onFiatUpdated() {
|
||||
target: Daemon.fx
|
||||
function onQuotesUpdated() {
|
||||
var a = Config.unitsToSats(amount.text)
|
||||
amountFiat.text = Daemon.fiatValue(a)
|
||||
amountFiat.text = Daemon.fx.fiatValue(a)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user