bugfixes, lifecycle improvements
This commit is contained in:
@@ -103,12 +103,12 @@ Pane {
|
|||||||
Label {
|
Label {
|
||||||
font.family: FixedFont
|
font.family: FixedFont
|
||||||
text: Config.formatSats(model.balance, false)
|
text: Config.formatSats(model.balance, false)
|
||||||
visible: model.balance > 0
|
visible: model.balance.satsInt != 0
|
||||||
}
|
}
|
||||||
Label {
|
Label {
|
||||||
color: Material.accentColor
|
color: Material.accentColor
|
||||||
text: Config.baseUnit + ','
|
text: Config.baseUnit + ','
|
||||||
visible: model.balance > 0
|
visible: model.balance.satsInt != 0
|
||||||
}
|
}
|
||||||
Label {
|
Label {
|
||||||
text: model.numtx
|
text: model.numtx
|
||||||
|
|||||||
@@ -206,6 +206,7 @@ Dialog {
|
|||||||
enabled: finalizer.valid
|
enabled: finalizer.valid
|
||||||
onClicked: {
|
onClicked: {
|
||||||
finalizer.send_onchain()
|
finalizer.send_onchain()
|
||||||
|
dialog.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -215,7 +215,9 @@ Pane {
|
|||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: requestdialog
|
id: requestdialog
|
||||||
RequestDialog {}
|
RequestDialog {
|
||||||
|
onClosed: destroy()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createRequest(ignoreGaplimit = false) {
|
function createRequest(ignoreGaplimit = false) {
|
||||||
|
|||||||
@@ -130,17 +130,17 @@ Dialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
visible: modelItem.amount != 0
|
visible: modelItem.amount.satsInt != 0
|
||||||
text: qsTr('Amount')
|
text: qsTr('Amount')
|
||||||
}
|
}
|
||||||
Label {
|
Label {
|
||||||
visible: modelItem.amount != 0
|
visible: modelItem.amount.satsInt != 0
|
||||||
text: Config.formatSats(modelItem.amount)
|
text: Config.formatSats(modelItem.amount)
|
||||||
font.family: FixedFont
|
font.family: FixedFont
|
||||||
font.pixelSize: constants.fontSizeLarge
|
font.pixelSize: constants.fontSizeLarge
|
||||||
}
|
}
|
||||||
Label {
|
Label {
|
||||||
visible: modelItem.amount != 0
|
visible: modelItem.amount.satsInt != 0
|
||||||
text: Config.baseUnit
|
text: Config.baseUnit
|
||||||
color: Material.accentColor
|
color: Material.accentColor
|
||||||
font.pixelSize: constants.fontSizeLarge
|
font.pixelSize: constants.fontSizeLarge
|
||||||
@@ -148,7 +148,7 @@ Dialog {
|
|||||||
|
|
||||||
Label {
|
Label {
|
||||||
id: fiatValue
|
id: fiatValue
|
||||||
visible: modelItem.amount != 0
|
visible: modelItem.amount.satsInt != 0
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.columnSpan: 2
|
Layout.columnSpan: 2
|
||||||
text: Daemon.fx.enabled
|
text: Daemon.fx.enabled
|
||||||
@@ -191,7 +191,7 @@ Dialog {
|
|||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: Daemon.currentWallet
|
target: Daemon.currentWallet
|
||||||
function onRequestStatusChanged(key, code) {
|
function onRequestStatusChanged(key, status) {
|
||||||
if (key != modelItem.key)
|
if (key != modelItem.key)
|
||||||
return
|
return
|
||||||
modelItem = Daemon.currentWallet.get_request(key)
|
modelItem = Daemon.currentWallet.get_request(key)
|
||||||
|
|||||||
@@ -32,14 +32,22 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
function show(message) {
|
||||||
|
root.text = message
|
||||||
|
root.hide = false
|
||||||
|
closetimer.start()
|
||||||
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
id: layout
|
id: layout
|
||||||
width: parent.width
|
width: parent.width
|
||||||
Text {
|
Text {
|
||||||
id: textItem
|
id: textItem
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
Layout.fillWidth: true
|
||||||
font.pixelSize: constants.fontSizeLarge
|
font.pixelSize: constants.fontSizeLarge
|
||||||
color: Material.foreground
|
color: Material.foreground
|
||||||
|
wrapMode: Text.Wrap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,8 +58,4 @@ Rectangle {
|
|||||||
onTriggered: hide = true
|
onTriggered: hide = true
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
hide = false
|
|
||||||
closetimer.start()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -174,13 +174,13 @@ ApplicationWindow
|
|||||||
property alias messageDialog: _messageDialog
|
property alias messageDialog: _messageDialog
|
||||||
Component {
|
Component {
|
||||||
id: _messageDialog
|
id: _messageDialog
|
||||||
MessageDialog {}
|
MessageDialog {
|
||||||
|
onClosed: destroy()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
property alias notificationPopup: _notificationPopup
|
NotificationPopup {
|
||||||
Component {
|
id: notificationPopup
|
||||||
id: _notificationPopup
|
|
||||||
NotificationPopup {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
@@ -226,7 +226,7 @@ ApplicationWindow
|
|||||||
Connections {
|
Connections {
|
||||||
target: AppController
|
target: AppController
|
||||||
function onUserNotify(message) {
|
function onUserNotify(message) {
|
||||||
var item = app.notificationPopup.createObject(app, {'text': message})
|
notificationPopup.show(message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ from PyQt5.QtCore import Qt, QAbstractListModel, QModelIndex
|
|||||||
from electrum.logging import get_logger
|
from electrum.logging import get_logger
|
||||||
from electrum.util import Satoshis
|
from electrum.util import Satoshis
|
||||||
|
|
||||||
|
from .qetypes import QEAmount
|
||||||
|
|
||||||
class QEAddressListModel(QAbstractListModel):
|
class QEAddressListModel(QAbstractListModel):
|
||||||
def __init__(self, wallet, parent=None):
|
def __init__(self, wallet, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
@@ -32,7 +34,7 @@ class QEAddressListModel(QAbstractListModel):
|
|||||||
address = self.receive_addresses[index.row()]
|
address = self.receive_addresses[index.row()]
|
||||||
role_index = role - Qt.UserRole
|
role_index = role - Qt.UserRole
|
||||||
value = address[self._ROLE_NAMES[role_index]]
|
value = address[self._ROLE_NAMES[role_index]]
|
||||||
if isinstance(value, bool) or isinstance(value, list) or isinstance(value, int) or value is None:
|
if isinstance(value, (bool, list, int, str, QEAmount)) or value is None:
|
||||||
return value
|
return value
|
||||||
if isinstance(value, Satoshis):
|
if isinstance(value, Satoshis):
|
||||||
return value.value
|
return value.value
|
||||||
@@ -50,7 +52,7 @@ class QEAddressListModel(QAbstractListModel):
|
|||||||
item['numtx'] = self.wallet.get_address_history_len(address)
|
item['numtx'] = self.wallet.get_address_history_len(address)
|
||||||
item['label'] = self.wallet.get_label(address)
|
item['label'] = self.wallet.get_label(address)
|
||||||
c, u, x = self.wallet.get_addr_balance(address)
|
c, u, x = self.wallet.get_addr_balance(address)
|
||||||
item['balance'] = c + u + x
|
item['balance'] = QEAmount(amount_sat=c + u + x)
|
||||||
item['held'] = self.wallet.is_frozen_address(address)
|
item['held'] = self.wallet.is_frozen_address(address)
|
||||||
return item
|
return item
|
||||||
|
|
||||||
|
|||||||
@@ -33,12 +33,11 @@ class QEAbstractInvoiceListModel(QAbstractListModel):
|
|||||||
invoice = self.invoices[index.row()]
|
invoice = self.invoices[index.row()]
|
||||||
role_index = role - Qt.UserRole
|
role_index = role - Qt.UserRole
|
||||||
value = invoice[self._ROLE_NAMES[role_index]]
|
value = invoice[self._ROLE_NAMES[role_index]]
|
||||||
if isinstance(value, bool) or isinstance(value, list) or isinstance(value, int) or value is None:
|
|
||||||
|
if isinstance(value, (bool, list, int, str, QEAmount)) or value is None:
|
||||||
return value
|
return value
|
||||||
if isinstance(value, Satoshis):
|
if isinstance(value, Satoshis):
|
||||||
return value.value
|
return value.value
|
||||||
if isinstance(value, QEAmount):
|
|
||||||
return value
|
|
||||||
return str(value)
|
return str(value)
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
@@ -77,6 +76,12 @@ class QEAbstractInvoiceListModel(QAbstractListModel):
|
|||||||
break
|
break
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
|
||||||
|
def get_model_invoice(self, key: str):
|
||||||
|
for invoice in self.invoices:
|
||||||
|
if invoice['key'] == key:
|
||||||
|
return invoice
|
||||||
|
return None
|
||||||
|
|
||||||
@pyqtSlot(str, int)
|
@pyqtSlot(str, int)
|
||||||
def updateInvoice(self, key, status):
|
def updateInvoice(self, key, status):
|
||||||
self._logger.debug('updating invoice for %s to %d' % (key,status))
|
self._logger.debug('updating invoice for %s to %d' % (key,status))
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class QETransactionListModel(QAbstractListModel):
|
|||||||
tx = self.tx_history[index.row()]
|
tx = self.tx_history[index.row()]
|
||||||
role_index = role - Qt.UserRole
|
role_index = role - Qt.UserRole
|
||||||
value = tx[self._ROLE_NAMES[role_index]]
|
value = tx[self._ROLE_NAMES[role_index]]
|
||||||
if isinstance(value, bool) or isinstance(value, list) or isinstance(value, int) or value is None:
|
if isinstance(value, (bool, list, int, str, QEAmount)) or value is None:
|
||||||
return value
|
return value
|
||||||
if isinstance(value, Satoshis):
|
if isinstance(value, Satoshis):
|
||||||
return value.value
|
return value.value
|
||||||
@@ -110,7 +110,7 @@ class QETransactionListModel(QAbstractListModel):
|
|||||||
tx['height'] = info.height
|
tx['height'] = info.height
|
||||||
tx['confirmations'] = info.conf
|
tx['confirmations'] = info.conf
|
||||||
tx['timestamp'] = info.timestamp
|
tx['timestamp'] = info.timestamp
|
||||||
tx['date'] = self.format_date_by_section(datetime.fromtimestamp(info.timestamp), tx['section'])
|
tx['date'] = self.format_date_by_section(tx['section'], datetime.fromtimestamp(info.timestamp))
|
||||||
index = self.index(i,0)
|
index = self.index(i,0)
|
||||||
roles = [self._ROLE_RMAP[x] for x in ['height','confirmations','timestamp','date']]
|
roles = [self._ROLE_RMAP[x] for x in ['height','confirmations','timestamp','date']]
|
||||||
self.dataChanged.emit(index, index, roles)
|
self.dataChanged.emit(index, index, roles)
|
||||||
|
|||||||
@@ -322,22 +322,21 @@ class QEWallet(QObject):
|
|||||||
#pass
|
#pass
|
||||||
##self.sign_payment_request(addr)
|
##self.sign_payment_request(addr)
|
||||||
self._requestModel.add_invoice(self.wallet.get_request(req_key))
|
self._requestModel.add_invoice(self.wallet.get_request(req_key))
|
||||||
#return addr
|
return addr
|
||||||
|
|
||||||
@pyqtSlot(QEAmount, 'QString', int)
|
@pyqtSlot(QEAmount, 'QString', int)
|
||||||
@pyqtSlot(QEAmount, 'QString', int, bool)
|
@pyqtSlot(QEAmount, 'QString', int, bool)
|
||||||
@pyqtSlot(QEAmount, 'QString', int, bool, bool)
|
@pyqtSlot(QEAmount, 'QString', int, bool, bool)
|
||||||
def create_request(self, amount: QEAmount, message: str, expiration: int, is_lightning: bool = False, ignore_gap: bool = False):
|
def create_request(self, amount: QEAmount, message: str, expiration: int, is_lightning: bool = False, ignore_gap: bool = False):
|
||||||
expiry = expiration #TODO: self.config.get('request_expiry', PR_DEFAULT_EXPIRATION_WHEN_CREATING)
|
|
||||||
try:
|
try:
|
||||||
if is_lightning:
|
if is_lightning:
|
||||||
if not self.wallet.lnworker.channels:
|
if not self.wallet.lnworker.channels:
|
||||||
self.requestCreateError.emit('fatal',_("You need to open a Lightning channel first."))
|
self.requestCreateError.emit('fatal',_("You need to open a Lightning channel first."))
|
||||||
return
|
return
|
||||||
# TODO maybe show a warning if amount exceeds lnworker.num_sats_can_receive (as in kivy)
|
# TODO maybe show a warning if amount exceeds lnworker.num_sats_can_receive (as in kivy)
|
||||||
key = self.wallet.lnworker.add_request(amount.satsInt, message, expiry)
|
key = self.wallet.lnworker.add_request(amount.satsInt, message, expiration)
|
||||||
else:
|
else:
|
||||||
key = self.create_bitcoin_request(amount.satsInt, message, expiry, ignore_gap)
|
key = self.create_bitcoin_request(amount.satsInt, message, expiration, ignore_gap)
|
||||||
if not key:
|
if not key:
|
||||||
return
|
return
|
||||||
self._addressModel.init_model()
|
self._addressModel.init_model()
|
||||||
@@ -356,8 +355,7 @@ class QEWallet(QObject):
|
|||||||
|
|
||||||
@pyqtSlot('QString', result='QVariant')
|
@pyqtSlot('QString', result='QVariant')
|
||||||
def get_request(self, key: str):
|
def get_request(self, key: str):
|
||||||
req = self.wallet.get_request(key)
|
return self._requestModel.get_model_invoice(key)
|
||||||
return self._requestModel.invoice_to_model(req)
|
|
||||||
|
|
||||||
@pyqtSlot('QString')
|
@pyqtSlot('QString')
|
||||||
def delete_invoice(self, key: str):
|
def delete_invoice(self, key: str):
|
||||||
@@ -367,5 +365,4 @@ class QEWallet(QObject):
|
|||||||
|
|
||||||
@pyqtSlot('QString', result='QVariant')
|
@pyqtSlot('QString', result='QVariant')
|
||||||
def get_invoice(self, key: str):
|
def get_invoice(self, key: str):
|
||||||
invoice = self.wallet.get_invoice(key)
|
return self._invoiceModel.get_model_invoice(key)
|
||||||
return self._invoiceModel.invoice_to_model(invoice)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user