diff --git a/openlp/plugins/songs/forms/__init__.py b/openlp/plugins/songs/forms/__init__.py index 1073b6866..824465348 100644 --- a/openlp/plugins/songs/forms/__init__.py +++ b/openlp/plugins/songs/forms/__init__.py @@ -23,6 +23,52 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +from openlp.core.lib import translate + +class VerseType(object): + Verse = 0 + Chorus = 1 + Bridge = 2 + PreChorus = 3 + Intro = 4 + Ending = 5 + Other = 6 + + @staticmethod + def to_string(verse_type): + if verse_type == VerseType.Verse: + return translate('SongTags', 'Verse') + elif verse_type == VerseType.Chorus: + return translate('SongTags', 'Chorus') + elif verse_type == VerseType.Bridge: + return translate('SongTags', 'Bridge') + elif verse_type == VerseType.PreChorus: + return u'Pre-Chorus' + elif verse_type == VerseType.Intro: + return u'Intro' + elif verse_type == VerseType.Ending: + return u'Ending' + elif verse_type == VerseType.Other: + return u'Other' + + @staticmethod + def from_string(verse_type): + verse_type = verse_type.lower() + if verse_type == translate('SongTags', 'verse'): + return VerseType.Verse + elif verse_type == translate('SongTags', 'chorus'): + return VerseType.Chorus + elif verse_type == translate('SongTags', 'bridge'): + return VerseType.Bridge + elif verse_type == u'pre-chorus': + return VerseType.PreChorus + elif verse_type == u'intro': + return VerseType.Intro + elif verse_type == u'ending': + return VerseType.Ending + elif verse_type == u'other': + return VerseType.Other + from authorsform import AuthorsForm from topicsform import TopicsForm from songbookform import SongBookForm diff --git a/openlp/plugins/songs/forms/editversedialog.py b/openlp/plugins/songs/forms/editversedialog.py index 164eb9177..42f1f1cac 100644 --- a/openlp/plugins/songs/forms/editversedialog.py +++ b/openlp/plugins/songs/forms/editversedialog.py @@ -24,8 +24,9 @@ ############################################################################### from PyQt4 import QtCore, QtGui + from openlp.core.lib import translate -from openlp.plugins.songs.lib import TagNames +from openlp.plugins.songs.forms import VerseType class Ui_EditVerseDialog(object): def setupUi(self, EditVerseDialog): @@ -93,9 +94,9 @@ class Ui_EditVerseDialog(object): def retranslateUi(self, EditVerseDialog): EditVerseDialog.setWindowTitle(translate('EditVerseForm', 'Edit Verse')) self.VerseTypeLabel.setText(translate('EditVerseForm', 'Verse Type:')) - self.VerseTypeComboBox.setItemText(0, TagNames.verse) - self.VerseTypeComboBox.setItemText(1, TagNames.chorus) - self.VerseTypeComboBox.setItemText(2, translate('EditVerseForm', 'Bridge')) + self.VerseTypeComboBox.setItemText(0, VerseType.to_string(VerseType.Verse)) + self.VerseTypeComboBox.setItemText(1, VerseType.to_string(VerseType.Chorus)) + self.VerseTypeComboBox.setItemText(2, VerseType.to_string(VerseType.Bridge)) self.VerseTypeComboBox.setItemText(3, translate('EditVerseForm', 'Pre-Chorus')) self.VerseTypeComboBox.setItemText(4, translate('EditVerseForm', 'Intro')) self.VerseTypeComboBox.setItemText(5, translate('EditVerseForm', 'Ending')) diff --git a/openlp/plugins/songs/forms/editverseform.py b/openlp/plugins/songs/forms/editverseform.py index c4adf3d3b..4e57c2497 100644 --- a/openlp/plugins/songs/forms/editverseform.py +++ b/openlp/plugins/songs/forms/editverseform.py @@ -28,56 +28,12 @@ import logging from PyQt4 import QtCore, QtGui +from openlp.plugins.songs.forms import VerseType + from editversedialog import Ui_EditVerseDialog -from openlp.plugins.songs.lib import TagNames log = logging.getLogger(__name__) -class VerseType(object): - Verse = 0 - Chorus = 1 - Bridge = 2 - PreChorus = 3 - Intro = 4 - Ending = 5 - Other = 6 - - @staticmethod - def to_string(verse_type): - if verse_type == VerseType.Verse: - return TagNames.verse - elif verse_type == VerseType.Chorus: - return TagNames.chorus - elif verse_type == VerseType.Bridge: - return u'Bridge' - elif verse_type == VerseType.PreChorus: - return u'Pre-Chorus' - elif verse_type == VerseType.Intro: - return u'Intro' - elif verse_type == VerseType.Ending: - return u'Ending' - elif verse_type == VerseType.Other: - return u'Other' - - @staticmethod - def from_string(verse_type): - verse_type = verse_type.lower() - if verse_type == TagNames.lower_verse: - return VerseType.Verse - elif verse_type == TagNames.lower_chorus: - return VerseType.Chorus - elif verse_type == u'bridge': - return VerseType.Bridge - elif verse_type == u'pre-chorus': - return VerseType.PreChorus - elif verse_type == u'intro': - return VerseType.Intro - elif verse_type == u'ending': - return VerseType.Ending - elif verse_type == u'other': - return VerseType.Other - - class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): """ This is the form that is used to edit the verses of the song. @@ -111,11 +67,13 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): self.VerseTextEdit.insertPlainText(u'\n') verse_type = self.VerseTypeComboBox.currentIndex() if verse_type == VerseType.Verse: - self.insertVerse('Verse', self.VerseNumberBox.value()) + self.insertVerse(VerseType.to_string(VerseType.Verse), + self.VerseNumberBox.value()) elif verse_type == VerseType.Chorus: - self.insertVerse('Chorus', self.VerseNumberBox.value()) + self.insertVerse(VerseType.to_string(VerseType.Chorus), + self.VerseNumberBox.value()) elif verse_type == VerseType.Bridge: - self.insertVerse('Bridge') + self.insertVerse(VerseType.to_string(VerseType.Bridge)) elif verse_type == VerseType.PreChorus: self.insertVerse('Pre-Chorus') elif verse_type == VerseType.Intro: @@ -172,6 +130,6 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): def getVerseAll(self): text = self.VerseTextEdit.toPlainText() if not text.startsWith(u'---['): - text = u'---[Verse:1]---\n%s' % text + text = u'---[%s:1]---\n%s' % (VerseType.to_string(VerseType.Verse), text) return text diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index 0f3705a55..bbb9260c6 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -23,22 +23,10 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from openlp.core.lib import translate - -class TagNames(object): - verse = translate('TagNames','Verse') - chorus = translate('TagNames','Chorus') - lower_verse = translate('TagNames','verse') - lower_chorus = translate('TagNames','chorus') - - from manager import SongManager from songstab import SongsTab from mediaitem import SongMediaItem from sofimport import SofImport from oooimport import OooImport from songimport import SongImport -from openlp.core.lib import translate - -