Browse Source

qml: add address to bolt11>bip21>address QR caroussel and remove address copy button

(conform qt and kivy)
master
Sander van Grieken 3 years ago
parent
commit
0c3ce4a6b6
  1. 65
      electrum/gui/qml/components/RequestDialog.qml

65
electrum/gui/qml/components/RequestDialog.qml

@ -13,8 +13,9 @@ ElDialog {
property var modelItem property var modelItem
property string _bip21uri
property string _bolt11 property string _bolt11
property string _bip21uri
property string _address
parent: Overlay.overlay parent: Overlay.overlay
modal: true modal: true
@ -62,6 +63,11 @@ ElDialog {
name: 'bip21uri' name: 'bip21uri'
PropertyChanges { target: qrloader; sourceComponent: qri_bip21uri } PropertyChanges { target: qrloader; sourceComponent: qri_bip21uri }
PropertyChanges { target: bip21label; font.bold: true } PropertyChanges { target: bip21label; font.bold: true }
},
State {
name: 'address'
PropertyChanges { target: qrloader; sourceComponent: qri_address }
PropertyChanges { target: addresslabel; font.bold: true }
} }
] ]
@ -81,6 +87,12 @@ ElDialog {
Loader { Loader {
id: qrloader id: qrloader
Component {
id: qri_bolt11
QRImage {
qrdata: _bolt11
}
}
Component { Component {
id: qri_bip21uri id: qri_bip21uri
QRImage { QRImage {
@ -88,9 +100,9 @@ ElDialog {
} }
} }
Component { Component {
id: qri_bolt11 id: qri_address
QRImage { QRImage {
qrdata: _bolt11 qrdata: _address
} }
} }
} }
@ -101,9 +113,18 @@ ElDialog {
if (rootLayout.state == 'bolt11') { if (rootLayout.state == 'bolt11') {
if (_bip21uri != '') if (_bip21uri != '')
rootLayout.state = 'bip21uri' rootLayout.state = 'bip21uri'
else if (_address != '')
rootLayout.state = 'address'
} else if (rootLayout.state == 'bip21uri') { } else if (rootLayout.state == 'bip21uri') {
if (_address != '')
rootLayout.state = 'address'
else if (_bolt11 != '')
rootLayout.state = 'bolt11'
} else if (rootLayout.state == 'address') {
if (_bolt11 != '') if (_bolt11 != '')
rootLayout.state = 'bolt11' rootLayout.state = 'bolt11'
else if (_bip21uri != '')
rootLayout.state = 'bip21uri'
} }
} }
} }
@ -125,9 +146,20 @@ ElDialog {
} }
Label { Label {
id: bip21label id: bip21label
text: qsTr('BIP21 URI') text: qsTr('BIP21')
color: _bip21uri ? Material.foreground : constants.mutedForeground color: _bip21uri ? Material.foreground : constants.mutedForeground
} }
Rectangle {
Layout.preferredWidth: constants.paddingXXSmall
Layout.preferredHeight: constants.paddingXXSmall
radius: constants.paddingXXSmall / 2
color: Material.accentColor
}
Label {
id: addresslabel
text: qsTr('ADDRESS')
color: _address ? Material.foreground : constants.mutedForeground
}
} }
Rectangle { Rectangle {
@ -153,9 +185,10 @@ ElDialog {
onClicked: { onClicked: {
if (modelItem.is_lightning && rootLayout.state == 'bolt11') if (modelItem.is_lightning && rootLayout.state == 'bolt11')
AppController.textToClipboard(_bolt11) AppController.textToClipboard(_bolt11)
else else if (rootLayout.state == 'bip21uri')
AppController.textToClipboard(_bip21uri) AppController.textToClipboard(_bip21uri)
else
AppController.textToClipboard(_address)
} }
} }
Button { Button {
@ -165,8 +198,11 @@ ElDialog {
enabled = false enabled = false
if (modelItem.is_lightning && rootLayout.state == 'bolt11') if (modelItem.is_lightning && rootLayout.state == 'bolt11')
AppController.doShare(_bolt11, qsTr('Payment Request')) AppController.doShare(_bolt11, qsTr('Payment Request'))
else else if (rootLayout.state == 'bip21uri')
AppController.doShare(_bip21uri, qsTr('Payment Request')) AppController.doShare(_bip21uri, qsTr('Payment Request'))
else
AppController.doShare(_address, qsTr('Onchain address'))
enabled = true enabled = true
} }
} }
@ -217,26 +253,18 @@ ElDialog {
} }
Label { Label {
visible: modelItem.address
text: qsTr('Address') text: qsTr('Address')
visible: !modelItem.is_lightning
} }
RowLayout {
visible: !modelItem.is_lightning
Label { Label {
visible: modelItem.address
Layout.fillWidth: true Layout.fillWidth: true
font.family: FixedFont font.family: FixedFont
font.pixelSize: constants.fontSizeLarge font.pixelSize: constants.fontSizeLarge
wrapMode: Text.WrapAnywhere wrapMode: Text.WrapAnywhere
text: modelItem.address text: modelItem.address
} }
ToolButton {
icon.source: '../../icons/copy_bw.png'
onClicked: {
AppController.textToClipboard(modelItem.address)
}
}
}
Label { Label {
text: qsTr('Status') text: qsTr('Status')
@ -262,13 +290,14 @@ ElDialog {
Component.onCompleted: { Component.onCompleted: {
if (!modelItem.is_lightning) { if (!modelItem.is_lightning) {
_bip21uri = bitcoin.create_bip21_uri(modelItem.address, modelItem.amount, modelItem.message, modelItem.timestamp, modelItem.expiration - modelItem.timestamp) _bip21uri = bitcoin.create_bip21_uri(modelItem.address, modelItem.amount, modelItem.message, modelItem.timestamp, modelItem.expiration - modelItem.timestamp)
_address = modelItem.address
rootLayout.state = 'bip21uri' rootLayout.state = 'bip21uri'
} else { } else {
_bolt11 = modelItem.lightning_invoice _bolt11 = modelItem.lightning_invoice
rootLayout.state = 'bolt11' rootLayout.state = 'bolt11'
if (modelItem.address != '') { if (modelItem.address != '') {
_bip21uri = bitcoin.create_bip21_uri(modelItem.address, modelItem.amount, modelItem.message, modelItem.timestamp, modelItem.expiration - modelItem.timestamp) _bip21uri = bitcoin.create_bip21_uri(modelItem.address, modelItem.amount, modelItem.message, modelItem.timestamp, modelItem.expiration - modelItem.timestamp)
console.log('BIP21:' + _bip21uri) _address = modelItem.address
} }
} }
} }

Loading…
Cancel
Save