From d527e8e3c24de82858a5ef74a25d80d74c0cab8e Mon Sep 17 00:00:00 2001 From: Travis Abendshien <46939827+CyanVoxel@users.noreply.github.com> Date: Tue, 10 Dec 2024 00:55:18 -0800 Subject: [PATCH 1/9] feat(ui): add filename label under thumbnails --- tagstudio/src/qt/widgets/item_thumb.py | 34 ++++++++++++++++++---- tagstudio/src/qt/widgets/thumb_renderer.py | 11 +++++-- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/tagstudio/src/qt/widgets/item_thumb.py b/tagstudio/src/qt/widgets/item_thumb.py index 07bf4862f..57ffd2ad3 100644 --- a/tagstudio/src/qt/widgets/item_thumb.py +++ b/tagstudio/src/qt/widgets/item_thumb.py @@ -110,6 +110,8 @@ class ItemThumb(FlowWidget): "padding-left: 1px;" ) + filename_style = "font-size:10px;" + def __init__( self, mode: ItemType, @@ -125,9 +127,17 @@ def __init__( self.driver = driver self.item_id: int | None = None self.thumb_size: tuple[int, int] = thumb_size - self.setMinimumSize(*thumb_size) - self.setMaximumSize(*thumb_size) + label_height = 16 + label_spacing = 3 check_size = 24 + self.setMinimumSize(thumb_size[0], thumb_size[1] + label_height + label_spacing) + self.setMaximumSize(thumb_size[0], thumb_size[1] + label_height + label_spacing) + + self.thumb_container = QWidget() + self.real_base_layout = QVBoxLayout(self) + self.real_base_layout.setContentsMargins(0, 0, 0, 0) + self.real_base_layout.setSpacing(label_spacing) + self.setLayout(self.real_base_layout) # +----------+ # | ARC FAV| Top Right: Favorite & Archived Badges @@ -135,6 +145,8 @@ def __init__( # | | # |EXT #| Lower Left: File Type, Tag Group Icon, or Collation Icon # +----------+ Lower Right: Collation Count, Video Length, or Word Count + # + # Filename Underneath: (Optional) Filename # Thumbnail ============================================================ @@ -144,7 +156,7 @@ def __init__( # || || # |*--------*| # +----------+ - self.base_layout = QVBoxLayout(self) + self.base_layout = QVBoxLayout(self.thumb_container) self.base_layout.setObjectName("baseLayout") self.base_layout.setContentsMargins(0, 0, 0, 0) @@ -182,12 +194,13 @@ def __init__( self.bottom_container.setLayout(self.bottom_layout) self.base_layout.addWidget(self.bottom_container) - self.thumb_button = ThumbButton(self, thumb_size) + self.thumb_button = ThumbButton(self.thumb_container, thumb_size) self.renderer = ThumbRenderer() self.renderer.updated.connect( - lambda ts, i, s, ext: ( + lambda ts, i, s, fn, ext: ( self.update_thumb(ts, image=i), self.update_size(ts, size=s), + self.update_filename(fn), self.set_extension(ext), ) ) @@ -284,6 +297,14 @@ def __init__( self.badges[badge_type] = badge self.cb_layout.addWidget(badge) + # Filename Label ======================================================= + self.file_label = QLabel(text="Filename") + self.file_label.setStyleSheet(ItemThumb.filename_style) + self.file_label.setMaximumHeight(label_height) + + self.real_base_layout.addWidget(self.thumb_container) + self.real_base_layout.addWidget(self.file_label) + self.set_mode(mode) @property @@ -365,6 +386,9 @@ def set_count(self, count: str) -> None: self.ext_badge.setHidden(True) self.count_badge.setHidden(True) + def update_filename(self, filename: Path | str | None): + self.file_label.setText(str(filename)) + def update_thumb(self, timestamp: float, image: QPixmap | None = None): """Update attributes of a thumbnail element.""" if timestamp > ItemThumb.update_cutoff: diff --git a/tagstudio/src/qt/widgets/thumb_renderer.py b/tagstudio/src/qt/widgets/thumb_renderer.py index ac0abb962..b17f519ad 100644 --- a/tagstudio/src/qt/widgets/thumb_renderer.py +++ b/tagstudio/src/qt/widgets/thumb_renderer.py @@ -72,7 +72,7 @@ class ThumbRenderer(QObject): """A class for rendering image and file thumbnails.""" rm: ResourceManager = ResourceManager() - updated = Signal(float, QPixmap, QSize, str) + updated = Signal(float, QPixmap, QSize, str, str) updated_ratio = Signal(float) def __init__(self) -> None: @@ -1208,8 +1208,15 @@ def render_unlinked() -> Image.Image: math.ceil(adj_size / pixel_ratio), math.ceil(final.size[1] / pixel_ratio), ), + str(_filepath.name), _filepath.suffix.lower(), ) else: - self.updated.emit(timestamp, QPixmap(), QSize(*base_size), _filepath.suffix.lower()) + self.updated.emit( + timestamp, + QPixmap(), + QSize(*base_size), + str(_filepath.name), + _filepath.suffix.lower(), + ) From 723dfbd773d6106441a2703ff16a13796b349d6f Mon Sep 17 00:00:00 2001 From: Travis Abendshien <46939827+CyanVoxel@users.noreply.github.com> Date: Tue, 10 Dec 2024 01:06:50 -0800 Subject: [PATCH 2/9] refactor(ui): organize menu items --- tagstudio/src/qt/ts_qt.py | 54 ++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/tagstudio/src/qt/ts_qt.py b/tagstudio/src/qt/ts_qt.py index 4e3cfaed4..c3f2bc228 100644 --- a/tagstudio/src/qt/ts_qt.py +++ b/tagstudio/src/qt/ts_qt.py @@ -269,9 +269,9 @@ def start(self) -> None: file_menu = QMenu("&File", menu_bar) edit_menu = QMenu("&Edit", menu_bar) + view_menu = QMenu("&View", menu_bar) tools_menu = QMenu("&Tools", menu_bar) macros_menu = QMenu("&Macros", menu_bar) - window_menu = QMenu("&Window", menu_bar) help_menu = QMenu("&Help", menu_bar) # File Menu ============================================================ @@ -327,6 +327,17 @@ def start(self) -> None: close_library_action = QAction("&Close Library", menu_bar) close_library_action.triggered.connect(self.close_library) file_menu.addAction(close_library_action) + file_menu.addSeparator() + + open_on_start_action = QAction("Open Library on Start", self) + open_on_start_action.setCheckable(True) + open_on_start_action.setChecked( + bool(self.settings.value(SettingItems.START_LOAD_LAST, defaultValue=True, type=bool)) + ) + open_on_start_action.triggered.connect( + lambda checked: self.settings.setValue(SettingItems.START_LOAD_LAST, checked) + ) + file_menu.addAction(open_on_start_action) # Edit Menu ============================================================ new_tag_action = QAction("New &Tag", menu_bar) @@ -369,15 +380,29 @@ def start(self) -> None: tag_database_action.triggered.connect(lambda: self.show_tag_database()) edit_menu.addAction(tag_database_action) - check_action = QAction("Open library on start", self) - check_action.setCheckable(True) - check_action.setChecked( + # View Menu ============================================================ + open_on_start_action = QAction("Open Library on Start", self) + open_on_start_action.setCheckable(True) + open_on_start_action.setChecked( bool(self.settings.value(SettingItems.START_LOAD_LAST, defaultValue=True, type=bool)) ) - check_action.triggered.connect( + open_on_start_action.triggered.connect( lambda checked: self.settings.setValue(SettingItems.START_LOAD_LAST, checked) ) - window_menu.addAction(check_action) + view_menu.addAction(open_on_start_action) + + show_libs_list_action = QAction("Show Recent Libraries", menu_bar) + show_libs_list_action.setCheckable(True) + show_libs_list_action.setChecked( + bool(self.settings.value(SettingItems.WINDOW_SHOW_LIBS, defaultValue=True, type=bool)) + ) + show_libs_list_action.triggered.connect( + lambda checked: ( + self.settings.setValue(SettingItems.WINDOW_SHOW_LIBS, checked), + self.toggle_libs_list(checked), + ) + ) + view_menu.addAction(show_libs_list_action) # Tools Menu =========================================================== def create_fix_unlinked_entries_modal(): @@ -412,19 +437,6 @@ def create_dupe_files_modal(): ) macros_menu.addAction(self.autofill_action) - show_libs_list_action = QAction("Show Recent Libraries", menu_bar) - show_libs_list_action.setCheckable(True) - show_libs_list_action.setChecked( - bool(self.settings.value(SettingItems.WINDOW_SHOW_LIBS, defaultValue=True, type=bool)) - ) - show_libs_list_action.triggered.connect( - lambda checked: ( - self.settings.setValue(SettingItems.WINDOW_SHOW_LIBS, checked), - self.toggle_libs_list(checked), - ) - ) - window_menu.addAction(show_libs_list_action) - def create_folders_tags_modal(): if not hasattr(self, "folders_modal"): self.folders_modal = FoldersToTagsModal(self.lib, self) @@ -434,7 +446,7 @@ def create_folders_tags_modal(): folders_to_tags_action.triggered.connect(create_folders_tags_modal) macros_menu.addAction(folders_to_tags_action) - # Help Menu ========================================================== + # Help Menu ============================================================ self.repo_action = QAction("Visit GitHub Repository", menu_bar) self.repo_action.triggered.connect( lambda: webbrowser.open("https://github.com/TagStudioDev/TagStudio") @@ -444,9 +456,9 @@ def create_folders_tags_modal(): menu_bar.addMenu(file_menu) menu_bar.addMenu(edit_menu) + menu_bar.addMenu(view_menu) menu_bar.addMenu(tools_menu) menu_bar.addMenu(macros_menu) - menu_bar.addMenu(window_menu) menu_bar.addMenu(help_menu) self.main_window.searchField.textChanged.connect(self.update_completions_list) From a93809df63223db3d4abeecb635ad2ab51bb15ca Mon Sep 17 00:00:00 2001 From: Travis Abendshien <46939827+CyanVoxel@users.noreply.github.com> Date: Tue, 10 Dec 2024 13:07:42 -0800 Subject: [PATCH 3/9] feat: make thumbnail filenames toggleable --- tagstudio/src/core/enums.py | 1 + tagstudio/src/qt/ts_qt.py | 40 ++++++++++----- tagstudio/src/qt/widgets/item_thumb.py | 47 ++++++++++++++---- .../.TagStudio/ts_library.sqlite | Bin 86016 -> 86016 bytes 4 files changed, 66 insertions(+), 22 deletions(-) diff --git a/tagstudio/src/core/enums.py b/tagstudio/src/core/enums.py index d4a9aa3d9..416e8c645 100644 --- a/tagstudio/src/core/enums.py +++ b/tagstudio/src/core/enums.py @@ -10,6 +10,7 @@ class SettingItems(str, enum.Enum): LAST_LIBRARY = "last_library" LIBS_LIST = "libs_list" WINDOW_SHOW_LIBS = "window_show_libs" + SHOW_FILENAMES = "show_filenames" AUTOPLAY = "autoplay_videos" diff --git a/tagstudio/src/qt/ts_qt.py b/tagstudio/src/qt/ts_qt.py index c3f2bc228..0591d8aa1 100644 --- a/tagstudio/src/qt/ts_qt.py +++ b/tagstudio/src/qt/ts_qt.py @@ -25,15 +25,7 @@ import structlog from humanfriendly import format_timespan from PySide6 import QtCore -from PySide6.QtCore import ( - QObject, - QSettings, - Qt, - QThread, - QThreadPool, - QTimer, - Signal, -) +from PySide6.QtCore import QObject, QSettings, Qt, QThread, QThreadPool, QTimer, Signal from PySide6.QtGui import ( QAction, QColor, @@ -404,6 +396,19 @@ def start(self) -> None: ) view_menu.addAction(show_libs_list_action) + show_filenames_action = QAction("Show Filenames in Grid", menu_bar) + show_filenames_action.setCheckable(True) + show_filenames_action.setChecked( + bool(self.settings.value(SettingItems.SHOW_FILENAMES, defaultValue=True, type=bool)) + ) + show_filenames_action.triggered.connect( + lambda checked: ( + self.settings.setValue(SettingItems.SHOW_FILENAMES, checked), + self.toggle_grid_filenames(checked), + ) + ) + view_menu.addAction(show_filenames_action) + # Tools Menu =========================================================== def create_fix_unlinked_entries_modal(): if not hasattr(self, "unlinked_modal"): @@ -568,6 +573,10 @@ def toggle_libs_list(self, value: bool): self.preview_panel.libs_flow_container.hide() self.preview_panel.update() + def toggle_grid_filenames(self, value: bool): + for thumb in self.item_thumbs: + thumb.toggle_filename(value) + def callback_library_needed_check(self, func): """Check if loaded library has valid path before executing the button function.""" if self.lib.library_dir: @@ -865,9 +874,9 @@ def thumb_size_callback(self, index: int): it.thumb_button.setIcon(blank_icon) it.resize(self.thumb_size, self.thumb_size) it.thumb_size = (self.thumb_size, self.thumb_size) - it.setMinimumSize(self.thumb_size, self.thumb_size) - it.setMaximumSize(self.thumb_size, self.thumb_size) + it.setFixedSize(self.thumb_size, self.thumb_size) it.thumb_button.thumb_size = (self.thumb_size, self.thumb_size) + it.toggle_filename(it.show_filename_label) self.flow_container.layout().setSpacing( min(self.thumb_size // spacing_divisor, min_spacing) ) @@ -915,7 +924,14 @@ def _init_thumb_grid(self): # TODO - init after library is loaded, it can have different page_size for grid_idx in range(self.filter.page_size): item_thumb = ItemThumb( - None, self.lib, self, (self.thumb_size, self.thumb_size), grid_idx + None, + self.lib, + self, + (self.thumb_size, self.thumb_size), + grid_idx, + bool( + self.settings.value(SettingItems.SHOW_FILENAMES, defaultValue=True, type=bool) + ), ) layout.addWidget(item_thumb) self.item_thumbs.append(item_thumb) diff --git a/tagstudio/src/qt/widgets/item_thumb.py b/tagstudio/src/qt/widgets/item_thumb.py index 57ffd2ad3..68f210816 100644 --- a/tagstudio/src/qt/widgets/item_thumb.py +++ b/tagstudio/src/qt/widgets/item_thumb.py @@ -119,6 +119,7 @@ def __init__( driver: "QtDriver", thumb_size: tuple[int, int], grid_idx: int, + show_filename_label: bool = False, ): super().__init__() self.grid_idx = grid_idx @@ -127,16 +128,19 @@ def __init__( self.driver = driver self.item_id: int | None = None self.thumb_size: tuple[int, int] = thumb_size - label_height = 16 - label_spacing = 3 + self.show_filename_label: bool = show_filename_label + self.label_height = 16 + self.label_spacing = 3 check_size = 24 - self.setMinimumSize(thumb_size[0], thumb_size[1] + label_height + label_spacing) - self.setMaximumSize(thumb_size[0], thumb_size[1] + label_height + label_spacing) + self.setFixedSize( + thumb_size[0], + thumb_size[1] + + ((self.label_height + self.label_spacing) if show_filename_label else 0), + ) self.thumb_container = QWidget() self.real_base_layout = QVBoxLayout(self) self.real_base_layout.setContentsMargins(0, 0, 0, 0) - self.real_base_layout.setSpacing(label_spacing) self.setLayout(self.real_base_layout) # +----------+ @@ -200,7 +204,7 @@ def __init__( lambda ts, i, s, fn, ext: ( self.update_thumb(ts, image=i), self.update_size(ts, size=s), - self.update_filename(fn), + self.set_filename(fn), self.set_extension(ext), ) ) @@ -300,7 +304,8 @@ def __init__( # Filename Label ======================================================= self.file_label = QLabel(text="Filename") self.file_label.setStyleSheet(ItemThumb.filename_style) - self.file_label.setMaximumHeight(label_height) + self.file_label.setFixedHeight(12) + self.file_label.setHidden(not show_filename_label) self.real_base_layout.addWidget(self.thumb_container) self.real_base_layout.addWidget(self.file_label) @@ -386,17 +391,39 @@ def set_count(self, count: str) -> None: self.ext_badge.setHidden(True) self.count_badge.setHidden(True) - def update_filename(self, filename: Path | str | None): + def set_filename(self, filename: Path | str | None): self.file_label.setText(str(filename)) + def toggle_filename(self, value: bool): + """Toggle the visibility of the filename label. + + Args: + value (bool): Show the filename, true or false. + """ + if value: + self.file_label.setHidden(False) + self.setFixedHeight(self.thumb_size[1] + self.label_height + self.label_spacing) + else: + self.file_label.setHidden(True) + self.setFixedHeight(self.thumb_size[1]) + self.show_filename_label = value + def update_thumb(self, timestamp: float, image: QPixmap | None = None): """Update attributes of a thumbnail element.""" if timestamp > ItemThumb.update_cutoff: self.thumb_button.setIcon(image if image else QPixmap()) def update_size(self, timestamp: float, size: QSize): - """Updates attributes of a thumbnail element.""" - if timestamp > ItemThumb.update_cutoff and self.thumb_button.iconSize != size: + """Updates attributes of a thumbnail element. + + Args: + timestamp (float | None): The UTC timestamp for when this call was + originally dispatched. Used to skip outdated jobs. + + size (QSize): The new thumbnail size to set. + """ + if timestamp > ItemThumb.update_cutoff: + self.thumb_size = size.toTuple() # type: ignore self.thumb_button.setIconSize(size) self.thumb_button.setMinimumSize(size) self.thumb_button.setMaximumSize(size) diff --git a/tagstudio/tests/fixtures/search_library/.TagStudio/ts_library.sqlite b/tagstudio/tests/fixtures/search_library/.TagStudio/ts_library.sqlite index 449f380b02fad6ca8fbcc08dddf2ca8d99116aaf..66c1a7c364c6dedfb9aad87abd13cce1ad747514 100644 GIT binary patch delta 24 ecmZozz}m2Yb%GQVqxnP`Cm`9Fur+~kfj5TdPC&9TVQT{80)GH&1PHPK From 12432571ad5ff6f8a3e04904ba4b7099f7d6b191 Mon Sep 17 00:00:00 2001 From: Travis Abendshien <46939827+CyanVoxel@users.noreply.github.com> Date: Tue, 10 Dec 2024 16:59:53 -0800 Subject: [PATCH 4/9] refactor variables, tweak spacing --- tagstudio/src/qt/widgets/item_thumb.py | 31 +++++++++++++------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/tagstudio/src/qt/widgets/item_thumb.py b/tagstudio/src/qt/widgets/item_thumb.py index 68f210816..183651d91 100644 --- a/tagstudio/src/qt/widgets/item_thumb.py +++ b/tagstudio/src/qt/widgets/item_thumb.py @@ -129,8 +129,8 @@ def __init__( self.item_id: int | None = None self.thumb_size: tuple[int, int] = thumb_size self.show_filename_label: bool = show_filename_label - self.label_height = 16 - self.label_spacing = 3 + self.label_height = 12 + self.label_spacing = 4 check_size = 24 self.setFixedSize( thumb_size[0], @@ -139,9 +139,10 @@ def __init__( ) self.thumb_container = QWidget() - self.real_base_layout = QVBoxLayout(self) - self.real_base_layout.setContentsMargins(0, 0, 0, 0) - self.setLayout(self.real_base_layout) + self.base_layout = QVBoxLayout(self) + self.base_layout.setContentsMargins(0, 0, 0, 0) + self.base_layout.setSpacing(0) + self.setLayout(self.base_layout) # +----------+ # | ARC FAV| Top Right: Favorite & Archived Badges @@ -160,9 +161,9 @@ def __init__( # || || # |*--------*| # +----------+ - self.base_layout = QVBoxLayout(self.thumb_container) - self.base_layout.setObjectName("baseLayout") - self.base_layout.setContentsMargins(0, 0, 0, 0) + self.thumb_layout = QVBoxLayout(self.thumb_container) + self.thumb_layout.setObjectName("baseLayout") + self.thumb_layout.setContentsMargins(0, 0, 0, 0) # +----------+ # |[~~~~~~~~]| @@ -175,7 +176,7 @@ def __init__( self.top_layout.setContentsMargins(6, 6, 6, 6) self.top_container = QWidget() self.top_container.setLayout(self.top_layout) - self.base_layout.addWidget(self.top_container) + self.thumb_layout.addWidget(self.top_container) # +----------+ # |[~~~~~~~~]| @@ -183,7 +184,7 @@ def __init__( # | | | # | v | # +----------+ - self.base_layout.addStretch(2) + self.thumb_layout.addStretch(2) # +----------+ # |[~~~~~~~~]| @@ -196,7 +197,7 @@ def __init__( self.bottom_layout.setContentsMargins(6, 6, 6, 6) self.bottom_container = QWidget() self.bottom_container.setLayout(self.bottom_layout) - self.base_layout.addWidget(self.bottom_container) + self.thumb_layout.addWidget(self.bottom_container) self.thumb_button = ThumbButton(self.thumb_container, thumb_size) self.renderer = ThumbRenderer() @@ -209,7 +210,7 @@ def __init__( ) ) self.thumb_button.setFlat(True) - self.thumb_button.setLayout(self.base_layout) + self.thumb_button.setLayout(self.thumb_layout) self.thumb_button.setContextMenuPolicy(Qt.ContextMenuPolicy.ActionsContextMenu) self.opener = FileOpenerHelper("") @@ -304,11 +305,11 @@ def __init__( # Filename Label ======================================================= self.file_label = QLabel(text="Filename") self.file_label.setStyleSheet(ItemThumb.filename_style) - self.file_label.setFixedHeight(12) + self.file_label.setMaximumHeight(self.label_height) self.file_label.setHidden(not show_filename_label) - self.real_base_layout.addWidget(self.thumb_container) - self.real_base_layout.addWidget(self.file_label) + self.base_layout.addWidget(self.thumb_container) + self.base_layout.addWidget(self.file_label) self.set_mode(mode) From c54599afbb972a8c178ad3412986f313904a9598 Mon Sep 17 00:00:00 2001 From: Travis Abendshien <46939827+CyanVoxel@users.noreply.github.com> Date: Tue, 10 Dec 2024 17:55:20 -0800 Subject: [PATCH 5/9] fix(ui): only change cursor on thumb_button --- tagstudio/src/qt/widgets/item_thumb.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tagstudio/src/qt/widgets/item_thumb.py b/tagstudio/src/qt/widgets/item_thumb.py index 183651d91..baf0c62c7 100644 --- a/tagstudio/src/qt/widgets/item_thumb.py +++ b/tagstudio/src/qt/widgets/item_thumb.py @@ -324,11 +324,11 @@ def is_archived(self): def set_mode(self, mode: ItemType | None) -> None: if mode is None: self.setAttribute(Qt.WidgetAttribute.WA_TransparentForMouseEvents, on=True) - self.unsetCursor() + self.thumb_button.unsetCursor() self.thumb_button.setHidden(True) elif mode == ItemType.ENTRY and self.mode != ItemType.ENTRY: self.setAttribute(Qt.WidgetAttribute.WA_TransparentForMouseEvents, on=False) - self.setCursor(Qt.CursorShape.PointingHandCursor) + self.thumb_button.setCursor(Qt.CursorShape.PointingHandCursor) self.thumb_button.setHidden(False) self.cb_container.setHidden(False) # Count Badge depends on file extension (video length, word count) @@ -338,7 +338,7 @@ def set_mode(self, mode: ItemType | None) -> None: self.ext_badge.setHidden(True) elif mode == ItemType.COLLATION and self.mode != ItemType.COLLATION: self.setAttribute(Qt.WidgetAttribute.WA_TransparentForMouseEvents, on=False) - self.setCursor(Qt.CursorShape.PointingHandCursor) + self.thumb_button.setCursor(Qt.CursorShape.PointingHandCursor) self.thumb_button.setHidden(False) self.cb_container.setHidden(True) self.ext_badge.setHidden(True) @@ -347,7 +347,7 @@ def set_mode(self, mode: ItemType | None) -> None: self.item_type_badge.setHidden(False) elif mode == ItemType.TAG_GROUP and self.mode != ItemType.TAG_GROUP: self.setAttribute(Qt.WidgetAttribute.WA_TransparentForMouseEvents, on=False) - self.setCursor(Qt.CursorShape.PointingHandCursor) + self.thumb_button.setCursor(Qt.CursorShape.PointingHandCursor) self.thumb_button.setHidden(False) self.ext_badge.setHidden(True) self.count_badge.setHidden(False) From 05bb5c8097b05e13047b5139601c0b670a04cbf1 Mon Sep 17 00:00:00 2001 From: Travis Abendshien Date: Fri, 13 Dec 2024 12:32:45 -0800 Subject: [PATCH 6/9] revert changes to ../search_library/../ts_library.sqlite --- .../.TagStudio/ts_library.sqlite | Bin 86016 -> 86016 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/tagstudio/tests/fixtures/search_library/.TagStudio/ts_library.sqlite b/tagstudio/tests/fixtures/search_library/.TagStudio/ts_library.sqlite index 66c1a7c364c6dedfb9aad87abd13cce1ad747514..449f380b02fad6ca8fbcc08dddf2ca8d99116aaf 100644 GIT binary patch delta 24 ecmZozz}m2Yb%GQV!>5TdPC&9TVQT{80)GH&1PHPK delta 24 ecmZozz}m2Yb%GQVqxnP`Cm`9Fur+~kfj Date: Fri, 13 Dec 2024 14:44:03 -0800 Subject: [PATCH 7/9] fix: don't ever call .setHidden(False) on visible widgets --- tagstudio/src/qt/widgets/item_thumb.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tagstudio/src/qt/widgets/item_thumb.py b/tagstudio/src/qt/widgets/item_thumb.py index 495270afe..5a78927f0 100644 --- a/tagstudio/src/qt/widgets/item_thumb.py +++ b/tagstudio/src/qt/widgets/item_thumb.py @@ -309,7 +309,8 @@ def __init__( self.file_label = QLabel(text="Filename") self.file_label.setStyleSheet(ItemThumb.filename_style) self.file_label.setMaximumHeight(self.label_height) - self.file_label.setHidden(not show_filename_label) + if not show_filename_label: + self.file_label.setHidden(True) self.base_layout.addWidget(self.thumb_container) self.base_layout.addWidget(self.file_label) @@ -405,7 +406,8 @@ def toggle_filename(self, value: bool): value (bool): Show the filename, true or false. """ if value: - self.file_label.setHidden(False) + if self.file_label.isHidden(): + self.file_label.setHidden(False) self.setFixedHeight(self.thumb_size[1] + self.label_height + self.label_spacing) else: self.file_label.setHidden(True) From 167f85937da5271347460966abaaa8aa2b345f29 Mon Sep 17 00:00:00 2001 From: Travis Abendshien Date: Fri, 13 Dec 2024 14:52:17 -0800 Subject: [PATCH 8/9] refactor: rename filename toggles to setters --- tagstudio/src/qt/ts_qt.py | 8 ++++---- tagstudio/src/qt/widgets/item_thumb.py | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tagstudio/src/qt/ts_qt.py b/tagstudio/src/qt/ts_qt.py index 59043060f..65aa77651 100644 --- a/tagstudio/src/qt/ts_qt.py +++ b/tagstudio/src/qt/ts_qt.py @@ -399,7 +399,7 @@ def start(self) -> None: show_filenames_action.triggered.connect( lambda checked: ( self.settings.setValue(SettingItems.SHOW_FILENAMES, checked), - self.toggle_grid_filenames(checked), + self.show_grid_filenames(checked), ) ) view_menu.addAction(show_filenames_action) @@ -568,9 +568,9 @@ def toggle_libs_list(self, value: bool): self.preview_panel.libs_flow_container.hide() self.preview_panel.update() - def toggle_grid_filenames(self, value: bool): + def show_grid_filenames(self, value: bool): for thumb in self.item_thumbs: - thumb.toggle_filename(value) + thumb.set_filename_visibility(value) def callback_library_needed_check(self, func): """Check if loaded library has valid path before executing the button function.""" @@ -852,7 +852,7 @@ def thumb_size_callback(self, index: int): it.thumb_size = (self.thumb_size, self.thumb_size) it.setFixedSize(self.thumb_size, self.thumb_size) it.thumb_button.thumb_size = (self.thumb_size, self.thumb_size) - it.toggle_filename(it.show_filename_label) + it.set_filename_visibility(it.show_filename_label) self.flow_container.layout().setSpacing( min(self.thumb_size // spacing_divisor, min_spacing) ) diff --git a/tagstudio/src/qt/widgets/item_thumb.py b/tagstudio/src/qt/widgets/item_thumb.py index 5a78927f0..9935fe4e7 100644 --- a/tagstudio/src/qt/widgets/item_thumb.py +++ b/tagstudio/src/qt/widgets/item_thumb.py @@ -208,7 +208,7 @@ def __init__( lambda ts, i, s, fn, ext: ( self.update_thumb(ts, image=i), self.update_size(ts, size=s), - self.set_filename(fn), + self.set_filename_text(fn), self.set_extension(ext), ) ) @@ -396,23 +396,23 @@ def set_count(self, count: str) -> None: self.ext_badge.setHidden(True) self.count_badge.setHidden(True) - def set_filename(self, filename: Path | str | None): + def set_filename_text(self, filename: Path | str | None): self.file_label.setText(str(filename)) - def toggle_filename(self, value: bool): + def set_filename_visibility(self, set_visible: bool): """Toggle the visibility of the filename label. Args: - value (bool): Show the filename, true or false. + set_visible (bool): Show the filename, true or false. """ - if value: + if set_visible: if self.file_label.isHidden(): self.file_label.setHidden(False) self.setFixedHeight(self.thumb_size[1] + self.label_height + self.label_spacing) else: self.file_label.setHidden(True) self.setFixedHeight(self.thumb_size[1]) - self.show_filename_label = value + self.show_filename_label = set_visible def update_thumb(self, timestamp: float, image: QPixmap | None = None): """Update attributes of a thumbnail element.""" From 9251fb2d32adcc33abc51ee7872b81ad6043b006 Mon Sep 17 00:00:00 2001 From: Travis Abendshien Date: Fri, 13 Dec 2024 14:54:44 -0800 Subject: [PATCH 9/9] fix: remove duplicate open_on_start_action --- tagstudio/src/qt/ts_qt.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/tagstudio/src/qt/ts_qt.py b/tagstudio/src/qt/ts_qt.py index 65aa77651..80160cfff 100644 --- a/tagstudio/src/qt/ts_qt.py +++ b/tagstudio/src/qt/ts_qt.py @@ -262,9 +262,6 @@ def start(self) -> None: help_menu = QMenu("&Help", menu_bar) # File Menu ============================================================ - # file_menu.addAction(QAction('&New Library', menu_bar)) - # file_menu.addAction(QAction('&Open Library', menu_bar)) - open_library_action = QAction("&Open/Create Library", menu_bar) open_library_action.triggered.connect(lambda: self.open_library_from_dialog()) open_library_action.setShortcut( @@ -294,8 +291,6 @@ def start(self) -> None: file_menu.addSeparator() - # refresh_lib_action = QAction('&Refresh Directories', self.main_window) - # refresh_lib_action.triggered.connect(lambda: self.lib.refresh_dir()) add_new_files_action = QAction("&Refresh Directories", menu_bar) add_new_files_action.triggered.connect( lambda: self.callback_library_needed_check(self.add_new_files_callback) @@ -307,7 +302,6 @@ def start(self) -> None: ) ) add_new_files_action.setStatusTip("Ctrl+R") - # file_menu.addAction(refresh_lib_action) file_menu.addAction(add_new_files_action) file_menu.addSeparator() @@ -368,16 +362,6 @@ def start(self) -> None: edit_menu.addAction(tag_database_action) # View Menu ============================================================ - open_on_start_action = QAction("Open Library on Start", self) - open_on_start_action.setCheckable(True) - open_on_start_action.setChecked( - bool(self.settings.value(SettingItems.START_LOAD_LAST, defaultValue=True, type=bool)) - ) - open_on_start_action.triggered.connect( - lambda checked: self.settings.setValue(SettingItems.START_LOAD_LAST, checked) - ) - view_menu.addAction(open_on_start_action) - show_libs_list_action = QAction("Show Recent Libraries", menu_bar) show_libs_list_action.setCheckable(True) show_libs_list_action.setChecked(