Improve stability issues
This commit is contained in:
@@ -176,16 +176,34 @@ class DuplicateManagerDialog(QDialog):
|
||||
super().wheelEvent(event)
|
||||
|
||||
def keyPressEvent(self, event):
|
||||
"""Handles keyboard shortcuts for zooming."""
|
||||
"""Handles keyboard shortcuts for zooming and duplicate management."""
|
||||
key = event.key()
|
||||
if key == Qt.Key_U:
|
||||
self._delete_left()
|
||||
event.accept()
|
||||
return
|
||||
elif key == Qt.Key_I:
|
||||
self._delete_right()
|
||||
event.accept()
|
||||
return
|
||||
elif key == Qt.Key_O:
|
||||
self._keep_both()
|
||||
event.accept()
|
||||
return
|
||||
elif key == Qt.Key_P:
|
||||
self._skip()
|
||||
event.accept()
|
||||
return
|
||||
|
||||
if not self.active_pane:
|
||||
super().keyPressEvent(event)
|
||||
return
|
||||
|
||||
if event.key() == Qt.Key_Plus or event.key() == Qt.Key_Equal:
|
||||
if key == Qt.Key_Plus or key == Qt.Key_Equal:
|
||||
self.active_pane.zoom_manager.zoom(1.1)
|
||||
elif event.key() == Qt.Key_Minus:
|
||||
elif key == Qt.Key_Minus:
|
||||
self.active_pane.zoom_manager.zoom(0.9)
|
||||
elif event.key() == Qt.Key_Z:
|
||||
elif key == Qt.Key_Z:
|
||||
self.active_pane.zoom_manager.zoom(reset=True)
|
||||
else:
|
||||
super().keyPressEvent(event)
|
||||
@@ -260,6 +278,7 @@ class DuplicateManagerDialog(QDialog):
|
||||
# Create ImagePane
|
||||
pane = ImagePane(self, self.main_win.cache, [], 0, None, 0)
|
||||
pane.setContextMenuPolicy(Qt.CustomContextMenu)
|
||||
pane.controller.show_faces = False # Disable showing and adding areas
|
||||
pane.customContextMenuRequested.connect(self._show_pane_context_menu)
|
||||
v_layout.addWidget(pane)
|
||||
|
||||
@@ -367,6 +386,44 @@ class DuplicateManagerDialog(QDialog):
|
||||
self._set_pane_data(self.left_pane_widget, path_right, filename_color, dir_color, filename_right, dir_right)
|
||||
self._set_pane_data(self.right_pane_widget, path_left, filename_color, dir_color, filename_left, dir_left)
|
||||
|
||||
# Compare resolutions and highlight the best one
|
||||
p_l = self.left_pane.controller.pixmap_original
|
||||
p_r = self.right_pane.controller.pixmap_original
|
||||
if not p_l.isNull() and not p_r.isNull():
|
||||
res_l = p_l.width() * p_l.height()
|
||||
res_r = p_r.width() * p_r.height()
|
||||
|
||||
winner = 0 # 0: none, 1: left, 2: right
|
||||
if res_l > res_r:
|
||||
winner = 1
|
||||
elif res_r > res_l:
|
||||
winner = 2
|
||||
else:
|
||||
# Same resolution, compare file sizes
|
||||
try:
|
||||
path_l = self.left_pane.controller.get_current_path()
|
||||
path_r = self.right_pane.controller.get_current_path()
|
||||
size_l = os.path.getsize(path_l)
|
||||
size_r = os.path.getsize(path_r)
|
||||
if size_l > size_r: winner = 1
|
||||
elif size_r > size_l: winner = 2
|
||||
except (OSError, AttributeError): pass
|
||||
|
||||
if winner == 1:
|
||||
self.left_pane_widget.info_lbl.setStyleSheet("font-weight: bold; color: #2ecc71;")
|
||||
self.left_pane_widget.info_lbl.setText("✓ " + self.left_pane_widget.info_lbl.text())
|
||||
self.right_pane_widget.info_lbl.setStyleSheet("font-weight: bold; color: #aaa;")
|
||||
elif winner == 2:
|
||||
self.right_pane_widget.info_lbl.setStyleSheet("font-weight: bold; color: #2ecc71;")
|
||||
self.right_pane_widget.info_lbl.setText("✓ " + self.right_pane_widget.info_lbl.text())
|
||||
self.left_pane_widget.info_lbl.setStyleSheet("font-weight: bold; color: #aaa;")
|
||||
else:
|
||||
self.left_pane_widget.info_lbl.setStyleSheet("font-weight: bold; color: #aaa;")
|
||||
self.right_pane_widget.info_lbl.setStyleSheet("font-weight: bold; color: #aaa;")
|
||||
else:
|
||||
self.left_pane_widget.info_lbl.setStyleSheet("font-weight: bold; color: #aaa;")
|
||||
self.right_pane_widget.info_lbl.setStyleSheet("font-weight: bold; color: #aaa;")
|
||||
|
||||
def _set_pane_data(self, pane_widget, path, filename_color, dir_color, filename_text, dir_text):
|
||||
pane = pane_widget.pane
|
||||
info_lbl = pane_widget.info_lbl
|
||||
@@ -636,6 +693,10 @@ class DuplicateManagerDialog(QDialog):
|
||||
self.cache.mark_as_pending(p.path1, p.path2, False)
|
||||
|
||||
self.main_win.delete_file_by_path(delete_path, permanent=permanent) # Use default setting
|
||||
if os.path.exists(delete_path):
|
||||
QMessageBox.warning(self, UITexts.ERROR, UITexts.ERROR_DELETING_FILE.format(delete_path))
|
||||
return
|
||||
|
||||
# Remove all pairs containing this path because it no longer exists
|
||||
self.duplicates = [d for d in self.duplicates if d.path1 != delete_path and d.path2 != delete_path]
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user