From f75b4d0b5717f9a29db67b17441978c0ef5b705b Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Mon, 4 Jul 2022 14:34:34 +0200 Subject: [PATCH] Improved dialog navigation --- nomadnet/ui/TextUI.py | 3 ++- nomadnet/ui/textui/Network.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/nomadnet/ui/TextUI.py b/nomadnet/ui/TextUI.py index 7ed1201..4a8abf9 100644 --- a/nomadnet/ui/TextUI.py +++ b/nomadnet/ui/TextUI.py @@ -210,7 +210,8 @@ class TextUI: self.screen.reset_default_terminal_palette() def unhandled_input(self, key): - pass + if key == "ctrl q": + raise urwid.ExitMainLoop def display_main(self, loop, user_data): self.loop.widget = self.main_display.widget diff --git a/nomadnet/ui/textui/Network.py b/nomadnet/ui/textui/Network.py index acfd4cf..8bfe457 100644 --- a/nomadnet/ui/textui/Network.py +++ b/nomadnet/ui/textui/Network.py @@ -51,6 +51,13 @@ class ListEntry(urwid.Text): class AnnounceInfo(urwid.WidgetWrap): + def keypress(self, size, key): + if key == "esc": + options = self.parent.left_pile.options(height_type="weight", height_amount=1) + self.parent.left_pile.contents[0] = (self.parent.announce_stream_display, options) + else: + return super(AnnounceInfo, self).keypress(size, key) + def __init__(self, announce, parent, app): self.app = nomadnet.NomadNetworkApp.get_shared_instance() self.parent = self.app.ui.main_display.sub_displays.network_display @@ -387,6 +394,13 @@ class ListDialogLineBox(urwid.LineBox): return super(ListDialogLineBox, self).keypress(size, key) class KnownNodeInfo(urwid.WidgetWrap): + def keypress(self, size, key): + if key == "esc": + options = self.parent.left_pile.options(height_type="weight", height_amount=1) + self.parent.left_pile.contents[0] = (self.parent.known_nodes_display, options) + else: + return super(KnownNodeInfo, self).keypress(size, key) + def __init__(self, node_hash): self.app = nomadnet.NomadNetworkApp.get_shared_instance() self.parent = self.app.ui.main_display.sub_displays.network_display @@ -567,6 +581,10 @@ class KnownNodeInfo(urwid.WidgetWrap): pile_widgets.insert(4, operator_entry) pile = urwid.Pile(pile_widgets) + + pile.focus_position = len(pile.contents)-1 + button_columns.focus_position = 0 + self.display_widget = urwid.Filler(pile, valign="top", height="pack") @@ -1257,6 +1275,8 @@ class NetworkLeftPile(urwid.Pile): def keypress(self, size, key): if key == "ctrl l": self.parent.toggle_list() + elif key == "ctrl e": + self.parent.selected_node_info() elif key == "ctrl p": self.parent.reinit_lxmf_peers() self.parent.show_peers() @@ -1332,6 +1352,18 @@ class NetworkDisplay(): else: self.list_display = 1 + def selected_node_info(self): + if self.list_display == 1: + parent = self.app.ui.main_display.sub_displays.network_display + selected_node_entry = parent.known_nodes_display.ilb.get_selected_item() + if selected_node_entry != None: + selected_node_hash = selected_node_entry._get_base_widget().display_widget.source_hash + + if selected_node_hash != None: + info_widget = KnownNodeInfo(selected_node_hash) + options = parent.left_pile.options(height_type="weight", height_amount=1) + parent.left_pile.contents[0] = (info_widget, options) + def focus_lists(self): self.columns.focus_position = 0