From e1f98727c509a1d6a6aba761dd46e4b1be028960 Mon Sep 17 00:00:00 2001 From: Dominic Windisch Date: Wed, 7 Feb 2024 09:14:27 +0100 Subject: [PATCH] add handling of mediaitem visibility --- photobooth/services/config/groups/uisettings.py | 4 ++++ photobooth/services/mediacollectionservice.py | 5 +++-- photobooth/services/processingservice.py | 9 ++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/photobooth/services/config/groups/uisettings.py b/photobooth/services/config/groups/uisettings.py index 89d52636..ecfeca56 100644 --- a/photobooth/services/config/groups/uisettings.py +++ b/photobooth/services/config/groups/uisettings.py @@ -86,3 +86,7 @@ class GroupUiSettings(BaseModel): default=True, description="Show print button for items in gallery.", ) + gallery_show_collage_images: bool = Field( + default=False, + description="Show images used for the collage in the gallery.", + ) diff --git a/photobooth/services/mediacollectionservice.py b/photobooth/services/mediacollectionservice.py index 88fb359e..dbfa2f7e 100644 --- a/photobooth/services/mediacollectionservice.py +++ b/photobooth/services/mediacollectionservice.py @@ -112,7 +112,7 @@ def db_get_images_as_dict(self) -> list: list: _description_ """ tms = time.time() - out = [item.asdict() for item in self._db] + out = [item.asdict() for item in self._db if item.visible] logger.debug(f"-- process time: {round((time.time() - tms), 2)}s to compile db_get_images_as_dict output") return out @@ -123,7 +123,8 @@ def db_get_images(self) -> list[MediaItem]: Returns: list: _description_ """ - return self._db + out = [item for item in self._db if item.visible] + return out def db_get_most_recent_mediaitem(self): # get most recent item diff --git a/photobooth/services/processingservice.py b/photobooth/services/processingservice.py index e5e0cf29..3df08b6a 100644 --- a/photobooth/services/processingservice.py +++ b/photobooth/services/processingservice.py @@ -187,14 +187,16 @@ def on_enter_capture(self): # depending on job type we have slightly different filenames so it can be distinguished in the UI later. # 1st phase is about capture, so always image - but distinguish between other types so UI can handle different later _type = MediaItemTypes.image + _visibility = True if self.model._typ is JobModel.Typ.collage: _type = MediaItemTypes.collageimage # 1st phase collage image + _visibility = appconfig.uisettings.gallery_show_collage_images if self.model._typ is JobModel.Typ.animation: _type = MediaItemTypes.animationimage # 1st phase collage image if self.model._typ is JobModel.Typ.video: raise RuntimeError("videos are not processed in capture state") - filepath_neworiginalfile = get_new_filename(type=_type) + filepath_neworiginalfile = get_new_filename(type=_type, visibility=_visibility) logger.debug(f"capture to {filepath_neworiginalfile=}") try: @@ -387,8 +389,9 @@ def on_exit_captures_completed(self): logger.info("exit job postprocess, adding items to db") for item in self.model._confirmed_captures_collection: - logger.debug(f"adding {item} to collection") - _ = self._mediacollection_service.db_add_item(item) + if item.visible: + logger.debug(f"adding {item} to collection") + _ = self._mediacollection_service.db_add_item(item) def on_enter_present_capture(self): self._finalize()