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.unichr(0x21c4)) self.swap.setStyleSheet('QPushButton { font-size: 10px }') set_symbol_font(self.swap) 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)
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 metadata self.metadata = Metadata(self.path) self.metadata.unsaved.connect(self.show_status) self.file_times = (os.path.getatime(self.path), os.path.getmtime(self.path)) # set file type self.file_type = self.metadata.get_mime_type() if not self.file_type: self.file_type = mimetypes.guess_type(self.path)[0] if not self.file_type: self.file_type = imghdr.what(self.path) if self.file_type: self.file_type = 'image/' + self.file_type # anything not recognised is assumed to be 'raw' if not self.file_type: self.file_type = 'image/raw' # 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) scale_font(self.label, 80) layout.addWidget(self.label, 1, 1) # label to display status self.status = QtWidgets.QLabel() self.status.setAlignment(Qt.AlignLeft) set_symbol_font(self.status) scale_font(self.status, 80) 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)
def __init__(self, *arg, **kw): super(OffsetWidget, self).__init__(*arg, **kw) self.config_store = QtWidgets.QApplication.instance().config_store self.setLayout(QtWidgets.QHBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) spacing = self.layout().spacing() self.layout().setSpacing(0) # offset value self.offset = QtWidgets.QTimeEdit() self.offset.setDisplayFormat("'h:'hh 'm:'mm 's:'ss") self.layout().addWidget(self.offset) self.layout().addSpacing(spacing) # time zone self.time_zone = TimeZoneWidget() self.time_zone.set_value(None) self.layout().addWidget(self.time_zone) self.layout().addSpacing(spacing) # add offset button add_button = QtWidgets.QPushButton(chr(0x002b)) add_button.setStyleSheet('QPushButton {padding: 0px}') set_symbol_font(add_button) scale_font(add_button, 170) add_button.setFixedWidth(self.offset.sizeHint().height()) add_button.setFixedHeight(self.offset.sizeHint().height()) add_button.clicked.connect(self.add) self.layout().addWidget(add_button) # subtract offset button sub_button = QtWidgets.QPushButton(chr(0x2212)) sub_button.setStyleSheet('QPushButton {padding: 0px}') set_symbol_font(sub_button) scale_font(sub_button, 170) sub_button.setFixedWidth(self.offset.sizeHint().height()) sub_button.setFixedHeight(self.offset.sizeHint().height()) sub_button.clicked.connect(self.sub) self.layout().addWidget(sub_button) self.layout().addStretch(1) # restore stored values value = self.config_store.get('technical', 'offset') if value: self.offset.setTime(QtCore.QTime(*value[0:3])) self.time_zone.set_value(value[3]) # connections self.offset.editingFinished.connect(self.new_value) self.time_zone.editingFinished.connect(self.new_value)
def __init__(self, path, image_list, thumb_size=80, *arg, **kw): super(Image, self).__init__(*arg, **kw) self.app = QtWidgets.QApplication.instance() 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 metadata self.metadata = Metadata(self.path, notify=self.show_status, utf_safe=self.app.options.utf_safe) self.file_times = (os.path.getatime(self.path), os.path.getmtime(self.path)) # set file type self.file_type = self.metadata.mime_type # 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) scale_font(self.label, 80) layout.addWidget(self.label, 1, 1) # label to display status self.status = QtWidgets.QLabel() self.status.setAlignment(Qt.AlignLeft) set_symbol_font(self.status) scale_font(self.status, 80) 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)
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 = mimetypes.guess_type(self.path)[0] if not self.file_type: self.file_type = imghdr.what(self.path, image_data) if self.file_type: self.file_type = 'image/' + self.file_type # anything not recognised is assumed to be 'raw' if not self.file_type: self.file_type = 'image/raw' # make 'master' thumbnail self.pixmap = QtGui.QPixmap() self.pixmap.loadFromData(image_data) unrotate = self.file_type == 'image/x-dcraw' 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 }") set_symbol_font(self.status) 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)