Esempio n. 1
0
 def __init__(self, *args, **kw):
     ConfigWidgetBase.__init__(self, *args, **kw)
     self.l = l = QVBoxLayout(self)
     l.setContentsMargins(0, 0, 0, 0)
     self.tabs_widget = t = QTabWidget(self)
     l.addWidget(t)
     self.main_tab = m = MainTab(self)
     t.addTab(m, _('&Main'))
     m.start_server.connect(self.start_server)
     m.stop_server.connect(self.stop_server)
     m.test_server.connect(self.test_server)
     m.show_logs.connect(self.view_server_logs)
     self.opt_autolaunch_server = m.opt_autolaunch_server
     self.users_tab = ua = Users(self)
     t.addTab(ua, _('&User accounts'))
     self.advanced_tab = a = AdvancedTab(self)
     sa = QScrollArea(self)
     sa.setWidget(a), sa.setWidgetResizable(True)
     t.addTab(sa, _('&Advanced'))
     self.custom_list_tab = clt = CustomList(self)
     sa = QScrollArea(self)
     sa.setWidget(clt), sa.setWidgetResizable(True)
     t.addTab(sa, _('Book &list template'))
     for tab in self.tabs:
         if hasattr(tab, 'changed_signal'):
             tab.changed_signal.connect(self.changed_signal.emit)
Esempio n. 2
0
 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
Esempio n. 3
0
 def initialize(self):
     ConfigWidgetBase.initialize(self)
     self.send_template.blockSignals(True)
     self.send_template.initialize('send_to_device', self.proxy['send_template'],
             self.proxy.help('send_template'),
             self.gui.library_view.model().db.field_metadata)
     self.send_template.blockSignals(False)
Esempio n. 4
0
 def initialize(self):
     ConfigWidgetBase.initialize(self)
     self.filename_pattern.blockSignals(True)
     self.filename_pattern.initialize()
     self.filename_pattern.blockSignals(False)
     self.init_blocked_auto_formats()
     self.opt_automerge.setEnabled(self.opt_add_formats_to_existing.isChecked())
Esempio n. 5
0
 def restore_defaults(self):
     ConfigWidgetBase.restore_defaults(self)
     ofont = self.current_font
     self.current_font = None
     if ofont is not None:
         self.changed_signal.emit()
         self.update_font_display()
     self.display_model.restore_defaults()
     self.edit_rules.clear()
     self.changed_signal.emit()
Esempio n. 6
0
 def restore_defaults(self):
     ConfigWidgetBase.restore_defaults(self)
     ofont = self.current_font
     self.current_font = None
     if ofont is not None:
         self.changed_signal.emit()
         self.update_font_display()
     self.display_model.restore_defaults()
     self.edit_rules.clear()
     self.icon_rules.clear()
     self.changed_signal.emit()
     self.set_cg_color(gprefs.defaults['cover_grid_color'])
Esempio n. 7
0
 def restore_defaults(self):
     ConfigWidgetBase.restore_defaults(self)
     self.default_author_link.value = DEFAULT_AUTHOR_LINK
     ofont = self.current_font
     self.current_font = None
     if ofont is not None:
         self.changed_signal.emit()
         self.update_font_display()
     self.display_model.restore_defaults()
     self.edit_rules.clear()
     self.icon_rules.clear()
     self.grid_rules.clear()
     self.changed_signal.emit()
     self.set_cg_color(gprefs.defaults['cover_grid_color'])
     self.set_cg_texture(gprefs.defaults['cover_grid_texture'])
Esempio n. 8
0
 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
Esempio n. 9
0
 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)
Esempio n. 10
0
 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
Esempio n. 11
0
    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
Esempio n. 12
0
 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
Esempio n. 13
0
 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
Esempio n. 14
0
 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
Esempio n. 15
0
 def initialize(self):
     ConfigWidgetBase.initialize(self)
     font = gprefs['font']
     if font is not None:
         font = list(font)
         font.append(gprefs.get('font_stretch', QFont.Unstretched))
     self.current_font = self.initial_font = font
     self.update_font_display()
     self.display_model.initialize()
     db = self.gui.current_db
     try:
         idx = self.gui.library_view.currentIndex().row()
         mi = db.get_metadata(idx, index_is_id=False)
     except:
         mi = None
     self.edit_rules.initialize(db.field_metadata, db.prefs, mi)
Esempio n. 16
0
 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
Esempio n. 17
0
 def restore_defaults(self):
     ConfigWidgetBase.restore_defaults(self)
     self.default_author_link.value = DEFAULT_AUTHOR_LINK
     ofont = self.current_font
     self.current_font = None
     if ofont is not None:
         self.changed_signal.emit()
         self.update_font_display()
     self.display_model.restore_defaults()
     self.qv_display_model.restore_defaults()
     self.edit_rules.clear()
     self.icon_rules.clear()
     self.grid_rules.clear()
     self.changed_signal.emit()
     self.set_cg_color(gprefs.defaults['cover_grid_color'])
     self.set_cg_texture(gprefs.defaults['cover_grid_texture'])
Esempio n. 18
0
 def initialize(self):
     ConfigWidgetBase.initialize(self)
     font = gprefs['font']
     if font is not None:
         font = list(font)
         font.append(gprefs.get('font_stretch', QFont.Unstretched))
     self.current_font = self.initial_font = font
     self.update_font_display()
     self.display_model.initialize()
     db = self.gui.current_db
     try:
         idx = self.gui.library_view.currentIndex().row()
         mi = db.get_metadata(idx, index_is_id=False)
     except:
         mi=None
     self.edit_rules.initialize(db.field_metadata, db.prefs, mi)
Esempio n. 19
0
    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)
Esempio n. 20
0
 def restore_defaults(self):
     ConfigWidgetBase.restore_defaults(self)
     self.default_author_link.value = DEFAULT_AUTHOR_LINK
     ofont = self.current_font
     self.current_font = None
     if ofont is not None:
         self.changed_signal.emit()
         self.update_font_display()
     self.display_model.restore_defaults()
     self.qv_display_model.restore_defaults()
     self.edit_rules.clear()
     self.icon_rules.clear()
     self.grid_rules.clear()
     self.changed_signal.emit()
     self.set_cg_color(gprefs.defaults['cover_grid_color'])
     self.set_cg_texture(gprefs.defaults['cover_grid_texture'])
     self.opt_book_details_css.setPlainText(P('templates/book_details.css', allow_user_override=False, data=True).decode('utf-8'))
Esempio n. 21
0
 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()
Esempio n. 22
0
 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)
Esempio n. 23
0
    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)
Esempio n. 24
0
 def commit(self):
     raw = self.tweaks.to_string()
     if not isinstance(raw, bytes):
         raw = raw.encode('utf-8')
     try:
         custom_tweaks = exec_tweaks(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_custom_tweaks(custom_tweaks)
     ConfigWidgetBase.commit(self)
     return True
Esempio n. 25
0
 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)
Esempio n. 26
0
 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)
Esempio n. 27
0
 def initialize(self):
     ConfigWidgetBase.initialize(self)
     font = gprefs["font"]
     if font is not None:
         font = list(font)
         font.append(gprefs.get("font_stretch", QFont.Unstretched))
     self.current_font = self.initial_font = font
     self.update_font_display()
     self.display_model.initialize()
     db = self.gui.current_db
     try:
         idx = self.gui.library_view.currentIndex().row()
         mi = db.get_metadata(idx, index_is_id=False)
     except:
         mi = None
     self.edit_rules.initialize(db.field_metadata, db.prefs, mi, "column_color_rules")
     self.icon_rules.initialize(db.field_metadata, db.prefs, mi, "column_icon_rules")
     self.set_cg_color(gprefs["cover_grid_color"])
Esempio n. 28
0
 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()
Esempio n. 29
0
 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)
Esempio n. 30
0
 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
Esempio n. 31
0
 def initialize(self):
     ConfigWidgetBase.initialize(self)
     font = gprefs['font']
     if font is not None:
         font = list(font)
         font.append(gprefs.get('font_stretch', QFont.Unstretched))
     self.current_font = self.initial_font = font
     self.update_font_display()
     self.display_model.initialize()
     db = self.gui.current_db
     try:
         idx = self.gui.library_view.currentIndex().row()
         mi = db.get_metadata(idx, index_is_id=False)
     except:
         mi=None
     self.edit_rules.initialize(db.field_metadata, db.prefs, mi, 'column_color_rules')
     self.icon_rules.initialize(db.field_metadata, db.prefs, mi, 'column_icon_rules')
     self.set_cg_color(gprefs['cover_grid_color'])
     self.set_cg_texture(gprefs['cover_grid_texture'])
     self.update_aspect_ratio()
Esempio n. 32
0
 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)
Esempio n. 33
0
 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)
Esempio n. 34
0
 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
Esempio n. 35
0
 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
     ConfigWidgetBase.commit(self)
     change_settings(**settings)
     UserManager().user_data = users
     return True
Esempio n. 36
0
 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
Esempio n. 37
0
 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
Esempio n. 38
0
 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
Esempio n. 39
0
 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)
Esempio n. 40
0
 def __init__(self, *args, **kw):
     ConfigWidgetBase.__init__(self, *args, **kw)
     self.l = l = QVBoxLayout(self)
     l.setContentsMargins(0, 0, 0, 0)
     self.tabs_widget = t = QTabWidget(self)
     l.addWidget(t)
     self.main_tab = m = MainTab(self)
     t.addTab(m, _('&Main'))
     m.start_server.connect(self.start_server)
     m.stop_server.connect(self.stop_server)
     m.test_server.connect(self.test_server)
     m.show_logs.connect(self.view_server_logs)
     self.opt_autolaunch_server = m.opt_autolaunch_server
     self.users_tab = ua = Users(self)
     t.addTab(ua, _('&User accounts'))
     self.advanced_tab = a = AdvancedTab(self)
     sa = QScrollArea(self)
     sa.setWidget(a), sa.setWidgetResizable(True)
     t.addTab(sa, _('&Advanced'))
     for tab in self.tabs:
         if hasattr(tab, 'changed_signal'):
             tab.changed_signal.connect(self.changed_signal.emit)
Esempio n. 41
0
 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)
Esempio n. 42
0
 def initialize(self):
     ConfigWidgetBase.initialize(self)
     self.default_author_link.value = default_author_link()
     font = gprefs['font']
     if font is not None:
         font = list(font)
         font.append(gprefs.get('font_stretch', QFont.Unstretched))
     self.current_font = self.initial_font = font
     self.update_font_display()
     self.display_model.initialize()
     db = self.gui.current_db
     try:
         idx = self.gui.library_view.currentIndex().row()
         mi = db.get_metadata(idx, index_is_id=False)
     except:
         mi=None
     self.edit_rules.initialize(db.field_metadata, db.prefs, mi, 'column_color_rules')
     self.icon_rules.initialize(db.field_metadata, db.prefs, mi, 'column_icon_rules')
     self.grid_rules.initialize(db.field_metadata, db.prefs, mi, 'cover_grid_icon_rules')
     self.set_cg_color(gprefs['cover_grid_color'])
     self.set_cg_texture(gprefs['cover_grid_texture'])
     self.update_aspect_ratio()
Esempio n. 43
0
    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)
Esempio n. 44
0
    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)
Esempio n. 45
0
 def initialize(self):
     ConfigWidgetBase.initialize(self)
     self.default_author_link.value = default_author_link()
     font = gprefs['font']
     if font is not None:
         font = list(font)
         font.append(gprefs.get('font_stretch', QFont.Stretch.Unstretched))
     self.current_font = self.initial_font = font
     self.update_font_display()
     self.display_model.initialize()
     self.em_display_model.initialize()
     self.qv_display_model.initialize()
     db = self.gui.current_db
     mi = []
     try:
         rows = self.gui.current_view().selectionModel().selectedRows()
         for row in rows:
             if row.isValid():
                 mi.append(
                     db.new_api.get_proxy_metadata(
                         db.data.index_to_id(row.row())))
     except:
         pass
     self.edit_rules.initialize(db.field_metadata, db.prefs, mi,
                                'column_color_rules')
     self.icon_rules.initialize(db.field_metadata, db.prefs, mi,
                                'column_icon_rules')
     self.grid_rules.initialize(db.field_metadata, db.prefs, mi,
                                'cover_grid_icon_rules')
     self.set_cg_color(gprefs['cover_grid_color'])
     self.set_cg_texture(gprefs['cover_grid_texture'])
     self.update_aspect_ratio()
     self.opt_book_details_css.blockSignals(True)
     self.opt_book_details_css.setPlainText(
         P('templates/book_details.css', data=True).decode('utf-8'))
     self.opt_book_details_css.blockSignals(False)
     self.tb_focus_label.setVisible(
         self.opt_tag_browser_allow_keyboard_focus.isChecked())
Esempio n. 46
0
 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
Esempio n. 47
0
 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
Esempio n. 48
0
 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
Esempio n. 49
0
 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
Esempio n. 50
0
 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)
Esempio n. 51
0
 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
Esempio n. 52
0
 def initialize(self):
     ConfigWidgetBase.initialize(self)
Esempio n. 53
0
 def restore_defaults(self):
     ConfigWidgetBase.restore_defaults(self)
Esempio n. 54
0
 def restore_defaults(self):
     ConfigWidgetBase.restore_defaults(self)
     self.sources_model.restore_defaults()
     self.fields_model.restore_defaults()
     self.changed_signal.emit()
Esempio n. 55
0
 def commit(self):
     self.sources_model.commit()
     self.fields_model.commit()
     return ConfigWidgetBase.commit(self)
Esempio n. 56
0
 def initialize(self):
     ConfigWidgetBase.initialize(self)
     self.sources_model.initialize()
     self.sources_view.resizeColumnsToContents()
     self.fields_model.initialize()
Esempio n. 57
0
 def restore_defaults(self):
     ConfigWidgetBase.restore_defaults(self)
     self.conf_widget.restore_defaults()
Esempio n. 58
0
 def restore_defaults(self):
     ConfigWidgetBase.restore_defaults(self)
Esempio n. 59
0
 def restore_defaults(self):
     ConfigWidgetBase.restore_defaults(self)
     self.tweaks.restore_to_defaults()
     self.changed()
Esempio n. 60
0
 def commit(self):
     self.conf_widget.commit()
     return ConfigWidgetBase.commit(self)