refactor(ui): make 'fix unlined entries' panel refresh button use sync banner

This commit is contained in:
Travis Abendshien
2026-09-10 23:48:04 -07:00
parent 5610fc0471
commit cabc289657
3 changed files with 6 additions and 41 deletions
+1 -38
View File
@@ -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()
+3
View File
@@ -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
+2 -3
View File
@@ -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}<br>{ffprobe}: {ffprobe_status}",