Skip to content

Commit

Permalink
Fixing zoom actions
Browse files Browse the repository at this point in the history
  • Loading branch information
bordaigorl committed May 3, 2020
1 parent 9258e27 commit 4670c29
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ def __init__(self):
self.menu.addAction(act)
###
act = QAction('Zoom In', self)
act.triggered.connect(lambda: self.scale(self.zoomInFactor, self.zoomInFactor))
act.triggered.connect(self.zoomIn)
self.menu.addAction(act)
###
act = QAction('Zoom Out', self)
act.triggered.connect(lambda: self.scale(self.zoomOutFactor, self.zoomOutFactor))
act.triggered.connect(self.zoomOut)
self.menu.addAction(act)
###
self.menu.addSeparator() # --------------------------
Expand Down Expand Up @@ -160,6 +160,14 @@ def rotateCCW(self):
self._rotation -= 90
self.updateViewer()

def zoomIn(self):
self._fit = False
self.scale(self.zoomInFactor, self.zoomInFactor)

def zoomOut(self):
self._fit = False
self.scale(self.zoomOutFactor, self.zoomOutFactor)

def setFit(self, f):
self._fit = f
self.updateViewer()
Expand All @@ -182,7 +190,7 @@ def keyPressEvent(self, event):
elif event.key() == Qt.Key_S:
self.screenshot()
elif event.key() == Qt.Key_Plus:
self.scale(self.zoomInFactor, self.zoomInFactor)
self.zoomIn()
elif event.key() == Qt.Key_Minus:
self.scale(self.zoomOutFactor, self.zoomOutFactor)
self.zoomOut()

0 comments on commit 4670c29

Please sign in to comment.