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:
Kovid Goyal 2015-08-05 10:19:12 +05:30
parent 1f15db67f2
commit a2120265e0
3 changed files with 26 additions and 12 deletions

View File

@ -56,7 +56,7 @@ class GenerateCatalogAction(InterfaceAction):
fmt = os.path.splitext(out)[1][1:].upper()
job = self.gui.job_manager.run_job(
self.Dispatcher(self.catalog_generated), func, args=args,
description=desc)
description=desc)
job.catalog_file_path = out
job.fmt = fmt
job.catalog_sync, job.catalog_title = sync, title
@ -78,15 +78,16 @@ class GenerateCatalogAction(InterfaceAction):
if job.failed:
return self.gui.job_exception(job)
id = self.gui.library_view.model().add_catalog(job.catalog_file_path, job.catalog_title)
self.gui.library_view.model().beginResetModel(), self.gui.library_view.model().endResetModel()
if job.catalog_sync:
sync = dynamic.get('catalogs_to_be_synced', set([]))
sync.add(id)
dynamic.set('catalogs_to_be_synced', sync)
if dynamic.get('catalog_add_to_library', True):
id = self.gui.library_view.model().add_catalog(job.catalog_file_path, job.catalog_title)
self.gui.library_view.model().beginResetModel(), self.gui.library_view.model().endResetModel()
if job.catalog_sync:
sync = dynamic.get('catalogs_to_be_synced', set([]))
sync.add(id)
dynamic.set('catalogs_to_be_synced', sync)
self.gui.status_bar.show_message(_('Catalog generated.'), 3000)
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'),
_('Select destination for %(title)s.%(fmt)s') % dict(
title=job.catalog_title, fmt=job.fmt.lower()))
@ -96,7 +97,7 @@ class GenerateCatalogAction(InterfaceAction):
try:
shutil.copyfile(job.catalog_file_path, destination)
except EnvironmentError as err:
if getattr(err, 'errno', None) == errno.EACCES: # Permission denied
if getattr(err, 'errno', None) == errno.EACCES: # Permission denied
import traceback
error_dialog(self, _('Permission denied'),
_('Could not open %s. Is it being used by another'
@ -104,4 +105,3 @@ class GenerateCatalogAction(InterfaceAction):
show=True)
return
raise

View File

@ -114,6 +114,7 @@ class Catalog(ResizableDialog, Ui_Dialog):
if self.sync.isEnabled():
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.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())
dynamic.set('catalog_sync_to_device', self.catalog_sync)
dynamic.set('catalog_window_geom', bytearray(self.saveGeometry()))
dynamic.set('catalog_add_to_library', self.add_to_library.isChecked())
def apply(self, *args):
# Store current values without building catalog

View File

@ -96,7 +96,7 @@
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Catalog &amp;format:</string>
<string>Catalo&amp;g format:</string>
</property>
<property name="buddy">
<cstring>format</cstring>
@ -122,7 +122,7 @@
<item row="1" column="2">
<widget class="QLineEdit" name="title"/>
</item>
<item row="3" column="1">
<item row="4" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -142,6 +142,18 @@
</property>
</widget>
</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>&amp;Add catalog to library</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>