This commit is contained in:
Kovid Goyal 2021-01-21 20:42:09 +05:30
commit 2b8ed93987
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 548 additions and 364 deletions

View File

@ -46,7 +46,7 @@ class TemplateHighlighter(QSyntaxHighlighter):
KEYWORDS = ["program", 'if', 'then', 'else', 'elif', 'fi'] KEYWORDS = ["program", 'if', 'then', 'else', 'elif', 'fi']
def __init__(self, parent=None): def __init__(self, parent=None, builtin_functions=None):
super(TemplateHighlighter, self).__init__(parent) super(TemplateHighlighter, self).__init__(parent)
self.initializeFormats() self.initializeFormats()
@ -56,7 +56,8 @@ class TemplateHighlighter(QSyntaxHighlighter):
"keyword")) "keyword"))
TemplateHighlighter.Rules.append((QRegExp( TemplateHighlighter.Rules.append((QRegExp(
"|".join([r"\b%s\b" % builtin for builtin in "|".join([r"\b%s\b" % builtin for builtin in
formatter_functions().get_builtins()])), (builtin_functions if builtin_functions else
formatter_functions().get_builtins())])),
"builtin")) "builtin"))
TemplateHighlighter.Rules.append((QRegExp( TemplateHighlighter.Rules.append((QRegExp(
@ -214,7 +215,7 @@ 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, dialog_is_st_editor=False, text_is_placeholder=False, dialog_is_st_editor=False,
global_vars={}): global_vars={}, all_functions=None, builtin_functions=None):
QDialog.__init__(self, parent) QDialog.__init__(self, parent)
Ui_TemplateDialog.__init__(self) Ui_TemplateDialog.__init__(self)
self.setupUi(self) self.setupUi(self)
@ -314,8 +315,11 @@ class TemplateDialog(QDialog, Ui_TemplateDialog):
self.setWindowFlags(self.windowFlags()&(~Qt.WindowType.WindowContextHelpButtonHint)) self.setWindowFlags(self.windowFlags()&(~Qt.WindowType.WindowContextHelpButtonHint))
self.setWindowIcon(icon) self.setWindowIcon(icon)
self.all_functions = all_functions if all_functions else formatter_functions().get_functions()
self.builtins = builtin_functions if builtin_functions else formatter_functions().get_builtins()
self.last_text = '' self.last_text = ''
self.highlighter = TemplateHighlighter(self.textbox.document()) self.highlighter = TemplateHighlighter(self.textbox.document(), builtin_functions=self.builtins)
self.textbox.cursorPositionChanged.connect(self.text_cursor_changed) self.textbox.cursorPositionChanged.connect(self.text_cursor_changed)
self.textbox.textChanged.connect(self.textbox_changed) self.textbox.textChanged.connect(self.textbox_changed)
@ -342,10 +346,7 @@ class TemplateDialog(QDialog, Ui_TemplateDialog):
except: except:
self.builtin_source_dict = {} self.builtin_source_dict = {}
self.funcs = formatter_functions().get_functions() func_names = sorted(self.all_functions)
self.builtins = formatter_functions().get_builtins()
func_names = sorted(self.funcs)
self.function.clear() self.function.clear()
self.function.addItem('') self.function.addItem('')
for f in func_names: for f in func_names:
@ -430,7 +431,8 @@ class TemplateDialog(QDialog, Ui_TemplateDialog):
self.text_cursor_changed() self.text_cursor_changed()
self.template_value.setText( self.template_value.setText(
SafeFormat().safe_format(cur_text, self.mi, _('EXCEPTION: '), SafeFormat().safe_format(cur_text, self.mi, _('EXCEPTION: '),
self.mi, global_vars=self.global_vars)) self.mi, global_vars=self.global_vars,
template_functions= self.all_functions))
def text_cursor_changed(self): def text_cursor_changed(self):
cursor = self.textbox.textCursor() cursor = self.textbox.textCursor()
@ -443,7 +445,7 @@ class TemplateDialog(QDialog, Ui_TemplateDialog):
pos_in_block) pos_in_block)
def function_type_string(self, name, longform=True): def function_type_string(self, name, longform=True):
if self.funcs[name].is_python: if self.all_functions[name].is_python:
if name in self.builtins: if name in self.builtins:
return (_('Built-in template function') if longform else return (_('Built-in template function') if longform else
_('Built-in function')) _('Built-in function'))
@ -457,12 +459,12 @@ class TemplateDialog(QDialog, Ui_TemplateDialog):
self.source_code.clear() self.source_code.clear()
self.documentation.clear() self.documentation.clear()
self.func_type.clear() self.func_type.clear()
if name in self.funcs: if name in self.all_functions:
self.documentation.setPlainText(self.funcs[name].doc) self.documentation.setPlainText(self.all_functions[name].doc)
if name in self.builtins and name in self.builtin_source_dict: if name in self.builtins and name in self.builtin_source_dict:
self.source_code.setPlainText(self.builtin_source_dict[name]) self.source_code.setPlainText(self.builtin_source_dict[name])
else: else:
self.source_code.setPlainText(self.funcs[name].program_text) self.source_code.setPlainText(self.all_functions[name].program_text)
self.func_type.setText(self.function_type_string(name, longform=True)) self.func_type.setText(self.function_type_string(name, longform=True))
def accept(self): def accept(self):

View File

@ -21,349 +21,520 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QWidget" name="color_layout"> <widget class="QScrollArea" name="scroll_area">
<layout class="QGridLayout"> <property name="widgetResizable">
<item row="0" column="0"> <bool>true</bool>
<widget class="QLabel" name="colored_field_label"> </property>
<property name="text"> <widget class="QWidget" name="wid1">
<string>Set the color of the column:</string> <layout class="QVBoxLayout" name="verticalLayout">
</property> <item>
<property name="buddy"> <widget class="QWidget" name="color_layout">
<cstring>colored_field</cstring> <layout class="QGridLayout">
</property> <item row="0" column="0">
</widget> <widget class="QLabel" name="colored_field_label">
</item> <property name="text">
<item row="0" column="1"> <string>Set the color of the column:</string>
<widget class="QComboBox" name="colored_field"> </property>
</widget> <property name="buddy">
</item> <cstring>colored_field</cstring>
<item row="1" column="0"> </property>
<widget class="QLabel" name="color_chooser_label"> </widget>
<property name="text"> </item>
<string>Copy a color name to the clipboard:</string> <item row="0" column="1">
</property> <widget class="QComboBox" name="colored_field">
<property name="buddy"> </widget>
<cstring>color_name</cstring> </item>
</property> <item row="1" column="0">
</widget> <widget class="QLabel" name="color_chooser_label">
</item> <property name="text">
<item row="1" column="1"> <string>Copy a color name to the clipboard:</string>
<widget class="ColorButton" name="color_name"> </property>
</widget> <property name="buddy">
</item> <cstring>color_name</cstring>
<item row="1" column="2"> </property>
<widget class="QToolButton" name="color_copy_button"> </widget>
<property name="icon"> </item>
<iconset resource="../../../../resources/images.qrc"> <item row="1" column="1">
<normaloff>:/images/edit-copy.png</normaloff>:/images/edit-copy.png</iconset> <widget class="ColorButton" name="color_name">
</property> </widget>
<property name="toolTip"> </item>
<string>Copy the selected color name to the clipboard</string> <item row="1" column="2">
</property> <widget class="QToolButton" name="color_copy_button">
</widget> <property name="icon">
</item> <iconset resource="../../../../resources/images.qrc">
</layout> <normaloff>:/images/edit-copy.png</normaloff>:/images/edit-copy.png</iconset>
</widget> </property>
</item> <property name="toolTip">
<item> <string>Copy the selected color name to the clipboard</string>
<widget class="QWidget" name="icon_layout"> </property>
<layout class="QGridLayout"> </widget>
<item row="0" column="0" colspan="2"> </item>
<layout class="QHBoxLayout"> </layout>
<item> </widget>
<widget class="QLabel" name="icon_kind_label"> </item>
<property name="text"> <item>
<string>Kind:</string> <widget class="QWidget" name="icon_layout">
</property> <layout class="QGridLayout">
</widget> <item row="0" column="0" colspan="2">
</item> <layout class="QHBoxLayout">
<item> <item>
<widget class="QComboBox" name="icon_kind"> <widget class="QLabel" name="icon_kind_label">
</widget> <property name="text">
</item> <string>Kind:</string>
</layout> </property>
</item> </widget>
<item row="1" column="0"> </item>
<widget class="QLabel" name="icon_chooser_label"> <item>
<property name="text"> <widget class="QComboBox" name="icon_kind">
<string>Apply the icon to column:</string> </widget>
</property> </item>
<property name="buddy"> </layout>
<cstring>icon_field</cstring> </item>
</property> <item row="1" column="0">
</widget> <widget class="QLabel" name="icon_chooser_label">
</item> <property name="text">
<item row="1" column="1"> <string>Apply the icon to column:</string>
<widget class="QComboBox" name="icon_field"> </property>
</widget> <property name="buddy">
</item> <cstring>icon_field</cstring>
<item row="2" column="0"> </property>
<widget class="QLabel" name="image_chooser_label"> </widget>
<property name="text"> </item>
<string>Copy an icon file name to the clipboard:</string> <item row="1" column="1">
</property> <widget class="QComboBox" name="icon_field">
<property name="buddy"> </widget>
<cstring>color_name</cstring> </item>
</property> <item row="2" column="0">
</widget> <widget class="QLabel" name="image_chooser_label">
</item> <property name="text">
<item row="2" column="1"> <string>Copy an icon file name to the clipboard:</string>
<widget class="QWidget"> </property>
<layout class="QHBoxLayout"> <property name="buddy">
<item> <cstring>color_name</cstring>
<widget class="QComboBox" name="icon_files"> </property>
</widget> </widget>
</item> </item>
<item> <item row="2" column="1">
<widget class="QToolButton" name="icon_copy_button"> <widget class="QWidget">
<property name="icon"> <layout class="QHBoxLayout">
<iconset resource="../../../../resources/images.qrc"> <item>
<normaloff>:/images/edit-copy.png</normaloff>:/images/edit-copy.png</iconset> <widget class="QComboBox" name="icon_files">
</property> </widget>
<property name="toolTip"> </item>
<string>Copy the selected icon file name to the clipboard</string> <item>
</property> <widget class="QToolButton" name="icon_copy_button">
</widget> <property name="icon">
</item> <iconset resource="../../../../resources/images.qrc">
<item> <normaloff>:/images/edit-copy.png</normaloff>:/images/edit-copy.png</iconset>
<widget class="QPushButton" name="filename_button"> </property>
<property name="toolTip">
<string>Copy the selected icon file name to the clipboard</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="filename_button">
<property name="text">
<string>Add icon</string>
</property>
<property name="toolTip">
<string>Add an icon file to the set of choices</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="template_name_label">
<property name="text"> <property name="text">
<string>Add icon</string> <string>Template &amp;name:</string>
</property>
<property name="buddy">
<cstring>template_name</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="template_name">
<property name="editable">
<bool>true</bool>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Add an icon file to the set of choices</string> <string>The name of the callable template</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel">
<property name="text">
<string>T&amp;emplate:</string>
</property>
<property name="buddy">
<cstring>textbox</cstring>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPlainTextEdit" name="textbox">
<property name="toolTip">
<string>The template program text</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="new_doc_label">
<property name="text">
<string>D&amp;ocumentation:</string>
</property>
<property name="buddy">
<cstring>new_doc</cstring>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QTextEdit" name="new_doc">
<property name="toolTip">
<string>Documentation for the function being defined or edited</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel">
<property name="text">
<string>Template value:</string>
</property>
<property name="buddy">
<cstring>template_value</cstring>
</property>
<property name="toolTip">
<string>The value of the template using the current book in the library view</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="template_value">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="user_label_1">
<property name="text">
<string>User Label</string>
</property>
<property name="buddy">
<cstring>template_value</cstring>
</property>
<property name="visible">
<bool>false</bool>
</property>
</widget>
</item>
<item row="11" column="1">
<layout class="BoxLayout" name="user_layout_1" dir="TopToBottom">
</layout>
</item>
<item row="12" column="0">
<widget class="QLabel" name="user_label_2">
<property name="text">
<string>User Label</string>
</property>
<property name="buddy">
<cstring>template_value</cstring>
</property>
<property name="visible">
<bool>false</bool>
</property>
</widget>
</item>
<item row="12" column="1">
<layout class="BoxLayout" name="user_layout_2" dir="TopToBottom">
</layout>
</item>
<item row="13" column="0">
<widget class="QLabel" name="user_label_3">
<property name="text">
<string>User Label</string>
</property>
<property name="buddy">
<cstring>template_value</cstring>
</property>
<property name="visible">
<bool>false</bool>
</property>
</widget>
</item>
<item row="13" column="1">
<layout class="BoxLayout" name="user_layout_3" dir="TopToBottom">
</layout>
</item>
<item row="14" column="0">
<widget class="QLabel" name="user_label_4">
<property name="text">
<string>User Label</string>
</property>
<property name="buddy">
<cstring>template_value</cstring>
</property>
<property name="visible">
<bool>false</bool>
</property>
</widget>
</item>
<item row="14" column="1">
<layout class="BoxLayout" name="user_layout_4" dir="TopToBottom">
</layout>
</item>
<item row="15" column="0">
<widget class="QLabel" name="user_label_5">
<property name="text">
<string>User Label</string>
</property>
<property name="buddy">
<cstring>template_value</cstring>
</property>
<property name="visible">
<bool>false</bool>
</property>
</widget>
</item>
<item row="15" column="1">
<layout class="BoxLayout" name="user_layout_5" dir="TopToBottom">
</layout>
</item>
<item row="16" column="0">
<widget class="QLabel" name="user_label_6">
<property name="text">
<string>User Label</string>
</property>
<property name="buddy">
<cstring>template_value</cstring>
</property>
<property name="visible">
<bool>false</bool>
</property>
</widget>
</item>
<item row="16" column="1">
<layout class="BoxLayout" name="user_layout_6" dir="TopToBottom">
</layout>
</item>
<item row="17" column="0">
<widget class="QLabel" name="user_label_7">
<property name="text">
<string>User Label</string>
</property>
<property name="buddy">
<cstring>template_value</cstring>
</property>
<property name="visible">
<bool>false</bool>
</property>
</widget>
</item>
<item row="17" column="1">
<layout class="BoxLayout" name="user_layout_7" dir="TopToBottom">
</layout>
</item>
<item row="18" column="0">
<widget class="QLabel" name="user_label_8">
<property name="text">
<string>User Label</string>
</property>
<property name="buddy">
<cstring>template_value</cstring>
</property>
<property name="visible">
<bool>false</bool>
</property>
</widget>
</item>
<item row="18" column="1">
<layout class="BoxLayout" name="user_layout_8" dir="TopToBottom">
</layout>
</item>
<item row="19" column="0">
<widget class="QLabel" name="user_label_9">
<property name="text">
<string>User Label</string>
</property>
<property name="buddy">
<cstring>template_value</cstring>
</property>
<property name="visible">
<bool>false</bool>
</property>
</widget>
</item>
<item row="19" column="1">
<layout class="BoxLayout" name="user_layout_9" dir="TopToBottom">
</layout>
</item>
<item row="20" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Font size:</string>
</property>
</widget>
</item>
<item row="20" column="1" colspan="3">
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QSpinBox" name="font_size_box"/>
</item>
<item row="1" column="1">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="21" column="0" colspan="5">
<widget class="QFrame">
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
</widget>
</item>
<item row="22" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="text">
<string>Template Function Reference</string>
</property>
<property name="buddy">
<cstring>function</cstring>
</property>
</widget>
</item>
<item row="23" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Function &amp;name:</string>
</property>
<property name="buddy">
<cstring>function</cstring>
</property>
</widget>
</item>
<item row="23" column="1" colspan="3">
<widget class="QComboBox" name="function"/>
</item>
<item row="24" column="0">
<widget class="QLabel" name="label_22">
<property name="text">
<string>&amp;Function type:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="buddy">
<cstring>func_type</cstring>
</property>
</widget>
</item>
<item row="24" column="1" colspan="3">
<widget class="QLineEdit" name="func_type">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="25" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&amp;Documentation:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="buddy">
<cstring>documentation</cstring>
</property>
</widget>
</item>
<item row="26" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>&amp;Code:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="buddy">
<cstring>source_code</cstring>
</property>
</widget>
</item>
<item row="25" column="1" colspan="3">
<widget class="QPlainTextEdit" name="documentation">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>75</height>
</size>
</property>
</widget>
</item>
<item row="26" column="1" colspan="3">
<widget class="QPlainTextEdit" name="source_code">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>75</height>
</size>
</property>
</widget>
</item>
<item row="27" column="1">
<widget class="QLabel" name="template_tutorial">
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="28" column="1">
<widget class="QLabel" name="template_func_reference">
<property name="openExternalLinks">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="template_name_label">
<property name="text">
<string>Template &amp;name:</string>
</property>
<property name="buddy">
<cstring>template_name</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="template_name">
<property name="editable">
<bool>true</bool>
</property>
<property name="toolTip">
<string>The name of the callable template</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel">
<property name="text">
<string>T&amp;emplate:</string>
</property>
<property name="buddy">
<cstring>textbox</cstring>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPlainTextEdit" name="textbox">
<property name="toolTip">
<string>The template program text</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="new_doc_label">
<property name="text">
<string>D&amp;ocumentation:</string>
</property>
<property name="buddy">
<cstring>new_doc</cstring>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QTextEdit" name="new_doc">
<property name="toolTip">
<string>Documentation for the function being defined or edited</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel">
<property name="text">
<string>Template value:</string>
</property>
<property name="buddy">
<cstring>template_value</cstring>
</property>
<property name="toolTip">
<string>The value of the template using the current book in the library view</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="template_value">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Font size:</string>
</property>
</widget>
</item>
<item row="6" column="1" colspan="3">
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QSpinBox" name="font_size_box"/>
</item>
<item row="1" column="1">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </widget>
<item row="7" column="0" colspan="5"> </widget>
<widget class="QFrame">
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="text">
<string>Template Function Reference</string>
</property>
<property name="buddy">
<cstring>function</cstring>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Function &amp;name:</string>
</property>
<property name="buddy">
<cstring>function</cstring>
</property>
</widget>
</item>
<item row="9" column="1" colspan="3">
<widget class="QComboBox" name="function"/>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_22">
<property name="text">
<string>&amp;Function type:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="buddy">
<cstring>func_type</cstring>
</property>
</widget>
</item>
<item row="10" column="1" colspan="3">
<widget class="QLineEdit" name="func_type">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&amp;Documentation:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="buddy">
<cstring>documentation</cstring>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>&amp;Code:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="buddy">
<cstring>source_code</cstring>
</property>
</widget>
</item>
<item row="11" column="1" colspan="3">
<widget class="QPlainTextEdit" name="documentation">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>75</height>
</size>
</property>
</widget>
</item>
<item row="12" column="1" colspan="3">
<widget class="QPlainTextEdit" name="source_code"/>
</item>
<item row="13" column="1">
<widget class="QLabel" name="template_tutorial">
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="14" column="1">
<widget class="QLabel" name="template_func_reference">
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item> </item>
</layout> </layout>
</widget> </widget>
@ -373,6 +544,11 @@
<extends>QPushButton</extends> <extends>QPushButton</extends>
<header>calibre/gui2/widgets2.h</header> <header>calibre/gui2/widgets2.h</header>
</customwidget> </customwidget>
<customwidget>
<class>BoxLayout</class>
<extends>QBoxLayout</extends>
<header>calibre/gui2/dialogs/template_dialog_box_layout.h</header>
</customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>
<connections> <connections>

View File

@ -0,0 +1,13 @@
'''
Created on 20 Jan 2021
@author: Charles Haley
'''
from PyQt5.Qt import (QBoxLayout)
class BoxLayout(QBoxLayout):
def __init__(self):
QBoxLayout.__init__(self, QBoxLayout.Direction.TopToBottom)

View File

@ -25,11 +25,17 @@
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2" stretch="0"> <item row="0" column="0" colspan="2" stretch="0">
<widget class="QTextBrowser" name="st_textBrowser"/> <widget class="QTextBrowser" name="st_textBrowser">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>75</height>
</size>
</property>
</widget>
</item> </item>
<item row="3" column="1" stretch="1"> <item row="3" column="1" stretch="1">
<widget class="EmbeddedTemplateDialog" name="template_editor"> <widget class="EmbeddedTemplateDialog" name="template_editor"/>
</widget>
</item> </item>
<item row="3" column="0"> <item row="3" column="0">
<layout class="QVBoxLayout" name="st_button_layout"> <layout class="QVBoxLayout" name="st_button_layout">
@ -76,19 +82,6 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="5" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>400</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="tab">