mirror of https://gitlab.com/pamhyr/pamhyr2
Geometry: Forbidden duplicate window.
parent
ec16586755
commit
ec9a061f9a
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue