This commit is contained in:
Ignacio Serantes
2026-05-03 13:31:48 +02:00
parent 28b120c9e9
commit 8025bef8d3
6 changed files with 654 additions and 227 deletions

View File

@@ -14,7 +14,7 @@ Classes:
MainWindow: The main application window containing the thumbnail grid and docks.
"""
__appname__ = "BagheeraView"
__version__ = "0.9.25"
__version__ = "0.9.26"
__author__ = "Ignacio Serantes"
__email__ = "kde@aynoa.net"
__license__ = "LGPL"
@@ -1768,13 +1768,18 @@ class MainWindow(QMainWindow):
UITexts.MENU_DETECT_CURRENT_SEARCH)
detect_current_action.triggered.connect(self.start_duplicate_detection)
detect_all_action = duplicates_menu.addAction(UITexts.MENU_DETECT_ALL)
detect_all_action.triggered.connect(self.detect_all_duplicates)
force_full_action = duplicates_menu.addAction(UITexts.MENU_FORCE_FULL_ANALYSIS)
force_full_action.triggered.connect(
lambda: self.start_duplicate_detection(force_full=True))
detect_all_action = duplicates_menu.addAction(UITexts.MENU_DETECT_ALL)
detect_all_action.triggered.connect(self.detect_all_duplicates)
force_full_all_action = duplicates_menu.addAction(
UITexts.MENU_FORCE_FULL_ALL_ANALYSIS)
force_full_all_action.triggered.connect(
lambda: self.detect_all_duplicates(force_full=True))
review_ignored_action = duplicates_menu.addAction(UITexts.MENU_REVIEW_IGNORED)
review_ignored_action.triggered.connect(self.review_ignored_duplicates)
@@ -1784,6 +1789,13 @@ class MainWindow(QMainWindow):
QIcon.fromTheme("edit-clear-all"), UITexts.MENU_CLEAN_UP_HASHES)
clean_hashes_action.triggered.connect(self.clean_duplicate_hashes)
repair_index_action = duplicates_menu.addAction(UITexts.MENU_REPAIR_DATABASE)
repair_index_action.triggered.connect(self.repair_duplicate_index)
clear_exceptions_action = duplicates_menu.addAction(
UITexts.MENU_CLEAR_EXCEPTIONS)
clear_exceptions_action.triggered.connect(self.clear_ignored_duplicates)
if self.duplicate_cache:
count, size_bytes = self.duplicate_cache.get_hash_stats()
size_mb = size_bytes / (1024 * 1024)
@@ -1828,7 +1840,7 @@ class MainWindow(QMainWindow):
menu.exec(self.menu_btn.mapToGlobal(QPoint(0, self.menu_btn.height())))
def detect_all_duplicates(self):
def detect_all_duplicates(self, force_full=False):
"""Gathers files from whitelist (respecting blacklist) and runs detector."""
QApplication.setOverrideCursor(Qt.WaitCursor)
try:
@@ -1849,7 +1861,7 @@ class MainWindow(QMainWindow):
# By default, we use optimized (incremental) mode to avoid repeating
# comparisons.
self.start_duplicate_detection(force_full=False, custom_paths=paths)
self.start_duplicate_detection(force_full=force_full, custom_paths=paths)
def _gather_files_for_duplicates(self):
"""Helper to collect image paths based on whitelist and blacklist settings."""
@@ -1892,6 +1904,40 @@ class MainWindow(QMainWindow):
count = self.duplicate_cache.clean_stale_hashes()
self.status_lbl.setText(f"Cleaned up {count} stale hash entries.")
def repair_duplicate_index(self):
"""Regenerates the BK-Tree and reverse index."""
if not self.duplicate_cache:
return
if self.duplicate_detector and self.duplicate_detector.isRunning():
QMessageBox.information(self, UITexts.DUPLICATE_DETECTION_TITLE,
UITexts.DUPLICATE_ALREADY_RUNNING)
return
self.status_lbl.setText(UITexts.REPAIRING_DATABASE)
QApplication.setOverrideCursor(Qt.WaitCursor)
try:
self.duplicate_cache.regenerate_bktree()
self.status_lbl.setText(UITexts.READY)
finally:
QApplication.restoreOverrideCursor()
def clear_ignored_duplicates(self):
"""Clears the ignored pairs database after user confirmation."""
if not self.duplicate_cache:
return
confirm = QMessageBox(self)
confirm.setIcon(QMessageBox.Question)
confirm.setWindowTitle(UITexts.CONFIRM_CLEAR_EXCEPTIONS_TITLE)
confirm.setText(UITexts.CONFIRM_CLEAR_EXCEPTIONS_TEXT)
confirm.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
confirm.setDefaultButton(QMessageBox.No)
if confirm.exec() == QMessageBox.Yes:
self.duplicate_cache.clear_exceptions()
self.status_lbl.setText(UITexts.READY)
def clear_duplicate_hashes(self):
if not self.duplicate_cache:
return