forked from openlp/openlp
r1401
This commit is contained in:
commit
606df1fd52
|
@ -160,6 +160,16 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
|||
self._performWizard()
|
||||
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):
|
||||
"""
|
||||
Update the wizard progress page.
|
||||
|
@ -184,19 +194,27 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
|||
max_progress = 2
|
||||
# Loop through the songs list and increase for each selected item
|
||||
for i in xrange(self.songsListWidget.count()):
|
||||
if self.songsListWidget.item(i).checkState() == QtCore.Qt.Checked:
|
||||
max_progress += 1
|
||||
item = self.songsListWidget.item(i)
|
||||
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
|
||||
iterator = QtGui.QTreeWidgetItemIterator(self.biblesTreeWidget)
|
||||
while iterator.value():
|
||||
item = iterator.value()
|
||||
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
|
||||
# Loop through the themes list and increase for each selected item
|
||||
for i in xrange(self.themesListWidget.count()):
|
||||
if self.themesListWidget.item(i).checkState() == QtCore.Qt.Checked:
|
||||
max_progress += 1
|
||||
item = self.themesListWidget.item(i)
|
||||
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.progressBar.setValue(0)
|
||||
self.progressBar.setMinimum(0)
|
||||
|
@ -241,27 +259,33 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
|||
item = self.songsListWidget.item(i)
|
||||
if item.checkState() == QtCore.Qt.Checked:
|
||||
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))
|
||||
urllib.urlretrieve(u'%s%s' % (self.web, filename), destination)
|
||||
urllib.urlretrieve(u'%s%s' % (self.web, filename), destination,
|
||||
self._downloadProgress)
|
||||
# Download Bibles
|
||||
bibles_iterator = QtGui.QTreeWidgetItemIterator(self.biblesTreeWidget)
|
||||
while bibles_iterator.value():
|
||||
item = bibles_iterator.value()
|
||||
if item.parent() and item.checkState(0) == QtCore.Qt.Checked:
|
||||
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),
|
||||
os.path.join(bibles_destination, bible))
|
||||
os.path.join(bibles_destination, bible),
|
||||
self._downloadProgress)
|
||||
bibles_iterator += 1
|
||||
# Download themes
|
||||
for i in xrange(self.themesListWidget.count()):
|
||||
item = self.themesListWidget.item(i)
|
||||
if item.checkState() == QtCore.Qt.Checked:
|
||||
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),
|
||||
os.path.join(themes_destination, theme))
|
||||
os.path.join(themes_destination, theme),
|
||||
self._downloadProgress)
|
||||
# Set Default Display
|
||||
if self.displayComboBox.currentIndex() != -1:
|
||||
QtCore.QSettings().setValue(u'General/monitor',
|
||||
|
|
|
@ -32,27 +32,6 @@ from openlp.core.lib.ui import UiStrings
|
|||
|
||||
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):
|
||||
"""
|
||||
GeneralTab is the general settings tab in the settings dialog.
|
||||
|
@ -164,30 +143,6 @@ class GeneralTab(SettingsTab):
|
|||
self.displayGroupBox.setObjectName(u'displayGroupBox')
|
||||
self.displayLayout = QtGui.QGridLayout(self.displayGroupBox)
|
||||
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.setObjectName(u'overrideCheckBox')
|
||||
self.displayLayout.addWidget(self.overrideCheckBox, 2, 0, 1, 4)
|
||||
|
@ -196,26 +151,30 @@ class GeneralTab(SettingsTab):
|
|||
self.customXLabel = QtGui.QLabel(self.displayGroupBox)
|
||||
self.customXLabel.setObjectName(u'customXLabel')
|
||||
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.setMaximum(9999)
|
||||
self.displayLayout.addWidget(self.customXValueEdit, 4, 0)
|
||||
self.customYLabel = QtGui.QLabel(self.displayGroupBox)
|
||||
self.customYLabel.setObjectName(u'customYLabel')
|
||||
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.setMaximum(9999)
|
||||
self.displayLayout.addWidget(self.customYValueEdit, 4, 1)
|
||||
self.customWidthLabel = QtGui.QLabel(self.displayGroupBox)
|
||||
self.customWidthLabel.setObjectName(u'customWidthLabel')
|
||||
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.setMaximum(9999)
|
||||
self.displayLayout.addWidget(self.customWidthValueEdit, 4, 2)
|
||||
self.customHeightLabel = QtGui.QLabel(self.displayGroupBox)
|
||||
self.customHeightLabel.setObjectName(u'customHeightLabel')
|
||||
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.setMaximum(9999)
|
||||
self.displayLayout.addWidget(self.customHeightValueEdit, 4, 3)
|
||||
self.rightLayout.addWidget(self.displayGroupBox)
|
||||
self.rightLayout.addStretch()
|
||||
|
@ -223,17 +182,13 @@ class GeneralTab(SettingsTab):
|
|||
QtCore.QObject.connect(self.overrideCheckBox,
|
||||
QtCore.SIGNAL(u'toggled(bool)'), self.onOverrideCheckBoxToggled)
|
||||
QtCore.QObject.connect(self.customHeightValueEdit,
|
||||
QtCore.SIGNAL(u'textEdited(const QString&)'),
|
||||
self.onDisplayPositionChanged)
|
||||
QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayPositionChanged)
|
||||
QtCore.QObject.connect(self.customWidthValueEdit,
|
||||
QtCore.SIGNAL(u'textEdited(const QString&)'),
|
||||
self.onDisplayPositionChanged)
|
||||
QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayPositionChanged)
|
||||
QtCore.QObject.connect(self.customYValueEdit,
|
||||
QtCore.SIGNAL(u'textEdited(const QString&)'),
|
||||
self.onDisplayPositionChanged)
|
||||
QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayPositionChanged)
|
||||
QtCore.QObject.connect(self.customXValueEdit,
|
||||
QtCore.SIGNAL(u'textEdited(const QString&)'),
|
||||
self.onDisplayPositionChanged)
|
||||
QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayPositionChanged)
|
||||
# Reload the tab, as the screen resolution/count may have changed.
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'config_screen_changed'), self.load)
|
||||
|
@ -273,8 +228,7 @@ class GeneralTab(SettingsTab):
|
|||
'Automatically preview next item in service'))
|
||||
self.timeoutLabel.setText(translate('OpenLP.GeneralTab',
|
||||
'Slide loop delay:'))
|
||||
self.timeoutSpinBox.setSuffix(
|
||||
translate('OpenLP.GeneralTab', ' sec'))
|
||||
self.timeoutSpinBox.setSuffix(translate('OpenLP.GeneralTab', ' sec'))
|
||||
self.ccliGroupBox.setTitle(
|
||||
translate('OpenLP.GeneralTab', 'CCLI Details'))
|
||||
self.numberLabel.setText(UiStrings.CCLINumberLabel)
|
||||
|
@ -285,22 +239,11 @@ class GeneralTab(SettingsTab):
|
|||
# Moved from display tab
|
||||
self.displayGroupBox.setTitle(
|
||||
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',
|
||||
'Override display position'))
|
||||
self.customXLabel.setText(translate('OpenLP.GeneralTab', 'X'))
|
||||
self.customYLabel.setText(translate('OpenLP.GeneralTab', 'Y'))
|
||||
self.customHeightLabel.setText(
|
||||
translate('OpenLP.GeneralTab', 'Height'))
|
||||
self.customHeightLabel.setText(translate('OpenLP.GeneralTab', 'Height'))
|
||||
self.customWidthLabel.setText(translate('OpenLP.GeneralTab', 'Width'))
|
||||
|
||||
def load(self):
|
||||
|
@ -310,8 +253,7 @@ class GeneralTab(SettingsTab):
|
|||
settings = QtCore.QSettings()
|
||||
settings.beginGroup(self.settingsSection)
|
||||
self.monitorComboBox.clear()
|
||||
for screen in self.screens.get_screen_list():
|
||||
self.monitorComboBox.addItem(screen)
|
||||
self.monitorComboBox.addItems(self.screens.get_screen_list())
|
||||
self.numberEdit.setText(unicode(settings.value(
|
||||
u'ccli number', QtCore.QVariant(u'')).toString()))
|
||||
self.usernameEdit.setText(unicode(settings.value(
|
||||
|
@ -334,26 +276,16 @@ class GeneralTab(SettingsTab):
|
|||
QtCore.QVariant(False)).toBool())
|
||||
self.timeoutSpinBox.setValue(settings.value(u'loop delay',
|
||||
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',
|
||||
QtCore.QVariant(False)).toBool())
|
||||
self.customXValueEdit.setText(settings.value(u'x position',
|
||||
QtCore.QVariant(self.screens.current[u'size'].x())).toString())
|
||||
self.customYValueEdit.setText(settings.value(u'y position',
|
||||
QtCore.QVariant(self.screens.current[u'size'].y())).toString())
|
||||
self.customHeightValueEdit.setText(
|
||||
settings.value(u'height', QtCore.QVariant(
|
||||
self.screens.current[u'size'].height())).toString())
|
||||
self.customWidthValueEdit.setText(
|
||||
settings.value(u'width', QtCore.QVariant(
|
||||
self.screens.current[u'size'].width())).toString())
|
||||
self.customXValueEdit.setValue(settings.value(u'x position',
|
||||
QtCore.QVariant(self.screens.current[u'size'].x())).toInt()[0])
|
||||
self.customYValueEdit.setValue(settings.value(u'y position',
|
||||
QtCore.QVariant(self.screens.current[u'size'].y())).toInt()[0])
|
||||
self.customHeightValueEdit.setValue(settings.value(u'height',
|
||||
QtCore.QVariant(self.screens.current[u'size'].height())).toInt()[0])
|
||||
self.customWidthValueEdit.setValue(settings.value(u'width',
|
||||
QtCore.QVariant(self.screens.current[u'size'].width())).toInt()[0])
|
||||
settings.endGroup()
|
||||
self.customXValueEdit.setEnabled(self.overrideCheckBox.isChecked())
|
||||
self.customYValueEdit.setEnabled(self.overrideCheckBox.isChecked())
|
||||
|
@ -391,13 +323,13 @@ class GeneralTab(SettingsTab):
|
|||
settings.setValue(u'songselect password',
|
||||
QtCore.QVariant(self.passwordEdit.displayText()))
|
||||
settings.setValue(u'x position',
|
||||
QtCore.QVariant(self.customXValueEdit.text()))
|
||||
QtCore.QVariant(self.customXValueEdit.value()))
|
||||
settings.setValue(u'y position',
|
||||
QtCore.QVariant(self.customYValueEdit.text()))
|
||||
QtCore.QVariant(self.customYValueEdit.value()))
|
||||
settings.setValue(u'height',
|
||||
QtCore.QVariant(self.customHeightValueEdit.text()))
|
||||
QtCore.QVariant(self.customHeightValueEdit.value()))
|
||||
settings.setValue(u'width',
|
||||
QtCore.QVariant(self.customWidthValueEdit.text()))
|
||||
QtCore.QVariant(self.customWidthValueEdit.value()))
|
||||
settings.setValue(u'override position',
|
||||
QtCore.QVariant(self.overrideCheckBox.isChecked()))
|
||||
settings.endGroup()
|
||||
|
@ -421,10 +353,10 @@ class GeneralTab(SettingsTab):
|
|||
# Reset screens after initial definition
|
||||
if self.overrideChanged:
|
||||
self.screens.override[u'size'] = QtCore.QRect(
|
||||
int(self.customXValueEdit.validText()),
|
||||
int(self.customYValueEdit.validText()),
|
||||
int(self.customWidthValueEdit.validText()),
|
||||
int(self.customHeightValueEdit.validText()))
|
||||
self.customXValueEdit.value(),
|
||||
self.customYValueEdit.value(),
|
||||
self.customWidthValueEdit.value(),
|
||||
self.customHeightValueEdit.value())
|
||||
if self.overrideCheckBox.isChecked():
|
||||
self.screens.set_override_display()
|
||||
else:
|
||||
|
|
|
@ -80,8 +80,7 @@ class PowerpointController(PresentationController):
|
|||
log.debug(u'start_process')
|
||||
if not self.process:
|
||||
self.process = Dispatch(u'PowerPoint.Application')
|
||||
if float(self.process.Version) < 13:
|
||||
self.process.Visible = True
|
||||
self.process.Visible = True
|
||||
self.process.WindowState = 2
|
||||
|
||||
def kill(self):
|
||||
|
|
|
@ -30,19 +30,32 @@ from ctypes import *
|
|||
from ctypes.wintypes import RECT
|
||||
|
||||
class PPTViewer(QtGui.QWidget):
|
||||
"""
|
||||
Standalone Test Harness for the pptviewlib library
|
||||
"""
|
||||
def __init__(self, parent=None):
|
||||
QtGui.QWidget.__init__(self, parent)
|
||||
self.pptid = -1
|
||||
self.setWindowTitle(u'PowerPoint Viewer Test')
|
||||
|
||||
PPTLabel = QtGui.QLabel(u'Open PowerPoint file')
|
||||
slideLabel = QtGui.QLabel(u'Go to slide #')
|
||||
self.PPTEdit = QtGui.QLineEdit()
|
||||
ppt_label = QtGui.QLabel(u'Open PowerPoint file')
|
||||
slide_label = QtGui.QLabel(u'Go to slide #')
|
||||
self.pptEdit = 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()
|
||||
PPTBtn = QtGui.QPushButton(u'Open')
|
||||
PPTDlgBtn = QtGui.QPushButton(u'...')
|
||||
slideBtn = QtGui.QPushButton(u'Go')
|
||||
ppt_btn = QtGui.QPushButton(u'Open')
|
||||
ppt_dlg_btn = QtGui.QPushButton(u'...')
|
||||
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')
|
||||
next = QtGui.QPushButton(u'Next')
|
||||
blank = QtGui.QPushButton(u'Blank')
|
||||
|
@ -51,122 +64,149 @@ class PPTViewer(QtGui.QWidget):
|
|||
close = QtGui.QPushButton(u'Close')
|
||||
resume = QtGui.QPushButton(u'Resume')
|
||||
stop = QtGui.QPushButton(u'Stop')
|
||||
pptwindow = QtGui.QWidget()
|
||||
|
||||
grid = QtGui.QGridLayout()
|
||||
grid.addWidget(PPTLabel, 0, 0)
|
||||
grid.addWidget(self.PPTEdit, 0, 1)
|
||||
grid.addWidget(PPTDlgBtn, 0, 2)
|
||||
grid.addWidget(PPTBtn, 0, 3)
|
||||
grid.addWidget(slideLabel, 1, 0)
|
||||
grid.addWidget(self.slideEdit, 1, 1)
|
||||
grid.addWidget(slideBtn, 1, 3)
|
||||
grid.addWidget(prev, 2, 0)
|
||||
grid.addWidget(next, 2, 1)
|
||||
grid.addWidget(blank, 3, 0)
|
||||
grid.addWidget(unblank, 3, 1)
|
||||
grid.addWidget(restart, 4, 0)
|
||||
grid.addWidget(close, 4, 1)
|
||||
grid.addWidget(stop, 5, 0)
|
||||
grid.addWidget(resume, 5, 1)
|
||||
grid.addWidget(pptwindow, 6, 0, 10, 3)
|
||||
self.connect(PPTBtn, QtCore.SIGNAL(u'clicked()'), self.OpenClick)
|
||||
self.connect(PPTDlgBtn, QtCore.SIGNAL(u'clicked()'), self.OpenDialog)
|
||||
self.connect(slideBtn, 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)
|
||||
|
||||
row = 0
|
||||
grid.addWidget(folder_label, 0, 0)
|
||||
grid.addWidget(self.folderEdit, 0, 1)
|
||||
row = row + 1
|
||||
grid.addWidget(x_label, row, 0)
|
||||
grid.addWidget(self.xEdit, row, 1)
|
||||
grid.addWidget(y_label, row, 2)
|
||||
grid.addWidget(self.yEdit, row, 3)
|
||||
row = row + 1
|
||||
grid.addWidget(width_label, row, 0)
|
||||
grid.addWidget(self.widthEdit, row, 1)
|
||||
grid.addWidget(height_label, row, 2)
|
||||
grid.addWidget(self.heightEdit, row, 3)
|
||||
row = row + 1
|
||||
grid.addWidget(ppt_label, row, 0)
|
||||
grid.addWidget(self.pptEdit, row, 1)
|
||||
grid.addWidget(ppt_dlg_btn, row, 2)
|
||||
grid.addWidget(ppt_btn, row, 3)
|
||||
row = row + 1
|
||||
grid.addWidget(slide_label, row, 0)
|
||||
grid.addWidget(self.slideEdit, row, 1)
|
||||
grid.addWidget(slide_btn, row, 2)
|
||||
row = row + 1
|
||||
grid.addWidget(prev, row, 0)
|
||||
grid.addWidget(next, row, 1)
|
||||
row = row + 1
|
||||
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.resize(300, 150)
|
||||
|
||||
def PrevClick(self):
|
||||
if self.pptid<0: return
|
||||
pptdll.PrevStep(self.pptid)
|
||||
self.UpdateCurrSlide()
|
||||
def prevClick(self):
|
||||
if self.pptid < 0:
|
||||
return
|
||||
self.pptdll.PrevStep(self.pptid)
|
||||
self.updateCurrSlide()
|
||||
app.processEvents()
|
||||
|
||||
def NextClick(self):
|
||||
if(self.pptid<0): return
|
||||
pptdll.NextStep(self.pptid)
|
||||
self.UpdateCurrSlide()
|
||||
def nextClick(self):
|
||||
if self.pptid < 0:
|
||||
return
|
||||
self.pptdll.NextStep(self.pptid)
|
||||
self.updateCurrSlide()
|
||||
app.processEvents()
|
||||
|
||||
def BlankClick(self):
|
||||
if(self.pptid<0): return
|
||||
pptdll.Blank(self.pptid)
|
||||
def blankClick(self):
|
||||
if self.pptid < 0:
|
||||
return
|
||||
self.pptdll.Blank(self.pptid)
|
||||
app.processEvents()
|
||||
|
||||
def UnblankClick(self):
|
||||
if(self.pptid<0): return
|
||||
pptdll.Unblank(self.pptid)
|
||||
def unblankClick(self):
|
||||
if self.pptid < 0:
|
||||
return
|
||||
self.pptdll.Unblank(self.pptid)
|
||||
app.processEvents()
|
||||
|
||||
def RestartClick(self):
|
||||
if(self.pptid<0): return
|
||||
pptdll.RestartShow(self.pptid)
|
||||
self.UpdateCurrSlide()
|
||||
def restartClick(self):
|
||||
if self.pptid < 0:
|
||||
return
|
||||
self.pptdll.RestartShow(self.pptid)
|
||||
self.updateCurrSlide()
|
||||
app.processEvents()
|
||||
|
||||
def StopClick(self):
|
||||
if(self.pptid<0): return
|
||||
pptdll.Stop(self.pptid)
|
||||
def stopClick(self):
|
||||
if self.pptid < 0:
|
||||
return
|
||||
self.pptdll.Stop(self.pptid)
|
||||
app.processEvents()
|
||||
|
||||
def ResumeClick(self):
|
||||
if(self.pptid<0): return
|
||||
pptdll.Resume(self.pptid)
|
||||
def resumeClick(self):
|
||||
if self.pptid < 0:
|
||||
return
|
||||
self.pptdll.Resume(self.pptid)
|
||||
app.processEvents()
|
||||
|
||||
def CloseClick(self):
|
||||
if(self.pptid<0): return
|
||||
pptdll.ClosePPT(self.pptid)
|
||||
def closeClick(self):
|
||||
if self.pptid < 0:
|
||||
return
|
||||
self.pptdll.ClosePPT(self.pptid)
|
||||
self.pptid = -1
|
||||
app.processEvents()
|
||||
|
||||
def OpenClick(self):
|
||||
def openClick(self):
|
||||
oldid = self.pptid;
|
||||
rect = RECT(100,100,900,700)
|
||||
filename = str(self.PPTEdit.text().replace(u'/', u'\\'))
|
||||
print filename
|
||||
self.pptid = pptdll.OpenPPT(filename, None, rect, 'c:\\temp\\slide')
|
||||
print "id: " + unicode(self.pptid)
|
||||
if oldid>=0:
|
||||
pptdll.ClosePPT(oldid);
|
||||
slides = pptdll.GetSlideCount(self.pptid)
|
||||
print "slidecount: " + unicode(slides)
|
||||
self.total.setNum(pptdll.GetSlideCount(self.pptid))
|
||||
self.UpdateCurrSlide()
|
||||
rect = RECT(int(self.xEdit.text()), int(self.yEdit.text()),
|
||||
int(self.widthEdit.text()), int(self.heightEdit.text()))
|
||||
filename = str(self.pptEdit.text().replace(u'/', u'\\'))
|
||||
folder = str(self.folderEdit.text().replace(u'/', u'\\'))
|
||||
print filename, folder
|
||||
self.pptid = self.pptdll.OpenPPT(filename, None, rect, folder)
|
||||
print u'id: ' + unicode(self.pptid)
|
||||
if oldid >= 0:
|
||||
self.pptdll.ClosePPT(oldid);
|
||||
slides = self.pptdll.GetSlideCount(self.pptid)
|
||||
print u'slidecount: ' + unicode(slides)
|
||||
self.total.setNum(self.pptdll.GetSlideCount(self.pptid))
|
||||
self.updateCurrSlide()
|
||||
|
||||
def UpdateCurrSlide(self):
|
||||
if(self.pptid<0): return
|
||||
slide = unicode(pptdll.GetCurrentSlide(self.pptid))
|
||||
print "currslide: " + slide
|
||||
def updateCurrSlide(self):
|
||||
if self.pptid < 0:
|
||||
return
|
||||
slide = unicode(self.pptdll.GetCurrentSlide(self.pptid))
|
||||
print u'currslide: ' + slide
|
||||
self.slideEdit.setText(slide)
|
||||
app.processEvents()
|
||||
|
||||
def GotoClick(self):
|
||||
if(self.pptid<0): return
|
||||
def gotoClick(self):
|
||||
if self.pptid < 0:
|
||||
return
|
||||
print self.slideEdit.text()
|
||||
pptdll.GotoSlide(self.pptid, int(self.slideEdit.text()))
|
||||
self.UpdateCurrSlide()
|
||||
self.pptdll.GotoSlide(self.pptid, int(self.slideEdit.text()))
|
||||
self.updateCurrSlide()
|
||||
app.processEvents()
|
||||
|
||||
def OpenDialog(self):
|
||||
self.PPTEdit.setText(QtGui.QFileDialog.getOpenFileName(self, 'Open file'))
|
||||
def openDialog(self):
|
||||
self.pptEdit.setText(QtGui.QFileDialog.getOpenFileName(self,
|
||||
u'Open file'))
|
||||
|
||||
if __name__ == '__main__':
|
||||
#pptdll = cdll.LoadLibrary(r'C:\Documents and Settings\jonathan\Desktop\pptviewlib.dll')
|
||||
pptdll = cdll.LoadLibrary(r'pptviewlib.dll')
|
||||
pptdll.SetDebug(1)
|
||||
print "Begin..."
|
||||
print u'Begin...'
|
||||
app = QtGui.QApplication(sys.argv)
|
||||
qb = PPTViewer()
|
||||
qb.show()
|
||||
window = PPTViewer()
|
||||
window.pptdll = pptdll
|
||||
window.show()
|
||||
sys.exit(app.exec_())
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
@ -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 )
|
||||
|
||||
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 void ClosePPT(int id);
|
||||
DllExport int GetCurrentSlide(int id);
|
||||
DllExport int GetSlideCount(int id);
|
||||
DllExport void NextStep(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 Blank(int id);
|
||||
DllExport void Unblank(int id);
|
||||
DllExport void Stop(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 CwpProc(int nCode, WPARAM wParam, LPARAM lParam);
|
||||
LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam);
|
||||
BOOL GetPPTViewerPath(char *pptviewerpath, int strsize);
|
||||
HBITMAP CaptureWindow (HWND hWnd);
|
||||
VOID SaveBitmap (CHAR* filename, HBITMAP hBmp) ;
|
||||
BOOL GetPPTViewerPath(char *pptViewerPath, int stringSize);
|
||||
HBITMAP CaptureWindow(HWND hWnd);
|
||||
VOID SaveBitmap(CHAR* filename, HBITMAP hBmp) ;
|
||||
VOID CaptureAndSaveWindow(HWND hWnd, CHAR* filename);
|
||||
BOOL GetPPTInfo(int id);
|
||||
BOOL SavePPTInfo(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 mhook;
|
||||
HWND hWnd;
|
||||
HWND hWnd2;
|
||||
HWND hParentWnd;
|
||||
HANDLE hProcess;
|
||||
HANDLE hThread;
|
||||
DWORD dwProcessId;
|
||||
DWORD dwThreadId;
|
||||
RECT rect;
|
||||
int slideCount;
|
||||
int currentSlide;
|
||||
int firstSlideSteps;
|
||||
int steps;
|
||||
char filename[MAX_PATH];
|
||||
char previewpath[MAX_PATH];
|
||||
PPTVIEWSTATE state;
|
||||
HHOOK hook;
|
||||
HHOOK msgHook;
|
||||
HWND hWnd;
|
||||
HWND hWnd2;
|
||||
HWND hParentWnd;
|
||||
HANDLE hProcess;
|
||||
HANDLE hThread;
|
||||
DWORD dwProcessId;
|
||||
DWORD dwThreadId;
|
||||
RECT rect;
|
||||
int slideCount;
|
||||
int currentSlide;
|
||||
int firstSlideSteps;
|
||||
int lastSlideSteps;
|
||||
int steps;
|
||||
int guess;
|
||||
char filename[MAX_PATH];
|
||||
char previewPath[MAX_PATH];
|
||||
int slideNos[MAX_SLIDES];
|
||||
PPTVIEWSTATE state;
|
||||
};
|
||||
|
|
|
@ -297,7 +297,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
self.verseOrderEdit.setText(u' '.join(translated))
|
||||
else:
|
||||
self.verseOrderEdit.setText(u'')
|
||||
self.verseListWidget.resizeRowsToContents()
|
||||
self.tagRows()
|
||||
# clear the results
|
||||
self.authorsListView.clear()
|
||||
|
@ -312,10 +311,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
topic_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id))
|
||||
self.topicsListView.addItem(topic_name)
|
||||
self.titleEdit.setFocus(QtCore.Qt.OtherFocusReason)
|
||||
# if not preview hide the preview button
|
||||
self.previewButton.setVisible(False)
|
||||
if preview:
|
||||
self.previewButton.setVisible(True)
|
||||
# Hide or show the preview button.
|
||||
self.previewButton.setVisible(preview)
|
||||
|
||||
def tagRows(self):
|
||||
"""
|
||||
|
@ -329,6 +326,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
row_def = u'%s%s' % (verse_tag, verse_def[1:])
|
||||
row_label.append(row_def)
|
||||
self.verseListWidget.setVerticalHeaderLabels(row_label)
|
||||
self.verseListWidget.setColumnWidth(0, self.width)
|
||||
self.verseListWidget.resizeRowsToContents()
|
||||
self.verseListWidget.repaint()
|
||||
|
||||
def onAuthorAddButtonClicked(self):
|
||||
item = int(self.authorsComboBox.currentIndex())
|
||||
|
@ -453,9 +453,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
self.verseListWidget.setRowCount(
|
||||
self.verseListWidget.rowCount() + 1)
|
||||
self.verseListWidget.setItem(
|
||||
int(self.verseListWidget.rowCount() - 1), 0, item)
|
||||
self.verseListWidget.setColumnWidth(0, self.width)
|
||||
self.verseListWidget.resizeRowsToContents()
|
||||
self.verseListWidget.rowCount() - 1, 0, item)
|
||||
self.tagRows()
|
||||
|
||||
def onVerseEditButtonClicked(self):
|
||||
|
@ -482,8 +480,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
item = QtGui.QTableWidgetItem(tempList[row], 0)
|
||||
item.setData(QtCore.Qt.UserRole, tempId[row])
|
||||
self.verseListWidget.setItem(row, 0, item)
|
||||
self.verseListWidget.resizeRowsToContents()
|
||||
self.verseListWidget.repaint()
|
||||
self.tagRows()
|
||||
|
||||
def onVerseEditAllButtonClicked(self):
|
||||
|
@ -500,53 +496,50 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
self.verse_form.setVerse(verse_list)
|
||||
else:
|
||||
self.verse_form.setVerse(u'')
|
||||
if self.verse_form.exec_():
|
||||
verse_list = self.verse_form.getVerseAll()
|
||||
verse_list = unicode(verse_list.replace(u'\r\n', u'\n'))
|
||||
self.verseListWidget.clear()
|
||||
self.verseListWidget.setRowCount(0)
|
||||
for row in self.findVerseSplit.split(verse_list):
|
||||
for match in row.split(u'---['):
|
||||
for count, parts in enumerate(match.split(u']---\n')):
|
||||
if len(parts) > 1:
|
||||
if count == 0:
|
||||
# handling carefully user inputted versetags
|
||||
separator = parts.find(u':')
|
||||
if separator >= 0:
|
||||
verse_name = parts[0:separator].strip()
|
||||
verse_num = parts[separator+1:].strip()
|
||||
else:
|
||||
verse_name = parts
|
||||
verse_num = u'1'
|
||||
verse_index = \
|
||||
VerseType.from_loose_input(verse_name)
|
||||
verse_tag = VerseType.Tags[verse_index]
|
||||
# Later we need to handle v1a as well.
|
||||
#regex = re.compile(r'(\d+\w.)')
|
||||
regex = re.compile(r'\D*(\d+)\D*')
|
||||
match = regex.match(verse_num)
|
||||
if match:
|
||||
verse_num = match.group(1)
|
||||
else:
|
||||
verse_num = u'1'
|
||||
verse_def = u'%s%s' % (verse_tag, verse_num)
|
||||
else:
|
||||
if parts.endswith(u'\n'):
|
||||
parts = parts.rstrip(u'\n')
|
||||
item = QtGui.QTableWidgetItem(parts)
|
||||
item.setData(QtCore.Qt.UserRole,
|
||||
QtCore.QVariant(verse_def))
|
||||
self.verseListWidget.setRowCount(
|
||||
self.verseListWidget.rowCount() + 1)
|
||||
self.verseListWidget.setItem(
|
||||
int(self.verseListWidget.rowCount() - 1),
|
||||
0, item)
|
||||
self.verseListWidget.setColumnWidth(0, self.width)
|
||||
self.verseListWidget.resizeRowsToContents()
|
||||
self.verseListWidget.repaint()
|
||||
self.tagRows()
|
||||
self.verseEditButton.setEnabled(False)
|
||||
self.verseDeleteButton.setEnabled(False)
|
||||
if not self.verse_form.exec_():
|
||||
return
|
||||
verse_list = self.verse_form.getVerseAll()
|
||||
verse_list = unicode(verse_list.replace(u'\r\n', u'\n'))
|
||||
self.verseListWidget.clear()
|
||||
self.verseListWidget.setRowCount(0)
|
||||
for row in self.findVerseSplit.split(verse_list):
|
||||
for match in row.split(u'---['):
|
||||
for count, parts in enumerate(match.split(u']---\n')):
|
||||
if len(parts) <= 1:
|
||||
continue
|
||||
if count == 0:
|
||||
# handling carefully user inputted versetags
|
||||
separator = parts.find(u':')
|
||||
if separator >= 0:
|
||||
verse_name = parts[0:separator].strip()
|
||||
verse_num = parts[separator+1:].strip()
|
||||
else:
|
||||
verse_name = parts
|
||||
verse_num = u'1'
|
||||
verse_index = VerseType.from_loose_input(verse_name)
|
||||
verse_tag = VerseType.Tags[verse_index]
|
||||
# Later we need to handle v1a as well.
|
||||
#regex = re.compile(r'(\d+\w.)')
|
||||
regex = re.compile(r'\D*(\d+)\D*')
|
||||
match = regex.match(verse_num)
|
||||
if match:
|
||||
verse_num = match.group(1)
|
||||
else:
|
||||
verse_num = u'1'
|
||||
verse_def = u'%s%s' % (verse_tag, verse_num)
|
||||
else:
|
||||
if parts.endswith(u'\n'):
|
||||
parts = parts.rstrip(u'\n')
|
||||
item = QtGui.QTableWidgetItem(parts)
|
||||
item.setData(QtCore.Qt.UserRole,
|
||||
QtCore.QVariant(verse_def))
|
||||
self.verseListWidget.setRowCount(
|
||||
self.verseListWidget.rowCount() + 1)
|
||||
self.verseListWidget.setItem(
|
||||
self.verseListWidget.rowCount() - 1, 0, item)
|
||||
self.tagRows()
|
||||
self.verseEditButton.setEnabled(False)
|
||||
self.verseDeleteButton.setEnabled(False)
|
||||
|
||||
def onVerseDeleteButtonClicked(self):
|
||||
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.alternate_title = unicode(self.alternativeEdit.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_lyrics = u''
|
||||
self.song.verse_order = u''
|
||||
|
@ -753,7 +746,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
self.song.theme_name = theme_name
|
||||
else:
|
||||
self.song.theme_name = None
|
||||
self.processLyrics()
|
||||
self._processLyrics()
|
||||
self.song.authors = []
|
||||
for row in range(self.authorsListView.count()):
|
||||
item = self.authorsListView.item(row)
|
||||
|
@ -769,12 +762,12 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||
if not preview:
|
||||
self.song = None
|
||||
|
||||
def processLyrics(self):
|
||||
def _processLyrics(self):
|
||||
"""
|
||||
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.
|
||||
log.debug(u'processLyrics')
|
||||
log.debug(u'_processLyrics')
|
||||
try:
|
||||
sxml = SongXML()
|
||||
multiple = []
|
||||
|
|
|
@ -89,8 +89,8 @@ class SongXML(object):
|
|||
Add a verse to the ``<lyrics>`` tag.
|
||||
|
||||
``type``
|
||||
A string denoting the type of verse. Possible values are *Verse*,
|
||||
*Chorus*, *Bridge*, *Pre-Chorus*, *Intro*, *Ending* and *Other*.
|
||||
A string denoting the type of verse. Possible values are *v*,
|
||||
*c*, *b*, *p*, *i*, *e* and *o*.
|
||||
Any other type is **not** allowed, this also includes translated
|
||||
types.
|
||||
|
||||
|
@ -128,8 +128,8 @@ class SongXML(object):
|
|||
|
||||
The returned list has the following format::
|
||||
|
||||
[[{'lang': 'en', 'type': 'Verse', 'label': '1'}, u"English verse"],
|
||||
[{'lang': 'en', 'type': 'Chorus', 'label': '1'}, u"English chorus"]]
|
||||
[[{'lang': 'en', 'type': 'v', 'label': '1'}, u"English verse"],
|
||||
[{'lang': 'en', 'type': 'c', 'label': '1'}, u"English chorus"]]
|
||||
"""
|
||||
self.song_xml = None
|
||||
if xml[:5] == u'<?xml':
|
||||
|
@ -451,10 +451,12 @@ class OpenLyrics(object):
|
|||
if text:
|
||||
text += u'\n'
|
||||
text += u'\n'.join([unicode(line) for line in lines.line])
|
||||
verse_name = self._get(verse, u'name')
|
||||
verse_type_index = VerseType.from_tag(verse_name[0])
|
||||
verse_type = VerseType.Names[verse_type_index]
|
||||
verse_number = re.compile(u'[a-zA-Z]*').sub(u'', verse_name)
|
||||
verse_def = self._get(verse, u'name').lower()
|
||||
if verse_def[0] in VerseType.Tags:
|
||||
verse_tag = verse_def[0]
|
||||
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
|
||||
# not correct the verse order.
|
||||
if not verse_number:
|
||||
|
@ -462,7 +464,7 @@ class OpenLyrics(object):
|
|||
lang = None
|
||||
if 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')
|
||||
# Process verse order
|
||||
if hasattr(properties, u'verseOrder'):
|
||||
|
|
Loading…
Reference in New Issue