Skip to content

Commit

Permalink
Merge pull request #1 from DominicWindisch/collage-images-options
Browse files Browse the repository at this point in the history
unify UI changes branch
  • Loading branch information
DominicWindisch authored Feb 6, 2024
2 parents 8261817 + a48a9b1 commit 5cc9d65
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
10 changes: 10 additions & 0 deletions photobooth/services/config/groups/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
27 changes: 26 additions & 1 deletion photobooth/services/processing/jobmodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down
10 changes: 10 additions & 0 deletions photobooth/services/processingservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5cc9d65

Please sign in to comment.