Skip to content

Commit 7bef302

Browse files
committed
fix: restore item_thumb delete action
1 parent e115443 commit 7bef302

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

src/tagstudio/qt/ts_qt.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,6 +1486,11 @@ def update_thumbs(self):
14861486
)
14871487
item_thumb.assign_badge(BadgeType.ARCHIVED, entry.id in tag_entries[TAG_ARCHIVED])
14881488
item_thumb.assign_badge(BadgeType.FAVORITE, entry.id in tag_entries[TAG_FAVORITE])
1489+
item_thumb.delete_action.triggered.connect(
1490+
lambda checked=False, f=filenames[index], e_id=entry.id: self.delete_files_callback(
1491+
f, e_id
1492+
)
1493+
)
14891494

14901495
# Restore Selected Borders
14911496
is_selected = item_thumb.item_id in self.selected

src/tagstudio/qt/widgets/item_thumb.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44

55

66
import time
7-
import typing
87
from enum import Enum
98
from functools import wraps
109
from pathlib import Path
1110
from typing import TYPE_CHECKING, override
12-
from warnings import catch_warnings
1311

1412
import structlog
1513
from PIL import Image, ImageQt
@@ -126,7 +124,7 @@ def __init__(
126124
self.lib = library
127125
self.mode: ItemType | None = mode
128126
self.driver = driver
129-
self.item_id: int | None = None
127+
self.item_id: int = -1
130128
self.thumb_size: tuple[int, int] = thumb_size
131129
self.show_filename_label: bool = show_filename_label
132130
self.label_height = 12
@@ -321,16 +319,16 @@ def __init__(
321319

322320
self.base_layout.addWidget(self.thumb_container)
323321
self.base_layout.addWidget(self.file_label)
322+
# NOTE: self.item_id seems to act as a reference here and does not need to be updated inside
323+
# QtDriver.update_thumbs() while item_thumb.delete_action does.
324+
# If this behavior ever changes, move this method back to QtDriver.update_thumbs().
324325
self.thumb_button.clicked.connect(
325326
lambda: self.driver.toggle_item_selection(
326327
self.item_id,
327328
append=(QGuiApplication.keyboardModifiers() == Qt.KeyboardModifier.ControlModifier),
328329
bridge=(QGuiApplication.keyboardModifiers() == Qt.KeyboardModifier.ShiftModifier),
329330
)
330331
)
331-
self.delete_action.triggered.connect(
332-
lambda: self.driver.delete_files_callback(self.opener.filepath, self.item_id)
333-
)
334332
self.set_mode(mode)
335333

336334
@property
@@ -451,12 +449,6 @@ def update_size(self, timestamp: float, size: QSize):
451449
self.thumb_button.setMinimumSize(size)
452450
self.thumb_button.setMaximumSize(size)
453451

454-
def update_clickable(self, clickable: typing.Callable[[], None]):
455-
"""Updates attributes of a thumbnail element."""
456-
with catch_warnings(record=True):
457-
self.thumb_button.clicked.disconnect()
458-
self.thumb_button.clicked.connect(clickable)
459-
460452
def set_item_id(self, item_id: int):
461453
self.item_id = item_id
462454

0 commit comments

Comments
 (0)