add request status code to listmodel, update request delegates,
enable bip21 uri copy
This commit is contained in:
@@ -129,6 +129,7 @@ Pane {
|
|||||||
Layout.columnSpan: 4
|
Layout.columnSpan: 4
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
text: qsTr('Create Request')
|
text: qsTr('Create Request')
|
||||||
|
icon.source: '../../icons/qrcode.png'
|
||||||
onClicked: {
|
onClicked: {
|
||||||
createRequest()
|
createRequest()
|
||||||
}
|
}
|
||||||
@@ -202,52 +203,90 @@ Pane {
|
|||||||
rightMargin: constants.paddingSmall
|
rightMargin: constants.paddingSmall
|
||||||
}
|
}
|
||||||
|
|
||||||
columns: 5
|
columns: 2
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
Layout.columnSpan: 5
|
Layout.columnSpan: 2
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: constants.paddingTiny
|
Layout.preferredHeight: constants.paddingTiny
|
||||||
color: 'transparent'
|
color: 'transparent'
|
||||||
}
|
}
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
Layout.rowSpan: 2
|
Layout.rowSpan: 2
|
||||||
Layout.preferredWidth: constants.iconSizeLarge
|
Layout.preferredWidth: constants.iconSizeLarge
|
||||||
Layout.preferredHeight: constants.iconSizeLarge
|
Layout.preferredHeight: constants.iconSizeLarge
|
||||||
source: model.type == 0 ? "../../icons/bitcoin.png" : "../../icons/lightning.png"
|
source: model.type == 0 ? "../../icons/bitcoin.png" : "../../icons/lightning.png"
|
||||||
}
|
}
|
||||||
Label {
|
|
||||||
|
RowLayout {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.columnSpan: 2
|
Label {
|
||||||
text: model.message
|
Layout.fillWidth: true
|
||||||
elide: Text.ElideRight
|
text: model.message ? model.message : model.address
|
||||||
font.pixelSize: constants.fontSizeLarge
|
elide: Text.ElideRight
|
||||||
|
wrapMode: Text.Wrap
|
||||||
|
maximumLineCount: 2
|
||||||
|
font.pixelSize: model.message ? constants.fontSizeMedium : constants.fontSizeSmall
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
id: amount
|
||||||
|
text: model.amount == 0 ? '' : Config.formatSats(model.amount)
|
||||||
|
font.pixelSize: constants.fontSizeMedium
|
||||||
|
font.family: FixedFont
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: model.amount == 0 ? '' : Config.baseUnit
|
||||||
|
font.pixelSize: constants.fontSizeMedium
|
||||||
|
color: Material.accentColor
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
RowLayout {
|
||||||
text: qsTr('Amount: ')
|
Layout.fillWidth: true
|
||||||
}
|
Label {
|
||||||
Label {
|
text: model.status_str
|
||||||
id: amount
|
color: Material.accentColor
|
||||||
text: Config.formatSats(model.amount, true)
|
}
|
||||||
font.family: FixedFont
|
Item {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.preferredHeight: status_icon.height
|
||||||
|
Image {
|
||||||
|
id: status_icon
|
||||||
|
source: model.status == 0
|
||||||
|
? '../../icons/unpaid.png'
|
||||||
|
: model.status == 1
|
||||||
|
? '../../icons/expired.png'
|
||||||
|
: model.status == 3
|
||||||
|
? '../../icons/confirmed.png'
|
||||||
|
: model.status == 7
|
||||||
|
? '../../icons/unconfirmed.png'
|
||||||
|
: ''
|
||||||
|
width: constants.iconSizeSmall
|
||||||
|
height: constants.iconSizeSmall
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
id: fiatValue
|
||||||
|
visible: Daemon.fx.enabled
|
||||||
|
Layout.alignment: Qt.AlignRight
|
||||||
|
text: model.amount == 0 ? '' : Daemon.fx.fiatValue(model.amount, false)
|
||||||
|
font.family: FixedFont
|
||||||
|
font.pixelSize: constants.fontSizeSmall
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
visible: Daemon.fx.enabled
|
||||||
|
Layout.alignment: Qt.AlignRight
|
||||||
|
text: model.amount == 0 ? '' : Daemon.fx.fiatCurrency
|
||||||
|
font.pixelSize: constants.fontSizeSmall
|
||||||
|
color: Material.accentColor
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
|
||||||
text: qsTr('Timestamp: ')
|
|
||||||
}
|
|
||||||
Label {
|
|
||||||
text: model.date
|
|
||||||
}
|
|
||||||
|
|
||||||
Label {
|
|
||||||
text: qsTr('Status: ')
|
|
||||||
}
|
|
||||||
Label {
|
|
||||||
text: model.status
|
|
||||||
}
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
Layout.columnSpan: 5
|
Layout.columnSpan: 2
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: constants.paddingTiny
|
Layout.preferredHeight: constants.paddingTiny
|
||||||
color: 'transparent'
|
color: 'transparent'
|
||||||
@@ -257,10 +296,16 @@ Pane {
|
|||||||
Connections {
|
Connections {
|
||||||
target: Config
|
target: Config
|
||||||
function onBaseUnitChanged() {
|
function onBaseUnitChanged() {
|
||||||
amount.text = Config.formatSats(model.amount, true)
|
amount.text = model.amount == 0 ? '' : Config.formatSats(model.amount)
|
||||||
}
|
}
|
||||||
function onThousandsSeparatorChanged() {
|
function onThousandsSeparatorChanged() {
|
||||||
amount.text = Config.formatSats(model.amount, true)
|
amount.text = model.amount == 0 ? '' : Config.formatSats(model.amount)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Connections {
|
||||||
|
target: Daemon.fx
|
||||||
|
function onQuotesUpdated() {
|
||||||
|
fiatValue.text = model.amount == 0 ? '' : Daemon.fx.fiatValue(model.amount, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,11 +314,14 @@ Pane {
|
|||||||
}
|
}
|
||||||
|
|
||||||
remove: Transition {
|
remove: Transition {
|
||||||
NumberAnimation { properties: 'scale'; to: 0; duration: 400 }
|
NumberAnimation { properties: 'scale'; to: 0.75; duration: 300 }
|
||||||
NumberAnimation { properties: 'opacity'; to: 0; duration: 300 }
|
NumberAnimation { properties: 'opacity'; to: 0; duration: 300 }
|
||||||
}
|
}
|
||||||
removeDisplaced: Transition {
|
removeDisplaced: Transition {
|
||||||
SpringAnimation { properties: 'y'; duration: 100; spring: 5; damping: 0.5; mass: 2 }
|
SequentialAnimation {
|
||||||
|
PauseAnimation { duration: 200 }
|
||||||
|
SpringAnimation { properties: 'y'; duration: 100; spring: 5; damping: 0.5; mass: 2 }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollIndicator.vertical: ScrollIndicator { }
|
ScrollIndicator.vertical: ScrollIndicator { }
|
||||||
@@ -330,8 +378,7 @@ Pane {
|
|||||||
Connections {
|
Connections {
|
||||||
target: Daemon.fx
|
target: Daemon.fx
|
||||||
function onQuotesUpdated() {
|
function onQuotesUpdated() {
|
||||||
var a = Config.unitsToSats(amount.text)
|
amountFiat.text = Daemon.fx.fiatValue(Config.unitsToSats(amount.text))
|
||||||
amountFiat.text = Daemon.fx.fiatValue(a)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ Dialog {
|
|||||||
|
|
||||||
property var modelItem
|
property var modelItem
|
||||||
|
|
||||||
|
property string _bip21uri
|
||||||
|
|
||||||
parent: Overlay.overlay
|
parent: Overlay.overlay
|
||||||
modal: true
|
modal: true
|
||||||
standardButtons: Dialog.Ok
|
standardButtons: Dialog.Ok
|
||||||
@@ -46,18 +48,18 @@ Dialog {
|
|||||||
id: rootLayout
|
id: rootLayout
|
||||||
width: parent.width
|
width: parent.width
|
||||||
rowSpacing: constants.paddingMedium
|
rowSpacing: constants.paddingMedium
|
||||||
columns: 4
|
columns: 5
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
height: 1
|
height: 1
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.columnSpan: 4
|
Layout.columnSpan: 5
|
||||||
color: Material.accentColor
|
color: Material.accentColor
|
||||||
}
|
}
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: qr
|
id: qr
|
||||||
Layout.columnSpan: 4
|
Layout.columnSpan: 5
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
Layout.topMargin: constants.paddingSmall
|
Layout.topMargin: constants.paddingSmall
|
||||||
Layout.bottomMargin: constants.paddingSmall
|
Layout.bottomMargin: constants.paddingSmall
|
||||||
@@ -71,6 +73,7 @@ Dialog {
|
|||||||
height: size
|
height: size
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
|
|
||||||
source: '../../icons/electrum.png'
|
source: '../../icons/electrum.png'
|
||||||
x: 1
|
x: 1
|
||||||
y: 1
|
y: 1
|
||||||
@@ -84,12 +87,12 @@ Dialog {
|
|||||||
Rectangle {
|
Rectangle {
|
||||||
height: 1
|
height: 1
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.columnSpan: 4
|
Layout.columnSpan: 5
|
||||||
color: Material.accentColor
|
color: Material.accentColor
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
Layout.columnSpan: 4
|
Layout.columnSpan: 5
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
Button {
|
Button {
|
||||||
icon.source: '../../icons/delete.png'
|
icon.source: '../../icons/delete.png'
|
||||||
@@ -103,7 +106,9 @@ Dialog {
|
|||||||
icon.source: '../../icons/copy_bw.png'
|
icon.source: '../../icons/copy_bw.png'
|
||||||
icon.color: 'transparent'
|
icon.color: 'transparent'
|
||||||
text: 'Copy'
|
text: 'Copy'
|
||||||
enabled: false
|
onClicked: {
|
||||||
|
AppController.textToClipboard(_bip21uri)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Button {
|
Button {
|
||||||
icon.source: '../../icons/share.png'
|
icon.source: '../../icons/share.png'
|
||||||
@@ -117,9 +122,9 @@ Dialog {
|
|||||||
}
|
}
|
||||||
Label {
|
Label {
|
||||||
visible: modelItem.message != ''
|
visible: modelItem.message != ''
|
||||||
Layout.columnSpan: 3
|
Layout.columnSpan: 4
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.Wrap
|
||||||
text: modelItem.message
|
text: modelItem.message
|
||||||
font.pixelSize: constants.fontSizeLarge
|
font.pixelSize: constants.fontSizeLarge
|
||||||
}
|
}
|
||||||
@@ -136,19 +141,29 @@ Dialog {
|
|||||||
}
|
}
|
||||||
Label {
|
Label {
|
||||||
visible: modelItem.amount > 0
|
visible: modelItem.amount > 0
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.columnSpan: 2
|
|
||||||
text: Config.baseUnit
|
text: Config.baseUnit
|
||||||
color: Material.accentColor
|
color: Material.accentColor
|
||||||
font.pixelSize: constants.fontSizeLarge
|
font.pixelSize: constants.fontSizeLarge
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
id: fiatValue
|
||||||
|
visible: modelItem.amount > 0
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.columnSpan: 2
|
||||||
|
text: Daemon.fx.enabled
|
||||||
|
? '(' + Daemon.fx.fiatValue(modelItem.amount, false) + ' ' + Daemon.fx.fiatCurrency + ')'
|
||||||
|
: ''
|
||||||
|
font.pixelSize: constants.fontSizeMedium
|
||||||
|
wrapMode: Text.Wrap
|
||||||
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
text: qsTr('Address')
|
text: qsTr('Address')
|
||||||
}
|
}
|
||||||
Label {
|
Label {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.columnSpan: 2
|
Layout.columnSpan: 3
|
||||||
font.family: FixedFont
|
font.family: FixedFont
|
||||||
font.pixelSize: constants.fontSizeLarge
|
font.pixelSize: constants.fontSizeLarge
|
||||||
wrapMode: Text.WrapAnywhere
|
wrapMode: Text.WrapAnywhere
|
||||||
@@ -165,10 +180,10 @@ Dialog {
|
|||||||
text: qsTr('Status')
|
text: qsTr('Status')
|
||||||
}
|
}
|
||||||
Label {
|
Label {
|
||||||
Layout.columnSpan: 3
|
Layout.columnSpan: 4
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
font.pixelSize: constants.fontSizeLarge
|
font.pixelSize: constants.fontSizeLarge
|
||||||
text: modelItem.status
|
text: modelItem.status_str
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -184,8 +199,8 @@ Dialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
var bip21uri = bitcoin.create_uri(modelItem.address, modelItem.amount, modelItem.message, modelItem.timestamp, modelItem.exp)
|
_bip21uri = bitcoin.create_uri(modelItem.address, modelItem.amount, modelItem.message, modelItem.timestamp, modelItem.exp)
|
||||||
qr.source = 'image://qrgen/' + bip21uri
|
qr.source = 'image://qrgen/' + _bip21uri
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitcoin {
|
Bitcoin {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class QERequestListModel(QAbstractListModel):
|
|||||||
_logger = get_logger(__name__)
|
_logger = get_logger(__name__)
|
||||||
|
|
||||||
# define listmodel rolemap
|
# define listmodel rolemap
|
||||||
_ROLE_NAMES=('key','type','timestamp','date','message','amount','status','address','exp')
|
_ROLE_NAMES=('key','type','timestamp','date','message','amount','status','status_str','address','exp')
|
||||||
_ROLE_KEYS = range(Qt.UserRole + 1, Qt.UserRole + 1 + len(_ROLE_NAMES))
|
_ROLE_KEYS = range(Qt.UserRole + 1, Qt.UserRole + 1 + len(_ROLE_NAMES))
|
||||||
_ROLE_MAP = dict(zip(_ROLE_KEYS, [bytearray(x.encode()) for x in _ROLE_NAMES]))
|
_ROLE_MAP = dict(zip(_ROLE_KEYS, [bytearray(x.encode()) for x in _ROLE_NAMES]))
|
||||||
_ROLE_RMAP = dict(zip(_ROLE_NAMES, _ROLE_KEYS))
|
_ROLE_RMAP = dict(zip(_ROLE_NAMES, _ROLE_KEYS))
|
||||||
@@ -44,7 +44,8 @@ class QERequestListModel(QAbstractListModel):
|
|||||||
item = {}
|
item = {}
|
||||||
key = self.wallet.get_key_for_receive_request(req) # (verified) address for onchain, rhash for LN
|
key = self.wallet.get_key_for_receive_request(req) # (verified) address for onchain, rhash for LN
|
||||||
status = self.wallet.get_request_status(key)
|
status = self.wallet.get_request_status(key)
|
||||||
item['status'] = req.get_status_str(status)
|
item['status'] = status
|
||||||
|
item['status_str'] = req.get_status_str(status)
|
||||||
item['type'] = req.type # 0=onchain, 2=LN
|
item['type'] = req.type # 0=onchain, 2=LN
|
||||||
item['timestamp'] = req.time
|
item['timestamp'] = req.time
|
||||||
item['date'] = format_time(item['timestamp'])
|
item['date'] = format_time(item['timestamp'])
|
||||||
@@ -97,7 +98,8 @@ class QERequestListModel(QAbstractListModel):
|
|||||||
for item in self.requests:
|
for item in self.requests:
|
||||||
if item['key'] == key:
|
if item['key'] == key:
|
||||||
req = self.wallet.get_request(key)
|
req = self.wallet.get_request(key)
|
||||||
item['status'] = req.get_status_str(status)
|
item['status'] = status
|
||||||
|
item['status_str'] = req.get_status_str(status)
|
||||||
index = self.index(i,0)
|
index = self.index(i,0)
|
||||||
self.dataChanged.emit(index, index, [self._ROLE_RMAP['status']])
|
self.dataChanged.emit(index, index, [self._ROLE_RMAP['status'], self._ROLE_RMAP['status_str']])
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
|||||||
Reference in New Issue
Block a user