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
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 {
text: qsTr('Amount to send')
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 }
InfoTextArea {

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

@ -19,250 +19,224 @@ Pane {
ColumnLayout {
anchors.fill: parent
TabBar {
id: tabbar
Flickable {
Layout.fillHeight: true
Layout.fillWidth: true
currentIndex: swipeview.currentIndex
TabButton {
text: qsTr('Preferences')
font.pixelSize: constants.fontSizeLarge
}
TabButton {
text: qsTr('Plugins')
font.pixelSize: constants.fontSizeLarge
}
}
SwipeView {
id: swipeview
contentHeight: prefsPane.height
interactive: height < contentHeight
clip: true
Layout.fillHeight: true
Layout.fillWidth: true
currentIndex: tabbar.currentIndex
Pane {
id: prefsPane
GridLayout {
columns: 2
width: parent.width
Flickable {
contentHeight: prefsPane.height
interactive: height < contentHeight
clip: true
Label {
text: qsTr('Language')
}
Pane {
id: prefsPane
GridLayout {
columns: 2
width: parent.width
ElComboBox {
id: language
enabled: false
}
Label {
text: qsTr('Language')
}
Label {
text: qsTr('Base unit')
}
ElComboBox {
id: language
enabled: false
ElComboBox {
id: baseUnit
model: _baseunits
onCurrentValueChanged: {
if (activeFocus)
Config.baseUnit = currentValue
}
}
Label {
text: qsTr('Base unit')
Switch {
id: thousands
Layout.columnSpan: 2
text: qsTr('Add thousands separators to bitcoin amounts')
onCheckedChanged: {
if (activeFocus)
Config.thousandsSeparator = checked
}
}
ElComboBox {
id: baseUnit
model: _baseunits
onCurrentValueChanged: {
if (activeFocus)
Config.baseUnit = currentValue
}
}
Switch {
id: checkSoftware
Layout.columnSpan: 2
text: qsTr('Automatically check for software updates')
enabled: false
}
Switch {
id: thousands
Layout.columnSpan: 2
text: qsTr('Add thousands separators to bitcoin amounts')
onCheckedChanged: {
if (activeFocus)
Config.thousandsSeparator = checked
}
Switch {
id: fiatEnable
text: qsTr('Fiat Currency')
onCheckedChanged: {
if (activeFocus)
Daemon.fx.enabled = checked
}
}
Switch {
id: checkSoftware
Layout.columnSpan: 2
text: qsTr('Automatically check for software updates')
enabled: false
ElComboBox {
id: currencies
model: Daemon.fx.currencies
enabled: Daemon.fx.enabled
onCurrentValueChanged: {
if (activeFocus)
Daemon.fx.fiatCurrency = currentValue
}
}
Switch {
id: fiatEnable
text: qsTr('Fiat Currency')
onCheckedChanged: {
if (activeFocus)
Daemon.fx.enabled = checked
}
Switch {
id: historicRates
text: qsTr('Historic rates')
enabled: Daemon.fx.enabled
Layout.columnSpan: 2
onCheckedChanged: {
if (activeFocus)
Daemon.fx.historicRates = checked
}
}
ElComboBox {
id: currencies
model: Daemon.fx.currencies
enabled: Daemon.fx.enabled
onCurrentValueChanged: {
if (activeFocus)
Daemon.fx.fiatCurrency = currentValue
}
}
Label {
text: qsTr('Source')
enabled: Daemon.fx.enabled
}
Switch {
id: historicRates
text: qsTr('Historic rates')
enabled: Daemon.fx.enabled
Layout.columnSpan: 2
onCheckedChanged: {
if (activeFocus)
Daemon.fx.historicRates = checked
}
ElComboBox {
id: rateSources
enabled: Daemon.fx.enabled
model: Daemon.fx.rateSources
onModelChanged: {
currentIndex = rateSources.indexOfValue(Daemon.fx.rateSource)
}
Label {
text: qsTr('Source')
enabled: Daemon.fx.enabled
onCurrentValueChanged: {
if (activeFocus)
Daemon.fx.rateSource = currentValue
}
}
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
}
}
Switch {
id: spendUnconfirmed
text: qsTr('Spend unconfirmed')
Layout.columnSpan: 2
onCheckedChanged: {
if (activeFocus)
Config.spendUnconfirmed = checked
}
Switch {
id: useRbf
text: qsTr('Use Replace-By-Fee')
Layout.columnSpan: 2
onCheckedChanged: {
if (activeFocus)
Config.useRbf = checked
}
}
Switch {
id: useRbf
text: qsTr('Use Replace-By-Fee')
Layout.columnSpan: 2
onCheckedChanged: {
if (activeFocus)
Config.useRbf = checked
}
}
Label {
text: qsTr('Default request expiry')
Layout.fillWidth: false
}
Label {
text: qsTr('Default request expiry')
Layout.fillWidth: false
RequestExpiryComboBox {
onCurrentValueChanged: {
if (activeFocus)
Config.requestExpiry = currentValue
}
}
RequestExpiryComboBox {
onCurrentValueChanged: {
if (activeFocus)
Config.requestExpiry = currentValue
}
}
Label {
text: qsTr('PIN')
}
RowLayout {
Label {
text: qsTr('PIN')
text: Config.pinCode == '' ? qsTr('Off'): qsTr('On')
color: Material.accentColor
Layout.rightMargin: constants.paddingMedium
}
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('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('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 = ''
}
}
Button {
text: qsTr('Remove')
visible: Config.pinCode != ''
onClicked: {
Config.pinCode = ''
}
}
}
Label {
text: qsTr('Lightning Routing')
}
Label {
text: qsTr('Lightning Routing')
}
ElComboBox {
id: lnRoutingType
enabled: Daemon.currentWallet && Daemon.currentWallet.isLightning
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'
}
valueRole: 'key'
textRole: 'label'
model: ListModel {
ListElement { key: 'gossip'; label: qsTr('Gossip') }
ListElement { key: 'trampoline'; label: qsTr('Trampoline') }
}
Switch {
id: useRecoverableChannels
text: qsTr('Create recoverable channels')
Layout.columnSpan: 2
onCheckedChanged: {
if (activeFocus)
Config.useRecoverableChannels = checked
}
onCurrentValueChanged: {
if (activeFocus)
Config.useGossip = currentValue == 'gossip'
}
}
Switch {
id: useFallbackAddress
text: qsTr('Use onchain fallback address for Lightning invoices')
Layout.columnSpan: 2
onCheckedChanged: {
if (activeFocus)
Config.useFallbackAddress = checked
}
Switch {
id: useRecoverableChannels
text: qsTr('Create recoverable channels')
Layout.columnSpan: 2
onCheckedChanged: {
if (activeFocus)
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 {}
}
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: {
baseUnit.currentIndex = _baseunits.indexOf(Config.baseUnit)
thousands.checked = Config.thousandsSeparator
@ -308,18 +258,5 @@ Pane {
lnRoutingType.currentIndex = Config.useGossip ? 0 : 1
useFallbackAddress.checked = Config.useFallbackAddress
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 {
Layout.alignment: Qt.AlignHCenter
Layout.topMargin: constants.paddingSmall
@ -162,7 +156,8 @@ ElDialog {
Rectangle {
height: 1
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: qrloader.width
color: Material.accentColor
}

Loading…
Cancel
Save