Skip to content
Prev Previous commit
Next Next commit
Translate fix_dupes.py abd fix_unlinked.py
  • Loading branch information
poseidon-rises committed Nov 24, 2024
commit e41b48b0c3d25a6e7052d1c535058a60a8ca5c2e
28 changes: 14 additions & 14 deletions tagstudio/src/qt/modals/fix_dupes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import typing

from PySide6.QtCore import Qt
from PySide6.QtCore import Qt, QCoreApplication
from PySide6.QtWidgets import (
QWidget,
QVBoxLayout,
Expand All @@ -32,7 +32,7 @@ def __init__(self, library: "Library", driver: "QtDriver"):
self.driver = driver
self.count = -1
self.filename = ""
self.setWindowTitle("Fix Duplicate Files")
self.setWindowTitle(QCoreApplication.translate("fix_dupes", "fix_dupes"))
self.setWindowModality(Qt.WindowModality.ApplicationModal)
self.setMinimumSize(400, 300)
self.root_layout = QVBoxLayout(self)
Expand Down Expand Up @@ -78,22 +78,22 @@ def __init__(self, library: "Library", driver: "QtDriver"):
# # 'padding-top: 6px'
# '')
# self.file_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.file_label.setText("No DupeGuru File Selected")
self.file_label.setText(QCoreApplication.translate("fix_dupes", "no_file_selected"))

self.open_button = QPushButton()
self.open_button.setText("&Load DupeGuru File")
self.open_button.setText(QCoreApplication.translate("fix_dupes", "load_file"))
self.open_button.clicked.connect(self.select_file)

self.mirror_modal = MirrorEntriesModal(self.driver, self.tracker)
self.mirror_modal.done.connect(self.refresh_dupes)

self.mirror_button = QPushButton()
self.mirror_button.setText("&Mirror Entries")
self.mirror_button.setText(QCoreApplication.translate("fix_dupes", "mirror_entries"))
self.mirror_button.clicked.connect(self.mirror_modal.show)
self.mirror_desc = QLabel()
self.mirror_desc.setWordWrap(True)
self.mirror_desc.setText(
"""Mirror the Entry data across each duplicate match set, combining all data while not removing or duplicating fields. This operation will not delete any files or data."""
QCoreApplication.translate("fix_dupes", "mirror_description")
)

# self.mirror_delete_button = QPushButton()
Expand All @@ -102,7 +102,7 @@ def __init__(self, library: "Library", driver: "QtDriver"):
self.advice_label = QLabel()
self.advice_label.setWordWrap(True)
self.advice_label.setText(
"""After mirroring, you're free to use DupeGuru to delete the unwanted files. Afterwards, use TagStudio's "Fix Unlinked Entries" feature in the Tools menu in order to delete the unlinked Entries."""
QCoreApplication.translate("fix_dupes", "advice_label")
)

self.button_container = QWidget()
Expand All @@ -111,7 +111,7 @@ def __init__(self, library: "Library", driver: "QtDriver"):
self.button_layout.addStretch(1)

self.done_button = QPushButton()
self.done_button.setText("&Done")
self.done_button.setText(QCoreApplication.translate("generic", "done"))
# self.save_button.setAutoDefault(True)
self.done_button.setDefault(True)
self.done_button.clicked.connect(self.hide)
Expand Down Expand Up @@ -140,9 +140,9 @@ def __init__(self, library: "Library", driver: "QtDriver"):
self.set_dupe_count(-1)

def select_file(self):
qfd = QFileDialog(self, "Open DupeGuru Results File", str(self.lib.library_dir))
qfd = QFileDialog(self, QCoreApplication.translate("fix_dupes", "open_results_file"), str(self.lib.library_dir))
qfd.setFileMode(QFileDialog.FileMode.ExistingFile)
qfd.setNameFilter("DupeGuru Files (*.dupeguru)")
qfd.setNameFilter(QCoreApplication.translate("fix_dupes", "name_filter"))
if qfd.exec_():
filename = qfd.selectedFiles()
if filename:
Expand All @@ -152,7 +152,7 @@ def set_filename(self, filename: str):
if filename:
self.file_label.setText(filename)
else:
self.file_label.setText("No DupeGuru File Selected")
self.file_label.setText(QCoreApplication.translate("fix_dupes", "no_file_selected"))
self.filename = filename
self.refresh_dupes()
self.mirror_modal.refresh_list()
Expand All @@ -164,10 +164,10 @@ def refresh_dupes(self):
def set_dupe_count(self, count: int):
if count < 0:
self.mirror_button.setDisabled(True)
self.dupe_count.setText("Duplicate File Matches: N/A")
self.dupe_count.setText(QCoreApplication.translate("fix_dupes", "no_file_match"))
elif count == 0:
self.mirror_button.setDisabled(True)
self.dupe_count.setText(f"Duplicate File Matches: {count}")
self.dupe_count.setText(QCoreApplication.translate("fix_dupes", "number_file_match"))
else:
self.mirror_button.setDisabled(False)
self.dupe_count.setText(f"Duplicate File Matches: {count}")
self.dupe_count.setText(QCoreApplication.translate("fix_dupes", "number_file_match"))
24 changes: 11 additions & 13 deletions tagstudio/src/qt/modals/fix_unlinked.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright (C) 2024 Travis Abendshien (CyanVoxel).
z # Copyright (C) 2024 Travis Abendshien (CyanVoxel).
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio


import typing

from PySide6.QtCore import Qt, QThreadPool
from PySide6.QtCore import Qt, QThreadPool, QCoreApplication
from PySide6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QLabel, QPushButton

from src.core.library import Library
Expand All @@ -32,7 +32,7 @@ def __init__(self, library: "Library", driver: "QtDriver"):

self.missing_count = -1
self.dupe_count = -1
self.setWindowTitle("Fix Unlinked Entries")
self.setWindowTitle(QCoreApplication.translate("fix_unlinked", "fix_unlinked"))
self.setWindowModality(Qt.WindowModality.ApplicationModal)
self.setMinimumSize(400, 300)
self.root_layout = QVBoxLayout(self)
Expand All @@ -42,9 +42,7 @@ def __init__(self, library: "Library", driver: "QtDriver"):
self.unlinked_desc_widget.setObjectName("unlinkedDescriptionLabel")
self.unlinked_desc_widget.setWordWrap(True)
self.unlinked_desc_widget.setStyleSheet("text-align:left;")
self.unlinked_desc_widget.setText(
"""Each library entry is linked to a file in one of your directories. If a file linked to an entry is moved or deleted outside of TagStudio, it is then considered unlinked. Unlinked entries may be automatically relinked via searching your directories, manually relinked by the user, or deleted if desired."""
)
self.unlinked_desc_widget.setText(QCoreApplication.translate("fix_unlinked", "description"))

self.missing_count_label = QLabel()
self.missing_count_label.setObjectName("missingCountLabel")
Expand All @@ -57,14 +55,14 @@ def __init__(self, library: "Library", driver: "QtDriver"):
self.dupe_count_label.setAlignment(Qt.AlignmentFlag.AlignCenter)

self.refresh_unlinked_button = QPushButton()
self.refresh_unlinked_button.setText("&Refresh All")
self.refresh_unlinked_button.setText(QCoreApplication.translate("generic", "refresh_all"))
self.refresh_unlinked_button.clicked.connect(self.refresh_missing_files)

self.merge_class = MergeDuplicateEntries(self.lib, self.driver)
self.relink_class = RelinkUnlinkedEntries(self.tracker)

self.search_button = QPushButton()
self.search_button.setText("&Search && Relink")
self.search_button.setText(QCoreApplication.translate("fix_unlinked", "search_and_relink"))
self.relink_class.done.connect(
# refresh the grid
lambda: (
Expand All @@ -75,7 +73,7 @@ def __init__(self, library: "Library", driver: "QtDriver"):
self.search_button.clicked.connect(self.relink_class.repair_entries)

self.manual_button = QPushButton()
self.manual_button.setText("&Manual Relink")
self.manual_button.setText(QCoreApplication.translate("fix_unlinked", "manual_relink"))
self.manual_button.setHidden(True)

self.delete_button = QPushButton()
Expand All @@ -87,7 +85,7 @@ def __init__(self, library: "Library", driver: "QtDriver"):
self.driver.filter_items(),
)
)
self.delete_button.setText("De&lete Unlinked Entries")
self.delete_button.setText(QCoreApplication.translate("fix_unlinked", "fix_unlinked"))
self.delete_button.clicked.connect(self.delete_modal.show)

self.button_container = QWidget()
Expand All @@ -96,7 +94,7 @@ def __init__(self, library: "Library", driver: "QtDriver"):
self.button_layout.addStretch(1)

self.done_button = QPushButton()
self.done_button.setText("&Done")
self.done_button.setText(QCoreApplication.translate("genric", "done"))
self.done_button.setDefault(True)
self.done_button.clicked.connect(self.hide)
self.button_layout.addWidget(self.done_button)
Expand All @@ -115,8 +113,8 @@ def __init__(self, library: "Library", driver: "QtDriver"):

def refresh_missing_files(self):
pw = ProgressWidget(
window_title="Scanning Library",
label_text="Scanning Library for Unlinked Entries...",
window_title=QCoreApplication.translate("fix_unlinked", "scan_library.title"),
label_text=QCoreApplication.translate("fix_unlinked", "scan_library.label"),
cancel_button_text=None,
minimum=0,
maximum=self.lib.entries_count,
Expand Down