Skip to content

Commit 4886007

Browse files
committed
qml: open invoices list after saving invoice, add invoice to model instead of reloading the whole list
1 parent 090706b commit 4886007

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed

electrum/gui/qml/components/InvoiceDialog.qml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import QtQuick 2.6
1+
import QtQuick 2.12
22
import QtQuick.Layouts 1.0
33
import QtQuick.Controls 2.14
44
import QtQuick.Controls.Material 2.0
@@ -299,6 +299,7 @@ ElDialog {
299299
visible: invoice_key == ''
300300
enabled: invoice.canSave
301301
onClicked: {
302+
app.stack.push(Qt.resolvedUrl('Invoices.qml'))
302303
invoice.save_invoice()
303304
dialog.close()
304305
}

electrum/gui/qml/components/Invoices.qml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ Pane {
4646
}
4747
}
4848

49+
add: Transition {
50+
NumberAnimation { properties: 'scale'; from: 0.75; to: 1; duration: 500 }
51+
NumberAnimation { properties: 'opacity'; from: 0; to: 1; duration: 500 }
52+
}
53+
addDisplaced: Transition {
54+
SpringAnimation { properties: 'y'; duration: 200; spring: 5; damping: 0.5; mass: 2 }
55+
}
56+
4957
remove: Transition {
5058
NumberAnimation { properties: 'scale'; to: 0.75; duration: 300 }
5159
NumberAnimation { properties: 'opacity'; to: 0; duration: 300 }

electrum/gui/qml/components/WalletMainView.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ Item {
193193
}
194194

195195
onInvoiceSaved: {
196-
Daemon.currentWallet.invoiceModel.init_model()
196+
Daemon.currentWallet.invoiceModel.addInvoice(key)
197197
}
198198
}
199199

electrum/gui/qml/qeinvoice.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class QEInvoiceParser(QEInvoice):
123123
_userinfo = ''
124124

125125
invoiceChanged = pyqtSignal()
126-
invoiceSaved = pyqtSignal()
126+
invoiceSaved = pyqtSignal([str], arguments=['key'])
127127

128128
validationSuccess = pyqtSignal()
129129
validationWarning = pyqtSignal([str,str], arguments=['code', 'message'])
@@ -493,7 +493,7 @@ def save_invoice(self):
493493
# TODO detect duplicate?
494494
self.key = self._effectiveInvoice.get_id()
495495
self._wallet.wallet.save_invoice(self._effectiveInvoice)
496-
self.invoiceSaved.emit()
496+
self.invoiceSaved.emit(self.key)
497497

498498

499499
class QEUserEnteredPayment(QEInvoice):

electrum/gui/qml/qeinvoicelistmodel.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ def add_invoice(self, invoice: Invoice):
6868
self.invoices.insert(0, item)
6969
self.endInsertRows()
7070

71+
@pyqtSlot(str)
72+
def addInvoice(self, key):
73+
self.add_invoice(self.get_invoice_for_key(key))
74+
7175
def delete_invoice(self, key: str):
7276
i = 0
7377
for invoice in self.invoices:

0 commit comments

Comments
 (0)