From 7ca6e695262724a028ae768a8d4ef8fdb3a3847e Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby Date: Fri, 31 Oct 2025 14:43:01 +0100 Subject: [PATCH] Pamhyr2: Add save action (ctrl+s) in each pamhyr window. --- src/View/MainWindow.py | 11 +++++++++-- src/View/Tools/PamhyrWindow.py | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py index e63954ec..cf2c4add 100644 --- a/src/View/MainWindow.py +++ b/src/View/MainWindow.py @@ -637,7 +637,10 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): logger.info(f"Open Study - {self._study.name}") self.set_title() - def save_study(self): + def _save(self, source): + self.save_study(progress_parent=source) + + def save_study(self, progress_parent=None): """Save current study Save current study, if study as no associate file, open a @@ -667,11 +670,15 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): self._backup_timer.blockSignals(True) self._save_mutex.lock() + parent = self + if progress_parent is not None: + parent = progress_parent + sql_request_count = self._study.sql_save_request_count() progress = QProgressDialog( "Saving...", None, 0, sql_request_count, - parent=self + parent=parent ) progress.setWindowModality(Qt.WindowModal) progress.setValue(0) diff --git a/src/View/Tools/PamhyrWindow.py b/src/View/Tools/PamhyrWindow.py index 321c2864..ffa0e90f 100644 --- a/src/View/Tools/PamhyrWindow.py +++ b/src/View/Tools/PamhyrWindow.py @@ -182,6 +182,7 @@ class PamhyrWindow(ASubMainWindow, ListedSubWindow, PamhyrWindowTools): self._set_title() self._set_icon() + self._setup_save_sc() def _set_title(self): title = self._title @@ -196,12 +197,25 @@ class PamhyrWindow(ASubMainWindow, ListedSubWindow, PamhyrWindowTools): self.ui.setWindowTitle(title) + def _setup_save_sc(self): + if self._parent is None: + return + + self._save_sc = QShortcut(QKeySequence("Ctrl+S"), self) + self._save_sc.activated.connect(lambda: self._save(self)) + def closeEvent(self, event): self._close_sub_window() self._propagate_update(Modules.WINDOW_LIST) super(PamhyrWindow, self).closeEvent(event) + def _save(self, source): + if self._parent is None: + return + + return self._parent._save(source) + class PamhyrDialog(ASubWindow, ListedSubWindow, PamhyrWindowTools): _pamhyr_ui = "dummy"