Skip to content

Commit

Permalink
Add working zoom functions to GraphicsView viewers.
Browse files Browse the repository at this point in the history
  • Loading branch information
glubsy committed Jul 2, 2020
1 parent 9f15139 commit 370b582
Show file tree
Hide file tree
Showing 2 changed files with 373 additions and 108 deletions.
20 changes: 13 additions & 7 deletions qt/pe/details_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _setupUi(self):
# self.horizontalLayout.setColumnStretch(3,0)
self.horizontalLayout.setSpacing(1)

self.selectedImageViewer = ScrollAreaImageViewer(self, "selectedImage")
self.selectedImageViewer = GraphicsViewViewer(self, "selectedImage")
# self.selectedImage = QLabel(self)
# sizePolicy = QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
# sizePolicy.setHorizontalStretch(0)
Expand All @@ -100,6 +100,11 @@ def _setupUi(self):
# self.horizontalLayout.addItem(QSpacerItem(5,0, QSizePolicy.Minimum),
# 1, 3, 1, 1, Qt.Alignment(Qt.AlignRight))

# FIXME make a subclass to initialize buttons later
# FIXME use qwidgetaction to make the popup on resize work -> QWidgetAction::createWidget()
# FIXME figure out why margins are changing when the window is updating (after Normal Size, on resize)
# it seems toggling the scrollbars reduce viewport size and messes up sizeHint returned?
# thus shrinking the space available for the toolbar?
self.verticalToolBar = QToolBar(self)
# self.verticalToolBar.setMaximumWidth(10)
self.verticalToolBar.setOrientation(Qt.Orientation(Qt.Vertical))
Expand Down Expand Up @@ -151,11 +156,12 @@ def _setupUi(self):

self.horizontalLayout.addWidget(self.verticalToolBar, 1, 1, 1, 1, Qt.AlignCenter)

self.referenceImageViewer = ScrollAreaImageViewer(self, "referenceImage")
self.referenceImageViewer = GraphicsViewViewer(self, "referenceImage")
# self.referenceImage = QLabel(self)
# sizePolicy = QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
# sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
# sizePolicy.setHorizontalStretch(0)
# sizePolicy.setVerticalStretch(0)
# self.verticalToolBar.setSizePolicy(sizePolicy)
# sizePolicy.setHeightForWidth(
# self.referenceImage.sizePolicy().hasHeightForWidth()
# )
Expand Down Expand Up @@ -217,6 +223,8 @@ def _setupUi(self):
self)

def _update(self):
if self.vController is None: # Not yet constructed!
return
if not self.app.model.selected_dupes:
# No item from the model, disable and clear everything.
self.vController.resetViewersState()
Expand All @@ -225,8 +233,6 @@ def _update(self):
group = self.app.model.results.get_group_of_duplicate(dupe)
ref = group.ref

if self.vController is None: # Not yet constructed!
return
self.vController.updateView(ref, dupe, group)

# --- Override
Expand Down Expand Up @@ -277,11 +283,11 @@ def swapImages(self):

@pyqtSlot()
def zoomIn(self):
self.vController.scaleImagesBy(1.25)
self.vController.zoomIn()

@pyqtSlot()
def zoomOut(self):
self.vController.scaleImagesBy(0.8)
self.vController.zoomOut()

@pyqtSlot()
def zoomBestFit(self):
Expand Down
Loading

0 comments on commit 370b582

Please sign in to comment.