def save_changes(self): settings = {} for tab in self.tabs: settings.update(getattr(tab, 'settings', {})) users = self.users_tab.user_data if settings['auth']: if not users: error_dialog( self, _('No users specified'), _( 'You have turned on the setting to require passwords to access' ' the content server, but you have not created any user accounts.' ' Create at least one user account in the "User accounts" tab to proceed.' ), show=True ) self.tabs_widget.setCurrentWidget(self.users_tab) return False if not self.custom_list_tab.commit(): return False ConfigWidgetBase.commit(self) change_settings(**settings) UserManager().user_data = users return True
def save_changes(self): settings = {} for tab in self.tabs: settings.update(getattr(tab, 'settings', {})) users = self.users_tab.user_data if settings['auth']: if not users: error_dialog( self, _('No users specified'), _( 'You have turned on the setting to require passwords to access' ' the content server, but you have not created any user accounts.' ' Create at least one user account in the "User accounts" tab to proceed.' ), show=True ) self.tabs_widget.setCurrentWidget(self.users_tab) return False if not self.custom_list_tab.commit(): return False if not self.search_net_tab.commit(): return False ConfigWidgetBase.commit(self) change_settings(**settings) UserManager().user_data = users return True
def commit(self): ConfigWidgetBase.commit(self) warning_dialog(self, _('Restart needed'), _('You need to restart the server for changes to' ' take effect'), show=True) return False
def commit(self): raw = self.tweaks.to_string() try: exec(raw) except: import traceback error_dialog(self, _('Invalid tweaks'), _('The tweaks you entered are invalid, try resetting the' ' tweaks to default and changing them one by one until' ' you find the invalid setting.'), det_msg=traceback.format_exc(), show=True) raise AbortCommit('abort') write_tweaks(raw) ConfigWidgetBase.commit(self) return True
def commit(self): widths = [] for i in range(0, self.opt_columns.columnCount()): widths.append(self.opt_columns.columnWidth(i)) gprefs.set('custcol-prefs-table-geometry', widths) rr = ConfigWidgetBase.commit(self) return self.apply_custom_column_changes() or rr
def commit(self, *args): with BusyCursor(): rr = ConfigWidgetBase.commit(self, *args) if self.current_font != self.initial_font: gprefs['font'] = (self.current_font[:4] if self.current_font else None) gprefs['font_stretch'] = (self.current_font[4] if self.current_font is not None else QFont.Stretch.Unstretched) QApplication.setFont(self.font_display.font()) rr = True self.display_model.commit() self.qv_display_model.commit() self.edit_rules.commit(self.gui.current_db.prefs) self.icon_rules.commit(self.gui.current_db.prefs) self.grid_rules.commit(self.gui.current_db.prefs) gprefs['cover_grid_color'] = tuple( self.cg_bg_widget.bcol.getRgb())[:3] gprefs['cover_grid_texture'] = self.cg_bg_widget.btex if self.commit_icon_theme is not None: self.commit_icon_theme() rr = True gprefs['default_author_link'] = self.default_author_link.value bcss = self.opt_book_details_css.toPlainText().encode('utf-8') defcss = P('templates/book_details.css', data=True, allow_user_override=False) if defcss == bcss: bcss = None set_data('templates/book_details.css', bcss) return rr
def commit(self): if self.opt_case_sensitive.isChecked( ) and self.opt_use_primary_find_in_search.isChecked(): error_dialog( self, _('Incompatible options'), _('The option to have un-accented characters match accented characters has no effect' ' if you also turn on case-sensitive searching. So only turn on one of those options' ), show=True) raise AbortCommit() if self.gst_changed: self.db.new_api.set_pref('grouped_search_terms', self.gst) self.db.field_metadata.add_grouped_search_terms(self.gst) self.db.new_api.set_pref( 'similar_authors_search_key', unicode_type(self.similar_authors_search_key.currentText())) self.db.new_api.set_pref( 'similar_tags_search_key', unicode_type(self.similar_tags_search_key.currentText())) self.db.new_api.set_pref( 'similar_series_search_key', unicode_type(self.similar_series_search_key.currentText())) self.db.new_api.set_pref( 'similar_publisher_search_key', unicode_type(self.similar_publisher_search_key.currentText())) return ConfigWidgetBase.commit(self)
def commit(self): path = unicode(self.opt_auto_add_path.text()).strip() if path != gprefs['auto_add_path']: if path: path = os.path.abspath(path) self.opt_auto_add_path.setText(path) if not os.path.isdir(path): error_dialog(self, _('Invalid folder'), _('You must specify an existing folder as your ' 'auto-add folder. %s does not exist.')%path, show=True) raise AbortCommit('invalid auto-add folder') if not os.access(path, os.R_OK|os.W_OK): error_dialog(self, _('Invalid folder'), _('You do not have read/write permissions for ' 'the folder: %s')%path, show=True) raise AbortCommit('invalid auto-add folder') if not question_dialog(self, _('Are you sure?'), _('<b>WARNING:</b> Any files you place in %s will be ' 'automatically deleted after being added to ' 'calibre. Are you sure?')%path): return pattern = self.filename_pattern.commit() prefs['filename_pattern'] = pattern fmts = self.current_blocked_auto_formats old = gprefs['blocked_auto_formats'] changed = set(fmts) != set(old) if changed: gprefs['blocked_auto_formats'] = self.current_blocked_auto_formats ret = ConfigWidgetBase.commit(self) return changed or ret
def commit(self): path = unicode_type(self.opt_auto_add_path.text()).strip() if path != gprefs['auto_add_path']: if path: path = os.path.abspath(path) self.opt_auto_add_path.setText(path) if not os.path.isdir(path): error_dialog( self, _('Invalid folder'), _('You must specify an existing folder as your ' 'auto-add folder. %s does not exist.') % path, show=True) raise AbortCommit('invalid auto-add folder') if not os.access(path, os.R_OK | os.W_OK): error_dialog( self, _('Invalid folder'), _('You do not have read/write permissions for ' 'the folder: %s') % path, show=True) raise AbortCommit('invalid auto-add folder') if os.path.basename(path)[0] in '._': error_dialog( self, _('Invalid folder'), _('Cannot use folders whose names start with a ' 'period or underscore: %s') % os.path.basename(path), show=True) raise AbortCommit('invalid auto-add folder') if not question_dialog( self, _('Are you sure?'), _('<b>WARNING:</b> Any files you place in %s will be ' 'automatically deleted after being added to ' 'calibre. Are you sure?') % path): return pattern = self.filename_pattern.commit() prefs['filename_pattern'] = pattern fmts = self.current_blocked_auto_formats old = gprefs['blocked_auto_formats'] changed = set(fmts) != set(old) if changed: gprefs['blocked_auto_formats'] = self.current_blocked_auto_formats if self.tag_map_rules is not None: if self.tag_map_rules: gprefs['tag_map_on_add_rules'] = self.tag_map_rules else: gprefs.pop('tag_map_on_add_rules', None) if self.author_map_rules is not None: if self.author_map_rules: gprefs['author_map_on_add_rules'] = self.author_map_rules else: gprefs.pop('author_map_on_add_rules', None) if self.add_filter_rules is not None: if self.add_filter_rules: gprefs['add_filter_rules'] = self.add_filter_rules else: gprefs.pop('add_filter_rules', None) ret = ConfigWidgetBase.commit(self) return changed or ret
def commit(self): to_set = bool(self._email_accounts.accounts) if not self.send_email_widget.set_email_settings(to_set): raise AbortCommit('abort') self.proxy['accounts'] = self._email_accounts.accounts self.proxy['subjects'] = self._email_accounts.subjects return ConfigWidgetBase.commit(self)
def commit(self): to_set = bool(self._email_accounts.accounts) if not self.send_email_widget.set_email_settings(to_set): raise AbortCommit("abort") self.proxy["accounts"] = self._email_accounts.accounts self.proxy["subjects"] = self._email_accounts.subjects return ConfigWidgetBase.commit(self)
def commit(self): self.sources_model.commit() self.fields_model.commit() if self.tag_map_rules is not None: msprefs['tag_map_rules'] = self.tag_map_rules or [] if self.author_map_rules is not None: msprefs['author_map_rules'] = self.author_map_rules or [] return ConfigWidgetBase.commit(self)
def start_server(self): ConfigWidgetBase.commit(self) self.setCursor(Qt.BusyCursor) try: self.gui.start_content_server(check_started=False) while (not self.gui.content_server.is_running and self.gui.content_server.exception is None): time.sleep(0.1) if self.gui.content_server.exception is not None: error_dialog(self, _('Failed to start content server'), as_unicode(self.gui.content_server.exception)).exec_() return self.start_button.setEnabled(False) self.test_button.setEnabled(True) self.stop_button.setEnabled(True) finally: self.unsetCursor()
def start_server(self): ConfigWidgetBase.commit(self) self.setCursor(Qt.BusyCursor) try: self.gui.start_content_server(check_started=False) while (not self.gui.content_server.is_running and self.gui.content_server.exception is None): time.sleep(0.1) if self.gui.content_server.exception is not None: error_dialog(self, _('Failed to start content server'), as_unicode( self.gui.content_server.exception)).exec_() return self.start_button.setEnabled(False) self.test_button.setEnabled(True) self.stop_button.setEnabled(True) finally: self.unsetCursor()
def commit(self): self.sources_model.commit() self.fields_model.commit() if self.tag_map_rules is not None: if self.tag_map_rules: msprefs['tag_map_rules'] = self.tag_map_rules else: msprefs.pop('tag_map_rules', None) return ConfigWidgetBase.commit(self)
def commit(self): input_map = prefs['input_format_order'] input_cols = [unicode_type(self.opt_input_order.item(i).data(Qt.UserRole) or '') for i in range(self.opt_input_order.count())] if input_map != input_cols: prefs['input_format_order'] = input_cols fmts = self.current_internally_viewed_formats old = config['internally_viewed_formats'] if fmts != old: config['internally_viewed_formats'] = fmts return ConfigWidgetBase.commit(self)
def commit(self): input_map = prefs['input_format_order'] input_cols = [unicode(self.opt_input_order.item(i).data(Qt.UserRole) or '') for i in range(self.opt_input_order.count())] if input_map != input_cols: prefs['input_format_order'] = input_cols fmts = self.current_internally_viewed_formats old = config['internally_viewed_formats'] if fmts != old: config['internally_viewed_formats'] = fmts return ConfigWidgetBase.commit(self)
def commit(self, *args): rr = ConfigWidgetBase.commit(self, *args) if self.current_font != self.initial_font: gprefs['font'] = (self.current_font[:4] if self.current_font else None) gprefs['font_stretch'] = (self.current_font[4] if self.current_font is not None else QFont.Unstretched) QApplication.setFont(self.font_display.font()) rr = True self.display_model.commit() self.edit_rules.commit(self.gui.current_db.prefs) return rr
def commit(self, *args): rr = ConfigWidgetBase.commit(self, *args) if self.current_font != self.initial_font: gprefs["font"] = self.current_font[:4] if self.current_font else None gprefs["font_stretch"] = self.current_font[4] if self.current_font is not None else QFont.Unstretched QApplication.setFont(self.font_display.font()) rr = True self.display_model.commit() self.edit_rules.commit(self.gui.current_db.prefs) self.icon_rules.commit(self.gui.current_db.prefs) gprefs["cover_grid_color"] = tuple(self.cover_grid_color_label.palette().color(QPalette.Window).getRgb())[:3] return rr
def commit(self): path = unicode(self.opt_auto_add_path.text()).strip() if path != gprefs["auto_add_path"]: if path: path = os.path.abspath(path) self.opt_auto_add_path.setText(path) if not os.path.isdir(path): error_dialog( self, _("Invalid folder"), _("You must specify an existing folder as your " "auto-add folder. %s does not exist.") % path, show=True, ) raise AbortCommit("invalid auto-add folder") if not os.access(path, os.R_OK | os.W_OK): error_dialog( self, _("Invalid folder"), _("You do not have read/write permissions for " "the folder: %s") % path, show=True, ) raise AbortCommit("invalid auto-add folder") if not question_dialog( self, _("Are you sure?"), _( "<b>WARNING:</b> Any files you place in %s will be " "automatically deleted after being added to " "calibre. Are you sure?" ) % path, ): return pattern = self.filename_pattern.commit() prefs["filename_pattern"] = pattern fmts = self.current_blocked_auto_formats old = gprefs["blocked_auto_formats"] changed = set(fmts) != set(old) if changed: gprefs["blocked_auto_formats"] = self.current_blocked_auto_formats if self.tag_map_rules is not None: if self.tag_map_rules: gprefs["tag_map_on_add_rules"] = self.tag_map_rules else: gprefs.pop("tag_map_on_add_rules", None) if self.add_filter_rules is not None: if self.add_filter_rules: gprefs["add_filter_rules"] = self.add_filter_rules else: gprefs.pop("add_filter_rules", None) ret = ConfigWidgetBase.commit(self) return changed or ret
def commit(self): if self.email_view.state() == self.email_view.EditingState: # Ensure that the cell being edited is committed by switching focus # to some other widget, which automatically closes the open editor self.send_email_widget.setFocus(Qt.OtherFocusReason) to_set = bool(self._email_accounts.accounts) if not self.send_email_widget.set_email_settings(to_set): raise AbortCommit('abort') self.proxy['accounts'] = self._email_accounts.accounts self.proxy['subjects'] = self._email_accounts.subjects self.proxy['aliases'] = self._email_accounts.aliases return ConfigWidgetBase.commit(self)
def commit(self): if self.gst_changed: self.db.prefs.set('grouped_search_terms', self.gst) self.db.field_metadata.add_grouped_search_terms(self.gst) self.db.prefs.set('similar_authors_search_key', unicode(self.similar_authors_search_key.currentText())) self.db.prefs.set('similar_tags_search_key', unicode(self.similar_tags_search_key.currentText())) self.db.prefs.set('similar_series_search_key', unicode(self.similar_series_search_key.currentText())) self.db.prefs.set('similar_publisher_search_key', unicode(self.similar_publisher_search_key.currentText())) return ConfigWidgetBase.commit(self)
def commit(self): input_map = prefs['input_format_order'] input_cols = [unicode_type(self.opt_input_order.item(i).data(Qt.ItemDataRole.UserRole) or '') for i in range(self.opt_input_order.count())] if input_map != input_cols: prefs['input_format_order'] = input_cols fmts = self.current_internally_viewed_formats old = config['internally_viewed_formats'] if fmts != old: config['internally_viewed_formats'] = fmts ret = ConfigWidgetBase.commit(self) # Signal a possible change of the VL at startup opt get_change_library_action_plugin().rebuild_change_library_menus.emit() return ret
def commit(self, *args): rr = ConfigWidgetBase.commit(self, *args) if self.current_font != self.initial_font: gprefs['font'] = (self.current_font[:4] if self.current_font else None) gprefs['font_stretch'] = (self.current_font[4] if self.current_font is not None else QFont.Unstretched) QApplication.setFont(self.font_display.font()) rr = True self.display_model.commit() self.edit_rules.commit(self.gui.current_db.prefs) self.icon_rules.commit(self.gui.current_db.prefs) gprefs['cover_grid_color'] = tuple(self.cover_grid_color_label.palette().color(QPalette.Window).getRgb())[:3] return rr
def commit(self, *args): rr = ConfigWidgetBase.commit(self, *args) if self.current_font != self.initial_font: gprefs['font'] = (self.current_font[:4] if self.current_font else None) gprefs['font_stretch'] = (self.current_font[4] if self.current_font is not None else QFont.Unstretched) QApplication.setFont(self.font_display.font()) rr = True self.display_model.commit() self.edit_rules.commit(self.gui.current_db.prefs) self.icon_rules.commit(self.gui.current_db.prefs) gprefs['cover_grid_color'] = tuple(self.cg_bg_widget.bcol.getRgb())[:3] gprefs['cover_grid_texture'] = self.cg_bg_widget.btex return rr
def commit(self, *args): rr = ConfigWidgetBase.commit(self, *args) if self.current_font != self.initial_font: gprefs['font'] = (self.current_font[:4] if self.current_font else None) gprefs['font_stretch'] = (self.current_font[4] if self.current_font is not None else QFont.Unstretched) QApplication.setFont(self.font_display.font()) rr = True self.display_model.commit() self.edit_rules.commit(self.gui.current_db.prefs) self.icon_rules.commit(self.gui.current_db.prefs) self.grid_rules.commit(self.gui.current_db.prefs) gprefs['cover_grid_color'] = tuple(self.cg_bg_widget.bcol.getRgb())[:3] gprefs['cover_grid_texture'] = self.cg_bg_widget.btex return rr
def commit(self): if self.opt_case_sensitive.isChecked() and self.opt_use_primary_find_in_search.isChecked(): error_dialog(self, _('Incompatible options'), _( 'The option to have un-accented characters match accented characters has no effect' ' if you also turn on case-sensitive searching. So only turn on one of those options'), show=True) raise AbortCommit() if self.gst_changed: self.db.new_api.set_pref('grouped_search_terms', self.gst) self.db.field_metadata.add_grouped_search_terms(self.gst) self.db.new_api.set_pref('similar_authors_search_key', unicode(self.similar_authors_search_key.currentText())) self.db.new_api.set_pref('similar_tags_search_key', unicode(self.similar_tags_search_key.currentText())) self.db.new_api.set_pref('similar_series_search_key', unicode(self.similar_series_search_key.currentText())) self.db.new_api.set_pref('similar_publisher_search_key', unicode(self.similar_publisher_search_key.currentText())) return ConfigWidgetBase.commit(self)
def commit(self, *args): with BusyCursor(): rr = ConfigWidgetBase.commit(self, *args) if self.current_font != self.initial_font: gprefs['font'] = (self.current_font[:4] if self.current_font else None) gprefs['font_stretch'] = (self.current_font[4] if self.current_font is not None else QFont.Unstretched) QApplication.setFont(self.font_display.font()) rr = True self.display_model.commit() self.qv_display_model.commit() self.edit_rules.commit(self.gui.current_db.prefs) self.icon_rules.commit(self.gui.current_db.prefs) self.grid_rules.commit(self.gui.current_db.prefs) gprefs['cover_grid_color'] = tuple(self.cg_bg_widget.bcol.getRgb())[:3] gprefs['cover_grid_texture'] = self.cg_bg_widget.btex if self.commit_icon_theme is not None: self.commit_icon_theme() rr = True gprefs['default_author_link'] = self.default_author_link.value return rr
def commit(self): if not self.send_template.validate(): raise AbortCommit('abort') self.send_template.save_settings(self.proxy, 'send_template') return ConfigWidgetBase.commit(self)
def commit(self): for widget in self.model.widgets: if not widget.pre_commit_check(): raise AbortCommit('abort') widget.commit(save_defaults=True) return ConfigWidgetBase.commit(self)
def commit(self): self.db.new_api.set_pref('plugboards', self.current_plugboards) return ConfigWidgetBase.commit(self)
def commit(self): rr = ConfigWidgetBase.commit(self) return self.apply_custom_column_changes() or rr
def commit(self): self.sources_model.commit() self.fields_model.commit() return ConfigWidgetBase.commit(self)
def commit(self): self.conf_widget.commit() return ConfigWidgetBase.commit(self)
def commit(self): self.db.prefs.set('plugboards', self.current_plugboards) return ConfigWidgetBase.commit(self)