mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Use preferred output format and input format order when converting via gui.
This commit is contained in:
parent
74dc8d5b1d
commit
a3361e36f6
@ -20,10 +20,6 @@ def supported_input_formats():
|
||||
fmts.add(x)
|
||||
return fmts
|
||||
|
||||
INPUT_FORMAT_PREFERENCES = ['cbr', 'cbz', 'cbc', 'lit', 'mobi', 'prc', 'azw', 'fb2', 'html',
|
||||
'rtf', 'pdf', 'txt', 'pdb']
|
||||
OUTPUT_FORMAT_PREFERENCES = ['epub', 'mobi', 'lit', 'pdf', 'pdb', 'txt']
|
||||
|
||||
class OptionValues(object):
|
||||
pass
|
||||
|
||||
|
@ -11,7 +11,6 @@ ORG_NAME = 'KovidsBrain'
|
||||
APP_UID = 'libprs500'
|
||||
from calibre import islinux, iswindows
|
||||
from calibre.startup import get_lang
|
||||
from calibre.customize.ui import all_input_formats
|
||||
from calibre.utils.config import Config, ConfigProxy, dynamic
|
||||
import calibre.resources as resources
|
||||
from calibre.ebooks.metadata.meta import get_metadata, metadata_from_formats
|
||||
@ -49,7 +48,8 @@ def _config():
|
||||
help=_('Defaults for conversion to LRF'))
|
||||
c.add_opt('LRF_ebook_viewer_options', default=None,
|
||||
help=_('Options for the LRF ebook viewer'))
|
||||
c.add_opt('internally_viewed_formats', default=all_input_formats(),
|
||||
c.add_opt('internally_viewed_formats', default=['LRF', 'EPUB', 'LIT',
|
||||
'MOBI', 'PRC', 'HTML', 'FB2', 'PDB', 'RB'],
|
||||
help=_('Formats that are viewed using the internal viewer'))
|
||||
c.add_opt('input_format_order', default=['EPUB', 'MOBI', 'PRC', 'LIT',
|
||||
'HTML', 'FB2', 'PDB', 'RB'],
|
||||
|
@ -15,7 +15,8 @@ from calibre.gui2.convert.page_setup import PageSetupWidget
|
||||
from calibre.gui2.convert.structure_detection import StructureDetectionWidget
|
||||
from calibre.gui2.convert.toc import TOCWidget
|
||||
from calibre.gui2.convert import GuiRecommendations
|
||||
from calibre.ebooks.conversion.plumber import Plumber, OUTPUT_FORMAT_PREFERENCES
|
||||
from calibre.ebooks.conversion.plumber import Plumber
|
||||
from calibre.utils.config import prefs
|
||||
from calibre.utils.logging import Log
|
||||
|
||||
class BulkConfig(Config):
|
||||
@ -102,7 +103,7 @@ class BulkConfig(Config):
|
||||
preferred_output_format = preferred_output_format if \
|
||||
preferred_output_format and preferred_output_format \
|
||||
in output_formats else sort_formats_by_preference(output_formats,
|
||||
OUTPUT_FORMAT_PREFERENCES)[0]
|
||||
prefs['output_format'])[0]
|
||||
self.output_formats.addItems(list(map(QString, [x.upper() for x in
|
||||
output_formats])))
|
||||
self.output_formats.setCurrentIndex(output_formats.index(preferred_output_format))
|
||||
@ -117,4 +118,3 @@ class BulkConfig(Config):
|
||||
self._recommendations = recs
|
||||
ResizableDialog.accept(self)
|
||||
|
||||
|
||||
|
@ -10,7 +10,7 @@ import sys, cPickle
|
||||
|
||||
from PyQt4.Qt import QString, SIGNAL, QAbstractListModel, Qt, QVariant, QFont
|
||||
|
||||
from calibre.gui2 import ResizableDialog, NONE
|
||||
from calibre.gui2 import ResizableDialog, NONE, config
|
||||
from calibre.ebooks.conversion.config import GuiRecommendations, save_specifics, \
|
||||
load_specifics
|
||||
from calibre.gui2.convert.single_ui import Ui_Dialog
|
||||
@ -20,11 +20,10 @@ from calibre.gui2.convert.page_setup import PageSetupWidget
|
||||
from calibre.gui2.convert.structure_detection import StructureDetectionWidget
|
||||
from calibre.gui2.convert.toc import TOCWidget
|
||||
|
||||
|
||||
from calibre.ebooks.conversion.plumber import Plumber, supported_input_formats, \
|
||||
INPUT_FORMAT_PREFERENCES, OUTPUT_FORMAT_PREFERENCES
|
||||
from calibre.ebooks.conversion.plumber import Plumber, supported_input_formats
|
||||
from calibre.customize.ui import available_output_formats
|
||||
from calibre.customize.conversion import OptionRecommendation
|
||||
from calibre.utils.config import prefs
|
||||
from calibre.utils.logging import Log
|
||||
|
||||
class NoSupportedInputFormats(Exception):
|
||||
@ -33,11 +32,11 @@ class NoSupportedInputFormats(Exception):
|
||||
def sort_formats_by_preference(formats, prefs):
|
||||
def fcmp(x, y):
|
||||
try:
|
||||
x = prefs.index(x)
|
||||
x = prefs.index(x.upper())
|
||||
except ValueError:
|
||||
x = sys.maxint
|
||||
try:
|
||||
y = prefs.index(y)
|
||||
y = prefs.index(y.upper())
|
||||
except ValueError:
|
||||
y = sys.maxint
|
||||
return cmp(x, y)
|
||||
@ -206,11 +205,11 @@ class Config(ResizableDialog, Ui_Dialog):
|
||||
preferred_input_format = preferred_input_format if \
|
||||
preferred_input_format in input_formats else \
|
||||
sort_formats_by_preference(input_formats,
|
||||
INPUT_FORMAT_PREFERENCES)[0]
|
||||
config['input_format_order'])[0]
|
||||
preferred_output_format = preferred_output_format if \
|
||||
preferred_output_format in output_formats else \
|
||||
sort_formats_by_preference(output_formats,
|
||||
OUTPUT_FORMAT_PREFERENCES)[0]
|
||||
prefs['output_format'])[0]
|
||||
self.input_formats.addItems(list(map(QString, [x.upper() for x in
|
||||
input_formats])))
|
||||
self.output_formats.addItems(list(map(QString, [x.upper() for x in
|
||||
|
Loading…
x
Reference in New Issue
Block a user