Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.image_list = image_list
name = self.__module__.split('.')[-1]
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.geocoder = self.get_geocoder()
self.setLayout(QtWidgets.QHBoxLayout())
## left side
left_side = QtWidgets.QGridLayout()
# latitude & longitude
self.coords = LatLongDisplay(self.image_list)
left_side.addWidget(self.coords.label, 0, 0)
self.coords.changed.connect(self.new_coords)
left_side.addWidget(self.coords, 0, 1)
# altitude
label = QtWidgets.QLabel(translate('MapTabsAll', 'Altitude'))
label.setAlignment(Qt.AlignRight)
left_side.addWidget(label, 1, 0)
self.altitude = DoubleSpinBox()
self.altitude.setSuffix(' m')
self.altitude.new_value.connect(self.new_altitude)
left_side.addWidget(self.altitude, 1, 1)
if hasattr(self.geocoder, 'get_altitude'):
self.altitude_button = QtWidgets.QPushButton(
translate('MapTabsAll', 'Get altitude from map'))
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)
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(
def __init__(self, *arg, **kw):
super(KeywordsEditor, self).__init__(*arg, **kw)
self.config_store = QtWidgets.QApplication.instance().config_store
self.league_table = defaultdict(int)
for keyword, score in eval(self.config_store.get(
'descriptive', 'keywords', '{}')).items():
self.league_table[keyword] = score
layout = QtWidgets.QHBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
self.setLayout(layout)
# line edit box
self.edit = SingleLineEdit(spell_check=True)
layout.addWidget(self.edit)
# favourites drop down
self.favourites = ComboBox()
self.update_favourites()
self.favourites.setFixedWidth(self.favourites.title_width())
self.favourites.currentIndexChanged.connect(self.add_favourite)
layout.addWidget(self.favourites)
def upload_error(self, name, error):
dialog = QtWidgets.QMessageBox(self)
dialog.setWindowTitle(translate(
'UploaderTabsAll', 'Photini: upload error'))
dialog.setText(translate(
'UploaderTabsAll', '<h3>File "{}" upload failed.</h3>').format(
name))
dialog.setInformativeText(error)
dialog.setIcon(QtWidgets.QMessageBox.Warning)
dialog.setStandardButtons(QtWidgets.QMessageBox.Abort |
QtWidgets.QMessageBox.Retry)
dialog.setDefaultButton(QtWidgets.QMessageBox.Retry)
self.abort_upload.emit(dialog.exec_() == QtWidgets.QMessageBox.Retry)
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 location metadata'), self.widgets['geo_tag'])
self.widgets['geo_tag'].setChecked(True)
label = config_group.layout().labelForField(self.widgets['geo_tag'])
label.setWordWrap(True)
def diff_metadata(self):
dialog = QtWidgets.QDialog(parent=self)
dialog.setWindowTitle(translate('ImageList', 'Metadata differences'))
dialog.setLayout(QtWidgets.QVBoxLayout())
table = TableWidget()
table.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
QtWidgets.QSizePolicy.Expanding)
table.setColumnCount(3)
table.setHorizontalHeaderLabels([translate('ImageList', 'new value'),
translate('ImageList', 'undo'),
translate('ImageList', 'old value')])
labels = []
row = 0
undo = {}
new_md = self.metadata
old_md = Metadata(self.path)
for key in ('title', 'description', 'keywords', 'rating',
'copyright', 'creator',
'date_taken', 'date_digitised', 'date_modified',
'orientation',
'lens_model', 'lens_make', 'lens_serial', 'lens_spec',
'focal_length', 'focal_length_35', 'aperture',
def new_set(self):
title, OK = QtWidgets.QInputDialog.getText(
self, translate('GooglePhotosTab', 'Album title'),
translate('GooglePhotosTab', 'Please enter a title for the album'))
if not OK or not title:
return
album = self.session.new_album(title)
if not album:
return
widget = self.upload_config.add_album(album, index=0)
widget.setChecked(True)
rsp = self.api.post(self.origin + path, **kw)
rsp.raise_for_status()
return rsp.json()
if QtWebEngineWidgets:
WebViewBase = QtWebEngineWidgets.QWebEngineView
else:
WebViewBase = QtWebKitWidgets.QWebView
class WebView(WebViewBase):
def sizeHint(self):
return QtCore.QSize(580, 490)
class FacebookLoginPopup(QtWidgets.QDialog):
def __init__(self, *arg, **kw):
super(FacebookLoginPopup, self).__init__(*arg, **kw)
self.setSizePolicy(
QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum)
self.setLayout(QtWidgets.QVBoxLayout())
self.browser = WebView()
self.browser.urlChanged.connect(self.auth_url_changed)
self.layout().addWidget(self.browser)
buttons = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Cancel)
buttons.rejected.connect(self.reject)
self.layout().addWidget(buttons)
def load_url(self, auth_url):
self.browser.load(QtCore.QUrl(auth_url))
@QtCore.pyqtSlot(QtCore.QUrl)