qt: add tx preview button instead of option
This commit is contained in:
parent
a07a3f748e
commit
1f8e6d38c8
|
@ -850,22 +850,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||||
if self.qr_window and self.qr_window.isVisible():
|
if self.qr_window and self.qr_window.isVisible():
|
||||||
self.qr_window.set_content(addr, amount, message, uri)
|
self.qr_window.set_content(addr, amount, message, uri)
|
||||||
|
|
||||||
def show_before_broadcast(self):
|
|
||||||
return self.config.get('show_before_broadcast', False)
|
|
||||||
|
|
||||||
def set_show_before_broadcast(self, show):
|
|
||||||
self.config.set_key('show_before_broadcast', bool(show))
|
|
||||||
self.set_send_button_text()
|
|
||||||
|
|
||||||
def set_send_button_text(self):
|
|
||||||
if self.show_before_broadcast():
|
|
||||||
text = _("Send...")
|
|
||||||
elif self.wallet and self.wallet.is_watching_only():
|
|
||||||
text = _("Send...")
|
|
||||||
else:
|
|
||||||
text = _("Send")
|
|
||||||
self.send_button.setText(text)
|
|
||||||
|
|
||||||
def create_send_tab(self):
|
def create_send_tab(self):
|
||||||
# A 4-column grid layout. All the stretch is in the last column.
|
# A 4-column grid layout. All the stretch is in the last column.
|
||||||
# The exchange rate plugin adds a fiat widget in column 2
|
# The exchange rate plugin adds a fiat widget in column 2
|
||||||
|
@ -960,12 +944,15 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||||
grid.addWidget(self.fee_slider, 5, 1)
|
grid.addWidget(self.fee_slider, 5, 1)
|
||||||
grid.addWidget(self.rbf_checkbox, 5, 2)
|
grid.addWidget(self.rbf_checkbox, 5, 2)
|
||||||
|
|
||||||
|
self.preview_button = EnterButton(_("Preview"), self.do_preview)
|
||||||
|
self.preview_button.setToolTip(_('Display the details of your transactions before signing it.'))
|
||||||
self.send_button = EnterButton(_("Send"), self.do_send)
|
self.send_button = EnterButton(_("Send"), self.do_send)
|
||||||
self.clear_button = EnterButton(_("Clear"), self.do_clear)
|
self.clear_button = EnterButton(_("Clear"), self.do_clear)
|
||||||
buttons = QHBoxLayout()
|
buttons = QHBoxLayout()
|
||||||
buttons.addStretch(1)
|
buttons.addStretch(1)
|
||||||
buttons.addWidget(self.send_button)
|
|
||||||
buttons.addWidget(self.clear_button)
|
buttons.addWidget(self.clear_button)
|
||||||
|
buttons.addWidget(self.preview_button)
|
||||||
|
buttons.addWidget(self.send_button)
|
||||||
grid.addLayout(buttons, 6, 1, 1, 2)
|
grid.addLayout(buttons, 6, 1, 1, 2)
|
||||||
|
|
||||||
self.amount_e.shortcut.connect(self.spend_max)
|
self.amount_e.shortcut.connect(self.spend_max)
|
||||||
|
@ -1175,8 +1162,10 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||||
coins = self.get_coins()
|
coins = self.get_coins()
|
||||||
return outputs, fee, label, coins
|
return outputs, fee, label, coins
|
||||||
|
|
||||||
|
def do_preview(self):
|
||||||
|
self.do_send(preview = True)
|
||||||
|
|
||||||
def do_send(self):
|
def do_send(self, preview = False):
|
||||||
if run_hook('abort_send', self):
|
if run_hook('abort_send', self):
|
||||||
return
|
return
|
||||||
r = self.read_send_tab()
|
r = self.read_send_tab()
|
||||||
|
@ -1202,9 +1191,10 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||||
self.show_error(_("This transaction requires a higher fee, or it will not be propagated by the network"))
|
self.show_error(_("This transaction requires a higher fee, or it will not be propagated by the network"))
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.show_before_broadcast():
|
if preview:
|
||||||
self.show_transaction(tx, tx_desc)
|
self.show_transaction(tx, tx_desc)
|
||||||
return
|
return
|
||||||
|
|
||||||
# confirmation dialog
|
# confirmation dialog
|
||||||
confirm_amount = self.config.get('confirm_amount', COIN)
|
confirm_amount = self.config.get('confirm_amount', COIN)
|
||||||
msg = [
|
msg = [
|
||||||
|
@ -1619,7 +1609,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||||
def update_buttons_on_seed(self):
|
def update_buttons_on_seed(self):
|
||||||
self.seed_button.setVisible(self.wallet.has_seed())
|
self.seed_button.setVisible(self.wallet.has_seed())
|
||||||
self.password_button.setVisible(self.wallet.can_change_password())
|
self.password_button.setVisible(self.wallet.can_change_password())
|
||||||
self.set_send_button_text()
|
self.send_button.setVisible(not self.wallet.is_watching_only())
|
||||||
|
|
||||||
def change_password_dialog(self):
|
def change_password_dialog(self):
|
||||||
from password_dialog import PasswordDialog, PW_CHANGE
|
from password_dialog import PasswordDialog, PW_CHANGE
|
||||||
|
@ -2545,13 +2535,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||||
multiple_cb.stateChanged.connect(on_multiple)
|
multiple_cb.stateChanged.connect(on_multiple)
|
||||||
tx_widgets.append((multiple_cb, None))
|
tx_widgets.append((multiple_cb, None))
|
||||||
|
|
||||||
showtx_cb = QCheckBox(_('View transaction before signing'))
|
|
||||||
showtx_cb.setChecked(self.show_before_broadcast())
|
|
||||||
showtx_cb.stateChanged.connect(lambda x: self.set_show_before_broadcast(showtx_cb.isChecked()))
|
|
||||||
showtx_cb.setToolTip(_('Display the details of your transactions before signing it.'))
|
|
||||||
tx_widgets.append((showtx_cb, None))
|
|
||||||
|
|
||||||
|
|
||||||
def fmt_docs(key, klass):
|
def fmt_docs(key, klass):
|
||||||
lines = [ln.lstrip(" ") for ln in klass.__doc__.split("\n")]
|
lines = [ln.lstrip(" ") for ln in klass.__doc__.split("\n")]
|
||||||
return '\n'.join([key, "", " ".join(lines)])
|
return '\n'.join([key, "", " ".join(lines)])
|
||||||
|
|
Loading…
Reference in New Issue