:erge branch 'master' of https://github.com/kovidgoyal/calibre into edit_mediapart_newsfeed

This commit is contained in:
Loic Houpert 2021-01-11 21:44:38 +01:00
commit ec2562fcbf
No known key found for this signature in database
GPG Key ID: 420C6A6671A9F480
3 changed files with 26 additions and 24 deletions

View File

@ -61,7 +61,7 @@ In the MOBI format, the situation is a little confused. This is because the MOBI
Now it might well seem to you that the MOBI book has two identical ToCs. Remember that one is semantically a content ToC and the other is a metadata ToC, even though both might have exactly the same entries and look the same. One can be accessed directly from the Kindle's menus, the other cannot. Now it might well seem to you that the MOBI book has two identical ToCs. Remember that one is semantically a content ToC and the other is a metadata ToC, even though both might have exactly the same entries and look the same. One can be accessed directly from the Kindle's menus, the other cannot.
When converting to MOBI, calibre detects the *metadata ToC* in the input document and generates an end-of-file ToC in the output MOBI file. You can turn this off by an option in the MOBI Output settings. You can also tell calibre whether to put it and the start or the end of the book via an option in the MOBI Output settings. Remember this ToC is semantically a *metadata ToC*, in any format other than MOBI it *cannot not be part of the text*. The fact that it is part of the text in MOBI is an accident caused by the limitations of MOBI. If you want a ToC at a particular location in your document text, create one by hand. So we strongly recommend that you leave the default as it is, i.e. with the metadata ToC at the end of the book. Also note that if you disable the generation of the end-of-file ToC the resulting MOBI file may not function correctly on a Kindle, since the Kindle's use the metadata ToC for many things, including the Page Flip feature. When converting to MOBI, calibre detects the *metadata ToC* in the input document and generates an end-of-file ToC in the output MOBI file. You can turn this off by an option in the MOBI Output settings. You can also tell calibre whether to put it at the start or the end of the book via an option in the MOBI Output settings. Remember this ToC is semantically a *metadata ToC*, in any format other than MOBI it *cannot not be part of the text*. The fact that it is part of the text in MOBI is an accident caused by the limitations of MOBI. If you want a ToC at a particular location in your document text, create one by hand. So we strongly recommend that you leave the default as it is, i.e. with the metadata ToC at the end of the book. Also note that if you disable the generation of the end-of-file ToC the resulting MOBI file may not function correctly on a Kindle, since the Kindle's use the metadata ToC for many things, including the Page Flip feature.
If you have a hand edited ToC in the input document, you can use the ToC detection options in calibre to automatically generate the metadata ToC from it. See the conversion section of the User Manual for more details on how to use these options. If you have a hand edited ToC in the input document, you can use the ToC detection options in calibre to automatically generate the metadata ToC from it. See the conversion section of the User Manual for more details on how to use these options.

View File

@ -278,24 +278,26 @@ class Plugin(object): # {{{
''' '''
if self.plugin_path is not None: if self.plugin_path is not None:
from calibre.utils.zipfile import ZipFile from calibre.utils.zipfile import ZipFile
zf = ZipFile(self.plugin_path) from importlib.machinery import EXTENSION_SUFFIXES
extensions = {x.rpartition('.')[-1].lower() for x in with ZipFile(self.plugin_path) as zf:
zf.namelist()} extensions = {x.lower() for x in EXTENSION_SUFFIXES}
zip_safe = True zip_safe = True
for ext in ('pyd', 'so', 'dll', 'dylib'): for name in zf.namelist():
if ext in extensions: for q in extensions:
zip_safe = False if name.endswith(q):
break zip_safe = False
if zip_safe: break
sys.path.insert(0, self.plugin_path) if not zip_safe:
self.sys_insertion_path = self.plugin_path break
else: if zip_safe:
from calibre.ptempfile import TemporaryDirectory sys.path.insert(0, self.plugin_path)
self._sys_insertion_tdir = TemporaryDirectory('plugin_unzip') self.sys_insertion_path = self.plugin_path
self.sys_insertion_path = self._sys_insertion_tdir.__enter__(*args) else:
zf.extractall(self.sys_insertion_path) from calibre.ptempfile import TemporaryDirectory
sys.path.insert(0, self.sys_insertion_path) self._sys_insertion_tdir = TemporaryDirectory('plugin_unzip')
zf.close() self.sys_insertion_path = self._sys_insertion_tdir.__enter__(*args)
zf.extractall(self.sys_insertion_path)
sys.path.insert(0, self.sys_insertion_path)
def __exit__(self, *args): def __exit__(self, *args):
ip, it = getattr(self, 'sys_insertion_path', None), getattr(self, ip, it = getattr(self, 'sys_insertion_path', None), getattr(self,

View File

@ -238,10 +238,10 @@ class Preferences(QDialog):
self.stack = QStackedWidget(self) self.stack = QStackedWidget(self)
self.bb = QDialogButtonBox( self.bb = QDialogButtonBox(
QDialogButtonBox.StandardButton.Close | QDialogButtonBox.StandardButton.Apply | QDialogButtonBox.StandardButton.Close | QDialogButtonBox.StandardButton.Apply |
QDialogButtonBox.StandardButton.Discard | QDialogButtonBox.StandardButton.RestoreDefaults QDialogButtonBox.StandardButton.Cancel | QDialogButtonBox.StandardButton.RestoreDefaults
) )
self.bb.button(QDialogButtonBox.StandardButton.Apply).clicked.connect(self.accept) self.bb.button(QDialogButtonBox.StandardButton.Apply).clicked.connect(self.accept)
self.bb.button(QDialogButtonBox.StandardButton.Discard).clicked.connect(self.reject) self.bb.button(QDialogButtonBox.StandardButton.Cancel).clicked.connect(self.reject)
self.bb.button(QDialogButtonBox.StandardButton.RestoreDefaults).setIcon(QIcon(I('clear_left.png'))) self.bb.button(QDialogButtonBox.StandardButton.RestoreDefaults).setIcon(QIcon(I('clear_left.png')))
self.bb.button(QDialogButtonBox.StandardButton.RestoreDefaults).clicked.connect(self.restore_defaults) self.bb.button(QDialogButtonBox.StandardButton.RestoreDefaults).clicked.connect(self.restore_defaults)
self.wizard_button = self.bb.addButton(_('Run Welcome &wizard'), QDialogButtonBox.ButtonRole.ActionRole) self.wizard_button = self.bb.addButton(_('Run Welcome &wizard'), QDialogButtonBox.ButtonRole.ActionRole)
@ -259,7 +259,7 @@ class Preferences(QDialog):
self.setContextMenuPolicy(Qt.ContextMenuPolicy.NoContextMenu) self.setContextMenuPolicy(Qt.ContextMenuPolicy.NoContextMenu)
self.title_bar = TitleBar(self) self.title_bar = TitleBar(self)
for ac, tt in [(QDialogButtonBox.StandardButton.Apply, _('Save changes')), for ac, tt in [(QDialogButtonBox.StandardButton.Apply, _('Save changes')),
(QDialogButtonBox.StandardButton.Discard, _('Cancel and return to overview'))]: (QDialogButtonBox.StandardButton.Cancel, _('Cancel and return to overview'))]:
self.bb.button(ac).setToolTip(tt) self.bb.button(ac).setToolTip(tt)
l.addWidget(self.title_bar), l.addWidget(self.stack), l.addWidget(self.bb) l.addWidget(self.title_bar), l.addWidget(self.stack), l.addWidget(self.bb)
@ -323,7 +323,7 @@ class Preferences(QDialog):
self.bb.button(QDialogButtonBox.StandardButton.Close).setVisible(False) self.bb.button(QDialogButtonBox.StandardButton.Close).setVisible(False)
self.wizard_button.setVisible(False) self.wizard_button.setVisible(False)
for button in (QDialogButtonBox.StandardButton.Apply, QDialogButtonBox.StandardButton.RestoreDefaults, QDialogButtonBox.StandardButton.Discard): for button in (QDialogButtonBox.StandardButton.Apply, QDialogButtonBox.StandardButton.RestoreDefaults, QDialogButtonBox.StandardButton.Cancel):
button = self.bb.button(button) button = self.bb.button(button)
button.setVisible(True) button.setVisible(True)
@ -353,7 +353,7 @@ class Preferences(QDialog):
self.title_bar.show_plugin() self.title_bar.show_plugin()
self.setWindowIcon(QIcon(I('config.png'))) self.setWindowIcon(QIcon(I('config.png')))
for button in (QDialogButtonBox.StandardButton.Apply, QDialogButtonBox.StandardButton.RestoreDefaults, QDialogButtonBox.StandardButton.Discard): for button in (QDialogButtonBox.StandardButton.Apply, QDialogButtonBox.StandardButton.RestoreDefaults, QDialogButtonBox.StandardButton.Cancel):
button = self.bb.button(button) button = self.bb.button(button)
button.setVisible(False) button.setVisible(False)