added option to turn off song key warning

This commit is contained in:
STEPHANVS 2022-02-16 03:50:23 +01:00
parent bf9aba52da
commit 7320f2ddc9
No known key found for this signature in database
GPG Key ID: 4EFE47E471FD62A9
4 changed files with 27 additions and 10 deletions

View File

@ -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,

View File

@ -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',

View File

@ -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:

View File

@ -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 = '<code>"{}"</code>'
@ -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