diff --git a/src/View/Geometry/Profile/Window.py b/src/View/Geometry/Profile/Window.py index 9f7df09031865de801b054da8cf0022dd3c0b782..54d1e0111bb39fa10a4f1045065c3976b9c248c2 100644 --- a/src/View/Geometry/Profile/Window.py +++ b/src/View/Geometry/Profile/Window.py @@ -86,12 +86,14 @@ class ProfileWindow(ASubMainWindow): if (name is None) or (name == ""): name = _translate("MainWindowProfile", "(no name)") - self.setWindowTitle( + self._title = ( header + " - " + f"{self._profile.reach.name}" + " - " + f"{name} ({self._profile.kp})" ) + self.setWindowTitle(self._title) + def setup_sc(self): self._undo_stack = QUndoStack() diff --git a/src/View/Geometry/Window.py b/src/View/Geometry/Window.py index 46e339f6ef8712ffae4c86384fc9730c6b58bbd3..851b73bb69b7dfa6fecc62e5bfa6967984e3a79f 100644 --- a/src/View/Geometry/Window.py +++ b/src/View/Geometry/Window.py @@ -80,7 +80,8 @@ class GeometryWindow(ASubMainWindow, ListedSubWindow): self.changed_slider_value() def setup_window(self): - self.setWindowTitle(f"{self.ui.mainwindow_title} - {self._reach.name}") + self._title = f"{self.ui.mainwindow_title} - {self._reach.name}" + self.setWindowTitle(self._title) def setup_sc(self): self._undo_stack = QUndoStack() diff --git a/src/View/ListedSubWindow.py b/src/View/ListedSubWindow.py index eaef39ef6cbb2a77c6bbaed8e97240c5a6f47db6..b44efd613012bde5dc2edc0971fe3376009ad3c4 100644 --- a/src/View/ListedSubWindow.py +++ b/src/View/ListedSubWindow.py @@ -62,7 +62,7 @@ class ListedSubWindow(object): ( (n[0] == name) and reduce( - lambda acc, a: acc and (a in n[1]._title), + lambda acc, c: acc and (c in n[1]._title), contain, True ) @@ -74,6 +74,24 @@ class ListedSubWindow(object): def sub_win_exists(self, name, contain = []): if contain == []: - self._sub_win_exists(name) + return self._sub_win_exists(name) else: - self._sub_win_exists_with_contain(name, contain) + return self._sub_win_exists_with_contain(name, contain) + + def sub_win_filter_first(self, name, contain): + try: + return next( + filter( + lambda n: ( + (n[0] == name) and + reduce( + lambda acc, c: acc and (c in n[1]._title), + contain, + True + ) + ), + self.sub_win_list, + ) + )[1] + except: + return None diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py index 8a94c469586cbab810ec1daa3abe9e686fd263e4..7b03dfb7231b744a5969c44d7522d42a60358b93 100644 --- a/src/View/MainWindow.py +++ b/src/View/MainWindow.py @@ -455,10 +455,17 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): Returns: Nothing """ - if (self.model is not None and - self.model.river.has_current_reach()): - geometry = GeometryWindow(model=self.model, parent=self) - geometry.show() + if (self.model is not None and self.model.river.has_current_reach()): + geometry = self.sub_win_filter_first( + "Geometry", + contain = [self.model.river.current_reach().name] + ) + + if geometry == None: + geometry = GeometryWindow(model=self.model, parent=self) + geometry.show() + else: + geometry.activateWindow() else: self.msg_select_reach()