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, *arg, **kw): super(RatingWidget, self).__init__(*arg, **kw) self.multiple_values = multiple_values() self.setLayout(QtWidgets.QHBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) # slider self.slider = Slider(Qt.Horizontal) self.slider.setFixedWidth(200) self.slider.setRange(-2, 5) self.slider.setPageStep(1) self.slider.valueChanged.connect(self.set_display) self.layout().addWidget(self.slider) # display self.display = QtWidgets.QLineEdit() self.display.setFrame(False) self.display.setReadOnly(True) self.layout().addWidget(self.display) # adopt child methods/signals self.is_multiple = self.slider.is_multiple self.editing_finished = self.slider.editing_finished
def __init__(self, *arg, **kw): super(RatingWidget, self).__init__(*arg, **kw) self.multiple_values = multiple_values() self.setLayout(QtWidgets.QHBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) # slider self.slider = Slider(Qt.Horizontal) self.slider.setFixedWidth(width_for_text(self.slider, 'x' * 25)) self.slider.setRange(-2, 5) self.slider.setPageStep(1) self.slider.valueChanged.connect(self.set_display) self.layout().addWidget(self.slider) # display self.display = QtWidgets.QLineEdit() self.display.setStyleSheet("* {background-color:rgba(0,0,0,0);}") self.display.setFrame(False) self.display.setReadOnly(True) self.display.setContextMenuPolicy(Qt.NoContextMenu) self.display.setFocusPolicy(Qt.NoFocus) self.layout().addWidget(self.display) # adopt child methods/signals self.is_multiple = self.slider.is_multiple self.editing_finished = self.slider.editing_finished
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 __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 __init__(self, image_list, parent=None): super(PhotiniMap, self).__init__(parent) self.logger = logging.getLogger(self.__class__.__name__) self.app = QtWidgets.QApplication.instance() self.config_store = self.app.config_store self.image_list = image_list self.multiple_values = multiple_values() self.script_dir = pkg_resources.resource_filename( 'photini', 'data/' + self.__class__.__name__.lower() + '/') self.drag_icon = QtGui.QPixmap( os.path.join(self.script_dir, 'grey_marker.png')) self.location = {} self.search_string = None self.map_loaded = False self.marker_images = {} layout = QtWidgets.QGridLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setRowStretch(6, 1) layout.setColumnStretch(1, 1) self.setLayout(layout) # map self.map = WebView() self.map.setPage(WebPage(parent=self.map)) self.map.setAcceptDrops(False) self.map.page().setLinkDelegationPolicy( QtWebKitWidgets.QWebPage.DelegateAllLinks) self.map.page().linkClicked.connect(self.link_clicked) self.map.page().loadFinished.connect(self.load_finished) self.map.page().mainFrame().javaScriptWindowObjectCleared.connect( self.java_script_window_object_cleared) self.map.drop_text.connect(self.drop_text) self.layout().addWidget(self.map, 0, 1, 8, 1) # search self.layout().addWidget( QtWidgets.QLabel(translate('PhotiniMap', 'Search:')), 0, 0) self.edit_box = QtWidgets.QComboBox() self.edit_box.setMinimumWidth(200) 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) self.layout().addWidget(self.edit_box, 1, 0) # latitude & longitude self.layout().addWidget( QtWidgets.QLabel(translate('PhotiniMap', 'Latitude, longitude:')), 2, 0) self.coords = QtWidgets.QLineEdit() self.coords.editingFinished.connect(self.new_coords) self.coords.setEnabled(False) self.layout().addWidget(self.coords, 3, 0) # load map button self.load_map = QtWidgets.QPushButton( translate('PhotiniMap', '\nLoad map\n')) self.load_map.clicked.connect(self.initialise) self.layout().addWidget(self.load_map, 7, 0) # other init self.image_list.image_list_changed.connect(self.image_list_changed)
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, 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, 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()