From cabc289657833157f4dca34b03c17f83d5e7445d Mon Sep 17 00:00:00 2001 From: Travis Abendshien <46939827+CyanVoxel@users.noreply.github.com> Date: Thu, 10 Sep 2026 23:48:04 -0700 Subject: [PATCH] refactor(ui): make 'fix unlined entries' panel refresh button use sync banner --- src/tagstudio/qt/mixed/fix_unlinked.py | 39 +------------------- src/tagstudio/qt/qt_driver.py | 3 ++ src/tagstudio/resources/translations/en.json | 5 +-- 3 files changed, 6 insertions(+), 41 deletions(-) diff --git a/src/tagstudio/qt/mixed/fix_unlinked.py b/src/tagstudio/qt/mixed/fix_unlinked.py index 6063cd42..d3ebba0f 100644 --- a/src/tagstudio/qt/mixed/fix_unlinked.py +++ b/src/tagstudio/qt/mixed/fix_unlinked.py @@ -4,24 +4,19 @@ from typing import TYPE_CHECKING, override -import structlog from PySide6 import QtCore, QtGui from PySide6.QtCore import Qt from PySide6.QtWidgets import QHBoxLayout, QLabel, QPushButton, QVBoxLayout, QWidget from tagstudio.core.library.alchemy.library import Library -from tagstudio.core.utils.types import unwrap from tagstudio.i18n.translations import Translations from tagstudio.qt.controllers.merge_dupe_entries_progress import MergeDuplicateEntriesProgress -from tagstudio.qt.controllers.progress_bar import ProgressWidget from tagstudio.qt.mixed.remove_unlinked_modal import RemoveUnlinkedEntriesModal from tagstudio.qt.views.styles.stylesheets import header if TYPE_CHECKING: from tagstudio.qt.qt_driver import QtDriver -logger = structlog.get_logger(__name__) - # TODO: Split to use MVC guidelines, or completely redo. class FixUnlinkedEntriesModal(QWidget): @@ -60,7 +55,7 @@ class FixUnlinkedEntriesModal(QWidget): self.dupe_count_label.setAlignment(Qt.AlignmentFlag.AlignCenter) self.refresh_unlinked_button = QPushButton(Translations["entries.generic.refresh_alt"]) - self.refresh_unlinked_button.clicked.connect(self.refresh_unlinked) + self.refresh_unlinked_button.clicked.connect(self.driver.sync_library_callback) self.merge_class = MergeDuplicateEntriesProgress(self.lib, self.driver) @@ -100,38 +95,6 @@ class FixUnlinkedEntriesModal(QWidget): self.update_unlinked_count() - def refresh_unlinked(self): - if self.driver.file_scan_lock: - logger.info("[FixUnlinkedEntries] Sync already in progress, ignoring refresh request") - return - self.driver.file_scan_lock = True - - pw = ProgressWidget( - cancel_button_text=None, - minimum=0, - maximum=self.lib.entries_count, - ) - pw.setWindowTitle(Translations["library.scan_library.title"]) - pw.update_label(Translations["entries.unlinked.scanning"]) - - def finish(): - self.driver.file_scan_lock = False - if ( - hasattr(self.driver, "library_info_window") - and self.driver.library_info_window.isVisible() - ): - self.driver.library_info_window.update_cleanup() - - # Uses the Library's shared path cache - pw.from_iterable_function( - lambda: self.sync_engine.sync_dir(unwrap(self.lib.library_dir)), - None, - self.set_unlinked_count, - finish, - self.update_unlinked_count, - self.remove_modal.refresh_list, - ) - def _sync_ui_from_tracker(self) -> None: """Refresh the UI from the tracker's current state, without rescanning the library.""" self.set_unlinked_count() diff --git a/src/tagstudio/qt/qt_driver.py b/src/tagstudio/qt/qt_driver.py index e468c2e0..bcc0907a 100644 --- a/src/tagstudio/qt/qt_driver.py +++ b/src/tagstudio/qt/qt_driver.py @@ -1166,6 +1166,9 @@ class QtDriver(DriverMixin, QObject): self.lib.unlinked_entries_count = unlinked_count if hasattr(self, "unlinked_modal") and self.unlinked_modal.isVisible(): self.unlinked_modal.update_unlinked_count() + self.unlinked_modal.remove_modal.refresh_list() + if hasattr(self, "library_info_window") and self.library_info_window.isVisible(): + self.library_info_window.update_cleanup() if self.sync_engine.cancelled: return diff --git a/src/tagstudio/resources/translations/en.json b/src/tagstudio/resources/translations/en.json index 7483d97d..6344844e 100644 --- a/src/tagstudio/resources/translations/en.json +++ b/src/tagstudio/resources/translations/en.json @@ -67,10 +67,9 @@ "entries.unlinked.description.ambiguous": "For unlinked entries that have ambiguous matches to multiple files in your library, you may manually choose how they get relinked.", "entries.unlinked.description.deleted": "When you delete files outside of TagStudio, their associated entries become unlinked. You may manually delete any unlinked entries at your own discretion.", "entries.unlinked.relink.manual": "&Manual Relink", - "entries.unlinked.remove": "Remove Unlinked Entries", - "entries.unlinked.remove_alt": "Remo&ve Unlinked Entries", + "entries.unlinked.remove": "Delete Unlinked Entries", + "entries.unlinked.remove_alt": "&Delete Unlinked Entries", "entries.unlinked.review": "Manual &Review", - "entries.unlinked.scanning": "Scanning Library for Unlinked Entries…", "entries.unlinked.title": "Fix Unlinked Entries", "entries.unlinked.unlinked_count": "Unlinked Entries: {count}", "ffmpeg.missing.status": "{ffmpeg}: {ffmpeg_status}
{ffprobe}: {ffprobe_status}",