Skip to content

Commit

Permalink
Merge pull request #360 from pfafflabatuiuc/feature/monitr_image_copying
Browse files Browse the repository at this point in the history
Feature/monitr image copying
  • Loading branch information
wpfff committed Dec 8, 2022
2 parents 3635c6c + 135e062 commit bde3338
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions plottr/apps/monitr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2328,9 +2328,28 @@ def __init__(self, path_file: Path, *args: Any, **kwargs: Any):
self.setText(f'Image could not be displayed')
LOGGER.error(e)

self.context_menu = QtWidgets.QMenu(self)

# creating actions
self.copy_action = QtWidgets.QAction('copy')
self.copy_action.triggered.connect(self.on_copy_action)

self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.customContextMenuRequested.connect(self.on_context_menu_requested)
self.context_menu.addAction(self.copy_action)

self.installEventFilter(self)
self.setMinimumWidth(1)

@Slot(QtCore.QPoint)
def on_context_menu_requested(self, pos: QtCore.QPoint) -> None:
self.context_menu.exec_(self.mapToGlobal(pos))

@Slot()
def on_copy_action(self) -> None:
clipboard = QtWidgets.QApplication.clipboard()
clipboard.setImage(self.image)

# FIXME: Instead of detecting when the infinite loop starts occurring and stopping it, figure out exactly what starts
# it and prevent it all together.
def eventFilter(self, a0: QtCore.QObject, a1: QtCore.QEvent) -> bool:
Expand Down

0 comments on commit bde3338

Please sign in to comment.