diff --git a/electrum/gui/qml/components/Invoices.qml b/electrum/gui/qml/components/Invoices.qml index 865856ca6..5535837b1 100644 --- a/electrum/gui/qml/components/Invoices.qml +++ b/electrum/gui/qml/components/Invoices.qml @@ -9,6 +9,7 @@ import "controls" Pane { id: root + property string selected_key ColumnLayout { anchors.fill: parent @@ -39,7 +40,11 @@ Pane { dialog.invoiceAmountChanged.connect(function () { Daemon.currentWallet.invoiceModel.init_model() }) + selected_key = '' } + onPressAndHold: { + selected_key = model.key + } } } @@ -65,5 +70,33 @@ Pane { ScrollIndicator.vertical: ScrollIndicator { } } } + ButtonContainer { + Layout.fillWidth: true + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + text: qsTr('Delete') + icon.source: '../../icons/delete.png' + visible: selected_key != '' + onClicked: { + Daemon.currentWallet.delete_invoice(selected_key) + selected_key = '' + } + } + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + text: qsTr('View') + icon.source: '../../icons/tab_receive.png' + visible: selected_key != '' + onClicked: { + var dialog = app.stack.getRoot().openInvoice(selected_key) + dialog.invoiceAmountChanged.connect(function () { + Daemon.currentWallet.invoiceModel.init_model() + }) + selected_key = '' + } + } + } } } diff --git a/electrum/gui/qml/components/ReceiveRequests.qml b/electrum/gui/qml/components/ReceiveRequests.qml index 42ac17e72..3de544f5b 100644 --- a/electrum/gui/qml/components/ReceiveRequests.qml +++ b/electrum/gui/qml/components/ReceiveRequests.qml @@ -12,6 +12,7 @@ import "controls" Pane { id: root objectName: 'ReceiveRequests' + property string selected_key ColumnLayout { anchors.fill: parent @@ -38,14 +39,14 @@ Pane { model: Daemon.currentWallet.requestModel delegate: InvoiceDelegate { onClicked: { - // TODO: only open unpaid? - if (model.status == Invoice.Unpaid) { - app.stack.getRoot().openRequest(model.key) - } + app.stack.getRoot().openRequest(model.key) + selected_key = '' } + onPressAndHold: { + selected_key = model.key + } } } - add: Transition { NumberAnimation { properties: 'scale'; from: 0.75; to: 1; duration: 500 } NumberAnimation { properties: 'opacity'; from: 0; to: 1; duration: 500 } @@ -68,5 +69,30 @@ Pane { ScrollIndicator.vertical: ScrollIndicator { } } } + ButtonContainer { + Layout.fillWidth: true + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + text: qsTr('Delete') + icon.source: '../../icons/delete.png' + visible: selected_key != '' + onClicked: { + Daemon.currentWallet.delete_request(selected_key) + selected_key = '' + } + } + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + text: qsTr('View') + icon.source: '../../icons/tab_receive.png' + visible: selected_key != '' + onClicked: { + app.stack.getRoot().openRequest(selected_key) + selected_key = '' + } + } + } } } diff --git a/electrum/gui/qml/components/WalletMainView.qml b/electrum/gui/qml/components/WalletMainView.qml index a8ce5687b..c0a1cbfff 100644 --- a/electrum/gui/qml/components/WalletMainView.qml +++ b/electrum/gui/qml/components/WalletMainView.qml @@ -192,6 +192,7 @@ Item { dialog.open() } onPressAndHold: { + Daemon.currentWallet.delete_expired_requests() app.stack.push(Qt.resolvedUrl('ReceiveRequests.qml')) } } diff --git a/electrum/gui/qml/qewallet.py b/electrum/gui/qml/qewallet.py index c9211fec7..5de412f1b 100644 --- a/electrum/gui/qml/qewallet.py +++ b/electrum/gui/qml/qewallet.py @@ -608,17 +608,18 @@ class QEWallet(AuthMixin, QObject, QtEventListener): threading.Thread(target=pay_thread, daemon=True).start() - + @pyqtSlot() + def delete_expired_requests(self): + keys = self.wallet.delete_expired_requests() + for key in keys: + self.requestModel.delete_invoice(key) @pyqtSlot(QEAmount, str, int) @pyqtSlot(QEAmount, str, int, bool) @pyqtSlot(QEAmount, str, int, bool, bool) @pyqtSlot(QEAmount, str, int, bool, bool, bool) def createRequest(self, amount: QEAmount, message: str, expiration: int, lightning_only: bool = False, reuse_address: bool = False): - # delete expired_requests - keys = self.wallet.delete_expired_requests() - for key in keys: - self.requestModel.delete_invoice(key) + self.delete_expired_requests() try: amount = amount.satsInt addr = self.wallet.get_unused_address()