v0.9.14
This commit is contained in:
@@ -14,7 +14,7 @@ Classes:
|
||||
MainWindow: The main application window containing the thumbnail grid and docks.
|
||||
"""
|
||||
__appname__ = "BagheeraView"
|
||||
__version__ = "0.9.13"
|
||||
__version__ = "0.9.14"
|
||||
__author__ = "Ignacio Serantes"
|
||||
__email__ = "kde@aynoa.net"
|
||||
__license__ = "LGPL"
|
||||
@@ -77,7 +77,7 @@ from widgets import (
|
||||
TagEditWidget, LayoutsWidget, HistoryWidget, RatingWidget, CommentWidget,
|
||||
FavoritesWidget
|
||||
)
|
||||
from metadatamanager import XattrManager
|
||||
from metadatamanager import load_common_metadata
|
||||
|
||||
|
||||
class ShortcutHelpDialog(QDialog):
|
||||
@@ -626,19 +626,20 @@ class ThumbnailDelegate(QStyledItemDelegate):
|
||||
|
||||
# Optimization: Use QPixmapCache to avoid expensive QImage->QPixmap
|
||||
# conversion on every paint event.
|
||||
cache_key = f"thumb_{path}_{mtime}_{thumb_size}"
|
||||
actual_tier = self.main_win.cache.get_available_tier(path, thumb_size, mtime)
|
||||
cache_key = f"thumb_{path}_{mtime}_{thumb_size}_{actual_tier}"
|
||||
source_pixmap = QPixmapCache.find(cache_key)
|
||||
|
||||
if not source_pixmap or source_pixmap.isNull():
|
||||
# Not in UI cache, try to get from main thumbnail cache (Memory/LMDB)
|
||||
inode = index.data(INODE_ROLE)
|
||||
device_id = index.data(DEVICE_ROLE)
|
||||
img, _ = self.main_win.cache.get_thumbnail(
|
||||
res = self.main_win.cache.get_thumbnail(
|
||||
path, requested_size=thumb_size, curr_mtime=mtime,
|
||||
inode=inode, device_id=device_id, async_load=True)
|
||||
|
||||
if img and not img.isNull():
|
||||
source_pixmap = QPixmap.fromImage(img)
|
||||
if res.image and not res.image.isNull():
|
||||
source_pixmap = QPixmap.fromImage(res.image)
|
||||
QPixmapCache.insert(cache_key, source_pixmap)
|
||||
else:
|
||||
# Fallback: Check a separate cache key for the placeholder to avoid
|
||||
@@ -3458,26 +3459,27 @@ class MainWindow(QMainWindow):
|
||||
if not path:
|
||||
return
|
||||
|
||||
# Determine tags and rating based on provided metadata or disk read
|
||||
if metadata:
|
||||
tags = metadata.get('tags', [])
|
||||
rating = metadata.get('rating', 0)
|
||||
else:
|
||||
res = load_common_metadata(path)
|
||||
tags, rating = res.tags, res.rating
|
||||
|
||||
# Find the item in the source model and update its data
|
||||
for row in range(self.thumbnail_model.rowCount()):
|
||||
item = self.thumbnail_model.item(row)
|
||||
if item and item.data(PATH_ROLE) == path:
|
||||
# Reload metadata for this item from xattr
|
||||
try:
|
||||
if metadata and 'tags' in metadata:
|
||||
tags = metadata['tags']
|
||||
else: # Fallback to reading from disk if not provided
|
||||
raw = XattrManager.get_attribute(path, XATTR_NAME)
|
||||
tags = sorted(list(set(t.strip() for t in raw.split(',')
|
||||
if t.strip()))) if raw else []
|
||||
item.setData(tags, TAGS_ROLE)
|
||||
except Exception:
|
||||
item.setData([], TAGS_ROLE)
|
||||
try:
|
||||
item.setData(metadata.get('rating', 0)
|
||||
if metadata else 0, RATING_ROLE)
|
||||
except Exception:
|
||||
item.setData(0, RATING_ROLE) # Default to 0 if error
|
||||
item.setData(tags, TAGS_ROLE)
|
||||
item.setData(rating, RATING_ROLE)
|
||||
|
||||
tooltip_text = f"{os.path.basename(path)}\n{path}"
|
||||
if tags:
|
||||
display_tags = [t.split('/')[-1] for t in tags]
|
||||
tooltip_text += f"\n{UITexts.TAGS_TAB}: {', '.join(
|
||||
display_tags)}"
|
||||
item.setToolTip(tooltip_text)
|
||||
|
||||
# Notify the view that the data has changed
|
||||
source_idx = self.thumbnail_model.indexFromItem(item)
|
||||
@@ -3485,13 +3487,10 @@ class MainWindow(QMainWindow):
|
||||
source_idx, source_idx, [TAGS_ROLE, RATING_ROLE])
|
||||
|
||||
# Update internal data structure to prevent stale data on rebuild
|
||||
current_tags = item.data(TAGS_ROLE)
|
||||
current_rating = item.data(RATING_ROLE)
|
||||
self._update_internal_data(path, tags=current_tags,
|
||||
rating=current_rating)
|
||||
self._update_internal_data(path, tags=tags, rating=rating)
|
||||
|
||||
# Update proxy filter cache to prevent stale filtering
|
||||
self.proxy_model.add_to_cache(path, current_tags)
|
||||
self.proxy_model.add_to_cache(path, tags)
|
||||
break
|
||||
|
||||
if self.main_dock.isVisible():
|
||||
@@ -3594,8 +3593,13 @@ class MainWindow(QMainWindow):
|
||||
if not paths:
|
||||
return
|
||||
|
||||
# Prioritize visible paths
|
||||
visible = self.get_visible_image_paths()
|
||||
visible_set = set(visible)
|
||||
ordered_paths = visible + [p for p in paths if p not in visible_set]
|
||||
|
||||
self.thumbnail_generator = ThumbnailGenerator(
|
||||
self.cache, paths, size, self.thread_pool_manager)
|
||||
self.cache, ordered_paths, size, self.thread_pool_manager)
|
||||
self.thumbnail_generator.generation_complete.connect(
|
||||
self.on_high_res_generation_finished)
|
||||
self.thumbnail_generator.progress.connect(
|
||||
|
||||
Reference in New Issue
Block a user