def __init__(self, parent, db, book_id, preferred_input_format=None, preferred_output_format=None): ResizableDialog.__init__(self, parent) self.opt_individual_saved_settings.setVisible(False) self.db, self.book_id = db, book_id self.setup_input_output_formats(self.db, self.book_id, preferred_input_format, preferred_output_format) self.setup_pipeline() self.connect(self.input_formats, SIGNAL('currentIndexChanged(QString)'), self.setup_pipeline) self.connect(self.output_formats, SIGNAL('currentIndexChanged(QString)'), self.setup_pipeline) self.connect(self.groups, SIGNAL('activated(QModelIndex)'), self.show_pane) self.connect(self.groups, SIGNAL('clicked(QModelIndex)'), self.show_pane) self.connect(self.groups, SIGNAL('entered(QModelIndex)'), self.show_group_help) rb = self.buttonBox.button(self.buttonBox.RestoreDefaults) self.connect(rb, SIGNAL('clicked()'), self.restore_defaults) self.groups.setMouseTracking(True) geom = gprefs.get('convert_single_dialog_geom', None) if geom: self.restoreGeometry(geom)
def __init__(self, db, parent=None): self.db = db self.changed = set() self.books_to_refresh = set() self.rows_to_refresh = set() self.metadata_before_fetch = None ResizableDialog.__init__(self, parent)
def __init__(self, parent, recipe_model): ResizableDialog.__init__(self, parent) self._model = self.model = CustomRecipeModel(recipe_model) self.available_profiles.setModel(self._model) self.available_profiles.currentChanged = self.current_changed f = QFont() f.setStyleHint(f.Monospace) self.source_code.setFont(f) self.remove_feed_button.clicked[(bool)].connect(self.added_feeds.remove_selected_items) self.remove_profile_button.clicked[(bool)].connect(self.remove_selected_items) self.add_feed_button.clicked[(bool)].connect(self.add_feed) self.load_button.clicked.connect(self.load) self.opml_button.clicked.connect(self.opml_import) self.builtin_recipe_button.clicked.connect(self.add_builtin_recipe) self.share_button.clicked.connect(self.share) self.show_recipe_files_button.clicked.connect(self.show_recipe_files) self.down_button.clicked.connect(self.down) self.up_button.clicked.connect(self.up) self.add_profile_button.clicked[(bool)].connect(self.add_profile) self.feed_url.returnPressed[()].connect(self.add_feed) self.feed_title.returnPressed[()].connect(self.add_feed) self.toggle_mode_button.clicked[(bool)].connect(self.toggle_mode) self.clear()
def __init__(self, parent, db, book_id, preferred_input_format=None, preferred_output_format=None): ResizableDialog.__init__(self, parent) self.opt_individual_saved_settings.setVisible(False) self.db, self.book_id = db, book_id self.setup_input_output_formats(self.db, self.book_id, preferred_input_format, preferred_output_format) self.setup_pipeline() self.input_formats.currentIndexChanged[str].connect( self.setup_pipeline) self.output_formats.currentIndexChanged[str].connect( self.setup_pipeline) self.groups.activated[(QModelIndex)].connect(self.show_pane) self.groups.clicked[(QModelIndex)].connect(self.show_pane) self.groups.entered[(QModelIndex)].connect(self.show_group_help) rb = self.buttonBox.button(self.buttonBox.RestoreDefaults) rb.setText(_('Restore &Defaults')) rb.clicked.connect(self.restore_defaults) self.groups.setMouseTracking(True) geom = gprefs.get('convert_single_dialog_geom', None) if geom: self.restoreGeometry(geom)
def __init__(self, parent, db, book_id, preferred_input_format=None, preferred_output_format=None): ResizableDialog.__init__(self, parent) self.opt_individual_saved_settings.setVisible(False) self.db, self.book_id = db, book_id self.setup_input_output_formats(self.db, self.book_id, preferred_input_format, preferred_output_format) self.setup_pipeline() self.connect(self.input_formats, SIGNAL('currentIndexChanged(QString)'), self.setup_pipeline) self.connect(self.output_formats, SIGNAL('currentIndexChanged(QString)'), self.setup_pipeline) self.connect(self.groups, SIGNAL('activated(QModelIndex)'), self.show_pane) self.connect(self.groups, SIGNAL('clicked(QModelIndex)'), self.show_pane) self.connect(self.groups, SIGNAL('entered(QModelIndex)'), self.show_group_help) rb = self.buttonBox.button(self.buttonBox.RestoreDefaults) self.connect(rb, SIGNAL('clicked()'), self.restore_defaults) self.groups.setMouseTracking(True)
def __init__(self, parent, db, preferred_output_format=None, has_saved_settings=True): ResizableDialog.__init__(self, parent) self.setup_output_formats(db, preferred_output_format) self.db = db self.setup_pipeline() self.input_label.hide() self.input_formats.hide() self.opt_individual_saved_settings.setVisible(True) self.opt_individual_saved_settings.setChecked(True) self.opt_individual_saved_settings.setToolTip(_('For ' 'settings that cannot be specified in this dialog, use the ' 'values saved in a previous conversion (if they exist) instead ' 'of using the defaults specified in the Preferences')) self.output_formats.currentIndexChanged[str].connect(self.setup_pipeline) self.groups.activated[(QModelIndex)].connect(self.show_pane) self.groups.clicked[(QModelIndex)].connect(self.show_pane) self.groups.entered[(QModelIndex)].connect(self.show_group_help) rb = self.buttonBox.button(self.buttonBox.RestoreDefaults) rb.setVisible(False) self.groups.setMouseTracking(True) if not has_saved_settings: o = self.opt_individual_saved_settings o.setEnabled(False) o.setToolTip(_('None of the selected books have saved conversion ' 'settings.')) o.setChecked(False) geom = gprefs.get('convert_bulk_dialog_geom', None) if geom: self.restoreGeometry(geom)
def __init__(self, db, parent=None, editing_multiple=False): self.db = db self.changed = set() self.books_to_refresh = set() self.rows_to_refresh = set() self.metadata_before_fetch = None self.editing_multiple = editing_multiple ResizableDialog.__init__(self, parent)
def reject(self): if question_dialog(self, _('Are you sure?'), _('You will lose any unsaved changes. To save your' ' changes, click the Add/Update recipe button.' ' Continue?'), show_copy_button=False): ResizableDialog.reject(self)
def accept(self): recs = GuiRecommendations() for w in self._groups_model.widgets: if not w.pre_commit_check(): return x = w.commit(save_defaults=False) recs.update(x) self._recommendations = recs ResizableDialog.accept(self)
def reject(self): if question_dialog( self, _("Are you sure?"), _( "You will lose any unsaved changes. To save your" " changes, click the Add/Update recipe button." " Continue?" ), show_copy_button=False, ): ResizableDialog.reject(self)
def accept(self): recs = GuiRecommendations() for w in self._groups_model.widgets: if not w.pre_commit_check(): return x = w.commit(save_defaults=False) recs.update(x) self.opf_file, self.cover_file = self.mw.opf_file, self.mw.cover_file self._recommendations = recs if self.db is not None: recs['gui_preferred_input_format'] = self.input_format save_specifics(self.db, self.book_id, recs) self.break_cycles() ResizableDialog.accept(self)
def accept(self): self.save_state() if not self.apply_changes(): return if self.editing_multiple and self.current_row != len(self.row_list) - 1: num = len(self.row_list) - 1 - self.current_row from calibre.gui2 import question_dialog if not question_dialog( self, _('Are you sure?'), _('There are still %d more books to edit in this set.' ' Are you sure you want to stop? Use the Next button' ' instead of the OK button to move through books in the set.') % num, yes_text=_('&Stop editing'), no_text=_('&Continue editing'), yes_icon='dot_red.png', no_icon='dot_green.png', default_yes=False, skip_dialog_name='edit-metadata-single-confirm-ok-on-multiple'): return self.do_one(delta=1, apply_changes=False) ResizableDialog.accept(self)
def __init__(self, parent, db, preferred_output_format=None, has_saved_settings=True): ResizableDialog.__init__(self, parent) self.setup_output_formats(db, preferred_output_format) self.db = db self.setup_pipeline() self.input_label.hide() self.input_formats.hide() self.opt_individual_saved_settings.setVisible(True) self.opt_individual_saved_settings.setChecked(True) self.opt_individual_saved_settings.setToolTip( _('For ' 'settings that cannot be specified in this dialog, use the ' 'values saved in a previous conversion (if they exist) instead ' 'of using the defaults specified in the Preferences')) self.connect(self.output_formats, SIGNAL('currentIndexChanged(QString)'), self.setup_pipeline) self.connect(self.groups, SIGNAL('activated(QModelIndex)'), self.show_pane) self.connect(self.groups, SIGNAL('clicked(QModelIndex)'), self.show_pane) self.connect(self.groups, SIGNAL('entered(QModelIndex)'), self.show_group_help) rb = self.buttonBox.button(self.buttonBox.RestoreDefaults) rb.setVisible(False) self.groups.setMouseTracking(True) if not has_saved_settings: o = self.opt_individual_saved_settings o.setEnabled(False) o.setToolTip( _('None of the selected books have saved conversion ' 'settings.')) o.setChecked(False) geom = gprefs.get('convert_bulk_dialog_geom', None) if geom: self.restoreGeometry(geom)
def reject(self): dynamic.set('catalog_window_geom', bytearray(self.saveGeometry())) ResizableDialog.reject(self)
def accept(self): self.save_catalog_settings() return ResizableDialog.accept(self)
def reject(self): self.break_cycles() ResizableDialog.reject(self)
def done(self, r): if self.isVisible(): gprefs['convert_bulk_dialog_geom'] = \ bytearray(self.saveGeometry()) return ResizableDialog.done(self, r)
def accept(self): self.save_state() if not self.apply_changes(): return ResizableDialog.accept(self)
def reject(self): self.save_state() ResizableDialog.reject(self)
def reject(self): dynamic.set("catalog_window_geom", bytearray(self.saveGeometry())) ResizableDialog.reject(self)
def __init__(self, window, rows, model, tab, refresh_books): ResizableDialog.__init__(self, window) Ui_MetadataBulkDialog.__init__(self) self.model = model self.db = model.db self.refresh_book_list.setChecked(gprefs['refresh_book_list_on_bulk_edit']) self.refresh_book_list.toggled.connect(self.save_refresh_booklist) self.ids = [self.db.id(r) for r in rows] self.first_title = self.db.title(self.ids[0], index_is_id=True) self.cover_clone.setToolTip(unicode(self.cover_clone.toolTip()) + ' (%s)' % self.first_title) self.box_title.setText('<p>' + _('Editing meta information for <b>%d books</b>') % len(rows)) self.write_series = False self.changed = False self.refresh_books = refresh_books self.comments = null self.comments_button.clicked.connect(self.set_comments) all_tags = self.db.all_tags() self.tags.update_items_cache(all_tags) self.remove_tags.update_items_cache(all_tags) self.initialize_combos() for f in sorted(self.db.all_formats()): self.remove_format.addItem(f) self.remove_format.setCurrentIndex(-1) self.series.currentIndexChanged[int].connect(self.series_changed) self.series.editTextChanged.connect(self.series_changed) self.tag_editor_button.clicked.connect(self.tag_editor) self.autonumber_series.stateChanged[int].connect(self.auto_number_changed) self.pubdate.setMinimumDateTime(UNDEFINED_QDATETIME) self.pubdate_cw = CalendarWidget(self.pubdate) self.pubdate.setCalendarWidget(self.pubdate_cw) pubdate_format = tweaks['gui_pubdate_display_format'] if pubdate_format is not None: self.pubdate.setDisplayFormat(pubdate_format) self.pubdate.setSpecialValueText(_('Undefined')) self.clear_pubdate_button.clicked.connect(self.clear_pubdate) self.pubdate.dateTimeChanged.connect(self.do_apply_pubdate) self.adddate.setDateTime(QDateTime.currentDateTime()) self.adddate.setMinimumDateTime(UNDEFINED_QDATETIME) adddate_format = tweaks['gui_timestamp_display_format'] if adddate_format is not None: self.adddate.setDisplayFormat(adddate_format) self.adddate.setSpecialValueText(_('Undefined')) self.clear_adddate_button.clicked.connect(self.clear_adddate) self.adddate.dateTimeChanged.connect(self.do_apply_adddate) if len(self.db.custom_field_keys(include_composites=False)) == 0: self.central_widget.removeTab(1) else: self.create_custom_column_editors() self.prepare_search_and_replace() self.button_box.clicked.connect(self.button_clicked) self.button_box.button(QDialogButtonBox.Apply).setToolTip(_( 'Immediately make all changes without closing the dialog. ' 'This operation cannot be canceled or undone')) self.do_again = False self.central_widget.setCurrentIndex(tab) geom = gprefs.get('bulk_metadata_window_geometry', None) if geom is not None: self.restoreGeometry(bytes(geom)) ct = gprefs.get('bulk_metadata_window_tab', 0) self.central_widget.setCurrentIndex(ct) self.languages.init_langs(self.db) self.languages.setEditText('') self.authors.setFocus(Qt.OtherFocusReason) self.exec_()
def __init__(self, db, parent=None): self.db = db self.changed = set() self.books_to_refresh = set() self.rows_to_refresh = set() ResizableDialog.__init__(self, parent)
def __init__(self, parent, dbspec, ids, db): import re, cStringIO from calibre import prints as info from PyQt5.uic import compileUi ResizableDialog.__init__(self, parent) self.dbspec, self.ids = dbspec, ids # Display the number of books we've been passed self.count.setText(unicode(self.count.text()).format(len(ids))) # Display the last-used title self.title.setText( dynamic.get('catalog_last_used_title', _('My Books'))) self.fmts, self.widgets = [], [] for plugin in catalog_plugins(): if plugin.name in config['disabled_plugins']: continue name = plugin.name.lower().replace(' ', '_') if getattr(plugin, 'plugin_path', None) is None: try: catalog_widget = importlib.import_module( 'calibre.gui2.catalog.' + name) pw = catalog_widget.PluginWidget() pw.initialize(name, db) pw.ICON = I('forward.png') self.widgets.append(pw) [ self.fmts.append( [file_type.upper(), pw.sync_enabled, pw]) for file_type in plugin.file_types ] except ImportError: info("ImportError initializing %s" % name) continue else: # Load dynamic tab form = os.path.join(plugin.resources_path, '%s.ui' % name) klass = os.path.join(plugin.resources_path, '%s.py' % name) compiled_form = os.path.join(plugin.resources_path, '%s_ui.py' % name) if os.path.exists(form) and os.path.exists(klass): # info("Adding widget for user-installed Catalog plugin %s" % plugin.name) # Compile the .ui form provided in plugin.zip if not os.path.exists(compiled_form): # info('\tCompiling form', form) buf = cStringIO.StringIO() compileUi(form, buf) dat = buf.getvalue() dat = re.compile( r'QtGui.QApplication.translate\(.+?,\s+"(.+?)(?<!\\)",.+?\)', re.DOTALL).sub(r'_("\1")', dat) open(compiled_form, 'wb').write(dat) # Import the dynamic PluginWidget() from .py file provided in plugin.zip try: sys.path.insert(0, plugin.resources_path) catalog_widget = importlib.import_module(name) pw = catalog_widget.PluginWidget() pw.initialize(name) pw.ICON = I('forward.png') self.widgets.append(pw) [ self.fmts.append( [file_type.upper(), pw.sync_enabled, pw]) for file_type in plugin.file_types ] except ImportError: info("ImportError with %s" % name) continue finally: sys.path.remove(plugin.resources_path) else: info("No dynamic tab resources found for %s" % name) self.widgets = sorted(self.widgets, cmp=lambda x, y: cmp(x.TITLE, y.TITLE)) # Generate a sorted list of installed catalog formats/sync_enabled pairs fmts = sorted([x[0] for x in self.fmts]) self.sync_enabled_formats = [] for fmt in self.fmts: if fmt[1]: self.sync_enabled_formats.append(fmt[0]) # Callbacks when format, title changes self.format.currentIndexChanged.connect(self.format_changed) self.format.currentIndexChanged.connect(self.settings_changed) self.title.editingFinished.connect(self.settings_changed) # Add the installed catalog format list to the format QComboBox self.format.blockSignals(True) self.format.addItems(fmts) pref = dynamic.get('catalog_preferred_format', 'CSV') idx = self.format.findText(pref) if idx > -1: self.format.setCurrentIndex(idx) self.format.blockSignals(False) if self.sync.isEnabled(): self.sync.setChecked(dynamic.get('catalog_sync_to_device', True)) self.format.currentIndexChanged.connect(self.show_plugin_tab) self.buttonBox.button(self.buttonBox.Apply).clicked.connect(self.apply) self.buttonBox.button(self.buttonBox.Help).clicked.connect(self.help) self.show_plugin_tab(None) geom = dynamic.get('catalog_window_geom', None) if geom is not None: self.restoreGeometry(bytes(geom))
def __init__(self, parent, dbspec, ids, db): import re, cStringIO from calibre import prints as info from PyQt5.uic import compileUi ResizableDialog.__init__(self, parent) self.dbspec, self.ids = dbspec, ids # Display the number of books we've been passed self.count.setText(unicode(self.count.text()).format(len(ids))) # Display the last-used title self.title.setText(dynamic.get("catalog_last_used_title", _("My Books"))) self.fmts, self.widgets = [], [] for plugin in catalog_plugins(): if plugin.name in config["disabled_plugins"]: continue name = plugin.name.lower().replace(" ", "_") if getattr(plugin, "plugin_path", None) is None: try: catalog_widget = importlib.import_module("calibre.gui2.catalog." + name) pw = catalog_widget.PluginWidget() pw.initialize(name, db) pw.ICON = I("forward.png") self.widgets.append(pw) [self.fmts.append([file_type.upper(), pw.sync_enabled, pw]) for file_type in plugin.file_types] except ImportError: info("ImportError initializing %s" % name) continue else: # Load dynamic tab form = os.path.join(plugin.resources_path, "%s.ui" % name) klass = os.path.join(plugin.resources_path, "%s.py" % name) compiled_form = os.path.join(plugin.resources_path, "%s_ui.py" % name) if os.path.exists(form) and os.path.exists(klass): # info("Adding widget for user-installed Catalog plugin %s" % plugin.name) # Compile the .ui form provided in plugin.zip if not os.path.exists(compiled_form): # info('\tCompiling form', form) buf = cStringIO.StringIO() compileUi(form, buf) dat = buf.getvalue() dat = re.compile(r'QtGui.QApplication.translate\(.+?,\s+"(.+?)(?<!\\)",.+?\)', re.DOTALL).sub( r'_("\1")', dat ) open(compiled_form, "wb").write(dat) # Import the dynamic PluginWidget() from .py file provided in plugin.zip try: sys.path.insert(0, plugin.resources_path) catalog_widget = importlib.import_module(name) pw = catalog_widget.PluginWidget() pw.initialize(name) pw.ICON = I("forward.png") self.widgets.append(pw) [self.fmts.append([file_type.upper(), pw.sync_enabled, pw]) for file_type in plugin.file_types] except ImportError: info("ImportError with %s" % name) continue finally: sys.path.remove(plugin.resources_path) else: info("No dynamic tab resources found for %s" % name) self.widgets = sorted(self.widgets, cmp=lambda x, y: cmp(x.TITLE, y.TITLE)) # Generate a sorted list of installed catalog formats/sync_enabled pairs fmts = sorted([x[0] for x in self.fmts]) self.sync_enabled_formats = [] for fmt in self.fmts: if fmt[1]: self.sync_enabled_formats.append(fmt[0]) # Callbacks when format, title changes self.format.currentIndexChanged.connect(self.format_changed) self.format.currentIndexChanged.connect(self.settings_changed) self.title.editingFinished.connect(self.settings_changed) # Add the installed catalog format list to the format QComboBox self.format.blockSignals(True) self.format.addItems(fmts) pref = dynamic.get("catalog_preferred_format", "CSV") idx = self.format.findText(pref) if idx > -1: self.format.setCurrentIndex(idx) self.format.blockSignals(False) if self.sync.isEnabled(): self.sync.setChecked(dynamic.get("catalog_sync_to_device", True)) self.format.currentIndexChanged.connect(self.show_plugin_tab) self.buttonBox.button(self.buttonBox.Apply).clicked.connect(self.apply) self.buttonBox.button(self.buttonBox.Help).clicked.connect(self.help) self.show_plugin_tab(None) geom = dynamic.get("catalog_window_geom", None) if geom is not None: self.restoreGeometry(bytes(geom))