diff --git a/src/calibre/gui2/convert/pdf_output.py b/src/calibre/gui2/convert/pdf_output.py new file mode 100644 index 0000000000..2225b59436 --- /dev/null +++ b/src/calibre/gui2/convert/pdf_output.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- + +__license__ = 'GPL 3' +__copyright__ = '2009, John Schember ' +__docformat__ = 'restructuredtext en' + +from calibre.gui2.convert.pdf_output_ui import Ui_Form +from calibre.gui2.convert import Widget +from calibre.ebooks.pdf.pageoptions import PAPER_SIZES, ORIENTATIONS +from calibre.gui2.widgets import BasicComboModel + +paper_size_model = None +orientation_model = None + +class PluginWidget(Widget, Ui_Form): + + TITLE = _('PDF Output') + + def __init__(self, parent, get_option, get_help, db=None, book_id=None): + Widget.__init__(self, parent, 'pdf_output', ['paper_size', 'orientation']) + self.db, self.book_id = db, book_id + self.initialize_options(get_option, get_help, db, book_id) + + default_paper_size = self.opt_paper_size.currentText() + default_orientation = self.opt_orientation.currentText() + + global paper_size_model + if paper_size_model is None: + paper_size_model = BasicComboModel(PAPER_SIZES.keys()) + self.paper_size_model = paper_size_model + self.opt_paper_size.setModel(self.paper_size_model) + + default_index = self.opt_paper_size.findText(default_paper_size) + self.opt_paper_size.setCurrentIndex(default_index if default_index != -1 else 0) + + global orientation_model + if orientation_model is None: + orientation_model = BasicComboModel(ORIENTATIONS.keys()) + self.orientation_model = orientation_model + self.opt_orientation.setModel(self.orientation_model) + + default_index = self.opt_orientation.findText(default_orientation) + self.opt_orientation.setCurrentIndex(default_index if default_index != -1 else 0) + diff --git a/src/calibre/gui2/convert/pdf_output.ui b/src/calibre/gui2/convert/pdf_output.ui new file mode 100644 index 0000000000..ef29c55265 --- /dev/null +++ b/src/calibre/gui2/convert/pdf_output.ui @@ -0,0 +1,54 @@ + + + Form + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + Paper Size: + + + + + + + + + + Orientation: + + + + + + + + + + Qt::Vertical + + + + 20 + 213 + + + + + + + + + diff --git a/src/calibre/gui2/convert/txt_output.py b/src/calibre/gui2/convert/txt_output.py new file mode 100644 index 0000000000..6c084b18ff --- /dev/null +++ b/src/calibre/gui2/convert/txt_output.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- + +__license__ = 'GPL 3' +__copyright__ = '2009, John Schember ' +__docformat__ = 'restructuredtext en' + +from calibre.gui2.convert.txt_output_ui import Ui_Form +from calibre.gui2.convert import Widget +from calibre.ebooks.txt.writer import TxtNewlines +from calibre.gui2.widgets import BasicComboModel + +newline_model = None + +class PluginWidget(Widget, Ui_Form): + + TITLE = _('TXT Output') + + def __init__(self, parent, get_option, get_help, db=None, book_id=None): + Widget.__init__(self, parent, 'txt_output', ['newline']) + self.db, self.book_id = db, book_id + self.initialize_options(get_option, get_help, db, book_id) + + default = self.opt_newline.currentText() + + global newline_model + if newline_model is None: + newline_model = BasicComboModel(TxtNewlines.NEWLINE_TYPES.keys()) + self.newline_model = newline_model + self.opt_newline.setModel(self.newline_model) + + default_index = self.opt_newline.findText(default) + self.opt_newline.setCurrentIndex(default_index if default_index != -1 else 0) + diff --git a/src/calibre/gui2/convert/txt_output.ui b/src/calibre/gui2/convert/txt_output.ui new file mode 100644 index 0000000000..368c8d7b8b --- /dev/null +++ b/src/calibre/gui2/convert/txt_output.ui @@ -0,0 +1,44 @@ + + + Form + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + Newline Type: + + + + + + + + + + Qt::Vertical + + + + 20 + 246 + + + + + + + + + diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py index 2b89064d30..6840f4d7a8 100644 --- a/src/calibre/gui2/main.py +++ b/src/calibre/gui2/main.py @@ -1041,7 +1041,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI): rows = [x.row() for x in \ self.library_view.selectionModel().selectedRows()] jobs, changed, bad = convert_bulk_ebook(self, - self.library_view.model().db, row_ids) + self.library_view.model().db, row_ids, out_format=prefs['output_format']) for func, args, desc, fmt, id, temp_files in jobs: if id not in bad: job = self.job_manager.run_job(Dispatcher(self.book_converted), @@ -1060,7 +1060,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI): rows = [x.row() for x in \ self.library_view.selectionModel().selectedRows()] jobs, changed, bad = convert_single_ebook(self, - self.library_view.model().db, row_ids) + self.library_view.model().db, row_ids, out_format=prefs['output_format']) for func, args, desc, fmt, id, temp_files in jobs: if id not in bad: job = self.job_manager.run_job(Dispatcher(self.book_converted), diff --git a/src/calibre/gui2/tools.py b/src/calibre/gui2/tools.py index ceeee60ab5..b8dbbd5eba 100644 --- a/src/calibre/gui2/tools.py +++ b/src/calibre/gui2/tools.py @@ -72,7 +72,7 @@ def convert_single_ebook(parent, db, book_ids, auto_conversion=False, out_format return jobs, changed, bad -def convert_bulk_ebook(parent, db, book_ids): +def convert_bulk_ebook(parent, db, book_ids, out_format=None): changed = False jobs = [] bad = [] @@ -82,7 +82,7 @@ def convert_bulk_ebook(parent, db, book_ids): return None, None, None parent.status_bar.showMessage(_('Starting conversion of %d books') % total, 2000) - d = BulkConfig(parent, db) + d = BulkConfig(parent, db, out_format) if d.exec_() != QDialog.Accepted: return jobs, changed, bad