diff --git a/dodo/app.py b/dodo/app.py index e01369d..985d2b1 100644 --- a/dodo/app.py +++ b/dodo/app.py @@ -152,8 +152,12 @@ def __init__(self) -> None: # open init_queries and make un-closeable # - for query in settings.init_queries: - self.open_search(query, keep_open=True) + for entry in settings.init_queries: + if isinstance(entry, tuple): + query, custom_title = entry + else: + query, custom_title = entry, '' + self.open_search(query, keep_open=True, custom_title=custom_title) def _handle_signal_wakeup(self) -> None: """Called when a Unix signal wakes up the Qt event loop via the pipe""" @@ -232,7 +236,7 @@ def close_panel(self, to_close: int|panel.Panel|None=None) -> None: # remove the panel itself self.tabs.removeTab(index) - def open_search(self, query: str, keep_open: bool=False) -> None: + def open_search(self, query: str, keep_open: bool=False, custom_title: str='') -> None: """Open a search panel with the given query If a panel with this query is already open, switch to it rather than @@ -246,7 +250,7 @@ def open_search(self, query: str, keep_open: bool=False) -> None: self.tabs.setCurrentIndex(i) return - p = search.SearchPanel(self, query, keep_open=keep_open) + p = search.SearchPanel(self, query, keep_open=keep_open, custom_title=custom_title) self.add_panel(p) def open_thread(self, thread_id: str, query: str) -> None: diff --git a/dodo/search.py b/dodo/search.py index bc69842..a9d0cff 100644 --- a/dodo/search.py +++ b/dodo/search.py @@ -220,10 +220,11 @@ class SearchPanel(panel.Panel): This is used as the main entry point for the GUI, i.e. a search for "tag:inbox".""" - def __init__(self, a: app.Dodo, q: str, keep_open: bool=False, parent: Optional[QWidget]=None): + def __init__(self, a: app.Dodo, q: str, keep_open: bool=False, custom_title: str='', parent: Optional[QWidget]=None): super().__init__(a, keep_open, parent) self.set_keymap(keymap.search_keymap) self.q = q + self.custom_title = custom_title self.conf = QSettings("dodo", "dodo") self.tree = QTreeView() self.error_view = QLabel() @@ -316,7 +317,7 @@ def title(self) -> str: self.model.refresh_num_threads() self._dirty_title = False return settings.search_title_format.format( - query=self.q, num_threads=self.model.num_threads + query=self.custom_title or self.q, num_threads=self.model.num_threads ) def next_thread(self, unread: bool=False) -> None: diff --git a/dodo/settings.py b/dodo/settings.py index c112eb2..5d97c3f 100644 --- a/dodo/settings.py +++ b/dodo/settings.py @@ -169,6 +169,14 @@ init_queries = [ 'tag:inbox' ] """List of non closable queries open at startup +Each entry can be a plain query string or a ``(query, title)`` tuple to +set a custom tab title. For example:: + + init_queries = [ + 'tag:inbox', + ('tag:flagged', 'Flagged'), + ] + You can save query with `notmuch config set query:inbox "tag:inbox and not tag:trash"` and use `query:inbox` as a search term. """