Ejemplo n.º 1
0
 def __init__(self, *args, **kw):
     super(LocationInfo, self).__init__(*args, **kw)
     layout = QtWidgets.QGridLayout()
     self.setLayout(layout)
     layout.setContentsMargins(0, 0, 0, 0)
     self.members = {
         'taken': LocationWidgets(self),
         'shown': LocationWidgets(self)
     }
     self.swap = SquareButton(six.chr(0x21c4))
     self.swap.setStyleSheet('QPushButton { font-size: 10px }')
     self.swap.setFont(QtGui.QFont("Dejavu Sans"))
     if not self.swap.fontInfo().exactMatch():
         # probably on Windows, try a different font
         self.swap.setFont(QtGui.QFont("Segoe UI Symbol"))
     layout.addWidget(self.swap, 0, 4)
     label = QtWidgets.QLabel(translate('PhotiniMap', 'camera'))
     layout.addWidget(label, 0, 1, 1, 2)
     label = QtWidgets.QLabel(translate('PhotiniMap', 'subject'))
     layout.addWidget(label, 0, 3)
     layout.addWidget(QtWidgets.QLabel(translate('PhotiniMap', 'Street:')),
                      1, 0)
     layout.addWidget(QtWidgets.QLabel(translate('PhotiniMap', 'City:')), 2,
                      0)
     layout.addWidget(
         QtWidgets.QLabel(translate('PhotiniMap', 'Province:')), 3, 0)
     layout.addWidget(QtWidgets.QLabel(translate('PhotiniMap', 'Country:')),
                      4, 0)
     layout.addWidget(QtWidgets.QLabel(translate('PhotiniMap', 'Region:')),
                      5, 0)
     for ts, col in (('taken', 1), ('shown', 3)):
         layout.addWidget(self.members[ts]['sublocation'], 1, col, 1, 2)
         layout.addWidget(self.members[ts]['city'], 2, col, 1, 2)
         layout.addWidget(self.members[ts]['province_state'], 3, col, 1, 2)
         layout.addWidget(self.members[ts]['country_name'], 4, col)
         layout.addWidget(self.members[ts]['country_code'], 4, col + 1)
         layout.addWidget(self.members[ts]['world_region'], 5, col, 1, 2)
Ejemplo n.º 2
0
 def __init__(self, path, image_list, thumb_size=80, *arg, **kw):
     super(Image, self).__init__(*arg, **kw)
     self.path = path
     self.image_list = image_list
     self.name, ext = os.path.splitext(os.path.basename(self.path))
     self.selected = False
     self.thumb_size = thumb_size
     # read image
     with open(self.path, 'rb') as pf:
         image_data = pf.read()
     # read metadata
     self.metadata = Metadata(
         self.path, image_data, new_status=self.show_status)
     # set file type
     ext = ext.lower()
     self.file_type = imghdr.what(self.path) or 'raw'
     if self.file_type == 'tiff' and ext not in ('.tif', '.tiff'):
         self.file_type = 'raw'
     # make 'master' thumbnail
     self.pixmap = QtGui.QPixmap()
     self.pixmap.loadFromData(image_data)
     unrotate = self.file_type == 'raw'
     if self.pixmap.isNull():
         # image read failed so attempt to use exif thumbnail
         thumb = self.metadata.get_exif_thumbnail()
         if thumb:
             self.pixmap.loadFromData(bytearray(thumb))
             unrotate = False
     if not self.pixmap.isNull():
         if max(self.pixmap.width(), self.pixmap.height()) > 450:
             # store a scaled down version of image to save memory
             self.pixmap = self.pixmap.scaled(
                 300, 300, Qt.KeepAspectRatio, Qt.SmoothTransformation)
         if unrotate:
             # loading preview which is already re-oriented
             orientation = self.metadata.orientation
             if orientation and orientation.value > 1:
                 # need to unrotate and or unreflect image
                 transform = QtGui.QTransform()
                 if orientation.value in (3, 4):
                     transform = transform.rotate(180.0)
                 elif orientation.value in (5, 6):
                     transform = transform.rotate(-90.0)
                 elif orientation.value in (7, 8):
                     transform = transform.rotate(90.0)
                 if orientation.value in (2, 4, 5, 7):
                     transform = transform.scale(-1.0, 1.0)
                 self.pixmap = self.pixmap.transformed(transform)
     # sub widgets
     layout = QtWidgets.QGridLayout()
     layout.setSpacing(0)
     layout.setContentsMargins(3, 3, 3, 3)
     self.setLayout(layout)
     self.setToolTip(self.path)
     # label to display image
     self.image = QtWidgets.QLabel()
     self.image.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
     layout.addWidget(self.image, 0, 0, 1, 2)
     # label to display file name
     self.label = QtWidgets.QLabel()
     self.label.setAlignment(Qt.AlignRight)
     self.label.setStyleSheet("QLabel { font-size: 12px }")
     layout.addWidget(self.label, 1, 1)
     # label to display status
     self.status = QtWidgets.QLabel()
     self.status.setAlignment(Qt.AlignLeft)
     self.status.setStyleSheet("QLabel { font-size: 12px }")
     self.status.setFont(QtGui.QFont("Dejavu Sans"))
     if not self.status.fontInfo().exactMatch():
         # probably on Windows, try a different font
         self.status.setFont(QtGui.QFont("Segoe UI Symbol"))
     layout.addWidget(self.status, 1, 0)
     self.setFrameStyle(QtWidgets.QFrame.Panel | QtWidgets.QFrame.Plain)
     self.setObjectName("thumbnail")
     self.set_selected(False)
     self.show_status(False)
     self._set_thumb_size(self.thumb_size)