def manager(qtbot, tmp_path, mocker): """Fixture to create a thumbnail manager with relevant methods mocked.""" # Mock directory in which the thumbnails are created tmp_cache_dir = tmp_path / "cache" mocker.patch("vimiv.utils.xdg.user_cache_dir", return_value=str(tmp_cache_dir)) # Create thumbnail manager and yield the instance yield thumbnail_manager.ThumbnailManager(None)
def __init__(self): super().__init__() self._paths: List[str] = [] fail_pixmap = create_pixmap( color=styles.get("thumbnail.error.bg"), frame_color=styles.get("thumbnail.frame.fg"), size=256, frame_size=10, ) self._manager = thumbnail_manager.ThumbnailManager(fail_pixmap) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setViewMode(QListWidget.IconMode) default_size = api.settings.thumbnail.size.value self.setIconSize(QSize(default_size, default_size)) self.setResizeMode(QListWidget.Adjust) self.setItemDelegate(ThumbnailDelegate(self)) api.signals.new_image_opened.connect(self._select_path) api.signals.new_images_opened.connect(self._on_new_images_opened) api.settings.thumbnail.size.changed.connect(self._on_size_changed) search.search.new_search.connect(self._on_new_search) search.search.cleared.connect(self._on_search_cleared) self._manager.created.connect(self._on_thumbnail_created) self.activated.connect(self.open_selected) self.doubleClicked.connect(self.open_selected) api.mark.marked.connect(self._mark_highlight) api.mark.unmarked.connect( lambda path: self._mark_highlight(path, marked=False)) synchronize.signals.new_library_path_selected.connect( self._select_path) styles.apply(self)