MainWindow: Add windows menu with list of windows (depth 1).

This commit is contained in:
Pierre-Antoine Rouby committed 2024-02-13 11:12:25 +01:00
1 parent e96e291ec4
commit a8c8e14d6a
3 files changed
+57 -9

No files matched your search

+34
View File
@@ -341,6 +341,10 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
def _do_propagate_update(self):
for key in self._propagation_keys:
if key == "window_list":
self._do_update_window_list()
continue
logger.debug(f"Propagation of {key}")
for _, window in self.sub_win_list:
window._propagated_update(key=key)
@@ -568,6 +572,36 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
# SUBWINDOW #
#############
def _activate_window(self, window_hash):
window = self.get_sub_win(window_hash)
if window is not None:
window.activateWindow()
def _update_window_list(self):
self._propagation_keys.add("window_list")
def _do_update_window_list(self):
menu = self.findChild(QMenu, "menu_windows")
# Remove all actions
menu.clear()
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)
def open_configure(self):
"""Open configure window