From 4a820724434f27e21ce67db0c96784753ea24917 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Wed, 17 Jan 2024 14:13:20 +0000 Subject: [PATCH] qt: new_channel_dialog: init USE_RECOVERABLE_CHANNELS cb intuitively if `not lnworker.can_have_recoverable_channels()`, - previously: the cb was disabled and checked - now: the cb is disabled and unchecked --- electrum/gui/qt/my_treeview.py | 6 ++++-- electrum/gui/qt/new_channel_dialog.py | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/electrum/gui/qt/my_treeview.py b/electrum/gui/qt/my_treeview.py index a72b2f81e..36fe9753f 100644 --- a/electrum/gui/qt/my_treeview.py +++ b/electrum/gui/qt/my_treeview.py @@ -89,16 +89,18 @@ class MyMenu(QMenu): configvar: 'ConfigVarWithConfig', *, callback=None, + checked: Optional[bool] = None, # to override initial state of checkbox short_desc: Optional[str] = None, ) -> QAction: assert isinstance(configvar, ConfigVarWithConfig), configvar if short_desc is None: short_desc = configvar.get_short_desc() assert short_desc is not None, f"short_desc missing for {configvar}" - b = configvar.get() + if checked is None: + checked = bool(configvar.get()) m = self.addAction(short_desc, lambda: self._do_toggle_config(configvar, callback=callback)) m.setCheckable(True) - m.setChecked(bool(b)) + m.setChecked(checked) if (long_desc := configvar.get_long_desc()) is not None: m.setToolTip(messages.to_rtf(long_desc)) return m diff --git a/electrum/gui/qt/new_channel_dialog.py b/electrum/gui/qt/new_channel_dialog.py index b4ab59953..e2f7d7094 100644 --- a/electrum/gui/qt/new_channel_dialog.py +++ b/electrum/gui/qt/new_channel_dialog.py @@ -37,6 +37,7 @@ class NewChannelDialog(WindowModalDialog): toolbar, menu = create_toolbar_with_menu(self.config, '') menu.addConfig( self.config.cv.LIGHTNING_USE_RECOVERABLE_CHANNELS, + checked=self.lnworker.has_recoverable_channels(), ).setEnabled(self.lnworker.can_have_recoverable_channels()) vbox.addLayout(toolbar) msg = _('Choose a remote node and an amount to fund the channel.')