From 83d53a46fbf127446f3018cd7f36ff7b2ecfcda7 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr> Date: Tue, 13 Feb 2024 11:25:53 +0100 Subject: [PATCH] Pamhyr: Add windows list recursively. --- src/View/MainWindow.py | 37 +++++++++++++++++++++---------- src/View/Tools/ListedSubWindow.py | 5 ++++- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py index d1af514b..075f26c5 100644 --- a/src/View/MainWindow.py +++ b/src/View/MainWindow.py @@ -586,21 +586,34 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): # Remove all actions menu.clear() + self._do_update_window_list_add_action(menu, self.sub_win_list) + + def _do_update_window_list_add_action(self, menu, win_list): + for _, win in win_list: + self._do_update_window_list_add_action_for_window( + menu, win + ) + + try: + lst = win.sub_win_list + self._do_update_window_list_add_action(menu, lst) + except Exception: + continue + + def _do_update_window_list_add_action_for_window(self, menu, window): def lambda_generator(h): return lambda: self._activate_window(h) - # Add window action - for _, win in self.sub_win_list: - action = QAction(win._title, self) - # action.setStatusTip( - # _translate("MainWindow", "Activate this window") - # ) - h = win.hash() - logger.info(f"Get hash: {h}") - fn = lambda_generator(h) - action.triggered.connect(fn) - - menu.addAction(action) + action = QAction(window._title, self) + # action.setStatusTip( + # _translate("MainWindowdow", "Activate this windowdow") + # ) + h = window.hash() + logger.info(f"Get hash: {h}") + fn = lambda_generator(h) + action.triggered.connect(fn) + + menu.addAction(action) def open_configure(self): """Open configure window diff --git a/src/View/Tools/ListedSubWindow.py b/src/View/Tools/ListedSubWindow.py index 96c4e64b..dad36234 100644 --- a/src/View/Tools/ListedSubWindow.py +++ b/src/View/Tools/ListedSubWindow.py @@ -108,4 +108,7 @@ class ListedSubWindow(object): return False def _update_window_list(self): - return + try: + self._parent._update_window_list() + except Exception: + return -- GitLab