transaction_dialog: don't override base class
Rename parent to main_window. Make the main window our parent.
This commit is contained in:
parent
3574ade484
commit
d9a13a5dd1
|
@ -44,16 +44,16 @@ class TxDialog(QDialog, MessageBoxMixin):
|
||||||
'''Transactions in the wallet will show their description.
|
'''Transactions in the wallet will show their description.
|
||||||
Pass desc to give a description for txs not yet in the wallet.
|
Pass desc to give a description for txs not yet in the wallet.
|
||||||
'''
|
'''
|
||||||
|
QDialog.__init__(self, parent)
|
||||||
self.tx = tx
|
self.tx = tx
|
||||||
self.tx.deserialize()
|
self.tx.deserialize()
|
||||||
self.parent = parent
|
self.main_window = parent
|
||||||
self.wallet = parent.wallet
|
self.wallet = parent.wallet
|
||||||
self.prompt_if_unsaved = prompt_if_unsaved
|
self.prompt_if_unsaved = prompt_if_unsaved
|
||||||
self.saved = False
|
self.saved = False
|
||||||
self.broadcast = False
|
self.broadcast = False
|
||||||
self.desc = desc
|
self.desc = desc
|
||||||
|
|
||||||
QDialog.__init__(self)
|
|
||||||
self.setMinimumWidth(660)
|
self.setMinimumWidth(660)
|
||||||
self.setWindowTitle(_("Transaction"))
|
self.setWindowTitle(_("Transaction"))
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ class TxDialog(QDialog, MessageBoxMixin):
|
||||||
|
|
||||||
vbox.addWidget(QLabel(_("Transaction ID:")))
|
vbox.addWidget(QLabel(_("Transaction ID:")))
|
||||||
self.tx_hash_e = ButtonsLineEdit()
|
self.tx_hash_e = ButtonsLineEdit()
|
||||||
qr_show = lambda: self.parent.show_qrcode(str(self.tx_hash_e.text()), 'Transaction ID', parent=self)
|
qr_show = lambda: parent.show_qrcode(str(self.tx_hash_e.text()), 'Transaction ID', parent=self)
|
||||||
self.tx_hash_e.addButton(":icons/qrcode.png", qr_show, _("Show as QR code"))
|
self.tx_hash_e.addButton(":icons/qrcode.png", qr_show, _("Show as QR code"))
|
||||||
self.tx_hash_e.setReadOnly(True)
|
self.tx_hash_e.setReadOnly(True)
|
||||||
vbox.addWidget(self.tx_hash_e)
|
vbox.addWidget(self.tx_hash_e)
|
||||||
|
@ -99,7 +99,7 @@ class TxDialog(QDialog, MessageBoxMixin):
|
||||||
b.setIcon(QIcon(":icons/qrcode.png"))
|
b.setIcon(QIcon(":icons/qrcode.png"))
|
||||||
b.clicked.connect(self.show_qr)
|
b.clicked.connect(self.show_qr)
|
||||||
|
|
||||||
self.copy_button = CopyButton(lambda: str(self.tx), self.parent.app)
|
self.copy_button = CopyButton(lambda: str(self.tx), parent.app)
|
||||||
|
|
||||||
# Action buttons
|
# Action buttons
|
||||||
self.buttons = [self.sign_button, self.broadcast_button, self.cancel_button]
|
self.buttons = [self.sign_button, self.broadcast_button, self.cancel_button]
|
||||||
|
@ -116,7 +116,7 @@ class TxDialog(QDialog, MessageBoxMixin):
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def do_broadcast(self):
|
def do_broadcast(self):
|
||||||
self.parent.broadcast_transaction(self.tx, self.desc, self)
|
self.main_window.broadcast_transaction(self.tx, self.desc, self)
|
||||||
self.broadcast = True
|
self.broadcast = True
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ class TxDialog(QDialog, MessageBoxMixin):
|
||||||
text = self.tx.raw.decode('hex')
|
text = self.tx.raw.decode('hex')
|
||||||
text = base_encode(text, base=43)
|
text = base_encode(text, base=43)
|
||||||
try:
|
try:
|
||||||
self.parent.show_qrcode(text, 'Transaction', parent=self)
|
self.main_window.show_qrcode(text, 'Transaction', parent=self)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.show_message(str(e))
|
self.show_message(str(e))
|
||||||
|
|
||||||
|
@ -148,11 +148,11 @@ class TxDialog(QDialog, MessageBoxMixin):
|
||||||
self.sign_button.setDisabled(True)
|
self.sign_button.setDisabled(True)
|
||||||
# Note sign_tx is wrapped and parent= is actually passed
|
# Note sign_tx is wrapped and parent= is actually passed
|
||||||
# to the password input dialog box
|
# to the password input dialog box
|
||||||
self.parent.sign_tx(self.tx, sign_done, parent=self)
|
self.main_window.sign_tx(self.tx, sign_done, parent=self)
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
name = 'signed_%s.txn' % (self.tx.hash()[0:8]) if self.tx.is_complete() else 'unsigned.txn'
|
name = 'signed_%s.txn' % (self.tx.hash()[0:8]) if self.tx.is_complete() else 'unsigned.txn'
|
||||||
fileName = self.parent.getSaveFileName(_("Select where to save your signed transaction"), name, "*.txn")
|
fileName = self.main_window.getSaveFileName(_("Select where to save your signed transaction"), name, "*.txn")
|
||||||
if fileName:
|
if fileName:
|
||||||
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')
|
||||||
|
@ -181,7 +181,7 @@ class TxDialog(QDialog, MessageBoxMixin):
|
||||||
else:
|
else:
|
||||||
self.broadcast_button.show()
|
self.broadcast_button.show()
|
||||||
# cannot broadcast when offline
|
# cannot broadcast when offline
|
||||||
if self.parent.network is None:
|
if self.main_window.network is None:
|
||||||
self.broadcast_button.setEnabled(False)
|
self.broadcast_button.setEnabled(False)
|
||||||
else:
|
else:
|
||||||
s, r = self.tx.signature_count()
|
s, r = self.tx.signature_count()
|
||||||
|
@ -211,16 +211,19 @@ class TxDialog(QDialog, MessageBoxMixin):
|
||||||
if not self.wallet.up_to_date:
|
if not self.wallet.up_to_date:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
base_unit = self.main_window.base_unit()
|
||||||
|
format_amount = self.main_window.format_amount
|
||||||
|
|
||||||
if is_relevant:
|
if is_relevant:
|
||||||
if is_mine:
|
if is_mine:
|
||||||
if fee is not None:
|
if fee is not None:
|
||||||
self.amount_label.setText(_("Amount sent:")+' %s'% self.parent.format_amount(-v+fee) + ' ' + self.parent.base_unit())
|
self.amount_label.setText(_("Amount sent:")+' %s'% format_amount(-v+fee) + ' ' + base_unit)
|
||||||
self.fee_label.setText(_("Transaction fee")+': %s'% self.parent.format_amount(-fee) + ' ' + self.parent.base_unit())
|
self.fee_label.setText(_("Transaction fee")+': %s'% format_amount(-fee) + ' ' + base_unit)
|
||||||
else:
|
else:
|
||||||
self.amount_label.setText(_("Amount sent:")+' %s'% self.parent.format_amount(-v) + ' ' + self.parent.base_unit())
|
self.amount_label.setText(_("Amount sent:")+' %s'% format_amount(-v) + ' ' + base_unit)
|
||||||
self.fee_label.setText(_("Transaction fee")+': '+ _("unknown"))
|
self.fee_label.setText(_("Transaction fee")+': '+ _("unknown"))
|
||||||
else:
|
else:
|
||||||
self.amount_label.setText(_("Amount received:")+' %s'% self.parent.format_amount(v) + ' ' + self.parent.base_unit())
|
self.amount_label.setText(_("Amount received:")+' %s'% format_amount(v) + ' ' + base_unit)
|
||||||
else:
|
else:
|
||||||
self.amount_label.setText(_("Transaction unrelated to your wallet"))
|
self.amount_label.setText(_("Transaction unrelated to your wallet"))
|
||||||
|
|
||||||
|
@ -248,7 +251,7 @@ class TxDialog(QDialog, MessageBoxMixin):
|
||||||
return ext
|
return ext
|
||||||
|
|
||||||
def format_amount(amt):
|
def format_amount(amt):
|
||||||
return self.parent.format_amount(amt, whitespaces = True)
|
return self.main_window.format_amount(amt, whitespaces = True)
|
||||||
|
|
||||||
i_text = QTextEdit()
|
i_text = QTextEdit()
|
||||||
i_text.setFont(QFont(MONOSPACE_FONT))
|
i_text.setFont(QFont(MONOSPACE_FONT))
|
||||||
|
|
Loading…
Reference in New Issue