Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
name = tab['name'].replace('&', '')
else:
name = tab['module']
tab['action'] = QtWidgets.QAction(name, self)
tab['action'].setCheckable(True)
if tab['class']:
tab['action'].setChecked(eval(
self.app.config_store.get('tabs', tab['module'], 'True')))
else:
tab['action'].setEnabled(False)
tab['action'].triggered.connect(self.add_tabs)
options_menu.addAction(tab['action'])
# spelling menu
languages = self.app.spell_check.available_languages()
spelling_menu = self.menuBar().addMenu(translate('MenuBar', 'Spelling'))
enable_action = QtWidgets.QAction(
translate('MenuBar', 'Enable spell check'), self)
enable_action.setEnabled(languages is not None)
enable_action.setCheckable(True)
enable_action.setChecked(self.app.spell_check.enabled)
enable_action.toggled.connect(self.app.spell_check.enable)
spelling_menu.addAction(enable_action)
language_menu = QtWidgets.QMenu(
translate('MenuBar', 'Choose language'), self)
language_menu.setEnabled(languages is not None)
current_language = self.app.spell_check.current_language()
if languages:
language_group = QtWidgets.QActionGroup(self)
for name, code in languages:
if name != code:
name = code + ': ' + name
language_action = QtWidgets.QAction(name, self)
self.import_gpx_action = QtWidgets.QAction(
translate('MenuBar', 'Import GPX file'), self)
self.import_gpx_action.triggered.connect(self.import_pgx_file)
file_menu.addAction(self.import_gpx_action)
else:
self.import_gpx_action = None
file_menu.addSeparator()
quit_action = QtWidgets.QAction(translate('MenuBar', 'Quit'), self)
quit_action.setShortcuts(
[QtGui.QKeySequence.Quit, QtGui.QKeySequence.Close])
quit_action.triggered.connect(
QtWidgets.QApplication.instance().closeAllWindows)
file_menu.addAction(quit_action)
# options menu
options_menu = self.menuBar().addMenu(translate('MenuBar', 'Options'))
settings_action = QtWidgets.QAction(
translate('MenuBar', 'Settings'), self)
settings_action.triggered.connect(self.edit_settings)
options_menu.addAction(settings_action)
options_menu.addSeparator()
for tab in self.tab_list:
if tab['class']:
name = tab['name'].replace('&', '')
else:
name = tab['module']
tab['action'] = QtWidgets.QAction(name, self)
tab['action'].setCheckable(True)
if tab['class']:
tab['action'].setChecked(eval(
self.app.config_store.get('tabs', tab['module'], 'True')))
else:
tab['action'].setEnabled(False)
self.close_action.triggered.connect(self.close_files)
file_menu.addAction(self.close_action)
close_all_action = QtWidgets.QAction(
translate('MenuBar', 'Close all images'), self)
close_all_action.triggered.connect(self.close_all_files)
file_menu.addAction(close_all_action)
if GpxImporter:
file_menu.addSeparator()
self.import_gpx_action = QtWidgets.QAction(
translate('MenuBar', 'Import GPX file'), self)
self.import_gpx_action.triggered.connect(self.import_pgx_file)
file_menu.addAction(self.import_gpx_action)
else:
self.import_gpx_action = None
file_menu.addSeparator()
quit_action = QtWidgets.QAction(translate('MenuBar', 'Quit'), self)
quit_action.setShortcuts(
[QtGui.QKeySequence.Quit, QtGui.QKeySequence.Close])
quit_action.triggered.connect(
QtWidgets.QApplication.instance().closeAllWindows)
file_menu.addAction(quit_action)
# options menu
options_menu = self.menuBar().addMenu(translate('MenuBar', 'Options'))
settings_action = QtWidgets.QAction(
translate('MenuBar', 'Settings'), self)
settings_action.triggered.connect(self.edit_settings)
options_menu.addAction(settings_action)
options_menu.addSeparator()
for tab in self.tab_list:
if tab['class']:
name = tab['name'].replace('&', '')
else:
def set_multiple(self):
blocked = self.blockSignals(True)
self.setCurrentIndex(self.count() - 1)
self.blockSignals(blocked)
class AugmentSpinBox(object):
new_value = QtCore.pyqtSignal(object)
def __init__(self, *arg, **kw):
super(AugmentSpinBox, self).__init__(*arg, **kw)
self.set_value(None)
self.editingFinished.connect(self.editing_finished)
class ContextAction(QtWidgets.QAction):
def __init__(self, label, value, parent):
super(AugmentSpinBox.ContextAction, self).__init__(label, parent)
self.setData(value)
self.triggered.connect(self.set_value)
@QtCore.pyqtSlot()
@catch_all
def set_value(self):
self.parent().setValue(self.data())
@catch_all
def contextMenuEvent(self, event):
if self.specialValueText() and self.choices:
QtCore.QTimer.singleShot(0, self.extend_context_menu)
return super(self.__class__, self).contextMenuEvent(event)
quit_action.triggered.connect(
QtWidgets.QApplication.instance().closeAllWindows)
file_menu.addAction(quit_action)
# options menu
options_menu = self.menuBar().addMenu(translate('MenuBar', 'Options'))
settings_action = QtWidgets.QAction(
translate('MenuBar', 'Settings'), self)
settings_action.triggered.connect(self.edit_settings)
options_menu.addAction(settings_action)
options_menu.addSeparator()
for tab in self.tab_list:
if tab['class']:
name = tab['name'].replace('&', '')
else:
name = tab['module']
tab['action'] = QtWidgets.QAction(name, self)
tab['action'].setCheckable(True)
if tab['class']:
tab['action'].setChecked(eval(
self.app.config_store.get('tabs', tab['module'], 'True')))
else:
tab['action'].setEnabled(False)
tab['action'].triggered.connect(self.add_tabs)
options_menu.addAction(tab['action'])
# spelling menu
languages = self.app.spell_check.available_languages()
spelling_menu = self.menuBar().addMenu(translate('MenuBar', 'Spelling'))
enable_action = QtWidgets.QAction(
translate('MenuBar', 'Enable spell check'), self)
enable_action.setEnabled(languages is not None)
enable_action.setCheckable(True)
enable_action.setChecked(self.app.spell_check.enabled)
translate('MenuBar', 'Enable spell check'), self)
enable_action.setEnabled(languages is not None)
enable_action.setCheckable(True)
enable_action.setChecked(self.app.spell_check.enabled)
enable_action.toggled.connect(self.app.spell_check.enable)
spelling_menu.addAction(enable_action)
language_menu = QtWidgets.QMenu(
translate('MenuBar', 'Choose language'), self)
language_menu.setEnabled(languages is not None)
current_language = self.app.spell_check.current_language()
if languages:
language_group = QtWidgets.QActionGroup(self)
for name, code in languages:
if name != code:
name = code + ': ' + name
language_action = QtWidgets.QAction(name, self)
language_action.setCheckable(True)
language_action.setChecked(code == current_language)
language_action.setData(code)
language_action.setActionGroup(language_group)
language_menu.addAction(language_action)
language_group.triggered.connect(self.set_language)
else:
language_action = QtWidgets.QAction(
translate('MenuBar', 'No dictionary installed'), self)
language_action.setEnabled(False)
language_menu.addAction(language_action)
spelling_menu.addMenu(language_menu)
# help menu
help_menu = self.menuBar().addMenu(translate('MenuBar', 'Help'))
about_action = QtWidgets.QAction(
translate('MenuBar', 'About Photini'), self)
def contextMenuEvent(self, event):
menu = self.createStandardContextMenu()
suggestion_group = QtWidgets.QActionGroup(menu)
if self._is_multiple:
if self.choices:
sep = menu.insertSeparator(menu.actions()[0])
fm = menu.fontMetrics()
for suggestion in self.choices:
label = six.text_type(suggestion).replace('\n', ' ')
label = fm.elidedText(label, Qt.ElideMiddle, self.width())
action = QtWidgets.QAction(label, suggestion_group)
action.setData(six.text_type(suggestion))
menu.insertAction(sep, action)
action = menu.exec_(event.globalPos())
if action and action.actionGroup() == suggestion_group:
self.set_value(action.data())
def remove_lens_model(self, pos):
current_lens_id = self.widgets['lens_model'].get_value()
menu = QtWidgets.QMenu()
for lens_id in self.lens_data.lenses:
if lens_id == current_lens_id:
continue
action = QtWidgets.QAction(translate(
'TechnicalTab', 'Remove lens "{}"').format(
self.lens_data.get_name(lens_id)), self)
action.setData(lens_id)
menu.addAction(action)
if menu.isEmpty():
# no deletable lenses
return
action = menu.exec_(self.widgets['lens_model'].mapToGlobal(pos))
if not action:
return
lens_id = action.data()
self.lens_data.delete_model(lens_id)
self.widgets['lens_model'].remove_item(lens_id)
language_action = QtWidgets.QAction(name, self)
language_action.setCheckable(True)
language_action.setChecked(code == current_language)
language_action.setData(code)
language_action.setActionGroup(language_group)
language_menu.addAction(language_action)
language_group.triggered.connect(self.set_language)
else:
language_action = QtWidgets.QAction(
translate('MenuBar', 'No dictionary installed'), self)
language_action.setEnabled(False)
language_menu.addAction(language_action)
spelling_menu.addMenu(language_menu)
# help menu
help_menu = self.menuBar().addMenu(translate('MenuBar', 'Help'))
about_action = QtWidgets.QAction(
translate('MenuBar', 'About Photini'), self)
about_action.triggered.connect(self.about)
help_menu.addAction(about_action)
help_menu.addSeparator()
help_action = QtWidgets.QAction(
translate('MenuBar', 'Photini documentation'), self)
help_action.triggered.connect(self.open_docs)
help_menu.addAction(help_action)
# main application area
self.central_widget = QtWidgets.QSplitter()
self.central_widget.setOrientation(Qt.Vertical)
self.central_widget.setChildrenCollapsible(False)
self.tabs = QtWidgets.QTabWidget()
self.tabs.setTabBar(QTabBar())
self.tabs.setElideMode(Qt.ElideRight)
self.tabs.currentChanged.connect(self.new_tab)
language_menu.addAction(language_action)
language_group.triggered.connect(self.set_language)
else:
language_action = QtWidgets.QAction(
translate('MenuBar', 'No dictionary installed'), self)
language_action.setEnabled(False)
language_menu.addAction(language_action)
spelling_menu.addMenu(language_menu)
# help menu
help_menu = self.menuBar().addMenu(translate('MenuBar', 'Help'))
about_action = QtWidgets.QAction(
translate('MenuBar', 'About Photini'), self)
about_action.triggered.connect(self.about)
help_menu.addAction(about_action)
help_menu.addSeparator()
help_action = QtWidgets.QAction(
translate('MenuBar', 'Photini documentation'), self)
help_action.triggered.connect(self.open_docs)
help_menu.addAction(help_action)
# main application area
self.central_widget = QtWidgets.QSplitter()
self.central_widget.setOrientation(Qt.Vertical)
self.central_widget.setChildrenCollapsible(False)
self.tabs = QtWidgets.QTabWidget()
self.tabs.setTabBar(QTabBar())
self.tabs.setElideMode(Qt.ElideRight)
self.tabs.currentChanged.connect(self.new_tab)
self.add_tabs(False)
self.central_widget.addWidget(self.tabs)
self.central_widget.addWidget(self.image_list)
size = self.central_widget.sizes()
self.central_widget.setSizes(eval(