mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Catalog dialog: Only show options tab for currently selected output format
This commit is contained in:
parent
dea55f5f09
commit
57a59d2798
@ -16,6 +16,7 @@ class PluginWidget(QWidget, Ui_Form):
|
|||||||
TITLE = _('CSV/XML Output')
|
TITLE = _('CSV/XML Output')
|
||||||
HELP = _('Options specific to')+' CSV/XML '+_('output')
|
HELP = _('Options specific to')+' CSV/XML '+_('output')
|
||||||
sync_enabled = False
|
sync_enabled = False
|
||||||
|
formats = set(['csv', 'xml'])
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
QWidget.__init__(self, parent)
|
QWidget.__init__(self, parent)
|
||||||
|
@ -100,8 +100,6 @@ class Catalog(QDialog, Ui_Dialog):
|
|||||||
info("No dynamic tab resources found for %s" % name)
|
info("No dynamic tab resources found for %s" % name)
|
||||||
|
|
||||||
self.widgets = sorted(self.widgets, cmp=lambda x,y:cmp(x.TITLE, y.TITLE))
|
self.widgets = sorted(self.widgets, cmp=lambda x,y:cmp(x.TITLE, y.TITLE))
|
||||||
for pw in self.widgets:
|
|
||||||
self.tabs.addTab(pw, pw.TITLE)
|
|
||||||
|
|
||||||
# Generate a sorted list of installed catalog formats/sync_enabled pairs
|
# Generate a sorted list of installed catalog formats/sync_enabled pairs
|
||||||
fmts = sorted([x[0] for x in self.fmts])
|
fmts = sorted([x[0] for x in self.fmts])
|
||||||
@ -125,6 +123,19 @@ class Catalog(QDialog, 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.format.currentIndexChanged.connect(self.format_changed)
|
||||||
|
self.show_plugin_tab(None)
|
||||||
|
|
||||||
|
|
||||||
|
def show_plugin_tab(self, idx):
|
||||||
|
cf = unicode(self.format.currentText()).lower()
|
||||||
|
while self.tabs.count() > 1:
|
||||||
|
self.tabs.remove(1)
|
||||||
|
for pw in self.widgets:
|
||||||
|
if cf in pw.formats:
|
||||||
|
self.tabs.addTab(pw, pw.TITLE)
|
||||||
|
break
|
||||||
|
|
||||||
def format_changed(self, idx):
|
def format_changed(self, idx):
|
||||||
cf = unicode(self.format.currentText())
|
cf = unicode(self.format.currentText())
|
||||||
if cf in self.sync_enabled_formats:
|
if cf in self.sync_enabled_formats:
|
||||||
@ -133,6 +144,14 @@ class Catalog(QDialog, Ui_Dialog):
|
|||||||
self.sync.setDisabled(True)
|
self.sync.setDisabled(True)
|
||||||
self.sync.setChecked(False)
|
self.sync.setChecked(False)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def fmt_options(self):
|
||||||
|
ans = {}
|
||||||
|
if self.tabs.count() > 1:
|
||||||
|
w = self.tabs.widget(1)
|
||||||
|
ans = w.options()
|
||||||
|
return ans
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
self.catalog_format = unicode(self.format.currentText())
|
self.catalog_format = unicode(self.format.currentText())
|
||||||
dynamic.set('catalog_preferred_format', self.catalog_format)
|
dynamic.set('catalog_preferred_format', self.catalog_format)
|
||||||
|
@ -238,7 +238,7 @@ def fetch_scheduled_recipe(arg):
|
|||||||
|
|
||||||
def generate_catalog(parent, dbspec, ids):
|
def generate_catalog(parent, dbspec, ids):
|
||||||
from calibre.gui2.dialogs.catalog import Catalog
|
from calibre.gui2.dialogs.catalog import Catalog
|
||||||
|
|
||||||
# Build the Catalog dialog in gui2.dialogs.catalog
|
# Build the Catalog dialog in gui2.dialogs.catalog
|
||||||
d = Catalog(parent, dbspec, ids)
|
d = Catalog(parent, dbspec, ids)
|
||||||
|
|
||||||
@ -248,22 +248,13 @@ def generate_catalog(parent, dbspec, ids):
|
|||||||
# Create the output file
|
# Create the output file
|
||||||
out = PersistentTemporaryFile(suffix='_catalog_out.'+d.catalog_format.lower())
|
out = PersistentTemporaryFile(suffix='_catalog_out.'+d.catalog_format.lower())
|
||||||
|
|
||||||
# Retrieve plugin options
|
|
||||||
fmt_options = {}
|
|
||||||
for x in range(d.tabs.count()):
|
|
||||||
if str(d.tabs.tabText(x)).find(str(d.catalog_format)) > -1:
|
|
||||||
for fmt in d.fmts:
|
|
||||||
if fmt[0] == d.catalog_format:
|
|
||||||
fmt_options = fmt[2].options()
|
|
||||||
# print "gui2.tools:generate_catalog(): options for %s: %s" % (fmt[0], fmt_options)
|
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
d.catalog_format,
|
d.catalog_format,
|
||||||
d.catalog_title,
|
d.catalog_title,
|
||||||
dbspec,
|
dbspec,
|
||||||
ids,
|
ids,
|
||||||
out.name,
|
out.name,
|
||||||
fmt_options
|
d.fmt_options
|
||||||
]
|
]
|
||||||
out.close()
|
out.close()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user