|
4 | 4 |
|
5 | 5 |
|
6 | 6 | import time |
7 | | -import typing |
8 | 7 | from enum import Enum |
9 | 8 | from functools import wraps |
10 | 9 | from pathlib import Path |
11 | 10 | from typing import TYPE_CHECKING, override |
12 | | -from warnings import catch_warnings |
13 | 11 |
|
14 | 12 | import structlog |
15 | 13 | from PIL import Image, ImageQt |
@@ -126,7 +124,7 @@ def __init__( |
126 | 124 | self.lib = library |
127 | 125 | self.mode: ItemType | None = mode |
128 | 126 | self.driver = driver |
129 | | - self.item_id: int | None = None |
| 127 | + self.item_id: int = -1 |
130 | 128 | self.thumb_size: tuple[int, int] = thumb_size |
131 | 129 | self.show_filename_label: bool = show_filename_label |
132 | 130 | self.label_height = 12 |
@@ -321,16 +319,16 @@ def __init__( |
321 | 319 |
|
322 | 320 | self.base_layout.addWidget(self.thumb_container) |
323 | 321 | 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(). |
324 | 325 | self.thumb_button.clicked.connect( |
325 | 326 | lambda: self.driver.toggle_item_selection( |
326 | 327 | self.item_id, |
327 | 328 | append=(QGuiApplication.keyboardModifiers() == Qt.KeyboardModifier.ControlModifier), |
328 | 329 | bridge=(QGuiApplication.keyboardModifiers() == Qt.KeyboardModifier.ShiftModifier), |
329 | 330 | ) |
330 | 331 | ) |
331 | | - self.delete_action.triggered.connect( |
332 | | - lambda: self.driver.delete_files_callback(self.opener.filepath, self.item_id) |
333 | | - ) |
334 | 332 | self.set_mode(mode) |
335 | 333 |
|
336 | 334 | @property |
@@ -451,12 +449,6 @@ def update_size(self, timestamp: float, size: QSize): |
451 | 449 | self.thumb_button.setMinimumSize(size) |
452 | 450 | self.thumb_button.setMaximumSize(size) |
453 | 451 |
|
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 | | - |
460 | 452 | def set_item_id(self, item_id: int): |
461 | 453 | self.item_id = item_id |
462 | 454 |
|
|
0 commit comments