Skip to content

Commit

Permalink
add handling of mediaitem visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicWindisch committed Feb 7, 2024
1 parent 51de538 commit e1f9872
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions photobooth/services/config/groups/uisettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
)
5 changes: 3 additions & 2 deletions photobooth/services/mediacollectionservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
9 changes: 6 additions & 3 deletions photobooth/services/processingservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit e1f9872

Please sign in to comment.