From 27e9b7d1c00aca796799c181bc5f08cd57d040aa Mon Sep 17 00:00:00 2001 From: kraanzu Date: Mon, 25 Nov 2024 21:36:00 +0530 Subject: [PATCH] fix: dont show help menu when not in normal node (closes #214) --- dooit/ui/api/dooit_api.py | 4 ++++ dooit/ui/widgets/trees/model_tree.py | 6 +++--- dooit/utils/default_config.py | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/dooit/ui/api/dooit_api.py b/dooit/ui/api/dooit_api.py index 31f2b321..d45f16f8 100644 --- a/dooit/ui/api/dooit_api.py +++ b/dooit/ui/api/dooit_api.py @@ -179,3 +179,7 @@ def decrease_urgency(self): """Decrease the urgency of the todo""" if isinstance(self.focused, TodosTree): self.focused.decrease_urgency() + + def show_help(self): + """Show the help screen""" + self.focused.show_help() diff --git a/dooit/ui/widgets/trees/model_tree.py b/dooit/ui/widgets/trees/model_tree.py index 854b6af9..6e5edf95 100644 --- a/dooit/ui/widgets/trees/model_tree.py +++ b/dooit/ui/widgets/trees/model_tree.py @@ -156,9 +156,6 @@ def add_children_recurse(model: ModelType): def on_mount(self): self.force_refresh() - def key_question_mark(self): - self.app.push_screen("help") - @require_highlighted_node def start_sort(self): self.post_message(StartSort(self.current_model, self.sort)) @@ -341,6 +338,9 @@ def sort(self, attr: str): else: self.current_model.sort_siblings(attr) + def show_help(self): + self.app.push_screen("help") + def compose(self) -> ComposeResult: with Label(id="empty_message"): yield Label("No items to display") diff --git a/dooit/utils/default_config.py b/dooit/utils/default_config.py index 0f70ec66..cd182bd1 100644 --- a/dooit/utils/default_config.py +++ b/dooit/utils/default_config.py @@ -147,6 +147,7 @@ def key_setup(api: DooitAPI, _): api.keys.set("/", api.start_search) api.keys.set("", api.start_sort) api.keys.set("", api.quit) + api.keys.set("?", api.show_help) @subscribe(Startup)