More chord fixes.

This commit is contained in:
Tomas Groth 2017-02-22 22:01:42 +01:00
parent 37e4a05be7
commit 9c299af567
3 changed files with 24 additions and 5 deletions

View File

@ -26,6 +26,8 @@ import logging
from PyQt5 import QtCore, QtGui, QtWidgets
from openlp.plugins.songs.lib import VerseType, transpose_lyrics
from openlp.core.lib.ui import critical_error_message_box
from openlp.core.common import translate
from .editversedialog import Ui_EditVerseDialog
log = logging.getLogger(__name__)
@ -101,8 +103,16 @@ class EditVerseForm(QtWidgets.QDialog, Ui_EditVerseDialog):
"""
The transpose up button clicked
"""
transposed_lyrics = transpose_lyrics(self.verse_text_edit.toPlainText(), 1)
self.verse_text_edit.setPlainText(transposed_lyrics)
try:
transposed_lyrics = transpose_lyrics(self.verse_text_edit.toPlainText(), 1)
self.verse_text_edit.setPlainText(transposed_lyrics)
except ValueError as ve:
# Transposing failed
critical_error_message_box(title=translate('SongsPlugin.EditVerseForm', 'Transposing failed'),
message=translate('SongsPlugin.EditVerseForm',
'Transposing failed because of invalid chord:\n{err_msg}'
.format(err_msg=ve)))
return
self.verse_text_edit.setFocus()
self.verse_text_edit.moveCursor(QtGui.QTextCursor.End)
@ -110,7 +120,16 @@ class EditVerseForm(QtWidgets.QDialog, Ui_EditVerseDialog):
"""
The transpose down button clicked
"""
transposed_lyrics = transpose_lyrics(self.verse_text_edit.toPlainText(), -1)
try:
transposed_lyrics = transpose_lyrics(self.verse_text_edit.toPlainText(), -1)
self.verse_text_edit.setPlainText(transposed_lyrics)
except ValueError as ve:
# Transposing failed
critical_error_message_box(title=translate('SongsPlugin.EditVerseForm', 'Transposing failed'),
message=translate('SongsPlugin.EditVerseForm',
'Transposing failed because of invalid chord:\n{err_msg}'
.format(err_msg=ve)))
return
self.verse_text_edit.setPlainText(transposed_lyrics)
self.verse_text_edit.setFocus()
self.verse_text_edit.moveCursor(QtGui.QTextCursor.End)

View File

@ -380,7 +380,7 @@ def clean_song(manager, song):
if isinstance(song.lyrics, bytes):
song.lyrics = str(song.lyrics, encoding='utf8')
verses = SongXML().get_verses(song.lyrics)
song.search_lyrics = ' '.join([clean_string(clean_tags(verse[1])) for verse in verses])
song.search_lyrics = ' '.join([clean_string(clean_tags(verse[1], True)) for verse in verses])
# The song does not have any author, add one.
if not song.authors_songs:
name = SongStrings.AuthorUnknown

View File

@ -14,7 +14,7 @@ install:
# Install dependencies from pypi
- "%PYTHON%\\python.exe -m pip install sqlalchemy alembic chardet beautifulsoup4 Mako nose mock pyodbc==4.0.8 psycopg2 pypiwin32 pyenchant"
# Install mysql dependency
- "%PYTHON%\\python.exe -m pip install http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.1.5.zip#md5=ce4a24cb1746c1c8f6189a97087f21c1"
- "%PYTHON%\\python.exe -m pip install http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.4.zip#md5=3df394d89300db95163f17c843ef49df"
# Download and install lxml and pyicu (originally from http://www.lfd.uci.edu/~gohlke/pythonlibs/)
- "%PYTHON%\\python.exe -m pip install https://get.openlp.org/win-sdk/lxml-3.6.4-cp34-cp34m-win32.whl"
- "%PYTHON%\\python.exe -m pip install https://get.openlp.org/win-sdk/PyICU-1.9.5-cp34-cp34m-win32.whl"