Exemple #1
0
    def commit(self):
        # Ensure preferences are showing in either the toolbar or
        # the menubar.
        pref_in_toolbar = self.models['toolbar'][1].has_action('Preferences')
        pref_in_menubar = self.models['menubar'][1].has_action('Preferences')
        lm_in_toolbar = self.models['toolbar-device'][1].has_action(
            'Location Manager')
        lm_in_menubar = self.models['menubar-device'][1].has_action(
            'Location Manager')
        if not pref_in_toolbar and not pref_in_menubar:
            error_dialog(
                self,
                _('Preferences missing'),
                _('The Preferences action must be in either the main toolbar or the menubar.'
                  ),
                show=True)
            raise AbortCommit()
        if not lm_in_toolbar and not lm_in_menubar:
            error_dialog(
                self,
                _('Location manager missing'),
                _('The Location manager must be in either the main toolbar or the menubar when a device is connected.'
                  ),
                show=True)
            raise AbortCommit()

        # Save data.
        for am, cm in self.models.values():
            cm.commit()
        return False
Exemple #2
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
Exemple #3
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
Exemple #4
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)
    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)
Exemple #6
0
 def commit(self):
     if not self.save_changes():
         raise AbortCommit()
     warning_dialog(self,
                    _('Restart needed'),
                    _('You need to restart the server for changes to'
                      ' take effect'),
                    show=True)
     return False
Exemple #7
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)
Exemple #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
Exemple #9
0
 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)
Exemple #10
0
 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)