Extended filetype support

Added rudimentary support for audio types, text types, spreadsheets, presentations, archives, and programs. These files will now be scanned and picked up when refreshing the library.
This commit is contained in:
Travis Abendshien
2024-04-23 17:10:23 -07:00
parent 5e33d07e39
commit 2e57e0397c
2 changed files with 17 additions and 5 deletions

View File

@@ -39,7 +39,9 @@ ARCHIVE_TYPES: list[str] = ['zip', 'rar', 'tar', 'tar.gz', 'tgz', '7z']
PROGRAM_TYPES: list[str] = ['exe', 'app']
SHORTCUT_TYPES: list[str] = ['lnk', 'desktop']
ALL_FILE_TYPES: list[str] = IMAGE_TYPES + VIDEO_TYPES
ALL_FILE_TYPES: list[str] = IMAGE_TYPES + VIDEO_TYPES + AUDIO_TYPES + \
TEXT_TYPES + SPREADSHEET_TYPES + PRESENTATION_TYPES + \
ARCHIVE_TYPES + PROGRAM_TYPES
BOX_FIELDS = ['tag_box', 'text_box']
TEXT_FIELDS = ['text_line', 'text_box']

View File

@@ -2113,7 +2113,11 @@ class PreviewPanel(QWidget):
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
image = Image.fromarray(frame)
self.dimensions_label.setText(f"{extension.upper()}{humanfriendly.format_size(os.stat(filepath).st_size)}\n{image.width} x {image.height} px")
# Stats for specific file types are displayed here.
if extension in (IMAGE_TYPES + VIDEO_TYPES):
self.dimensions_label.setText(f"{extension.upper()}{humanfriendly.format_size(os.stat(filepath).st_size)}\n{image.width} x {image.height} px")
else:
self.dimensions_label.setText(f"{extension.upper()}")
if not image:
self.dimensions_label.setText(f"{extension.upper()}{humanfriendly.format_size(os.stat(filepath).st_size)}")
@@ -2563,7 +2567,7 @@ class ItemThumb(FlowWidget):
tag_group_icon_128.load()
small_text_style = (
f'background-color:rgba(0, 0, 0, 64);'
f'background-color:rgba(0, 0, 0, 128);'
f'font-family:Oxanium;'
f'font-weight:bold;'
f'font-size:12px;'
@@ -2820,10 +2824,11 @@ class ItemThumb(FlowWidget):
# pass
def set_extension(self, ext: str) -> None:
if ext in VIDEO_TYPES + ['gif', 'apng']:
if ext and ext not in IMAGE_TYPES or ext in ['gif', 'apng']:
self.ext_badge.setHidden(False)
self.ext_badge.setText(ext.upper())
self.count_badge.setHidden(False)
if ext in VIDEO_TYPES + AUDIO_TYPES:
self.count_badge.setHidden(False)
else:
if self.mode == ItemType.ENTRY:
self.ext_badge.setHidden(True)
@@ -3226,6 +3231,11 @@ class ThumbRenderer(QObject):
success, frame = video.read()
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
image = Image.fromarray(frame)
# TODO: Create placeholder thumbnails for non-media files.
# else:
# image: Image.Image = ThumbRenderer.thumb_loading_512.resize(
# (adj_size, adj_size), resample=Image.Resampling.BILINEAR)
if not image:
raise UnidentifiedImageError