mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-02 02:05:19 +00:00
ask user before closing transaction window with unsaved transaction
This commit is contained in:
parent
d9874ecb01
commit
c0e60ec93d
2 changed files with 18 additions and 7 deletions
|
@ -47,6 +47,7 @@ class TxDialog(QDialog):
|
||||||
tx_dict = tx.as_dict()
|
tx_dict = tx.as_dict()
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.wallet = parent.wallet
|
self.wallet = parent.wallet
|
||||||
|
self.saved = True
|
||||||
|
|
||||||
QDialog.__init__(self)
|
QDialog.__init__(self)
|
||||||
self.setMinimumWidth(600)
|
self.setMinimumWidth(600)
|
||||||
|
@ -78,14 +79,14 @@ class TxDialog(QDialog):
|
||||||
b.clicked.connect(self.sign)
|
b.clicked.connect(self.sign)
|
||||||
|
|
||||||
self.broadcast_button = b = QPushButton(_("Broadcast"))
|
self.broadcast_button = b = QPushButton(_("Broadcast"))
|
||||||
b.clicked.connect(lambda: self.parent.broadcast_transaction(self.tx))
|
b.clicked.connect(self.do_broadcast)
|
||||||
b.hide()
|
b.hide()
|
||||||
|
|
||||||
self.save_button = b = QPushButton(_("Save"))
|
self.save_button = b = QPushButton(_("Save"))
|
||||||
b.clicked.connect(self.save)
|
b.clicked.connect(self.save)
|
||||||
|
|
||||||
self.cancel_button = b = QPushButton(_("Close"))
|
self.cancel_button = b = QPushButton(_("Close"))
|
||||||
b.clicked.connect(lambda: self.done(0))
|
b.clicked.connect(self.close)
|
||||||
b.setDefault(True)
|
b.setDefault(True)
|
||||||
|
|
||||||
self.qr_button = b = QPushButton()
|
self.qr_button = b = QPushButton()
|
||||||
|
@ -98,6 +99,15 @@ class TxDialog(QDialog):
|
||||||
vbox.addLayout(Buttons(*self.buttons))
|
vbox.addLayout(Buttons(*self.buttons))
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
|
def do_broadcast(self):
|
||||||
|
self.parent.broadcast_transaction(self.tx)
|
||||||
|
self.saved = True
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
if not self.saved:
|
||||||
|
if QMessageBox.question(self, _('Message'), _('This transaction is not saved. Close anyway?'), QMessageBox.Yes | QMessageBox.No, QMessageBox.No) == QMessageBox.No:
|
||||||
|
return
|
||||||
|
self.done(0)
|
||||||
|
|
||||||
def show_qr(self):
|
def show_qr(self):
|
||||||
text = self.tx.raw.decode('hex')
|
text = self.tx.raw.decode('hex')
|
||||||
|
@ -120,7 +130,7 @@ class TxDialog(QDialog):
|
||||||
with open(fileName, "w+") as f:
|
with open(fileName, "w+") as f:
|
||||||
f.write(json.dumps(self.tx.as_dict(),indent=4) + '\n')
|
f.write(json.dumps(self.tx.as_dict(),indent=4) + '\n')
|
||||||
self.show_message(_("Transaction saved successfully"))
|
self.show_message(_("Transaction saved successfully"))
|
||||||
|
self.saved = True
|
||||||
|
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
|
|
|
@ -29,6 +29,8 @@ from electrum import transaction
|
||||||
from electrum.plugins import BasePlugin, hook
|
from electrum.plugins import BasePlugin, hook
|
||||||
from electrum.i18n import _
|
from electrum.i18n import _
|
||||||
|
|
||||||
|
from electrum_gui.qt import transaction_dialog
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
@ -188,7 +190,6 @@ class Plugin(BasePlugin):
|
||||||
|
|
||||||
self.listener.clear()
|
self.listener.clear()
|
||||||
tx = transaction.Transaction.deserialize(message)
|
tx = transaction.Transaction.deserialize(message)
|
||||||
self.win.show_transaction(tx)
|
d = transaction_dialog.TxDialog(tx, self.win)
|
||||||
|
d.saved = False
|
||||||
|
d.exec_()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue