mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Permit zero-argument template functions.
This commit is contained in:
parent
5c8745c6cf
commit
efac88d69a
@ -7,7 +7,9 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
import json, traceback
|
||||
|
||||
from calibre.gui2 import error_dialog
|
||||
from PyQt4.Qt import QDialogButtonBox
|
||||
|
||||
from calibre.gui2 import error_dialog, warning_dialog
|
||||
from calibre.gui2.preferences import ConfigWidgetBase, test_widget
|
||||
from calibre.gui2.preferences.template_functions_ui import Ui_Form
|
||||
from calibre.gui2.widgets import PythonHighlighter
|
||||
@ -152,9 +154,14 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||
_('Name already used'), show=True)
|
||||
return
|
||||
if self.argument_count.value() == 0:
|
||||
error_dialog(self.gui, _('Template functions'),
|
||||
_('Argument count must be -1 or greater than zero'),
|
||||
show=True)
|
||||
box = warning_dialog(self.gui, _('Template functions'),
|
||||
_('Argument count should be -1 or greater than zero.'
|
||||
'Setting it to zero means that this function cannot '
|
||||
'be used in single function mode.'), det_msg = '',
|
||||
show=False)
|
||||
box.bb.setStandardButtons(box.bb.standardButtons() | QDialogButtonBox.Cancel)
|
||||
box.det_msg_toggle.setVisible(False)
|
||||
if not box.exec_():
|
||||
return
|
||||
try:
|
||||
prog = unicode(self.program.toPlainText())
|
||||
|
Loading…
x
Reference in New Issue
Block a user