Browse Source

Merge pull request #6832 from SomberNight/202012_fix_qt_swap_dialog_ok_btn

qt swap dialog: fix enabling OK button
patch-4
ThomasV 4 years ago
committed by GitHub
parent
commit
0c3f360385
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      electrum/gui/qt/swap_dialog.py

14
electrum/gui/qt/swap_dialog.py

@ -34,7 +34,7 @@ class SwapDialog(WindowModalDialog):
self.lnworker = self.window.wallet.lnworker
self.swap_manager = self.lnworker.swap_manager
self.network = window.network
self.tx = None
self.tx = None # for the forward-swap only
self.is_reverse = True
vbox = QVBoxLayout(self)
self.description_label = WWLabel(self.get_description())
@ -113,7 +113,6 @@ class SwapDialog(WindowModalDialog):
else:
self._spend_max_forward_swap()
else:
self.tx = None
self.send_amount_e.setAmount(None)
self.update_fee()
@ -156,7 +155,8 @@ class SwapDialog(WindowModalDialog):
self.recv_amount_e.setStyleSheet(ColorScheme.BLUE.as_stylesheet())
self.recv_amount_e.follows = False
self.send_follows = False
self.ok_button.setEnabled((recv_amount is not None) and (self.tx is not None))
self.ok_button.setEnabled((recv_amount is not None)
and (self.tx is not None or self.is_reverse))
def on_recv_edited(self):
if self.recv_amount_e.follows:
@ -171,7 +171,8 @@ class SwapDialog(WindowModalDialog):
self.send_amount_e.setStyleSheet(ColorScheme.BLUE.as_stylesheet())
self.send_amount_e.follows = False
self.send_follows = True
self.ok_button.setEnabled((send_amount is not None) and (self.tx is not None))
self.ok_button.setEnabled((send_amount is not None)
and (self.tx is not None or self.is_reverse))
def update(self):
sm = self.swap_manager
@ -188,6 +189,7 @@ class SwapDialog(WindowModalDialog):
self.update_fee()
def update_fee(self):
self.tx = None
is_max = self.max_button.isChecked()
if self.is_reverse:
if is_max:
@ -201,8 +203,8 @@ class SwapDialog(WindowModalDialog):
onchain_amount = self.send_amount_e.get_amount()
self.update_tx(onchain_amount)
fee = self.tx.get_fee() if self.tx else None
if self.tx is None:
self.ok_button.setEnabled(False)
if self.tx is None:
self.ok_button.setEnabled(False)
fee_text = self.window.format_amount(fee) + ' ' + self.window.base_unit() if fee else ''
self.fee_label.setText(fee_text)
self.fee_label.repaint() # macOS hack for #6269

Loading…
Cancel
Save