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:
parent
4e8cc97876
commit
43a4e1e726
@ -1898,9 +1898,21 @@ class BooruApp(QMainWindow):
|
|||||||
super().keyPressEvent(event)
|
super().keyPressEvent(event)
|
||||||
|
|
||||||
def _copy_preview_to_clipboard(self) -> None:
|
def _copy_preview_to_clipboard(self) -> None:
|
||||||
if self._preview._image_viewer._pixmap and not self._preview._image_viewer._pixmap.isNull():
|
# Try image viewer pixmap first
|
||||||
QApplication.clipboard().setPixmap(self._preview._image_viewer._pixmap)
|
pix = self._preview._image_viewer._pixmap
|
||||||
self._status.showMessage("Image copied to clipboard")
|
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 --
|
# -- Bookmarks --
|
||||||
|
|
||||||
|
|||||||
@ -681,9 +681,7 @@ class ImagePreview(QWidget):
|
|||||||
save_new = save_menu.addAction("+ New Folder...")
|
save_new = save_menu.addAction("+ New Folder...")
|
||||||
|
|
||||||
menu.addSeparator()
|
menu.addSeparator()
|
||||||
copy_image = None
|
copy_image = menu.addAction("Copy Image to Clipboard")
|
||||||
if self._stack.currentIndex() == 0 and self._image_viewer._pixmap:
|
|
||||||
copy_image = menu.addAction("Copy Image to Clipboard")
|
|
||||||
open_action = menu.addAction("Open in Default App")
|
open_action = menu.addAction("Open in Default App")
|
||||||
browser_action = menu.addAction("Open in Browser")
|
browser_action = menu.addAction("Open in Browser")
|
||||||
|
|
||||||
@ -715,7 +713,14 @@ class ImagePreview(QWidget):
|
|||||||
self.save_to_folder.emit(save_folder_actions[id(action)])
|
self.save_to_folder.emit(save_folder_actions[id(action)])
|
||||||
elif action == copy_image:
|
elif action == copy_image:
|
||||||
from PySide6.QtWidgets import QApplication
|
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:
|
elif action == open_action:
|
||||||
self.open_in_default.emit()
|
self.open_in_default.emit()
|
||||||
elif action == browser_action:
|
elif action == browser_action:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user