diff --git a/clive/__private/ui/app.py b/clive/__private/ui/app.py index 0c3688d74a42085dfec36c41435af990fe3fb249..aadbc33a16db9abbc28d40b9629b854625afb362 100644 --- a/clive/__private/ui/app.py +++ b/clive/__private/ui/app.py @@ -11,8 +11,10 @@ from textual import on, work from textual._context import active_app from textual.app import App from textual.await_complete import AwaitComplete +from textual.css.query import NoMatches from textual.notifications import Notification, Notify, SeverityLevel from textual.reactive import var +from textual.widgets import HelpPanel from textual.worker import NoActiveWorker, WorkerCancelled, get_current_worker from clive.__private.core.async_guard import AsyncGuard @@ -88,6 +90,7 @@ class Clive(App[int]): CLIVE_PREDEFINED_BINDINGS.app.load_transaction_from_file.create(show=False), CLIVE_PREDEFINED_BINDINGS.app.quit.create(show=False), CLIVE_PREDEFINED_BINDINGS.app.switch_node.create(show=False), + CLIVE_PREDEFINED_BINDINGS.app.toggle_keys_panel.create(show=False), CLIVE_PREDEFINED_BINDINGS.app.dashboard.create(), CLIVE_PREDEFINED_BINDINGS.app.lock_wallet.create(), CLIVE_PREDEFINED_BINDINGS.app.settings.create(), @@ -319,6 +322,14 @@ class Clive(App[int]): return self.push_screen(LoadTransactionFromFileDialog()) + def action_toggle_keys_panel(self) -> None: + try: + self.screen.query_exactly_one(HelpPanel) + except NoMatches: + self.action_show_help_panel() + else: + self.action_hide_help_panel() + async def action_transaction_summary(self) -> None: with self._screen_remove_guard.suppress(), self._screen_remove_guard.guard(): await self.go_to_transaction_summary() diff --git a/clive/__private/ui/bindings/sections.py b/clive/__private/ui/bindings/sections.py index f75835b83f5e83ac2961bca88a4122e1e69c4dc8..2f0ffb5dbc057a4f65e9e96549f149a629cc6a05 100644 --- a/clive/__private/ui/bindings/sections.py +++ b/clive/__private/ui/bindings/sections.py @@ -18,6 +18,7 @@ class App(CliveBindingSection): lock_wallet: CliveBinding = field(default_factory=lambda: CliveBinding(id="lock_wallet", key="ctrl+l")) settings: CliveBinding = field(default_factory=lambda: CliveBinding(id="settings", key="ctrl+s")) switch_node: CliveBinding = field(default_factory=lambda: CliveBinding(id="switch_node", key="ctrl+n")) + toggle_keys_panel: CliveBinding = field(default_factory=lambda: CliveBinding(id="toggle_keys_panel", key="ctrl+b")) transaction_summary: CliveBinding = field( default_factory=lambda: CliveBinding(id="transaction_summary", key="ctrl+t") ) diff --git a/tests/clive-local-tools/clive_local_tools/tui/bindings/default_bindings.toml b/tests/clive-local-tools/clive_local_tools/tui/bindings/default_bindings.toml index 68bc399a7f390bffe3856a9ddb4c6b240aebb242..2155c0ef3066024b9058089ba51ded0da1807e90 100644 --- a/tests/clive-local-tools/clive_local_tools/tui/bindings/default_bindings.toml +++ b/tests/clive-local-tools/clive_local_tools/tui/bindings/default_bindings.toml @@ -5,6 +5,7 @@ load_transaction_from_file = "ctrl+o" lock_wallet = "ctrl+l" settings = "ctrl+s" switch_node = "ctrl+n" +toggle_keys_panel = "ctrl+b" transaction_summary = "ctrl+t" quit = "ctrl+q"