def __init__(self, *arg, **kw): super(NewItemDialog, self).__init__(*arg, **kw) self.setLayout(QtWidgets.QVBoxLayout()) # main dialog area scroll_area = QtWidgets.QScrollArea() scroll_area.setWidgetResizable(True) self.layout().addWidget(scroll_area) self.panel = QtWidgets.QWidget() self.panel.setLayout(QtWidgets.QFormLayout()) self.panel.layout().setFieldGrowthPolicy( QtWidgets.QFormLayout.AllNonFixedFieldsGrow) # ok & cancel buttons button_box = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel) button_box.accepted.connect(self.accept) button_box.rejected.connect(self.reject) self.layout().addWidget(button_box) # common data items self.model_widgets = {} for key, label in ( ('make', translate('TechnicalTab', "Maker's name")), ('model', translate('TechnicalTab', 'Model name')), ('serial_no', translate('TechnicalTab', 'Serial number')), ): self.model_widgets[key] = QtWidgets.QLineEdit() self.model_widgets[key].setMinimumWidth( width_for_text(self.model_widgets[key], 'x' * 35)) self.panel.layout().addRow(label, self.model_widgets[key]) # add any other data items self.extend_data() # add panel to scroll area now its size is known scroll_area.setWidget(self.panel)
def __init__(self, image_list, *arg, **kw): super(Descriptive, self).__init__(*arg, **kw) self.config_store = QtWidgets.QApplication.instance().config_store self.image_list = image_list self.form = QtWidgets.QFormLayout() self.setLayout(self.form) if qt_version_info >= (5, 0): self.trUtf8 = self.tr # construct widgets self.widgets = {} # title self.widgets['title'] = SingleLineEdit(spell_check=True) self.widgets['title'].editingFinished.connect(self.new_title) self.form.addRow(self.tr('Title / Object Name'), self.widgets['title']) # description self.widgets['description'] = MultiLineEdit(spell_check=True) self.widgets['description'].editingFinished.connect(self.new_description) self.form.addRow( self.tr('Description / Caption'), self.widgets['description']) # keywords self.widgets['keywords'] = SingleLineEdit(spell_check=True) self.widgets['keywords'].editingFinished.connect(self.new_keywords) self.form.addRow(self.tr('Keywords'), self.widgets['keywords']) # copyright self.widgets['copyright'] = LineEditWithAuto() self.widgets['copyright'].editingFinished.connect(self.new_copyright) self.widgets['copyright'].autoComplete.connect(self.auto_copyright) self.form.addRow(self.tr('Copyright'), self.widgets['copyright']) # creator self.widgets['creator'] = LineEditWithAuto() self.widgets['creator'].editingFinished.connect(self.new_creator) self.widgets['creator'].autoComplete.connect(self.auto_creator) self.form.addRow(self.tr('Creator / Artist'), self.widgets['creator']) # disable until an image is selected self.setEnabled(False)
def new_set(self): dialog = QtWidgets.QDialog(parent=self) dialog.setWindowTitle(self.tr('Create new Flickr album')) dialog.setLayout(QtWidgets.QFormLayout()) title = SingleLineEdit(spell_check=True) dialog.layout().addRow(self.tr('Title'), title) description = MultiLineEdit(spell_check=True) dialog.layout().addRow(self.tr('Description'), description) dialog.layout().addRow(QtWidgets.QLabel( self.tr('Album will be created when photos are uploaded'))) button_box = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel) button_box.accepted.connect(dialog.accept) button_box.rejected.connect(dialog.reject) dialog.layout().addRow(button_box) if dialog.exec_() != QtWidgets.QDialog.Accepted: return title = title.toPlainText() if not title: return description = description.toPlainText() widget = self.upload_config.add_set(title, description, index=0) widget.setChecked(True) self.photosets.insert(0, { 'id' : None, 'title' : title, 'description' : description, 'widget' : widget, })
def new_album(self): dialog = QtWidgets.QDialog(parent=self) dialog.setWindowTitle(self.tr('Create new Facebook album')) dialog.setLayout(QtWidgets.QFormLayout()) name = SingleLineEdit(spell_check=True) dialog.layout().addRow(self.tr('Title'), name) message = MultiLineEdit(spell_check=True) dialog.layout().addRow(self.tr('Description'), message) location = SingleLineEdit(spell_check=True) dialog.layout().addRow(self.tr('Location'), location) privacy = QtWidgets.QComboBox() for display_name, value in ( (self.tr('Only me'), '{value: "SELF"}'), (self.tr('All friends'), '{value: "ALL_FRIENDS"}'), (self.tr('Friends of friends'), '{value: "FRIENDS_OF_FRIENDS"}'), (self.tr('Friends + networks'), '{value: "NETWORKS_FRIENDS"}'), (self.tr('Everyone'), '{value: "EVERYONE"}'), ): privacy.addItem(display_name, value) dialog.layout().addRow(self.tr('Privacy'), privacy) button_box = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel) button_box.accepted.connect(dialog.accept) button_box.rejected.connect(dialog.reject) dialog.layout().addRow(button_box) if dialog.exec_() != QtWidgets.QDialog.Accepted: return if not self.authorise('write'): self.refresh(force=True) return name = name.toPlainText().strip() if not name: return data = {'name': name} message = message.toPlainText().strip() if message: data['message'] = message location = location.toPlainText().strip() if location: data['location'] = location data['privacy'] = privacy.itemData(privacy.currentIndex()) try: album = self.session.post('https://graph.facebook.com/me/albums', data=data) except Exception as ex: self.logger.error(str(ex)) self.refresh(force=True) return self.load_user_data(album_id=album['id'])
def __init__(self, image_list, *arg, **kw): super(TabWidget, self).__init__(*arg, **kw) self.config_store = QtWidgets.QApplication.instance().config_store self.image_list = image_list self.form = QtWidgets.QFormLayout() self.setLayout(self.form) # construct widgets self.widgets = {} # title self.widgets['title'] = SingleLineEdit(spell_check=True) self.widgets['title'].editingFinished.connect(self.new_title) self.form.addRow(translate('DescriptiveTab', 'Title / Object Name'), self.widgets['title']) # description self.widgets['description'] = MultiLineEdit(spell_check=True) self.widgets['description'].editingFinished.connect( self.new_description) self.form.addRow(translate('DescriptiveTab', 'Description / Caption'), self.widgets['description']) # keywords self.widgets['keywords'] = KeywordsEditor() self.widgets['keywords'].editingFinished.connect(self.new_keywords) self.form.addRow(translate('DescriptiveTab', 'Keywords'), self.widgets['keywords']) self.image_list.image_list_changed.connect(self.image_list_changed) # rating self.widgets['rating'] = RatingWidget() self.widgets['rating'].editing_finished.connect(self.new_rating) self.form.addRow(translate('DescriptiveTab', 'Rating'), self.widgets['rating']) # copyright self.widgets['copyright'] = LineEditWithAuto() self.widgets['copyright'].editingFinished.connect(self.new_copyright) self.widgets['copyright'].autoComplete.connect(self.auto_copyright) self.form.addRow(translate('DescriptiveTab', 'Copyright'), self.widgets['copyright']) # creator self.widgets['creator'] = LineEditWithAuto() self.widgets['creator'].editingFinished.connect(self.new_creator) self.widgets['creator'].autoComplete.connect(self.auto_creator) self.form.addRow(translate('DescriptiveTab', 'Creator / Artist'), self.widgets['creator']) # disable until an image is selected self.setEnabled(False)
def __init__(self, images, *arg, **kw): super(NewLensDialog, self).__init__(*arg, **kw) self.setWindowTitle(self.tr('Photini: define lens')) self.setLayout(QtWidgets.QVBoxLayout()) # main dialog area scroll_area = QtWidgets.QScrollArea() scroll_area.setWidgetResizable(True) self.layout().addWidget(scroll_area) panel = QtWidgets.QWidget() panel.setLayout(QtWidgets.QFormLayout()) # ok & cancel buttons button_box = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel) button_box.accepted.connect(self.accept) button_box.rejected.connect(self.reject) self.layout().addWidget(button_box) # model self.lens_model = QtWidgets.QLineEdit() self.lens_model.setMinimumWidth(250) panel.layout().addRow(self.tr('Model name'), self.lens_model) # maker self.lens_make = QtWidgets.QLineEdit() panel.layout().addRow(self.tr("Maker's name"), self.lens_make) # serial number self.lens_serial = QtWidgets.QLineEdit() panel.layout().addRow(self.tr('Serial number'), self.lens_serial) ## spec has four items self.lens_spec = {} # min focal length self.lens_spec['min_fl'] = QtWidgets.QLineEdit() self.lens_spec['min_fl'].setValidator( QtGui.QDoubleValidator(bottom=0.0)) panel.layout().addRow(self.tr('Minimum focal length (mm)'), self.lens_spec['min_fl']) # min focal length aperture self.lens_spec['min_fl_fn'] = QtWidgets.QLineEdit() self.lens_spec['min_fl_fn'].setValidator(DoubleValidator(bottom=0.0)) panel.layout().addRow(self.tr('Aperture at min. focal length f/'), self.lens_spec['min_fl_fn']) # max focal length self.lens_spec['max_fl'] = QtWidgets.QLineEdit() self.lens_spec['max_fl'].setValidator( QtGui.QDoubleValidator(bottom=0.0)) panel.layout().addRow(self.tr('Maximum focal length (mm)'), self.lens_spec['max_fl']) # max focal length aperture self.lens_spec['max_fl_fn'] = QtWidgets.QLineEdit() self.lens_spec['max_fl_fn'].setValidator(DoubleValidator(bottom=0.0)) panel.layout().addRow(self.tr('Aperture at max. focal length f/'), self.lens_spec['max_fl_fn']) # add panel to scroll area after its size is known scroll_area.setWidget(panel) # fill in any values we can from existing metadata for image in images: if image.metadata.lens_model: self.lens_model.setText(image.metadata.lens_model.value) if image.metadata.lens_make: self.lens_make.setText(image.metadata.lens_make.value) if image.metadata.lens_serial: self.lens_serial.setText(image.metadata.lens_serial.value) spec = image.metadata.lens_spec for key in self.lens_spec: if spec and spec.value[key]: self.lens_spec[key].setText('{:g}'.format( float(spec.value[key])))
def __init__(self, image_list, parent=None): super(TabWidget, self).__init__(parent) app = QtWidgets.QApplication.instance() app.aboutToQuit.connect(self.shutdown) if gp and app.test_mode: self.gp_log = gp.check_result(gp.use_python_logging()) self.config_store = app.config_store self.image_list = image_list self.setLayout(QtWidgets.QGridLayout()) form = QtWidgets.QFormLayout() form.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow) self.nm = NameMangler() self.file_data = {} self.file_list = [] self.source = None self.file_reader = None self.file_writer = None # source selector box = QtWidgets.QHBoxLayout() box.setContentsMargins(0, 0, 0, 0) self.source_selector = QtWidgets.QComboBox() self.source_selector.currentIndexChanged.connect(self.new_source) box.addWidget(self.source_selector) refresh_button = QtWidgets.QPushButton(self.tr('refresh')) refresh_button.clicked.connect(self.refresh) box.addWidget(refresh_button) box.setStretch(0, 1) form.addRow(self.tr('Source'), box) # path format self.path_format = QtWidgets.QLineEdit() self.path_format.setValidator(PathFormatValidator()) self.path_format.textChanged.connect(self.nm.new_format) self.path_format.editingFinished.connect(self.path_format_finished) form.addRow(self.tr('Target format'), self.path_format) # path example self.path_example = QtWidgets.QLabel() self.nm.new_example.connect(self.path_example.setText) form.addRow('=>', self.path_example) self.layout().addLayout(form, 0, 0) # file list self.file_list_widget = QtWidgets.QListWidget() self.file_list_widget.setSelectionMode( QtWidgets.QAbstractItemView.ExtendedSelection) self.file_list_widget.itemSelectionChanged.connect(self.selection_changed) self.layout().addWidget(self.file_list_widget, 1, 0) # selection buttons buttons = QtWidgets.QVBoxLayout() buttons.addStretch(1) self.selected_count = QtWidgets.QLabel() self.selection_changed() buttons.addWidget(self.selected_count) select_all = QtWidgets.QPushButton(self.tr('Select\nall')) select_all.clicked.connect(self.select_all) buttons.addWidget(select_all) select_new = QtWidgets.QPushButton(self.tr('Select\nnew')) select_new.clicked.connect(self.select_new) buttons.addWidget(select_new) self.copy_button = StartStopButton(self.tr('Copy\nphotos'), self.tr('Stop\nimport')) self.copy_button.click_start.connect(self.copy_selected) self.copy_button.click_stop.connect(self.stop_copy) buttons.addWidget(self.copy_button) self.layout().addLayout(buttons, 0, 1, 2, 1) # final initialisation self.image_list.sort_order_changed.connect(self.sort_file_list) path = os.path.expanduser('~/Pictures') if not os.path.isdir(path) and sys.platform == 'win32': try: import win32com.shell as ws path = ws.shell.SHGetFolderPath( 0, ws.shellcon.CSIDL_MYPICTURES, None, 0) except ImportError: pass self.path_format.setText( os.path.join(path, '%Y', '%Y_%m_%d', '{name}')) self.refresh() self.list_files()
def __init__(self, image_list, parent=None): super(TabWidget, self).__init__(parent) self.app = QtWidgets.QApplication.instance() self.app.aboutToQuit.connect(self.stop_copy) if gp and self.app.options.test: self.gp_log = gp.check_result(gp.use_python_logging()) self.config_store = self.app.config_store self.image_list = image_list self.setLayout(QtWidgets.QGridLayout()) form = QtWidgets.QFormLayout() form.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow) self.nm = NameMangler() self.file_data = {} self.file_list = [] self.source = None self.file_copier = None self.updating = QtCore.QMutex() # source selector box = QtWidgets.QHBoxLayout() box.setContentsMargins(0, 0, 0, 0) self.source_selector = QtWidgets.QComboBox() self.source_selector.currentIndexChanged.connect(self.new_source) self.source_selector.setContextMenuPolicy(Qt.CustomContextMenu) self.source_selector.customContextMenuRequested.connect( self.remove_folder) box.addWidget(self.source_selector) refresh_button = QtWidgets.QPushButton( translate('ImporterTab', 'refresh')) refresh_button.clicked.connect(self.refresh) box.addWidget(refresh_button) box.setStretch(0, 1) form.addRow(translate('ImporterTab', 'Source'), box) # update config self.config_store.delete('importer', 'folders') for section in self.config_store.config.sections(): if not section.startswith('importer'): continue path_format = self.config_store.get(section, 'path_format') if not (path_format and '(' in path_format): continue path_format = path_format.replace('(', '{').replace(')', '}') self.config_store.set(section, 'path_format', path_format) # path format self.path_format = QtWidgets.QLineEdit() self.path_format.setValidator(PathFormatValidator()) self.path_format.textChanged.connect(self.nm.new_format) self.path_format.editingFinished.connect(self.path_format_finished) form.addRow(translate('ImporterTab', 'Target format'), self.path_format) # path example self.path_example = QtWidgets.QLabel() self.nm.new_example.connect(self.path_example.setText) form.addRow('=>', self.path_example) self.layout().addLayout(form, 0, 0) # file list self.file_list_widget = QtWidgets.QListWidget() self.file_list_widget.setSelectionMode( QtWidgets.QAbstractItemView.ExtendedSelection) self.file_list_widget.itemSelectionChanged.connect( self.selection_changed) self.layout().addWidget(self.file_list_widget, 1, 0) # selection buttons buttons = QtWidgets.QVBoxLayout() buttons.addStretch(1) self.selected_count = QtWidgets.QLabel() buttons.addWidget(self.selected_count) select_all = QtWidgets.QPushButton( translate('ImporterTab', 'Select\nall')) select_all.clicked.connect(self.select_all) buttons.addWidget(select_all) select_new = QtWidgets.QPushButton( translate('ImporterTab', 'Select\nnew')) select_new.clicked.connect(self.select_new) buttons.addWidget(select_new) # copy buttons self.move_button = StartStopButton( translate('ImporterTab', 'Move\nphotos'), translate('ImporterTab', 'Stop\nmove')) self.move_button.click_start.connect(self.move_selected) self.move_button.click_stop.connect(self.stop_copy) buttons.addWidget(self.move_button) self.copy_button = StartStopButton( translate('ImporterTab', 'Copy\nphotos'), translate('ImporterTab', 'Stop\ncopy')) self.copy_button.click_start.connect(self.copy_selected) self.copy_button.click_stop.connect(self.stop_copy) buttons.addWidget(self.copy_button) self.layout().addLayout(buttons, 0, 1, 2, 1) self.selection_changed() # final initialisation self.image_list.sort_order_changed.connect(self.sort_file_list) path = QtCore.QStandardPaths.writableLocation( QtCore.QStandardPaths.PicturesLocation) self.path_format.setText(os.path.join(path, '%Y', '%Y_%m_%d', '{name}'))
def do_import(self, parent): args = [ parent, self.tr('Import GPX file'), parent.app.config_store.get('paths', 'gpx', ''), self.tr("GPX files (*.gpx *.GPX *.Gpx);;All files (*)") ] if eval(parent.app.config_store.get('pyqt', 'native_dialog', 'True')): pass else: args += [None, QtWidgets.QFileDialog.DontUseNativeDialog] path = QtWidgets.QFileDialog.getOpenFileName(*args) path = path[0] if not path: return parent.app.config_store.set('paths', 'gpx', os.path.dirname(os.path.abspath(path))) # get user options config_store = QtWidgets.QApplication.instance().config_store dialog = QtWidgets.QDialog(parent=parent) dialog.setWindowTitle(self.tr('GPX options')) dialog.setLayout(QtWidgets.QFormLayout()) max_interval = QtWidgets.QSpinBox() max_interval.setRange(60, 300) max_interval.setValue( int(config_store.get('gpx_importer', 'interval', '120'))) max_interval.setSuffix(self.tr(' secs')) dialog.layout().addRow(self.tr('Max time between points'), max_interval) max_dilution = QtWidgets.QDoubleSpinBox() max_dilution.setRange(1.0, 100.0) max_dilution.setValue( float(config_store.get('gpx_importer', 'dilution', '2.5'))) max_dilution.setSingleStep(0.1) dialog.layout().addRow(self.tr('Max dilution of precision'), max_dilution) if hasattr(parent.tabs.currentWidget(), 'plot_track'): plot_track = QtWidgets.QCheckBox() plot_track.setChecked( bool(config_store.get('gpx_importer', 'plot', 'True'))) dialog.layout().addRow(self.tr('Plot track on map'), plot_track) else: plot_track = False button_box = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok) button_box.accepted.connect(dialog.accept) dialog.layout().addWidget(button_box) dialog.exec_() max_interval = max_interval.value() max_dilution = max_dilution.value() config_store.set('gpx_importer', 'interval', max_interval) config_store.set('gpx_importer', 'dilution', max_dilution) if plot_track: plot_track = plot_track.isChecked() config_store.set('gpx_importer', 'plot', plot_track) # make a list of all points in the file points = [] discards = 0 for p in self.read_file(path): if p.horizontal_dilution and p.horizontal_dilution > max_dilution: discards += 1 continue time_stamp = p.time if time_stamp.tzinfo is not None: # convert timestamp to UTC utc_offset = time_stamp.utcoffset() time_stamp = (time_stamp - utc_offset).replace(tzinfo=None) # add point to list points.append((time_stamp, p.latitude, p.longitude)) if discards: logger.warning('Discarded %d low accuracy points', discards) if not points: logger.warning('No points found in file "%s"', path) return logger.warning('Using %d points', len(points)) # sort points by timestamp points.sort(key=lambda x: x[0]) # display on map if plot_track: # divide points into contiguous tracks tracks = [] t = [] for p in points: if t and (p[0] - t[-1][0]).total_seconds() > max_interval: tracks.append(t) t = [] t.append(p) if t: tracks.append(t) parent.tabs.currentWidget().plot_track(tracks) # set image coordinates max_interval = max_interval / 2.0 for image in parent.image_list.get_selected_images(): if not image.metadata.date_taken: continue time_stamp = image.metadata.date_taken.to_utc() if len(points) < 2: lo, hi = 0, 0 elif time_stamp < points[0][0]: lo, hi = 0, 1 elif time_stamp > points[-1][0]: lo, hi = -2, -1 else: # binary search for points with nearest timestamps lo, hi = 0, len(points) - 1 while hi - lo > 1: mid = (lo + hi) // 2 if time_stamp >= points[mid][0]: lo = mid elif time_stamp <= points[mid][0]: hi = mid # use linear interpolation (or extrapolation) to set lat & long dt_lo = (time_stamp - points[lo][0]).total_seconds() dt_hi = (time_stamp - points[hi][0]).total_seconds() if abs(dt_lo) > max_interval and abs(dt_hi) > max_interval: logger.info('No point for time %s', image.metadata.date_taken) continue if dt_lo == dt_hi: beta = 0.5 else: beta = dt_lo / (dt_lo - dt_hi) lat = points[lo][1] + (beta * (points[hi][1] - points[lo][1])) lng = points[lo][2] + (beta * (points[hi][2] - points[lo][2])) image.metadata.latlong = lat, lng parent.image_list.emit_selection()
def __init__(self, parent): QtWidgets.QDialog.__init__(self, parent) self.config_store = QtWidgets.QApplication.instance().config_store self.setWindowTitle(self.tr('Photini: settings')) self.setLayout(QtWidgets.QVBoxLayout()) # main dialog area scroll_area = QtWidgets.QScrollArea() self.layout().addWidget(scroll_area) panel = QtWidgets.QWidget() panel.setLayout(QtWidgets.QFormLayout()) # apply & cancel buttons self.button_box = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Apply | QtWidgets.QDialogButtonBox.Cancel) self.button_box.clicked.connect(self.button_clicked) self.layout().addWidget(self.button_box) # copyright holder name self.copyright_name = QtWidgets.QLineEdit() self.copyright_name.setText( self.config_store.get('user', 'copyright_name', '')) self.copyright_name.setMinimumWidth(200) panel.layout().addRow(self.tr('Copyright holder'), self.copyright_name) # creator name self.creator_name = QtWidgets.QLineEdit() self.creator_name.setText( self.config_store.get('user', 'creator_name', '')) panel.layout().addRow(self.tr('Creator'), self.creator_name) # reset flickr self.reset_flickr = QtWidgets.QCheckBox() panel.layout().addRow(self.tr('Disconnect from Flickr'), self.reset_flickr) if not keyring or keyring.get_password('photini', 'flickr') is None: self.reset_flickr.setDisabled(True) panel.layout().labelForField(self.reset_flickr).setDisabled(True) # reset picasa self.reset_picasa = QtWidgets.QCheckBox() panel.layout().addRow(self.tr('Disconnect from Google Photos'), self.reset_picasa) if not keyring or keyring.get_password('photini', 'picasa') is None: self.reset_picasa.setDisabled(True) panel.layout().labelForField(self.reset_picasa).setDisabled(True) # reset facebook self.reset_facebook = QtWidgets.QCheckBox() panel.layout().addRow(self.tr('Disconnect from Facebook'), self.reset_facebook) if not keyring or keyring.get_password('photini', 'facebook') is None: self.reset_facebook.setDisabled(True) panel.layout().labelForField(self.reset_facebook).setDisabled(True) # IPTC data force_iptc = eval(self.config_store.get('files', 'force_iptc', 'False')) self.write_iptc = QtWidgets.QCheckBox(self.tr('Write unconditionally')) self.write_iptc.setChecked(force_iptc) panel.layout().addRow(self.tr('IPTC metadata'), self.write_iptc) # sidecar files if_mode = eval(self.config_store.get('files', 'image', 'True')) sc_mode = self.config_store.get('files', 'sidecar', 'auto') if not if_mode: sc_mode = 'always' self.sc_always = QtWidgets.QRadioButton(self.tr('Always create')) self.sc_always.setChecked(sc_mode == 'always') panel.layout().addRow(self.tr('Sidecar files'), self.sc_always) self.sc_auto = QtWidgets.QRadioButton(self.tr('Create if necessary')) self.sc_auto.setChecked(sc_mode == 'auto') self.sc_auto.setEnabled(if_mode) panel.layout().addRow('', self.sc_auto) self.sc_delete = QtWidgets.QRadioButton( self.tr('Delete when possible')) self.sc_delete.setChecked(sc_mode == 'delete') self.sc_delete.setEnabled(if_mode) panel.layout().addRow('', self.sc_delete) # image file locking self.write_if = QtWidgets.QCheckBox(self.tr('(when possible)')) self.write_if.setChecked(if_mode) self.write_if.clicked.connect(self.new_write_if) panel.layout().addRow(self.tr('Write to image'), self.write_if) # add panel to scroll area after its size is known scroll_area.setWidget(panel)
def data_form(self): widgets = {} scrollarea = QtWidgets.QScrollArea() scrollarea.setFrameStyle(QtWidgets.QFrame.NoFrame) scrollarea.setWidgetResizable(True) form = QtWidgets.QWidget() form.setLayout(QtWidgets.QFormLayout()) # creator widgets['creator'] = SingleLineEdit( length_check=ImageMetadata.max_bytes('creator'), spell_check=True, multi_string=True) widgets['creator'].setToolTip( translate('OwnerTab', 'Enter the name of the person that created this image.')) form.layout().addRow(translate('OwnerTab', 'Creator'), widgets['creator']) # creator title widgets['creator_title'] = SingleLineEdit( length_check=ImageMetadata.max_bytes('creator_title'), spell_check=True, multi_string=True) widgets['creator_title'].setToolTip( translate( 'OwnerTab', 'Enter the job title of the person listed in the Creator field.' )) form.layout().addRow(translate('OwnerTab', "Creator's Jobtitle"), widgets['creator_title']) # credit line widgets['credit_line'] = SingleLineEdit( length_check=ImageMetadata.max_bytes('credit_line'), spell_check=True) widgets['credit_line'].setToolTip( translate( 'OwnerTab', 'Enter who should be credited when this image is published.')) form.layout().addRow(translate('OwnerTab', 'Credit Line'), widgets['credit_line']) # copyright widgets['copyright'] = SingleLineEdit( length_check=ImageMetadata.max_bytes('copyright'), spell_check=True) widgets['copyright'].setToolTip( translate( 'OwnerTab', 'Enter a notice on the current owner of the' ' copyright for this image, such as "©2008 Jane Doe".')) form.layout().addRow(translate('OwnerTab', 'Copyright Notice'), widgets['copyright']) # usage terms widgets['usageterms'] = SingleLineEdit( length_check=ImageMetadata.max_bytes('usageterms'), spell_check=True) widgets['usageterms'].setToolTip( translate( 'OwnerTab', 'Enter instructions on how this image can legally be used.')) form.layout().addRow(translate('OwnerTab', 'Rights Usage Terms'), widgets['usageterms']) # special instructions widgets['instructions'] = SingleLineEdit( length_check=ImageMetadata.max_bytes('instructions'), spell_check=True) widgets['instructions'].setToolTip( translate( 'OwnerTab', 'Enter information about embargoes, or other' ' restrictions not covered by the Rights Usage Terms field.')) form.layout().addRow(translate('OwnerTab', 'Instructions'), widgets['instructions']) ## contact information contact_group = QtWidgets.QGroupBox() contact_group.setLayout(QtWidgets.QFormLayout()) # email addresses widgets['CiEmailWork'] = SingleLineEdit() widgets['CiEmailWork'].setToolTip( translate( 'OwnerTab', 'Enter the work email address(es) for the person' ' that created this image, such as [email protected].')) contact_group.layout().addRow(translate('OwnerTab', 'Email(s)'), widgets['CiEmailWork']) # URLs widgets['CiUrlWork'] = SingleLineEdit() widgets['CiUrlWork'].setToolTip( translate( 'OwnerTab', 'Enter the work Web URL(s) for the person' ' that created this image, such as http://www.domain.com/.')) contact_group.layout().addRow(translate('OwnerTab', 'Web URL(s)'), widgets['CiUrlWork']) # phone numbers widgets['CiTelWork'] = SingleLineEdit() widgets['CiTelWork'].setToolTip( translate( 'OwnerTab', 'Enter the work phone number(s) for the person' ' that created this image, using the international format,' ' such as +1 (123) 456789.')) contact_group.layout().addRow(translate('OwnerTab', 'Phone(s)'), widgets['CiTelWork']) # address widgets['CiAdrExtadr'] = MultiLineEdit( length_check=ImageMetadata.max_bytes('contact_info'), spell_check=True) widgets['CiAdrExtadr'].setToolTip( translate('OwnerTab', 'Enter address for the person that created this image.')) contact_group.layout().addRow(translate('OwnerTab', 'Address'), widgets['CiAdrExtadr']) # city widgets['CiAdrCity'] = SingleLineEdit(spell_check=True) widgets['CiAdrCity'].setToolTip( translate( 'OwnerTab', 'Enter the city for the address of the person' ' that created this image.')) contact_group.layout().addRow(translate('OwnerTab', 'City'), widgets['CiAdrCity']) # postcode widgets['CiAdrPcode'] = SingleLineEdit() widgets['CiAdrPcode'].setToolTip( translate( 'OwnerTab', 'Enter the postal code for the address of the person' ' that created this image.')) contact_group.layout().addRow(translate('OwnerTab', 'Postal Code'), widgets['CiAdrPcode']) # region widgets['CiAdrRegion'] = SingleLineEdit(spell_check=True) widgets['CiAdrRegion'].setToolTip( translate( 'OwnerTab', 'Enter the state for the address of the person' ' that created this image.')) contact_group.layout().addRow(translate('OwnerTab', 'State/Province'), widgets['CiAdrRegion']) # country widgets['CiAdrCtry'] = SingleLineEdit(spell_check=True) widgets['CiAdrCtry'].setToolTip( translate( 'OwnerTab', 'Enter the country name for the address of the person' ' that created this image.')) contact_group.layout().addRow(translate('OwnerTab', 'Country'), widgets['CiAdrCtry']) form.layout().addRow(translate('OwnerTab', 'Contact Information'), contact_group) scrollarea.setWidget(form) return scrollarea, widgets
def __init__(self, *arg, **kw): super(PicasaUploadConfig, self).__init__(*arg, **kw) self.setLayout(QtWidgets.QHBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) self.widgets = {} ## album details, left hand side album_group = QtWidgets.QGroupBox(self.tr('Collection / Album')) album_group.setLayout(QtWidgets.QHBoxLayout()) album_form_left = QtWidgets.QFormLayout() album_form_left.setFieldGrowthPolicy( QtWidgets.QFormLayout.AllNonFixedFieldsGrow) album_group.layout().addLayout(album_form_left) # album title / selector self.albums = QtWidgets.QComboBox() self.albums.setEditable(True) self.albums.setInsertPolicy(QtWidgets.QComboBox.NoInsert) self.albums.activated.connect(self.switch_album) self.albums.lineEdit().editingFinished.connect(self.new_title) album_form_left.addRow(self.tr('Title'), self.albums) # album description self.widgets['description'] = MultiLineEdit(spell_check=True) self.widgets['description'].editingFinished.connect( self.new_album_details) album_form_left.addRow(self.tr('Description'), self.widgets['description']) # album location self.widgets['location'] = QtWidgets.QLineEdit() self.widgets['location'].editingFinished.connect( self.new_album_details) album_form_left.addRow(self.tr('Place taken'), self.widgets['location']) # album visibility self.widgets['access'] = QtWidgets.QComboBox() self.widgets['access'].addItem(self.tr('Public on the web'), 'public') self.widgets['access'].addItem( self.tr('Limited, anyone with the link'), 'private') self.widgets['access'].addItem(self.tr('Only you'), 'protected') self.widgets['access'].currentIndexChanged.connect(self.new_access) album_form_left.addRow(self.tr('Visibility'), self.widgets['access']) ## album buttons buttons = QtWidgets.QHBoxLayout() buttons.addStretch(stretch=60) album_form_left.addRow(buttons) # new album new_album_button = QtWidgets.QPushButton(self.tr('New album')) new_album_button.clicked.connect(self.new_album) buttons.addWidget(new_album_button, stretch=20) # delete album delete_album_button = QtWidgets.QPushButton(self.tr('Delete album')) delete_album_button.clicked.connect(self.delete_album) buttons.addWidget(delete_album_button, stretch=20) ## album details, right hand side album_form_right = QtWidgets.QFormLayout() album_form_right.setFieldGrowthPolicy( QtWidgets.QFormLayout.AllNonFixedFieldsGrow) album_group.layout().addLayout(album_form_right) # album date self.widgets['timestamp'] = QtWidgets.QDateEdit() self.widgets['timestamp'].setMinimumDateTime( QtCore.QDateTime.fromTime_t(0)) self.widgets['timestamp'].setCalendarPopup(True) self.widgets['timestamp'].editingFinished.connect( self.new_album_details) album_form_right.addRow(self.tr('Date'), self.widgets['timestamp']) # album thumbnail self.album_thumb = QtWidgets.QLabel() self.album_thumb.setFixedWidth(160) album_form_right.addRow(self.album_thumb) self.layout().addWidget(album_group)
def __init__(self, image_list, *arg, **kw): super(TabWidget, self).__init__(*arg, **kw) self.config_store = QtWidgets.QApplication.instance().config_store self.image_list = image_list self.form = QtWidgets.QFormLayout() self.setLayout(QtWidgets.QVBoxLayout()) self.layout().addLayout(self.form) self.layout().addStretch(1) # construct widgets self.widgets = {} # title self.widgets['title'] = SingleLineEdit( spell_check=True, length_check=ImageMetadata.max_bytes('title')) self.widgets['title'].setToolTip( translate( 'DescriptiveTab', 'Enter a short verbal and human readable name' ' for the image, this may be the file name.')) self.widgets['title'].editingFinished.connect(self.new_title) self.form.addRow(translate('DescriptiveTab', 'Title / Object Name'), self.widgets['title']) # description self.widgets['description'] = MultiLineEdit( spell_check=True, length_check=ImageMetadata.max_bytes('description')) self.widgets['description'].setToolTip( translate( 'DescriptiveTab', 'Enter a "caption" describing the who, what,' ' and why of what is happening in this image,\nthis might include' ' names of people, and/or their role in the action that is taking' ' place within the image.')) self.widgets['description'].editingFinished.connect( self.new_description) self.form.addRow(translate('DescriptiveTab', 'Description / Caption'), self.widgets['description']) # keywords self.widgets['keywords'] = KeywordsEditor( spell_check=True, length_check=ImageMetadata.max_bytes('keywords'), multi_string=True) self.widgets['keywords'].setToolTip( translate( 'DescriptiveTab', 'Enter any number of keywords, terms or phrases' ' used to express the subject matter in the image.' '\nSeparate them with ";" characters.')) self.widgets['keywords'].editingFinished.connect(self.new_keywords) self.form.addRow(translate('DescriptiveTab', 'Keywords'), self.widgets['keywords']) self.image_list.image_list_changed.connect(self.image_list_changed) # rating self.widgets['rating'] = RatingWidget() self.widgets['rating'].editing_finished.connect(self.new_rating) self.form.addRow(translate('DescriptiveTab', 'Rating'), self.widgets['rating']) # copyright self.widgets['copyright'] = LineEditWithAuto( length_check=ImageMetadata.max_bytes('copyright')) self.widgets['copyright'].setToolTip( translate( 'OwnerTab', 'Enter a notice on the current owner of the' ' copyright for this image, such as "©2008 Jane Doe".')) self.widgets['copyright'].editingFinished.connect(self.new_copyright) self.widgets['copyright'].autoComplete.connect(self.auto_copyright) self.form.addRow(translate('DescriptiveTab', 'Copyright'), self.widgets['copyright']) # creator self.widgets['creator'] = LineEditWithAuto( length_check=ImageMetadata.max_bytes('creator'), multi_string=True) self.widgets['creator'].setToolTip( translate('OwnerTab', 'Enter the name of the person that created this image.')) self.widgets['creator'].editingFinished.connect(self.new_creator) self.widgets['creator'].autoComplete.connect(self.auto_creator) self.form.addRow(translate('DescriptiveTab', 'Creator / Artist'), self.widgets['creator']) # disable until an image is selected self.setEnabled(False)
def __init__(self, images, *arg, **kw): super(NewLensDialog, self).__init__(*arg, **kw) self.setWindowTitle(translate('TechnicalTab', 'Photini: define lens')) self.setLayout(QtWidgets.QVBoxLayout()) # main dialog area scroll_area = QtWidgets.QScrollArea() scroll_area.setWidgetResizable(True) self.layout().addWidget(scroll_area) panel = QtWidgets.QWidget() panel.setLayout(QtWidgets.QFormLayout()) panel.layout().setFieldGrowthPolicy( QtWidgets.QFormLayout.AllNonFixedFieldsGrow) # ok & cancel buttons button_box = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel) button_box.accepted.connect(self.accept) button_box.rejected.connect(self.reject) self.layout().addWidget(button_box) # model self.lens_model = QtWidgets.QLineEdit() self.lens_model.setMinimumWidth( width_for_text(self.lens_model, 'x' * 35)) panel.layout().addRow(translate('TechnicalTab', 'Model name'), self.lens_model) # maker self.lens_make = QtWidgets.QLineEdit() panel.layout().addRow(translate('TechnicalTab', "Maker's name"), self.lens_make) # serial number self.lens_serial = QtWidgets.QLineEdit() panel.layout().addRow(translate('TechnicalTab', 'Serial number'), self.lens_serial) ## spec has four items self.lens_spec = {} # min focal length self.lens_spec['min_fl'] = DoubleSpinBox() self.lens_spec['min_fl'].setMinimum(0.0) self.lens_spec['min_fl'].setSingleStep(1.0) self.lens_spec['min_fl'].setSuffix(' mm') panel.layout().addRow( translate('TechnicalTab', 'Minimum focal length'), self.lens_spec['min_fl']) # min focal length aperture self.lens_spec['min_fl_fn'] = DoubleSpinBox() self.lens_spec['min_fl_fn'].setMinimum(0.0) self.lens_spec['min_fl_fn'].setPrefix('ƒ/') panel.layout().addRow( translate('TechnicalTab', 'Aperture at min. focal length'), self.lens_spec['min_fl_fn']) # max focal length self.lens_spec['max_fl'] = DoubleSpinBox() self.lens_spec['max_fl'].setMinimum(0.0) self.lens_spec['max_fl'].setSingleStep(1.0) self.lens_spec['max_fl'].setSuffix(' mm') panel.layout().addRow( translate('TechnicalTab', 'Maximum focal length'), self.lens_spec['max_fl']) # max focal length aperture self.lens_spec['max_fl_fn'] = DoubleSpinBox() self.lens_spec['max_fl_fn'].setMinimum(0.0) self.lens_spec['max_fl_fn'].setPrefix('ƒ/') panel.layout().addRow( translate('TechnicalTab', 'Aperture at max. focal length'), self.lens_spec['max_fl_fn']) # add panel to scroll area after its size is known scroll_area.setWidget(panel) # fill in any values we can from existing metadata for image in images: if image.metadata.lens_model: self.lens_model.setText(image.metadata.lens_model) if image.metadata.lens_make: self.lens_make.setText(image.metadata.lens_make) if image.metadata.lens_serial: self.lens_serial.setText(image.metadata.lens_serial) spec = image.metadata.lens_spec for key in self.lens_spec: if spec and spec[key]: self.lens_spec[key].set_value(spec[key])
def __init__(self, *arg, **kw): super(FacebookUploadConfig, self).__init__(*arg, **kw) self.setLayout(QtWidgets.QHBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) self.widgets = {} ## upload config config_group = QtWidgets.QGroupBox(self.tr('Options')) config_group.setLayout(QtWidgets.QFormLayout()) self.layout().addWidget(config_group) # suppress feed story self.widgets['no_story'] = QtWidgets.QCheckBox() config_group.layout().addRow(self.tr('Suppress news feed story'), self.widgets['no_story']) label = config_group.layout().labelForField(self.widgets['no_story']) label.setWordWrap(True) label.setFixedWidth(90) # geotagging self.widgets['geo_tag'] = QtWidgets.QCheckBox() config_group.layout().addRow( self.tr('Set "city" from map coordinates'), self.widgets['geo_tag']) self.widgets['geo_tag'].setChecked(True) label = config_group.layout().labelForField(self.widgets['geo_tag']) label.setWordWrap(True) label.setFixedWidth(90) # optimise self.widgets['optimise'] = QtWidgets.QCheckBox() config_group.layout().addRow(self.tr('Optimise image size'), self.widgets['optimise']) label = config_group.layout().labelForField(self.widgets['optimise']) label.setWordWrap(True) label.setFixedWidth(90) if PIL: self.widgets['optimise'].setChecked(True) else: self.widgets['optimise'].setEnabled(False) label.setEnabled(False) ## album details album_group = QtWidgets.QGroupBox(self.tr('Album')) album_group.setLayout(QtWidgets.QHBoxLayout()) # left hand side album_form_left = QtWidgets.QFormLayout() album_form_left.setFieldGrowthPolicy( QtWidgets.QFormLayout.AllNonFixedFieldsGrow) album_group.layout().addLayout(album_form_left) # album title / selector self.widgets['album_choose'] = QtWidgets.QComboBox() self.widgets['album_choose'].activated.connect(self.select_album) album_form_left.addRow(self.tr('Title'), self.widgets['album_choose']) # album description self.widgets['album_description'] = QtWidgets.QPlainTextEdit() self.widgets['album_description'].setReadOnly(True) policy = self.widgets['album_description'].sizePolicy() policy.setVerticalStretch(1) self.widgets['album_description'].setSizePolicy(policy) album_form_left.addRow(self.tr('Description'), self.widgets['album_description']) # album location self.widgets['album_location'] = QtWidgets.QLineEdit() self.widgets['album_location'].setReadOnly(True) album_form_left.addRow(self.tr('Location'), self.widgets['album_location']) # right hand side album_form_right = QtWidgets.QVBoxLayout() album_group.layout().addLayout(album_form_right) # album thumbnail self.widgets['album_thumb'] = QtWidgets.QLabel() self.widgets['album_thumb'].setFixedSize(150, 150) self.widgets['album_thumb'].setAlignment(Qt.AlignHCenter | Qt.AlignTop) album_form_right.addWidget(self.widgets['album_thumb']) album_form_right.addStretch(1) # new album new_album_button = QtWidgets.QPushButton(self.tr('New album')) new_album_button.clicked.connect(self.new_album) album_form_right.addWidget(new_album_button) self.layout().addWidget(album_group, stretch=1)
def __init__(self, image_list, *arg, **kw): super(Technical, self).__init__(*arg, **kw) self.image_list = image_list self.setLayout(QtWidgets.QGridLayout()) self.widgets = {} self.date_widget = {} self.link_widget = {} # store lens data in another object self.lens_data = LensData() # date and time date_group = QtWidgets.QGroupBox(self.tr('Date and time')) date_group.setLayout(QtWidgets.QFormLayout()) # taken self.date_widget['taken'] = DateAndTimeWidget() self.date_widget['taken'].new_value.connect(self.new_date_taken) date_group.layout().addRow(self.tr('Taken'), self.date_widget['taken']) # link taken & digitised self.link_widget['taken', 'digitised'] = QtWidgets.QCheckBox( self.tr("Link 'taken' and 'digitised'")) self.link_widget['taken', 'digitised'].clicked.connect(self.new_link_digitised) date_group.layout().addRow('', self.link_widget['taken', 'digitised']) # digitised self.date_widget['digitised'] = DateAndTimeWidget() self.date_widget['digitised'].new_value.connect( self.new_date_digitised) date_group.layout().addRow(self.tr('Digitised'), self.date_widget['digitised']) # link digitised & modified self.link_widget['digitised', 'modified'] = QtWidgets.QCheckBox( self.tr("Link 'digitised' and 'modified'")) self.link_widget['digitised', 'modified'].clicked.connect(self.new_link_modified) date_group.layout().addRow('', self.link_widget['digitised', 'modified']) # modified self.date_widget['modified'] = DateAndTimeWidget() self.date_widget['modified'].new_value.connect(self.new_date_modified) date_group.layout().addRow(self.tr('Modified'), self.date_widget['modified']) # offset self.offset_widget = OffsetWidget() self.offset_widget.apply_offset.connect(self.apply_offset) date_group.layout().addRow(self.tr('Adjust times'), self.offset_widget) self.layout().addWidget(date_group, 0, 0) # other other_group = QtWidgets.QGroupBox(self.tr('Other')) other_group.setLayout(QtWidgets.QFormLayout()) # orientation self.widgets['orientation'] = DropdownEdit() self.widgets['orientation'].add_item(self.tr('normal'), 1) self.widgets['orientation'].add_item(self.tr('rotate -90'), 6) self.widgets['orientation'].add_item(self.tr('rotate +90'), 8) self.widgets['orientation'].add_item(self.tr('rotate 180'), 3) self.widgets['orientation'].add_item(self.tr('reflect left-right'), 2) self.widgets['orientation'].add_item(self.tr('reflect top-bottom'), 4) self.widgets['orientation'].add_item(self.tr('reflect tr-bl'), 5) self.widgets['orientation'].add_item(self.tr('reflect tl-br'), 7) self.widgets['orientation'].new_value.connect(self.new_orientation) other_group.layout().addRow(self.tr('Orientation'), self.widgets['orientation']) # lens model self.widgets['lens_model'] = DropdownEdit() self.widgets['lens_model'].setContextMenuPolicy(Qt.CustomContextMenu) self.widgets['lens_model'].add_item(self.tr('<define new lens>'), '<add lens>') for model in self.lens_data.lenses: self.widgets['lens_model'].add_item(model, model) self.widgets['lens_model'].new_value.connect(self.new_lens_model) self.widgets['lens_model'].customContextMenuRequested.connect( self.remove_lens_model) other_group.layout().addRow(self.tr('Lens model'), self.widgets['lens_model']) # lens specification self.widgets['lens_spec'] = LensSpecWidget() other_group.layout().addRow(self.tr('Lens details'), self.widgets['lens_spec']) # focal length self.widgets['focal_length'] = FloatEdit() self.widgets['focal_length'].validator().setBottom(0.1) self.widgets['focal_length'].editingFinished.connect( self.new_focal_length) other_group.layout().addRow(self.tr('Focal length (mm)'), self.widgets['focal_length']) # 35mm equivalent focal length self.widgets['focal_length_35'] = IntEdit() self.widgets['focal_length_35'].validator().setBottom(1) self.widgets['focal_length_35'].editingFinished.connect( self.new_focal_length_35) other_group.layout().addRow(self.tr('35mm equiv (mm)'), self.widgets['focal_length_35']) # aperture self.widgets['aperture'] = FloatEdit() self.widgets['aperture'].validator().setBottom(0.1) self.widgets['aperture'].editingFinished.connect(self.new_aperture) other_group.layout().addRow(self.tr('Aperture f/'), self.widgets['aperture']) self.layout().addWidget(other_group, 0, 1) self.layout().setColumnStretch(0, 1) self.layout().setColumnStretch(1, 1) # disable until an image is selected self.setEnabled(False)
def __init__(self, image_list, *arg, **kw): super(TabWidget, self).__init__(*arg, **kw) self.config_store = QtWidgets.QApplication.instance().config_store self.image_list = image_list self.setLayout(QtWidgets.QHBoxLayout()) self.widgets = {} self.date_widget = {} self.link_widget = {} # date and time date_group = QtWidgets.QGroupBox( translate('TechnicalTab', 'Date and time')) date_group.setLayout(QtWidgets.QFormLayout()) # create date and link widgets for master in self._master_slave: self.date_widget[master] = DateAndTimeWidget(master) self.date_widget[master].new_value.connect(self.new_date_value) slave = self._master_slave[master] if slave: self.link_widget[master, slave] = DateLink(master) self.link_widget[master, slave].new_link.connect(self.new_link) self.link_widget['taken', 'digitised'].setText( translate('TechnicalTab', "Link 'taken' and 'digitised'")) self.link_widget['digitised', 'modified'].setText( translate('TechnicalTab', "Link 'digitised' and 'modified'")) # add to layout date_group.layout().addRow(translate('TechnicalTab', 'Taken'), self.date_widget['taken']) date_group.layout().addRow('', self.link_widget['taken', 'digitised']) date_group.layout().addRow(translate('TechnicalTab', 'Digitised'), self.date_widget['digitised']) date_group.layout().addRow('', self.link_widget['digitised', 'modified']) date_group.layout().addRow(translate('TechnicalTab', 'Modified'), self.date_widget['modified']) # offset self.offset_widget = OffsetWidget() self.offset_widget.apply_offset.connect(self.apply_offset) date_group.layout().addRow( translate('TechnicalTab', 'Adjust times'), self.offset_widget) self.layout().addWidget(date_group) # other other_group = QtWidgets.QGroupBox(translate('TechnicalTab', 'Other')) other_group.setLayout(QtWidgets.QFormLayout()) other_group.layout().setFieldGrowthPolicy( QtWidgets.QFormLayout.AllNonFixedFieldsGrow) # orientation self.widgets['orientation'] = DropdownEdit() self.widgets['orientation'].add_item( translate('TechnicalTab', 'normal'), 1, ordered=False) self.widgets['orientation'].add_item( translate('TechnicalTab', 'rotate -90'), 6, ordered=False) self.widgets['orientation'].add_item( translate('TechnicalTab', 'rotate +90'), 8, ordered=False) self.widgets['orientation'].add_item( translate('TechnicalTab', 'rotate 180'), 3, ordered=False) self.widgets['orientation'].add_item( translate('TechnicalTab', 'reflect left-right'), 2, ordered=False) self.widgets['orientation'].add_item( translate('TechnicalTab', 'reflect top-bottom'), 4, ordered=False) self.widgets['orientation'].add_item( translate('TechnicalTab', 'reflect tr-bl'), 5, ordered=False) self.widgets['orientation'].add_item( translate('TechnicalTab', 'reflect tl-br'), 7, ordered=False) self.widgets['orientation'].new_value.connect(self.new_orientation) other_group.layout().addRow(translate( 'TechnicalTab', 'Orientation'), self.widgets['orientation']) # camera model self.widgets['camera_model'] = CameraList(extendable=True) self.widgets['camera_model'].setMinimumWidth( width_for_text(self.widgets['camera_model'], 'x' * 30)) self.widgets['camera_model'].new_value.connect(self.new_camera_model) self.widgets['camera_model'].extend_list.connect(self.add_camera_model) other_group.layout().addRow(translate( 'TechnicalTab', 'Camera'), self.widgets['camera_model']) # lens model self.widgets['lens_model'] = LensList(extendable=True) self.widgets['lens_model'].setMinimumWidth( width_for_text(self.widgets['lens_model'], 'x' * 30)) self.widgets['lens_model'].new_value.connect(self.new_lens_model) self.widgets['lens_model'].extend_list.connect(self.add_lens_model) other_group.layout().addRow(translate( 'TechnicalTab', 'Lens model'), self.widgets['lens_model']) # focal length self.widgets['focal_length'] = DoubleSpinBox() self.widgets['focal_length'].setMinimum(0.0) self.widgets['focal_length'].setSuffix(' mm') self.widgets['focal_length'].new_value.connect(self.new_focal_length) other_group.layout().addRow(translate( 'TechnicalTab', 'Focal length'), self.widgets['focal_length']) # 35mm equivalent focal length self.widgets['focal_length_35'] = IntSpinBox() self.widgets['focal_length_35'].setMinimum(0) self.widgets['focal_length_35'].setSuffix(' mm') self.widgets['focal_length_35'].new_value.connect(self.new_focal_length_35) other_group.layout().addRow(translate( 'TechnicalTab', '35mm equiv'), self.widgets['focal_length_35']) # aperture self.widgets['aperture'] = DoubleSpinBox() self.widgets['aperture'].setMinimum(0.0) self.widgets['aperture'].setPrefix('ƒ/') self.widgets['aperture'].new_value.connect(self.new_aperture) other_group.layout().addRow(translate( 'TechnicalTab', 'Aperture'), self.widgets['aperture']) self.layout().addWidget(other_group, stretch=1) # disable until an image is selected self.setEnabled(False)
def _find_local(self, photo, unknowns): granularity = int(photo['datetakengranularity']) min_taken_date = datetime.strptime( photo['datetaken'], '%Y-%m-%d %H:%M:%S') if granularity <= 0: max_taken_date = min_taken_date + timedelta(seconds=1) elif granularity <= 4: max_taken_date = min_taken_date + timedelta(days=31) else: max_taken_date = min_taken_date + timedelta(days=366) candidates = [] for candidate in unknowns: if not candidate.metadata.date_taken: continue date_taken = candidate.metadata.date_taken['datetime'] if date_taken < min_taken_date or date_taken > max_taken_date: continue candidates.append(candidate) if not candidates: return None rsp = requests.get(photo['url_t']) if rsp.status_code == 200: flickr_icon = rsp.content else: logger.error('HTTP error %d (%s)', rsp.status_code, photo['url_t']) return None # get user to choose matching image file dialog = QtWidgets.QDialog(parent=self) dialog.setWindowTitle(translate('FlickrTab', 'Select an image')) dialog.setLayout(QtWidgets.QFormLayout()) dialog.layout().setFieldGrowthPolicy( QtWidgets.QFormLayout.AllNonFixedFieldsGrow) pixmap = QtGui.QPixmap() pixmap.loadFromData(flickr_icon) label = QtWidgets.QLabel() label.setPixmap(pixmap) dialog.layout().addRow(label, QtWidgets.QLabel(translate( 'FlickrTab', 'Which image file matches\nthis picture on Flickr?'))) divider = QtWidgets.QFrame() divider.setFrameStyle(QtWidgets.QFrame.HLine) dialog.layout().addRow(divider) buttons = {} for candidate in candidates: label = QtWidgets.QLabel() pixmap = candidate.image.pixmap() if pixmap: label.setPixmap(pixmap) else: label.setText(candidate.image.text()) button = QtWidgets.QPushButton( os.path.basename(candidate.path)) button.setToolTip(candidate.path) button.setCheckable(True) button.clicked.connect(dialog.accept) dialog.layout().addRow(label, button) buttons[button] = candidate button = QtWidgets.QPushButton(translate('FlickrTab', 'No match')) button.setDefault(True) button.clicked.connect(dialog.reject) dialog.layout().addRow('', button) if dialog.exec_() == QtWidgets.QDialog.Accepted: for button, candidate in buttons.items(): if button.isChecked(): return candidate return None
def __init__(self, *arg, **kw): super(EditSettings, self).__init__(*arg, **kw) self.config_store = QtWidgets.QApplication.instance().config_store self.setWindowTitle(self.tr('Photini: settings')) self.setLayout(QtWidgets.QVBoxLayout()) # main dialog area scroll_area = QtWidgets.QScrollArea() self.layout().addWidget(scroll_area) panel = QtWidgets.QWidget() panel.setLayout(QtWidgets.QFormLayout()) panel.layout().setRowWrapPolicy( max(QtWidgets.QFormLayout.WrapLongRows, panel.layout().rowWrapPolicy())) # apply & cancel buttons self.button_box = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Apply | QtWidgets.QDialogButtonBox.Cancel) self.button_box.clicked.connect(self.button_clicked) self.layout().addWidget(self.button_box) # copyright holder name self.copyright_name = SingleLineEdit(spell_check=True) self.copyright_name.set_value( self.config_store.get('user', 'copyright_name', '')) panel.layout().addRow(self.tr('Copyright holder name'), self.copyright_name) # copyright text self.copyright_text = SingleLineEdit(spell_check=True) self.copyright_text.set_value( self.config_store.get('user', 'copyright_text', '')) self.copyright_text.setMinimumWidth( width_for_text(self.copyright_text, 'x' * 50)) panel.layout().addRow(self.tr('Copyright text'), self.copyright_text) # creator name self.creator_name = SingleLineEdit(spell_check=True) self.creator_name.set_value( self.config_store.get('user', 'creator_name', '')) panel.layout().addRow(self.tr('Creator name'), self.creator_name) # IPTC data force_iptc = self.config_store.get('files', 'force_iptc', False) self.write_iptc = QtWidgets.QCheckBox(self.tr('Always write')) self.write_iptc.setChecked(force_iptc) panel.layout().addRow(self.tr('IPTC-IIM metadata'), self.write_iptc) # show IPTC-IIM length limits length_warning = self.config_store.get('files', 'length_warning', True) self.length_warning = QtWidgets.QCheckBox( self.tr('Show IPTC-IIM length limits')) self.length_warning.setChecked(length_warning) panel.layout().addRow('', self.length_warning) # sidecar files if_mode = self.config_store.get('files', 'image', True) sc_mode = self.config_store.get('files', 'sidecar', 'auto') if not if_mode: sc_mode = 'always' button_group = QtWidgets.QButtonGroup(parent=self) self.sc_always = QtWidgets.QRadioButton(self.tr('Always create')) button_group.addButton(self.sc_always) self.sc_always.setChecked(sc_mode == 'always') panel.layout().addRow(self.tr('Sidecar files'), self.sc_always) self.sc_auto = QtWidgets.QRadioButton(self.tr('Create if necessary')) button_group.addButton(self.sc_auto) self.sc_auto.setChecked(sc_mode == 'auto') self.sc_auto.setEnabled(if_mode) panel.layout().addRow('', self.sc_auto) self.sc_delete = QtWidgets.QRadioButton( self.tr('Delete when possible')) button_group.addButton(self.sc_delete) self.sc_delete.setChecked(sc_mode == 'delete') self.sc_delete.setEnabled(if_mode) panel.layout().addRow('', self.sc_delete) # image file locking self.write_if = QtWidgets.QCheckBox(self.tr('(when possible)')) self.write_if.setChecked(if_mode) self.write_if.clicked.connect(self.new_write_if) panel.layout().addRow(self.tr('Write to image file'), self.write_if) # preserve file timestamps keep_time = self.config_store.get('files', 'preserve_timestamps', 'now') if isinstance(keep_time, bool): # old config format keep_time = ('now', 'keep')[keep_time] button_group = QtWidgets.QButtonGroup(parent=self) self.keep_time = QtWidgets.QRadioButton(self.tr('Keep original')) button_group.addButton(self.keep_time) self.keep_time.setChecked(keep_time == 'keep') panel.layout().addRow(self.tr('File timestamps'), self.keep_time) self.time_taken = QtWidgets.QRadioButton( self.tr('Set to when photo was taken')) button_group.addButton(self.time_taken) self.time_taken.setChecked(keep_time == 'taken') panel.layout().addRow('', self.time_taken) button = QtWidgets.QRadioButton(self.tr('Set to when file is saved')) button_group.addButton(button) button.setChecked(keep_time == 'now') panel.layout().addRow('', button) # add panel to scroll area after its size is known scroll_area.setWidget(panel)
def __init__(self, image_list, parent=None): super(PhotiniMap, self).__init__(parent) self.app = QtWidgets.QApplication.instance() self.image_list = image_list self.geocode_cache = OrderedDict() name = self.__module__.split('.')[-1] self.api_key = key_store.get(name, 'api_key') self.search_key = key_store.get('opencage', 'api_key') self.script_dir = pkg_resources.resource_filename( 'photini', 'data/' + name + '/') self.drag_icon = QtGui.QPixmap( os.path.join(self.script_dir, '../map_pin_grey.png')) self.drag_hotspot = 11, 35 self.search_string = None self.map_loaded = False self.marker_info = {} self.map_status = {} self.dropped_images = [] self.setChildrenCollapsible(False) left_side = QtWidgets.QWidget() self.addWidget(left_side) left_side.setLayout(QtWidgets.QFormLayout()) left_side.layout().setContentsMargins(0, 0, 0, 0) left_side.layout().setFieldGrowthPolicy( QtWidgets.QFormLayout.AllNonFixedFieldsGrow) # map # create handler for calls from JavaScript self.call_handler = CallHandler(parent=self) self.map = MapWebView(self.call_handler) self.map.drop_text.connect(self.drop_text) self.map.setAcceptDrops(False) self.addWidget(self.map) # search search_layout = QtWidgets.QFormLayout() search_layout.setContentsMargins(0, 0, 0, 0) search_layout.setVerticalSpacing(0) search_layout.setFieldGrowthPolicy( QtWidgets.QFormLayout.AllNonFixedFieldsGrow) self.edit_box = ComboBox() self.edit_box.setEditable(True) self.edit_box.setInsertPolicy(QtWidgets.QComboBox.NoInsert) self.edit_box.lineEdit().setPlaceholderText( translate('PhotiniMap', '<new search>')) self.edit_box.lineEdit().returnPressed.connect(self.search) self.edit_box.activated.connect(self.goto_search_result) self.clear_search() self.edit_box.setEnabled(False) search_layout.addRow(translate('PhotiniMap', 'Search'), self.edit_box) # search terms and conditions terms = self.search_terms() if terms: search_layout.addRow(*terms) left_side.layout().addRow(search_layout) if terms: divider = QtWidgets.QFrame() divider.setFrameStyle(QtWidgets.QFrame.HLine) left_side.layout().addRow(divider) left_side.layout().addItem( QtWidgets.QSpacerItem(1, 1000, vPolicy=QtWidgets.QSizePolicy.Expanding)) # latitude & longitude layout = QtWidgets.QHBoxLayout() self.coords = SingleLineEdit() self.coords.editingFinished.connect(self.new_coords) self.coords.setEnabled(False) layout.addWidget(self.coords) # convert lat/lng to location info self.auto_location = QtWidgets.QPushButton( translate('PhotiniMap', six.unichr(0x21e8) + ' address')) self.auto_location.setFixedHeight(self.coords.height()) self.auto_location.setEnabled(False) self.auto_location.clicked.connect(self.get_address) layout.addWidget(self.auto_location) left_side.layout().addRow(translate('PhotiniMap', 'Lat, long'), layout) # location info self.location_widgets = [] self.location_info = QtWidgets.QTabWidget() tab_bar = QTabBar() self.location_info.setTabBar(tab_bar) tab_bar.context_menu.connect(self.location_tab_context_menu) tab_bar.tabMoved.connect(self.location_tab_moved) self.location_info.setElideMode(Qt.ElideLeft) self.location_info.setMovable(True) self.location_info.setEnabled(False) left_side.layout().addRow(self.location_info) # address lookup (and default search) terms and conditions layout = QtWidgets.QHBoxLayout() if terms: widget = CompactButton( self.tr('Address lookup\npowered by OpenCage')) else: widget = CompactButton( self.tr('Search && lookup\npowered by OpenCage')) widget.clicked.connect(self.load_tou_opencage) layout.addWidget(widget) widget = CompactButton( self.tr('Geodata © OpenStreetMap\ncontributors')) widget.clicked.connect(self.load_tou_osm) layout.addWidget(widget) left_side.layout().addRow(layout) # other init self.image_list.image_list_changed.connect(self.image_list_changed) self.splitterMoved.connect(self.new_split) self.block_timer = QtCore.QTimer(self) self.block_timer.setInterval(5000) self.block_timer.setSingleShot(True) self.block_timer.timeout.connect(self.enable_search)
def __init__(self, image_list, parent=None): super(TabWidget, self).__init__(parent) app = QtWidgets.QApplication.instance() app.aboutToQuit.connect(self.shutdown) if gp and app.test_mode: self.gp_log = gp.check_result(gp.use_python_logging()) self.config_store = app.config_store self.image_list = image_list self.setLayout(QtWidgets.QGridLayout()) form = QtWidgets.QFormLayout() form.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow) self.nm = NameMangler() self.file_data = {} self.file_list = [] self.source = None self.file_copier = None # source selector box = QtWidgets.QHBoxLayout() box.setContentsMargins(0, 0, 0, 0) self.source_selector = QtWidgets.QComboBox() self.source_selector.currentIndexChanged.connect(self.new_source) box.addWidget(self.source_selector) refresh_button = QtWidgets.QPushButton(self.tr('refresh')) refresh_button.clicked.connect(self.refresh) box.addWidget(refresh_button) box.setStretch(0, 1) form.addRow(self.tr('Source'), box) # path format self.path_format = QtWidgets.QLineEdit() self.path_format.setValidator(PathFormatValidator()) self.path_format.textChanged.connect(self.nm.new_format) self.path_format.editingFinished.connect(self.path_format_finished) form.addRow(self.tr('Target format'), self.path_format) # path example self.path_example = QtWidgets.QLabel() self.nm.new_example.connect(self.path_example.setText) form.addRow('=>', self.path_example) self.layout().addLayout(form, 0, 0) # file list self.file_list_widget = QtWidgets.QListWidget() self.file_list_widget.setSelectionMode( QtWidgets.QAbstractItemView.ExtendedSelection) self.file_list_widget.itemSelectionChanged.connect( self.selection_changed) self.layout().addWidget(self.file_list_widget, 1, 0) # selection buttons buttons = QtWidgets.QVBoxLayout() buttons.addStretch(1) self.selected_count = QtWidgets.QLabel() buttons.addWidget(self.selected_count) select_all = QtWidgets.QPushButton(self.tr('Select\nall')) select_all.clicked.connect(self.select_all) buttons.addWidget(select_all) select_new = QtWidgets.QPushButton(self.tr('Select\nnew')) select_new.clicked.connect(self.select_new) buttons.addWidget(select_new) # copy buttons self.move_button = StartStopButton(self.tr('Move\nphotos'), self.tr('Stop\nmove')) self.move_button.click_start.connect(self.move_selected) self.move_button.click_stop.connect(self.stop_copy) buttons.addWidget(self.move_button) self.copy_button = StartStopButton(self.tr('Copy\nphotos'), self.tr('Stop\ncopy')) self.copy_button.click_start.connect(self.copy_selected) self.copy_button.click_stop.connect(self.stop_copy) buttons.addWidget(self.copy_button) self.layout().addLayout(buttons, 0, 1, 2, 1) self.selection_changed() # final initialisation self.image_list.sort_order_changed.connect(self.sort_file_list) if qt_version_info >= (5, 0): path = QtCore.QStandardPaths.writableLocation( QtCore.QStandardPaths.PicturesLocation) else: path = QtGui.QDesktopServices.storageLocation( QtGui.QDesktopServices.PicturesLocation) self.path_format.setText(os.path.join(path, '%Y', '%Y_%m_%d', '{name}')) self.refresh() self.list_files()
def __init__(self, *arg, **kw): super(EditSettings, self).__init__(*arg, **kw) self.config_store = QtWidgets.QApplication.instance().config_store self.setWindowTitle(self.tr('Photini: settings')) self.setLayout(QtWidgets.QVBoxLayout()) # main dialog area scroll_area = QtWidgets.QScrollArea() self.layout().addWidget(scroll_area) panel = QtWidgets.QWidget() panel.setLayout(QtWidgets.QFormLayout()) panel.layout().setRowWrapPolicy( max(QtWidgets.QFormLayout.WrapLongRows, panel.layout().rowWrapPolicy())) # apply & cancel buttons self.button_box = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Apply | QtWidgets.QDialogButtonBox.Cancel) self.button_box.clicked.connect(self.button_clicked) self.layout().addWidget(self.button_box) # copyright holder name self.copyright_name = SingleLineEdit(spell_check=True) self.copyright_name.set_value( self.config_store.get('user', 'copyright_name', '')) panel.layout().addRow(self.tr('Copyright holder name'), self.copyright_name) # copyright text self.copyright_text = SingleLineEdit(spell_check=True) self.copyright_text.set_value( self.config_store.get('user', 'copyright_text', '')) self.copyright_text.setMinimumWidth( width_for_text(self.copyright_text, 'x' * 50)) panel.layout().addRow(self.tr('Copyright text'), self.copyright_text) # creator name self.creator_name = SingleLineEdit(spell_check=True) self.creator_name.set_value( self.config_store.get('user', 'creator_name', '')) panel.layout().addRow(self.tr('Creator name'), self.creator_name) # IPTC data force_iptc = eval(self.config_store.get('files', 'force_iptc', 'False')) self.write_iptc = QtWidgets.QCheckBox(self.tr('Always write')) self.write_iptc.setChecked(force_iptc) panel.layout().addRow(self.tr('IPTC metadata'), self.write_iptc) # sidecar files if_mode = eval(self.config_store.get('files', 'image', 'True')) sc_mode = self.config_store.get('files', 'sidecar', 'auto') if not if_mode: sc_mode = 'always' self.sc_always = QtWidgets.QRadioButton(self.tr('Always create')) self.sc_always.setChecked(sc_mode == 'always') panel.layout().addRow(self.tr('Sidecar files'), self.sc_always) self.sc_auto = QtWidgets.QRadioButton(self.tr('Create if necessary')) self.sc_auto.setChecked(sc_mode == 'auto') self.sc_auto.setEnabled(if_mode) panel.layout().addRow('', self.sc_auto) self.sc_delete = QtWidgets.QRadioButton( self.tr('Delete when possible')) self.sc_delete.setChecked(sc_mode == 'delete') self.sc_delete.setEnabled(if_mode) panel.layout().addRow('', self.sc_delete) # image file locking self.write_if = QtWidgets.QCheckBox(self.tr('(when possible)')) self.write_if.setChecked(if_mode) self.write_if.clicked.connect(self.new_write_if) panel.layout().addRow(self.tr('Write to image file'), self.write_if) # preserve file timestamps keep_time = eval( self.config_store.get('files', 'preserve_timestamps', 'False')) self.keep_time = QtWidgets.QCheckBox() self.keep_time.setChecked(keep_time) panel.layout().addRow(self.tr('Preserve file timestamps'), self.keep_time) # add panel to scroll area after its size is known scroll_area.setWidget(panel)
def __init__(self, image_list, *arg, **kw): super(Technical, self).__init__(*arg, **kw) self.config_store = QtWidgets.QApplication.instance().config_store self.image_list = image_list self.setLayout(QtWidgets.QHBoxLayout()) self.widgets = {} self.date_widget = {} self.link_widget = {} # store lens data in another object self.lens_data = LensData() # date and time date_group = QtWidgets.QGroupBox(self.tr('Date and time')) date_group.setLayout(QtWidgets.QFormLayout()) # create date and link widgets for master in self._master_slave: self.date_widget[master] = DateAndTimeWidget(master) self.date_widget[master].new_value.connect(self.new_date_value) slave = self._master_slave[master] if slave: self.link_widget[master, slave] = DateLink(master) self.link_widget[master, slave].new_link.connect(self.new_link) self.link_widget['taken', 'digitised'].setText( self.tr("Link 'taken' and 'digitised'")) self.link_widget['digitised', 'modified'].setText( self.tr("Link 'digitised' and 'modified'")) # add to layout date_group.layout().addRow(self.tr('Taken'), self.date_widget['taken']) date_group.layout().addRow('', self.link_widget['taken', 'digitised']) date_group.layout().addRow(self.tr('Digitised'), self.date_widget['digitised']) date_group.layout().addRow('', self.link_widget['digitised', 'modified']) date_group.layout().addRow(self.tr('Modified'), self.date_widget['modified']) # offset self.offset_widget = OffsetWidget() self.offset_widget.apply_offset.connect(self.apply_offset) date_group.layout().addRow(self.tr('Adjust times'), self.offset_widget) self.layout().addWidget(date_group) # other other_group = QtWidgets.QGroupBox(self.tr('Other')) other_group.setLayout(QtWidgets.QFormLayout()) other_group.layout().setFieldGrowthPolicy( QtWidgets.QFormLayout.AllNonFixedFieldsGrow) # orientation self.widgets['orientation'] = DropdownEdit() self.widgets['orientation'].add_item(self.tr('normal'), 1) self.widgets['orientation'].add_item(self.tr('rotate -90'), 6) self.widgets['orientation'].add_item(self.tr('rotate +90'), 8) self.widgets['orientation'].add_item(self.tr('rotate 180'), 3) self.widgets['orientation'].add_item(self.tr('reflect left-right'), 2) self.widgets['orientation'].add_item(self.tr('reflect top-bottom'), 4) self.widgets['orientation'].add_item(self.tr('reflect tr-bl'), 5) self.widgets['orientation'].add_item(self.tr('reflect tl-br'), 7) self.widgets['orientation'].new_value.connect(self.new_orientation) other_group.layout().addRow( self.tr('Orientation'), self.widgets['orientation']) # lens model self.widgets['lens_model'] = DropdownEdit() self.widgets['lens_model'].setMinimumWidth( self.widgets['lens_model'].fontMetrics().width('x' * 30)) self.widgets['lens_model'].setContextMenuPolicy(Qt.CustomContextMenu) self.widgets['lens_model'].add_item( self.tr('<define new lens>'), '<add lens>') for model in self.lens_data.lenses: self.widgets['lens_model'].add_item(model, model) self.widgets['lens_model'].new_value.connect(self.new_lens_model) self.widgets['lens_model'].customContextMenuRequested.connect( self.remove_lens_model) other_group.layout().addRow( self.tr('Lens model'), self.widgets['lens_model']) # lens specification self.widgets['lens_spec'] = LensSpecWidget() other_group.layout().addRow( self.tr('Lens details'), self.widgets['lens_spec']) # focal length self.widgets['focal_length'] = NumberEdit() self.widgets['focal_length'].setValidator(DoubleValidator()) self.widgets['focal_length'].validator().setBottom(0.1) self.widgets['focal_length'].new_value.connect(self.new_focal_length) other_group.layout().addRow( self.tr('Focal length (mm)'), self.widgets['focal_length']) # 35mm equivalent focal length self.widgets['focal_length_35'] = NumberEdit() self.widgets['focal_length_35'].setValidator(IntValidator()) self.widgets['focal_length_35'].validator().setBottom(1) self.widgets['focal_length_35'].new_value.connect(self.new_focal_length_35) other_group.layout().addRow( self.tr('35mm equiv (mm)'), self.widgets['focal_length_35']) # aperture self.widgets['aperture'] = NumberEdit() self.widgets['aperture'].setValidator(DoubleValidator()) self.widgets['aperture'].validator().setBottom(0.1) self.widgets['aperture'].new_value.connect(self.new_aperture) other_group.layout().addRow( self.tr('Aperture f/'), self.widgets['aperture']) self.layout().addWidget(other_group, stretch=1) # disable until an image is selected self.setEnabled(False)