fix #4356: qt/tx_dialog - move save local button to left.
also: properly parent popup, and add extra note re what local tx ('save') means
This commit is contained in:
@@ -3167,17 +3167,21 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
|||||||
self.show_transaction(new_tx, tx_label)
|
self.show_transaction(new_tx, tx_label)
|
||||||
|
|
||||||
def save_transaction_into_wallet(self, tx):
|
def save_transaction_into_wallet(self, tx):
|
||||||
|
win = self.top_level_window()
|
||||||
try:
|
try:
|
||||||
if not self.wallet.add_transaction(tx.txid(), tx):
|
if not self.wallet.add_transaction(tx.txid(), tx):
|
||||||
self.show_error(_("Transaction could not be saved.") + "\n" +
|
win.show_error(_("Transaction could not be saved.") + "\n" +
|
||||||
_("It conflicts with current history."))
|
_("It conflicts with current history."))
|
||||||
return False
|
return False
|
||||||
except AddTransactionException as e:
|
except AddTransactionException as e:
|
||||||
self.show_error(e)
|
win.show_error(e)
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
self.wallet.save_transactions(write=True)
|
self.wallet.save_transactions(write=True)
|
||||||
# need to update at least: history_list, utxo_list, address_list
|
# need to update at least: history_list, utxo_list, address_list
|
||||||
self.need_update.set()
|
self.need_update.set()
|
||||||
self.msg_box(QPixmap(":icons/offline_tx.png"), None, _('Success'), _("Transaction added to wallet history"))
|
msg = (_("Transaction added to wallet history.") + '\n\n' +
|
||||||
|
_("Note: this is an offline transaction, if you want the network "
|
||||||
|
"to see it, you need to broadcast it."))
|
||||||
|
win.msg_box(QPixmap(":icons/offline_tx.png"), None, _('Success'), msg)
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -42,6 +42,11 @@ from electrum.transaction import SerializationError
|
|||||||
|
|
||||||
from .util import *
|
from .util import *
|
||||||
|
|
||||||
|
|
||||||
|
SAVE_BUTTON_ENABLED_TOOLTIP = _("Save transaction offline")
|
||||||
|
SAVE_BUTTON_DISABLED_TOOLTIP = _("Please sign this transaction in order to save it")
|
||||||
|
|
||||||
|
|
||||||
dialogs = [] # Otherwise python randomly garbage collects the dialogs...
|
dialogs = [] # Otherwise python randomly garbage collects the dialogs...
|
||||||
|
|
||||||
|
|
||||||
@@ -113,14 +118,14 @@ class TxDialog(QDialog, MessageBoxMixin):
|
|||||||
self.broadcast_button = b = QPushButton(_("Broadcast"))
|
self.broadcast_button = b = QPushButton(_("Broadcast"))
|
||||||
b.clicked.connect(self.do_broadcast)
|
b.clicked.connect(self.do_broadcast)
|
||||||
|
|
||||||
self.save_button = QPushButton(_("Save"))
|
self.save_button = b = QPushButton(_("Save"))
|
||||||
save_button_disabled = not tx.is_complete()
|
save_button_disabled = not tx.is_complete()
|
||||||
self.save_button.setDisabled(save_button_disabled)
|
b.setDisabled(save_button_disabled)
|
||||||
if save_button_disabled:
|
if save_button_disabled:
|
||||||
self.save_button.setToolTip(_("Please sign this transaction in order to save it"))
|
b.setToolTip(SAVE_BUTTON_DISABLED_TOOLTIP)
|
||||||
else:
|
else:
|
||||||
self.save_button.setToolTip("")
|
b.setToolTip(SAVE_BUTTON_ENABLED_TOOLTIP)
|
||||||
self.save_button.clicked.connect(self.save)
|
b.clicked.connect(self.save)
|
||||||
|
|
||||||
self.export_button = b = QPushButton(_("Export"))
|
self.export_button = b = QPushButton(_("Export"))
|
||||||
b.clicked.connect(self.export)
|
b.clicked.connect(self.export)
|
||||||
@@ -136,9 +141,9 @@ class TxDialog(QDialog, MessageBoxMixin):
|
|||||||
self.copy_button = CopyButton(lambda: str(self.tx), 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.save_button, self.cancel_button]
|
self.buttons = [self.sign_button, self.broadcast_button, self.cancel_button]
|
||||||
# Transaction sharing buttons
|
# Transaction sharing buttons
|
||||||
self.sharing_buttons = [self.copy_button, self.qr_button, self.export_button]
|
self.sharing_buttons = [self.copy_button, self.qr_button, self.export_button, self.save_button]
|
||||||
|
|
||||||
run_hook('transaction_dialog', self)
|
run_hook('transaction_dialog', self)
|
||||||
|
|
||||||
@@ -184,7 +189,7 @@ class TxDialog(QDialog, MessageBoxMixin):
|
|||||||
self.prompt_if_unsaved = True
|
self.prompt_if_unsaved = True
|
||||||
self.saved = False
|
self.saved = False
|
||||||
self.save_button.setDisabled(False)
|
self.save_button.setDisabled(False)
|
||||||
self.save_button.setToolTip("")
|
self.save_button.setToolTip(SAVE_BUTTON_ENABLED_TOOLTIP)
|
||||||
self.update()
|
self.update()
|
||||||
self.main_window.pop_top_level_window(self)
|
self.main_window.pop_top_level_window(self)
|
||||||
|
|
||||||
@@ -193,9 +198,11 @@ class TxDialog(QDialog, MessageBoxMixin):
|
|||||||
self.main_window.sign_tx(self.tx, sign_done)
|
self.main_window.sign_tx(self.tx, sign_done)
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
|
self.main_window.push_top_level_window(self)
|
||||||
if self.main_window.save_transaction_into_wallet(self.tx):
|
if self.main_window.save_transaction_into_wallet(self.tx):
|
||||||
self.save_button.setDisabled(True)
|
self.save_button.setDisabled(True)
|
||||||
self.saved = True
|
self.saved = True
|
||||||
|
self.main_window.pop_top_level_window(self)
|
||||||
|
|
||||||
|
|
||||||
def export(self):
|
def export(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user