mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add a tweak to control the default choice of format for the Tweak Book feature
This commit is contained in:
parent
4536a89989
commit
1c25651c1b
@ -506,3 +506,17 @@ change_book_details_font_size_by = 0
|
|||||||
# No compile: compile_gpm_templates = False
|
# No compile: compile_gpm_templates = False
|
||||||
compile_gpm_templates = True
|
compile_gpm_templates = True
|
||||||
|
|
||||||
|
#: What format to default to when using the Tweak feature
|
||||||
|
# The Tweak feature of calibre allows direct editing of a book format.
|
||||||
|
# If multiple formats are available, calibre will offer you a choice
|
||||||
|
# of formats, defaulting to your preferred output format if it is available.
|
||||||
|
# Set this tweak to a specific value of 'EPUB' or 'AZW3' to always default
|
||||||
|
# to that format rather than your output format preference.
|
||||||
|
# Set to a value of 'remember' to use whichever format you chose last time you
|
||||||
|
# used the Tweak feature.
|
||||||
|
# Examples:
|
||||||
|
# default_tweak_format = None (Use output format)
|
||||||
|
# default_tweak_format = 'EPUB'
|
||||||
|
# default_tweak_format = 'remember'
|
||||||
|
default_tweak_format = None
|
||||||
|
|
||||||
|
@ -12,11 +12,11 @@ from PyQt4.Qt import (QDialog, QVBoxLayout, QHBoxLayout, QRadioButton, QFrame,
|
|||||||
|
|
||||||
from calibre import as_unicode
|
from calibre import as_unicode
|
||||||
from calibre.constants import isosx
|
from calibre.constants import isosx
|
||||||
from calibre.gui2 import error_dialog, question_dialog, open_local_file
|
from calibre.gui2 import error_dialog, question_dialog, open_local_file, gprefs
|
||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
from calibre.ptempfile import (PersistentTemporaryDirectory,
|
from calibre.ptempfile import (PersistentTemporaryDirectory,
|
||||||
PersistentTemporaryFile)
|
PersistentTemporaryFile)
|
||||||
from calibre.utils.config import prefs
|
from calibre.utils.config import prefs, tweaks
|
||||||
|
|
||||||
class TweakBook(QDialog):
|
class TweakBook(QDialog):
|
||||||
|
|
||||||
@ -32,11 +32,16 @@ class TweakBook(QDialog):
|
|||||||
index_is_id=True))
|
index_is_id=True))
|
||||||
|
|
||||||
button = self.fmt_choice_buttons[0]
|
button = self.fmt_choice_buttons[0]
|
||||||
|
button_map = {unicode(x.text()):x for x in self.fmt_choice_buttons}
|
||||||
of = prefs['output_format'].upper()
|
of = prefs['output_format'].upper()
|
||||||
for x in self.fmt_choice_buttons:
|
df = tweaks.get('default_tweak_format', None)
|
||||||
if unicode(x.text()) == of:
|
lf = gprefs.get('last_tweak_format', None)
|
||||||
button = x
|
if df and df.lower() == 'remember' and lf in button_map:
|
||||||
break
|
button = button_map[lf]
|
||||||
|
elif df and df.upper() in button_map:
|
||||||
|
button = button_map[df.upper()]
|
||||||
|
elif of in button_map:
|
||||||
|
button = button_map[of]
|
||||||
button.setChecked(True)
|
button.setChecked(True)
|
||||||
|
|
||||||
self.init_state()
|
self.init_state()
|
||||||
@ -148,6 +153,8 @@ class TweakBook(QDialog):
|
|||||||
|
|
||||||
def explode(self):
|
def explode(self):
|
||||||
self.show_msg(_('Exploding, please wait...'))
|
self.show_msg(_('Exploding, please wait...'))
|
||||||
|
if len(self.fmt_choice_buttons) > 1:
|
||||||
|
gprefs.set('last_tweak_format', self.current_format.upper())
|
||||||
QTimer.singleShot(5, self.do_explode)
|
QTimer.singleShot(5, self.do_explode)
|
||||||
|
|
||||||
def ask_question(self, msg):
|
def ask_question(self, msg):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user