From 045e12e6c446746c193b86349fc27e3788eb5618 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Thu, 2 Feb 2017 22:55:05 +0100 Subject: [PATCH] Added support for printing chords. --- openlp/core/lib/__init__.py | 5 ++--- openlp/core/ui/printservicedialog.py | 5 ++++- openlp/core/ui/printserviceform.py | 24 +++++++++++++++++++----- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 85b59091a..6895b2399 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -430,7 +430,7 @@ def expand_chords(text, line_split): lyric = ' ' chords.append(chord) lyrics.append(lyric) - new_chord_line = '' + new_chord_line = '' new_lyric_line = '' 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 += ' {starttags}{lyrics} {endtags}'.format(starttags=start_formatting_tags, lyrics=word, endtags=end_formatting_tags) + new_line += ' {starttags}{lyrics} {endtags}'.format(starttags=start_formatting_tags, lyrics=word, endtags=end_formatting_tags) new_line += '' - #print(new_line) else: new_line += line new_line += '' diff --git a/openlp/core/ui/printservicedialog.py b/openlp/core/ui/printservicedialog.py index fba7771ba..925b88599 100644 --- a/openlp/core/ui/printservicedialog.py +++ b/openlp/core/ui/printservicedialog.py @@ -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([ diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index f602d53d9..08360d6b0 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -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')