From 955af412ea73d707c4a0c422b61328ac82f4f283 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby Date: Tue, 6 Feb 2024 15:21:51 +0100 Subject: [PATCH] MainWindow: Make toolbar run launch the lasest solver used and add sc on F6. --- src/View/MainWindow.py | 54 ++++++++++++++++++++++--------------- src/View/ui/SelectSolver.ui | 14 +++++----- 2 files changed, 39 insertions(+), 29 deletions(-) diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py index adc3933d..e2f38dda 100644 --- a/src/View/MainWindow.py +++ b/src/View/MainWindow.py @@ -175,7 +175,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): self.findChild(QAction, action).setEnabled(enable) def setup_sc(self): - # self._run_sc = QShortcut(QKeySequence("F5"), self) + self._run_sc = QShortcut(QKeySequence("F6"), self) return def setup_connection(self): @@ -202,7 +202,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): "action_menu_initial_conditions": self.open_initial_conditions, "action_menu_edit_friction": self.open_frictions, "action_menu_edit_lateral_contribution": self.open_lateral_contrib, - "action_menu_run_solver": self.run_solver, + "action_menu_run_solver": self.select_and_run_solver, "action_menu_sediment_layers": self.open_sediment_layers, "action_menu_edit_reach_sediment_layers": self.open_reach_sediment_layers, @@ -222,7 +222,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): "action_toolBar_open": self.open_model, "action_toolBar_save": self.save_study, "action_toolBar_close": self.close_model, - "action_toolBar_run_solver": self.run_solver, + "action_toolBar_run_solver": self.run_lasest_solver, # Current actions "action_toolBar_network": self.open_network, "action_toolBar_geometry": self.open_geometry, @@ -243,7 +243,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): .triggered.connect(actions[action]) # action.triggered.connect(actions[action]) - # self._run_sc.activated.connect(self.run_solver) + self._run_sc.activated.connect(self.run_lasest_solver) def changeEvent(self, event): if event.type() == QEvent.LanguageChange: @@ -808,7 +808,13 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): ) sl.show() - def run_solver(self): + def run_lasest_solver(self): + if self._last_solver is None: + return + + self.run_solver(self._last_solver) + + def select_and_run_solver(self): if self._study is None: return @@ -818,25 +824,29 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): parent=self ) if run.exec(): - solver = run.solver + self.run_solver(run.solver) - if self.sub_window_exists( - CheckListWindow, - data=[ - self._study, - self.conf, - solver - ] - ): - return + def run_solver(self, solver): + if self._study is None: + return - check = CheckListWindow( - study=self._study, - config=self.conf, - solver=solver, - parent=self - ) - check.show() + if self.sub_window_exists( + CheckListWindow, + data=[ + self._study, + self.conf, + solver + ] + ): + return + + check = CheckListWindow( + study=self._study, + config=self.conf, + solver=solver, + parent=self + ) + check.show() def solver_log(self, solver): sol = SolverLogWindow( diff --git a/src/View/ui/SelectSolver.ui b/src/View/ui/SelectSolver.ui index c621bdd4..7d5bd578 100644 --- a/src/View/ui/SelectSolver.ui +++ b/src/View/ui/SelectSolver.ui @@ -35,13 +35,6 @@ - - - - Cancel - - - @@ -53,6 +46,13 @@ + + + + Cancel + + +