Skip to content

Commit

Permalink
Merge pull request #142 from maunke/feature/screenshot-to-clipboard
Browse files Browse the repository at this point in the history
Add screenshot to clipboard action
  • Loading branch information
bordaigorl authored Aug 24, 2022
2 parents 396acde + 61122f1 commit 9a48de1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/rmview/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ def __init__(self):
self.screenshotAction.triggered.connect(self.screenshot)
self.addAction(self.screenshotAction)
###
self.screenshotToClipboardAction = QAction('Copy screenshot', self)
self.screenshotToClipboardAction.setShortcut(QKeySequence.Copy)
self.screenshotToClipboardAction.triggered.connect(self.screenshotToClipboard)
self.addAction(self.screenshotToClipboardAction)

self.menu = QMenu(self)
self.menu.addAction(self.fitAction)
Expand All @@ -92,6 +96,8 @@ def __init__(self):
self.menu.addAction(self.invertColorsAction)
self.menu.addSeparator() # --------------------------
self.menu.addAction(self.screenshotAction)
self.menu.addAction(self.screenshotToClipboardAction)
self.menu.addSeparator() # --------------------------

def contextMenuEvent(self, event):
self.fitAction.setChecked(self._fit)
Expand Down Expand Up @@ -214,6 +220,12 @@ def screenshot(self):
img = img.transformed(QTransform().rotate(self._rotation))
img.save(fileName)

def screenshotToClipboard(self):
img = self.image()
if img is not None:
img = img.transformed(QTransform().rotate(self._rotation))
QApplication.clipboard().setImage(img)

def invertColors(self):
self._invert_colors = not self._invert_colors
if self._pixmap:
Expand Down

0 comments on commit 9a48de1

Please sign in to comment.