mirror of
https://github.com/arsenetar/dupeguru.git
synced 2024-11-18 13:09:02 +00:00
a8a601ec36
--HG-- extra : convert_revision : svn%3Ac306627e-7827-47d3-bdf0-9a457c9553a1/trunk%40100
64 lines
2.2 KiB
Python
64 lines
2.2 KiB
Python
# Created By: Virgil Dupras
|
|
# Created On: 2009-04-27
|
|
# $Id$
|
|
# Copyright 2009 Hardcoded Software (http://www.hardcoded.net)
|
|
#
|
|
# This software is licensed under the "HS" License as described in the "LICENSE" file,
|
|
# which should be included with this package. The terms are also available at
|
|
# http://www.hardcoded.net/licenses/hs_license
|
|
|
|
from PyQt4.QtCore import Qt, SIGNAL, QAbstractTableModel, QVariant
|
|
from PyQt4.QtGui import QDialog, QHeaderView, QPixmap
|
|
|
|
from base.details_table import DetailsModel
|
|
from details_dialog_ui import Ui_DetailsDialog
|
|
|
|
class DetailsDialog(QDialog, Ui_DetailsDialog):
|
|
def __init__(self, parent, app):
|
|
QDialog.__init__(self, parent, Qt.Tool)
|
|
self.app = app
|
|
self.selectedPixmap = None
|
|
self.referencePixmap = None
|
|
self.setupUi(self)
|
|
self.model = DetailsModel(app)
|
|
self.tableView.setModel(self.model)
|
|
self.connect(app, SIGNAL('duplicateSelected()'), self.duplicateSelected)
|
|
|
|
def _update(self):
|
|
dupe = self.app.selected_dupe
|
|
if dupe is None:
|
|
return
|
|
group = self.app.results.get_group_of_duplicate(dupe)
|
|
ref = group.ref
|
|
|
|
self.selectedPixmap = QPixmap(unicode(dupe.path))
|
|
if ref is dupe:
|
|
self.referencePixmap = self.selectedPixmap
|
|
else:
|
|
self.referencePixmap = QPixmap(unicode(ref.path))
|
|
self._updateImages()
|
|
|
|
def _updateImages(self):
|
|
if self.selectedPixmap is not None:
|
|
target_size = self.selectedImage.size()
|
|
scaledPixmap = self.selectedPixmap.scaled(target_size, Qt.KeepAspectRatio, Qt.SmoothTransformation)
|
|
self.selectedImage.setPixmap(scaledPixmap)
|
|
if self.referencePixmap is not None:
|
|
target_size = self.referenceImage.size()
|
|
scaledPixmap = self.referencePixmap.scaled(target_size, Qt.KeepAspectRatio, Qt.SmoothTransformation)
|
|
self.referenceImage.setPixmap(scaledPixmap)
|
|
|
|
#--- Override
|
|
def resizeEvent(self, event):
|
|
self._updateImages()
|
|
|
|
def show(self):
|
|
QDialog.show(self)
|
|
self._update()
|
|
|
|
#--- Events
|
|
def duplicateSelected(self):
|
|
if self.isVisible():
|
|
self._update()
|
|
|