forked from openlp/openlp
Reworked the verse dialog.
This commit is contained in:
parent
646d8a658c
commit
513b7a10b7
@ -41,7 +41,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
"""
|
"""
|
||||||
log.info(u'%s EditSongForm loaded', __name__)
|
log.info(u'%s EditSongForm loaded', __name__)
|
||||||
|
|
||||||
def __init__(self, songmanager, parent=None):
|
def __init__(self, parent, songmanager):
|
||||||
"""
|
"""
|
||||||
Constructor
|
Constructor
|
||||||
"""
|
"""
|
||||||
@ -106,7 +106,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
QtCore.SIGNAL(u'clicked(QAbstractButton*)'), self.onPreview)
|
QtCore.SIGNAL(u'clicked(QAbstractButton*)'), self.onPreview)
|
||||||
# Create other objects and forms
|
# Create other objects and forms
|
||||||
self.songmanager = songmanager
|
self.songmanager = songmanager
|
||||||
self.verse_form = EditVerseForm()
|
self.verse_form = EditVerseForm(self)
|
||||||
self.initialise()
|
self.initialise()
|
||||||
self.AuthorsListView.setSortingEnabled(False)
|
self.AuthorsListView.setSortingEnabled(False)
|
||||||
self.AuthorsListView.setAlternatingRowColors(True)
|
self.AuthorsListView.setAlternatingRowColors(True)
|
||||||
@ -317,7 +317,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
self.VerseDeleteButton.setEnabled(True)
|
self.VerseDeleteButton.setEnabled(True)
|
||||||
|
|
||||||
def onVerseAddButtonClicked(self):
|
def onVerseAddButtonClicked(self):
|
||||||
self.verse_form.setVerse(u'', self.VerseListWidget.count() + 1, True)
|
self.verse_form.setVerse(u'', True)
|
||||||
if self.verse_form.exec_():
|
if self.verse_form.exec_():
|
||||||
afterText, verse, subVerse = self.verse_form.getVerse()
|
afterText, verse, subVerse = self.verse_form.getVerse()
|
||||||
data = u'%s:%s' %(verse, subVerse)
|
data = u'%s:%s' %(verse, subVerse)
|
||||||
@ -331,8 +331,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
if item:
|
if item:
|
||||||
tempText = item.text()
|
tempText = item.text()
|
||||||
verseId = unicode((item.data(QtCore.Qt.UserRole)).toString())
|
verseId = unicode((item.data(QtCore.Qt.UserRole)).toString())
|
||||||
self.verse_form.setVerse(tempText, \
|
self.verse_form.setVerse(tempText, True, verseId)
|
||||||
self.VerseListWidget.count(), True, verseId)
|
|
||||||
if self.verse_form.exec_():
|
if self.verse_form.exec_():
|
||||||
afterText, verse, subVerse = self.verse_form.getVerse()
|
afterText, verse, subVerse = self.verse_form.getVerse()
|
||||||
data = u'%s:%s' %(verse, subVerse)
|
data = u'%s:%s' %(verse, subVerse)
|
||||||
|
@ -28,102 +28,75 @@ from PyQt4 import QtCore, QtGui
|
|||||||
class Ui_EditVerseDialog(object):
|
class Ui_EditVerseDialog(object):
|
||||||
def setupUi(self, EditVerseDialog):
|
def setupUi(self, EditVerseDialog):
|
||||||
EditVerseDialog.setObjectName(u'EditVerseDialog')
|
EditVerseDialog.setObjectName(u'EditVerseDialog')
|
||||||
EditVerseDialog.resize(500, 521)
|
EditVerseDialog.resize(474, 442)
|
||||||
EditVerseDialog.setModal(True)
|
EditVerseDialog.setModal(True)
|
||||||
self.layoutWidget = QtGui.QWidget(EditVerseDialog)
|
self.EditVerseLayout = QtGui.QVBoxLayout(EditVerseDialog)
|
||||||
self.layoutWidget.setGeometry(QtCore.QRect(11, 1, 471, 491))
|
self.EditVerseLayout.setSpacing(8)
|
||||||
self.layoutWidget.setObjectName(u'layoutWidget')
|
self.EditVerseLayout.setMargin(8)
|
||||||
self.verticalLayout_3 = QtGui.QVBoxLayout(self.layoutWidget)
|
self.EditVerseLayout.setObjectName(u'EditVerseLayout')
|
||||||
self.verticalLayout_3.setObjectName(u'verticalLayout_3')
|
self.VerseTextEdit = QtGui.QPlainTextEdit(EditVerseDialog)
|
||||||
self.horizontalLayout = QtGui.QHBoxLayout()
|
|
||||||
self.horizontalLayout.setObjectName(u'horizontalLayout')
|
|
||||||
self.verticalLayout = QtGui.QVBoxLayout()
|
|
||||||
self.verticalLayout.setObjectName(u'verticalLayout')
|
|
||||||
self.VerseTypeLabel = QtGui.QLabel(self.layoutWidget)
|
|
||||||
self.VerseTypeLabel.setTextFormat(QtCore.Qt.PlainText)
|
|
||||||
self.VerseTypeLabel.setAlignment(QtCore.Qt.AlignCenter)
|
|
||||||
self.VerseTypeLabel.setObjectName(u'VerseTypeLabel')
|
|
||||||
self.verticalLayout.addWidget(self.VerseTypeLabel)
|
|
||||||
self.VerseListComboBox = QtGui.QComboBox(self.layoutWidget)
|
|
||||||
self.VerseListComboBox.setObjectName(u'VerseListComboBox')
|
|
||||||
self.VerseListComboBox.addItem(u'')
|
|
||||||
self.VerseListComboBox.addItem(u'')
|
|
||||||
self.VerseListComboBox.addItem(u'')
|
|
||||||
self.VerseListComboBox.addItem(u'')
|
|
||||||
self.VerseListComboBox.addItem(u'')
|
|
||||||
self.VerseListComboBox.addItem(u'')
|
|
||||||
self.VerseListComboBox.addItem(u'')
|
|
||||||
self.verticalLayout.addWidget(self.VerseListComboBox)
|
|
||||||
self.horizontalLayout.addLayout(self.verticalLayout)
|
|
||||||
self.verticalLayout_2 = QtGui.QVBoxLayout()
|
|
||||||
self.verticalLayout_2.setObjectName(u'verticalLayout_2')
|
|
||||||
self.VerseNumberLabel = QtGui.QLabel(self.layoutWidget)
|
|
||||||
self.VerseNumberLabel.setAlignment(QtCore.Qt.AlignCenter)
|
|
||||||
self.VerseNumberLabel.setObjectName(u'VerseNumberLabel')
|
|
||||||
self.verticalLayout_2.addWidget(self.VerseNumberLabel)
|
|
||||||
self.SubVerseListComboBox = QtGui.QComboBox(self.layoutWidget)
|
|
||||||
self.SubVerseListComboBox.setObjectName(u'SubVerseListComboBox')
|
|
||||||
self.verticalLayout_2.addWidget(self.SubVerseListComboBox)
|
|
||||||
self.horizontalLayout.addLayout(self.verticalLayout_2)
|
|
||||||
self.verticalLayout_3.addLayout(self.horizontalLayout)
|
|
||||||
self.VerseTextEdit = QtGui.QTextEdit(self.layoutWidget)
|
|
||||||
self.VerseTextEdit.setAcceptRichText(False)
|
|
||||||
self.VerseTextEdit.setObjectName(u'VerseTextEdit')
|
self.VerseTextEdit.setObjectName(u'VerseTextEdit')
|
||||||
self.verticalLayout_3.addWidget(self.VerseTextEdit)
|
self.EditVerseLayout.addWidget(self.VerseTextEdit)
|
||||||
self.horizontalLayout_2 = QtGui.QHBoxLayout()
|
self.VerseTypeLayout = QtGui.QHBoxLayout()
|
||||||
self.horizontalLayout_2.setObjectName(u'horizontalLayout_2')
|
self.VerseTypeLayout.setSpacing(8)
|
||||||
self.addBridge = QtGui.QPushButton(self.layoutWidget)
|
self.VerseTypeLayout.setObjectName(u'VerseTypeLayout')
|
||||||
self.addBridge.setObjectName(u'addBridge')
|
self.VerseTypeLabel = QtGui.QLabel(EditVerseDialog)
|
||||||
self.horizontalLayout_2.addWidget(self.addBridge)
|
self.VerseTypeLabel.setObjectName(u'VerseTypeLabel')
|
||||||
self.addVerse = QtGui.QPushButton(self.layoutWidget)
|
self.VerseTypeLayout.addWidget(self.VerseTypeLabel)
|
||||||
self.addVerse.setObjectName(u'addVerse')
|
self.VerseTypeComboBox = QtGui.QComboBox(EditVerseDialog)
|
||||||
self.horizontalLayout_2.addWidget(self.addVerse)
|
self.VerseTypeComboBox.setObjectName(u'VerseTypeComboBox')
|
||||||
self.addChorus = QtGui.QPushButton(self.layoutWidget)
|
self.VerseTypeComboBox.addItem(u'')
|
||||||
self.addChorus.setObjectName(u'addChorus')
|
self.VerseTypeComboBox.addItem(u'')
|
||||||
self.horizontalLayout_2.addWidget(self.addChorus)
|
self.VerseTypeComboBox.addItem(u'')
|
||||||
self.verticalLayout_3.addLayout(self.horizontalLayout_2)
|
self.VerseTypeComboBox.addItem(u'')
|
||||||
self.horizontalLayout_3 = QtGui.QHBoxLayout()
|
self.VerseTypeComboBox.addItem(u'')
|
||||||
self.horizontalLayout_3.setObjectName(u'horizontalLayout_3')
|
self.VerseTypeComboBox.addItem(u'')
|
||||||
self.addPreChorus = QtGui.QPushButton(self.layoutWidget)
|
self.VerseTypeComboBox.addItem(u'')
|
||||||
self.addPreChorus.setObjectName(u'addPreChorus')
|
self.VerseTypeLayout.addWidget(self.VerseTypeComboBox)
|
||||||
self.horizontalLayout_3.addWidget(self.addPreChorus)
|
self.VerseNumberBox = QtGui.QSpinBox(EditVerseDialog)
|
||||||
self.addIntro = QtGui.QPushButton(self.layoutWidget)
|
self.VerseNumberBox.setMinimum(1)
|
||||||
self.addIntro.setObjectName(u'addIntro')
|
self.VerseNumberBox.setObjectName(u'VerseNumberBox')
|
||||||
self.horizontalLayout_3.addWidget(self.addIntro)
|
self.VerseTypeLayout.addWidget(self.VerseNumberBox)
|
||||||
self.addOther = QtGui.QPushButton(self.layoutWidget)
|
self.InsertButton = QtGui.QPushButton(EditVerseDialog)
|
||||||
self.addOther.setObjectName(u'addOther')
|
self.AddIcon = QtGui.QIcon()
|
||||||
self.horizontalLayout_3.addWidget(self.addOther)
|
self.AddIcon.addPixmap(QtGui.QPixmap(u':/general/general_add.png'),
|
||||||
self.addEnding = QtGui.QPushButton(self.layoutWidget)
|
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
self.addEnding.setObjectName(u'addEnding')
|
self.InsertButton.setIcon(self.AddIcon)
|
||||||
self.horizontalLayout_3.addWidget(self.addEnding)
|
self.InsertButton.setObjectName(u'InsertButton')
|
||||||
self.verticalLayout_3.addLayout(self.horizontalLayout_3)
|
self.VerseTypeLayout.addWidget(self.InsertButton)
|
||||||
self.ButtonBox = QtGui.QDialogButtonBox(self.layoutWidget)
|
self.VerseTypeSpacer = QtGui.QSpacerItem(40, 20,
|
||||||
self.ButtonBox.setOrientation(QtCore.Qt.Horizontal)
|
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||||
self.ButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Save)
|
self.VerseTypeLayout.addItem(self.VerseTypeSpacer)
|
||||||
self.ButtonBox.setObjectName(u'ButtonBox')
|
self.EditVerseLayout.addLayout(self.VerseTypeLayout)
|
||||||
self.verticalLayout_3.addWidget(self.ButtonBox)
|
self.EditButtonBox = QtGui.QDialogButtonBox(EditVerseDialog)
|
||||||
|
self.EditButtonBox.setOrientation(QtCore.Qt.Horizontal)
|
||||||
|
self.EditButtonBox.setStandardButtons(
|
||||||
|
QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Save)
|
||||||
|
self.EditButtonBox.setObjectName(u'EditButtonBox')
|
||||||
|
self.EditVerseLayout.addWidget(self.EditButtonBox)
|
||||||
|
|
||||||
self.retranslateUi(EditVerseDialog)
|
self.retranslateUi(EditVerseDialog)
|
||||||
QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL(u'accepted()'), EditVerseDialog.accept)
|
QtCore.QObject.connect(
|
||||||
QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL(u'rejected()'), EditVerseDialog.reject)
|
self.EditButtonBox,
|
||||||
|
QtCore.SIGNAL(u'accepted()'),
|
||||||
|
EditVerseDialog.accept
|
||||||
|
)
|
||||||
|
QtCore.QObject.connect(
|
||||||
|
self.EditButtonBox,
|
||||||
|
QtCore.SIGNAL(u'rejected()'),
|
||||||
|
EditVerseDialog.reject
|
||||||
|
)
|
||||||
QtCore.QMetaObject.connectSlotsByName(EditVerseDialog)
|
QtCore.QMetaObject.connectSlotsByName(EditVerseDialog)
|
||||||
|
|
||||||
def retranslateUi(self, EditVerseDialog):
|
def retranslateUi(self, EditVerseDialog):
|
||||||
EditVerseDialog.setWindowTitle(self.trUtf8('Edit Verse'))
|
EditVerseDialog.setWindowTitle(self.trUtf8('Edit Verse'))
|
||||||
self.VerseTypeLabel.setText(self.trUtf8('Verse Type'))
|
self.VerseTypeLabel.setText(self.trUtf8('Verse Type:'))
|
||||||
self.VerseListComboBox.setItemText(0, self.trUtf8('Intro'))
|
self.VerseTypeComboBox.setItemText(0, self.trUtf8('Verse'))
|
||||||
self.VerseListComboBox.setItemText(1, self.trUtf8('Verse'))
|
self.VerseTypeComboBox.setItemText(1, self.trUtf8('Chorus'))
|
||||||
self.VerseListComboBox.setItemText(2, self.trUtf8('Pre-Chorus'))
|
self.VerseTypeComboBox.setItemText(2, self.trUtf8('Bridge'))
|
||||||
self.VerseListComboBox.setItemText(3, self.trUtf8('Chorus'))
|
self.VerseTypeComboBox.setItemText(3, self.trUtf8('Pre-Chorus'))
|
||||||
self.VerseListComboBox.setItemText(4, self.trUtf8('Bridge'))
|
self.VerseTypeComboBox.setItemText(4, self.trUtf8('Intro'))
|
||||||
self.VerseListComboBox.setItemText(5, self.trUtf8('Ending'))
|
self.VerseTypeComboBox.setItemText(5, self.trUtf8('Ending'))
|
||||||
self.VerseListComboBox.setItemText(6, self.trUtf8('Other'))
|
self.VerseTypeComboBox.setItemText(6, self.trUtf8('Other'))
|
||||||
self.VerseNumberLabel.setText(self.trUtf8('Number'))
|
self.InsertButton.setText(self.trUtf8('Insert'))
|
||||||
self.addBridge.setText(self.trUtf8('Bridge'))
|
|
||||||
self.addVerse.setText(self.trUtf8('Verse'))
|
|
||||||
self.addChorus.setText(self.trUtf8('Chorus'))
|
|
||||||
self.addPreChorus.setText(self.trUtf8('Pre-Chorus'))
|
|
||||||
self.addIntro.setText(self.trUtf8('Intro'))
|
|
||||||
self.addOther.setText(self.trUtf8('Other'))
|
|
||||||
self.addEnding.setText(self.trUtf8('Ending'))
|
|
||||||
|
|
||||||
|
@ -23,9 +23,60 @@
|
|||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
import re
|
||||||
|
import logging
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from editversedialog import Ui_EditVerseDialog
|
from editversedialog import Ui_EditVerseDialog
|
||||||
|
|
||||||
|
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 u'Verse'
|
||||||
|
elif verse_type == VerseType.Chorus:
|
||||||
|
return u'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 == u'verse':
|
||||||
|
return VerseType.Verse
|
||||||
|
elif verse_type == u'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):
|
class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
|
||||||
"""
|
"""
|
||||||
This is the form that is used to edit the verses of the song.
|
This is the form that is used to edit the verses of the song.
|
||||||
@ -36,127 +87,91 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
|
|||||||
"""
|
"""
|
||||||
QtGui.QDialog.__init__(self, parent)
|
QtGui.QDialog.__init__(self, parent)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
QtCore.QObject.connect(self.addVerse,
|
QtCore.QObject.connect(
|
||||||
QtCore.SIGNAL(u'clicked()'), self.onAddVerse)
|
self.InsertButton,
|
||||||
QtCore.QObject.connect(self.addChorus,
|
QtCore.SIGNAL(u'clicked()'),
|
||||||
QtCore.SIGNAL(u'clicked()'), self.onAddChorus)
|
self.onInsertButtonClicked
|
||||||
QtCore.QObject.connect(self.addBridge,
|
)
|
||||||
QtCore.SIGNAL(u'clicked()'), self.onAddBridge)
|
QtCore.QObject.connect(
|
||||||
QtCore.QObject.connect(self.addIntro,
|
self.VerseTextEdit,
|
||||||
QtCore.SIGNAL(u'clicked()'), self.onAddIntro)
|
QtCore.SIGNAL(u'cursorPositionChanged()'),
|
||||||
QtCore.QObject.connect(self.addOther,
|
self.onCursorPositionChanged
|
||||||
QtCore.SIGNAL(u'clicked()'), self.onAddOther)
|
)
|
||||||
QtCore.QObject.connect(self.addPreChorus,
|
# QtCore.QObject.connect(self.VerseListComboBox,
|
||||||
QtCore.SIGNAL(u'clicked()'), self.onAddPreChorus)
|
# QtCore.SIGNAL(u'activated(int)'), self.onVerseComboChanged)
|
||||||
QtCore.QObject.connect(self.addEnding,
|
self.verse_regex = re.compile(r'---\[([-\w]+):([\d]+)\]---')
|
||||||
QtCore.SIGNAL(u'clicked()'), self.onAddEnding)
|
|
||||||
QtCore.QObject.connect(self.VerseListComboBox,
|
|
||||||
QtCore.SIGNAL(u'activated(int)'), self.onVerseComboChanged)
|
|
||||||
|
|
||||||
def startNewLine(self):
|
def insertVerse(self, title, num=1):
|
||||||
if self.VerseTextEdit.textCursor().columnNumber() != 0:
|
if self.VerseTextEdit.textCursor().columnNumber() != 0:
|
||||||
self.VerseTextEdit.insertPlainText(u'\n')
|
self.VerseTextEdit.insertPlainText(u'\n')
|
||||||
|
self.VerseTextEdit.insertPlainText(u'---[%s:%s]---\n' % (title, num))
|
||||||
def onAddIntro(self):
|
|
||||||
self.startNewLine()
|
|
||||||
self.VerseTextEdit.insertPlainText(u'---[%s:1]---\n'
|
|
||||||
% self.trUtf8('Intro'))
|
|
||||||
self.VerseTextEdit.setFocus()
|
self.VerseTextEdit.setFocus()
|
||||||
|
|
||||||
def onAddEnding(self):
|
def onInsertButtonClicked(self):
|
||||||
self.startNewLine()
|
if self.VerseTextEdit.textCursor().columnNumber() != 0:
|
||||||
self.VerseTextEdit.insertPlainText(u'---[%s:1]---\n'
|
self.VerseTextEdit.insertPlainText(u'\n')
|
||||||
% self.trUtf8('Ending'))
|
verse_type = self.VerseTypeComboBox.currentIndex()
|
||||||
self.VerseTextEdit.setFocus()
|
if verse_type == VerseType.Verse:
|
||||||
|
self.insertVerse('Verse', self.VerseNumberBox.value())
|
||||||
|
elif verse_type == VerseType.Chorus:
|
||||||
|
self.insertVerse('Chorus', self.VerseNumberBox.value())
|
||||||
|
elif verse_type == VerseType.Bridge:
|
||||||
|
self.insertVerse('Bridge')
|
||||||
|
elif verse_type == VerseType.PreChorus:
|
||||||
|
self.insertVerse('Pre-Chorus')
|
||||||
|
elif verse_type == VerseType.Intro:
|
||||||
|
self.insertVerse('Intro')
|
||||||
|
elif verse_type == VerseType.Ending:
|
||||||
|
self.insertVerse('Ending')
|
||||||
|
elif verse_type == VerseType.Other:
|
||||||
|
self.insertVerse('Other')
|
||||||
|
|
||||||
def onAddOther(self):
|
def onCursorPositionChanged(self):
|
||||||
self.startNewLine()
|
position = self.VerseTextEdit.textCursor().position()
|
||||||
self.VerseTextEdit.insertPlainText(u'---[%s:1]---\n'
|
text = unicode(self.VerseTextEdit.toPlainText())
|
||||||
% self.trUtf8('Other'))
|
if not text:
|
||||||
self.VerseTextEdit.setFocus()
|
return
|
||||||
|
if text.rfind(u'[', 0, position) > text.rfind(u']', 0, position) and \
|
||||||
|
text.find(u']', position) < text.find(u'[', position):
|
||||||
|
return
|
||||||
|
position = text.rfind(u'---[', 0, position)
|
||||||
|
if position == -1:
|
||||||
|
return
|
||||||
|
text = text[position:]
|
||||||
|
position = text.find(u']---')
|
||||||
|
if position == -1:
|
||||||
|
return
|
||||||
|
text = text[:position + 4]
|
||||||
|
match = self.verse_regex.match(text)
|
||||||
|
if match:
|
||||||
|
verse_type = match.group(1)
|
||||||
|
verse_number = int(match.group(2))
|
||||||
|
self.VerseTypeComboBox.setCurrentIndex(VerseType.from_string(verse_type))
|
||||||
|
self.VerseNumberBox.setValue(verse_number)
|
||||||
|
|
||||||
def onAddPreChorus(self):
|
def setVerse(self, text, single=False, tag=u'Verse:1'):
|
||||||
self.startNewLine()
|
|
||||||
self.VerseTextEdit.insertPlainText(u'---[%s:1]---\n'
|
|
||||||
% self.trUtf8('Pre-Chorus'))
|
|
||||||
self.VerseTextEdit.setFocus()
|
|
||||||
|
|
||||||
def onAddBridge(self):
|
|
||||||
self.startNewLine()
|
|
||||||
self.VerseTextEdit.insertPlainText(u'---[%s:1]---\n'
|
|
||||||
% self.trUtf8('Bridge'))
|
|
||||||
self.VerseTextEdit.setFocus()
|
|
||||||
|
|
||||||
def onAddChorus(self):
|
|
||||||
self.startNewLine()
|
|
||||||
self.VerseTextEdit.insertPlainText(u'---[%s:1]---\n'
|
|
||||||
% self.trUtf8('Chorus'))
|
|
||||||
self.VerseTextEdit.setFocus()
|
|
||||||
|
|
||||||
def onAddVerse(self):
|
|
||||||
self.startNewLine()
|
|
||||||
count = self.VerseTextEdit.toPlainText().\
|
|
||||||
count(u'---[%s' % self.trUtf8('Verse'))
|
|
||||||
self.VerseTextEdit.insertPlainText(u'---[%s:%s]---\n'
|
|
||||||
% (self.trUtf8('Verse'), count + 1))
|
|
||||||
self.VerseTextEdit.setFocus()
|
|
||||||
|
|
||||||
def setVerse(self, text, verseCount=0, single=False, tag=u'Verse:1'):
|
|
||||||
posVerse = 0
|
|
||||||
posSub = 0
|
|
||||||
if len(text) == 0 and not single:
|
|
||||||
text = u'---[%s:1]---\n' % self.trUtf8('Verse')
|
|
||||||
if single:
|
if single:
|
||||||
id = tag.split(u':')
|
verse_type, verse_number = tag.split(u':')
|
||||||
posVerse = self.VerseListComboBox.findText(id[0], QtCore.Qt.MatchExactly)
|
self.VerseTypeComboBox.setCurrentIndex(VerseType.from_string(verse_type))
|
||||||
posSub = self.SubVerseListComboBox.findText(id[1], QtCore.Qt.MatchExactly)
|
self.VerseNumberBox.setValue(int(verse_number))
|
||||||
if posVerse == -1:
|
self.InsertButton.setVisible(False)
|
||||||
posVerse = 0
|
|
||||||
if posSub == -1:
|
|
||||||
posSub = 0
|
|
||||||
self.VerseListComboBox.setEnabled(True)
|
|
||||||
self.SubVerseListComboBox.setEnabled(True)
|
|
||||||
self.SubVerseListComboBox.clear()
|
|
||||||
for i in range(1, verseCount + 1):
|
|
||||||
self.SubVerseListComboBox.addItem(u'%s'% i)
|
|
||||||
self.addBridge.setEnabled(False)
|
|
||||||
self.addChorus.setEnabled(False)
|
|
||||||
self.addVerse.setEnabled(False)
|
|
||||||
self.addIntro.setEnabled(False)
|
|
||||||
self.addPreChorus.setEnabled(False)
|
|
||||||
self.addOther.setEnabled(False)
|
|
||||||
self.addEnding.setEnabled(False)
|
|
||||||
else:
|
else:
|
||||||
self.VerseListComboBox.setEnabled(False)
|
if not text:
|
||||||
self.SubVerseListComboBox.setEnabled(False)
|
text = u'---[Verse:1]---\n'
|
||||||
self.addBridge.setEnabled(True)
|
self.VerseTypeComboBox.setCurrentIndex(0)
|
||||||
self.addChorus.setEnabled(True)
|
self.VerseNumberBox.setValue(1)
|
||||||
self.addVerse.setEnabled(True)
|
self.InsertButton.setVisible(True)
|
||||||
self.addIntro.setEnabled(True)
|
|
||||||
self.addPreChorus.setEnabled(True)
|
|
||||||
self.addOther.setEnabled(True)
|
|
||||||
self.addEnding.setEnabled(True)
|
|
||||||
self.VerseListComboBox.setCurrentIndex(posVerse)
|
|
||||||
self.SubVerseListComboBox.setCurrentIndex(posSub)
|
|
||||||
self.VerseTextEdit.setPlainText(text)
|
self.VerseTextEdit.setPlainText(text)
|
||||||
self.VerseTextEdit.setFocus(QtCore.Qt.OtherFocusReason)
|
self.VerseTextEdit.setFocus(QtCore.Qt.OtherFocusReason)
|
||||||
self.onVerseComboChanged(0)
|
|
||||||
self.VerseTextEdit.moveCursor(QtGui.QTextCursor.Down)
|
|
||||||
|
|
||||||
def getVerse(self):
|
def getVerse(self):
|
||||||
return self.VerseTextEdit.toPlainText(), \
|
return self.VerseTextEdit.toPlainText(), \
|
||||||
unicode(self.VerseListComboBox.currentText()), \
|
VerseType.to_string(self.VerseTypeComboBox.currentIndex()), \
|
||||||
unicode(self.SubVerseListComboBox.currentText())
|
unicode(self.VerseNumberBox.value())
|
||||||
|
|
||||||
def getVerseAll(self):
|
def getVerseAll(self):
|
||||||
text = self.VerseTextEdit.toPlainText()
|
text = self.VerseTextEdit.toPlainText()
|
||||||
if not text.startsWith(u'---['):
|
if not text.startsWith(u'---['):
|
||||||
text = u'---[%s:1]---\n%s' % (self.trUtf8('Verse'), text)
|
text = u'---[Verse:1]---\n%s' % text
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def onVerseComboChanged(self, id):
|
|
||||||
if unicode(self.VerseListComboBox.currentText()) == self.trUtf8('Verse'):
|
|
||||||
self.SubVerseListComboBox.setEnabled(True)
|
|
||||||
else:
|
|
||||||
self.SubVerseListComboBox.setEnabled(False)
|
|
||||||
self.SubVerseListComboBox.setCurrentIndex(0)
|
|
||||||
|
@ -52,7 +52,7 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
self.ListViewWithDnD_class = SongListView
|
self.ListViewWithDnD_class = SongListView
|
||||||
self.servicePath = None
|
self.servicePath = None
|
||||||
MediaManagerItem.__init__(self, parent, icon, title)
|
MediaManagerItem.__init__(self, parent, icon, title)
|
||||||
self.edit_song_form = EditSongForm(self.parent.manager, self)
|
self.edit_song_form = EditSongForm(self, self.parent.manager)
|
||||||
self.song_maintenance_form = SongMaintenanceForm(
|
self.song_maintenance_form = SongMaintenanceForm(
|
||||||
self.parent.manager, self)
|
self.parent.manager, self)
|
||||||
# Holds information about whether the edit is remotly triggered and
|
# Holds information about whether the edit is remotly triggered and
|
||||||
@ -305,8 +305,7 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
songXML = SongXMLParser(song.lyrics)
|
songXML = SongXMLParser(song.lyrics)
|
||||||
verseList = songXML.get_verses()
|
verseList = songXML.get_verses()
|
||||||
#no verse list or only 1 space (in error)
|
#no verse list or only 1 space (in error)
|
||||||
if song.verse_order is None or \
|
if not song.verse_order or not song.verse_order.strip():
|
||||||
song.verse_order == u'' or song.verse_order == u' ':
|
|
||||||
for verse in verseList:
|
for verse in verseList:
|
||||||
service_item.add_from_text(verse[1][:30], unicode(verse[1]))
|
service_item.add_from_text(verse[1][:30], unicode(verse[1]))
|
||||||
else:
|
else:
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>500</width>
|
<width>474</width>
|
||||||
<height>521</height>
|
<height>442</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -16,93 +16,13 @@
|
|||||||
<property name="modal">
|
<property name="modal">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="layoutWidget">
|
<layout class="QVBoxLayout" name="EditVerseLayout">
|
||||||
<property name="geometry">
|
<property name="spacing">
|
||||||
<rect>
|
<number>8</number>
|
||||||
<x>11</x>
|
|
||||||
<y>1</y>
|
|
||||||
<width>471</width>
|
|
||||||
<height>491</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<property name="margin">
|
||||||
<item>
|
<number>8</number>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="VerseTypeLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Verse Type</string>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="textFormat">
|
|
||||||
<enum>Qt::PlainText</enum>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="VerseListComboBox">
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Intro</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Verse</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Pre-Chorus</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Chorus</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Bridge</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Ending</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Other</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="VerseNumberLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Number</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="SubVerseListComboBox"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTextEdit" name="VerseTextEdit">
|
<widget class="QTextEdit" name="VerseTextEdit">
|
||||||
<property name="acceptRichText">
|
<property name="acceptRichText">
|
||||||
@ -111,64 +31,87 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="VerseTypeLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>8</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="addBridge">
|
<widget class="QLabel" name="VerseTypeLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Bridge</string>
|
<string>Verse Type:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="addVerse">
|
<widget class="QComboBox" name="VerseTypeComboBox">
|
||||||
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Verse</string>
|
<string>Verse</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="addChorus">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Chorus</string>
|
<string>Chorus</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<property name="text">
|
||||||
|
<string>Bridge</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="addPreChorus">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Pre-Chorus</string>
|
<string>Pre-Chorus</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="addIntro">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Intro</string>
|
<string>Intro</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="addOther">
|
|
||||||
<property name="text">
|
|
||||||
<string>Other</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="addEnding">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Ending</string>
|
<string>Ending</string>
|
||||||
</property>
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Other</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="VerseNumberBox"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="InsertButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Insert</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../images/openlp-2.qrc">
|
||||||
|
<normaloff>:/general/general_add.png</normaloff>:/general/general_add.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="VerseTypeSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="ButtonBox">
|
<widget class="QDialogButtonBox" name="EditButtonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -179,11 +122,12 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
<resources>
|
||||||
<resources/>
|
<include location="../images/openlp-2.qrc"/>
|
||||||
|
</resources>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>ButtonBox</sender>
|
<sender>EditButtonBox</sender>
|
||||||
<signal>accepted()</signal>
|
<signal>accepted()</signal>
|
||||||
<receiver>EditVerseDialog</receiver>
|
<receiver>EditVerseDialog</receiver>
|
||||||
<slot>accept()</slot>
|
<slot>accept()</slot>
|
||||||
@ -199,7 +143,7 @@
|
|||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>ButtonBox</sender>
|
<sender>EditButtonBox</sender>
|
||||||
<signal>rejected()</signal>
|
<signal>rejected()</signal>
|
||||||
<receiver>EditVerseDialog</receiver>
|
<receiver>EditVerseDialog</receiver>
|
||||||
<slot>reject()</slot>
|
<slot>reject()</slot>
|
||||||
|
Loading…
Reference in New Issue
Block a user