2016-06-01 01:59:31 +00:00
|
|
|
# Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
|
|
|
|
#
|
|
|
|
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
|
|
|
# which should be included with this package. The terms are also available at
|
2015-01-03 21:33:16 +00:00
|
|
|
# http://www.gnu.org/licenses/gpl-3.0.html
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2020-06-05 20:39:16 +00:00
|
|
|
from PyQt5.QtCore import Qt, QSize, pyqtSlot, pyqtSignal
|
|
|
|
from PyQt5.QtGui import QPixmap, QIcon, QKeySequence
|
2020-01-01 02:16:27 +00:00
|
|
|
from PyQt5.QtWidgets import (
|
|
|
|
QVBoxLayout,
|
|
|
|
QAbstractItemView,
|
|
|
|
QHBoxLayout,
|
|
|
|
QLabel,
|
|
|
|
QSizePolicy,
|
2020-05-01 16:22:25 +00:00
|
|
|
QToolBar,
|
|
|
|
QToolButton,
|
|
|
|
QGridLayout,
|
|
|
|
QStyle,
|
2020-05-02 16:05:19 +00:00
|
|
|
QAction,
|
|
|
|
QWidget,
|
2020-06-04 00:33:54 +00:00
|
|
|
QApplication,
|
2020-01-01 02:16:27 +00:00
|
|
|
)
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2011-11-01 19:44:18 +00:00
|
|
|
from hscommon.trans import trget
|
2020-05-02 00:29:23 +00:00
|
|
|
from hscommon import desktop
|
2016-06-01 01:59:31 +00:00
|
|
|
from ..details_dialog import DetailsDialog as DetailsDialogBase
|
|
|
|
from ..details_table import DetailsTable
|
2020-05-01 16:22:25 +00:00
|
|
|
from qtlib.util import createActions
|
2020-06-05 20:39:16 +00:00
|
|
|
from qt.pe.image_viewer import ImageViewer
|
2020-01-01 02:16:27 +00:00
|
|
|
tr = trget("ui")
|
|
|
|
|
2010-10-04 13:29:00 +00:00
|
|
|
class DetailsDialog(DetailsDialogBase):
|
2009-06-01 09:55:11 +00:00
|
|
|
def __init__(self, parent, app):
|
2020-06-04 00:33:54 +00:00
|
|
|
super().__init__(parent, app)
|
2020-06-05 20:39:16 +00:00
|
|
|
self.selectedPixmap = QPixmap()
|
|
|
|
self.referencePixmap = QPixmap()
|
|
|
|
self.scaledSelectedPixmap = QPixmap()
|
|
|
|
self.scaledReferencePixmap = QPixmap()
|
2020-05-02 13:09:01 +00:00
|
|
|
self.scaleFactor = 1.0
|
2020-06-04 00:33:54 +00:00
|
|
|
self.bestFit = True
|
2020-05-01 16:22:25 +00:00
|
|
|
|
2020-06-04 00:33:54 +00:00
|
|
|
def setupActions(self):
|
2020-05-01 16:22:25 +00:00
|
|
|
# (name, shortcut, icon, desc, func)
|
|
|
|
ACTIONS = [
|
|
|
|
(
|
2020-06-04 00:33:54 +00:00
|
|
|
# FIXME probably not used right now
|
2020-05-01 16:22:25 +00:00
|
|
|
"actionSwap",
|
|
|
|
QKeySequence.Backspace,
|
|
|
|
"swap",
|
|
|
|
tr("Swap images"),
|
|
|
|
self.swapImages,
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"actionZoomIn",
|
|
|
|
QKeySequence.ZoomIn,
|
|
|
|
"zoom-in",
|
|
|
|
tr("Increase zoom factor"),
|
|
|
|
self.zoomIn,
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"actionZoomOut",
|
|
|
|
QKeySequence.ZoomOut,
|
|
|
|
"zoom-out",
|
|
|
|
tr("Decrease zoom factor"),
|
|
|
|
self.zoomOut,
|
|
|
|
),
|
|
|
|
(
|
2020-05-02 13:09:01 +00:00
|
|
|
"actionNormalSize",
|
|
|
|
QKeySequence.Refresh,
|
|
|
|
"zoom-normal",
|
|
|
|
tr("Normal size"),
|
|
|
|
self.zoomNormalSize,
|
2020-05-02 16:05:19 +00:00
|
|
|
),
|
2020-05-02 13:09:01 +00:00
|
|
|
(
|
|
|
|
"actionBestFit",
|
2020-06-04 00:33:54 +00:00
|
|
|
tr("Ctrl+p"),
|
2020-05-01 16:22:25 +00:00
|
|
|
"zoom-reset",
|
2020-05-02 13:09:01 +00:00
|
|
|
tr("Best fit"),
|
|
|
|
self.zoomBestFit,
|
2020-05-01 16:22:25 +00:00
|
|
|
)
|
|
|
|
]
|
|
|
|
createActions(ACTIONS, self)
|
|
|
|
|
2010-02-05 20:09:04 +00:00
|
|
|
def _setupUi(self):
|
2020-06-04 00:33:54 +00:00
|
|
|
self.setupActions()
|
2011-01-21 12:57:54 +00:00
|
|
|
self.setWindowTitle(tr("Details"))
|
2010-10-04 13:29:00 +00:00
|
|
|
self.resize(502, 295)
|
|
|
|
self.setMinimumSize(QSize(250, 250))
|
|
|
|
self.verticalLayout = QVBoxLayout(self)
|
|
|
|
self.verticalLayout.setSpacing(0)
|
2013-11-16 18:38:07 +00:00
|
|
|
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
|
2020-05-01 16:22:25 +00:00
|
|
|
# self.horizontalLayout = QHBoxLayout()
|
|
|
|
self.horizontalLayout = QGridLayout()
|
|
|
|
self.horizontalLayout.setColumnMinimumWidth(1, 30)
|
|
|
|
self.horizontalLayout.setColumnStretch(0,1)
|
|
|
|
self.horizontalLayout.setColumnStretch(1,0)
|
|
|
|
self.horizontalLayout.setColumnStretch(2,1)
|
2010-10-04 13:29:00 +00:00
|
|
|
self.horizontalLayout.setSpacing(4)
|
2020-06-04 00:33:54 +00:00
|
|
|
|
2020-06-05 20:39:16 +00:00
|
|
|
self.selectedImage = ImageViewer(self, "selectedImage")
|
2020-05-02 16:05:19 +00:00
|
|
|
# self.selectedImage = QLabel(self)
|
|
|
|
# sizePolicy = QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
|
|
|
|
# sizePolicy.setHorizontalStretch(0)
|
|
|
|
# sizePolicy.setVerticalStretch(0)
|
|
|
|
# sizePolicy.setHeightForWidth(
|
|
|
|
# self.selectedImage.sizePolicy().hasHeightForWidth()
|
|
|
|
# )
|
|
|
|
# self.selectedImage.setSizePolicy(sizePolicy)
|
|
|
|
# self.selectedImage.setScaledContents(False)
|
|
|
|
# self.selectedImage.setAlignment(Qt.AlignCenter)
|
|
|
|
# # self.horizontalLayout.addWidget(self.selectedImage)
|
2020-05-01 16:22:25 +00:00
|
|
|
self.horizontalLayout.addWidget(self.selectedImage, 0, 0, 3, 1)
|
|
|
|
|
|
|
|
self.verticalToolBar = QToolBar(self)
|
|
|
|
self.verticalToolBar.setOrientation(Qt.Orientation(2))
|
|
|
|
# self.subVLayout = QVBoxLayout(self)
|
|
|
|
# self.subVLayout.addWidget(self.verticalToolBar)
|
|
|
|
# self.horizontalLayout.addLayout(self.subVLayout)
|
|
|
|
|
|
|
|
self.buttonImgSwap = QToolButton(self.verticalToolBar)
|
|
|
|
self.buttonImgSwap.setToolButtonStyle(Qt.ToolButtonIconOnly)
|
|
|
|
self.buttonImgSwap.setIcon(QIcon.fromTheme('document-revert', \
|
|
|
|
self.style().standardIcon(QStyle.SP_BrowserReload)))
|
|
|
|
self.buttonImgSwap.setText('Swap images')
|
2020-06-04 00:33:54 +00:00
|
|
|
self.buttonImgSwap.setToolTip('Swap images')
|
2020-05-01 16:22:25 +00:00
|
|
|
self.buttonImgSwap.pressed.connect(self.swapImages)
|
2020-06-04 00:33:54 +00:00
|
|
|
self.buttonImgSwap.released.connect(self.deswapImages)
|
2020-05-01 16:22:25 +00:00
|
|
|
|
|
|
|
self.buttonZoomIn = QToolButton(self.verticalToolBar)
|
|
|
|
self.buttonZoomIn.setToolButtonStyle(Qt.ToolButtonIconOnly)
|
|
|
|
self.buttonZoomIn.setDefaultAction(self.actionZoomIn)
|
|
|
|
self.buttonZoomIn.setText('ZoomIn')
|
|
|
|
self.buttonZoomIn.setIcon(QIcon.fromTheme(('zoom-in'), QIcon(":images/zoom-in.png")))
|
|
|
|
|
|
|
|
self.buttonZoomOut = QToolButton(self.verticalToolBar)
|
|
|
|
self.buttonZoomOut.setToolButtonStyle(Qt.ToolButtonIconOnly)
|
|
|
|
self.buttonZoomOut.setDefaultAction(self.actionZoomOut)
|
|
|
|
self.buttonZoomOut.setText('ZoomOut')
|
|
|
|
self.buttonZoomOut.setIcon(QIcon.fromTheme('zoom-out'))
|
|
|
|
self.buttonZoomOut.setEnabled(False)
|
|
|
|
|
2020-05-02 13:09:01 +00:00
|
|
|
self.buttonNormalSize = QToolButton(self.verticalToolBar)
|
|
|
|
self.buttonNormalSize.setToolButtonStyle(Qt.ToolButtonIconOnly)
|
|
|
|
self.buttonNormalSize.setDefaultAction(self.actionNormalSize)
|
|
|
|
self.buttonNormalSize.setText('Normal Size')
|
|
|
|
self.buttonNormalSize.setIcon(QIcon.fromTheme('zoom-original'))
|
|
|
|
self.buttonNormalSize.setEnabled(True)
|
|
|
|
|
|
|
|
self.buttonBestFit = QToolButton(self.verticalToolBar)
|
|
|
|
self.buttonBestFit.setToolButtonStyle(Qt.ToolButtonIconOnly)
|
2020-05-02 16:05:19 +00:00
|
|
|
self.buttonBestFit.setDefaultAction(self.actionBestFit)
|
2020-05-02 13:09:01 +00:00
|
|
|
self.buttonBestFit.setText('BestFit')
|
|
|
|
self.buttonBestFit.setIcon(QIcon.fromTheme('zoom-best-fit'))
|
|
|
|
self.buttonBestFit.setEnabled(False)
|
2020-05-01 16:22:25 +00:00
|
|
|
|
|
|
|
self.verticalToolBar.addWidget(self.buttonImgSwap)
|
|
|
|
self.verticalToolBar.addWidget(self.buttonZoomIn)
|
|
|
|
self.verticalToolBar.addWidget(self.buttonZoomOut)
|
2020-05-02 13:09:01 +00:00
|
|
|
self.verticalToolBar.addWidget(self.buttonNormalSize)
|
|
|
|
self.verticalToolBar.addWidget(self.buttonBestFit)
|
2020-05-01 16:22:25 +00:00
|
|
|
|
|
|
|
self.horizontalLayout.addWidget(self.verticalToolBar, 1, 1, 1, 1, Qt.AlignCenter)
|
|
|
|
# self.horizontalLayout.addWidget(self.verticalToolBar, Qt.AlignVCenter)
|
|
|
|
|
2020-06-05 20:39:16 +00:00
|
|
|
self.referenceImage = ImageViewer(self, "referenceImage")
|
2020-06-04 00:33:54 +00:00
|
|
|
# self.referenceImage = QLabel(self)
|
|
|
|
# sizePolicy = QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
|
|
|
|
# sizePolicy.setHorizontalStretch(0)
|
|
|
|
# sizePolicy.setVerticalStretch(0)
|
|
|
|
# sizePolicy.setHeightForWidth(
|
|
|
|
# self.referenceImage.sizePolicy().hasHeightForWidth()
|
|
|
|
# )
|
|
|
|
# self.referenceImage.setSizePolicy(sizePolicy)
|
|
|
|
# self.referenceImage.setAlignment(Qt.AlignCenter)
|
2020-05-01 16:22:25 +00:00
|
|
|
self.horizontalLayout.addWidget(self.referenceImage, 0, 2, 3, 1)
|
|
|
|
# self.horizontalLayout.addWidget(self.referenceImage)
|
2010-10-04 13:29:00 +00:00
|
|
|
self.verticalLayout.addLayout(self.horizontalLayout)
|
|
|
|
self.tableView = DetailsTable(self)
|
|
|
|
sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
|
|
|
|
sizePolicy.setHorizontalStretch(0)
|
|
|
|
sizePolicy.setVerticalStretch(0)
|
|
|
|
sizePolicy.setHeightForWidth(self.tableView.sizePolicy().hasHeightForWidth())
|
|
|
|
self.tableView.setSizePolicy(sizePolicy)
|
|
|
|
self.tableView.setMinimumSize(QSize(0, 188))
|
|
|
|
self.tableView.setMaximumSize(QSize(16777215, 190))
|
|
|
|
self.tableView.setAlternatingRowColors(True)
|
|
|
|
self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows)
|
|
|
|
self.tableView.setShowGrid(False)
|
|
|
|
self.verticalLayout.addWidget(self.tableView)
|
2016-06-01 01:59:31 +00:00
|
|
|
|
2020-06-05 20:39:16 +00:00
|
|
|
self.disable_buttons()
|
2020-06-04 15:38:28 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def _update(self):
|
2020-06-05 20:39:16 +00:00
|
|
|
print("_update()")
|
2011-09-20 19:06:29 +00:00
|
|
|
if not self.app.model.selected_dupes:
|
2020-06-05 20:39:16 +00:00
|
|
|
self.clear_all()
|
2009-06-01 09:55:11 +00:00
|
|
|
return
|
2011-09-20 19:06:29 +00:00
|
|
|
dupe = self.app.model.selected_dupes[0]
|
|
|
|
group = self.app.model.results.get_group_of_duplicate(dupe)
|
2009-06-01 09:55:11 +00:00
|
|
|
ref = group.ref
|
2016-06-01 01:59:31 +00:00
|
|
|
|
2020-06-04 00:33:54 +00:00
|
|
|
self.resetState()
|
2010-08-11 14:39:06 +00:00
|
|
|
self.selectedPixmap = QPixmap(str(dupe.path))
|
2020-06-05 20:39:16 +00:00
|
|
|
if ref is dupe: # currently selected file is the ref
|
|
|
|
self.referencePixmap = QPixmap()
|
|
|
|
self.scaledReferencePixmap = QPixmap()
|
2020-05-01 16:22:25 +00:00
|
|
|
self.buttonImgSwap.setEnabled(False)
|
2020-06-05 20:39:16 +00:00
|
|
|
# disable the blank widget.
|
|
|
|
self.disable_widget(self.referenceImage)
|
2009-06-01 09:55:11 +00:00
|
|
|
else:
|
2010-08-11 14:39:06 +00:00
|
|
|
self.referencePixmap = QPixmap(str(ref.path))
|
2020-05-01 16:22:25 +00:00
|
|
|
self.buttonImgSwap.setEnabled(True)
|
2020-06-05 20:39:16 +00:00
|
|
|
self.enable_widget(self.referenceImage)
|
|
|
|
|
|
|
|
self.update_selected_widget()
|
|
|
|
self.update_reference_widget()
|
2016-06-01 01:59:31 +00:00
|
|
|
|
2020-05-02 13:09:01 +00:00
|
|
|
self._updateImages()
|
2020-05-02 00:29:23 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def _updateImages(self):
|
2020-06-04 00:33:54 +00:00
|
|
|
target_size = None
|
2020-06-05 20:39:16 +00:00
|
|
|
if self.selectedPixmap.isNull():
|
|
|
|
# self.disable_widget(self.selectedImage, self.referenceImage)
|
|
|
|
pass
|
|
|
|
else:
|
2009-06-01 09:55:11 +00:00
|
|
|
target_size = self.selectedImage.size()
|
2020-06-04 00:33:54 +00:00
|
|
|
if not self.bestFit:
|
|
|
|
# zoomed in state, expand
|
|
|
|
self.scaledSelectedPixmap = self.selectedPixmap.scaled(
|
|
|
|
target_size, Qt.KeepAspectRatioByExpanding, Qt.SmoothTransformation)
|
2020-06-05 20:39:16 +00:00
|
|
|
else:
|
|
|
|
# best fit, keep ratio always
|
2020-06-04 00:33:54 +00:00
|
|
|
self.scaledSelectedPixmap = self.selectedPixmap.scaled(
|
2020-05-02 00:29:23 +00:00
|
|
|
target_size, Qt.KeepAspectRatio, Qt.SmoothTransformation)
|
2020-06-04 00:33:54 +00:00
|
|
|
self.selectedImage.setPixmap(self.scaledSelectedPixmap)
|
2020-05-02 00:29:23 +00:00
|
|
|
|
2020-06-05 20:39:16 +00:00
|
|
|
if self.referencePixmap.isNull():
|
|
|
|
# self.disable_widget(self.referenceImage, self.selectedImage)
|
|
|
|
pass
|
|
|
|
else:
|
2020-06-04 00:33:54 +00:00
|
|
|
# the selectedImage viewer widget sometimes ends up being bigger
|
|
|
|
# than the referenceImage viewer, which distorts by one pixel the
|
|
|
|
# scaled down pixmap for the reference, hence we'll reuse its size here.
|
|
|
|
# target_size = self.selectedImage.size()
|
|
|
|
if not self.bestFit:
|
|
|
|
self.scaledReferencePixmap = self.referencePixmap.scaled(
|
|
|
|
target_size, Qt.KeepAspectRatioByExpanding, Qt.SmoothTransformation)
|
2020-05-02 00:29:23 +00:00
|
|
|
else:
|
2020-06-04 00:33:54 +00:00
|
|
|
self.scaledReferencePixmap = self.referencePixmap.scaled(
|
2020-05-02 00:29:23 +00:00
|
|
|
target_size, Qt.KeepAspectRatio, Qt.SmoothTransformation)
|
2020-06-04 00:33:54 +00:00
|
|
|
self.referenceImage.setPixmap(self.scaledReferencePixmap)
|
2020-06-05 20:39:16 +00:00
|
|
|
|
|
|
|
def update_selected_widget(self):
|
|
|
|
print("update_selected_widget()")
|
|
|
|
if not self.selectedPixmap.isNull():
|
|
|
|
self.enable_widget(self.selectedImage)
|
|
|
|
self.connect_signal(self.selectedImage, self.referenceImage)
|
|
|
|
else:
|
|
|
|
self.disable_widget(self.selectedImage)
|
|
|
|
self.disconnect_signal(self.referenceImage)
|
|
|
|
|
|
|
|
def update_reference_widget(self):
|
|
|
|
print("update_reference_widget()")
|
|
|
|
if not self.referencePixmap.isNull():
|
|
|
|
self.enable_widget(self.referenceImage)
|
|
|
|
self.connect_signal(self.referenceImage, self.selectedImage)
|
2009-10-03 12:29:16 +00:00
|
|
|
else:
|
2020-06-05 20:39:16 +00:00
|
|
|
self.disable_widget(self.referenceImage)
|
|
|
|
self.disconnect_signal(self.selectedImage)
|
|
|
|
|
|
|
|
def enable_widget(self, widget):
|
|
|
|
"""We want to receive signals from the other_widget."""
|
|
|
|
print(f"enable_widget({widget})")
|
|
|
|
if not widget.isEnabled():
|
|
|
|
widget.setEnabled(True)
|
|
|
|
|
|
|
|
def disable_widget(self, widget):
|
|
|
|
"""Disables this widget and prevents receiving signals from other_widget."""
|
|
|
|
print(f"disable_widget({widget})")
|
|
|
|
widget.setPixmap(QPixmap())
|
|
|
|
widget.setDisabled(True)
|
|
|
|
|
|
|
|
def connect_signal(self, widget, other_widget):
|
|
|
|
"""We want this widget to send its signal to the other_widget."""
|
|
|
|
print(f"connect_signal({widget}, {other_widget})")
|
|
|
|
if widget.connection is None:
|
|
|
|
if other_widget.isEnabled():
|
|
|
|
widget.connection = widget.mouseMoved.connect(other_widget.slot_paint_event)
|
|
|
|
print(f"Connected signal from {widget} to slot of {other_widget}")
|
|
|
|
|
|
|
|
def disconnect_signal(self, other_widget):
|
|
|
|
"""We don't want this widget to send its signal anymore to the other_widget."""
|
|
|
|
print(f"disconnect_signal({other_widget}")
|
|
|
|
if other_widget.connection:
|
|
|
|
other_widget.mouseMoved.disconnect()
|
|
|
|
other_widget.connection = None
|
|
|
|
print(f"Disconnected signal from {other_widget}")
|
|
|
|
|
|
|
|
def resetState(self):
|
|
|
|
self.referencePixmap = QPixmap()
|
|
|
|
self.scaledReferencePixmap = QPixmap()
|
|
|
|
self.selectedPixmap = QPixmap()
|
|
|
|
self.scaledSelectedPixmap = QPixmap()
|
|
|
|
self.buttonZoomIn.setEnabled(False)
|
|
|
|
self.buttonZoomOut.setEnabled(False)
|
|
|
|
self.buttonBestFit.setEnabled(False) # active mode by default
|
|
|
|
self.buttonNormalSize.setEnabled(True)
|
|
|
|
self.bestFit = True
|
|
|
|
self.scaleFactor = 1.0
|
|
|
|
self.referenceImage.setCenter()
|
|
|
|
self.selectedImage.setCenter()
|
|
|
|
|
|
|
|
def clear_all(self):
|
|
|
|
"""No item from the model, disable and clear everything."""
|
|
|
|
self.resetState()
|
|
|
|
|
|
|
|
self.selectedPixmap = QPixmap()
|
|
|
|
self.scaledSelectedPixmap = QPixmap()
|
|
|
|
self.selectedImage.setPixmap(QPixmap())
|
|
|
|
self.selectedImage.setDisabled(True)
|
|
|
|
|
|
|
|
self.referencePixmap = QPixmap()
|
|
|
|
self.scaledReferencePixmap = QPixmap()
|
|
|
|
self.referenceImage.setPixmap(QPixmap())
|
|
|
|
self.referenceImage.setDisabled(True)
|
|
|
|
|
|
|
|
self.buttonImgSwap.setDisabled(True)
|
|
|
|
self.buttonNormalSize.setDisabled(True)
|
|
|
|
|
|
|
|
def disable_buttons(self):
|
|
|
|
self.buttonImgSwap.setEnabled(False)
|
|
|
|
self.buttonZoomIn.setEnabled(False)
|
|
|
|
self.buttonZoomOut.setEnabled(False)
|
|
|
|
self.buttonNormalSize.setEnabled(False)
|
|
|
|
self.buttonBestFit.setEnabled(False)
|
2016-06-01 01:59:31 +00:00
|
|
|
|
2020-01-01 02:16:27 +00:00
|
|
|
# --- Override
|
2009-06-01 09:55:11 +00:00
|
|
|
def resizeEvent(self, event):
|
2020-06-04 00:33:54 +00:00
|
|
|
if not self.bestFit:
|
|
|
|
return
|
2009-06-01 09:55:11 +00:00
|
|
|
self._updateImages()
|
2016-06-01 01:59:31 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def show(self):
|
2020-06-05 20:39:16 +00:00
|
|
|
print("show()")
|
2010-02-05 20:09:04 +00:00
|
|
|
DetailsDialogBase.show(self)
|
2009-06-01 09:55:11 +00:00
|
|
|
self._update()
|
2016-06-01 01:59:31 +00:00
|
|
|
|
2010-02-05 20:09:04 +00:00
|
|
|
# model --> view
|
|
|
|
def refresh(self):
|
2020-06-05 20:39:16 +00:00
|
|
|
print("refresh()")
|
2010-02-05 20:09:04 +00:00
|
|
|
DetailsDialogBase.refresh(self)
|
2009-06-01 09:55:11 +00:00
|
|
|
if self.isVisible():
|
|
|
|
self._update()
|
2020-05-01 16:22:25 +00:00
|
|
|
|
2020-06-05 20:39:16 +00:00
|
|
|
# ImageViewers
|
2020-05-01 16:22:25 +00:00
|
|
|
def scaleImages(self, factor):
|
2020-06-04 00:33:54 +00:00
|
|
|
self.scaleFactor *= factor
|
2020-05-02 13:09:01 +00:00
|
|
|
|
2020-06-05 20:39:16 +00:00
|
|
|
print(f'QDialog scaleFactor = {self.scaleFactor} (+factor {factor})')
|
2020-05-02 13:09:01 +00:00
|
|
|
|
2020-06-04 00:33:54 +00:00
|
|
|
self.referenceImage.scale(self.scaleFactor)
|
|
|
|
self.selectedImage.scale(self.scaleFactor)
|
|
|
|
|
2020-06-04 15:38:28 +00:00
|
|
|
self.buttonZoomIn.setEnabled(self.scaleFactor < 16.0)
|
2020-06-04 00:33:54 +00:00
|
|
|
self.buttonZoomOut.setEnabled(self.scaleFactor > 1.0)
|
|
|
|
self.buttonBestFit.setEnabled(self.bestFit is False)
|
|
|
|
self.buttonNormalSize.setEnabled(self.scaleFactor != 1.0)
|
2020-05-01 16:22:25 +00:00
|
|
|
|
2020-06-04 00:33:54 +00:00
|
|
|
@pyqtSlot()
|
2020-05-01 16:22:25 +00:00
|
|
|
def swapImages(self):
|
2020-06-05 20:39:16 +00:00
|
|
|
"""Swap pixmaps between ImageViewers."""
|
2020-06-04 00:33:54 +00:00
|
|
|
if self.bestFit:
|
|
|
|
self.selectedImage.setPixmap(self.scaledReferencePixmap)
|
|
|
|
self.referenceImage.setPixmap(self.scaledSelectedPixmap)
|
|
|
|
else:
|
|
|
|
self.selectedImage.setPixmap(self.referencePixmap)
|
|
|
|
self.referenceImage.setPixmap(self.selectedPixmap)
|
|
|
|
|
2020-05-01 16:22:25 +00:00
|
|
|
# swap the columns in the details table as well
|
|
|
|
self.tableView.horizontalHeader().swapSections(1, 2)
|
|
|
|
|
2020-06-04 00:33:54 +00:00
|
|
|
@pyqtSlot()
|
|
|
|
def deswapImages(self):
|
2020-06-05 20:39:16 +00:00
|
|
|
"""Restore swapped pixmaps between ImageViewers."""
|
2020-06-04 00:33:54 +00:00
|
|
|
if self.bestFit:
|
|
|
|
self.selectedImage.setPixmap(self.scaledSelectedPixmap)
|
|
|
|
self.referenceImage.setPixmap(self.scaledReferencePixmap)
|
|
|
|
else:
|
|
|
|
self.selectedImage.setPixmap(self.selectedPixmap)
|
|
|
|
self.referenceImage.setPixmap(self.referencePixmap)
|
|
|
|
|
|
|
|
self.tableView.horizontalHeader().swapSections(1, 2)
|
|
|
|
|
|
|
|
@pyqtSlot()
|
2020-05-01 16:22:25 +00:00
|
|
|
def zoomIn(self):
|
2020-05-02 13:09:01 +00:00
|
|
|
self.scaleImages(1.25)
|
2020-05-01 16:22:25 +00:00
|
|
|
|
2020-06-04 00:33:54 +00:00
|
|
|
@pyqtSlot()
|
2020-05-01 16:22:25 +00:00
|
|
|
def zoomOut(self):
|
2020-05-02 13:09:01 +00:00
|
|
|
self.scaleImages(0.8)
|
|
|
|
|
2020-06-04 00:33:54 +00:00
|
|
|
@pyqtSlot()
|
|
|
|
def scale_to_bestfit(self):
|
|
|
|
self.referenceImage.scale(self.scaleFactor)
|
|
|
|
self.selectedImage.scale(self.scaleFactor)
|
2020-06-04 15:38:28 +00:00
|
|
|
self.referenceImage.setCenter()
|
|
|
|
self.selectedImage.setCenter()
|
2020-06-04 00:33:54 +00:00
|
|
|
self._updateImages()
|
2020-05-01 16:22:25 +00:00
|
|
|
|
2020-06-04 00:33:54 +00:00
|
|
|
@pyqtSlot()
|
2020-05-02 13:09:01 +00:00
|
|
|
def zoomBestFit(self):
|
2020-06-04 00:33:54 +00:00
|
|
|
self.bestFit = True
|
2020-05-02 13:09:01 +00:00
|
|
|
self.scaleFactor = 1.0
|
|
|
|
self.buttonBestFit.setEnabled(False)
|
2020-05-01 16:22:25 +00:00
|
|
|
self.buttonZoomOut.setEnabled(False)
|
2020-06-04 00:33:54 +00:00
|
|
|
self.buttonZoomIn.setEnabled(False)
|
|
|
|
self.buttonNormalSize.setEnabled(True)
|
|
|
|
self.scale_to_bestfit()
|
|
|
|
|
|
|
|
@pyqtSlot()
|
|
|
|
def zoomNormalSize(self):
|
|
|
|
self.bestFit = False
|
|
|
|
self.scaleFactor = 1.0
|
|
|
|
|
|
|
|
self.selectedImage.setPixmap(self.selectedPixmap)
|
2020-06-05 20:39:16 +00:00
|
|
|
self.referenceImage.setPixmap(self.referencePixmap)
|
2020-05-01 16:22:25 +00:00
|
|
|
|
2020-06-04 00:33:54 +00:00
|
|
|
self.selectedImage.pixmapReset()
|
|
|
|
self.referenceImage.pixmapReset()
|
2020-06-05 20:39:16 +00:00
|
|
|
|
|
|
|
self.update_selected_widget()
|
|
|
|
self.update_reference_widget()
|
2020-06-04 00:33:54 +00:00
|
|
|
|
|
|
|
self.buttonNormalSize.setEnabled(False)
|
|
|
|
self.buttonZoomIn.setEnabled(True)
|
|
|
|
self.buttonZoomOut.setEnabled(True)
|
|
|
|
self.buttonBestFit.setEnabled(True)
|