diff --git a/mantidimaging/gui/windows/live_viewer/model.py b/mantidimaging/gui/windows/live_viewer/model.py index 9d41dfd01d0..44b5400eb38 100644 --- a/mantidimaging/gui/windows/live_viewer/model.py +++ b/mantidimaging/gui/windows/live_viewer/model.py @@ -100,7 +100,6 @@ def path(self, path: Path) -> None: self._dataset_path = path self.image_watcher = ImageWatcher(path) self.image_watcher.image_changed.connect(self._handle_image_changed_in_list) - self.image_watcher.find_images() def _handle_image_changed_in_list(self, image_files: list[Image_Data]) -> None: """ @@ -113,6 +112,15 @@ def _handle_image_changed_in_list(self, image_files: list[Image_Data]) -> None: self.images = image_files self.presenter.update_image_list(image_files) + def get_images(self) -> None: + """ + Trigger the image watcher to find images in the directory + in case images are already present. + """ + if self.image_watcher: + image_files = self.image_watcher.find_images() + self._handle_image_changed_in_list(image_files) + class ImageWatcher(QObject): """ diff --git a/mantidimaging/gui/windows/live_viewer/view.py b/mantidimaging/gui/windows/live_viewer/view.py index aec0de7237e..6d530177223 100644 --- a/mantidimaging/gui/windows/live_viewer/view.py +++ b/mantidimaging/gui/windows/live_viewer/view.py @@ -37,6 +37,7 @@ def __init__(self, main_window: 'MainWindowView', live_dir_path: Path) -> None: self.move(self.main_window.x() + self.main_window.width(), self.main_window.y()) self.live_viewer.z_slider.valueChanged.connect(self.presenter.select_image) + self.presenter.model.get_images() def show_most_recent_image(self, image: np.ndarray) -> None: """ @@ -49,6 +50,10 @@ def watch_directory(self) -> None: """Show the most recent image arrived in the selected directory""" self.presenter.set_dataset_path(self.path) + def load_exisitng_images(self) -> None: + """Load the existing images in the selected directory if present""" + self.presenter.model.get_images() + def remove_image(self) -> None: """Remove the image from the view.""" self.live_viewer.handle_deleted()