diff --git a/src/toad/qt/host.py b/src/toad/qt/host.py index 85612215b..2b261d407 100644 --- a/src/toad/qt/host.py +++ b/src/toad/qt/host.py @@ -126,10 +126,6 @@ def clear_focus(self) -> None: if (focused := QApplication.focusWidget()) is not None: focused.clearFocus() - async def reveal_sidebar(self) -> bool: - """The window's thread list is always on screen.""" - return True - def capture_command_origin(self) -> WindowCommandOrigin: return WindowCommandOrigin(QApplication.activeWindow()) diff --git a/src/toad/qt/window.py b/src/toad/qt/window.py index abf79cdff..982d45378 100644 --- a/src/toad/qt/window.py +++ b/src/toad/qt/window.py @@ -53,6 +53,7 @@ ) from toad.client.application import ClientApplication +from toad.client.application_actions import ApplicationAction from toad.client.connection import ( CoordinationAccess, FailedObservation, @@ -94,6 +95,10 @@ class MessageSend(OperationKind): """Sends one message; sends run side by side and are never superseded.""" +class MenuActionRun(OperationKind): + """One application action chosen from the menu.""" + + class TabClose(OperationKind): """Closes one tab; closes run side by side.""" @@ -734,6 +739,11 @@ def hide_sidebar(self) -> None: self.sidebar.hide() self.paint_sidebar_bar() + async def reveal_sidebar(self) -> bool: + """The sidebar comes up over the conversation, as its bar would bring it.""" + self.show_sidebar() + return True + def toggle_sidebar(self) -> None: if self.sidebar.isVisible(): self.hide_sidebar() @@ -741,12 +751,12 @@ def toggle_sidebar(self) -> None: self.show_sidebar() def show_menu(self) -> None: - """popup(), not exec(): exec's nested event loop under qasync showed nothing on - Android.""" + """Toad's application actions under their labels, as its menu lists them; a choice + runs as its own operation. popup(), not exec(): exec's nested event loop under qasync + showed nothing on Android.""" self.menu_popup = QMenu(self) - self.menu_popup.addAction("Hide sidebar" if self.sidebar.isVisible() else "Show sidebar", - self.toggle_sidebar) - self.menu_popup.addAction("Quit", self.close) + for command, label in ApplicationAction.menu(self): + self.menu_popup.addAction(label, partial(self.run_operation, MenuActionRun, partial(command.apply, self))) corner = self.menu.mapToGlobal(self.menu.rect().topLeft()) self.menu_popup.popup(corner - QPoint(0, self.menu_popup.sizeHint().height()))