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