Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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()
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)
def new_set(self):
dialog = QtWidgets.QDialog(parent=self)
dialog.setWindowTitle(translate('FlickrTab', 'Create new Flickr album'))
dialog.setLayout(QtWidgets.QFormLayout())
title = SingleLineEdit(spell_check=True)
dialog.layout().addRow(translate('FlickrTab', 'Title'), title)
description = MultiLineEdit(spell_check=True)
dialog.layout().addRow(translate(
'FlickrTab', 'Description'), description)
dialog.layout().addRow(QtWidgets.QLabel(translate(
'FlickrTab', '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, None, index=0)
widget.setChecked(True)
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
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()
widget['new_photo'] = QtWidgets.QCheckBox(
translate('FlickrTab', 'Upload as new photo'))
no_upload = QtWidgets.QCheckBox(
translate('FlickrTab', 'No image upload'))
no_upload.setChecked(True)
button_group = QtWidgets.QButtonGroup()
button_group.addButton(widget['replace_image'])
button_group.addButton(widget['new_photo'])
button_group.addButton(no_upload)
for key in ('set_metadata', 'set_visibility', 'set_type',
'set_albums', 'replace_image', 'new_photo'):
dialog.layout().addWidget(widget[key])
widget[key].setChecked(self.replace_prefs[key])
dialog.layout().addWidget(no_upload)
button_box = QtWidgets.QDialogButtonBox(
QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel)
button_box.accepted.connect(dialog.accept)
button_box.rejected.connect(dialog.reject)
dialog.layout().addWidget(button_box)
if dialog.exec_() != QtWidgets.QDialog.Accepted:
return None, photo_id
for key in self.replace_prefs:
self.replace_prefs[key] = widget[key].isChecked()
return dict(self.replace_prefs), photo_id
translate('FlickrTab', 'Replace image'))
widget['new_photo'] = QtWidgets.QCheckBox(
translate('FlickrTab', 'Upload as new photo'))
no_upload = QtWidgets.QCheckBox(
translate('FlickrTab', 'No image upload'))
no_upload.setChecked(True)
button_group = QtWidgets.QButtonGroup()
button_group.addButton(widget['replace_image'])
button_group.addButton(widget['new_photo'])
button_group.addButton(no_upload)
for key in ('set_metadata', 'set_visibility', 'set_type',
'set_albums', 'replace_image', 'new_photo'):
dialog.layout().addWidget(widget[key])
widget[key].setChecked(self.replace_prefs[key])
dialog.layout().addWidget(no_upload)
button_box = QtWidgets.QDialogButtonBox(
QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel)
button_box.accepted.connect(dialog.accept)
button_box.rejected.connect(dialog.reject)
dialog.layout().addWidget(button_box)
if dialog.exec_() != QtWidgets.QDialog.Accepted:
return None, photo_id
for key in self.replace_prefs:
self.replace_prefs[key] = widget[key].isChecked()
return dict(self.replace_prefs), photo_id
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)
value = '\n'.join(value)
else:
value = six.text_type(value)
item = QtWidgets.QTableWidgetItem(value)
table.setItem(row, n * 2, item)
undo[key] = QtWidgets.QTableWidgetItem()
undo[key].setFlags(undo[key].flags() | Qt.ItemIsUserCheckable)
undo[key].setCheckState(False)
table.setItem(row, 1, undo[key])
labels.append(key)
row += 1
table.setVerticalHeaderLabels(labels)
table.resizeColumnsToContents()
table.resizeRowsToContents()
dialog.layout().addWidget(table)
button_box = QtWidgets.QDialogButtonBox(
QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel)
button_box.accepted.connect(dialog.accept)
button_box.rejected.connect(dialog.reject)
dialog.layout().addWidget(button_box)
if dialog.exec_() != QtWidgets.QDialog.Accepted:
return
changed = False
dirty = False
for key, widget in undo.items():
if widget.checkState() == Qt.Checked:
setattr(new_md, key, getattr(old_md, key))
changed = True
else:
dirty = True
if not dirty:
self.reload_metadata()