mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Changes to template tester: make the intro text into placeholder text and remember the last template entered during the calibre session.
See http://www.mobileread.com/forums/showthread.php?p=2917642
This commit is contained in:
parent
3e733c1a33
commit
c4b46b77c5
@ -18,6 +18,8 @@ class ShowTemplateTesterAction(InterfaceAction):
|
|||||||
action_type = 'current'
|
action_type = 'current'
|
||||||
|
|
||||||
def genesis(self):
|
def genesis(self):
|
||||||
|
self.previous_text = _('Enter a template to test using data from the selected book')
|
||||||
|
self.first_time = True
|
||||||
self.qaction.triggered.connect(self.show_template_editor)
|
self.qaction.triggered.connect(self.show_template_editor)
|
||||||
|
|
||||||
def show_template_editor(self, *args):
|
def show_template_editor(self, *args):
|
||||||
@ -38,8 +40,10 @@ class ShowTemplateTesterAction(InterfaceAction):
|
|||||||
index = rows[0]
|
index = rows[0]
|
||||||
if index.isValid():
|
if index.isValid():
|
||||||
db = view.model().db
|
db = view.model().db
|
||||||
t = TemplateDialog(self.gui,
|
t = TemplateDialog(self.gui, self.previous_text,
|
||||||
_('Enter a template to test using data from the selected book'),
|
mi=db.get_metadata(index.row(), index_is_id=False, get_cover=False),
|
||||||
mi=db.get_metadata(index.row(), index_is_id=False, get_cover=False))
|
text_is_placeholder=self.first_time)
|
||||||
t.setWindowTitle(_('Template tester'))
|
t.setWindowTitle(_('Template tester'))
|
||||||
t.exec_()
|
if t.exec_() == t.Accepted:
|
||||||
|
self.previous_text = t.rule[1]
|
||||||
|
self.first_time = False
|
@ -202,7 +202,8 @@ class TemplateHighlighter(QSyntaxHighlighter):
|
|||||||
class TemplateDialog(QDialog, Ui_TemplateDialog):
|
class TemplateDialog(QDialog, Ui_TemplateDialog):
|
||||||
|
|
||||||
def __init__(self, parent, text, mi=None, fm=None, color_field=None,
|
def __init__(self, parent, text, mi=None, fm=None, color_field=None,
|
||||||
icon_field_key=None, icon_rule_kind=None, doing_emblem=False):
|
icon_field_key=None, icon_rule_kind=None, doing_emblem=False,
|
||||||
|
text_is_placeholder=False):
|
||||||
QDialog.__init__(self, parent)
|
QDialog.__init__(self, parent)
|
||||||
Ui_TemplateDialog.__init__(self)
|
Ui_TemplateDialog.__init__(self)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
@ -299,7 +300,10 @@ class TemplateDialog(QDialog, Ui_TemplateDialog):
|
|||||||
self.source_code.setReadOnly(True)
|
self.source_code.setReadOnly(True)
|
||||||
|
|
||||||
if text is not None:
|
if text is not None:
|
||||||
self.textbox.setPlainText(text)
|
if text_is_placeholder:
|
||||||
|
self.textbox.setPlaceholderText(text)
|
||||||
|
else:
|
||||||
|
self.textbox.setPlainText(text)
|
||||||
self.buttonBox.button(QDialogButtonBox.Ok).setText(_('&OK'))
|
self.buttonBox.button(QDialogButtonBox.Ok).setText(_('&OK'))
|
||||||
self.buttonBox.button(QDialogButtonBox.Cancel).setText(_('&Cancel'))
|
self.buttonBox.button(QDialogButtonBox.Cancel).setText(_('&Cancel'))
|
||||||
self.color_copy_button.clicked.connect(self.color_to_clipboard)
|
self.color_copy_button.clicked.connect(self.color_to_clipboard)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user