diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py
index 001bf4c8..d1af514b 100644
--- a/src/View/MainWindow.py
+++ b/src/View/MainWindow.py
@@ -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
diff --git a/src/View/Tools/ListedSubWindow.py b/src/View/Tools/ListedSubWindow.py
index 4c53590f..96c4e64b 100644
--- a/src/View/Tools/ListedSubWindow.py
+++ b/src/View/Tools/ListedSubWindow.py
@@ -39,6 +39,9 @@ class ListedSubWindow(object):
def sub_win_add(self, name, win):
self._sub_win_list.append((name, win))
self._sub_win_cnt += 1
+
+ self._update_window_list()
+
try:
logger.info(
f"Open window: {name}: {self._sub_win_cnt}")
@@ -54,6 +57,8 @@ class ListedSubWindow(object):
)
)
self._sub_win_cnt = len(self._sub_win_list)
+ self._update_window_list()
+
logger.info(f"Close window: ({h}) {self._sub_win_cnt}")
def _sub_win_exists(self, h):
@@ -78,8 +83,7 @@ class ListedSubWindow(object):
except Exception:
return None
- def sub_window_exists(self, cls,
- data=None):
+ def sub_window_exists(self, cls, data=None):
"""Check if window already exists
Check if window already exists, used to deni window open
@@ -97,7 +101,11 @@ class ListedSubWindow(object):
hash = cls._hash(data)
if self._sub_win_exists(hash):
win = self.get_sub_win(hash)
+ logger.debug(f"subwindow: {hash} -> {win} ({win.hash()})")
win.activateWindow()
return True
else:
return False
+
+ def _update_window_list(self):
+ return
diff --git a/src/View/ui/MainWindow.ui b/src/View/ui/MainWindow.ui
index dfe37a80..0e47519f 100644
--- a/src/View/ui/MainWindow.ui
+++ b/src/View/ui/MainWindow.ui
@@ -12,8 +12,8 @@
0
0
- 850
- 646
+ 1280
+ 720
@@ -65,7 +65,7 @@
0
0
- 850
+ 1280
23
@@ -179,6 +179,14 @@
+
@@ -187,6 +195,7 @@
+
@@ -263,10 +272,7 @@
New study
-
- 50
- false
-
+
Ctrl+N