mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Pull from driver-dev
This commit is contained in:
commit
7961339e2a
@ -16,18 +16,19 @@ class DeviceConfig(object):
|
||||
c.add_opt('format_map', default=cls.FORMATS, help=cls.HELP_MESSAGE)
|
||||
return c
|
||||
|
||||
@classmethod
|
||||
def _configProxy(cls):
|
||||
return ConfigProxy(cls._config())
|
||||
|
||||
@classmethod
|
||||
def config_widget(cls):
|
||||
from calibre.gui2.device_drivers.configwidget import ConfigWidget
|
||||
cw = ConfigWidget(cls.configProxy(cls._config()), cls.FORMATS)
|
||||
cw = ConfigWidget(cls._configProxy(), cls.FORMATS)
|
||||
return cw
|
||||
|
||||
@classmethod
|
||||
def save_settings(cls, config_widget):
|
||||
cls.configProxy(cls._config())['format_map'] = config_widget.format_map()
|
||||
cls._configProxy()['format_map'] = config_widget.format_map()
|
||||
|
||||
@classmethod
|
||||
def settings(cls):
|
||||
|
@ -22,8 +22,7 @@ from cssutils import CSSParser
|
||||
from calibre.translations.dynamic import translate
|
||||
from calibre.ebooks.chardet import xml_to_unicode
|
||||
from calibre.ebooks.oeb.entitydefs import ENTITYDEFS
|
||||
from calibre.ebooks.conversion.preprocess import HTMLPreProcessor, \
|
||||
CSSPreProcessor
|
||||
from calibre.ebooks.conversion.preprocess import CSSPreProcessor
|
||||
|
||||
XML_NS = 'http://www.w3.org/XML/1998/namespace'
|
||||
XHTML_NS = 'http://www.w3.org/1999/xhtml'
|
||||
|
0
src/calibre/gui2/device_drivers/__init__.py
Normal file
0
src/calibre/gui2/device_drivers/__init__.py
Normal file
@ -7,7 +7,8 @@ from PyQt4.Qt import QDialog, QMessageBox, QListWidgetItem, QIcon, \
|
||||
QDesktopServices, QVBoxLayout, QLabel, QPlainTextEdit, \
|
||||
QStringListModel, QAbstractItemModel, QFont, \
|
||||
SIGNAL, QTimer, Qt, QSize, QVariant, QUrl, \
|
||||
QModelIndex, QInputDialog, QAbstractTableModel
|
||||
QModelIndex, QInputDialog, QAbstractTableModel, \
|
||||
QDialogButtonBox
|
||||
|
||||
from calibre.constants import islinux, iswindows
|
||||
from calibre.gui2.dialogs.config_ui import Ui_Dialog
|
||||
@ -525,11 +526,11 @@ class ConfigDialog(QDialog, Ui_Dialog):
|
||||
index = self.plugin_view.currentIndex()
|
||||
if index.isValid():
|
||||
plugin = self._plugin_model.index_to_plugin(index)
|
||||
if not plugin.can_be_disabled:
|
||||
error_dialog(self,_('Plugin cannot be disabled'),
|
||||
_('The plugin: %s cannot be disabled')%plugin.name).exec_()
|
||||
return
|
||||
if op == 'toggle':
|
||||
if not plugin.can_be_disabled:
|
||||
error_dialog(self,_('Plugin cannot be disabled'),
|
||||
_('The plugin: %s cannot be disabled')%plugin.name).exec_()
|
||||
return
|
||||
if is_disabled(plugin):
|
||||
enable_plugin(plugin)
|
||||
else:
|
||||
@ -540,11 +541,28 @@ class ConfigDialog(QDialog, Ui_Dialog):
|
||||
info_dialog(self, _('Plugin not customizable'),
|
||||
_('Plugin: %s does not need customization')%plugin.name).exec_()
|
||||
return
|
||||
help = plugin.customization_help()
|
||||
text, ok = QInputDialog.getText(self, _('Customize %s')%plugin.name,
|
||||
help)
|
||||
if ok:
|
||||
customize_plugin(plugin, unicode(text))
|
||||
if hasattr(plugin, 'config_widget'):
|
||||
config_dialog = QDialog(self)
|
||||
button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
||||
|
||||
config_dialog.connect(button_box, SIGNAL('accepted()'), config_dialog.accept)
|
||||
config_dialog.connect(button_box, SIGNAL('rejected()'), config_dialog.reject)
|
||||
|
||||
config_widget = plugin.config_widget()
|
||||
v = QVBoxLayout(config_dialog)
|
||||
v.addWidget(config_widget)
|
||||
v.addWidget(button_box)
|
||||
config_dialog.exec_()
|
||||
|
||||
if config_dialog.result() == QDialog.Accepted:
|
||||
plugin.save_settings(config_widget)
|
||||
self._plugin_model.refresh_plugin(plugin)
|
||||
else:
|
||||
help = plugin.customization_help()
|
||||
text, ok = QInputDialog.getText(self, _('Customize %s')%plugin.name,
|
||||
help)
|
||||
if ok:
|
||||
customize_plugin(plugin, unicode(text))
|
||||
self._plugin_model.refresh_plugin(plugin)
|
||||
if op == 'remove':
|
||||
if remove_plugin(plugin):
|
||||
|
Loading…
x
Reference in New Issue
Block a user