Fix copy to clipboard — fallback to cached path, always show option

- Ctrl+C tries pixmap then cached file path as fallback
- Preview right-click always shows "Copy Image to Clipboard"
- Works for images and loads from disk for videos
- Status bar shows result count with copy confirmation
This commit is contained in:
pax 2026-04-05 14:24:02 -05:00
parent 4e8cc97876
commit 43a4e1e726
2 changed files with 24 additions and 7 deletions

View File

@ -1898,9 +1898,21 @@ class BooruApp(QMainWindow):
super().keyPressEvent(event)
def _copy_preview_to_clipboard(self) -> None:
if self._preview._image_viewer._pixmap and not self._preview._image_viewer._pixmap.isNull():
QApplication.clipboard().setPixmap(self._preview._image_viewer._pixmap)
self._status.showMessage("Image copied to clipboard")
# Try image viewer pixmap first
pix = self._preview._image_viewer._pixmap
if pix and not pix.isNull():
QApplication.clipboard().setPixmap(pix)
self._status.showMessage(f"{len(self._posts)} results — Copied to clipboard")
return
# Try loading from cached path
path = self._preview._current_path
if path:
pix = QPixmap(path)
if not pix.isNull():
QApplication.clipboard().setPixmap(pix)
self._status.showMessage(f"{len(self._posts)} results — Copied to clipboard")
return
self._status.showMessage(f"{len(self._posts)} results — Nothing to copy")
# -- Bookmarks --

View File

@ -681,9 +681,7 @@ class ImagePreview(QWidget):
save_new = save_menu.addAction("+ New Folder...")
menu.addSeparator()
copy_image = None
if self._stack.currentIndex() == 0 and self._image_viewer._pixmap:
copy_image = menu.addAction("Copy Image to Clipboard")
copy_image = menu.addAction("Copy Image to Clipboard")
open_action = menu.addAction("Open in Default App")
browser_action = menu.addAction("Open in Browser")
@ -715,7 +713,14 @@ class ImagePreview(QWidget):
self.save_to_folder.emit(save_folder_actions[id(action)])
elif action == copy_image:
from PySide6.QtWidgets import QApplication
QApplication.clipboard().setPixmap(self._image_viewer._pixmap)
from PySide6.QtGui import QPixmap as _QP
pix = self._image_viewer._pixmap
if pix and not pix.isNull():
QApplication.clipboard().setPixmap(pix)
elif self._current_path:
pix = _QP(self._current_path)
if not pix.isNull():
QApplication.clipboard().setPixmap(pix)
elif action == open_action:
self.open_in_default.emit()
elif action == browser_action: