Example #1
0
    def modify_plugin(self, op=''):
        index = self.plugin_view.currentIndex()
        if index.isValid():
            if not index.parent().isValid():
                name = unicode(index.data() or '')
                return error_dialog(self, _('Error'), '<p>'+
                        _('Select an actual plugin under <b>%s</b> to customize')%name,
                        show=True, show_copy_button=False)

            plugin = self._plugin_model.index_to_plugin(index)
            if op == 'toggle':
                if not plugin.can_be_disabled:
                    info_dialog(self, _('Plugin cannot be disabled'),
                                 _('Disabling the plugin %s is not allowed')%plugin.name, show=True, show_copy_button=False)
                    return
                if is_disabled(plugin):
                    enable_plugin(plugin)
                else:
                    disable_plugin(plugin)
                self._plugin_model.refresh_plugin(plugin)
                self.changed_signal.emit()
            if op == 'customize':
                if not plugin.is_customizable():
                    info_dialog(self, _('Plugin not customizable'),
                        _('Plugin: %s does not need customization')%plugin.name).exec_()
                    return
                self.changed_signal.emit()
                from calibre.customize import InterfaceActionBase
                if isinstance(plugin, InterfaceActionBase) and not getattr(plugin,
                        'actual_iaction_plugin_loaded', False):
                    return error_dialog(self, _('Must restart'),
                            _('You must restart calibre before you can'
                                ' configure the <b>%s</b> plugin')%plugin.name, show=True)
                if plugin.do_user_config(self.gui):
                    self._plugin_model.refresh_plugin(plugin)
            elif op == 'remove':
                if not confirm('<p>' +
                    _('Are you sure you want to remove the plugin: %s?')%
                    '<b>{0}</b>'.format(plugin.name),
                    'confirm_plugin_removal_msg', parent=self):
                    return

                msg = _('Plugin <b>{0}</b> successfully removed. You will have'
                        ' to restart calibre for it to be completely removed.').format(plugin.name)
                if remove_plugin(plugin):
                    self._plugin_model.beginResetModel()
                    self._plugin_model.populate()
                    self._plugin_model.endResetModel()
                    self.changed_signal.emit()
                    info_dialog(self, _('Success'), msg, show=True,
                            show_copy_button=False)
                else:
                    error_dialog(self, _('Cannot remove builtin plugin'),
                         plugin.name + _(' cannot be removed. It is a '
                         'builtin plugin. Try disabling it instead.')).exec_()
Example #2
0
    def modify_plugin(self, op=''):
        index = self.plugin_view.currentIndex()
        if index.isValid():
            if not index.parent().isValid():
                name = str(index.data() or '')
                return error_dialog(self, _('Error'), '<p>'+
                        _('Select an actual plugin under <b>%s</b> to customize')%name,
                        show=True, show_copy_button=False)

            plugin = self._plugin_model.index_to_plugin(index)
            if op == 'toggle':
                if not plugin.can_be_disabled:
                    info_dialog(self, _('Plugin cannot be disabled'),
                                 _('Disabling the plugin %s is not allowed')%plugin.name, show=True, show_copy_button=False)
                    return
                if is_disabled(plugin):
                    enable_plugin(plugin)
                else:
                    disable_plugin(plugin)
                self._plugin_model.refresh_plugin(plugin)
                self.changed_signal.emit()
            if op == 'customize':
                if not plugin.is_customizable():
                    info_dialog(self, _('Plugin not customizable'),
                        _('Plugin: %s does not need customization')%plugin.name).exec_()
                    return
                self.changed_signal.emit()
                from calibre.customize import InterfaceActionBase
                if isinstance(plugin, InterfaceActionBase) and not getattr(plugin,
                        'actual_iaction_plugin_loaded', False):
                    return error_dialog(self, _('Must restart'),
                            _('You must restart calibre before you can'
                                ' configure the <b>%s</b> plugin')%plugin.name, show=True)
                if plugin.do_user_config(self.gui):
                    self._plugin_model.refresh_plugin(plugin)
            elif op == 'remove':
                if not confirm('<p>' +
                    _('Are you sure you want to remove the plugin: %s?')%
                    '<b>{0}</b>'.format(plugin.name),
                    'confirm_plugin_removal_msg', parent=self):
                    return

                msg = _('Plugin <b>{0}</b> successfully removed. You will have'
                        ' to restart calibre for it to be completely removed.').format(plugin.name)
                if remove_plugin(plugin):
                    self._plugin_model.beginResetModel()
                    self._plugin_model.populate()
                    self._plugin_model.endResetModel()
                    self.changed_signal.emit()
                    info_dialog(self, _('Success'), msg, show=True,
                            show_copy_button=False)
                else:
                    error_dialog(self, _('Cannot remove builtin plugin'),
                         plugin.name + _(' cannot be removed. It is a '
                         'builtin plugin. Try disabling it instead.')).exec_()
Example #3
0
 def _toggle_enabled_clicked(self):
     display_plugin = self._selected_display_plugin()
     plugin = display_plugin.plugin
     if not plugin.can_be_disabled:
         return error_dialog(self,_('Plugin cannot be disabled'),
                      _('The plugin: %s cannot be disabled')%plugin.name, show=True)
     if is_disabled(plugin):
         enable_plugin(plugin)
     else:
         disable_plugin(plugin)
     self.model.refresh_plugin(display_plugin)
Example #4
0
 def setData(self, index, data, role):
     if not index.isValid():
         return False
     row, col = index.row(), index.column()
     if col == 0:
         if data.toBool():
             enable_plugin(self.get_plugin(index))
         else:
             disable_plugin(self.get_plugin(index))
     self.dataChanged.emit(self.index(index.row(), 0), self.index(index.row(), self.columnCount() - 1))
     return True
Example #5
0
 def _toggle_enabled_clicked(self):
     display_plugin = self._selected_display_plugin()
     plugin = display_plugin.plugin
     if not plugin.can_be_disabled:
         return error_dialog(self,_('Plugin cannot be disabled'),
                      _('The plugin: %s cannot be disabled')%plugin.name, show=True)
     if is_disabled(plugin):
         enable_plugin(plugin)
     else:
         disable_plugin(plugin)
     self.model.refresh_plugin(display_plugin)
Example #6
0
 def setData(self, index, data, role):
     if not index.isValid():
         return False
     col = index.column()
     if col == 0:
         if bool(data):
             enable_plugin(self.get_plugin(index))
         else:
             disable_plugin(self.get_plugin(index))
     self.dataChanged.emit(self.index(index.row(), 0), self.index(index.row(), self.columnCount() - 1))
     return True
Example #7
0
    def commit(self):
        for plugin, val in self.enabled_overrides.iteritems():
            if val == Qt.Checked:
                enable_plugin(plugin)
            elif val == Qt.Unchecked:
                disable_plugin(plugin)

        if self.cover_overrides:
            cp = msprefs['cover_priorities']
            for plugin, val in self.cover_overrides.iteritems():
                if val == 1:
                    cp.pop(plugin.name, None)
                else:
                    cp[plugin.name] = val
            msprefs['cover_priorities'] = cp

        self.enabled_overrides = {}
        self.cover_overrides = {}
Example #8
0
    def commit(self):
        for plugin, val in self.enabled_overrides.iteritems():
            if val == Qt.Checked:
                enable_plugin(plugin)
            elif val == Qt.Unchecked:
                disable_plugin(plugin)

        if self.cover_overrides:
            cp = msprefs['cover_priorities']
            for plugin, val in self.cover_overrides.iteritems():
                if val == 1:
                    cp.pop(plugin.name, None)
                else:
                    cp[plugin.name] = val
            msprefs['cover_priorities'] = cp

        self.enabled_overrides = {}
        self.cover_overrides = {}
Example #9
0
    def modify_plugin(self, op=""):
        index = self.plugin_view.currentIndex()
        if index.isValid():
            if not index.parent().isValid():
                name = unicode(index.data().toString())
                return error_dialog(
                    self,
                    _("Error"),
                    "<p>" + _("Select an actual plugin under <b>%s</b> to customize") % name,
                    show=True,
                    show_copy_button=False,
                )

            plugin = self._plugin_model.index_to_plugin(index)
            if op == "toggle":
                if not plugin.can_be_disabled:
                    info_dialog(
                        self,
                        _("Plugin cannot be disabled"),
                        _("Disabling the plugin %s is not allowed") % plugin.name,
                        show=True,
                        show_copy_button=False,
                    )
                    return
                if is_disabled(plugin):
                    enable_plugin(plugin)
                else:
                    disable_plugin(plugin)
                self._plugin_model.refresh_plugin(plugin)
                self.changed_signal.emit()
            if op == "customize":
                if not plugin.is_customizable():
                    info_dialog(
                        self, _("Plugin not customizable"), _("Plugin: %s does not need customization") % plugin.name
                    ).exec_()
                    return
                self.changed_signal.emit()
                from calibre.customize import InterfaceActionBase

                if isinstance(plugin, InterfaceActionBase) and not getattr(
                    plugin, "actual_iaction_plugin_loaded", False
                ):
                    return error_dialog(
                        self,
                        _("Must restart"),
                        _("You must restart calibre before you can" " configure the <b>%s</b> plugin") % plugin.name,
                        show=True,
                    )
                if plugin.do_user_config(self.gui):
                    self._plugin_model.refresh_plugin(plugin)
            elif op == "remove":
                if not confirm(
                    "<p>" + _("Are you sure you want to remove the plugin: %s?") % "<b>{0}</b>".format(plugin.name),
                    "confirm_plugin_removal_msg",
                    parent=self,
                ):
                    return

                msg = _("Plugin <b>{0}</b> successfully removed").format(plugin.name)
                if remove_plugin(plugin):
                    self._plugin_model.populate()
                    self._plugin_model.reset()
                    self.changed_signal.emit()
                    info_dialog(self, _("Success"), msg, show=True, show_copy_button=False)
                else:
                    error_dialog(
                        self,
                        _("Cannot remove builtin plugin"),
                        plugin.name + _(" cannot be removed. It is a " "builtin plugin. Try disabling it instead."),
                    ).exec_()