From a48a9b117b6220f4b472914227c225b44ced96c7 Mon Sep 17 00:00:00 2001 From: Dominic Windisch Date: Tue, 6 Feb 2024 13:30:08 +0100 Subject: [PATCH] add option to hide/delete images of a collage --- photobooth/services/config/groups/common.py | 10 ++++++++ photobooth/services/processing/jobmodels.py | 27 ++++++++++++++++++++- photobooth/services/processingservice.py | 10 ++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/photobooth/services/config/groups/common.py b/photobooth/services/config/groups/common.py index 56b27154..1b8e90e8 100644 --- a/photobooth/services/config/groups/common.py +++ b/photobooth/services/config/groups/common.py @@ -47,6 +47,16 @@ class GroupCommon(BaseModel): description="Automatically continue with second and following images to capture for collage. No user interaction in between.", ) + collage_hide_individual_pictures: bool = Field( + default=True, + description="Hide the individual pictures of a collage. They will still be accessibly in the unprocessed images folder.", + ) + + collage_delete_individual_pictures: bool = Field( + default=False, + description="Delete the individual pictures of a collage. They will not be accessibly in the unprocessed images folder.", + ) + DEBUG_LEVEL: EnumDebugLevel = Field( title="Debug Level", default=EnumDebugLevel.DEBUG, diff --git a/photobooth/services/processing/jobmodels.py b/photobooth/services/processing/jobmodels.py index 48718289..9f4c1000 100644 --- a/photobooth/services/processing/jobmodels.py +++ b/photobooth/services/processing/jobmodels.py @@ -84,6 +84,8 @@ def __init__(self): # job metadata processing ui interaction self._collage_automatic_capture_continue = False + self._collage_delete_individual_pictures = False + self._collage_hide_individual_pictures = False # job model timer self._duration_user: float = 0 @@ -181,14 +183,37 @@ def jobtype_recording(self) -> bool: else: return False + def hide_individual_images(self) -> bool: + # hide individual images of a collage (inherintly true when deleting them) + if self._typ is JobModel.Typ.collage and (self._collage_hide_individual_pictures | self._collage_delete_individual_pictures): + return True + else: + return False + + def delete_individual_images(self) -> bool: + # delete individual images of a collage after processing + if self._typ is JobModel.Typ.collage and self._collage_delete_individual_pictures: + return True + else: + return False + # external model start/stop controls - def start_model(self, typ: Typ, total_captures_to_take: int, collage_automatic_capture_continue: bool = False): + def start_model( + self, + typ: Typ, + total_captures_to_take: int, + collage_automatic_capture_continue: bool = False, + collage_hide_individual_pictures: bool = False, + collage_delete_individual_pictures: bool = False, + ): self.reset_job() self._typ = typ self._total_captures_to_take = total_captures_to_take self._last_captured_mediaitem = None self._confirmed_captures_collection = [] self._collage_automatic_capture_continue = collage_automatic_capture_continue + self._collage_hide_individual_pictures = collage_hide_individual_pictures + self._collage_delete_individual_pictures = collage_delete_individual_pictures self._validate_job() diff --git a/photobooth/services/processingservice.py b/photobooth/services/processingservice.py index e5e0cf29..ce5504cb 100644 --- a/photobooth/services/processingservice.py +++ b/photobooth/services/processingservice.py @@ -89,6 +89,8 @@ def before_start(self, typ: JobModel.Typ, total_captures_to_take: int): typ, total_captures_to_take, collage_automatic_capture_continue=appconfig.common.collage_automatic_capture_continue, + collage_hide_individual_pictures=appconfig.common.collage_hide_individual_pictures, + collage_delete_individual_pictures=appconfig.common.collage_delete_individual_pictures, ) logger.info(f"start job {self.model}") @@ -330,6 +332,14 @@ def on_enter_captures_completed(self): logger.info(f"-- process time: {round((time.time() - tms), 2)}s to create collage") + # (optionally) hide individual images from gallery + if self.model.hide_individual_images(): + while len(self.model._confirmed_captures_collection) > 0: + delete_mediaitem = self.model._confirmed_captures_collection.pop() + # (optionally) delete individual images + if self.model.delete_individual_images(): + self._mediacollection_service.delete_mediaitem_files(delete_mediaitem) + # resulting collage mediaitem will be added to the collection as most recent item self.model.add_confirmed_capture_to_collection(mediaitem) self.model.set_last_capture(mediaitem) # set last item also to collage, so UI can rely on last capture being the one to present