Browse Source

qml: ui

patch-4
Sander van Grieken 2 years ago
parent
commit
685f32750c
  1. 230
      electrum/gui/qml/components/InvoiceDialog.qml
  2. 403
      electrum/gui/qml/components/Preferences.qml
  3. 9
      electrum/gui/qml/components/ReceiveDialog.qml

230
electrum/gui/qml/components/InvoiceDialog.qml

@ -30,6 +30,113 @@ ElDialog {
height: parent.height height: parent.height
columns: 2 columns: 2
Label {
text: qsTr('Type')
color: Material.accentColor
}
RowLayout {
Layout.fillWidth: true
Image {
Layout.preferredWidth: constants.iconSizeSmall
Layout.preferredHeight: constants.iconSizeSmall
source: invoice.invoiceType == Invoice.LightningInvoice
? "../../icons/lightning.png"
: "../../icons/bitcoin.png"
}
Label {
text: invoice.invoiceType == Invoice.OnchainInvoice
? qsTr('On chain')
: invoice.invoiceType == Invoice.LightningInvoice
? qsTr('Lightning')
: ''
Layout.fillWidth: true
}
}
Label {
text: qsTr('Status')
color: Material.accentColor
}
Label {
text: invoice.status_str
}
Label {
visible: invoice.invoiceType == Invoice.OnchainInvoice
Layout.columnSpan: 2
text: qsTr('Address')
color: Material.accentColor
}
TextHighlightPane {
visible: invoice.invoiceType == Invoice.OnchainInvoice
Layout.columnSpan: 2
Layout.fillWidth: true
padding: 0
leftPadding: constants.paddingMedium
Label {
width: parent.width
text: invoice.address
font.family: FixedFont
wrapMode: Text.Wrap
}
}
Label {
visible: invoice.invoiceType == Invoice.LightningInvoice
text: qsTr('Remote Pubkey')
color: Material.accentColor
}
TextHighlightPane {
visible: invoice.invoiceType == Invoice.LightningInvoice
Layout.columnSpan: 2
Layout.fillWidth: true
padding: 0
leftPadding: constants.paddingMedium
Label {
width: parent.width
text: invoice.lnprops ? invoice.lnprops.pubkey : ''
font.family: FixedFont
wrapMode: Text.Wrap
}
}
Label {
text: qsTr('Description')
visible: invoice.message
Layout.columnSpan: 2
color: Material.accentColor
}
TextHighlightPane {
visible: invoice.message
Layout.columnSpan: 2
Layout.preferredWidth: parent.width
Layout.alignment: Qt.AlignHCenter
padding: 0
leftPadding: constants.paddingMedium
Label {
text: invoice.message
width: parent.width
font.pixelSize: constants.fontSizeXLarge
wrapMode: Text.Wrap
elide: Text.ElideRight
}
}
Label { Label {
text: qsTr('Amount to send') text: qsTr('Amount to send')
color: Material.accentColor color: Material.accentColor
@ -146,129 +253,6 @@ ElDialog {
} }
Label {
text: qsTr('Description')
visible: invoice.message
Layout.columnSpan: 2
color: Material.accentColor
}
TextHighlightPane {
visible: invoice.message
Layout.columnSpan: 2
Layout.preferredWidth: parent.width
Layout.alignment: Qt.AlignHCenter
padding: 0
leftPadding: constants.paddingMedium
Label {
text: invoice.message
Layout.fillWidth: true
font.pixelSize: constants.fontSizeXLarge
wrapMode: Text.Wrap
elide: Text.ElideRight
}
}
Label {
text: qsTr('Type')
color: Material.accentColor
}
RowLayout {
Layout.fillWidth: true
Image {
Layout.preferredWidth: constants.iconSizeSmall
Layout.preferredHeight: constants.iconSizeSmall
source: invoice.invoiceType == Invoice.LightningInvoice
? "../../icons/lightning.png"
: "../../icons/bitcoin.png"
}
Label {
text: invoice.invoiceType == Invoice.OnchainInvoice
? qsTr('On chain')
: invoice.invoiceType == Invoice.LightningInvoice
? qsTr('Lightning')
: ''
Layout.fillWidth: true
}
}
Label {
visible: invoice.invoiceType == Invoice.OnchainInvoice
text: qsTr('Address')
color: Material.accentColor
}
Label {
visible: invoice.invoiceType == Invoice.OnchainInvoice
Layout.fillWidth: true
text: invoice.address
font.family: FixedFont
wrapMode: Text.Wrap
}
Label {
visible: invoice.invoiceType == Invoice.LightningInvoice
text: qsTr('Remote Pubkey')
color: Material.accentColor
}
Label {
visible: invoice.invoiceType == Invoice.LightningInvoice
Layout.fillWidth: true
text: invoice.lnprops ? invoice.lnprops.pubkey : ''
font.family: FixedFont
wrapMode: Text.Wrap
}
Label {
visible: invoice.invoiceType == Invoice.LightningInvoice
text: qsTr('Route via (t)')
color: Material.accentColor
}
Label {
visible: invoice.invoiceType == Invoice.LightningInvoice
Layout.fillWidth: true
text: invoice.lnprops ? invoice.lnprops.t : ''
font.family: FixedFont
wrapMode: Text.Wrap
}
Label {
visible: invoice.invoiceType == Invoice.LightningInvoice
text: qsTr('Route via (r)')
color: Material.accentColor
}
Label {
visible: invoice.invoiceType == Invoice.LightningInvoice
Layout.fillWidth: true
text: invoice.lnprops ? invoice.lnprops.r : ''
font.family: FixedFont
wrapMode: Text.Wrap
}
Label {
text: qsTr('Status')
color: Material.accentColor
}
Label {
text: invoice.status_str
}
Rectangle {
height: 1
Layout.fillWidth: true
Layout.columnSpan: 2
color: Material.accentColor
}
Item { Layout.preferredHeight: constants.paddingLarge; Layout.preferredWidth: 1 } Item { Layout.preferredHeight: constants.paddingLarge; Layout.preferredWidth: 1 }
InfoTextArea { InfoTextArea {

403
electrum/gui/qml/components/Preferences.qml

@ -19,250 +19,224 @@ Pane {
ColumnLayout { ColumnLayout {
anchors.fill: parent anchors.fill: parent
TabBar { Flickable {
id: tabbar Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
currentIndex: swipeview.currentIndex
TabButton {
text: qsTr('Preferences')
font.pixelSize: constants.fontSizeLarge
}
TabButton {
text: qsTr('Plugins')
font.pixelSize: constants.fontSizeLarge
}
}
SwipeView { contentHeight: prefsPane.height
id: swipeview interactive: height < contentHeight
clip: true
Layout.fillHeight: true Pane {
Layout.fillWidth: true id: prefsPane
currentIndex: tabbar.currentIndex GridLayout {
columns: 2
width: parent.width
Flickable { Label {
contentHeight: prefsPane.height text: qsTr('Language')
interactive: height < contentHeight }
clip: true
Pane { ElComboBox {
id: prefsPane id: language
GridLayout { enabled: false
columns: 2 }
width: parent.width
Label { Label {
text: qsTr('Language') text: qsTr('Base unit')
} }
ElComboBox { ElComboBox {
id: language id: baseUnit
enabled: false model: _baseunits
onCurrentValueChanged: {
if (activeFocus)
Config.baseUnit = currentValue
} }
}
Label { Switch {
text: qsTr('Base unit') id: thousands
Layout.columnSpan: 2
text: qsTr('Add thousands separators to bitcoin amounts')
onCheckedChanged: {
if (activeFocus)
Config.thousandsSeparator = checked
} }
}
ElComboBox { Switch {
id: baseUnit id: checkSoftware
model: _baseunits Layout.columnSpan: 2
onCurrentValueChanged: { text: qsTr('Automatically check for software updates')
if (activeFocus) enabled: false
Config.baseUnit = currentValue }
}
}
Switch { Switch {
id: thousands id: fiatEnable
Layout.columnSpan: 2 text: qsTr('Fiat Currency')
text: qsTr('Add thousands separators to bitcoin amounts') onCheckedChanged: {
onCheckedChanged: { if (activeFocus)
if (activeFocus) Daemon.fx.enabled = checked
Config.thousandsSeparator = checked
}
} }
}
Switch { ElComboBox {
id: checkSoftware id: currencies
Layout.columnSpan: 2 model: Daemon.fx.currencies
text: qsTr('Automatically check for software updates') enabled: Daemon.fx.enabled
enabled: false onCurrentValueChanged: {
if (activeFocus)
Daemon.fx.fiatCurrency = currentValue
} }
}
Switch { Switch {
id: fiatEnable id: historicRates
text: qsTr('Fiat Currency') text: qsTr('Historic rates')
onCheckedChanged: { enabled: Daemon.fx.enabled
if (activeFocus) Layout.columnSpan: 2
Daemon.fx.enabled = checked onCheckedChanged: {
} if (activeFocus)
Daemon.fx.historicRates = checked
} }
}
ElComboBox { Label {
id: currencies text: qsTr('Source')
model: Daemon.fx.currencies enabled: Daemon.fx.enabled
enabled: Daemon.fx.enabled }
onCurrentValueChanged: {
if (activeFocus)
Daemon.fx.fiatCurrency = currentValue
}
}
Switch { ElComboBox {
id: historicRates id: rateSources
text: qsTr('Historic rates') enabled: Daemon.fx.enabled
enabled: Daemon.fx.enabled model: Daemon.fx.rateSources
Layout.columnSpan: 2 onModelChanged: {
onCheckedChanged: { currentIndex = rateSources.indexOfValue(Daemon.fx.rateSource)
if (activeFocus)
Daemon.fx.historicRates = checked
}
} }
onCurrentValueChanged: {
Label { if (activeFocus)
text: qsTr('Source') Daemon.fx.rateSource = currentValue
enabled: Daemon.fx.enabled
} }
}
ElComboBox { Switch {
id: rateSources id: spendUnconfirmed
enabled: Daemon.fx.enabled text: qsTr('Spend unconfirmed')
model: Daemon.fx.rateSources Layout.columnSpan: 2
onModelChanged: { onCheckedChanged: {
currentIndex = rateSources.indexOfValue(Daemon.fx.rateSource) if (activeFocus)
} Config.spendUnconfirmed = checked
onCurrentValueChanged: {
if (activeFocus)
Daemon.fx.rateSource = currentValue
}
} }
}
Switch { Switch {
id: spendUnconfirmed id: useRbf
text: qsTr('Spend unconfirmed') text: qsTr('Use Replace-By-Fee')
Layout.columnSpan: 2 Layout.columnSpan: 2
onCheckedChanged: { onCheckedChanged: {
if (activeFocus) if (activeFocus)
Config.spendUnconfirmed = checked Config.useRbf = checked
}
} }
}
Switch { Label {
id: useRbf text: qsTr('Default request expiry')
text: qsTr('Use Replace-By-Fee') Layout.fillWidth: false
Layout.columnSpan: 2 }
onCheckedChanged: {
if (activeFocus)
Config.useRbf = checked
}
}
Label { RequestExpiryComboBox {
text: qsTr('Default request expiry') onCurrentValueChanged: {
Layout.fillWidth: false if (activeFocus)
Config.requestExpiry = currentValue
} }
}
RequestExpiryComboBox { Label {
onCurrentValueChanged: { text: qsTr('PIN')
if (activeFocus) }
Config.requestExpiry = currentValue
}
}
RowLayout {
Label { Label {
text: qsTr('PIN') text: Config.pinCode == '' ? qsTr('Off'): qsTr('On')
color: Material.accentColor
Layout.rightMargin: constants.paddingMedium
} }
Button {
RowLayout { text: qsTr('Enable')
Label { visible: Config.pinCode == ''
text: Config.pinCode == '' ? qsTr('Off'): qsTr('On') onClicked: {
color: Material.accentColor var dialog = pinSetup.createObject(preferences, {mode: 'enter'})
Layout.rightMargin: constants.paddingMedium dialog.accepted.connect(function() {
} Config.pinCode = dialog.pincode
Button { dialog.close()
text: qsTr('Enable') })
visible: Config.pinCode == '' dialog.open()
onClicked: {
var dialog = pinSetup.createObject(preferences, {mode: 'enter'})
dialog.accepted.connect(function() {
Config.pinCode = dialog.pincode
dialog.close()
})
dialog.open()
}
} }
Button { }
text: qsTr('Change') Button {
visible: Config.pinCode != '' text: qsTr('Change')
onClicked: { visible: Config.pinCode != ''
var dialog = pinSetup.createObject(preferences, {mode: 'change', pincode: Config.pinCode}) onClicked: {
dialog.accepted.connect(function() { var dialog = pinSetup.createObject(preferences, {mode: 'change', pincode: Config.pinCode})
Config.pinCode = dialog.pincode dialog.accepted.connect(function() {
dialog.close() Config.pinCode = dialog.pincode
}) dialog.close()
dialog.open() })
} dialog.open()
} }
Button { }
text: qsTr('Remove') Button {
visible: Config.pinCode != '' text: qsTr('Remove')
onClicked: { visible: Config.pinCode != ''
Config.pinCode = '' onClicked: {
} Config.pinCode = ''
} }
} }
}
Label { Label {
text: qsTr('Lightning Routing') text: qsTr('Lightning Routing')
} }
ElComboBox { ElComboBox {
id: lnRoutingType id: lnRoutingType
enabled: Daemon.currentWallet && Daemon.currentWallet.isLightning enabled: Daemon.currentWallet && Daemon.currentWallet.isLightning
valueRole: 'key' valueRole: 'key'
textRole: 'label' textRole: 'label'
model: ListModel { model: ListModel {
ListElement { key: 'gossip'; label: qsTr('Gossip') } ListElement { key: 'gossip'; label: qsTr('Gossip') }
ListElement { key: 'trampoline'; label: qsTr('Trampoline') } ListElement { key: 'trampoline'; label: qsTr('Trampoline') }
}
onCurrentValueChanged: {
if (activeFocus)
Config.useGossip = currentValue == 'gossip'
}
} }
onCurrentValueChanged: {
Switch { if (activeFocus)
id: useRecoverableChannels Config.useGossip = currentValue == 'gossip'
text: qsTr('Create recoverable channels')
Layout.columnSpan: 2
onCheckedChanged: {
if (activeFocus)
Config.useRecoverableChannels = checked
}
} }
}
Switch { Switch {
id: useFallbackAddress id: useRecoverableChannels
text: qsTr('Use onchain fallback address for Lightning invoices') text: qsTr('Create recoverable channels')
Layout.columnSpan: 2 Layout.columnSpan: 2
onCheckedChanged: { onCheckedChanged: {
if (activeFocus) if (activeFocus)
Config.useFallbackAddress = checked Config.useRecoverableChannels = checked
}
} }
}
Switch {
id: useFallbackAddress
text: qsTr('Use onchain fallback address for Lightning invoices')
Layout.columnSpan: 2
onCheckedChanged: {
if (activeFocus)
Config.useFallbackAddress = checked
}
} }
} }
}
Pane {
ColumnLayout {
x: constants.paddingXXLarge
id: pluginsRootLayout
}
} }
} }
@ -273,30 +247,6 @@ Pane {
Pin {} Pin {}
} }
Component {
id: pluginHeader
RowLayout {
Layout.leftMargin: -constants.paddingXXLarge
property string name
property string fullname
property bool pluginEnabled
Switch {
checked: pluginEnabled
onCheckedChanged: {
if (activeFocus)
pluginEnabled = checked
}
}
Label {
text: fullname
}
onPluginEnabledChanged: {
console.log('!')
AppController.setPluginEnabled(name, pluginEnabled)
}
}
}
Component.onCompleted: { Component.onCompleted: {
baseUnit.currentIndex = _baseunits.indexOf(Config.baseUnit) baseUnit.currentIndex = _baseunits.indexOf(Config.baseUnit)
thousands.checked = Config.thousandsSeparator thousands.checked = Config.thousandsSeparator
@ -308,18 +258,5 @@ Pane {
lnRoutingType.currentIndex = Config.useGossip ? 0 : 1 lnRoutingType.currentIndex = Config.useGossip ? 0 : 1
useFallbackAddress.checked = Config.useFallbackAddress useFallbackAddress.checked = Config.useFallbackAddress
useRbf.checked = Config.useRbf useRbf.checked = Config.useRbf
var plugins = AppController.plugins
for (var i=0; i<plugins.length; i++) {
var p = plugins[i]
pluginHeader.createObject(pluginsRootLayout, { name: p['name'], fullname: p['fullname'], pluginEnabled: p['enabled'] })
var labelsPlugin = AppController.plugin(p['name'])
if (labelsPlugin) {
if (labelsPlugin.settingsComponent()) {
var component = Qt.createComponent(Qt.resolvedUrl(labelsPlugin.settingsComponent()))
component.createObject(pluginsRootLayout, { plugin: labelsPlugin })
}
}
}
} }
} }

9
electrum/gui/qml/components/ReceiveDialog.qml

@ -50,12 +50,6 @@ ElDialog {
} }
] ]
Rectangle {
height: 1
Layout.fillWidth: true
color: Material.accentColor
}
Item { Item {
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
Layout.topMargin: constants.paddingSmall Layout.topMargin: constants.paddingSmall
@ -162,7 +156,8 @@ ElDialog {
Rectangle { Rectangle {
height: 1 height: 1
Layout.fillWidth: true Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: qrloader.width
color: Material.accentColor color: Material.accentColor
} }

Loading…
Cancel
Save