This commit is contained in:
Andreas Preikschat 2011-03-18 06:13:04 +01:00
commit 606df1fd52
9 changed files with 1029 additions and 909 deletions

View File

@ -160,6 +160,16 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
self._performWizard() self._performWizard()
self._postWizard() self._postWizard()
def _getFileSize(self, url):
site = urllib.urlopen(url)
meta = site.info()
return int(meta.getheaders("Content-Length")[0])
def _downloadProgress(self, count, block_size, total_size):
increment = (count * block_size) - self.previous_size
self._incrementProgressBar(None, increment)
self.previous_size = count * block_size
def _incrementProgressBar(self, status_text, increment=1): def _incrementProgressBar(self, status_text, increment=1):
""" """
Update the wizard progress page. Update the wizard progress page.
@ -184,19 +194,27 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
max_progress = 2 max_progress = 2
# Loop through the songs list and increase for each selected item # Loop through the songs list and increase for each selected item
for i in xrange(self.songsListWidget.count()): for i in xrange(self.songsListWidget.count()):
if self.songsListWidget.item(i).checkState() == QtCore.Qt.Checked: item = self.songsListWidget.item(i)
max_progress += 1 if item.checkState() == QtCore.Qt.Checked:
filename = item.data(QtCore.Qt.UserRole).toString()
size = self._getFileSize(u'%s%s' % (self.web, filename))
max_progress += size
# Loop through the Bibles list and increase for each selected item # Loop through the Bibles list and increase for each selected item
iterator = QtGui.QTreeWidgetItemIterator(self.biblesTreeWidget) iterator = QtGui.QTreeWidgetItemIterator(self.biblesTreeWidget)
while iterator.value(): while iterator.value():
item = iterator.value() item = iterator.value()
if item.parent() and item.checkState(0) == QtCore.Qt.Checked: if item.parent() and item.checkState(0) == QtCore.Qt.Checked:
max_progress += 1 filename = item.data(0, QtCore.Qt.UserRole).toString()
size = self._getFileSize(u'%s%s' % (self.web, filename))
max_progress += size
iterator += 1 iterator += 1
# Loop through the themes list and increase for each selected item # Loop through the themes list and increase for each selected item
for i in xrange(self.themesListWidget.count()): for i in xrange(self.themesListWidget.count()):
if self.themesListWidget.item(i).checkState() == QtCore.Qt.Checked: item = self.themesListWidget.item(i)
max_progress += 1 if item.checkState() == QtCore.Qt.Checked:
filename = item.data(QtCore.Qt.UserRole).toString()
size = self._getFileSize(u'%s%s' % (self.web, filename))
max_progress += size
self.finishButton.setVisible(False) self.finishButton.setVisible(False)
self.progressBar.setValue(0) self.progressBar.setValue(0)
self.progressBar.setMinimum(0) self.progressBar.setMinimum(0)
@ -241,27 +259,33 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
item = self.songsListWidget.item(i) item = self.songsListWidget.item(i)
if item.checkState() == QtCore.Qt.Checked: if item.checkState() == QtCore.Qt.Checked:
filename = item.data(QtCore.Qt.UserRole).toString() filename = item.data(QtCore.Qt.UserRole).toString()
self._incrementProgressBar(self.downloading % filename) self._incrementProgressBar(self.downloading % filename, 0)
self.previous_size = 0
destination = os.path.join(songs_destination, unicode(filename)) destination = os.path.join(songs_destination, unicode(filename))
urllib.urlretrieve(u'%s%s' % (self.web, filename), destination) urllib.urlretrieve(u'%s%s' % (self.web, filename), destination,
self._downloadProgress)
# Download Bibles # Download Bibles
bibles_iterator = QtGui.QTreeWidgetItemIterator(self.biblesTreeWidget) bibles_iterator = QtGui.QTreeWidgetItemIterator(self.biblesTreeWidget)
while bibles_iterator.value(): while bibles_iterator.value():
item = bibles_iterator.value() item = bibles_iterator.value()
if item.parent() and item.checkState(0) == QtCore.Qt.Checked: if item.parent() and item.checkState(0) == QtCore.Qt.Checked:
bible = unicode(item.data(0, QtCore.Qt.UserRole).toString()) bible = unicode(item.data(0, QtCore.Qt.UserRole).toString())
self._incrementProgressBar(self.downloading % bible) self._incrementProgressBar(self.downloading % bible, 0)
self.previous_size = 0
urllib.urlretrieve(u'%s%s' % (self.web, bible), urllib.urlretrieve(u'%s%s' % (self.web, bible),
os.path.join(bibles_destination, bible)) os.path.join(bibles_destination, bible),
self._downloadProgress)
bibles_iterator += 1 bibles_iterator += 1
# Download themes # Download themes
for i in xrange(self.themesListWidget.count()): for i in xrange(self.themesListWidget.count()):
item = self.themesListWidget.item(i) item = self.themesListWidget.item(i)
if item.checkState() == QtCore.Qt.Checked: if item.checkState() == QtCore.Qt.Checked:
theme = unicode(item.data(QtCore.Qt.UserRole).toString()) theme = unicode(item.data(QtCore.Qt.UserRole).toString())
self._incrementProgressBar(self.downloading % theme) self._incrementProgressBar(self.downloading % theme, 0)
self.previous_size = 0
urllib.urlretrieve(u'%s%s' % (self.web, theme), urllib.urlretrieve(u'%s%s' % (self.web, theme),
os.path.join(themes_destination, theme)) os.path.join(themes_destination, theme),
self._downloadProgress)
# Set Default Display # Set Default Display
if self.displayComboBox.currentIndex() != -1: if self.displayComboBox.currentIndex() != -1:
QtCore.QSettings().setValue(u'General/monitor', QtCore.QSettings().setValue(u'General/monitor',

View File

@ -32,27 +32,6 @@ from openlp.core.lib.ui import UiStrings
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class ValidEdit(QtGui.QLineEdit):
"""
Only allow numeric characters to be edited
"""
def __init__(self, parent):
"""
Set up Override and Validator
"""
QtGui.QLineEdit.__init__(self, parent)
self.setValidator(QtGui.QIntValidator(0, 9999, self))
def validText(self):
"""
Only return Integers. Space is 0
"""
if self.text().isEmpty():
return QtCore.QString(u'0')
else:
return self.text()
class GeneralTab(SettingsTab): class GeneralTab(SettingsTab):
""" """
GeneralTab is the general settings tab in the settings dialog. GeneralTab is the general settings tab in the settings dialog.
@ -164,30 +143,6 @@ class GeneralTab(SettingsTab):
self.displayGroupBox.setObjectName(u'displayGroupBox') self.displayGroupBox.setObjectName(u'displayGroupBox')
self.displayLayout = QtGui.QGridLayout(self.displayGroupBox) self.displayLayout = QtGui.QGridLayout(self.displayGroupBox)
self.displayLayout.setObjectName(u'displayLayout') self.displayLayout.setObjectName(u'displayLayout')
self.currentXLabel = QtGui.QLabel(self.displayGroupBox)
self.currentXLabel.setObjectName(u'currentXLabel')
self.displayLayout.addWidget(self.currentXLabel, 0, 0)
self.currentXValueLabel = QtGui.QLabel(self.displayGroupBox)
self.currentXValueLabel.setObjectName(u'currentXValueLabel')
self.displayLayout.addWidget(self.currentXValueLabel, 1, 0)
self.currentYLabel = QtGui.QLabel(self.displayGroupBox)
self.currentYLabel.setObjectName(u'currentYLabel')
self.displayLayout.addWidget(self.currentYLabel, 0, 1)
self.currentYValueLabel = QtGui.QLabel(self.displayGroupBox)
self.currentYValueLabel.setObjectName(u'currentYValueLabel')
self.displayLayout.addWidget(self.currentYValueLabel, 1, 1)
self.currentWidthLabel = QtGui.QLabel(self.displayGroupBox)
self.currentWidthLabel.setObjectName(u'currentWidthLabel')
self.displayLayout.addWidget(self.currentWidthLabel, 0, 2)
self.currentWidthValueLabel = QtGui.QLabel(self.displayGroupBox)
self.currentWidthValueLabel.setObjectName(u'currentWidthValueLabel')
self.displayLayout.addWidget(self.currentWidthValueLabel, 1, 2)
self.currentHeightLabel = QtGui.QLabel(self.displayGroupBox)
self.currentHeightLabel.setObjectName(u'currentHeightLabel')
self.displayLayout.addWidget(self.currentHeightLabel, 0, 3)
self.currentHeightValueLabel = QtGui.QLabel(self.displayGroupBox)
self.currentHeightValueLabel.setObjectName(u'Height')
self.displayLayout.addWidget(self.currentHeightValueLabel, 1, 3)
self.overrideCheckBox = QtGui.QCheckBox(self.displayGroupBox) self.overrideCheckBox = QtGui.QCheckBox(self.displayGroupBox)
self.overrideCheckBox.setObjectName(u'overrideCheckBox') self.overrideCheckBox.setObjectName(u'overrideCheckBox')
self.displayLayout.addWidget(self.overrideCheckBox, 2, 0, 1, 4) self.displayLayout.addWidget(self.overrideCheckBox, 2, 0, 1, 4)
@ -196,26 +151,30 @@ class GeneralTab(SettingsTab):
self.customXLabel = QtGui.QLabel(self.displayGroupBox) self.customXLabel = QtGui.QLabel(self.displayGroupBox)
self.customXLabel.setObjectName(u'customXLabel') self.customXLabel.setObjectName(u'customXLabel')
self.displayLayout.addWidget(self.customXLabel, 3, 0) self.displayLayout.addWidget(self.customXLabel, 3, 0)
self.customXValueEdit = ValidEdit(self.displayGroupBox) self.customXValueEdit = QtGui.QSpinBox(self.displayGroupBox)
self.customXValueEdit.setObjectName(u'customXValueEdit') self.customXValueEdit.setObjectName(u'customXValueEdit')
self.customXValueEdit.setMaximum(9999)
self.displayLayout.addWidget(self.customXValueEdit, 4, 0) self.displayLayout.addWidget(self.customXValueEdit, 4, 0)
self.customYLabel = QtGui.QLabel(self.displayGroupBox) self.customYLabel = QtGui.QLabel(self.displayGroupBox)
self.customYLabel.setObjectName(u'customYLabel') self.customYLabel.setObjectName(u'customYLabel')
self.displayLayout.addWidget(self.customYLabel, 3, 1) self.displayLayout.addWidget(self.customYLabel, 3, 1)
self.customYValueEdit = ValidEdit(self.displayGroupBox) self.customYValueEdit = QtGui.QSpinBox(self.displayGroupBox)
self.customYValueEdit.setObjectName(u'customYValueEdit') self.customYValueEdit.setObjectName(u'customYValueEdit')
self.customYValueEdit.setMaximum(9999)
self.displayLayout.addWidget(self.customYValueEdit, 4, 1) self.displayLayout.addWidget(self.customYValueEdit, 4, 1)
self.customWidthLabel = QtGui.QLabel(self.displayGroupBox) self.customWidthLabel = QtGui.QLabel(self.displayGroupBox)
self.customWidthLabel.setObjectName(u'customWidthLabel') self.customWidthLabel.setObjectName(u'customWidthLabel')
self.displayLayout.addWidget(self.customWidthLabel, 3, 2) self.displayLayout.addWidget(self.customWidthLabel, 3, 2)
self.customWidthValueEdit = ValidEdit(self.displayGroupBox) self.customWidthValueEdit = QtGui.QSpinBox(self.displayGroupBox)
self.customWidthValueEdit.setObjectName(u'customWidthValueEdit') self.customWidthValueEdit.setObjectName(u'customWidthValueEdit')
self.customWidthValueEdit.setMaximum(9999)
self.displayLayout.addWidget(self.customWidthValueEdit, 4, 2) self.displayLayout.addWidget(self.customWidthValueEdit, 4, 2)
self.customHeightLabel = QtGui.QLabel(self.displayGroupBox) self.customHeightLabel = QtGui.QLabel(self.displayGroupBox)
self.customHeightLabel.setObjectName(u'customHeightLabel') self.customHeightLabel.setObjectName(u'customHeightLabel')
self.displayLayout.addWidget(self.customHeightLabel, 3, 3) self.displayLayout.addWidget(self.customHeightLabel, 3, 3)
self.customHeightValueEdit = ValidEdit(self.displayGroupBox) self.customHeightValueEdit = QtGui.QSpinBox(self.displayGroupBox)
self.customHeightValueEdit.setObjectName(u'customHeightValueEdit') self.customHeightValueEdit.setObjectName(u'customHeightValueEdit')
self.customHeightValueEdit.setMaximum(9999)
self.displayLayout.addWidget(self.customHeightValueEdit, 4, 3) self.displayLayout.addWidget(self.customHeightValueEdit, 4, 3)
self.rightLayout.addWidget(self.displayGroupBox) self.rightLayout.addWidget(self.displayGroupBox)
self.rightLayout.addStretch() self.rightLayout.addStretch()
@ -223,17 +182,13 @@ class GeneralTab(SettingsTab):
QtCore.QObject.connect(self.overrideCheckBox, QtCore.QObject.connect(self.overrideCheckBox,
QtCore.SIGNAL(u'toggled(bool)'), self.onOverrideCheckBoxToggled) QtCore.SIGNAL(u'toggled(bool)'), self.onOverrideCheckBoxToggled)
QtCore.QObject.connect(self.customHeightValueEdit, QtCore.QObject.connect(self.customHeightValueEdit,
QtCore.SIGNAL(u'textEdited(const QString&)'), QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayPositionChanged)
self.onDisplayPositionChanged)
QtCore.QObject.connect(self.customWidthValueEdit, QtCore.QObject.connect(self.customWidthValueEdit,
QtCore.SIGNAL(u'textEdited(const QString&)'), QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayPositionChanged)
self.onDisplayPositionChanged)
QtCore.QObject.connect(self.customYValueEdit, QtCore.QObject.connect(self.customYValueEdit,
QtCore.SIGNAL(u'textEdited(const QString&)'), QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayPositionChanged)
self.onDisplayPositionChanged)
QtCore.QObject.connect(self.customXValueEdit, QtCore.QObject.connect(self.customXValueEdit,
QtCore.SIGNAL(u'textEdited(const QString&)'), QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayPositionChanged)
self.onDisplayPositionChanged)
# Reload the tab, as the screen resolution/count may have changed. # Reload the tab, as the screen resolution/count may have changed.
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'config_screen_changed'), self.load) QtCore.SIGNAL(u'config_screen_changed'), self.load)
@ -273,8 +228,7 @@ class GeneralTab(SettingsTab):
'Automatically preview next item in service')) 'Automatically preview next item in service'))
self.timeoutLabel.setText(translate('OpenLP.GeneralTab', self.timeoutLabel.setText(translate('OpenLP.GeneralTab',
'Slide loop delay:')) 'Slide loop delay:'))
self.timeoutSpinBox.setSuffix( self.timeoutSpinBox.setSuffix(translate('OpenLP.GeneralTab', ' sec'))
translate('OpenLP.GeneralTab', ' sec'))
self.ccliGroupBox.setTitle( self.ccliGroupBox.setTitle(
translate('OpenLP.GeneralTab', 'CCLI Details')) translate('OpenLP.GeneralTab', 'CCLI Details'))
self.numberLabel.setText(UiStrings.CCLINumberLabel) self.numberLabel.setText(UiStrings.CCLINumberLabel)
@ -285,22 +239,11 @@ class GeneralTab(SettingsTab):
# Moved from display tab # Moved from display tab
self.displayGroupBox.setTitle( self.displayGroupBox.setTitle(
translate('OpenLP.GeneralTab', 'Display Position')) translate('OpenLP.GeneralTab', 'Display Position'))
self.currentXLabel.setText(translate('OpenLP.GeneralTab', 'X'))
self.currentXValueLabel.setText(u'0')
self.currentYLabel.setText(translate('OpenLP.GeneralTab', 'Y'))
self.currentYValueLabel.setText(u'0')
self.currentHeightLabel.setText(
translate('OpenLP.GeneralTab', 'Height'))
self.currentHeightValueLabel.setText(u'0')
self.currentWidthLabel.setText(
translate('OpenLP.GeneralTab', 'Width'))
self.currentWidthValueLabel.setText(u'0')
self.overrideCheckBox.setText(translate('OpenLP.GeneralTab', self.overrideCheckBox.setText(translate('OpenLP.GeneralTab',
'Override display position')) 'Override display position'))
self.customXLabel.setText(translate('OpenLP.GeneralTab', 'X')) self.customXLabel.setText(translate('OpenLP.GeneralTab', 'X'))
self.customYLabel.setText(translate('OpenLP.GeneralTab', 'Y')) self.customYLabel.setText(translate('OpenLP.GeneralTab', 'Y'))
self.customHeightLabel.setText( self.customHeightLabel.setText(translate('OpenLP.GeneralTab', 'Height'))
translate('OpenLP.GeneralTab', 'Height'))
self.customWidthLabel.setText(translate('OpenLP.GeneralTab', 'Width')) self.customWidthLabel.setText(translate('OpenLP.GeneralTab', 'Width'))
def load(self): def load(self):
@ -310,8 +253,7 @@ class GeneralTab(SettingsTab):
settings = QtCore.QSettings() settings = QtCore.QSettings()
settings.beginGroup(self.settingsSection) settings.beginGroup(self.settingsSection)
self.monitorComboBox.clear() self.monitorComboBox.clear()
for screen in self.screens.get_screen_list(): self.monitorComboBox.addItems(self.screens.get_screen_list())
self.monitorComboBox.addItem(screen)
self.numberEdit.setText(unicode(settings.value( self.numberEdit.setText(unicode(settings.value(
u'ccli number', QtCore.QVariant(u'')).toString())) u'ccli number', QtCore.QVariant(u'')).toString()))
self.usernameEdit.setText(unicode(settings.value( self.usernameEdit.setText(unicode(settings.value(
@ -334,26 +276,16 @@ class GeneralTab(SettingsTab):
QtCore.QVariant(False)).toBool()) QtCore.QVariant(False)).toBool())
self.timeoutSpinBox.setValue(settings.value(u'loop delay', self.timeoutSpinBox.setValue(settings.value(u'loop delay',
QtCore.QVariant(5)).toInt()[0]) QtCore.QVariant(5)).toInt()[0])
self.currentXValueLabel.setText(
unicode(self.screens.current[u'size'].x()))
self.currentYValueLabel.setText(
unicode(self.screens.current[u'size'].y()))
self.currentHeightValueLabel.setText(
unicode(self.screens.current[u'size'].height()))
self.currentWidthValueLabel.setText(
unicode(self.screens.current[u'size'].width()))
self.overrideCheckBox.setChecked(settings.value(u'override position', self.overrideCheckBox.setChecked(settings.value(u'override position',
QtCore.QVariant(False)).toBool()) QtCore.QVariant(False)).toBool())
self.customXValueEdit.setText(settings.value(u'x position', self.customXValueEdit.setValue(settings.value(u'x position',
QtCore.QVariant(self.screens.current[u'size'].x())).toString()) QtCore.QVariant(self.screens.current[u'size'].x())).toInt()[0])
self.customYValueEdit.setText(settings.value(u'y position', self.customYValueEdit.setValue(settings.value(u'y position',
QtCore.QVariant(self.screens.current[u'size'].y())).toString()) QtCore.QVariant(self.screens.current[u'size'].y())).toInt()[0])
self.customHeightValueEdit.setText( self.customHeightValueEdit.setValue(settings.value(u'height',
settings.value(u'height', QtCore.QVariant( QtCore.QVariant(self.screens.current[u'size'].height())).toInt()[0])
self.screens.current[u'size'].height())).toString()) self.customWidthValueEdit.setValue(settings.value(u'width',
self.customWidthValueEdit.setText( QtCore.QVariant(self.screens.current[u'size'].width())).toInt()[0])
settings.value(u'width', QtCore.QVariant(
self.screens.current[u'size'].width())).toString())
settings.endGroup() settings.endGroup()
self.customXValueEdit.setEnabled(self.overrideCheckBox.isChecked()) self.customXValueEdit.setEnabled(self.overrideCheckBox.isChecked())
self.customYValueEdit.setEnabled(self.overrideCheckBox.isChecked()) self.customYValueEdit.setEnabled(self.overrideCheckBox.isChecked())
@ -391,13 +323,13 @@ class GeneralTab(SettingsTab):
settings.setValue(u'songselect password', settings.setValue(u'songselect password',
QtCore.QVariant(self.passwordEdit.displayText())) QtCore.QVariant(self.passwordEdit.displayText()))
settings.setValue(u'x position', settings.setValue(u'x position',
QtCore.QVariant(self.customXValueEdit.text())) QtCore.QVariant(self.customXValueEdit.value()))
settings.setValue(u'y position', settings.setValue(u'y position',
QtCore.QVariant(self.customYValueEdit.text())) QtCore.QVariant(self.customYValueEdit.value()))
settings.setValue(u'height', settings.setValue(u'height',
QtCore.QVariant(self.customHeightValueEdit.text())) QtCore.QVariant(self.customHeightValueEdit.value()))
settings.setValue(u'width', settings.setValue(u'width',
QtCore.QVariant(self.customWidthValueEdit.text())) QtCore.QVariant(self.customWidthValueEdit.value()))
settings.setValue(u'override position', settings.setValue(u'override position',
QtCore.QVariant(self.overrideCheckBox.isChecked())) QtCore.QVariant(self.overrideCheckBox.isChecked()))
settings.endGroup() settings.endGroup()
@ -421,10 +353,10 @@ class GeneralTab(SettingsTab):
# Reset screens after initial definition # Reset screens after initial definition
if self.overrideChanged: if self.overrideChanged:
self.screens.override[u'size'] = QtCore.QRect( self.screens.override[u'size'] = QtCore.QRect(
int(self.customXValueEdit.validText()), self.customXValueEdit.value(),
int(self.customYValueEdit.validText()), self.customYValueEdit.value(),
int(self.customWidthValueEdit.validText()), self.customWidthValueEdit.value(),
int(self.customHeightValueEdit.validText())) self.customHeightValueEdit.value())
if self.overrideCheckBox.isChecked(): if self.overrideCheckBox.isChecked():
self.screens.set_override_display() self.screens.set_override_display()
else: else:

View File

@ -80,8 +80,7 @@ class PowerpointController(PresentationController):
log.debug(u'start_process') log.debug(u'start_process')
if not self.process: if not self.process:
self.process = Dispatch(u'PowerPoint.Application') self.process = Dispatch(u'PowerPoint.Application')
if float(self.process.Version) < 13: self.process.Visible = True
self.process.Visible = True
self.process.WindowState = 2 self.process.WindowState = 2
def kill(self): def kill(self):

View File

@ -30,19 +30,32 @@ from ctypes import *
from ctypes.wintypes import RECT from ctypes.wintypes import RECT
class PPTViewer(QtGui.QWidget): class PPTViewer(QtGui.QWidget):
"""
Standalone Test Harness for the pptviewlib library
"""
def __init__(self, parent=None): def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent) QtGui.QWidget.__init__(self, parent)
self.pptid = -1 self.pptid = -1
self.setWindowTitle(u'PowerPoint Viewer Test') self.setWindowTitle(u'PowerPoint Viewer Test')
PPTLabel = QtGui.QLabel(u'Open PowerPoint file') ppt_label = QtGui.QLabel(u'Open PowerPoint file')
slideLabel = QtGui.QLabel(u'Go to slide #') slide_label = QtGui.QLabel(u'Go to slide #')
self.PPTEdit = QtGui.QLineEdit() self.pptEdit = QtGui.QLineEdit()
self.slideEdit = QtGui.QLineEdit() self.slideEdit = QtGui.QLineEdit()
x_label = QtGui.QLabel(u'X pos')
y_label = QtGui.QLabel(u'Y pos')
width_label = QtGui.QLabel(u'Width')
height_label = QtGui.QLabel(u'Height')
self.xEdit = QtGui.QLineEdit(u'100')
self.yEdit = QtGui.QLineEdit(u'100')
self.widthEdit = QtGui.QLineEdit(u'900')
self.heightEdit = QtGui.QLineEdit(u'700')
self.total = QtGui.QLabel() self.total = QtGui.QLabel()
PPTBtn = QtGui.QPushButton(u'Open') ppt_btn = QtGui.QPushButton(u'Open')
PPTDlgBtn = QtGui.QPushButton(u'...') ppt_dlg_btn = QtGui.QPushButton(u'...')
slideBtn = QtGui.QPushButton(u'Go') folder_label = QtGui.QLabel(u'Slide .bmp path')
self.folderEdit = QtGui.QLineEdit(u'slide')
slide_btn = QtGui.QPushButton(u'Go')
prev = QtGui.QPushButton(u'Prev') prev = QtGui.QPushButton(u'Prev')
next = QtGui.QPushButton(u'Next') next = QtGui.QPushButton(u'Next')
blank = QtGui.QPushButton(u'Blank') blank = QtGui.QPushButton(u'Blank')
@ -51,122 +64,149 @@ class PPTViewer(QtGui.QWidget):
close = QtGui.QPushButton(u'Close') close = QtGui.QPushButton(u'Close')
resume = QtGui.QPushButton(u'Resume') resume = QtGui.QPushButton(u'Resume')
stop = QtGui.QPushButton(u'Stop') stop = QtGui.QPushButton(u'Stop')
pptwindow = QtGui.QWidget()
grid = QtGui.QGridLayout() grid = QtGui.QGridLayout()
grid.addWidget(PPTLabel, 0, 0) row = 0
grid.addWidget(self.PPTEdit, 0, 1) grid.addWidget(folder_label, 0, 0)
grid.addWidget(PPTDlgBtn, 0, 2) grid.addWidget(self.folderEdit, 0, 1)
grid.addWidget(PPTBtn, 0, 3) row = row + 1
grid.addWidget(slideLabel, 1, 0) grid.addWidget(x_label, row, 0)
grid.addWidget(self.slideEdit, 1, 1) grid.addWidget(self.xEdit, row, 1)
grid.addWidget(slideBtn, 1, 3) grid.addWidget(y_label, row, 2)
grid.addWidget(prev, 2, 0) grid.addWidget(self.yEdit, row, 3)
grid.addWidget(next, 2, 1) row = row + 1
grid.addWidget(blank, 3, 0) grid.addWidget(width_label, row, 0)
grid.addWidget(unblank, 3, 1) grid.addWidget(self.widthEdit, row, 1)
grid.addWidget(restart, 4, 0) grid.addWidget(height_label, row, 2)
grid.addWidget(close, 4, 1) grid.addWidget(self.heightEdit, row, 3)
grid.addWidget(stop, 5, 0) row = row + 1
grid.addWidget(resume, 5, 1) grid.addWidget(ppt_label, row, 0)
grid.addWidget(pptwindow, 6, 0, 10, 3) grid.addWidget(self.pptEdit, row, 1)
self.connect(PPTBtn, QtCore.SIGNAL(u'clicked()'), self.OpenClick) grid.addWidget(ppt_dlg_btn, row, 2)
self.connect(PPTDlgBtn, QtCore.SIGNAL(u'clicked()'), self.OpenDialog) grid.addWidget(ppt_btn, row, 3)
self.connect(slideBtn, QtCore.SIGNAL(u'clicked()'), self.GotoClick) row = row + 1
self.connect(prev, QtCore.SIGNAL(u'clicked()'), self.PrevClick) grid.addWidget(slide_label, row, 0)
self.connect(next, QtCore.SIGNAL(u'clicked()'), self.NextClick) grid.addWidget(self.slideEdit, row, 1)
self.connect(blank, QtCore.SIGNAL(u'clicked()'), self.BlankClick) grid.addWidget(slide_btn, row, 2)
self.connect(unblank, QtCore.SIGNAL(u'clicked()'), self.UnblankClick) row = row + 1
self.connect(restart, QtCore.SIGNAL(u'clicked()'), self.RestartClick) grid.addWidget(prev, row, 0)
self.connect(close, QtCore.SIGNAL(u'clicked()'), self.CloseClick) grid.addWidget(next, row, 1)
self.connect(stop, QtCore.SIGNAL(u'clicked()'), self.StopClick) row = row + 1
self.connect(resume, QtCore.SIGNAL(u'clicked()'), self.ResumeClick) grid.addWidget(blank, row, 0)
grid.addWidget(unblank, row, 1)
row = row + 1
grid.addWidget(restart, row, 0)
grid.addWidget(close, row, 1)
row = row + 1
grid.addWidget(stop, row, 0)
grid.addWidget(resume, row, 1)
self.connect(ppt_btn, QtCore.SIGNAL(u'clicked()'), self.openClick)
self.connect(ppt_dlg_btn, QtCore.SIGNAL(u'clicked()'), self.openDialog)
self.connect(slide_btn, QtCore.SIGNAL(u'clicked()'), self.gotoClick)
self.connect(prev, QtCore.SIGNAL(u'clicked()'), self.prevClick)
self.connect(next, QtCore.SIGNAL(u'clicked()'), self.nextClick)
self.connect(blank, QtCore.SIGNAL(u'clicked()'), self.blankClick)
self.connect(unblank, QtCore.SIGNAL(u'clicked()'), self.unblankClick)
self.connect(restart, QtCore.SIGNAL(u'clicked()'), self.restartClick)
self.connect(close, QtCore.SIGNAL(u'clicked()'), self.closeClick)
self.connect(stop, QtCore.SIGNAL(u'clicked()'), self.stopClick)
self.connect(resume, QtCore.SIGNAL(u'clicked()'), self.resumeClick)
self.setLayout(grid) self.setLayout(grid)
self.resize(300, 150) self.resize(300, 150)
def PrevClick(self): def prevClick(self):
if self.pptid<0: return if self.pptid < 0:
pptdll.PrevStep(self.pptid) return
self.UpdateCurrSlide() self.pptdll.PrevStep(self.pptid)
self.updateCurrSlide()
app.processEvents() app.processEvents()
def NextClick(self): def nextClick(self):
if(self.pptid<0): return if self.pptid < 0:
pptdll.NextStep(self.pptid) return
self.UpdateCurrSlide() self.pptdll.NextStep(self.pptid)
self.updateCurrSlide()
app.processEvents() app.processEvents()
def BlankClick(self): def blankClick(self):
if(self.pptid<0): return if self.pptid < 0:
pptdll.Blank(self.pptid) return
self.pptdll.Blank(self.pptid)
app.processEvents() app.processEvents()
def UnblankClick(self): def unblankClick(self):
if(self.pptid<0): return if self.pptid < 0:
pptdll.Unblank(self.pptid) return
self.pptdll.Unblank(self.pptid)
app.processEvents() app.processEvents()
def RestartClick(self): def restartClick(self):
if(self.pptid<0): return if self.pptid < 0:
pptdll.RestartShow(self.pptid) return
self.UpdateCurrSlide() self.pptdll.RestartShow(self.pptid)
self.updateCurrSlide()
app.processEvents() app.processEvents()
def StopClick(self): def stopClick(self):
if(self.pptid<0): return if self.pptid < 0:
pptdll.Stop(self.pptid) return
self.pptdll.Stop(self.pptid)
app.processEvents() app.processEvents()
def ResumeClick(self): def resumeClick(self):
if(self.pptid<0): return if self.pptid < 0:
pptdll.Resume(self.pptid) return
self.pptdll.Resume(self.pptid)
app.processEvents() app.processEvents()
def CloseClick(self): def closeClick(self):
if(self.pptid<0): return if self.pptid < 0:
pptdll.ClosePPT(self.pptid) return
self.pptdll.ClosePPT(self.pptid)
self.pptid = -1 self.pptid = -1
app.processEvents() app.processEvents()
def OpenClick(self): def openClick(self):
oldid = self.pptid; oldid = self.pptid;
rect = RECT(100,100,900,700) rect = RECT(int(self.xEdit.text()), int(self.yEdit.text()),
filename = str(self.PPTEdit.text().replace(u'/', u'\\')) int(self.widthEdit.text()), int(self.heightEdit.text()))
print filename filename = str(self.pptEdit.text().replace(u'/', u'\\'))
self.pptid = pptdll.OpenPPT(filename, None, rect, 'c:\\temp\\slide') folder = str(self.folderEdit.text().replace(u'/', u'\\'))
print "id: " + unicode(self.pptid) print filename, folder
if oldid>=0: self.pptid = self.pptdll.OpenPPT(filename, None, rect, folder)
pptdll.ClosePPT(oldid); print u'id: ' + unicode(self.pptid)
slides = pptdll.GetSlideCount(self.pptid) if oldid >= 0:
print "slidecount: " + unicode(slides) self.pptdll.ClosePPT(oldid);
self.total.setNum(pptdll.GetSlideCount(self.pptid)) slides = self.pptdll.GetSlideCount(self.pptid)
self.UpdateCurrSlide() print u'slidecount: ' + unicode(slides)
self.total.setNum(self.pptdll.GetSlideCount(self.pptid))
self.updateCurrSlide()
def UpdateCurrSlide(self): def updateCurrSlide(self):
if(self.pptid<0): return if self.pptid < 0:
slide = unicode(pptdll.GetCurrentSlide(self.pptid)) return
print "currslide: " + slide slide = unicode(self.pptdll.GetCurrentSlide(self.pptid))
print u'currslide: ' + slide
self.slideEdit.setText(slide) self.slideEdit.setText(slide)
app.processEvents() app.processEvents()
def GotoClick(self): def gotoClick(self):
if(self.pptid<0): return if self.pptid < 0:
return
print self.slideEdit.text() print self.slideEdit.text()
pptdll.GotoSlide(self.pptid, int(self.slideEdit.text())) self.pptdll.GotoSlide(self.pptid, int(self.slideEdit.text()))
self.UpdateCurrSlide() self.updateCurrSlide()
app.processEvents() app.processEvents()
def OpenDialog(self): def openDialog(self):
self.PPTEdit.setText(QtGui.QFileDialog.getOpenFileName(self, 'Open file')) self.pptEdit.setText(QtGui.QFileDialog.getOpenFileName(self,
u'Open file'))
if __name__ == '__main__': if __name__ == '__main__':
#pptdll = cdll.LoadLibrary(r'C:\Documents and Settings\jonathan\Desktop\pptviewlib.dll')
pptdll = cdll.LoadLibrary(r'pptviewlib.dll') pptdll = cdll.LoadLibrary(r'pptviewlib.dll')
pptdll.SetDebug(1) pptdll.SetDebug(1)
print "Begin..." print u'Begin...'
app = QtGui.QApplication(sys.argv) app = QtGui.QApplication(sys.argv)
qb = PPTViewer() window = PPTViewer()
qb.show() window.pptdll = pptdll
window.show()
sys.exit(app.exec_()) sys.exit(app.exec_())

File diff suppressed because it is too large Load Diff

View File

@ -1,55 +1,84 @@
/******************************************************************************
* PptViewLib - PowerPoint Viewer 2003/2007 Controller *
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
* Copyright (c) 2008-2011 Raoul Snyman *
* Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael *
* Gorven, Scott Guerrieri, Meinert Jordan, Armin Köhler, Andreas Preikschat, *
* Christian Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon *
* Tibble, Carsten Tinggaard, Frode Woldsund *
* --------------------------------------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the Free *
* Software Foundation; version 2 of the License. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
* more details. *
* *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., 59 *
* Temple Place, Suite 330, Boston, MA 02111-1307 USA *
******************************************************************************/
#define DllExport extern "C" __declspec( dllexport ) #define DllExport extern "C" __declspec( dllexport )
enum PPTVIEWSTATE { PPT_CLOSED, PPT_STARTED, PPT_OPENED, PPT_LOADED, PPT_CLOSING}; #define DEBUG(...) if (debug) printf(__VA_ARGS__)
DllExport int OpenPPT(char *filename, HWND hParentWnd, RECT rect, char *previewpath); enum PPTVIEWSTATE {PPT_CLOSED, PPT_STARTED, PPT_OPENED, PPT_LOADED,
PPT_CLOSING};
DllExport int OpenPPT(char *filename, HWND hParentWnd, RECT rect,
char *previewPath);
DllExport BOOL CheckInstalled(); DllExport BOOL CheckInstalled();
DllExport void ClosePPT(int id); DllExport void ClosePPT(int id);
DllExport int GetCurrentSlide(int id); DllExport int GetCurrentSlide(int id);
DllExport int GetSlideCount(int id); DllExport int GetSlideCount(int id);
DllExport void NextStep(int id); DllExport void NextStep(int id);
DllExport void PrevStep(int id); DllExport void PrevStep(int id);
DllExport void GotoSlide(int id, int slideno); DllExport void GotoSlide(int id, int slide_no);
DllExport void RestartShow(int id); DllExport void RestartShow(int id);
DllExport void Blank(int id); DllExport void Blank(int id);
DllExport void Unblank(int id); DllExport void Unblank(int id);
DllExport void Stop(int id); DllExport void Stop(int id);
DllExport void Resume(int id); DllExport void Resume(int id);
DllExport void SetDebug(BOOL onoff); DllExport void SetDebug(BOOL onOff);
LRESULT CALLBACK CbtProc(int nCode, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK CbtProc(int nCode, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK CwpProc(int nCode, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK CwpProc(int nCode, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam);
BOOL GetPPTViewerPath(char *pptviewerpath, int strsize); BOOL GetPPTViewerPath(char *pptViewerPath, int stringSize);
HBITMAP CaptureWindow (HWND hWnd); HBITMAP CaptureWindow(HWND hWnd);
VOID SaveBitmap (CHAR* filename, HBITMAP hBmp) ; VOID SaveBitmap(CHAR* filename, HBITMAP hBmp) ;
VOID CaptureAndSaveWindow(HWND hWnd, CHAR* filename); VOID CaptureAndSaveWindow(HWND hWnd, CHAR* filename);
BOOL GetPPTInfo(int id); BOOL GetPPTInfo(int id);
BOOL SavePPTInfo(int id); BOOL SavePPTInfo(int id);
void Unhook(int id); void Unhook(int id);
#define MAX_PPTOBJS 50 #define MAX_PPTS 16
#define MAX_SLIDES 256
struct PPTVIEWOBJ struct PPTVIEW
{ {
HHOOK hook; HHOOK hook;
HHOOK mhook; HHOOK msgHook;
HWND hWnd; HWND hWnd;
HWND hWnd2; HWND hWnd2;
HWND hParentWnd; HWND hParentWnd;
HANDLE hProcess; HANDLE hProcess;
HANDLE hThread; HANDLE hThread;
DWORD dwProcessId; DWORD dwProcessId;
DWORD dwThreadId; DWORD dwThreadId;
RECT rect; RECT rect;
int slideCount; int slideCount;
int currentSlide; int currentSlide;
int firstSlideSteps; int firstSlideSteps;
int steps; int lastSlideSteps;
char filename[MAX_PATH]; int steps;
char previewpath[MAX_PATH]; int guess;
PPTVIEWSTATE state; char filename[MAX_PATH];
char previewPath[MAX_PATH];
int slideNos[MAX_SLIDES];
PPTVIEWSTATE state;
}; };

View File

@ -297,7 +297,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.verseOrderEdit.setText(u' '.join(translated)) self.verseOrderEdit.setText(u' '.join(translated))
else: else:
self.verseOrderEdit.setText(u'') self.verseOrderEdit.setText(u'')
self.verseListWidget.resizeRowsToContents()
self.tagRows() self.tagRows()
# clear the results # clear the results
self.authorsListView.clear() self.authorsListView.clear()
@ -312,10 +311,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
topic_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id)) topic_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id))
self.topicsListView.addItem(topic_name) self.topicsListView.addItem(topic_name)
self.titleEdit.setFocus(QtCore.Qt.OtherFocusReason) self.titleEdit.setFocus(QtCore.Qt.OtherFocusReason)
# if not preview hide the preview button # Hide or show the preview button.
self.previewButton.setVisible(False) self.previewButton.setVisible(preview)
if preview:
self.previewButton.setVisible(True)
def tagRows(self): def tagRows(self):
""" """
@ -329,6 +326,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
row_def = u'%s%s' % (verse_tag, verse_def[1:]) row_def = u'%s%s' % (verse_tag, verse_def[1:])
row_label.append(row_def) row_label.append(row_def)
self.verseListWidget.setVerticalHeaderLabels(row_label) self.verseListWidget.setVerticalHeaderLabels(row_label)
self.verseListWidget.setColumnWidth(0, self.width)
self.verseListWidget.resizeRowsToContents()
self.verseListWidget.repaint()
def onAuthorAddButtonClicked(self): def onAuthorAddButtonClicked(self):
item = int(self.authorsComboBox.currentIndex()) item = int(self.authorsComboBox.currentIndex())
@ -453,9 +453,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.verseListWidget.setRowCount( self.verseListWidget.setRowCount(
self.verseListWidget.rowCount() + 1) self.verseListWidget.rowCount() + 1)
self.verseListWidget.setItem( self.verseListWidget.setItem(
int(self.verseListWidget.rowCount() - 1), 0, item) self.verseListWidget.rowCount() - 1, 0, item)
self.verseListWidget.setColumnWidth(0, self.width)
self.verseListWidget.resizeRowsToContents()
self.tagRows() self.tagRows()
def onVerseEditButtonClicked(self): def onVerseEditButtonClicked(self):
@ -482,8 +480,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
item = QtGui.QTableWidgetItem(tempList[row], 0) item = QtGui.QTableWidgetItem(tempList[row], 0)
item.setData(QtCore.Qt.UserRole, tempId[row]) item.setData(QtCore.Qt.UserRole, tempId[row])
self.verseListWidget.setItem(row, 0, item) self.verseListWidget.setItem(row, 0, item)
self.verseListWidget.resizeRowsToContents()
self.verseListWidget.repaint()
self.tagRows() self.tagRows()
def onVerseEditAllButtonClicked(self): def onVerseEditAllButtonClicked(self):
@ -500,53 +496,50 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.verse_form.setVerse(verse_list) self.verse_form.setVerse(verse_list)
else: else:
self.verse_form.setVerse(u'') self.verse_form.setVerse(u'')
if self.verse_form.exec_(): if not self.verse_form.exec_():
verse_list = self.verse_form.getVerseAll() return
verse_list = unicode(verse_list.replace(u'\r\n', u'\n')) verse_list = self.verse_form.getVerseAll()
self.verseListWidget.clear() verse_list = unicode(verse_list.replace(u'\r\n', u'\n'))
self.verseListWidget.setRowCount(0) self.verseListWidget.clear()
for row in self.findVerseSplit.split(verse_list): self.verseListWidget.setRowCount(0)
for match in row.split(u'---['): for row in self.findVerseSplit.split(verse_list):
for count, parts in enumerate(match.split(u']---\n')): for match in row.split(u'---['):
if len(parts) > 1: for count, parts in enumerate(match.split(u']---\n')):
if count == 0: if len(parts) <= 1:
# handling carefully user inputted versetags continue
separator = parts.find(u':') if count == 0:
if separator >= 0: # handling carefully user inputted versetags
verse_name = parts[0:separator].strip() separator = parts.find(u':')
verse_num = parts[separator+1:].strip() if separator >= 0:
else: verse_name = parts[0:separator].strip()
verse_name = parts verse_num = parts[separator+1:].strip()
verse_num = u'1' else:
verse_index = \ verse_name = parts
VerseType.from_loose_input(verse_name) verse_num = u'1'
verse_tag = VerseType.Tags[verse_index] verse_index = VerseType.from_loose_input(verse_name)
# Later we need to handle v1a as well. verse_tag = VerseType.Tags[verse_index]
#regex = re.compile(r'(\d+\w.)') # Later we need to handle v1a as well.
regex = re.compile(r'\D*(\d+)\D*') #regex = re.compile(r'(\d+\w.)')
match = regex.match(verse_num) regex = re.compile(r'\D*(\d+)\D*')
if match: match = regex.match(verse_num)
verse_num = match.group(1) if match:
else: verse_num = match.group(1)
verse_num = u'1' else:
verse_def = u'%s%s' % (verse_tag, verse_num) verse_num = u'1'
else: verse_def = u'%s%s' % (verse_tag, verse_num)
if parts.endswith(u'\n'): else:
parts = parts.rstrip(u'\n') if parts.endswith(u'\n'):
item = QtGui.QTableWidgetItem(parts) parts = parts.rstrip(u'\n')
item.setData(QtCore.Qt.UserRole, item = QtGui.QTableWidgetItem(parts)
QtCore.QVariant(verse_def)) item.setData(QtCore.Qt.UserRole,
self.verseListWidget.setRowCount( QtCore.QVariant(verse_def))
self.verseListWidget.rowCount() + 1) self.verseListWidget.setRowCount(
self.verseListWidget.setItem( self.verseListWidget.rowCount() + 1)
int(self.verseListWidget.rowCount() - 1), self.verseListWidget.setItem(
0, item) self.verseListWidget.rowCount() - 1, 0, item)
self.verseListWidget.setColumnWidth(0, self.width) self.tagRows()
self.verseListWidget.resizeRowsToContents() self.verseEditButton.setEnabled(False)
self.verseListWidget.repaint() self.verseDeleteButton.setEnabled(False)
self.tagRows()
self.verseEditButton.setEnabled(False)
self.verseDeleteButton.setEnabled(False)
def onVerseDeleteButtonClicked(self): def onVerseDeleteButtonClicked(self):
self.verseListWidget.removeRow(self.verseListWidget.currentRow()) self.verseListWidget.removeRow(self.verseListWidget.currentRow())
@ -728,7 +721,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.song.title = unicode(self.titleEdit.text()) self.song.title = unicode(self.titleEdit.text())
self.song.alternate_title = unicode(self.alternativeEdit.text()) self.song.alternate_title = unicode(self.alternativeEdit.text())
self.song.copyright = unicode(self.copyrightEdit.text()) self.song.copyright = unicode(self.copyrightEdit.text())
# Values will be set when cleaning the song. # Values will be set when cleaning the song.
self.song.search_title = u'' self.song.search_title = u''
self.song.search_lyrics = u'' self.song.search_lyrics = u''
self.song.verse_order = u'' self.song.verse_order = u''
@ -753,7 +746,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.song.theme_name = theme_name self.song.theme_name = theme_name
else: else:
self.song.theme_name = None self.song.theme_name = None
self.processLyrics() self._processLyrics()
self.song.authors = [] self.song.authors = []
for row in range(self.authorsListView.count()): for row in range(self.authorsListView.count()):
item = self.authorsListView.item(row) item = self.authorsListView.item(row)
@ -769,12 +762,12 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
if not preview: if not preview:
self.song = None self.song = None
def processLyrics(self): def _processLyrics(self):
""" """
Process the lyric data entered by the user into the OpenLP XML format. Process the lyric data entered by the user into the OpenLP XML format.
""" """
# This method must only be run after the self.song = Song() assignment. # This method must only be run after the self.song = Song() assignment.
log.debug(u'processLyrics') log.debug(u'_processLyrics')
try: try:
sxml = SongXML() sxml = SongXML()
multiple = [] multiple = []

View File

@ -89,8 +89,8 @@ class SongXML(object):
Add a verse to the ``<lyrics>`` tag. Add a verse to the ``<lyrics>`` tag.
``type`` ``type``
A string denoting the type of verse. Possible values are *Verse*, A string denoting the type of verse. Possible values are *v*,
*Chorus*, *Bridge*, *Pre-Chorus*, *Intro*, *Ending* and *Other*. *c*, *b*, *p*, *i*, *e* and *o*.
Any other type is **not** allowed, this also includes translated Any other type is **not** allowed, this also includes translated
types. types.
@ -128,8 +128,8 @@ class SongXML(object):
The returned list has the following format:: The returned list has the following format::
[[{'lang': 'en', 'type': 'Verse', 'label': '1'}, u"English verse"], [[{'lang': 'en', 'type': 'v', 'label': '1'}, u"English verse"],
[{'lang': 'en', 'type': 'Chorus', 'label': '1'}, u"English chorus"]] [{'lang': 'en', 'type': 'c', 'label': '1'}, u"English chorus"]]
""" """
self.song_xml = None self.song_xml = None
if xml[:5] == u'<?xml': if xml[:5] == u'<?xml':
@ -451,10 +451,12 @@ class OpenLyrics(object):
if text: if text:
text += u'\n' text += u'\n'
text += u'\n'.join([unicode(line) for line in lines.line]) text += u'\n'.join([unicode(line) for line in lines.line])
verse_name = self._get(verse, u'name') verse_def = self._get(verse, u'name').lower()
verse_type_index = VerseType.from_tag(verse_name[0]) if verse_def[0] in VerseType.Tags:
verse_type = VerseType.Names[verse_type_index] verse_tag = verse_def[0]
verse_number = re.compile(u'[a-zA-Z]*').sub(u'', verse_name) else:
verse_tag = VerseType.Tags[VerseType.Other]
verse_number = re.compile(u'[a-zA-Z]*').sub(u'', verse_def)
# OpenLyrics allows e. g. "c", but we need "c1". However, this does # OpenLyrics allows e. g. "c", but we need "c1". However, this does
# not correct the verse order. # not correct the verse order.
if not verse_number: if not verse_number:
@ -462,7 +464,7 @@ class OpenLyrics(object):
lang = None lang = None
if self._get(verse, u'lang'): if self._get(verse, u'lang'):
lang = self._get(verse, u'lang') lang = self._get(verse, u'lang')
sxml.add_verse_to_lyrics(verse_type, verse_number, text, lang) sxml.add_verse_to_lyrics(verse_tag, verse_number, text, lang)
song.lyrics = unicode(sxml.extract_xml(), u'utf-8') song.lyrics = unicode(sxml.extract_xml(), u'utf-8')
# Process verse order # Process verse order
if hasattr(properties, u'verseOrder'): if hasattr(properties, u'verseOrder'):