mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
actually add pdf and txt output config widgets. Set preferred output format in convert dialogs to format in preferences.
This commit is contained in:
parent
2ae74a0395
commit
e2d2dd08ae
44
src/calibre/gui2/convert/pdf_output.py
Normal file
44
src/calibre/gui2/convert/pdf_output.py
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
__license__ = 'GPL 3'
|
||||||
|
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
||||||
|
__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)
|
||||||
|
|
54
src/calibre/gui2/convert/pdf_output.ui
Normal file
54
src/calibre/gui2/convert/pdf_output.ui
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>Form</class>
|
||||||
|
<widget class="QWidget" name="Form">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Paper Size:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="opt_paper_size"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Orientation:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QComboBox" name="opt_orientation"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>213</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
33
src/calibre/gui2/convert/txt_output.py
Normal file
33
src/calibre/gui2/convert/txt_output.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
__license__ = 'GPL 3'
|
||||||
|
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
||||||
|
__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)
|
||||||
|
|
44
src/calibre/gui2/convert/txt_output.ui
Normal file
44
src/calibre/gui2/convert/txt_output.ui
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>Form</class>
|
||||||
|
<widget class="QWidget" name="Form">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Newline Type:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="opt_newline"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>246</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
@ -1041,7 +1041,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
rows = [x.row() for x in \
|
rows = [x.row() for x in \
|
||||||
self.library_view.selectionModel().selectedRows()]
|
self.library_view.selectionModel().selectedRows()]
|
||||||
jobs, changed, bad = convert_bulk_ebook(self,
|
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:
|
for func, args, desc, fmt, id, temp_files in jobs:
|
||||||
if id not in bad:
|
if id not in bad:
|
||||||
job = self.job_manager.run_job(Dispatcher(self.book_converted),
|
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 \
|
rows = [x.row() for x in \
|
||||||
self.library_view.selectionModel().selectedRows()]
|
self.library_view.selectionModel().selectedRows()]
|
||||||
jobs, changed, bad = convert_single_ebook(self,
|
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:
|
for func, args, desc, fmt, id, temp_files in jobs:
|
||||||
if id not in bad:
|
if id not in bad:
|
||||||
job = self.job_manager.run_job(Dispatcher(self.book_converted),
|
job = self.job_manager.run_job(Dispatcher(self.book_converted),
|
||||||
|
@ -72,7 +72,7 @@ def convert_single_ebook(parent, db, book_ids, auto_conversion=False, out_format
|
|||||||
|
|
||||||
return jobs, changed, bad
|
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
|
changed = False
|
||||||
jobs = []
|
jobs = []
|
||||||
bad = []
|
bad = []
|
||||||
@ -82,7 +82,7 @@ def convert_bulk_ebook(parent, db, book_ids):
|
|||||||
return None, None, None
|
return None, None, None
|
||||||
parent.status_bar.showMessage(_('Starting conversion of %d books') % total, 2000)
|
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:
|
if d.exec_() != QDialog.Accepted:
|
||||||
return jobs, changed, bad
|
return jobs, changed, bad
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user