mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Catalogs: Add an option to not add the generated catalog to the library. Fixes #1481529 [[Enhancement] Don't Save Catalogue in Library Option](https://bugs.launchpad.net/calibre/+bug/1481529)
This commit is contained in:
parent
1f15db67f2
commit
a2120265e0
@ -56,7 +56,7 @@ class GenerateCatalogAction(InterfaceAction):
|
|||||||
fmt = os.path.splitext(out)[1][1:].upper()
|
fmt = os.path.splitext(out)[1][1:].upper()
|
||||||
job = self.gui.job_manager.run_job(
|
job = self.gui.job_manager.run_job(
|
||||||
self.Dispatcher(self.catalog_generated), func, args=args,
|
self.Dispatcher(self.catalog_generated), func, args=args,
|
||||||
description=desc)
|
description=desc)
|
||||||
job.catalog_file_path = out
|
job.catalog_file_path = out
|
||||||
job.fmt = fmt
|
job.fmt = fmt
|
||||||
job.catalog_sync, job.catalog_title = sync, title
|
job.catalog_sync, job.catalog_title = sync, title
|
||||||
@ -78,15 +78,16 @@ class GenerateCatalogAction(InterfaceAction):
|
|||||||
|
|
||||||
if job.failed:
|
if job.failed:
|
||||||
return self.gui.job_exception(job)
|
return self.gui.job_exception(job)
|
||||||
id = self.gui.library_view.model().add_catalog(job.catalog_file_path, job.catalog_title)
|
if dynamic.get('catalog_add_to_library', True):
|
||||||
self.gui.library_view.model().beginResetModel(), self.gui.library_view.model().endResetModel()
|
id = self.gui.library_view.model().add_catalog(job.catalog_file_path, job.catalog_title)
|
||||||
if job.catalog_sync:
|
self.gui.library_view.model().beginResetModel(), self.gui.library_view.model().endResetModel()
|
||||||
sync = dynamic.get('catalogs_to_be_synced', set([]))
|
if job.catalog_sync:
|
||||||
sync.add(id)
|
sync = dynamic.get('catalogs_to_be_synced', set([]))
|
||||||
dynamic.set('catalogs_to_be_synced', sync)
|
sync.add(id)
|
||||||
|
dynamic.set('catalogs_to_be_synced', sync)
|
||||||
self.gui.status_bar.show_message(_('Catalog generated.'), 3000)
|
self.gui.status_bar.show_message(_('Catalog generated.'), 3000)
|
||||||
self.gui.sync_catalogs()
|
self.gui.sync_catalogs()
|
||||||
if job.fmt not in {'EPUB','MOBI', 'AZW3'}:
|
if not dynamic.get('catalog_add_to_library', True) or job.fmt not in {'EPUB','MOBI', 'AZW3'}:
|
||||||
export_dir = choose_dir(self.gui, _('Export Catalog Directory'),
|
export_dir = choose_dir(self.gui, _('Export Catalog Directory'),
|
||||||
_('Select destination for %(title)s.%(fmt)s') % dict(
|
_('Select destination for %(title)s.%(fmt)s') % dict(
|
||||||
title=job.catalog_title, fmt=job.fmt.lower()))
|
title=job.catalog_title, fmt=job.fmt.lower()))
|
||||||
@ -96,7 +97,7 @@ class GenerateCatalogAction(InterfaceAction):
|
|||||||
try:
|
try:
|
||||||
shutil.copyfile(job.catalog_file_path, destination)
|
shutil.copyfile(job.catalog_file_path, destination)
|
||||||
except EnvironmentError as err:
|
except EnvironmentError as err:
|
||||||
if getattr(err, 'errno', None) == errno.EACCES: # Permission denied
|
if getattr(err, 'errno', None) == errno.EACCES: # Permission denied
|
||||||
import traceback
|
import traceback
|
||||||
error_dialog(self, _('Permission denied'),
|
error_dialog(self, _('Permission denied'),
|
||||||
_('Could not open %s. Is it being used by another'
|
_('Could not open %s. Is it being used by another'
|
||||||
@ -104,4 +105,3 @@ class GenerateCatalogAction(InterfaceAction):
|
|||||||
show=True)
|
show=True)
|
||||||
return
|
return
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
@ -114,6 +114,7 @@ class Catalog(ResizableDialog, Ui_Dialog):
|
|||||||
|
|
||||||
if self.sync.isEnabled():
|
if self.sync.isEnabled():
|
||||||
self.sync.setChecked(dynamic.get('catalog_sync_to_device', True))
|
self.sync.setChecked(dynamic.get('catalog_sync_to_device', True))
|
||||||
|
self.add_to_library.setChecked(dynamic.get('catalog_add_to_library', True))
|
||||||
|
|
||||||
self.format.currentIndexChanged.connect(self.show_plugin_tab)
|
self.format.currentIndexChanged.connect(self.show_plugin_tab)
|
||||||
self.buttonBox.button(self.buttonBox.Apply).clicked.connect(self.apply)
|
self.buttonBox.button(self.buttonBox.Apply).clicked.connect(self.apply)
|
||||||
@ -169,6 +170,7 @@ class Catalog(ResizableDialog, Ui_Dialog):
|
|||||||
self.catalog_sync = bool(self.sync.isChecked())
|
self.catalog_sync = bool(self.sync.isChecked())
|
||||||
dynamic.set('catalog_sync_to_device', self.catalog_sync)
|
dynamic.set('catalog_sync_to_device', self.catalog_sync)
|
||||||
dynamic.set('catalog_window_geom', bytearray(self.saveGeometry()))
|
dynamic.set('catalog_window_geom', bytearray(self.saveGeometry()))
|
||||||
|
dynamic.set('catalog_add_to_library', self.add_to_library.isChecked())
|
||||||
|
|
||||||
def apply(self, *args):
|
def apply(self, *args):
|
||||||
# Store current values without building catalog
|
# Store current values without building catalog
|
||||||
|
@ -96,7 +96,7 @@
|
|||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Catalog &format:</string>
|
<string>Catalo&g format:</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy">
|
<property name="buddy">
|
||||||
<cstring>format</cstring>
|
<cstring>format</cstring>
|
||||||
@ -122,7 +122,7 @@
|
|||||||
<item row="1" column="2">
|
<item row="1" column="2">
|
||||||
<widget class="QLineEdit" name="title"/>
|
<widget class="QLineEdit" name="title"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="4" column="1">
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
@ -142,6 +142,18 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="0" colspan="3">
|
||||||
|
<widget class="QCheckBox" name="add_to_library">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Add the catalog to your calibre library after it is generated.
|
||||||
|
Note that if you disable adding of the catalog to the library
|
||||||
|
sending of the catalog todevice will not work.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Add catalog to library</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user