forked from openlp/openlp
fixed formattigtagsform/dialog
This commit is contained in:
parent
1660fbf2f8
commit
86efc5629c
@ -94,18 +94,18 @@ class Ui_FormattingTagDialog(object):
|
|||||||
self.tag_label.setAlignment(QtCore.Qt.AlignCenter)
|
self.tag_label.setAlignment(QtCore.Qt.AlignCenter)
|
||||||
self.tag_label.setObjectName(u'tag_label')
|
self.tag_label.setObjectName(u'tag_label')
|
||||||
self.data_grid_layout.addWidget(self.tag_label, 2, 0, 1, 1)
|
self.data_grid_layout.addWidget(self.tag_label, 2, 0, 1, 1)
|
||||||
self.tagLineEdit = QtGui.QLineEdit(self.edit_group_box)
|
self.tag_line_edit = QtGui.QLineEdit(self.edit_group_box)
|
||||||
self.tagLineEdit.setMaximumSize(QtCore.QSize(50, 16777215))
|
self.tag_line_edit.setMaximumSize(QtCore.QSize(50, 16777215))
|
||||||
self.tagLineEdit.setMaxLength(5)
|
self.tag_line_edit.setMaxLength(5)
|
||||||
self.tagLineEdit.setObjectName(u'tagLineEdit')
|
self.tag_line_edit.setObjectName(u'tag_line_edit')
|
||||||
self.data_grid_layout.addWidget(self.tagLineEdit, 2, 1, 1, 1)
|
self.data_grid_layout.addWidget(self.tag_line_edit, 2, 1, 1, 1)
|
||||||
self.start_tag_label = QtGui.QLabel(self.edit_group_box)
|
self.start_tag_label = QtGui.QLabel(self.edit_group_box)
|
||||||
self.start_tag_label.setAlignment(QtCore.Qt.AlignCenter)
|
self.start_tag_label.setAlignment(QtCore.Qt.AlignCenter)
|
||||||
self.start_tag_label.setObjectName(u'start_tag_label')
|
self.start_tag_label.setObjectName(u'start_tag_label')
|
||||||
self.data_grid_layout.addWidget(self.start_tag_label, 3, 0, 1, 1)
|
self.data_grid_layout.addWidget(self.start_tag_label, 3, 0, 1, 1)
|
||||||
self.startTagLineEdit = QtGui.QLineEdit(self.edit_group_box)
|
self.start_tag_line_edit = QtGui.QLineEdit(self.edit_group_box)
|
||||||
self.startTagLineEdit.setObjectName(u'startTagLineEdit')
|
self.start_tag_line_edit.setObjectName(u'start_tag_line_edit')
|
||||||
self.data_grid_layout.addWidget(self.startTagLineEdit, 3, 1, 1, 1)
|
self.data_grid_layout.addWidget(self.start_tag_line_edit, 3, 1, 1, 1)
|
||||||
self.end_tag_label = QtGui.QLabel(self.edit_group_box)
|
self.end_tag_label = QtGui.QLabel(self.edit_group_box)
|
||||||
self.end_tag_label.setAlignment(QtCore.Qt.AlignCenter)
|
self.end_tag_label.setAlignment(QtCore.Qt.AlignCenter)
|
||||||
self.end_tag_label.setObjectName(u'end_tag_label')
|
self.end_tag_label.setObjectName(u'end_tag_label')
|
||||||
|
@ -48,15 +48,15 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog):
|
|||||||
"""
|
"""
|
||||||
QtGui.QDialog.__init__(self, parent)
|
QtGui.QDialog.__init__(self, parent)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
QtCore.QObject.connect(self.tag_table_widget, QtCore.SIGNAL(u'itemSelectionChanged()'), self.onRowSelected)
|
self.tag_table_widget.itemSelectionChanged.connect(self.on_row_selected)
|
||||||
QtCore.QObject.connect(self.new_push_button, QtCore.SIGNAL(u'clicked()'), self.onNewClicked)
|
self.new_push_button.clicked.connect(self.on_new_clicked)
|
||||||
QtCore.QObject.connect(self.save_push_button, QtCore.SIGNAL(u'clicked()'), self.onSavedClicked)
|
self.save_push_button.clicked.connect(self.on_saved_clicked)
|
||||||
QtCore.QObject.connect(self.delete_push_button, QtCore.SIGNAL(u'clicked()'), self.onDeleteClicked)
|
self.delete_push_button.clicked.connect(self.on_delete_clicked)
|
||||||
QtCore.QObject.connect(self.button_box, QtCore.SIGNAL(u'rejected()'), self.close)
|
self.button_boxrejected.connect(self.close)
|
||||||
QtCore.QObject.connect(self.description_line_edit, QtCore.SIGNAL(u'textEdited(QString)'), self.onTextEdited)
|
self.description_line_edit.textEdited.connect(self.on_text_edited)
|
||||||
QtCore.QObject.connect(self.tagLineEdit, QtCore.SIGNAL(u'textEdited(QString)'), self.onTextEdited)
|
self.tag_line_edit.textEdited.connect(self.on_text_edited)
|
||||||
QtCore.QObject.connect(self.startTagLineEdit, QtCore.SIGNAL(u'textEdited(QString)'), self.onTextEdited)
|
self.start_tag_line_edit.textEdited.connect(self.on_text_edited)
|
||||||
QtCore.QObject.connect(self.end_tag_line_edit, QtCore.SIGNAL(u'textEdited(QString)'), self.onTextEdited)
|
self.end_tag_line_edit.textEdited.connect(self.on_text_edited)
|
||||||
# Forces reloading of tags from openlp configuration.
|
# Forces reloading of tags from openlp configuration.
|
||||||
FormattingTags.load_tags()
|
FormattingTags.load_tags()
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog):
|
|||||||
self.selected = -1
|
self.selected = -1
|
||||||
return QtGui.QDialog.exec_(self)
|
return QtGui.QDialog.exec_(self)
|
||||||
|
|
||||||
def onRowSelected(self):
|
def on_row_selected(self):
|
||||||
"""
|
"""
|
||||||
Table Row selected so display items and set field state.
|
Table Row selected so display items and set field state.
|
||||||
"""
|
"""
|
||||||
@ -77,30 +77,30 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog):
|
|||||||
self.selected = self.tag_table_widget.currentRow()
|
self.selected = self.tag_table_widget.currentRow()
|
||||||
html = FormattingTags.get_html_tags()[self.selected]
|
html = FormattingTags.get_html_tags()[self.selected]
|
||||||
self.description_line_edit.setText(html[u'desc'])
|
self.description_line_edit.setText(html[u'desc'])
|
||||||
self.tagLineEdit.setText(self._strip(html[u'start tag']))
|
self.tag_line_edit.setText(self._strip(html[u'start tag']))
|
||||||
self.startTagLineEdit.setText(html[u'start html'])
|
self.start_tag_line_edit.setText(html[u'start html'])
|
||||||
self.end_tag_line_edit.setText(html[u'end html'])
|
self.end_tag_line_edit.setText(html[u'end html'])
|
||||||
if html[u'protected']:
|
if html[u'protected']:
|
||||||
self.description_line_edit.setEnabled(False)
|
self.description_line_edit.setEnabled(False)
|
||||||
self.tagLineEdit.setEnabled(False)
|
self.tag_line_edit.setEnabled(False)
|
||||||
self.startTagLineEdit.setEnabled(False)
|
self.start_tag_line_edit.setEnabled(False)
|
||||||
self.end_tag_line_edit.setEnabled(False)
|
self.end_tag_line_edit.setEnabled(False)
|
||||||
self.delete_push_button.setEnabled(False)
|
self.delete_push_button.setEnabled(False)
|
||||||
else:
|
else:
|
||||||
self.description_line_edit.setEnabled(True)
|
self.description_line_edit.setEnabled(True)
|
||||||
self.tagLineEdit.setEnabled(True)
|
self.tag_line_edit.setEnabled(True)
|
||||||
self.startTagLineEdit.setEnabled(True)
|
self.start_tag_line_edit.setEnabled(True)
|
||||||
self.end_tag_line_edit.setEnabled(True)
|
self.end_tag_line_edit.setEnabled(True)
|
||||||
self.delete_push_button.setEnabled(True)
|
self.delete_push_button.setEnabled(True)
|
||||||
|
|
||||||
def onTextEdited(self, text):
|
def on_text_edited(self, text):
|
||||||
"""
|
"""
|
||||||
Enable the ``save_push_button`` when any of the selected tag's properties
|
Enable the ``save_push_button`` when any of the selected tag's properties
|
||||||
has been changed.
|
has been changed.
|
||||||
"""
|
"""
|
||||||
self.save_push_button.setEnabled(True)
|
self.save_push_button.setEnabled(True)
|
||||||
|
|
||||||
def onNewClicked(self):
|
def on_new_clicked(self):
|
||||||
"""
|
"""
|
||||||
Add a new tag to list only if it is not a duplicate.
|
Add a new tag to list only if it is not a duplicate.
|
||||||
"""
|
"""
|
||||||
@ -125,10 +125,10 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog):
|
|||||||
self._reloadTable()
|
self._reloadTable()
|
||||||
# Highlight new row
|
# Highlight new row
|
||||||
self.tag_table_widget.selectRow(self.tag_table_widget.rowCount() - 1)
|
self.tag_table_widget.selectRow(self.tag_table_widget.rowCount() - 1)
|
||||||
self.onRowSelected()
|
self.on_row_selected()
|
||||||
self.tag_table_widget.scrollToBottom()
|
self.tag_table_widget.scrollToBottom()
|
||||||
|
|
||||||
def onDeleteClicked(self):
|
def on_delete_clicked(self):
|
||||||
"""
|
"""
|
||||||
Delete selected custom tag.
|
Delete selected custom tag.
|
||||||
"""
|
"""
|
||||||
@ -141,14 +141,14 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog):
|
|||||||
FormattingTags.save_html_tags()
|
FormattingTags.save_html_tags()
|
||||||
self._reloadTable()
|
self._reloadTable()
|
||||||
|
|
||||||
def onSavedClicked(self):
|
def on_saved_clicked(self):
|
||||||
"""
|
"""
|
||||||
Update Custom Tag details if not duplicate and save the data.
|
Update Custom Tag details if not duplicate and save the data.
|
||||||
"""
|
"""
|
||||||
html_expands = FormattingTags.get_html_tags()
|
html_expands = FormattingTags.get_html_tags()
|
||||||
if self.selected != -1:
|
if self.selected != -1:
|
||||||
html = html_expands[self.selected]
|
html = html_expands[self.selected]
|
||||||
tag = self.tagLineEdit.text()
|
tag = self.tag_line_edit.text()
|
||||||
for linenumber, html1 in enumerate(html_expands):
|
for linenumber, html1 in enumerate(html_expands):
|
||||||
if self._strip(html1[u'start tag']) == tag and linenumber != self.selected:
|
if self._strip(html1[u'start tag']) == tag and linenumber != self.selected:
|
||||||
critical_error_message_box(
|
critical_error_message_box(
|
||||||
@ -156,7 +156,7 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog):
|
|||||||
translate('OpenLP.FormattingTagForm', 'Tag %s already defined.') % tag)
|
translate('OpenLP.FormattingTagForm', 'Tag %s already defined.') % tag)
|
||||||
return
|
return
|
||||||
html[u'desc'] = self.description_line_edit.text()
|
html[u'desc'] = self.description_line_edit.text()
|
||||||
html[u'start html'] = self.startTagLineEdit.text()
|
html[u'start html'] = self.start_tag_line_edit.text()
|
||||||
html[u'end html'] = self.end_tag_line_edit.text()
|
html[u'end html'] = self.end_tag_line_edit.text()
|
||||||
html[u'start tag'] = u'{%s}' % tag
|
html[u'start tag'] = u'{%s}' % tag
|
||||||
html[u'end tag'] = u'{/%s}' % tag
|
html[u'end tag'] = u'{/%s}' % tag
|
||||||
@ -186,12 +186,12 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog):
|
|||||||
html[u'temporary'] = False
|
html[u'temporary'] = False
|
||||||
self.tag_table_widget.resizeRowsToContents()
|
self.tag_table_widget.resizeRowsToContents()
|
||||||
self.description_line_edit.setText(u'')
|
self.description_line_edit.setText(u'')
|
||||||
self.tagLineEdit.setText(u'')
|
self.tag_line_edit.setText(u'')
|
||||||
self.startTagLineEdit.setText(u'')
|
self.start_tag_line_edit.setText(u'')
|
||||||
self.end_tag_line_edit.setText(u'')
|
self.end_tag_line_edit.setText(u'')
|
||||||
self.description_line_edit.setEnabled(False)
|
self.description_line_edit.setEnabled(False)
|
||||||
self.tagLineEdit.setEnabled(False)
|
self.tag_line_edit.setEnabled(False)
|
||||||
self.startTagLineEdit.setEnabled(False)
|
self.start_tag_line_edit.setEnabled(False)
|
||||||
self.end_tag_line_edit.setEnabled(False)
|
self.end_tag_line_edit.setEnabled(False)
|
||||||
|
|
||||||
def _strip(self, tag):
|
def _strip(self, tag):
|
||||||
|
Loading…
Reference in New Issue
Block a user