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
|
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 import ConfigWidgetBase, test_widget
|
||||||
from calibre.gui2.preferences.template_functions_ui import Ui_Form
|
from calibre.gui2.preferences.template_functions_ui import Ui_Form
|
||||||
from calibre.gui2.widgets import PythonHighlighter
|
from calibre.gui2.widgets import PythonHighlighter
|
||||||
@ -152,10 +154,15 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
_('Name already used'), show=True)
|
_('Name already used'), show=True)
|
||||||
return
|
return
|
||||||
if self.argument_count.value() == 0:
|
if self.argument_count.value() == 0:
|
||||||
error_dialog(self.gui, _('Template functions'),
|
box = warning_dialog(self.gui, _('Template functions'),
|
||||||
_('Argument count must be -1 or greater than zero'),
|
_('Argument count should be -1 or greater than zero.'
|
||||||
show=True)
|
'Setting it to zero means that this function cannot '
|
||||||
return
|
'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:
|
try:
|
||||||
prog = unicode(self.program.toPlainText())
|
prog = unicode(self.program.toPlainText())
|
||||||
cls = compile_user_function(name, unicode(self.documentation.toPlainText()),
|
cls = compile_user_function(name, unicode(self.documentation.toPlainText()),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user