core: add 'Rebuild will on wallet close' setting to skip the build wizard at close (REBUILD_ON_CLOSE); settings checkbox + tests

This commit is contained in:
2026-08-14 23:56:14 -04:00
parent c80f0e1524
commit ce659048ca
4 changed files with 205 additions and 2 deletions

View File

@@ -251,6 +251,14 @@ class BalPlugin(BasePlugin):
# (handled by BalWindow.get_wallet_password). Default ON.
self.AUTO_SIGN = BalConfig(config, "bal_auto_sign", True)
# REBUILD_ON_CLOSE: when enabled (default), closing the wallet or
# quitting Electrum runs the "Build your will" wizard
# (BalBuildWillDialog) to rebuild and re-validate the will. When
# disabled, on_close() only persists the current in-memory willitems to
# the wallet DB: no rebuild dialog, no auto-sign/broadcast, no
# invalidation prompts at close. Default ON.
self.REBUILD_ON_CLOSE = BalConfig(config, "bal_rebuild_on_close", True)
# EDITABLE_DATES (Group C / C2): when enabled, the delivery-time and
# check-alive date fields are editable everywhere (toolbar / Heirs tab),
# not only inside the "Build your will" wizard. Default OFF, so the dates

View File

@@ -456,6 +456,14 @@ class Plugin(BalPlugin):
# be saved on a USB stick and a copy given to the heirs).
heir_no_willexecutor = BalCheckBox(self.NO_WILLEXECUTOR)
# "Rebuild will on wallet close" checkbox. Bound to the persisted
# REBUILD_ON_CLOSE config (default ON). When ticked, closing the wallet
# / quitting Electrum runs the "Build your will" wizard to rebuild and
# re-validate the will. When unticked, the will is only rebuilt when
# the user presses Check/Prepare. Visible to all users (BASIC and
# ADVANCED).
heir_rebuild_on_close = BalCheckBox(self.REBUILD_ON_CLOSE)
# USER TYPE selector (SIMPLE / ADVANCED, global). A two-choice combo
# (not a free-text field) bound to the USER_TYPE config:
# index 0 -> "BASIC" -> stored value "basic" (DEFAULT)
@@ -810,6 +818,24 @@ class Plugin(BalPlugin):
2,
)
# "Rebuild will on wallet close" row (always visible, BASIC + ADVANCED).
# Placed below the rebroadcast button so the existing rows keep their
# numbers.
lbl_rebuild_on_close = QLabel(_("Rebuild will on wallet close"))
help_rebuild_on_close = HelpButton(
"Run the 'Build your will' wizard every time the wallet is closed "
"or Electrum is quit, so the will is rebuilt and re-validated.\n"
"When disabled, the will is only rebuilt when you press Check or "
"Prepare. The last built state is still saved to the wallet."
)
grid.addWidget(lbl_rebuild_on_close, 15, 0)
grid.addWidget(heir_rebuild_on_close, 15, 1)
grid.addWidget(help_rebuild_on_close, 15, 2)
reset_btn_rebuild_on_close = _make_reset_btn(
self.REBUILD_ON_CLOSE, heir_rebuild_on_close, "check"
)
grid.addWidget(reset_btn_rebuild_on_close, 15, 3)
# ----------------------------------------------------------------- #
# Group C / C4b: "Reset" button that restores the dialog settings to #
# their factory defaults. It only resets the settings exposed by THIS #
@@ -842,6 +868,7 @@ class Plugin(BalPlugin):
(self.CALENDAR_APP, edit_calendar_app, "line"),
(self.SAVE_HISTORY, heir_save_history, "check"),
(self.HISTORY_LABEL, edit_history_label, "line"),
(self.REBUILD_ON_CLOSE, heir_rebuild_on_close, "check"),
]
for cfg, widget, kind in resets:
# Persist the default value back into the Electrum config.

View File

@@ -1044,9 +1044,12 @@ class BalWindow:
return
# 1) Business logic: build/save the will on close (unchanged behaviour).
# REBUILD_ON_CLOSE gates the "Build your will" wizard only: the will is
# still persisted so a manual Build/Check from the session is not lost.
try:
close_window = BalBuildWillDialog(self)
close_window.build_will_task()
if self.bal_plugin.REBUILD_ON_CLOSE.get():
close_window = BalBuildWillDialog(self)
close_window.build_will_task()
self.save_willitems()
except Exception as e:
_logger.error(f"on_close: build/save will failed: {e}")