Added support for printing chords.

This commit is contained in:
Tomas Groth 2017-02-02 22:55:05 +01:00
parent 111826dd69
commit 045e12e6c4
3 changed files with 25 additions and 9 deletions

View File

@ -430,7 +430,7 @@ def expand_chords(text, line_split):
lyric = ' '
chords.append(chord)
lyrics.append(lyric)
new_chord_line = '<tr>'
new_chord_line = '<tr class="chordrow">'
new_lyric_line = '</tr><tr>'
for i in range(len(lyrics)):
spacer = compare_chord_lyric(chords[i], lyrics[i])
@ -461,9 +461,8 @@ def expand_chords(text, line_split):
end_formatting_tags = ''
if active_formatting_tags:
end_formatting_tags = '{/' + '}{/'.join(active_formatting_tags) + '}'
new_line += '<tr><td class="chord">&nbsp;</td></tr><tr><td class="lyrics">{starttags}{lyrics}&nbsp;{endtags}</td></tr>'.format(starttags=start_formatting_tags, lyrics=word, endtags=end_formatting_tags)
new_line += '<tr class="chordrow"><td class="chord">&nbsp;</td></tr><tr><td class="lyrics">{starttags}{lyrics}&nbsp;{endtags}</td></tr>'.format(starttags=start_formatting_tags, lyrics=word, endtags=end_formatting_tags)
new_line += '</table>'
#print(new_line)
else:
new_line += line
new_line += '</td></tr></table>'

View File

@ -95,7 +95,7 @@ class Ui_PrintServiceDialog(object):
self.main_layout.addWidget(self.preview_widget)
self.options_widget = QtWidgets.QWidget(print_service_dialog)
self.options_widget.hide()
self.options_widget.resize(400, 300)
self.options_widget.resize(400, 350)
self.options_widget.setAutoFillBackground(True)
self.options_layout = QtWidgets.QVBoxLayout(self.options_widget)
self.options_layout.setContentsMargins(8, 8, 8, 8)
@ -121,6 +121,8 @@ class Ui_PrintServiceDialog(object):
self.group_layout.addWidget(self.notes_check_box)
self.meta_data_check_box = QtWidgets.QCheckBox()
self.group_layout.addWidget(self.meta_data_check_box)
self.show_chords_check_box = QtWidgets.QCheckBox()
self.group_layout.addWidget(self.show_chords_check_box)
self.group_layout.addStretch(1)
self.options_group_box.setLayout(self.group_layout)
self.options_layout.addWidget(self.options_group_box)
@ -144,6 +146,7 @@ class Ui_PrintServiceDialog(object):
self.page_break_after_text.setText(translate('OpenLP.PrintServiceForm', 'Add page break before each text item'))
self.notes_check_box.setText(translate('OpenLP.PrintServiceForm', 'Include service item notes'))
self.meta_data_check_box.setText(translate('OpenLP.PrintServiceForm', 'Include play length of media items'))
self.show_chords_check_box.setText(translate('OpenLP.PrintServiceForm', 'Show chords'))
self.title_line_edit.setText(translate('OpenLP.PrintServiceForm', 'Service Sheet'))
# Do not change the order.
self.zoom_combo_box.addItems([

View File

@ -101,6 +101,19 @@ https://doc.qt.io/qt-5/richtext-html-subset.html#css-properties
.newPage {
page-break-before: always;
}
table.line {}
table.segment {
float: left;
}
td.chord {
font-size: 80%;
}
td.lyrics {
}
"""
@ -172,11 +185,12 @@ class PrintServiceForm(QtWidgets.QDialog, Ui_PrintServiceDialog, RegistryPropert
self._add_element('h1', html.escape(self.title_line_edit.text()), html_data.body, classId='serviceTitle')
for index, item in enumerate(self.service_manager.service_items):
self._add_preview_item(html_data.body, item['service_item'], index)
# Remove chord span and ws span elements since printing them are not yet support
for chord_span in html_data.find_class('chord'):
chord_span.drop_tree()
for ws_span in html_data.find_class('ws'):
ws_span.drop_tree()
if not self.show_chords_check_box.isChecked():
# Remove chord row and spacing span elements when not printing chords
for chord_row in html_data.find_class('chordrow'):
chord_row.drop_tree()
for spacing_span in html_data.find_class('spacing'):
spacing_span.drop_tree()
# Add the custom service notes:
if self.footer_text_edit.toPlainText():
div = self._add_element('div', parent=html_data.body, classId='customNotes')