qml: use custom combobox so we have more control over cropping and styling
enable lightning routing choice combobox
This commit is contained in:
@@ -5,178 +5,184 @@ import QtQuick.Controls.Material 2.0
|
|||||||
|
|
||||||
import org.electrum 1.0
|
import org.electrum 1.0
|
||||||
|
|
||||||
|
import "controls"
|
||||||
|
|
||||||
Pane {
|
Pane {
|
||||||
id: preferences
|
id: preferences
|
||||||
|
|
||||||
property string title: qsTr("Preferences")
|
property string title: qsTr("Preferences")
|
||||||
|
|
||||||
ColumnLayout {
|
property var _baseunits: ['BTC','mBTC','bits','sat']
|
||||||
|
|
||||||
|
Flickable {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
contentHeight: rootLayout.height
|
||||||
|
interactive: height < contentHeight
|
||||||
|
|
||||||
Flickable {
|
GridLayout {
|
||||||
Layout.fillHeight: true
|
id: rootLayout
|
||||||
Layout.fillWidth: true
|
columns: 2
|
||||||
|
width: parent.width
|
||||||
|
|
||||||
GridLayout {
|
Label {
|
||||||
id: rootLayout
|
text: qsTr('Language')
|
||||||
columns: 2
|
}
|
||||||
|
|
||||||
|
ElComboBox {
|
||||||
|
id: language
|
||||||
|
enabled: false
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: qsTr('Base unit')
|
||||||
|
}
|
||||||
|
|
||||||
|
ElComboBox {
|
||||||
|
id: baseUnit
|
||||||
|
model: _baseunits
|
||||||
|
onCurrentValueChanged: {
|
||||||
|
if (activeFocus)
|
||||||
|
Config.baseUnit = currentValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Switch {
|
||||||
|
id: thousands
|
||||||
|
Layout.columnSpan: 2
|
||||||
|
text: qsTr('Add thousands separators to bitcoin amounts')
|
||||||
|
onCheckedChanged: {
|
||||||
|
if (activeFocus)
|
||||||
|
Config.thousandsSeparator = checked
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Switch {
|
||||||
|
id: checkSoftware
|
||||||
|
Layout.columnSpan: 2
|
||||||
|
text: qsTr('Automatically check for software updates')
|
||||||
|
enabled: false
|
||||||
|
}
|
||||||
|
|
||||||
|
Switch {
|
||||||
|
id: fiatEnable
|
||||||
|
text: qsTr('Fiat Currency')
|
||||||
|
onCheckedChanged: {
|
||||||
|
if (activeFocus)
|
||||||
|
Daemon.fx.enabled = checked
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ElComboBox {
|
||||||
|
id: currencies
|
||||||
|
model: Daemon.fx.currencies
|
||||||
|
enabled: Daemon.fx.enabled
|
||||||
|
onCurrentValueChanged: {
|
||||||
|
if (activeFocus)
|
||||||
|
Daemon.fx.fiatCurrency = currentValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Switch {
|
||||||
|
id: historicRates
|
||||||
|
text: qsTr('Historic rates')
|
||||||
|
enabled: Daemon.fx.enabled
|
||||||
|
Layout.columnSpan: 2
|
||||||
|
onCheckedChanged: {
|
||||||
|
if (activeFocus)
|
||||||
|
Daemon.fx.historicRates = checked
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: qsTr('Source')
|
||||||
|
enabled: Daemon.fx.enabled
|
||||||
|
}
|
||||||
|
|
||||||
|
ElComboBox {
|
||||||
|
id: rateSources
|
||||||
|
enabled: Daemon.fx.enabled
|
||||||
|
model: Daemon.fx.rateSources
|
||||||
|
onModelChanged: {
|
||||||
|
currentIndex = rateSources.indexOfValue(Daemon.fx.rateSource)
|
||||||
|
}
|
||||||
|
onCurrentValueChanged: {
|
||||||
|
if (activeFocus)
|
||||||
|
Daemon.fx.rateSource = currentValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Switch {
|
||||||
|
id: spendUnconfirmed
|
||||||
|
text: qsTr('Spend unconfirmed')
|
||||||
|
Layout.columnSpan: 2
|
||||||
|
onCheckedChanged: {
|
||||||
|
if (activeFocus)
|
||||||
|
Config.spendUnconfirmed = checked
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: qsTr('PIN')
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
Label {
|
Label {
|
||||||
text: qsTr('Language')
|
text: Config.pinCode == '' ? qsTr('Off'): qsTr('On')
|
||||||
|
color: Material.accentColor
|
||||||
|
Layout.rightMargin: constants.paddingMedium
|
||||||
}
|
}
|
||||||
|
Button {
|
||||||
ComboBox {
|
text: qsTr('Enable')
|
||||||
id: language
|
visible: Config.pinCode == ''
|
||||||
enabled: false
|
onClicked: {
|
||||||
}
|
var dialog = pinSetup.createObject(preferences, {mode: 'enter'})
|
||||||
|
dialog.accepted.connect(function() {
|
||||||
Label {
|
Config.pinCode = dialog.pincode
|
||||||
text: qsTr('Base unit')
|
dialog.close()
|
||||||
}
|
})
|
||||||
|
dialog.open()
|
||||||
ComboBox {
|
|
||||||
id: baseUnit
|
|
||||||
model: ['BTC','mBTC','bits','sat']
|
|
||||||
onCurrentValueChanged: {
|
|
||||||
if (activeFocus)
|
|
||||||
Config.baseUnit = currentValue
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Button {
|
||||||
Switch {
|
text: qsTr('Change')
|
||||||
id: thousands
|
visible: Config.pinCode != ''
|
||||||
Layout.columnSpan: 2
|
onClicked: {
|
||||||
text: qsTr('Add thousands separators to bitcoin amounts')
|
var dialog = pinSetup.createObject(preferences, {mode: 'change', pincode: Config.pinCode})
|
||||||
onCheckedChanged: {
|
dialog.accepted.connect(function() {
|
||||||
if (activeFocus)
|
Config.pinCode = dialog.pincode
|
||||||
Config.thousandsSeparator = checked
|
dialog.close()
|
||||||
|
})
|
||||||
|
dialog.open()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Button {
|
||||||
Switch {
|
text: qsTr('Remove')
|
||||||
id: checkSoftware
|
visible: Config.pinCode != ''
|
||||||
Layout.columnSpan: 2
|
onClicked: {
|
||||||
text: qsTr('Automatically check for software updates')
|
Config.pinCode = ''
|
||||||
enabled: false
|
|
||||||
}
|
|
||||||
|
|
||||||
Switch {
|
|
||||||
id: fiatEnable
|
|
||||||
text: qsTr('Fiat Currency')
|
|
||||||
onCheckedChanged: {
|
|
||||||
if (activeFocus)
|
|
||||||
Daemon.fx.enabled = checked
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ComboBox {
|
|
||||||
id: currencies
|
|
||||||
model: Daemon.fx.currencies
|
|
||||||
enabled: Daemon.fx.enabled
|
|
||||||
onCurrentValueChanged: {
|
|
||||||
if (activeFocus)
|
|
||||||
Daemon.fx.fiatCurrency = currentValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Switch {
|
|
||||||
id: historicRates
|
|
||||||
text: qsTr('Historic rates')
|
|
||||||
enabled: Daemon.fx.enabled
|
|
||||||
Layout.columnSpan: 2
|
|
||||||
onCheckedChanged: {
|
|
||||||
if (activeFocus)
|
|
||||||
Daemon.fx.historicRates = checked
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Label {
|
|
||||||
text: qsTr('Source')
|
|
||||||
enabled: Daemon.fx.enabled
|
|
||||||
}
|
|
||||||
|
|
||||||
ComboBox {
|
|
||||||
id: rateSources
|
|
||||||
enabled: Daemon.fx.enabled
|
|
||||||
model: Daemon.fx.rateSources
|
|
||||||
onModelChanged: {
|
|
||||||
currentIndex = rateSources.indexOfValue(Daemon.fx.rateSource)
|
|
||||||
}
|
|
||||||
onCurrentValueChanged: {
|
|
||||||
if (activeFocus)
|
|
||||||
Daemon.fx.rateSource = currentValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Switch {
|
|
||||||
id: spendUnconfirmed
|
|
||||||
text: qsTr('Spend unconfirmed')
|
|
||||||
Layout.columnSpan: 2
|
|
||||||
onCheckedChanged: {
|
|
||||||
if (activeFocus)
|
|
||||||
Config.spendUnconfirmed = checked
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Label {
|
|
||||||
text: qsTr('PIN')
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
Label {
|
|
||||||
text: Config.pinCode == '' ? qsTr('Off'): qsTr('On')
|
|
||||||
color: Material.accentColor
|
|
||||||
Layout.rightMargin: constants.paddingMedium
|
|
||||||
}
|
|
||||||
Button {
|
|
||||||
text: qsTr('Enable')
|
|
||||||
visible: Config.pinCode == ''
|
|
||||||
onClicked: {
|
|
||||||
var dialog = pinSetup.createObject(preferences, {mode: 'enter'})
|
|
||||||
dialog.accepted.connect(function() {
|
|
||||||
Config.pinCode = dialog.pincode
|
|
||||||
dialog.close()
|
|
||||||
})
|
|
||||||
dialog.open()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Button {
|
|
||||||
text: qsTr('Change')
|
|
||||||
visible: Config.pinCode != ''
|
|
||||||
onClicked: {
|
|
||||||
var dialog = pinSetup.createObject(preferences, {mode: 'change', pincode: Config.pinCode})
|
|
||||||
dialog.accepted.connect(function() {
|
|
||||||
Config.pinCode = dialog.pincode
|
|
||||||
dialog.close()
|
|
||||||
})
|
|
||||||
dialog.open()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Button {
|
|
||||||
text: qsTr('Remove')
|
|
||||||
visible: Config.pinCode != ''
|
|
||||||
onClicked: {
|
|
||||||
Config.pinCode = ''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Label {
|
|
||||||
text: qsTr('Lightning Routing')
|
|
||||||
}
|
|
||||||
|
|
||||||
ComboBox {
|
|
||||||
id: lnRoutingType
|
|
||||||
valueRole: 'key'
|
|
||||||
textRole: 'label'
|
|
||||||
enabled: Daemon.currentWallet != null && Daemon.currentWallet.isLightning && false
|
|
||||||
model: ListModel {
|
|
||||||
ListElement { key: 'gossip'; label: qsTr('Gossip') }
|
|
||||||
ListElement { key: 'trampoline'; label: qsTr('Trampoline') }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: qsTr('Lightning Routing')
|
||||||
|
}
|
||||||
|
|
||||||
|
ElComboBox {
|
||||||
|
id: lnRoutingType
|
||||||
|
enabled: Daemon.currentWallet && Daemon.currentWallet.isLightning
|
||||||
|
|
||||||
|
valueRole: 'key'
|
||||||
|
textRole: 'label'
|
||||||
|
model: ListModel {
|
||||||
|
ListElement { key: 'gossip'; label: qsTr('Gossip') }
|
||||||
|
ListElement { key: 'trampoline'; label: qsTr('Trampoline') }
|
||||||
|
}
|
||||||
|
onCurrentValueChanged: {
|
||||||
|
if (activeFocus)
|
||||||
|
Config.useGossip = currentValue == 'gossip'
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -187,7 +193,7 @@ Pane {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
baseUnit.currentIndex = ['BTC','mBTC','bits','sat'].indexOf(Config.baseUnit)
|
baseUnit.currentIndex = _baseunits.indexOf(Config.baseUnit)
|
||||||
thousands.checked = Config.thousandsSeparator
|
thousands.checked = Config.thousandsSeparator
|
||||||
currencies.currentIndex = currencies.indexOfValue(Daemon.fx.fiatCurrency)
|
currencies.currentIndex = currencies.indexOfValue(Daemon.fx.fiatCurrency)
|
||||||
historicRates.checked = Daemon.fx.historicRates
|
historicRates.checked = Daemon.fx.historicRates
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ Pane {
|
|||||||
Layout.fillWidth: false
|
Layout.fillWidth: false
|
||||||
}
|
}
|
||||||
|
|
||||||
ComboBox {
|
ElComboBox {
|
||||||
id: expires
|
id: expires
|
||||||
Layout.columnSpan: 2
|
Layout.columnSpan: 2
|
||||||
|
|
||||||
@@ -91,13 +91,6 @@ Pane {
|
|||||||
expires.currentIndex = 0
|
expires.currentIndex = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// redefine contentItem, as the default crops the widest item
|
|
||||||
contentItem: Label {
|
|
||||||
text: expires.currentText
|
|
||||||
padding: constants.paddingLarge
|
|
||||||
font.pixelSize: constants.fontSizeMedium
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Item { width: 1; height: 1; Layout.fillWidth: true }
|
Item { width: 1; height: 1; Layout.fillWidth: true }
|
||||||
|
|||||||
14
electrum/gui/qml/components/controls/ElComboBox.qml
Normal file
14
electrum/gui/qml/components/controls/ElComboBox.qml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import QtQuick.Controls 2.0
|
||||||
|
|
||||||
|
ComboBox {
|
||||||
|
id: cb
|
||||||
|
// make combobox implicit width a multiple of 32, so it aligns with others
|
||||||
|
implicitWidth: Math.ceil(contentItem.implicitWidth/32)*32 + constants.paddingXXLarge
|
||||||
|
// redefine contentItem, as the default crops the text easily
|
||||||
|
contentItem: Label {
|
||||||
|
text: cb.currentText
|
||||||
|
padding: constants.paddingLarge
|
||||||
|
rightPadding: constants.paddingXXLarge
|
||||||
|
font.pixelSize: constants.fontSizeMedium
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user