From 7320f2ddc9a8dc44a40bb17461bd8e1d1aeba030 Mon Sep 17 00:00:00 2001 From: STEPHANVS Date: Wed, 16 Feb 2022 03:50:23 +0100 Subject: [PATCH] added option to turn off song key warning --- openlp/core/common/settings.py | 1 + openlp/plugins/songs/forms/editsongform.py | 9 +++++---- openlp/plugins/songs/forms/editverseform.py | 16 ++++++++++------ openlp/plugins/songs/lib/songstab.py | 11 +++++++++++ 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/openlp/core/common/settings.py b/openlp/core/common/settings.py index c92cefe60..c5984408a 100644 --- a/openlp/core/common/settings.py +++ b/openlp/core/common/settings.py @@ -342,6 +342,7 @@ class Settings(QtCore.QSettings): 'songs/songselect password': '', 'songs/songselect searches': '', 'songs/enable chords': True, + 'songs/warn about missing song key': True, 'songs/chord notation': 'english', # Can be english, german or neo-latin 'songs/disable chords import': False, 'songs/auto play audio': False, diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index e3d389c8a..eb8ebacb7 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -258,13 +258,14 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties): if not self._validate_tags(tags): misplaced_tags.append('{field1} {field2}'.format(field1=VerseType.translated_name(field[0]), field2=field[1:])) - if Registry().get('settings').value('songs/enable chords') and len(chords) > 0 and \ - not chords[0].startswith("="): + if Registry().get('settings').value('songs/enable chords') and \ + Registry().get('settings').value('songs/warn about missing song key') and len(chords) > 0 and \ + not chords[0].startswith("="): QtWidgets.QMessageBox.warning(self, translate('SongsPlugin.EditVerseForm', 'Song key warning'), translate('SongsPlugin.EditVerseForm', 'No song key is present or song key ' 'is not the first chord.\nFor optimal chord experience, please, ' - 'include a song key\nbefore any chord. Ex.: [=G]'), - QtWidgets.QMessageBox.checkBox) + 'include a song key\nbefore any chord. Ex.: [=G]' + 'You can disable this warning message in songs settings.')) if misplaced_tags: critical_error_message_box( message=translate('SongsPlugin.EditSongForm', diff --git a/openlp/plugins/songs/forms/editverseform.py b/openlp/plugins/songs/forms/editverseform.py index 4163caa0f..9f53bc4c4 100644 --- a/openlp/plugins/songs/forms/editverseform.py +++ b/openlp/plugins/songs/forms/editverseform.py @@ -124,13 +124,15 @@ class EditVerseForm(QtWidgets.QDialog, Ui_EditVerseDialog): try: lyrics_stripped = re.sub(r'\[---\]', "\n", re.sub(r'---\[.*?\]---', "\n", re.sub(r'\[--}{--\]', "\n", self.verse_text_edit.toPlainText()))) - chords = re.search(r'\[(.*?)\]', lyrics_stripped) - if chords and len(chords) > 0 and not chords[1].startswith("="): + chords = re.findall(r'\[(.*?)\]', lyrics_stripped) + if Registry().get('settings').value('songs/warn about missing song key') and chords and len(chords) > 0 and\ + not chords[0].startswith("="): QtWidgets.QMessageBox.warning(self, translate('SongsPlugin.EditVerseForm', 'Song key warning'), translate('SongsPlugin.EditVerseForm', 'No song key is present or song key is not the first ' 'chord.\nFor optimal chord experience, please, include a ' - 'song key\nbefore any chord. Ex.: [=G]')) + 'song key\nbefore any chord. Ex.: [=G]\n' + 'You can disable this warning message in songs settings.')) transposed_lyrics = transpose_lyrics(self.verse_text_edit.toPlainText(), 1) self.verse_text_edit.setPlainText(transposed_lyrics) except KeyError as ke: @@ -150,13 +152,15 @@ class EditVerseForm(QtWidgets.QDialog, Ui_EditVerseDialog): try: lyrics_stripped = re.sub(r'\[---\]', "\n", re.sub(r'---\[.*?\]---', "\n", re.sub(r'\[--}{--\]', "\n", self.verse_text_edit.toPlainText()))) - chords = re.search(r'\[(.*?)\]', lyrics_stripped) - if chords and len(chords) > 0 and not chords[1].startswith("="): + chords = re.findall(r'\[(.*?)\]', lyrics_stripped) + if Registry().get('settings').value('songs/warn about missing song key') and chords and len(chords) > 0 and\ + not chords[0].startswith("="): QtWidgets.QMessageBox.warning(self, translate('SongsPlugin.EditVerseForm', 'Song key warning'), translate('SongsPlugin.EditVerseForm', 'No song key is present or song key is not the first ' 'chord.\nFor optimal chord experience, please, include a ' - 'song key\nbefore any chord. Ex.: [=G]')) + 'song key\nbefore any chord. Ex.: [=G]\n' + 'You can disable this warning message in songs settings.')) transposed_lyrics = transpose_lyrics(self.verse_text_edit.toPlainText(), -1) self.verse_text_edit.setPlainText(transposed_lyrics) except KeyError as ke: diff --git a/openlp/plugins/songs/lib/songstab.py b/openlp/plugins/songs/lib/songstab.py index f70190d4e..86727279c 100644 --- a/openlp/plugins/songs/lib/songstab.py +++ b/openlp/plugins/songs/lib/songstab.py @@ -67,7 +67,10 @@ class SongsTab(SettingsTab): self.chords_layout.addWidget(self.chords_info_label) self.disable_chords_import_check_box = QtWidgets.QCheckBox(self.mode_group_box) self.disable_chords_import_check_box.setObjectName('disable_chords_import_check_box') + self.song_key_warning_check_box = QtWidgets.QCheckBox(self.mode_group_box) + self.song_key_warning_check_box.setObjectName('song_key_warning_checkbox') self.chords_layout.addWidget(self.disable_chords_import_check_box) + self.chords_layout.addWidget(self.song_key_warning_check_box) # Chords notation group box self.chord_notation_label = QtWidgets.QLabel(self.chords_group_box) @@ -128,6 +131,7 @@ class SongsTab(SettingsTab): self.songbook_slide_check_box.stateChanged.connect(self.on_songbook_slide_check_box_changed) self.auto_play_check_box.stateChanged.connect(self.on_auto_play_check_box_changed) self.disable_chords_import_check_box.stateChanged.connect(self.on_disable_chords_import_check_box_changed) + self.song_key_warning_check_box.stateChanged.connect(self.on_song_key_warning_check_box_changed) self.english_notation_radio_button.clicked.connect(self.on_english_notation_button_clicked) self.german_notation_radio_button.clicked.connect(self.on_german_notation_button_clicked) self.neolatin_notation_radio_button.clicked.connect(self.on_neolatin_notation_button_clicked) @@ -156,6 +160,7 @@ class SongsTab(SettingsTab): self.german_notation_radio_button.setText(translate('SongsPlugin.SongsTab', 'German') + ' (C-D-E-F-G-A-H)') self.neolatin_notation_radio_button.setText( translate('SongsPlugin.SongsTab', 'Neo-Latin') + ' (Do-Re-Mi-Fa-Sol-La-Si)') + self.song_key_warning_check_box.setText(translate('SongsPlugin.SongsTab', 'Warn about missing song key')) self.footer_group_box.setTitle(translate('SongsPlugin.SongsTab', 'Footer')) # Keep this in sync with the list in mediaitem.py const = '"{}"' @@ -224,6 +229,9 @@ class SongsTab(SettingsTab): def on_disable_chords_import_check_box_changed(self, check_state): self.disable_chords_import = (check_state == QtCore.Qt.Checked) + def on_song_key_warning_check_box_changed(self, check_state): + self.song_key_warning = (check_state == QtCore.Qt.Checked) + def on_english_notation_button_clicked(self): self.chord_notation = 'english' @@ -245,11 +253,13 @@ class SongsTab(SettingsTab): self.enable_chords = self.settings.value('songs/enable chords') self.chord_notation = self.settings.value('songs/chord notation') self.disable_chords_import = self.settings.value('songs/disable chords import') + self.song_key_warning = self.settings.value('songs/warn about missing song key') self.tool_bar_active_check_box.setChecked(self.tool_bar) self.update_on_edit_check_box.setChecked(self.update_edit) self.add_from_service_check_box.setChecked(self.update_load) self.chords_group_box.setChecked(self.enable_chords) self.disable_chords_import_check_box.setChecked(self.disable_chords_import) + self.song_key_warning_check_box.setChecked(self.song_key_warning) if self.chord_notation == 'german': self.german_notation_radio_button.setChecked(True) elif self.chord_notation == 'neo-latin': @@ -267,6 +277,7 @@ class SongsTab(SettingsTab): self.settings.setValue('songs/auto play audio', self.auto_play) self.settings.setValue('songs/enable chords', self.chords_group_box.isChecked()) self.settings.setValue('songs/disable chords import', self.disable_chords_import) + self.settings.setValue('songs/warn about missing song key', self.song_key_warning) self.settings.setValue('songs/chord notation', self.chord_notation) self.settings.setValue('songs/songselect username', self.ccli_username.text()) # Only save password if it's blank or the user acknowleges the warning