forked from openlp/openlp
Head
This commit is contained in:
commit
47713f52e4
@ -78,9 +78,7 @@ class OpenLP(QtGui.QApplication):
|
|||||||
Run the OpenLP application.
|
Run the OpenLP application.
|
||||||
"""
|
"""
|
||||||
#Load and store current Application Version
|
#Load and store current Application Version
|
||||||
filepath = AppLocation.get_directory(AppLocation.AppDir)
|
filepath = AppLocation.get_directory(AppLocation.VersionDir)
|
||||||
if not hasattr(sys, u'frozen'):
|
|
||||||
filepath = os.path.join(filepath, u'openlp')
|
|
||||||
filepath = os.path.join(filepath, u'.version')
|
filepath = os.path.join(filepath, u'.version')
|
||||||
fversion = None
|
fversion = None
|
||||||
try:
|
try:
|
||||||
|
@ -139,8 +139,9 @@ class PluginConfig(object):
|
|||||||
list = []
|
list = []
|
||||||
if list_count > 0:
|
if list_count > 0:
|
||||||
for counter in range(0, list_count):
|
for counter in range(0, list_count):
|
||||||
item = unicode(self.get_config(u'%s %d' % (name, counter)))
|
item = self.get_config(u'%s %d' % (name, counter))
|
||||||
list.append(item)
|
if item:
|
||||||
|
list.append(item)
|
||||||
return list
|
return list
|
||||||
|
|
||||||
def set_list(self, name, list):
|
def set_list(self, name, list):
|
||||||
|
@ -47,6 +47,7 @@ class ItemCapabilities(object):
|
|||||||
AllowsEdit = 2
|
AllowsEdit = 2
|
||||||
AllowsMaintain = 3
|
AllowsMaintain = 3
|
||||||
RequiresMedia = 4
|
RequiresMedia = 4
|
||||||
|
AllowsLoop = 5
|
||||||
|
|
||||||
|
|
||||||
class ServiceItem(object):
|
class ServiceItem(object):
|
||||||
|
@ -28,6 +28,7 @@ from servicenoteform import ServiceNoteForm
|
|||||||
from serviceitemeditform import ServiceItemEditForm
|
from serviceitemeditform import ServiceItemEditForm
|
||||||
from screen import ScreenList
|
from screen import ScreenList
|
||||||
from maindisplay import MainDisplay
|
from maindisplay import MainDisplay
|
||||||
|
from maindisplay import VideoDisplay
|
||||||
from amendthemeform import AmendThemeForm
|
from amendthemeform import AmendThemeForm
|
||||||
from slidecontroller import SlideController
|
from slidecontroller import SlideController
|
||||||
from splashscreen import SplashScreen
|
from splashscreen import SplashScreen
|
||||||
|
@ -95,13 +95,9 @@ class MainDisplay(DisplayWidget):
|
|||||||
DisplayWidget.__init__(self, None)
|
DisplayWidget.__init__(self, None)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.setWindowTitle(u'OpenLP Display')
|
self.setWindowTitle(u'OpenLP Display')
|
||||||
|
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
|
||||||
|
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
|
||||||
self.screens = screens
|
self.screens = screens
|
||||||
self.mediaObject = Phonon.MediaObject(self)
|
|
||||||
self.video = Phonon.VideoWidget()
|
|
||||||
self.video.setVisible(False)
|
|
||||||
self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self.mediaObject)
|
|
||||||
Phonon.createPath(self.mediaObject, self.video)
|
|
||||||
Phonon.createPath(self.mediaObject, self.audio)
|
|
||||||
self.display_image = QtGui.QLabel(self)
|
self.display_image = QtGui.QLabel(self)
|
||||||
self.display_image.setScaledContents(True)
|
self.display_image.setScaledContents(True)
|
||||||
self.display_text = QtGui.QLabel(self)
|
self.display_text = QtGui.QLabel(self)
|
||||||
@ -113,25 +109,14 @@ class MainDisplay(DisplayWidget):
|
|||||||
self.blankFrame = None
|
self.blankFrame = None
|
||||||
self.frame = None
|
self.frame = None
|
||||||
self.firstTime = True
|
self.firstTime = True
|
||||||
self.mediaLoaded = False
|
|
||||||
self.hasTransition = False
|
self.hasTransition = False
|
||||||
self.mediaBackground = False
|
self.mediaBackground = False
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'live_slide_hide'), self.hideDisplay)
|
QtCore.SIGNAL(u'live_slide_hide'), self.hideDisplay)
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'live_slide_show'), self.showDisplay)
|
QtCore.SIGNAL(u'live_slide_show'), self.showDisplay)
|
||||||
QtCore.QObject.connect(self.mediaObject,
|
|
||||||
QtCore.SIGNAL(u'finished()'), self.onMediaFinish)
|
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'media_start'), self.onMediaQueue)
|
QtCore.SIGNAL(u'media_start'), self.onMediaQueue)
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
|
||||||
QtCore.SIGNAL(u'media_play'), self.onMediaPlay)
|
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
|
||||||
QtCore.SIGNAL(u'media_pause'), self.onMediaPause)
|
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
|
||||||
QtCore.SIGNAL(u'media_stop'), self.onMediaStop)
|
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
|
||||||
QtCore.SIGNAL(u'update_config'), self.setup)
|
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
"""
|
"""
|
||||||
@ -144,7 +129,6 @@ class MainDisplay(DisplayWidget):
|
|||||||
#Sort out screen locations and sizes
|
#Sort out screen locations and sizes
|
||||||
self.setGeometry(self.screen[u'size'])
|
self.setGeometry(self.screen[u'size'])
|
||||||
self.display_alert.setGeometry(self.screen[u'size'])
|
self.display_alert.setGeometry(self.screen[u'size'])
|
||||||
self.video.setGeometry(self.screen[u'size'])
|
|
||||||
self.display_image.resize(self.screen[u'size'].width(),
|
self.display_image.resize(self.screen[u'size'].width(),
|
||||||
self.screen[u'size'].height())
|
self.screen[u'size'].height())
|
||||||
self.display_text.resize(self.screen[u'size'].width(),
|
self.display_text.resize(self.screen[u'size'].width(),
|
||||||
@ -177,6 +161,7 @@ class MainDisplay(DisplayWidget):
|
|||||||
self.screen[u'size'].height())
|
self.screen[u'size'].height())
|
||||||
self.transparent.fill(QtCore.Qt.transparent)
|
self.transparent.fill(QtCore.Qt.transparent)
|
||||||
self.display_alert.setPixmap(self.transparent)
|
self.display_alert.setPixmap(self.transparent)
|
||||||
|
self.display_text.setPixmap(self.transparent)
|
||||||
self.frameView(self.transparent)
|
self.frameView(self.transparent)
|
||||||
# To display or not to display?
|
# To display or not to display?
|
||||||
if not self.screen[u'primary']:
|
if not self.screen[u'primary']:
|
||||||
@ -187,6 +172,7 @@ class MainDisplay(DisplayWidget):
|
|||||||
self.primary = True
|
self.primary = True
|
||||||
|
|
||||||
def resetDisplay(self):
|
def resetDisplay(self):
|
||||||
|
log.debug(u'resetDisplay')
|
||||||
Receiver.send_message(u'stop_display_loop')
|
Receiver.send_message(u'stop_display_loop')
|
||||||
if self.primary:
|
if self.primary:
|
||||||
self.setVisible(False)
|
self.setVisible(False)
|
||||||
@ -194,28 +180,33 @@ class MainDisplay(DisplayWidget):
|
|||||||
self.showFullScreen()
|
self.showFullScreen()
|
||||||
|
|
||||||
def hideDisplay(self):
|
def hideDisplay(self):
|
||||||
self.mediaLoaded = True
|
log.debug(u'hideDisplay')
|
||||||
self.setVisible(False)
|
self.display_image.setPixmap(self.transparent)
|
||||||
|
self.display_alert.setPixmap(self.transparent)
|
||||||
|
self.display_text.setPixmap(self.transparent)
|
||||||
|
|
||||||
def showDisplay(self):
|
def showDisplay(self):
|
||||||
self.mediaLoaded = False
|
log.debug(u'showDisplay')
|
||||||
if not self.primary:
|
if not self.primary:
|
||||||
self.setVisible(True)
|
self.setVisible(True)
|
||||||
self.showFullScreen()
|
self.showFullScreen()
|
||||||
Receiver.send_message(u'flush_alert')
|
Receiver.send_message(u'flush_alert')
|
||||||
|
|
||||||
def addImageWithText(self, frame):
|
def addImageWithText(self, frame):
|
||||||
|
log.debug(u'addImageWithText')
|
||||||
frame = resize_image(frame,
|
frame = resize_image(frame,
|
||||||
self.screen[u'size'].width(),
|
self.screen[u'size'].width(),
|
||||||
self.screen[u'size'].height() )
|
self.screen[u'size'].height() )
|
||||||
self.display_image.setPixmap(QtGui.QPixmap.fromImage(frame))
|
self.display_image.setPixmap(QtGui.QPixmap.fromImage(frame))
|
||||||
|
|
||||||
def setAlertSize(self, top, height):
|
def setAlertSize(self, top, height):
|
||||||
|
log.debug(u'setAlertSize')
|
||||||
self.display_alert.setGeometry(
|
self.display_alert.setGeometry(
|
||||||
QtCore.QRect(0, top,
|
QtCore.QRect(0, top,
|
||||||
self.screen[u'size'].width(), height))
|
self.screen[u'size'].width(), height))
|
||||||
|
|
||||||
def addAlertImage(self, frame, blank=False):
|
def addAlertImage(self, frame, blank=False):
|
||||||
|
log.debug(u'addAlertImage')
|
||||||
if blank:
|
if blank:
|
||||||
self.display_alert.setPixmap(self.transparent)
|
self.display_alert.setPixmap(self.transparent)
|
||||||
else:
|
else:
|
||||||
@ -277,48 +268,134 @@ class MainDisplay(DisplayWidget):
|
|||||||
|
|
||||||
def onMediaQueue(self, message):
|
def onMediaQueue(self, message):
|
||||||
log.debug(u'Queue new media message %s' % message)
|
log.debug(u'Queue new media message %s' % message)
|
||||||
self.display_image.close()
|
self.hideDisplay()
|
||||||
self.display_text.close()
|
self.activateWindow()
|
||||||
self.display_alert.close()
|
|
||||||
|
class VideoWidget(QtGui.QWidget):
|
||||||
|
"""
|
||||||
|
Customised version of QTableWidget which can respond to keyboard
|
||||||
|
events.
|
||||||
|
"""
|
||||||
|
log.info(u'MainDisplay loaded')
|
||||||
|
|
||||||
|
def __init__(self, parent=None, name=None):
|
||||||
|
QtGui.QWidget.__init__(self, None)
|
||||||
|
self.parent = parent
|
||||||
|
self.hotkey_map = {QtCore.Qt.Key_Return: 'servicemanager_next_item',
|
||||||
|
QtCore.Qt.Key_Space: 'live_slidecontroller_next_noloop',
|
||||||
|
QtCore.Qt.Key_Enter: 'live_slidecontroller_next_noloop',
|
||||||
|
QtCore.Qt.Key_0: 'servicemanager_next_item',
|
||||||
|
QtCore.Qt.Key_Backspace: 'live_slidecontroller_previous_noloop'}
|
||||||
|
|
||||||
|
def keyPressEvent(self, event):
|
||||||
|
if type(event) == QtGui.QKeyEvent:
|
||||||
|
#here accept the event and do something
|
||||||
|
if event.key() == QtCore.Qt.Key_Up:
|
||||||
|
Receiver.send_message(u'live_slidecontroller_previous')
|
||||||
|
event.accept()
|
||||||
|
elif event.key() == QtCore.Qt.Key_Down:
|
||||||
|
Receiver.send_message(u'live_slidecontroller_next')
|
||||||
|
event.accept()
|
||||||
|
elif event.key() == QtCore.Qt.Key_PageUp:
|
||||||
|
Receiver.send_message(u'live_slidecontroller_first')
|
||||||
|
event.accept()
|
||||||
|
elif event.key() == QtCore.Qt.Key_PageDown:
|
||||||
|
Receiver.send_message(u'live_slidecontroller_last')
|
||||||
|
event.accept()
|
||||||
|
elif event.key() in self.hotkey_map:
|
||||||
|
Receiver.send_message(self.hotkey_map[event.key()])
|
||||||
|
event.accept()
|
||||||
|
elif event.key() == QtCore.Qt.Key_Escape:
|
||||||
|
self.resetDisplay()
|
||||||
|
event.accept()
|
||||||
|
event.ignore()
|
||||||
|
else:
|
||||||
|
event.ignore()
|
||||||
|
|
||||||
|
class VideoDisplay(VideoWidget):
|
||||||
|
"""
|
||||||
|
This is the form that is used to display videos on the projector.
|
||||||
|
"""
|
||||||
|
log.info(u'VideoDisplay Loaded')
|
||||||
|
|
||||||
|
def __init__(self, parent, screens):
|
||||||
|
"""
|
||||||
|
The constructor for the display form.
|
||||||
|
|
||||||
|
``parent``
|
||||||
|
The parent widget.
|
||||||
|
|
||||||
|
``screens``
|
||||||
|
The list of screens.
|
||||||
|
"""
|
||||||
|
log.debug(u'VideoDisplay Initilisation started')
|
||||||
|
VideoWidget.__init__(self, parent)
|
||||||
|
self.setWindowTitle(u'OpenLP Video Display')
|
||||||
|
self.parent = parent
|
||||||
|
self.screens = screens
|
||||||
|
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
|
||||||
|
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
|
||||||
|
self.mediaObject = Phonon.MediaObject(self)
|
||||||
|
self.video = Phonon.VideoWidget()
|
||||||
|
self.video.setVisible(False)
|
||||||
|
self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self.mediaObject)
|
||||||
|
Phonon.createPath(self.mediaObject, self.video)
|
||||||
|
Phonon.createPath(self.mediaObject, self.audio)
|
||||||
|
self.firstTime = True
|
||||||
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
|
QtCore.SIGNAL(u'media_start'), self.onMediaQueue)
|
||||||
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
|
QtCore.SIGNAL(u'media_play'), self.onMediaPlay)
|
||||||
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
|
QtCore.SIGNAL(u'media_pause'), self.onMediaPause)
|
||||||
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
|
QtCore.SIGNAL(u'media_stop'), self.onMediaStop)
|
||||||
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
|
QtCore.SIGNAL(u'update_config'), self.setup)
|
||||||
|
|
||||||
|
def setup(self):
|
||||||
|
"""
|
||||||
|
Sets up the screen on a particular screen.
|
||||||
|
"""
|
||||||
|
log.debug(u'VideoDisplay Setup %s for %s ' %(self.screens,
|
||||||
|
self.screens.monitor_number))
|
||||||
|
self.setVisible(False)
|
||||||
|
self.screen = self.screens.current
|
||||||
|
#Sort out screen locations and sizes
|
||||||
|
self.setGeometry(self.screen[u'size'])
|
||||||
|
self.video.setGeometry(self.screen[u'size'])
|
||||||
|
|
||||||
|
def onMediaQueue(self, message):
|
||||||
|
log.debug(u'VideoDisplay Queue new media message %s' % message)
|
||||||
file = os.path.join(message[1], message[2])
|
file = os.path.join(message[1], message[2])
|
||||||
if self.firstTime:
|
if self.firstTime:
|
||||||
self.mediaObject.setCurrentSource(Phonon.MediaSource(file))
|
source = self.mediaObject.setCurrentSource(Phonon.MediaSource(file))
|
||||||
self.firstTime = False
|
self.firstTime = False
|
||||||
else:
|
else:
|
||||||
self.mediaObject.enqueue(Phonon.MediaSource(file))
|
self.mediaObject.enqueue(Phonon.MediaSource(file))
|
||||||
self.onMediaPlay()
|
self.onMediaPlay()
|
||||||
|
|
||||||
def onMediaPlay(self):
|
def onMediaPlay(self):
|
||||||
log.debug(u'Play the new media, Live ')
|
log.debug(u'VideoDisplay Play the new media, Live ')
|
||||||
if not self.mediaLoaded and not self.displayBlank:
|
|
||||||
self.blankDisplay()
|
|
||||||
self.display_frame = self.blankFrame
|
|
||||||
self.firstTime = True
|
self.firstTime = True
|
||||||
self.mediaLoaded = True
|
self.setWindowState(QtCore.Qt.WindowMinimized)
|
||||||
self.display_image.hide()
|
|
||||||
self.display_text.hide()
|
|
||||||
self.display_alert.hide()
|
|
||||||
self.video.setFullScreen(True)
|
self.video.setFullScreen(True)
|
||||||
self.video.setVisible(True)
|
|
||||||
self.mediaObject.play()
|
self.mediaObject.play()
|
||||||
self.setVisible(True)
|
self.setVisible(True)
|
||||||
self.hide()
|
self.lower()
|
||||||
|
|
||||||
def onMediaPause(self):
|
def onMediaPause(self):
|
||||||
log.debug(u'Media paused by user')
|
log.debug(u'VideoDisplay Media paused by user')
|
||||||
self.mediaObject.pause()
|
self.mediaObject.pause()
|
||||||
|
|
||||||
def onMediaStop(self):
|
def onMediaStop(self):
|
||||||
log.debug(u'Media stopped by user')
|
log.debug(u'VideoDisplay Media stopped by user')
|
||||||
self.mediaObject.stop()
|
self.mediaObject.stop()
|
||||||
self.onMediaFinish()
|
self.onMediaFinish()
|
||||||
|
|
||||||
def onMediaFinish(self):
|
def onMediaFinish(self):
|
||||||
log.debug(u'Reached end of media playlist')
|
log.debug(u'VideoDisplay Reached end of media playlist')
|
||||||
self.mediaObject.stop()
|
self.mediaObject.stop()
|
||||||
self.mediaObject.clearQueue()
|
self.mediaObject.clearQueue()
|
||||||
self.mediaLoaded = False
|
|
||||||
self.video.setVisible(False)
|
self.video.setVisible(False)
|
||||||
self.display_text.show()
|
self.setVisible(False)
|
||||||
self.display_image.show()
|
|
||||||
self.blankDisplay(False, False)
|
|
||||||
|
@ -30,7 +30,7 @@ from PyQt4 import QtCore, QtGui
|
|||||||
|
|
||||||
from openlp.core.ui import AboutForm, SettingsForm, \
|
from openlp.core.ui import AboutForm, SettingsForm, \
|
||||||
ServiceManager, ThemeManager, MainDisplay, SlideController, \
|
ServiceManager, ThemeManager, MainDisplay, SlideController, \
|
||||||
PluginForm, MediaDockManager
|
PluginForm, MediaDockManager, VideoDisplay
|
||||||
from openlp.core.lib import RenderManager, PluginConfig, build_icon, \
|
from openlp.core.lib import RenderManager, PluginConfig, build_icon, \
|
||||||
OpenLPDockWidget, SettingsManager, PluginManager, Receiver, str_to_bool
|
OpenLPDockWidget, SettingsManager, PluginManager, Receiver, str_to_bool
|
||||||
from openlp.core.utils import check_latest_version, AppLocation
|
from openlp.core.utils import check_latest_version, AppLocation
|
||||||
@ -443,6 +443,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
self.serviceNotSaved = False
|
self.serviceNotSaved = False
|
||||||
self.settingsmanager = SettingsManager(screens)
|
self.settingsmanager = SettingsManager(screens)
|
||||||
self.generalConfig = PluginConfig(u'General')
|
self.generalConfig = PluginConfig(u'General')
|
||||||
|
self.videoDisplay = VideoDisplay(self, screens)
|
||||||
self.mainDisplay = MainDisplay(self, screens)
|
self.mainDisplay = MainDisplay(self, screens)
|
||||||
self.aboutForm = AboutForm(self, applicationVersion)
|
self.aboutForm = AboutForm(self, applicationVersion)
|
||||||
self.settingsForm = SettingsForm(self.screens, self, self)
|
self.settingsForm = SettingsForm(self.screens, self, self)
|
||||||
@ -572,11 +573,14 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
self.showMaximized()
|
self.showMaximized()
|
||||||
#screen_number = self.getMonitorNumber()
|
#screen_number = self.getMonitorNumber()
|
||||||
self.mainDisplay.setup()
|
self.mainDisplay.setup()
|
||||||
|
self.videoDisplay.setup()
|
||||||
if self.mainDisplay.isVisible():
|
if self.mainDisplay.isVisible():
|
||||||
self.mainDisplay.setFocus()
|
self.mainDisplay.setFocus()
|
||||||
self.activateWindow()
|
self.activateWindow()
|
||||||
if str_to_bool(self.generalConfig.get_config(u'auto open', False)):
|
if str_to_bool(self.generalConfig.get_config(u'auto open', False)):
|
||||||
self.ServiceManagerContents.onLoadService(True)
|
self.ServiceManagerContents.onLoadService(True)
|
||||||
|
self.videoDisplay.lower()
|
||||||
|
self.mainDisplay.raise_()
|
||||||
|
|
||||||
def blankCheck(self):
|
def blankCheck(self):
|
||||||
if str_to_bool(self.generalConfig.get_config(u'screen blank', False)) \
|
if str_to_bool(self.generalConfig.get_config(u'screen blank', False)) \
|
||||||
@ -633,16 +637,19 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
if ret == QtGui.QMessageBox.Save:
|
if ret == QtGui.QMessageBox.Save:
|
||||||
self.ServiceManagerContents.onSaveService()
|
self.ServiceManagerContents.onSaveService()
|
||||||
self.mainDisplay.close()
|
self.mainDisplay.close()
|
||||||
|
self.videoDisplay.close()
|
||||||
self.cleanUp()
|
self.cleanUp()
|
||||||
event.accept()
|
event.accept()
|
||||||
elif ret == QtGui.QMessageBox.Discard:
|
elif ret == QtGui.QMessageBox.Discard:
|
||||||
self.mainDisplay.close()
|
self.mainDisplay.close()
|
||||||
|
self.videoDisplay.close()
|
||||||
self.cleanUp()
|
self.cleanUp()
|
||||||
event.accept()
|
event.accept()
|
||||||
else:
|
else:
|
||||||
event.ignore()
|
event.ignore()
|
||||||
else:
|
else:
|
||||||
self.mainDisplay.close()
|
self.mainDisplay.close()
|
||||||
|
self.videoDisplay.close()
|
||||||
self.cleanUp()
|
self.cleanUp()
|
||||||
event.accept()
|
event.accept()
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ class SlideController(QtGui.QWidget):
|
|||||||
self.isLive = isLive
|
self.isLive = isLive
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.songsconfig = PluginConfig(u'Songs')
|
self.songsconfig = PluginConfig(u'Songs')
|
||||||
self.image_list = [
|
self.loop_list = [
|
||||||
u'Start Loop',
|
u'Start Loop',
|
||||||
u'Stop Loop',
|
u'Stop Loop',
|
||||||
u'Loop Separator',
|
u'Loop Separator',
|
||||||
@ -233,6 +233,12 @@ class SlideController(QtGui.QWidget):
|
|||||||
self.Mediabar.addToolbarButton(
|
self.Mediabar.addToolbarButton(
|
||||||
u'Media Stop', u':/slides/media_playback_stop.png',
|
u'Media Stop', u':/slides/media_playback_stop.png',
|
||||||
self.trUtf8('Start playing media'), self.onMediaStop)
|
self.trUtf8('Start playing media'), self.onMediaStop)
|
||||||
|
if not self.isLive:
|
||||||
|
self.seekSlider = Phonon.SeekSlider()
|
||||||
|
self.seekSlider.setGeometry(QtCore.QRect(90, 260, 221, 24))
|
||||||
|
self.seekSlider.setObjectName(u'seekSlider')
|
||||||
|
self.Mediabar.addToolbarWidget(
|
||||||
|
u'Seek Slider', self.seekSlider)
|
||||||
self.volumeSlider = Phonon.VolumeSlider()
|
self.volumeSlider = Phonon.VolumeSlider()
|
||||||
self.volumeSlider.setGeometry(QtCore.QRect(90, 260, 221, 24))
|
self.volumeSlider.setGeometry(QtCore.QRect(90, 260, 221, 24))
|
||||||
self.volumeSlider.setObjectName(u'volumeSlider')
|
self.volumeSlider.setObjectName(u'volumeSlider')
|
||||||
@ -299,7 +305,7 @@ class SlideController(QtGui.QWidget):
|
|||||||
QtCore.SIGNAL(u'update_spin_delay'), self.receiveSpinDelay)
|
QtCore.SIGNAL(u'update_spin_delay'), self.receiveSpinDelay)
|
||||||
Receiver.send_message(u'request_spin_delay')
|
Receiver.send_message(u'request_spin_delay')
|
||||||
if isLive:
|
if isLive:
|
||||||
self.Toolbar.makeWidgetsInvisible(self.image_list)
|
self.Toolbar.makeWidgetsInvisible(self.loop_list)
|
||||||
else:
|
else:
|
||||||
self.Toolbar.makeWidgetsInvisible(self.song_edit_list)
|
self.Toolbar.makeWidgetsInvisible(self.song_edit_list)
|
||||||
self.Mediabar.setVisible(False)
|
self.Mediabar.setVisible(False)
|
||||||
@ -374,20 +380,19 @@ class SlideController(QtGui.QWidget):
|
|||||||
self.Toolbar.setVisible(True)
|
self.Toolbar.setVisible(True)
|
||||||
self.Mediabar.setVisible(False)
|
self.Mediabar.setVisible(False)
|
||||||
self.Toolbar.makeWidgetsInvisible([u'Song Menu'])
|
self.Toolbar.makeWidgetsInvisible([u'Song Menu'])
|
||||||
self.Toolbar.makeWidgetsInvisible(self.image_list)
|
self.Toolbar.makeWidgetsInvisible(self.loop_list)
|
||||||
if item.is_text():
|
if item.is_text():
|
||||||
self.Toolbar.makeWidgetsInvisible(self.image_list)
|
self.Toolbar.makeWidgetsInvisible(self.loop_list)
|
||||||
if str_to_bool(self.songsconfig.get_config(u'show songbar', True)) \
|
if str_to_bool(self.songsconfig.get_config(u'show songbar', True)) \
|
||||||
and len(self.slideList) > 0:
|
and len(self.slideList) > 0:
|
||||||
self.Toolbar.makeWidgetsVisible([u'Song Menu'])
|
self.Toolbar.makeWidgetsVisible([u'Song Menu'])
|
||||||
elif item.is_image():
|
if item.is_capable(ItemCapabilities.AllowsLoop) and \
|
||||||
#Not sensible to allow loops with 1 frame
|
len(item.get_frames()) > 1:
|
||||||
if len(item.get_frames()) > 1:
|
self.Toolbar.makeWidgetsVisible(self.loop_list)
|
||||||
self.Toolbar.makeWidgetsVisible(self.image_list)
|
if item.is_media():
|
||||||
elif item.is_media():
|
|
||||||
self.Toolbar.setVisible(False)
|
self.Toolbar.setVisible(False)
|
||||||
self.Mediabar.setVisible(True)
|
self.Mediabar.setVisible(True)
|
||||||
self.volumeSlider.setAudioOutput(self.parent.mainDisplay.audio)
|
#self.volumeSlider.setAudioOutput(self.parent.mainDisplay.videoDisplay.audio)
|
||||||
|
|
||||||
def enablePreviewToolBar(self, item):
|
def enablePreviewToolBar(self, item):
|
||||||
"""
|
"""
|
||||||
@ -585,7 +590,7 @@ class SlideController(QtGui.QWidget):
|
|||||||
"""
|
"""
|
||||||
log.debug(u'onHideDisplay %d' % force)
|
log.debug(u'onHideDisplay %d' % force)
|
||||||
if force:
|
if force:
|
||||||
self.themeButton.setChecked(True)
|
self.hideButton.setChecked(True)
|
||||||
if self.hideButton.isChecked():
|
if self.hideButton.isChecked():
|
||||||
self.parent.mainDisplay.hideDisplay()
|
self.parent.mainDisplay.hideDisplay()
|
||||||
else:
|
else:
|
||||||
@ -766,6 +771,8 @@ class SlideController(QtGui.QWidget):
|
|||||||
self.mediaObject.clearQueue()
|
self.mediaObject.clearQueue()
|
||||||
file = os.path.join(item.get_frame_path(), item.get_frame_title())
|
file = os.path.join(item.get_frame_path(), item.get_frame_title())
|
||||||
self.mediaObject.setCurrentSource(Phonon.MediaSource(file))
|
self.mediaObject.setCurrentSource(Phonon.MediaSource(file))
|
||||||
|
self.seekSlider.setMediaObject(self.mediaObject)
|
||||||
|
self.seekSlider.show()
|
||||||
self.onMediaPlay()
|
self.onMediaPlay()
|
||||||
|
|
||||||
def onMediaPause(self):
|
def onMediaPause(self):
|
||||||
|
@ -43,9 +43,10 @@ class AppLocation(object):
|
|||||||
ConfigDir = 2
|
ConfigDir = 2
|
||||||
DataDir = 3
|
DataDir = 3
|
||||||
PluginsDir = 4
|
PluginsDir = 4
|
||||||
|
VersionDir = 5
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_directory(dir_type):
|
def get_directory(dir_type=1):
|
||||||
"""
|
"""
|
||||||
Return the appropriate directory according to the directory type.
|
Return the appropriate directory according to the directory type.
|
||||||
|
|
||||||
@ -89,17 +90,18 @@ class AppLocation(object):
|
|||||||
elif dir_type == AppLocation.PluginsDir:
|
elif dir_type == AppLocation.PluginsDir:
|
||||||
plugin_path = None
|
plugin_path = None
|
||||||
app_path = os.path.abspath(os.path.split(sys.argv[0])[0])
|
app_path = os.path.abspath(os.path.split(sys.argv[0])[0])
|
||||||
if sys.platform == u'win32':
|
if hasattr(sys, u'frozen') and sys.frozen == 1:
|
||||||
if hasattr(sys, u'frozen') and sys.frozen == 1:
|
|
||||||
plugin_path = os.path.join(app_path, u'plugins')
|
|
||||||
else:
|
|
||||||
plugin_path = os.path.join(app_path, u'openlp', u'plugins')
|
|
||||||
elif sys.platform == u'darwin':
|
|
||||||
plugin_path = os.path.join(app_path, u'plugins')
|
plugin_path = os.path.join(app_path, u'plugins')
|
||||||
else:
|
else:
|
||||||
plugin_path = os.path.join(
|
plugin_path = os.path.join(
|
||||||
os.path.split(openlp.__file__)[0], u'plugins')
|
os.path.split(openlp.__file__)[0], u'plugins')
|
||||||
return plugin_path
|
return plugin_path
|
||||||
|
elif dir_type == AppLocation.VersionDir:
|
||||||
|
if hasattr(sys, u'frozen') and sys.frozen == 1:
|
||||||
|
plugin_path = os.path.abspath(os.path.split(sys.argv[0])[0])
|
||||||
|
else:
|
||||||
|
plugin_path = os.path.split(openlp.__file__)[0]
|
||||||
|
return plugin_path
|
||||||
|
|
||||||
|
|
||||||
def check_latest_version(config, current_version):
|
def check_latest_version(config, current_version):
|
||||||
|
@ -41,15 +41,17 @@ class Registry(object):
|
|||||||
"""
|
"""
|
||||||
Check if a value exists.
|
Check if a value exists.
|
||||||
"""
|
"""
|
||||||
return self.config.has_option(section, key)
|
return self.config.has_option(section.encode('utf-8'),
|
||||||
|
key.encode('utf-8'))
|
||||||
|
|
||||||
def get_value(self, section, key, default=None):
|
def get_value(self, section, key, default=None):
|
||||||
"""
|
"""
|
||||||
Get a single value from the registry.
|
Get a single value from the registry.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if self.config.get(section, key):
|
if self.config.get(section.encode('utf-8'), key.encode('utf-8')):
|
||||||
return self.config.get(section, key)
|
return self.config.get(section.encode('utf-8'),
|
||||||
|
key.encode('utf-8')).decode('utf-8')
|
||||||
else:
|
else:
|
||||||
return default
|
return default
|
||||||
except:
|
except:
|
||||||
@ -60,7 +62,8 @@ class Registry(object):
|
|||||||
Set a single value in the registry.
|
Set a single value in the registry.
|
||||||
"""
|
"""
|
||||||
try :
|
try :
|
||||||
self.config.set(section, key, unicode(value))
|
self.config.set(section.encode('utf-8'), key.encode('utf-8'),
|
||||||
|
unicode(value).encode('utf-8'))
|
||||||
return self._save()
|
return self._save()
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
@ -70,7 +73,8 @@ class Registry(object):
|
|||||||
Delete a single value from the registry.
|
Delete a single value from the registry.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.config.remove_option(section, key)
|
self.config.remove_option(section.encode('utf-8'),
|
||||||
|
key.encode('utf-8'))
|
||||||
return self._save()
|
return self._save()
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
@ -79,14 +83,14 @@ class Registry(object):
|
|||||||
"""
|
"""
|
||||||
Check if a section exists.
|
Check if a section exists.
|
||||||
"""
|
"""
|
||||||
return self.config.has_section(section)
|
return self.config.has_section(section.encode('utf-8'))
|
||||||
|
|
||||||
def create_section(self, section):
|
def create_section(self, section):
|
||||||
"""
|
"""
|
||||||
Create a new section in the registry.
|
Create a new section in the registry.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.config.add_section(section)
|
self.config.add_section(section.encode('utf-8'))
|
||||||
return self._save()
|
return self._save()
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
@ -96,7 +100,7 @@ class Registry(object):
|
|||||||
Delete a section (including all values).
|
Delete a section (including all values).
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.config.remove_section(section)
|
self.config.remove_section(section.encode('utf-8'))
|
||||||
return self._save()
|
return self._save()
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
@ -35,6 +35,7 @@ class AlertsTab(SettingsTab):
|
|||||||
def __init__(self, parent, section=None):
|
def __init__(self, parent, section=None):
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.manager = parent.manager
|
self.manager = parent.manager
|
||||||
|
self.alertsmanager = parent.alertsmanager
|
||||||
SettingsTab.__init__(self, parent.name, section)
|
SettingsTab.__init__(self, parent.name, section)
|
||||||
|
|
||||||
def setupUi(self):
|
def setupUi(self):
|
||||||
|
@ -40,6 +40,7 @@ class AlertsManager(QtCore.QObject):
|
|||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
QtCore.QObject.__init__(self)
|
QtCore.QObject.__init__(self)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
|
self.screen = None
|
||||||
self.timer_id = 0
|
self.timer_id = 0
|
||||||
self.alertList = []
|
self.alertList = []
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
@ -53,8 +54,8 @@ class AlertsManager(QtCore.QObject):
|
|||||||
|
|
||||||
def screenChanged(self):
|
def screenChanged(self):
|
||||||
log.debug(u'screen changed')
|
log.debug(u'screen changed')
|
||||||
self.screen = self.parent.maindisplay.screen
|
|
||||||
self.alertTab = self.parent.alertsTab
|
self.alertTab = self.parent.alertsTab
|
||||||
|
self.screen = self.parent.maindisplay.screens.current
|
||||||
self.font = QtGui.QFont()
|
self.font = QtGui.QFont()
|
||||||
self.font.setFamily(self.alertTab.font_face)
|
self.font.setFamily(self.alertTab.font_face)
|
||||||
self.font.setBold(True)
|
self.font.setBold(True)
|
||||||
@ -76,9 +77,11 @@ class AlertsManager(QtCore.QObject):
|
|||||||
display text
|
display text
|
||||||
"""
|
"""
|
||||||
log.debug(u'display alert called %s' % text)
|
log.debug(u'display alert called %s' % text)
|
||||||
|
if not self.screen:
|
||||||
|
self.screenChanged()
|
||||||
self.parent.maindisplay.parent.StatusBar.showMessage(u'')
|
self.parent.maindisplay.parent.StatusBar.showMessage(u'')
|
||||||
self.alertList.append(text)
|
self.alertList.append(text)
|
||||||
if self.timer_id != 0 or self.parent.maindisplay.mediaLoaded:
|
if self.timer_id != 0:
|
||||||
self.parent.maindisplay.parent.StatusBar.showMessage(\
|
self.parent.maindisplay.parent.StatusBar.showMessage(\
|
||||||
self.trUtf8(u'Alert message created and delayed'))
|
self.trUtf8(u'Alert message created and delayed'))
|
||||||
return
|
return
|
||||||
|
@ -449,6 +449,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
raw_footer = []
|
raw_footer = []
|
||||||
bible_text = u''
|
bible_text = u''
|
||||||
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
||||||
|
service_item.add_capability(ItemCapabilities.AllowsLoop)
|
||||||
#If we want to use a 2nd translation / version
|
#If we want to use a 2nd translation / version
|
||||||
bible2 = u''
|
bible2 = u''
|
||||||
if self.SearchTabWidget.currentIndex() == 0:
|
if self.SearchTabWidget.currentIndex() == 0:
|
||||||
|
@ -24,13 +24,14 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
from openlp.core.lib import build_icon
|
|
||||||
|
|
||||||
class Ui_customEditDialog(object):
|
class Ui_customEditDialog(object):
|
||||||
def setupUi(self, customEditDialog):
|
def setupUi(self, customEditDialog):
|
||||||
customEditDialog.setObjectName(u'customEditDialog')
|
customEditDialog.setObjectName(u'customEditDialog')
|
||||||
customEditDialog.resize(590, 541)
|
customEditDialog.resize(590, 541)
|
||||||
icon = build_icon(u':/icon/openlp.org-icon-32.bmp')
|
icon = QtGui.QIcon()
|
||||||
|
icon.addPixmap(QtGui.QPixmap(u':/icon/openlp.org-icon-32.bmp'),
|
||||||
|
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
customEditDialog.setWindowIcon(icon)
|
customEditDialog.setWindowIcon(icon)
|
||||||
self.gridLayout = QtGui.QGridLayout(customEditDialog)
|
self.gridLayout = QtGui.QGridLayout(customEditDialog)
|
||||||
self.gridLayout.setObjectName(u'gridLayout')
|
self.gridLayout.setObjectName(u'gridLayout')
|
||||||
@ -52,15 +53,19 @@ class Ui_customEditDialog(object):
|
|||||||
self.verticalLayout = QtGui.QVBoxLayout()
|
self.verticalLayout = QtGui.QVBoxLayout()
|
||||||
self.verticalLayout.setObjectName(u'verticalLayout')
|
self.verticalLayout.setObjectName(u'verticalLayout')
|
||||||
self.UpButton = QtGui.QPushButton(customEditDialog)
|
self.UpButton = QtGui.QPushButton(customEditDialog)
|
||||||
icon1 = build_icon(u':/services/service_up.png')
|
icon1 = QtGui.QIcon()
|
||||||
|
icon1.addPixmap(QtGui.QPixmap(u':/services/service_up.png'),
|
||||||
|
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
self.UpButton.setIcon(icon1)
|
self.UpButton.setIcon(icon1)
|
||||||
self.UpButton.setObjectName(u'UpButton')
|
self.UpButton.setObjectName(u'UpButton')
|
||||||
self.verticalLayout.addWidget(self.UpButton)
|
self.verticalLayout.addWidget(self.UpButton)
|
||||||
spacerItem = QtGui.QSpacerItem(20, 128,
|
spacerItem = QtGui.QSpacerItem(20, 128, QtGui.QSizePolicy.Minimum,
|
||||||
QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
QtGui.QSizePolicy.Expanding)
|
||||||
self.verticalLayout.addItem(spacerItem)
|
self.verticalLayout.addItem(spacerItem)
|
||||||
self.DownButton = QtGui.QPushButton(customEditDialog)
|
self.DownButton = QtGui.QPushButton(customEditDialog)
|
||||||
icon2 = build_icon(u':/services/service_down.png')
|
icon2 = QtGui.QIcon()
|
||||||
|
icon2.addPixmap(QtGui.QPixmap(u':/services/service_down.png'),
|
||||||
|
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
self.DownButton.setIcon(icon2)
|
self.DownButton.setIcon(icon2)
|
||||||
self.DownButton.setObjectName(u'DownButton')
|
self.DownButton.setObjectName(u'DownButton')
|
||||||
self.verticalLayout.addWidget(self.DownButton)
|
self.verticalLayout.addWidget(self.DownButton)
|
||||||
@ -97,6 +102,9 @@ class Ui_customEditDialog(object):
|
|||||||
self.ClearButton = QtGui.QPushButton(self.ButtonWidge)
|
self.ClearButton = QtGui.QPushButton(self.ButtonWidge)
|
||||||
self.ClearButton.setObjectName(u'ClearButton')
|
self.ClearButton.setObjectName(u'ClearButton')
|
||||||
self.verticalLayout_2.addWidget(self.ClearButton)
|
self.verticalLayout_2.addWidget(self.ClearButton)
|
||||||
|
self.SplitButton = QtGui.QPushButton(self.ButtonWidge)
|
||||||
|
self.SplitButton.setObjectName(u'SplitButton')
|
||||||
|
self.verticalLayout_2.addWidget(self.SplitButton)
|
||||||
spacerItem1 = QtGui.QSpacerItem(20, 40,
|
spacerItem1 = QtGui.QSpacerItem(20, 40,
|
||||||
QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
||||||
self.verticalLayout_2.addItem(spacerItem1)
|
self.verticalLayout_2.addItem(spacerItem1)
|
||||||
@ -121,16 +129,15 @@ class Ui_customEditDialog(object):
|
|||||||
self.horizontalLayout_2.addWidget(self.CreditEdit)
|
self.horizontalLayout_2.addWidget(self.CreditEdit)
|
||||||
self.gridLayout.addLayout(self.horizontalLayout_2, 4, 0, 1, 1)
|
self.gridLayout.addLayout(self.horizontalLayout_2, 4, 0, 1, 1)
|
||||||
self.buttonBox = QtGui.QDialogButtonBox(customEditDialog)
|
self.buttonBox = QtGui.QDialogButtonBox(customEditDialog)
|
||||||
self.buttonBox.setStandardButtons(
|
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Save)
|
||||||
QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Save)
|
|
||||||
self.buttonBox.setObjectName(u'buttonBox')
|
self.buttonBox.setObjectName(u'buttonBox')
|
||||||
self.gridLayout.addWidget(self.buttonBox, 5, 0, 1, 1)
|
self.gridLayout.addWidget(self.buttonBox, 5, 0, 1, 1)
|
||||||
|
|
||||||
self.retranslateUi(customEditDialog)
|
self.retranslateUi(customEditDialog)
|
||||||
QtCore.QObject.connect(self.buttonBox,
|
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'),
|
||||||
QtCore.SIGNAL(u'rejected()'), customEditDialog.closePressed)
|
customEditDialog.accept)
|
||||||
QtCore.QObject.connect(self.buttonBox,
|
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'),
|
||||||
QtCore.SIGNAL(u'accepted()'), customEditDialog.accept)
|
customEditDialog.closePressed)
|
||||||
QtCore.QMetaObject.connectSlotsByName(customEditDialog)
|
QtCore.QMetaObject.connectSlotsByName(customEditDialog)
|
||||||
customEditDialog.setTabOrder(self.TitleEdit, self.VerseTextEdit)
|
customEditDialog.setTabOrder(self.TitleEdit, self.VerseTextEdit)
|
||||||
customEditDialog.setTabOrder(self.VerseTextEdit, self.AddButton)
|
customEditDialog.setTabOrder(self.VerseTextEdit, self.AddButton)
|
||||||
@ -143,12 +150,11 @@ class Ui_customEditDialog(object):
|
|||||||
customEditDialog.setTabOrder(self.CreditEdit, self.UpButton)
|
customEditDialog.setTabOrder(self.CreditEdit, self.UpButton)
|
||||||
customEditDialog.setTabOrder(self.UpButton, self.DownButton)
|
customEditDialog.setTabOrder(self.UpButton, self.DownButton)
|
||||||
customEditDialog.setTabOrder(self.DownButton, self.ThemeComboBox)
|
customEditDialog.setTabOrder(self.DownButton, self.ThemeComboBox)
|
||||||
customEditDialog.setTabOrder(self.ThemeComboBox, self.buttonBox)
|
|
||||||
|
|
||||||
def retranslateUi(self, customEditDialog):
|
def retranslateUi(self, customEditDialog):
|
||||||
|
customEditDialog.setWindowTitle(self.trUtf8('Edit Custom Slides'))
|
||||||
self.UpButton.setToolTip(self.trUtf8('Move slide Up 1'))
|
self.UpButton.setToolTip(self.trUtf8('Move slide Up 1'))
|
||||||
self.DownButton.setToolTip(self.trUtf8('Move slide down 1'))
|
self.DownButton.setToolTip(self.trUtf8('Move slide down 1'))
|
||||||
customEditDialog.setWindowTitle(self.trUtf8('Edit Custom Slides'))
|
|
||||||
self.TitleLabel.setText(self.trUtf8('Title:'))
|
self.TitleLabel.setText(self.trUtf8('Title:'))
|
||||||
self.AddButton.setText(self.trUtf8('Add New'))
|
self.AddButton.setText(self.trUtf8('Add New'))
|
||||||
self.AddButton.setToolTip(self.trUtf8('Add new slide at bottom'))
|
self.AddButton.setToolTip(self.trUtf8('Add new slide at bottom'))
|
||||||
@ -162,6 +168,7 @@ class Ui_customEditDialog(object):
|
|||||||
self.DeleteButton.setToolTip(self.trUtf8('Delete selected slide'))
|
self.DeleteButton.setToolTip(self.trUtf8('Delete selected slide'))
|
||||||
self.ClearButton.setText(self.trUtf8('Clear'))
|
self.ClearButton.setText(self.trUtf8('Clear'))
|
||||||
self.ClearButton.setToolTip(self.trUtf8('Clear edit area'))
|
self.ClearButton.setToolTip(self.trUtf8('Clear edit area'))
|
||||||
|
self.SplitButton.setText(self.trUtf8('Split Slide'))
|
||||||
|
self.SplitButton.setToolTip(self.trUtf8('Add slide split'))
|
||||||
self.ThemeLabel.setText(self.trUtf8('Theme:'))
|
self.ThemeLabel.setText(self.trUtf8('Theme:'))
|
||||||
self.ThemeComboBox.setToolTip(self.trUtf8('Set Theme for Slides'))
|
|
||||||
self.CreditLabel.setText(self.trUtf8('Credits:'))
|
self.CreditLabel.setText(self.trUtf8('Credits:'))
|
||||||
|
@ -68,6 +68,8 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
|
|||||||
QtCore.SIGNAL(u'pressed()'), self.onUpButtonPressed)
|
QtCore.SIGNAL(u'pressed()'), self.onUpButtonPressed)
|
||||||
QtCore.QObject.connect(self.DownButton,
|
QtCore.QObject.connect(self.DownButton,
|
||||||
QtCore.SIGNAL(u'pressed()'), self.onDownButtonPressed)
|
QtCore.SIGNAL(u'pressed()'), self.onDownButtonPressed)
|
||||||
|
QtCore.QObject.connect(self.SplitButton,
|
||||||
|
QtCore.SIGNAL(u'pressed()'), self.onSplitButtonPressed)
|
||||||
QtCore.QObject.connect(self.VerseListView,
|
QtCore.QObject.connect(self.VerseListView,
|
||||||
QtCore.SIGNAL(u'itemDoubleClicked(QListWidgetItem*)'),
|
QtCore.SIGNAL(u'itemDoubleClicked(QListWidgetItem*)'),
|
||||||
self.onVerseListViewSelected)
|
self.onVerseListViewSelected)
|
||||||
@ -94,6 +96,7 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
|
|||||||
self.EditAllButton.setEnabled(True)
|
self.EditAllButton.setEnabled(True)
|
||||||
self.SaveButton.setEnabled(False)
|
self.SaveButton.setEnabled(False)
|
||||||
self.ClearButton.setEnabled(False)
|
self.ClearButton.setEnabled(False)
|
||||||
|
self.SplitButton.setEnabled(False)
|
||||||
self.TitleEdit.setText(u'')
|
self.TitleEdit.setText(u'')
|
||||||
self.CreditEdit.setText(u'')
|
self.CreditEdit.setText(u'')
|
||||||
self.VerseTextEdit.clear()
|
self.VerseTextEdit.clear()
|
||||||
@ -202,12 +205,14 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
|
|||||||
def onEditAllButtonPressed(self):
|
def onEditAllButtonPressed(self):
|
||||||
self.editAll = True
|
self.editAll = True
|
||||||
self.AddButton.setEnabled(False)
|
self.AddButton.setEnabled(False)
|
||||||
|
self.SplitButton.setEnabled(True)
|
||||||
if self.VerseListView.count() > 0:
|
if self.VerseListView.count() > 0:
|
||||||
verse_list = u''
|
verse_list = u''
|
||||||
for row in range(0, self.VerseListView.count()):
|
for row in range(0, self.VerseListView.count()):
|
||||||
item = self.VerseListView.item(row)
|
item = self.VerseListView.item(row)
|
||||||
verse_list += item.text()
|
verse_list += item.text()
|
||||||
verse_list += u'\n---\n'
|
if row != self.VerseListView.count() - 1:
|
||||||
|
verse_list += u'\n[---]\n'
|
||||||
self.editText(verse_list)
|
self.editText(verse_list)
|
||||||
|
|
||||||
def editText(self, text):
|
def editText(self, text):
|
||||||
@ -222,7 +227,7 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
|
|||||||
def onSaveButtonPressed(self):
|
def onSaveButtonPressed(self):
|
||||||
if self.editAll:
|
if self.editAll:
|
||||||
self.VerseListView.clear()
|
self.VerseListView.clear()
|
||||||
for row in unicode(self.VerseTextEdit.toPlainText()).split(u'\n---\n'):
|
for row in unicode(self.VerseTextEdit.toPlainText()).split(u'\n[---]\n'):
|
||||||
self.VerseListView.addItem(row)
|
self.VerseListView.addItem(row)
|
||||||
else:
|
else:
|
||||||
self.VerseListView.currentItem().setText(
|
self.VerseListView.currentItem().setText(
|
||||||
@ -241,8 +246,15 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
|
|||||||
self.SaveButton.setEnabled(False)
|
self.SaveButton.setEnabled(False)
|
||||||
self.EditButton.setEnabled(False)
|
self.EditButton.setEnabled(False)
|
||||||
self.EditAllButton.setEnabled(True)
|
self.EditAllButton.setEnabled(True)
|
||||||
|
self.SplitButton.setEnabled(False)
|
||||||
self.VerseTextEdit.clear()
|
self.VerseTextEdit.clear()
|
||||||
|
|
||||||
|
def onSplitButtonPressed(self):
|
||||||
|
if self.VerseTextEdit.textCursor().columnNumber() != 0:
|
||||||
|
self.VerseTextEdit.insertPlainText(u'\n')
|
||||||
|
self.VerseTextEdit.insertPlainText(u'[---]\n' )
|
||||||
|
self.VerseTextEdit.setFocus()
|
||||||
|
|
||||||
def onDeleteButtonPressed(self):
|
def onDeleteButtonPressed(self):
|
||||||
self.VerseListView.takeItem(self.VerseListView.currentRow())
|
self.VerseListView.takeItem(self.VerseListView.currentRow())
|
||||||
self.EditButton.setEnabled(False)
|
self.EditButton.setEnabled(False)
|
||||||
@ -258,5 +270,5 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
|
|||||||
return False, self.trUtf8('You need to enter a slide')
|
return False, self.trUtf8('You need to enter a slide')
|
||||||
if self.VerseTextEdit.toPlainText():
|
if self.VerseTextEdit.toPlainText():
|
||||||
self.VerseTextEdit.setFocus()
|
self.VerseTextEdit.setFocus()
|
||||||
return False, self.trUtf8('You have unsaved data')
|
return False, self.trUtf8('You have unsaved data, please save or clear')
|
||||||
return True, u''
|
return True, u''
|
||||||
|
@ -149,6 +149,7 @@ class CustomMediaItem(MediaManagerItem):
|
|||||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||||
service_item.add_capability(ItemCapabilities.AllowsEdit)
|
service_item.add_capability(ItemCapabilities.AllowsEdit)
|
||||||
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
||||||
|
service_item.add_capability(ItemCapabilities.AllowsLoop)
|
||||||
customSlide = self.parent.custommanager.get_custom(item_id)
|
customSlide = self.parent.custommanager.get_custom(item_id)
|
||||||
title = customSlide.title
|
title = customSlide.title
|
||||||
credit = customSlide.credits
|
credit = customSlide.credits
|
||||||
@ -169,4 +170,4 @@ class CustomMediaItem(MediaManagerItem):
|
|||||||
else:
|
else:
|
||||||
raw_footer.append(u'')
|
raw_footer.append(u'')
|
||||||
service_item.raw_footer = raw_footer
|
service_item.raw_footer = raw_footer
|
||||||
return True
|
return True
|
||||||
|
@ -139,6 +139,7 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
service_item.title = self.trUtf8('Image(s)')
|
service_item.title = self.trUtf8('Image(s)')
|
||||||
service_item.add_capability(ItemCapabilities.AllowsMaintain)
|
service_item.add_capability(ItemCapabilities.AllowsMaintain)
|
||||||
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
||||||
|
service_item.add_capability(ItemCapabilities.AllowsLoop)
|
||||||
for item in items:
|
for item in items:
|
||||||
bitem = self.ListView.item(item.row())
|
bitem = self.ListView.item(item.row())
|
||||||
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())
|
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())
|
||||||
@ -162,4 +163,4 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
self.parent.maindisplay.addImageWithText(frame)
|
self.parent.maindisplay.addImageWithText(frame)
|
||||||
|
|
||||||
def onPreviewClick(self):
|
def onPreviewClick(self):
|
||||||
MediaManagerItem.onPreviewClick(self)
|
MediaManagerItem.onPreviewClick(self)
|
||||||
|
@ -27,4 +27,5 @@ from manager import SongManager
|
|||||||
from songstab import SongsTab
|
from songstab import SongsTab
|
||||||
from mediaitem import SongMediaItem
|
from mediaitem import SongMediaItem
|
||||||
from sofimport import SofImport
|
from sofimport import SofImport
|
||||||
|
from oooimport import OooImport
|
||||||
from songimport import SongImport
|
from songimport import SongImport
|
||||||
|
@ -306,6 +306,7 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||||
service_item.add_capability(ItemCapabilities.AllowsEdit)
|
service_item.add_capability(ItemCapabilities.AllowsEdit)
|
||||||
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
||||||
|
service_item.add_capability(ItemCapabilities.AllowsLoop)
|
||||||
song = self.parent.songmanager.get_song(item_id)
|
song = self.parent.songmanager.get_song(item_id)
|
||||||
service_item.theme = song.theme_name
|
service_item.theme = song.theme_name
|
||||||
service_item.editId = item_id
|
service_item.editId = item_id
|
||||||
@ -361,4 +362,4 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
service_item.audit = [
|
service_item.audit = [
|
||||||
song.title, author_audit, song.copyright, song.ccli_number
|
song.title, author_audit, song.copyright, song.ccli_number
|
||||||
]
|
]
|
||||||
return True
|
return True
|
||||||
|
197
openlp/plugins/songs/lib/oooimport.py
Normal file
197
openlp/plugins/songs/lib/oooimport.py
Normal file
@ -0,0 +1,197 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# OpenLP - Open Source Lyrics Projection #
|
||||||
|
# --------------------------------------------------------------------------- #
|
||||||
|
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||||
|
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||||
|
# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin #
|
||||||
|
# Thompson, Jon Tibble, Carsten Tinggaard #
|
||||||
|
# --------------------------------------------------------------------------- #
|
||||||
|
# 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 #
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
import os
|
||||||
|
from PyQt4 import QtCore
|
||||||
|
from songimport import SongImport
|
||||||
|
|
||||||
|
if os.name == u'nt':
|
||||||
|
from win32com.client import Dispatch
|
||||||
|
PAGE_BEFORE = 4
|
||||||
|
PAGE_AFTER = 5
|
||||||
|
PAGE_BOTH = 6
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
import uno
|
||||||
|
from com.sun.star.style.BreakType import PAGE_BEFORE, PAGE_AFTER, PAGE_BOTH
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
class OooImport(object):
|
||||||
|
"""
|
||||||
|
Import songs from Impress/Powerpoint docs using Impress
|
||||||
|
"""
|
||||||
|
def __init__(self, songmanager):
|
||||||
|
"""
|
||||||
|
Initialise the class. Requires a songmanager class which is passed
|
||||||
|
to SongImport for writing song to disk
|
||||||
|
"""
|
||||||
|
self.song = None
|
||||||
|
self.manager = songmanager
|
||||||
|
self.document = None
|
||||||
|
self.process_started = False
|
||||||
|
|
||||||
|
def import_docs(self, filenames):
|
||||||
|
self.start_ooo()
|
||||||
|
for filename in filenames:
|
||||||
|
filename = unicode(filename)
|
||||||
|
if os.path.isfile(filename):
|
||||||
|
self.open_ooo_file(filename)
|
||||||
|
if self.document:
|
||||||
|
if self.document.supportsService(
|
||||||
|
"com.sun.star.presentation.PresentationDocument"):
|
||||||
|
self.process_pres()
|
||||||
|
if self.document.supportsService(
|
||||||
|
"com.sun.star.text.TextDocument"):
|
||||||
|
self.process_doc()
|
||||||
|
self.close_ooo_file()
|
||||||
|
self.close_ooo()
|
||||||
|
|
||||||
|
def start_ooo(self):
|
||||||
|
"""
|
||||||
|
Start OpenOffice.org process
|
||||||
|
TODO: The presentation/Impress plugin may already have it running
|
||||||
|
"""
|
||||||
|
if os.name == u'nt':
|
||||||
|
self.start_ooo_process()
|
||||||
|
self.desktop = self.manager.createInstance(u'com.sun.star.frame.Desktop')
|
||||||
|
else:
|
||||||
|
context = uno.getComponentContext()
|
||||||
|
resolver = context.ServiceManager.createInstanceWithContext(
|
||||||
|
u'com.sun.star.bridge.UnoUrlResolver', context)
|
||||||
|
ctx = None
|
||||||
|
loop = 0
|
||||||
|
while ctx is None and loop < 5:
|
||||||
|
try:
|
||||||
|
ctx = resolver.resolve(u'uno:socket,host=localhost,' \
|
||||||
|
+ 'port=2002;urp;StarOffice.ComponentContext')
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
self.start_ooo_process()
|
||||||
|
loop += 1
|
||||||
|
manager = ctx.ServiceManager
|
||||||
|
self.desktop = manager.createInstanceWithContext(
|
||||||
|
"com.sun.star.frame.Desktop", ctx )
|
||||||
|
|
||||||
|
def start_ooo_process(self):
|
||||||
|
try:
|
||||||
|
if os.name == u'nt':
|
||||||
|
self.manager = Dispatch(u'com.sun.star.ServiceManager')
|
||||||
|
self.manager._FlagAsMethod(u'Bridge_GetStruct')
|
||||||
|
self.manager._FlagAsMethod(u'Bridge_GetValueObject')
|
||||||
|
else:
|
||||||
|
cmd = u'openoffice.org -nologo -norestore -minimized -invisible ' \
|
||||||
|
+ u'-nofirststartwizard ' \
|
||||||
|
+ '-accept="socket,host=localhost,port=2002;urp;"'
|
||||||
|
process = QtCore.QProcess()
|
||||||
|
process.startDetached(cmd)
|
||||||
|
process.waitForStarted()
|
||||||
|
self.process_started = True
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def open_ooo_file(self, filepath):
|
||||||
|
"""
|
||||||
|
Open the passed file in OpenOffice.org Impress
|
||||||
|
"""
|
||||||
|
if os.name == u'nt':
|
||||||
|
url = u'file:///' + filepath.replace(u'\\', u'/')
|
||||||
|
url = url.replace(u':', u'|').replace(u' ', u'%20')
|
||||||
|
else:
|
||||||
|
url = uno.systemPathToFileUrl(filepath)
|
||||||
|
properties = []
|
||||||
|
properties = tuple(properties)
|
||||||
|
try:
|
||||||
|
self.document = self.desktop.loadComponentFromURL(url, u'_blank',
|
||||||
|
0, properties)
|
||||||
|
if not self.document.supportsService(
|
||||||
|
"com.sun.star.presentation.PresentationDocument") \
|
||||||
|
and not self.document.supportsService(
|
||||||
|
"com.sun.star.text.TextDocument"):
|
||||||
|
self.close_ooo_file()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return
|
||||||
|
|
||||||
|
def close_ooo_file(self):
|
||||||
|
"""
|
||||||
|
Close file.
|
||||||
|
"""
|
||||||
|
self.document.close(True)
|
||||||
|
self.document = None
|
||||||
|
|
||||||
|
def close_ooo(self):
|
||||||
|
"""
|
||||||
|
Close OOo. But only if we started it and not on windows
|
||||||
|
"""
|
||||||
|
if self.process_started:
|
||||||
|
self.desktop.terminate()
|
||||||
|
|
||||||
|
def process_pres(self):
|
||||||
|
"""
|
||||||
|
Process the file
|
||||||
|
"""
|
||||||
|
doc = self.document
|
||||||
|
slides = doc.getDrawPages()
|
||||||
|
text = u''
|
||||||
|
for slide_no in range(slides.getCount()):
|
||||||
|
slide = slides.getByIndex(slide_no)
|
||||||
|
slidetext = u''
|
||||||
|
for idx in range(slide.getCount()):
|
||||||
|
shape = slide.getByIndex(idx)
|
||||||
|
if shape.supportsService("com.sun.star.drawing.Text"):
|
||||||
|
if shape.getString().strip() != u'':
|
||||||
|
slidetext += shape.getString().strip() + u'\n\n'
|
||||||
|
if slidetext.strip() == u'':
|
||||||
|
slidetext = u'\f'
|
||||||
|
text += slidetext
|
||||||
|
song = SongImport(self.manager)
|
||||||
|
songs = SongImport.process_songs_text(self.manager, text)
|
||||||
|
for song in songs:
|
||||||
|
song.finish()
|
||||||
|
return
|
||||||
|
|
||||||
|
def process_doc(self):
|
||||||
|
"""
|
||||||
|
Process the doc file, a paragraph at a time
|
||||||
|
"""
|
||||||
|
text = u''
|
||||||
|
paragraphs = self.document.getText().createEnumeration()
|
||||||
|
while paragraphs.hasMoreElements():
|
||||||
|
paratext = u''
|
||||||
|
paragraph = paragraphs.nextElement()
|
||||||
|
if paragraph.supportsService("com.sun.star.text.Paragraph"):
|
||||||
|
textportions = paragraph.createEnumeration()
|
||||||
|
while textportions.hasMoreElements():
|
||||||
|
textportion = textportions.nextElement()
|
||||||
|
if textportion.BreakType in (PAGE_BEFORE, PAGE_BOTH):
|
||||||
|
paratext += u'\f'
|
||||||
|
paratext += textportion.getString()
|
||||||
|
if textportion.BreakType in (PAGE_AFTER, PAGE_BOTH):
|
||||||
|
paratext += u'\f'
|
||||||
|
text += paratext + u'\n'
|
||||||
|
songs = SongImport.process_songs_text(self.manager, text)
|
||||||
|
for song in songs:
|
||||||
|
song.finish()
|
||||||
|
|
@ -24,23 +24,24 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
# OOo API documentation:
|
# OOo API documentation:
|
||||||
# http://wiki.services.openoffice.org/wiki/Documentation/BASIC_Guide/Structure_of_Text_Documents
|
# http://wiki.services.openoffice.org/wiki/Documentation/BASIC_Guide/Structure_of_Text_Documents
|
||||||
# http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Text/Iterating_over_Text
|
# http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Text/Iterating_over_Text
|
||||||
# http://www.oooforum.org/forum/viewtopic.phtml?t=14409
|
# http://www.oooforum.org/forum/viewtopic.phtml?t=14409
|
||||||
# http://wiki.services.openoffice.org/wiki/Python
|
# http://wiki.services.openoffice.org/wiki/Python
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
from songimport import SongImport
|
from songimport import SongImport
|
||||||
|
from oooimport import OooImport
|
||||||
|
|
||||||
if os.name == u'nt':
|
if os.name == u'nt':
|
||||||
from win32com.client import Dispatch
|
from win32com.client import Dispatch
|
||||||
BOLD = 150.0
|
BOLD = 150.0
|
||||||
ITALIC = 2
|
ITALIC = 2
|
||||||
PAGE_BEFORE = 4
|
PAGE_BEFORE = 4
|
||||||
PAGE_AFTER = 5
|
PAGE_AFTER = 5
|
||||||
PAGE_BOTH = 6
|
PAGE_BOTH = 6
|
||||||
else:
|
else:
|
||||||
import uno
|
import uno
|
||||||
@ -48,7 +49,7 @@ else:
|
|||||||
from com.sun.star.awt.FontSlant import ITALIC
|
from com.sun.star.awt.FontSlant import ITALIC
|
||||||
from com.sun.star.style.BreakType import PAGE_BEFORE, PAGE_AFTER, PAGE_BOTH
|
from com.sun.star.style.BreakType import PAGE_BEFORE, PAGE_AFTER, PAGE_BOTH
|
||||||
|
|
||||||
class SofImport(object):
|
class SofImport(OooImport):
|
||||||
"""
|
"""
|
||||||
Import songs provided on disks with the Songs of Fellowship music books
|
Import songs provided on disks with the Songs of Fellowship music books
|
||||||
VOLS1_2.RTF, sof3words.rtf and sof4words.rtf
|
VOLS1_2.RTF, sof3words.rtf and sof4words.rtf
|
||||||
@ -69,95 +70,28 @@ class SofImport(object):
|
|||||||
Initialise the class. Requires a songmanager class which is passed
|
Initialise the class. Requires a songmanager class which is passed
|
||||||
to SongImport for writing song to disk
|
to SongImport for writing song to disk
|
||||||
"""
|
"""
|
||||||
self.song = None
|
OooImport.__init__(self,songmanager)
|
||||||
self.manager = songmanager
|
|
||||||
self.process_started = False
|
|
||||||
|
|
||||||
def import_sof(self, filename):
|
def import_sof(self, filename):
|
||||||
self.start_ooo()
|
self.start_ooo()
|
||||||
self.open_ooo_file(filename)
|
self.open_ooo_file(filename)
|
||||||
self.process_doc()
|
self.process_sof_file()
|
||||||
|
self.close_ooo_file()
|
||||||
self.close_ooo()
|
self.close_ooo()
|
||||||
|
|
||||||
def start_ooo(self):
|
def process_sof_file(self):
|
||||||
"""
|
|
||||||
Start OpenOffice.org process
|
|
||||||
TODO: The presentation/Impress plugin may already have it running
|
|
||||||
"""
|
|
||||||
if os.name == u'nt':
|
|
||||||
self.start_ooo_process()
|
|
||||||
self.desktop = self.manager.createInstance(u'com.sun.star.frame.Desktop')
|
|
||||||
else:
|
|
||||||
context = uno.getComponentContext()
|
|
||||||
resolver = context.ServiceManager.createInstanceWithContext(
|
|
||||||
u'com.sun.star.bridge.UnoUrlResolver', context)
|
|
||||||
ctx = None
|
|
||||||
loop = 0
|
|
||||||
while ctx is None and loop < 5:
|
|
||||||
try:
|
|
||||||
ctx = resolver.resolve(u'uno:socket,host=localhost,' \
|
|
||||||
+ 'port=2002;urp;StarOffice.ComponentContext')
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
self.start_ooo_process()
|
|
||||||
loop += 1
|
|
||||||
manager = ctx.ServiceManager
|
|
||||||
self.desktop = manager.createInstanceWithContext(
|
|
||||||
"com.sun.star.frame.Desktop", ctx )
|
|
||||||
|
|
||||||
def start_ooo_process(self):
|
|
||||||
try:
|
|
||||||
if os.name == u'nt':
|
|
||||||
self.manager = Dispatch(u'com.sun.star.ServiceManager')
|
|
||||||
self.manager._FlagAsMethod(u'Bridge_GetStruct')
|
|
||||||
self.manager._FlagAsMethod(u'Bridge_GetValueObject')
|
|
||||||
else:
|
|
||||||
cmd = u'openoffice.org -nologo -norestore -minimized -invisible ' \
|
|
||||||
+ u'-nofirststartwizard ' \
|
|
||||||
+ '-accept="socket,host=localhost,port=2002;urp;"'
|
|
||||||
process = QtCore.QProcess()
|
|
||||||
process.startDetached(cmd)
|
|
||||||
process.waitForStarted()
|
|
||||||
self.process_started = True
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def open_ooo_file(self, filepath):
|
|
||||||
"""
|
|
||||||
Open the passed file in OpenOffice.org Writer
|
|
||||||
"""
|
|
||||||
if os.name == u'nt':
|
|
||||||
url = u'file:///' + filepath.replace(u'\\', u'/')
|
|
||||||
url = url.replace(u':', u'|').replace(u' ', u'%20')
|
|
||||||
else:
|
|
||||||
url = uno.systemPathToFileUrl(filepath)
|
|
||||||
properties = []
|
|
||||||
properties = tuple(properties)
|
|
||||||
self.document = self.desktop.loadComponentFromURL(url, u'_blank',
|
|
||||||
0, properties)
|
|
||||||
|
|
||||||
def close_ooo(self):
|
|
||||||
"""
|
|
||||||
Close RTF file. Note, on Windows we'll leave OOo running
|
|
||||||
Leave running on Windows
|
|
||||||
"""
|
|
||||||
self.document.close(True)
|
|
||||||
if self.process_started:
|
|
||||||
self.desktop.terminate()
|
|
||||||
|
|
||||||
def process_doc(self):
|
|
||||||
"""
|
"""
|
||||||
Process the RTF file, a paragraph at a time
|
Process the RTF file, a paragraph at a time
|
||||||
"""
|
"""
|
||||||
self.blanklines = 0
|
self.blanklines = 0
|
||||||
self.new_song()
|
self.new_song()
|
||||||
paragraphs = self.document.getText().createEnumeration()
|
paragraphs = self.document.getText().createEnumeration()
|
||||||
while paragraphs.hasMoreElements():
|
while paragraphs.hasMoreElements():
|
||||||
paragraph = paragraphs.nextElement()
|
paragraph = paragraphs.nextElement()
|
||||||
if paragraph.supportsService("com.sun.star.text.Paragraph"):
|
if paragraph.supportsService("com.sun.star.text.Paragraph"):
|
||||||
self.process_paragraph(paragraph)
|
self.process_paragraph(paragraph)
|
||||||
if self.song:
|
if self.song:
|
||||||
self.song.finish()
|
self.song.finish()
|
||||||
self.song = None
|
self.song = None
|
||||||
|
|
||||||
def process_paragraph(self, paragraph):
|
def process_paragraph(self, paragraph):
|
||||||
@ -171,71 +105,71 @@ class SofImport(object):
|
|||||||
In later books, there may not be line breaks, so check for 3 or more
|
In later books, there may not be line breaks, so check for 3 or more
|
||||||
newlines
|
newlines
|
||||||
"""
|
"""
|
||||||
text = u''
|
text = u''
|
||||||
textportions = paragraph.createEnumeration()
|
textportions = paragraph.createEnumeration()
|
||||||
while textportions.hasMoreElements():
|
while textportions.hasMoreElements():
|
||||||
textportion = textportions.nextElement()
|
textportion = textportions.nextElement()
|
||||||
if textportion.BreakType in (PAGE_BEFORE, PAGE_BOTH):
|
if textportion.BreakType in (PAGE_BEFORE, PAGE_BOTH):
|
||||||
self.process_paragraph_text(text)
|
self.process_paragraph_text(text)
|
||||||
self.new_song()
|
self.new_song()
|
||||||
text = u''
|
text = u''
|
||||||
text += self.process_textportion(textportion)
|
text += self.process_textportion(textportion)
|
||||||
if textportion.BreakType in (PAGE_AFTER, PAGE_BOTH):
|
if textportion.BreakType in (PAGE_AFTER, PAGE_BOTH):
|
||||||
self.process_paragraph_text(text)
|
self.process_paragraph_text(text)
|
||||||
self.new_song()
|
self.new_song()
|
||||||
text = u''
|
text = u''
|
||||||
self.process_paragraph_text(text)
|
self.process_paragraph_text(text)
|
||||||
|
|
||||||
def process_paragraph_text(self, text):
|
def process_paragraph_text(self, text):
|
||||||
"""
|
"""
|
||||||
Split the paragraph text into multiple lines and process
|
Split the paragraph text into multiple lines and process
|
||||||
"""
|
"""
|
||||||
for line in text.split(u'\n'):
|
for line in text.split(u'\n'):
|
||||||
self.process_paragraph_line(line)
|
self.process_paragraph_line(line)
|
||||||
if self.blanklines > 2:
|
if self.blanklines > 2:
|
||||||
self.new_song()
|
self.new_song()
|
||||||
|
|
||||||
def process_paragraph_line(self, text):
|
def process_paragraph_line(self, text):
|
||||||
"""
|
"""
|
||||||
Process a single line. Throw away that text which isn't relevant, i.e.
|
Process a single line. Throw away that text which isn't relevant, i.e.
|
||||||
stuff that appears at the end of the song.
|
stuff that appears at the end of the song.
|
||||||
Anything that is OK, append to the current verse
|
Anything that is OK, append to the current verse
|
||||||
"""
|
"""
|
||||||
text = text.strip()
|
text = text.strip()
|
||||||
if text == u'':
|
if text == u'':
|
||||||
self.blanklines += 1
|
self.blanklines += 1
|
||||||
if self.blanklines > 1:
|
if self.blanklines > 1:
|
||||||
return
|
return
|
||||||
if self.song.get_title() != u'':
|
if self.song.get_title() != u'':
|
||||||
self.finish_verse()
|
self.finish_verse()
|
||||||
return
|
return
|
||||||
self.blanklines = 0
|
self.blanklines = 0
|
||||||
if self.skip_to_close_bracket:
|
if self.skip_to_close_bracket:
|
||||||
if text.endswith(u')'):
|
if text.endswith(u')'):
|
||||||
self.skip_to_close_bracket = False
|
self.skip_to_close_bracket = False
|
||||||
return
|
return
|
||||||
if text.startswith(u'CCL Licence'):
|
if text.startswith(u'CCL Licence'):
|
||||||
self.italics = False
|
self.italics = False
|
||||||
return
|
return
|
||||||
if text == u'A Songs of Fellowship Worship Resource':
|
if text == u'A Songs of Fellowship Worship Resource':
|
||||||
return
|
return
|
||||||
if text.startswith(u'(NB.') or text.startswith(u'(Regrettably') \
|
if text.startswith(u'(NB.') or text.startswith(u'(Regrettably') \
|
||||||
or text.startswith(u'(From'):
|
or text.startswith(u'(From'):
|
||||||
self.skip_to_close_bracket = True
|
self.skip_to_close_bracket = True
|
||||||
return
|
return
|
||||||
if text.startswith(u'Copyright'):
|
if text.startswith(u'Copyright'):
|
||||||
self.song.add_copyright(text)
|
self.song.add_copyright(text)
|
||||||
return
|
return
|
||||||
if text == u'(Repeat)':
|
if text == u'(Repeat)':
|
||||||
self.finish_verse()
|
self.finish_verse()
|
||||||
self.song.repeat_verse()
|
self.song.repeat_verse()
|
||||||
return
|
return
|
||||||
if self.song.get_title() == u'':
|
if self.song.get_title() == u'':
|
||||||
if self.song.get_copyright() == u'':
|
if self.song.get_copyright() == u'':
|
||||||
self.add_author(text)
|
self.add_author(text)
|
||||||
else:
|
else:
|
||||||
self.song.add_copyright(text)
|
self.song.add_copyright(text)
|
||||||
return
|
return
|
||||||
self.add_verse_line(text)
|
self.add_verse_line(text)
|
||||||
|
|
||||||
def process_textportion(self, textportion):
|
def process_textportion(self, textportion):
|
||||||
@ -244,157 +178,132 @@ class SofImport(object):
|
|||||||
it's bold or italics. If it's bold then its a song number or song title.
|
it's bold or italics. If it's bold then its a song number or song title.
|
||||||
Song titles are in all capitals, so we must bring the capitalization
|
Song titles are in all capitals, so we must bring the capitalization
|
||||||
into line
|
into line
|
||||||
"""
|
"""
|
||||||
text = textportion.getString()
|
text = textportion.getString()
|
||||||
text = self.tidy_text(text)
|
text = SongImport.tidy_text(text)
|
||||||
if text.strip() == u'':
|
if text.strip() == u'':
|
||||||
return text
|
return text
|
||||||
if textportion.CharWeight == BOLD:
|
if textportion.CharWeight == BOLD:
|
||||||
boldtext = text.strip()
|
boldtext = text.strip()
|
||||||
if boldtext.isdigit() and self.song.get_song_number() == '':
|
if boldtext.isdigit() and self.song.get_song_number() == '':
|
||||||
self.add_songnumber(boldtext)
|
self.add_songnumber(boldtext)
|
||||||
return u''
|
return u''
|
||||||
if self.song.get_title() == u'':
|
if self.song.get_title() == u'':
|
||||||
text = self.uncap_text(text)
|
text = self.uncap_text(text)
|
||||||
self.add_title(text)
|
self.add_title(text)
|
||||||
return text
|
return text
|
||||||
if text.strip().startswith(u'('):
|
if text.strip().startswith(u'('):
|
||||||
return text
|
return text
|
||||||
self.italics = (textportion.CharPosture == ITALIC)
|
self.italics = (textportion.CharPosture == ITALIC)
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def new_song(self):
|
def new_song(self):
|
||||||
"""
|
"""
|
||||||
A change of song. Store the old, create a new
|
A change of song. Store the old, create a new
|
||||||
... but only if the last song was complete. If not, stick with it
|
... but only if the last song was complete. If not, stick with it
|
||||||
"""
|
"""
|
||||||
if self.song:
|
if self.song:
|
||||||
self.finish_verse()
|
self.finish_verse()
|
||||||
if not self.song.check_complete():
|
if not self.song.check_complete():
|
||||||
return
|
return
|
||||||
self.song.finish()
|
self.song.finish()
|
||||||
self.song = SongImport(self.manager)
|
self.song = SongImport(self.manager)
|
||||||
self.skip_to_close_bracket = False
|
self.skip_to_close_bracket = False
|
||||||
self.is_chorus = False
|
self.is_chorus = False
|
||||||
self.italics = False
|
self.italics = False
|
||||||
self.currentverse = u''
|
self.currentverse = u''
|
||||||
|
|
||||||
def add_songnumber(self, song_no):
|
def add_songnumber(self, song_no):
|
||||||
"""
|
"""
|
||||||
Add a song number, store as alternate title. Also use the song
|
Add a song number, store as alternate title. Also use the song
|
||||||
number to work out which songbook we're in
|
number to work out which songbook we're in
|
||||||
"""
|
"""
|
||||||
self.song.set_song_number(song_no)
|
self.song.set_song_number(song_no)
|
||||||
self.song.set_alternate_title(song_no + u'.')
|
self.song.set_alternate_title(song_no + u'.')
|
||||||
if int(song_no) <= 640:
|
if int(song_no) <= 640:
|
||||||
self.song.set_song_book(u'Songs of Fellowship 1',
|
self.song.set_song_book(u'Songs of Fellowship 1',
|
||||||
u'Kingsway Publications')
|
u'Kingsway Publications')
|
||||||
elif int(song_no) <= 1150:
|
elif int(song_no) <= 1150:
|
||||||
self.song.set_song_book(u'Songs of Fellowship 2',
|
self.song.set_song_book(u'Songs of Fellowship 2',
|
||||||
u'Kingsway Publications')
|
u'Kingsway Publications')
|
||||||
elif int(song_no) <= 1690:
|
elif int(song_no) <= 1690:
|
||||||
self.song.set_song_book(u'Songs of Fellowship 3',
|
self.song.set_song_book(u'Songs of Fellowship 3',
|
||||||
u'Kingsway Publications')
|
u'Kingsway Publications')
|
||||||
else:
|
else:
|
||||||
self.song.set_song_book(u'Songs of Fellowship 4',
|
self.song.set_song_book(u'Songs of Fellowship 4',
|
||||||
u'Kingsway Publications')
|
u'Kingsway Publications')
|
||||||
|
|
||||||
def add_title(self, text):
|
def add_title(self, text):
|
||||||
"""
|
"""
|
||||||
Add the title to the song. Strip some leading/trailing punctuation that
|
Add the title to the song. Strip some leading/trailing punctuation that
|
||||||
we don't want in a title
|
we don't want in a title
|
||||||
"""
|
"""
|
||||||
title = text.strip()
|
title = text.strip()
|
||||||
if title.startswith(u'\''):
|
if title.startswith(u'\''):
|
||||||
title = title[1:]
|
title = title[1:]
|
||||||
if title.endswith(u','):
|
if title.endswith(u','):
|
||||||
title = title[:-1]
|
title = title[:-1]
|
||||||
self.song.set_title(title)
|
self.song.set_title(title)
|
||||||
|
|
||||||
def add_author(self, text):
|
def add_author(self, text):
|
||||||
"""
|
"""
|
||||||
Add the author. OpenLP stores them individually so split by 'and', '&'
|
Add the author. OpenLP stores them individually so split by 'and', '&'
|
||||||
and comma.
|
and comma.
|
||||||
However need to check for "Mr and Mrs Smith" and turn it to
|
However need to check for "Mr and Mrs Smith" and turn it to
|
||||||
"Mr Smith" and "Mrs Smith".
|
"Mr Smith" and "Mrs Smith".
|
||||||
"""
|
"""
|
||||||
text = text.replace(u' and ', u' & ')
|
text = text.replace(u' and ', u' & ')
|
||||||
for author in text.split(u','):
|
self.song.parse_author(text)
|
||||||
authors = author.split(u'&')
|
|
||||||
for i in range(len(authors)):
|
|
||||||
author2 = authors[i].strip()
|
|
||||||
if author2.find(u' ') == -1 and i < len(authors) - 1:
|
|
||||||
author2 = author2 + u' ' \
|
|
||||||
+ authors[i + 1].strip().split(u' ')[-1]
|
|
||||||
if author2.endswith(u'.'):
|
|
||||||
author2 = author2[:-1]
|
|
||||||
if author2:
|
|
||||||
self.song.add_author(author2)
|
|
||||||
|
|
||||||
def add_verse_line(self, text):
|
def add_verse_line(self, text):
|
||||||
"""
|
"""
|
||||||
Add a line to the current verse. If the formatting has changed and
|
Add a line to the current verse. If the formatting has changed and
|
||||||
we're beyond the second line of first verse, then this indicates
|
we're beyond the second line of first verse, then this indicates
|
||||||
a change of verse. Italics are a chorus
|
a change of verse. Italics are a chorus
|
||||||
"""
|
"""
|
||||||
if self.italics != self.is_chorus and ((len(self.song.verses) > 0) or
|
if self.italics != self.is_chorus and ((len(self.song.verses) > 0) or
|
||||||
(self.currentverse.count(u'\n') > 1)):
|
(self.currentverse.count(u'\n') > 1)):
|
||||||
self.finish_verse()
|
self.finish_verse()
|
||||||
if self.italics:
|
if self.italics:
|
||||||
self.is_chorus = True
|
self.is_chorus = True
|
||||||
self.currentverse += text + u'\n'
|
self.currentverse += text + u'\n'
|
||||||
|
|
||||||
def finish_verse(self):
|
def finish_verse(self):
|
||||||
"""
|
"""
|
||||||
Verse is finished, store it. Note in book 1+2, some songs are formatted
|
Verse is finished, store it. Note in book 1+2, some songs are formatted
|
||||||
incorrectly. Here we try and split songs with missing line breaks into
|
incorrectly. Here we try and split songs with missing line breaks into
|
||||||
the correct number of verses.
|
the correct number of verses.
|
||||||
"""
|
|
||||||
if self.currentverse.strip() == u'':
|
|
||||||
return
|
|
||||||
if self.is_chorus:
|
|
||||||
versetag = u'C'
|
|
||||||
splitat = None
|
|
||||||
else:
|
|
||||||
versetag = u'V'
|
|
||||||
splitat = self.verse_splits(self.song.get_song_number())
|
|
||||||
if splitat:
|
|
||||||
ln = 0
|
|
||||||
verse = u''
|
|
||||||
for line in self.currentverse.split(u'\n'):
|
|
||||||
ln += 1
|
|
||||||
if line == u'' or ln > splitat:
|
|
||||||
self.song.add_verse(verse, versetag)
|
|
||||||
ln = 0
|
|
||||||
if line:
|
|
||||||
verse = line + u'\n'
|
|
||||||
else:
|
|
||||||
verse = u''
|
|
||||||
else:
|
|
||||||
verse += line + u'\n'
|
|
||||||
if verse:
|
|
||||||
self.song.add_verse(verse, versetag)
|
|
||||||
else:
|
|
||||||
self.song.add_verse(self.currentverse, versetag)
|
|
||||||
self.currentverse = u''
|
|
||||||
self.is_chorus = False
|
|
||||||
|
|
||||||
def tidy_text(self, text):
|
|
||||||
"""
|
"""
|
||||||
Get rid of some dodgy unicode and formatting characters we're not
|
if self.currentverse.strip() == u'':
|
||||||
interested in. Some can be converted to ascii.
|
return
|
||||||
"""
|
if self.is_chorus:
|
||||||
text = text.replace(u'\t', u' ')
|
versetag = u'C'
|
||||||
text = text.replace(u'\r', u'\n')
|
splitat = None
|
||||||
text = text.replace(u'\u2018', u'\'')
|
else:
|
||||||
text = text.replace(u'\u2019', u'\'')
|
versetag = u'V'
|
||||||
text = text.replace(u'\u201c', u'"')
|
splitat = self.verse_splits(self.song.get_song_number())
|
||||||
text = text.replace(u'\u201d', u'"')
|
if splitat:
|
||||||
text = text.replace(u'\u2026', u'...')
|
ln = 0
|
||||||
text = text.replace(u'\u2013', u'-')
|
verse = u''
|
||||||
text = text.replace(u'\u2014', u'-')
|
for line in self.currentverse.split(u'\n'):
|
||||||
return text
|
ln += 1
|
||||||
|
if line == u'' or ln > splitat:
|
||||||
|
self.song.add_verse(verse, versetag)
|
||||||
|
ln = 0
|
||||||
|
if line:
|
||||||
|
verse = line + u'\n'
|
||||||
|
else:
|
||||||
|
verse = u''
|
||||||
|
else:
|
||||||
|
verse += line + u'\n'
|
||||||
|
if verse:
|
||||||
|
self.song.add_verse(verse, versetag)
|
||||||
|
else:
|
||||||
|
self.song.add_verse(self.currentverse, versetag)
|
||||||
|
self.currentverse = u''
|
||||||
|
self.is_chorus = False
|
||||||
|
|
||||||
|
|
||||||
def uncap_text(self, text):
|
def uncap_text(self, text):
|
||||||
"""
|
"""
|
||||||
Words in the title are in all capitals, so we lowercase them.
|
Words in the title are in all capitals, so we lowercase them.
|
||||||
@ -403,128 +312,128 @@ class SofImport(object):
|
|||||||
|
|
||||||
There is a complicated word "One", which is sometimes lower and
|
There is a complicated word "One", which is sometimes lower and
|
||||||
sometimes upper depending on context. Never mind, keep it lower.
|
sometimes upper depending on context. Never mind, keep it lower.
|
||||||
"""
|
"""
|
||||||
textarr = re.split(u'(\W+)', text)
|
textarr = re.split(u'(\W+)', text)
|
||||||
textarr[0] = textarr[0].capitalize()
|
textarr[0] = textarr[0].capitalize()
|
||||||
for i in range(1, len(textarr)):
|
for i in range(1, len(textarr)):
|
||||||
# Do not translate these. Fixed strings in SOF song file
|
# Do not translate these. Fixed strings in SOF song file
|
||||||
if textarr[i] in (u'JESUS', u'CHRIST', u'KING', u'ALMIGHTY',
|
if textarr[i] in (u'JESUS', u'CHRIST', u'KING', u'ALMIGHTY',
|
||||||
u'REDEEMER', u'SHEPHERD', u'SON', u'GOD', u'LORD', u'FATHER',
|
u'REDEEMER', u'SHEPHERD', u'SON', u'GOD', u'LORD', u'FATHER',
|
||||||
u'HOLY', u'SPIRIT', u'LAMB', u'YOU', u'YOUR', u'I', u'I\'VE',
|
u'HOLY', u'SPIRIT', u'LAMB', u'YOU', u'YOUR', u'I', u'I\'VE',
|
||||||
u'I\'M', u'I\'LL', u'SAVIOUR', u'O', u'YOU\'RE', u'HE', u'HIS',
|
u'I\'M', u'I\'LL', u'SAVIOUR', u'O', u'YOU\'RE', u'HE', u'HIS',
|
||||||
u'HIM', u'ZION', u'EMMANUEL', u'MAJESTY', u'JESUS\'', u'JIREH',
|
u'HIM', u'ZION', u'EMMANUEL', u'MAJESTY', u'JESUS\'', u'JIREH',
|
||||||
u'JUDAH', u'LION', u'LORD\'S', u'ABRAHAM', u'GOD\'S',
|
u'JUDAH', u'LION', u'LORD\'S', u'ABRAHAM', u'GOD\'S',
|
||||||
u'FATHER\'S', u'ELIJAH'):
|
u'FATHER\'S', u'ELIJAH'):
|
||||||
textarr[i] = textarr[i].capitalize()
|
textarr[i] = textarr[i].capitalize()
|
||||||
else:
|
else:
|
||||||
textarr[i] = textarr[i].lower()
|
textarr[i] = textarr[i].lower()
|
||||||
text = u''.join(textarr)
|
text = u''.join(textarr)
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def verse_splits(self, song_number):
|
def verse_splits(self, song_number):
|
||||||
"""
|
"""
|
||||||
Because someone at Kingsway forgot to check the 1+2 RTF file,
|
Because someone at Kingsway forgot to check the 1+2 RTF file,
|
||||||
some verses were not formatted correctly.
|
some verses were not formatted correctly.
|
||||||
"""
|
"""
|
||||||
if song_number == 11: return 8
|
if song_number == 11: return 8
|
||||||
if song_number == 18: return 5
|
if song_number == 18: return 5
|
||||||
if song_number == 21: return 6
|
if song_number == 21: return 6
|
||||||
if song_number == 23: return 4
|
if song_number == 23: return 4
|
||||||
if song_number == 24: return 7
|
if song_number == 24: return 7
|
||||||
if song_number == 27: return 4
|
if song_number == 27: return 4
|
||||||
if song_number == 31: return 6
|
if song_number == 31: return 6
|
||||||
if song_number == 49: return 4
|
if song_number == 49: return 4
|
||||||
if song_number == 50: return 8
|
if song_number == 50: return 8
|
||||||
if song_number == 70: return 4
|
if song_number == 70: return 4
|
||||||
if song_number == 75: return 8
|
if song_number == 75: return 8
|
||||||
if song_number == 79: return 6
|
if song_number == 79: return 6
|
||||||
if song_number == 97: return 7
|
if song_number == 97: return 7
|
||||||
if song_number == 107: return 4
|
if song_number == 107: return 4
|
||||||
if song_number == 109: return 4
|
if song_number == 109: return 4
|
||||||
if song_number == 133: return 4
|
if song_number == 133: return 4
|
||||||
if song_number == 155: return 10
|
if song_number == 155: return 10
|
||||||
if song_number == 156: return 8
|
if song_number == 156: return 8
|
||||||
if song_number == 171: return 4
|
if song_number == 171: return 4
|
||||||
if song_number == 188: return 7
|
if song_number == 188: return 7
|
||||||
if song_number == 192: return 4
|
if song_number == 192: return 4
|
||||||
if song_number == 208: return 8
|
if song_number == 208: return 8
|
||||||
if song_number == 215: return 8
|
if song_number == 215: return 8
|
||||||
if song_number == 220: return 4
|
if song_number == 220: return 4
|
||||||
if song_number == 247: return 6
|
if song_number == 247: return 6
|
||||||
if song_number == 248: return 6
|
if song_number == 248: return 6
|
||||||
if song_number == 251: return 8
|
if song_number == 251: return 8
|
||||||
if song_number == 295: return 8
|
if song_number == 295: return 8
|
||||||
if song_number == 307: return 5
|
if song_number == 307: return 5
|
||||||
if song_number == 314: return 6
|
if song_number == 314: return 6
|
||||||
if song_number == 325: return 8
|
if song_number == 325: return 8
|
||||||
if song_number == 386: return 6
|
if song_number == 386: return 6
|
||||||
if song_number == 415: return 4
|
if song_number == 415: return 4
|
||||||
if song_number == 426: return 4
|
if song_number == 426: return 4
|
||||||
if song_number == 434: return 5
|
if song_number == 434: return 5
|
||||||
if song_number == 437: return 4
|
if song_number == 437: return 4
|
||||||
if song_number == 438: return 6
|
if song_number == 438: return 6
|
||||||
if song_number == 456: return 8
|
if song_number == 456: return 8
|
||||||
if song_number == 461: return 4
|
if song_number == 461: return 4
|
||||||
if song_number == 469: return 4
|
if song_number == 469: return 4
|
||||||
if song_number == 470: return 5
|
if song_number == 470: return 5
|
||||||
if song_number == 476: return 6
|
if song_number == 476: return 6
|
||||||
if song_number == 477: return 7
|
if song_number == 477: return 7
|
||||||
if song_number == 480: return 8
|
if song_number == 480: return 8
|
||||||
if song_number == 482: return 4
|
if song_number == 482: return 4
|
||||||
if song_number == 512: return 4
|
if song_number == 512: return 4
|
||||||
if song_number == 513: return 8
|
if song_number == 513: return 8
|
||||||
if song_number == 518: return 5
|
if song_number == 518: return 5
|
||||||
if song_number == 520: return 4
|
if song_number == 520: return 4
|
||||||
if song_number == 523: return 6
|
if song_number == 523: return 6
|
||||||
if song_number == 526: return 8
|
if song_number == 526: return 8
|
||||||
if song_number == 527: return 4
|
if song_number == 527: return 4
|
||||||
if song_number == 529: return 4
|
if song_number == 529: return 4
|
||||||
if song_number == 537: return 4
|
if song_number == 537: return 4
|
||||||
if song_number == 555: return 6
|
if song_number == 555: return 6
|
||||||
if song_number == 581: return 4
|
if song_number == 581: return 4
|
||||||
if song_number == 589: return 6
|
if song_number == 589: return 6
|
||||||
if song_number == 590: return 4
|
if song_number == 590: return 4
|
||||||
if song_number == 593: return 8
|
if song_number == 593: return 8
|
||||||
if song_number == 596: return 4
|
if song_number == 596: return 4
|
||||||
if song_number == 610: return 6
|
if song_number == 610: return 6
|
||||||
if song_number == 611: return 6
|
if song_number == 611: return 6
|
||||||
if song_number == 619: return 8
|
if song_number == 619: return 8
|
||||||
if song_number == 645: return 5
|
if song_number == 645: return 5
|
||||||
if song_number == 653: return 6
|
if song_number == 653: return 6
|
||||||
if song_number == 683: return 7
|
if song_number == 683: return 7
|
||||||
if song_number == 686: return 4
|
if song_number == 686: return 4
|
||||||
if song_number == 697: return 8
|
if song_number == 697: return 8
|
||||||
if song_number == 698: return 4
|
if song_number == 698: return 4
|
||||||
if song_number == 704: return 6
|
if song_number == 704: return 6
|
||||||
if song_number == 716: return 4
|
if song_number == 716: return 4
|
||||||
if song_number == 717: return 6
|
if song_number == 717: return 6
|
||||||
if song_number == 730: return 4
|
if song_number == 730: return 4
|
||||||
if song_number == 731: return 8
|
if song_number == 731: return 8
|
||||||
if song_number == 732: return 8
|
if song_number == 732: return 8
|
||||||
if song_number == 738: return 4
|
if song_number == 738: return 4
|
||||||
if song_number == 756: return 9
|
if song_number == 756: return 9
|
||||||
if song_number == 815: return 6
|
if song_number == 815: return 6
|
||||||
if song_number == 830: return 8
|
if song_number == 830: return 8
|
||||||
if song_number == 831: return 4
|
if song_number == 831: return 4
|
||||||
if song_number == 876: return 6
|
if song_number == 876: return 6
|
||||||
if song_number == 877: return 6
|
if song_number == 877: return 6
|
||||||
if song_number == 892: return 4
|
if song_number == 892: return 4
|
||||||
if song_number == 894: return 6
|
if song_number == 894: return 6
|
||||||
if song_number == 902: return 8
|
if song_number == 902: return 8
|
||||||
if song_number == 905: return 8
|
if song_number == 905: return 8
|
||||||
if song_number == 921: return 6
|
if song_number == 921: return 6
|
||||||
if song_number == 940: return 7
|
if song_number == 940: return 7
|
||||||
if song_number == 955: return 9
|
if song_number == 955: return 9
|
||||||
if song_number == 968: return 8
|
if song_number == 968: return 8
|
||||||
if song_number == 972: return 7
|
if song_number == 972: return 7
|
||||||
if song_number == 974: return 4
|
if song_number == 974: return 4
|
||||||
if song_number == 988: return 6
|
if song_number == 988: return 6
|
||||||
if song_number == 991: return 5
|
if song_number == 991: return 5
|
||||||
if song_number == 1002: return 8
|
if song_number == 1002: return 8
|
||||||
if song_number == 1024: return 8
|
if song_number == 1024: return 8
|
||||||
if song_number == 1044: return 9
|
if song_number == 1044: return 9
|
||||||
if song_number == 1088: return 6
|
if song_number == 1088: return 6
|
||||||
if song_number == 1117: return 6
|
if song_number == 1117: return 6
|
||||||
if song_number == 1119: return 7
|
if song_number == 1119: return 7
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -24,9 +24,10 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
import string
|
import string
|
||||||
from openlp.core.lib import SongXMLBuilder
|
from PyQt4 import QtGui, QtCore
|
||||||
|
from openlp.core.lib import SongXMLBuilder
|
||||||
from openlp.plugins.songs.lib.models import Song, Author, Topic, Book
|
from openlp.plugins.songs.lib.models import Song, Author, Topic, Book
|
||||||
|
|
||||||
class SongImport(object):
|
class SongImport(object):
|
||||||
"""
|
"""
|
||||||
Helper class for import a song from a third party source into OpenLP
|
Helper class for import a song from a third party source into OpenLP
|
||||||
@ -42,232 +43,328 @@ class SongImport(object):
|
|||||||
|
|
||||||
song_manager is an instance of a SongManager, through which all
|
song_manager is an instance of a SongManager, through which all
|
||||||
database access is performed
|
database access is performed
|
||||||
"""
|
"""
|
||||||
self.manager = song_manager
|
self.manager = song_manager
|
||||||
self.title = u''
|
self.title = u''
|
||||||
self.song_number = u''
|
self.song_number = u''
|
||||||
self.alternate_title = u''
|
self.alternate_title = u''
|
||||||
self.copyright = u''
|
self.copyright = u''
|
||||||
self.comment = u''
|
self.comment = u''
|
||||||
self.theme_name = u''
|
self.theme_name = u''
|
||||||
self.ccli_number = u''
|
self.ccli_number = u''
|
||||||
self.authors = []
|
self.authors = []
|
||||||
self.topics = []
|
self.topics = []
|
||||||
self.song_book_name = u''
|
self.song_book_name = u''
|
||||||
self.song_book_pub = u''
|
self.song_book_pub = u''
|
||||||
self.verse_order_list = []
|
self.verse_order_list = []
|
||||||
self.verses = []
|
self.verses = []
|
||||||
self.versecount = 0
|
self.versecount = 0
|
||||||
self.choruscount = 0
|
self.choruscount = 0
|
||||||
|
self.copyright_string = unicode(QtGui.QApplication.translate( \
|
||||||
|
u'SongImport', u'copyright'))
|
||||||
|
self.copyright_symbol = unicode(QtGui.QApplication.translate( \
|
||||||
|
u'SongImport', u'©'))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def process_songs_text(manager, text):
|
||||||
|
songs = []
|
||||||
|
songtexts = SongImport.tidy_text(text).split(u'\f')
|
||||||
|
song = SongImport(manager)
|
||||||
|
for songtext in songtexts:
|
||||||
|
if songtext.strip():
|
||||||
|
song.process_song_text(songtext.strip())
|
||||||
|
if song.check_complete():
|
||||||
|
songs.append(song)
|
||||||
|
song = SongImport(manager)
|
||||||
|
if song.check_complete():
|
||||||
|
songs.append(song)
|
||||||
|
return songs
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def tidy_text(text):
|
||||||
|
"""
|
||||||
|
Get rid of some dodgy unicode and formatting characters we're not
|
||||||
|
interested in. Some can be converted to ascii.
|
||||||
|
"""
|
||||||
|
text = text.replace(u'\t', u' ')
|
||||||
|
text = text.replace(u'\r\n', u'\n')
|
||||||
|
text = text.replace(u'\r', u'\n')
|
||||||
|
text = text.replace(u'\u2018', u'\'')
|
||||||
|
text = text.replace(u'\u2019', u'\'')
|
||||||
|
text = text.replace(u'\u201c', u'"')
|
||||||
|
text = text.replace(u'\u201d', u'"')
|
||||||
|
text = text.replace(u'\u2026', u'...')
|
||||||
|
text = text.replace(u'\u2013', u'-')
|
||||||
|
text = text.replace(u'\u2014', u'-')
|
||||||
|
# Remove surplus blank lines, spaces, trailing/leading spaces
|
||||||
|
while text.find(u' ') >= 0:
|
||||||
|
text = text.replace(u' ', u' ')
|
||||||
|
text = text.replace(u'\n ', u'\n')
|
||||||
|
text = text.replace(u' \n', u'\n')
|
||||||
|
text = text.replace(u'\n\n\n\n\n', u'\f')
|
||||||
|
text = text.replace(u'\f ', u'\f')
|
||||||
|
text = text.replace(u' \f', u'\f')
|
||||||
|
while text.find(u'\f\f') >= 0:
|
||||||
|
text = text.replace(u'\f\f', u'\f')
|
||||||
|
return text
|
||||||
|
|
||||||
|
def process_song_text(self, text):
|
||||||
|
versetexts = text.split(u'\n\n')
|
||||||
|
for versetext in versetexts:
|
||||||
|
if versetext.strip() != u'':
|
||||||
|
self.process_verse_text(versetext.strip())
|
||||||
|
|
||||||
|
def process_verse_text(self, text):
|
||||||
|
lines = text.split(u'\n')
|
||||||
|
if text.lower().find(self.copyright_string) >= 0 \
|
||||||
|
or text.lower().find(self.copyright_symbol) >= 0:
|
||||||
|
copyright_found = False
|
||||||
|
for line in lines:
|
||||||
|
if copyright_found or line.lower().find(self.copyright_string) >= 0\
|
||||||
|
or line.lower().find(self.copyright_symbol) >= 0:
|
||||||
|
copyright_found = True
|
||||||
|
self.add_copyright(line)
|
||||||
|
else:
|
||||||
|
self.parse_author(line)
|
||||||
|
return
|
||||||
|
if len(lines) == 1:
|
||||||
|
self.parse_author(lines[0])
|
||||||
|
return
|
||||||
|
if not self.get_title():
|
||||||
|
self.set_title(lines[0])
|
||||||
|
self.add_verse(text)
|
||||||
|
|
||||||
def get_title(self):
|
def get_title(self):
|
||||||
"""
|
"""
|
||||||
Return the title
|
Return the title
|
||||||
"""
|
"""
|
||||||
return self.title
|
return self.title
|
||||||
|
|
||||||
def get_copyright(self):
|
def get_copyright(self):
|
||||||
"""
|
"""
|
||||||
Return the copyright
|
Return the copyright
|
||||||
"""
|
"""
|
||||||
return self.copyright
|
return self.copyright
|
||||||
|
|
||||||
def get_song_number(self):
|
def get_song_number(self):
|
||||||
"""
|
"""
|
||||||
Return the song number
|
Return the song number
|
||||||
"""
|
"""
|
||||||
return self.song_number
|
return self.song_number
|
||||||
|
|
||||||
def set_title(self, title):
|
def set_title(self, title):
|
||||||
"""
|
"""
|
||||||
Set the title
|
Set the title
|
||||||
"""
|
"""
|
||||||
self.title = title
|
self.title = title
|
||||||
|
|
||||||
def set_alternate_title(self, title):
|
def set_alternate_title(self, title):
|
||||||
"""
|
"""
|
||||||
Set the alternate title
|
Set the alternate title
|
||||||
"""
|
"""
|
||||||
self.alternate_title = title
|
self.alternate_title = title
|
||||||
|
|
||||||
def set_song_number(self, song_number):
|
def set_song_number(self, song_number):
|
||||||
"""
|
"""
|
||||||
Set the song number
|
Set the song number
|
||||||
"""
|
"""
|
||||||
self.song_number = song_number
|
self.song_number = song_number
|
||||||
|
|
||||||
def set_song_book(self, song_book, publisher):
|
def set_song_book(self, song_book, publisher):
|
||||||
"""
|
"""
|
||||||
Set the song book name and publisher
|
Set the song book name and publisher
|
||||||
"""
|
"""
|
||||||
self.song_book_name = song_book
|
self.song_book_name = song_book
|
||||||
self.song_book_pub = publisher
|
self.song_book_pub = publisher
|
||||||
|
|
||||||
def add_copyright(self, copyright):
|
def add_copyright(self, copyright):
|
||||||
"""
|
"""
|
||||||
Build the copyright field
|
Build the copyright field
|
||||||
"""
|
"""
|
||||||
if self.copyright != u'':
|
if self.copyright.find(copyright) >= 0:
|
||||||
self.copyright += ' '
|
return
|
||||||
self.copyright += copyright
|
if self.copyright != u'':
|
||||||
|
self.copyright += ' '
|
||||||
def add_author(self, text):
|
self.copyright += copyright
|
||||||
|
|
||||||
|
def parse_author(self, text):
|
||||||
|
"""
|
||||||
|
Add the author. OpenLP stores them individually so split by 'and', '&'
|
||||||
|
and comma.
|
||||||
|
However need to check for "Mr and Mrs Smith" and turn it to
|
||||||
|
"Mr Smith" and "Mrs Smith".
|
||||||
|
"""
|
||||||
|
for author in text.split(u','):
|
||||||
|
authors = author.split(u'&')
|
||||||
|
for i in range(len(authors)):
|
||||||
|
author2 = authors[i].strip()
|
||||||
|
if author2.find(u' ') == -1 and i < len(authors) - 1:
|
||||||
|
author2 = author2 + u' ' \
|
||||||
|
+ authors[i + 1].strip().split(u' ')[-1]
|
||||||
|
if author2.endswith(u'.'):
|
||||||
|
author2 = author2[:-1]
|
||||||
|
if author2:
|
||||||
|
self.add_author(author2)
|
||||||
|
|
||||||
|
def add_author(self, author):
|
||||||
"""
|
"""
|
||||||
Add an author to the list
|
Add an author to the list
|
||||||
"""
|
"""
|
||||||
self.authors.append(text)
|
if author in self.authors:
|
||||||
|
return
|
||||||
def add_verse(self, verse, versetag):
|
self.authors.append(author)
|
||||||
|
|
||||||
|
def add_verse(self, verse, versetag=None):
|
||||||
"""
|
"""
|
||||||
Add a verse. This is the whole verse, lines split by \n
|
Add a verse. This is the whole verse, lines split by \n
|
||||||
Verse tag can be V1/C1/B etc, or 'V' and 'C' (will count the verses/
|
Verse tag can be V1/C1/B etc, or 'V' and 'C' (will count the verses/
|
||||||
choruses itself) or None, where it will assume verse
|
choruses itself) or None, where it will assume verse
|
||||||
It will also attempt to detect duplicates. In this case it will just
|
It will also attempt to detect duplicates. In this case it will just
|
||||||
add to the verse order
|
add to the verse order
|
||||||
"""
|
"""
|
||||||
for (oldversetag, oldverse) in self.verses:
|
for (oldversetag, oldverse) in self.verses:
|
||||||
if oldverse.strip() == verse.strip():
|
if oldverse.strip() == verse.strip():
|
||||||
self.verse_order_list.append(oldversetag)
|
self.verse_order_list.append(oldversetag)
|
||||||
return
|
return
|
||||||
if versetag.startswith(u'C'):
|
if versetag == u'V' or not versetag:
|
||||||
self.choruscount += 1
|
self.versecount += 1
|
||||||
if versetag == u'C':
|
versetag = u'V' + unicode(self.versecount)
|
||||||
versetag += unicode(self.choruscount)
|
if versetag.startswith(u'C'):
|
||||||
if versetag == u'V' or not versetag:
|
self.choruscount += 1
|
||||||
self.versecount += 1
|
if versetag == u'C':
|
||||||
versetag = u'V' + unicode(self.versecount)
|
versetag += unicode(self.choruscount)
|
||||||
self.verses.append([versetag, verse.rstrip()])
|
self.verses.append([versetag, verse.rstrip()])
|
||||||
self.verse_order_list.append(versetag)
|
self.verse_order_list.append(versetag)
|
||||||
if versetag.startswith(u'V') and self.contains_verse(u'C1'):
|
if versetag.startswith(u'V') and self.contains_verse(u'C1'):
|
||||||
self.verse_order_list.append(u'C1')
|
self.verse_order_list.append(u'C1')
|
||||||
|
|
||||||
def repeat_verse(self):
|
def repeat_verse(self):
|
||||||
"""
|
"""
|
||||||
Repeat the previous verse in the verse order
|
Repeat the previous verse in the verse order
|
||||||
"""
|
"""
|
||||||
self.verse_order_list.append(self.verse_order_list[-1])
|
self.verse_order_list.append(self.verse_order_list[-1])
|
||||||
|
|
||||||
def contains_verse(self, versetag):
|
def contains_verse(self, versetag):
|
||||||
return versetag in self.verse_order_list
|
return versetag in self.verse_order_list
|
||||||
|
|
||||||
def check_complete(self):
|
def check_complete(self):
|
||||||
"""
|
"""
|
||||||
Check the mandatory fields are entered (i.e. title and a verse)
|
Check the mandatory fields are entered (i.e. title and a verse)
|
||||||
Author not checked here, if no author then "Author unknown" is
|
Author not checked here, if no author then "Author unknown" is
|
||||||
automatically added
|
automatically added
|
||||||
"""
|
"""
|
||||||
if self.title == u'' or len(self.verses) == 0:
|
if self.title == u'' or len(self.verses) == 0:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def remove_punctuation(self, text):
|
def remove_punctuation(self, text):
|
||||||
"""
|
"""
|
||||||
Remove punctuation from the string for searchable fields
|
Remove punctuation from the string for searchable fields
|
||||||
"""
|
"""
|
||||||
for c in string.punctuation:
|
for c in string.punctuation:
|
||||||
text = text.replace(c, u'')
|
text = text.replace(c, u'')
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def finish(self):
|
def finish(self):
|
||||||
"""
|
"""
|
||||||
All fields have been set to this song. Write it away
|
All fields have been set to this song. Write it away
|
||||||
"""
|
"""
|
||||||
if len(self.authors) == 0:
|
if len(self.authors) == 0:
|
||||||
self.authors.append(u'Author unknown')
|
self.authors.append(u'Author unknown')
|
||||||
self.commit_song()
|
self.commit_song()
|
||||||
#self.print_song()
|
#self.print_song()
|
||||||
|
|
||||||
def commit_song(self):
|
def commit_song(self):
|
||||||
"""
|
"""
|
||||||
Write the song and it's fields to disk
|
Write the song and it's fields to disk
|
||||||
"""
|
"""
|
||||||
song = Song()
|
song = Song()
|
||||||
song.title = self.title
|
song.title = self.title
|
||||||
song.search_title = self.remove_punctuation(self.title) \
|
song.search_title = self.remove_punctuation(self.title) \
|
||||||
+ '@' + self.alternate_title
|
+ '@' + self.alternate_title
|
||||||
song.song_number = self.song_number
|
song.song_number = self.song_number
|
||||||
song.search_lyrics = u''
|
song.search_lyrics = u''
|
||||||
sxml = SongXMLBuilder()
|
sxml = SongXMLBuilder()
|
||||||
sxml.new_document()
|
sxml.new_document()
|
||||||
sxml.add_lyrics_to_song()
|
sxml.add_lyrics_to_song()
|
||||||
for (versetag, versetext) in self.verses:
|
for (versetag, versetext) in self.verses:
|
||||||
if versetag[0] == u'C':
|
if versetag[0] == u'C':
|
||||||
versetype = u'Chorus'
|
versetype = u'Chorus'
|
||||||
elif versetag[0] == u'V':
|
elif versetag[0] == u'V':
|
||||||
versetype = u'Verse'
|
versetype = u'Verse'
|
||||||
elif versetag[0] == u'B':
|
elif versetag[0] == u'B':
|
||||||
versetype = u'Bridge'
|
versetype = u'Bridge'
|
||||||
elif versetag[0] == u'I':
|
elif versetag[0] == u'I':
|
||||||
versetype = u'Intro'
|
versetype = u'Intro'
|
||||||
elif versetag[0] == u'P':
|
elif versetag[0] == u'P':
|
||||||
versetype = u'Prechorus'
|
versetype = u'Prechorus'
|
||||||
elif versetag[0] == u'E':
|
elif versetag[0] == u'E':
|
||||||
versetype = u'Ending'
|
versetype = u'Ending'
|
||||||
else:
|
else:
|
||||||
versetype = u'Other'
|
versetype = u'Other'
|
||||||
sxml.add_verse_to_lyrics(versetype, versetag[1:], versetext)
|
sxml.add_verse_to_lyrics(versetype, versetag[1:], versetext)
|
||||||
song.search_lyrics += u' ' + self.remove_punctuation(versetext)
|
song.search_lyrics += u' ' + self.remove_punctuation(versetext)
|
||||||
song.lyrics = unicode(sxml.extract_xml(), u'utf-8')
|
song.lyrics = unicode(sxml.extract_xml(), u'utf-8')
|
||||||
song.verse_order = u' '.join(self.verse_order_list)
|
song.verse_order = u' '.join(self.verse_order_list)
|
||||||
song.copyright = self.copyright
|
song.copyright = self.copyright
|
||||||
song.comment = self.comment
|
song.comment = self.comment
|
||||||
song.theme_name = self.theme_name
|
song.theme_name = self.theme_name
|
||||||
song.ccli_number = self.ccli_number
|
song.ccli_number = self.ccli_number
|
||||||
for authortext in self.authors:
|
for authortext in self.authors:
|
||||||
author = self.manager.get_author_by_name(authortext)
|
author = self.manager.get_author_by_name(authortext)
|
||||||
if author is None:
|
if author is None:
|
||||||
author = Author()
|
author = Author()
|
||||||
author.display_name = authortext
|
author.display_name = authortext
|
||||||
author.last_name = authortext.split(u' ')[-1]
|
author.last_name = authortext.split(u' ')[-1]
|
||||||
author.first_name = u' '.join(authortext.split(u' ')[:-1])
|
author.first_name = u' '.join(authortext.split(u' ')[:-1])
|
||||||
self.manager.save_author(author)
|
self.manager.save_author(author)
|
||||||
song.authors.append(author)
|
song.authors.append(author)
|
||||||
if self.song_book_name:
|
if self.song_book_name:
|
||||||
song_book = self.manager.get_book_by_name(self.song_book_name)
|
song_book = self.manager.get_book_by_name(self.song_book_name)
|
||||||
if song_book is None:
|
if song_book is None:
|
||||||
song_book = Book()
|
song_book = Book()
|
||||||
song_book.name = self.song_book_name
|
song_book.name = self.song_book_name
|
||||||
song_book.publisher = self.song_book_pub
|
song_book.publisher = self.song_book_pub
|
||||||
self.manager.save_book(song_book)
|
self.manager.save_book(song_book)
|
||||||
song.song_book_id = song_book.id
|
song.song_book_id = song_book.id
|
||||||
for topictext in self.topics:
|
for topictext in self.topics:
|
||||||
topic = self.manager.get_topic_by_name(topictext)
|
topic = self.manager.get_topic_by_name(topictext)
|
||||||
if topic is None:
|
if topic is None:
|
||||||
topic = Topic()
|
topic = Topic()
|
||||||
topic.name = topictext
|
topic.name = topictext
|
||||||
self.manager.save_topic(topic)
|
self.manager.save_topic(topic)
|
||||||
song.topics.append(topictext)
|
song.topics.append(topictext)
|
||||||
self.manager.save_song(song)
|
self.manager.save_song(song)
|
||||||
|
|
||||||
def print_song(self):
|
def print_song(self):
|
||||||
"""
|
"""
|
||||||
For debugging
|
For debugging
|
||||||
"""
|
"""
|
||||||
print u'========================================' \
|
print u'========================================' \
|
||||||
+ u'========================================'
|
+ u'========================================'
|
||||||
print u'TITLE: ' + self.title
|
print u'TITLE: ' + self.title
|
||||||
print u'ALT TITLE: ' + self.alternate_title
|
print u'ALT TITLE: ' + self.alternate_title
|
||||||
for (versetag, versetext) in self.verses:
|
for (versetag, versetext) in self.verses:
|
||||||
print u'VERSE ' + versetag + u': ' + versetext
|
print u'VERSE ' + versetag + u': ' + versetext
|
||||||
print u'ORDER: ' + u' '.join(self.verse_order_list)
|
print u'ORDER: ' + u' '.join(self.verse_order_list)
|
||||||
for author in self.authors:
|
for author in self.authors:
|
||||||
print u'AUTHOR: ' + author
|
print u'AUTHOR: ' + author
|
||||||
if self.copyright:
|
if self.copyright:
|
||||||
print u'COPYRIGHT: ' + self.copyright
|
print u'COPYRIGHT: ' + self.copyright
|
||||||
if self.song_book_name:
|
if self.song_book_name:
|
||||||
print u'BOOK: ' + self.song_book_name
|
print u'BOOK: ' + self.song_book_name
|
||||||
if self.song_book_pub:
|
if self.song_book_pub:
|
||||||
print u'BOOK PUBLISHER: ' + self.song_book_pub
|
print u'BOOK PUBLISHER: ' + self.song_book_pub
|
||||||
if self.song_number:
|
if self.song_number:
|
||||||
print u'NUMBER: ' + self.song_number
|
print u'NUMBER: ' + self.song_number
|
||||||
for topictext in self.topics:
|
for topictext in self.topics:
|
||||||
print u'TOPIC: ' + topictext
|
print u'TOPIC: ' + topictext
|
||||||
if self.comment:
|
if self.comment:
|
||||||
print u'COMMENT: ' + self.comment
|
print u'COMMENT: ' + self.comment
|
||||||
if self.theme_name:
|
if self.theme_name:
|
||||||
print u'THEME: ' + self.theme_name
|
print u'THEME: ' + self.theme_name
|
||||||
if self.ccli_number:
|
if self.ccli_number:
|
||||||
print u'CCLI: ' + self.ccli_number
|
print u'CCLI: ' + self.ccli_number
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ from PyQt4 import QtCore, QtGui
|
|||||||
|
|
||||||
from openlp.core.lib import Plugin, build_icon, PluginStatus, Receiver
|
from openlp.core.lib import Plugin, build_icon, PluginStatus, Receiver
|
||||||
from openlp.plugins.songs.lib import SongManager, SongMediaItem, SongsTab, \
|
from openlp.plugins.songs.lib import SongManager, SongMediaItem, SongsTab, \
|
||||||
SofImport
|
SofImport, OooImport
|
||||||
from openlp.plugins.songs.forms import OpenLPImportForm, OpenSongExportForm, \
|
from openlp.plugins.songs.forms import OpenLPImportForm, OpenSongExportForm, \
|
||||||
OpenSongImportForm, OpenLPExportForm
|
OpenSongImportForm, OpenLPExportForm
|
||||||
|
|
||||||
@ -105,11 +105,14 @@ class SongsPlugin(Plugin):
|
|||||||
self.ImportOpenlp2Item.setObjectName(u'ImportOpenlp2Item')
|
self.ImportOpenlp2Item.setObjectName(u'ImportOpenlp2Item')
|
||||||
self.ImportSofItem = QtGui.QAction(import_menu)
|
self.ImportSofItem = QtGui.QAction(import_menu)
|
||||||
self.ImportSofItem.setObjectName(u'ImportSofItem')
|
self.ImportSofItem.setObjectName(u'ImportSofItem')
|
||||||
|
self.ImportOooItem = QtGui.QAction(import_menu)
|
||||||
|
self.ImportOooItem.setObjectName(u'ImportOooItem')
|
||||||
# Add to menus
|
# Add to menus
|
||||||
self.ImportSongMenu.addAction(self.ImportOpenlp1Item)
|
self.ImportSongMenu.addAction(self.ImportOpenlp1Item)
|
||||||
self.ImportSongMenu.addAction(self.ImportOpenlp2Item)
|
self.ImportSongMenu.addAction(self.ImportOpenlp2Item)
|
||||||
self.ImportSongMenu.addAction(self.ImportOpenSongItem)
|
self.ImportSongMenu.addAction(self.ImportOpenSongItem)
|
||||||
self.ImportSongMenu.addAction(self.ImportSofItem)
|
self.ImportSongMenu.addAction(self.ImportSofItem)
|
||||||
|
self.ImportSongMenu.addAction(self.ImportOooItem)
|
||||||
import_menu.addAction(self.ImportSongMenu.menuAction())
|
import_menu.addAction(self.ImportSongMenu.menuAction())
|
||||||
# Translations...
|
# Translations...
|
||||||
self.ImportSongMenu.setTitle(import_menu.trUtf8('&Song'))
|
self.ImportSongMenu.setTitle(import_menu.trUtf8('&Song'))
|
||||||
@ -132,6 +135,12 @@ class SongsPlugin(Plugin):
|
|||||||
self.ImportSofItem.setStatusTip(
|
self.ImportSofItem.setStatusTip(
|
||||||
import_menu.trUtf8('Import songs from the VOLS1_2.RTF, sof3words' \
|
import_menu.trUtf8('Import songs from the VOLS1_2.RTF, sof3words' \
|
||||||
+ '.rtf and sof4words.rtf supplied with the music books'))
|
+ '.rtf and sof4words.rtf supplied with the music books'))
|
||||||
|
self.ImportOooItem.setText(
|
||||||
|
import_menu.trUtf8('Generic Document/Presentation Import'))
|
||||||
|
self.ImportOooItem.setToolTip(
|
||||||
|
import_menu.trUtf8('Import songs from Word/Writer/Powerpoint/Impress'))
|
||||||
|
self.ImportOooItem.setStatusTip(
|
||||||
|
import_menu.trUtf8('Import songs from Word/Writer/Powerpoint/Impress'))
|
||||||
# Signals and slots
|
# Signals and slots
|
||||||
QtCore.QObject.connect(self.ImportOpenlp1Item,
|
QtCore.QObject.connect(self.ImportOpenlp1Item,
|
||||||
QtCore.SIGNAL(u'triggered()'), self.onImportOpenlp1ItemClick)
|
QtCore.SIGNAL(u'triggered()'), self.onImportOpenlp1ItemClick)
|
||||||
@ -141,6 +150,8 @@ class SongsPlugin(Plugin):
|
|||||||
QtCore.SIGNAL(u'triggered()'), self.onImportOpenSongItemClick)
|
QtCore.SIGNAL(u'triggered()'), self.onImportOpenSongItemClick)
|
||||||
QtCore.QObject.connect(self.ImportSofItem,
|
QtCore.QObject.connect(self.ImportSofItem,
|
||||||
QtCore.SIGNAL(u'triggered()'), self.onImportSofItemClick)
|
QtCore.SIGNAL(u'triggered()'), self.onImportSofItemClick)
|
||||||
|
QtCore.QObject.connect(self.ImportOooItem,
|
||||||
|
QtCore.SIGNAL(u'triggered()'), self.onImportOooItemClick)
|
||||||
self.ImportSongMenu.menuAction().setVisible(False)
|
self.ImportSongMenu.menuAction().setVisible(False)
|
||||||
|
|
||||||
def add_export_menu_item(self, export_menu):
|
def add_export_menu_item(self, export_menu):
|
||||||
@ -184,12 +195,13 @@ class SongsPlugin(Plugin):
|
|||||||
self.opensong_import_form.show()
|
self.opensong_import_form.show()
|
||||||
|
|
||||||
def onImportSofItemClick(self):
|
def onImportSofItemClick(self):
|
||||||
filename = QtGui.QFileDialog.getOpenFileName(
|
filenames = QtGui.QFileDialog.getOpenFileNames(
|
||||||
None, self.trUtf8('Open Songs of Fellowship file'),
|
None, self.trUtf8('Open Songs of Fellowship file'),
|
||||||
u'', u'Songs of Fellowship file (*.rtf *.RTF)')
|
u'', u'Songs of Fellowship file (*.rtf *.RTF)')
|
||||||
try:
|
try:
|
||||||
sofimport = SofImport(self.songmanager)
|
for filename in filenames:
|
||||||
sofimport.import_sof(unicode(filename))
|
sofimport = SofImport(self.songmanager)
|
||||||
|
sofimport.import_sof(unicode(filename))
|
||||||
except:
|
except:
|
||||||
log.exception('Could not import SoF file')
|
log.exception('Could not import SoF file')
|
||||||
QtGui.QMessageBox.critical(None,
|
QtGui.QMessageBox.critical(None,
|
||||||
@ -202,6 +214,14 @@ class SongsPlugin(Plugin):
|
|||||||
QtGui.QMessageBox.Ok)
|
QtGui.QMessageBox.Ok)
|
||||||
Receiver.send_message(u'load_song_list')
|
Receiver.send_message(u'load_song_list')
|
||||||
|
|
||||||
|
def onImportOooItemClick(self):
|
||||||
|
filenames = QtGui.QFileDialog.getOpenFileNames(
|
||||||
|
None, self.trUtf8('Open documents or presentations'),
|
||||||
|
u'', u'All Files(*.*)')
|
||||||
|
oooimport = OooImport(self.songmanager)
|
||||||
|
oooimport.import_docs(filenames)
|
||||||
|
Receiver.send_message(u'load_song_list')
|
||||||
|
|
||||||
def onExportOpenlp1ItemClicked(self):
|
def onExportOpenlp1ItemClicked(self):
|
||||||
self.openlp_export_form.show()
|
self.openlp_export_form.show()
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="UpButton">
|
<widget class="QPushButton" name="UpButton">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string extracomment="Move selected slide up one"/>
|
<string extracomment="Move slide up 1"/>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
@ -73,7 +73,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="DownButton">
|
<widget class="QPushButton" name="DownButton">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string extracomment="Move selected slide down one"/>
|
<string extracomment="Move slide down 1"/>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
@ -106,7 +106,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="AddButton">
|
<widget class="QPushButton" name="AddButton">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string extracomment="Adds a new slide at bottom of list"/>
|
<string extracomment="Adds a new slide at bottom"/>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add New</string>
|
<string>Add New</string>
|
||||||
@ -136,7 +136,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="SaveButton">
|
<widget class="QPushButton" name="SaveButton">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string extracomment="Save changed slide"/>
|
<string extracomment="Replace edited slide"/>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Save</string>
|
<string>Save</string>
|
||||||
@ -163,6 +163,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="SplitButton">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string extracomment="Add new slide split"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Split Slide</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="ButtonSpacer">
|
<spacer name="ButtonSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@ -216,8 +226,11 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="5" column="0">
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string extracomment="Edit dialog"/>
|
||||||
|
</property>
|
||||||
<property name="standardButtons">
|
<property name="standardButtons">
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -236,12 +249,44 @@
|
|||||||
<tabstop>UpButton</tabstop>
|
<tabstop>UpButton</tabstop>
|
||||||
<tabstop>DownButton</tabstop>
|
<tabstop>DownButton</tabstop>
|
||||||
<tabstop>ThemeComboBox</tabstop>
|
<tabstop>ThemeComboBox</tabstop>
|
||||||
<tabstop>buttonBox</tabstop>
|
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../images/openlp-2.qrc"/>
|
<include location="../images/openlp-2.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections/>
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>customEditDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>294</x>
|
||||||
|
<y>524</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>294</x>
|
||||||
|
<y>270</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>customEditDialog</receiver>
|
||||||
|
<slot>close()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>294</x>
|
||||||
|
<y>524</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>294</x>
|
||||||
|
<y>270</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
<slots>
|
<slots>
|
||||||
<slot>accept()</slot>
|
<slot>accept()</slot>
|
||||||
<slot>rejected()</slot>
|
<slot>rejected()</slot>
|
||||||
|
2
setup.py
2
setup.py
@ -69,7 +69,7 @@ OpenLP (previously openlp.org) is free church presentation software, or lyrics p
|
|||||||
license='GNU General Public License',
|
license='GNU General Public License',
|
||||||
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
|
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
|
||||||
scripts=['openlp.pyw', 'scripts/openlp-1to2-converter.py',
|
scripts=['openlp.pyw', 'scripts/openlp-1to2-converter.py',
|
||||||
'scripts/bible-1to2-converter.py','scripts/openlp-remoteclient.py'],
|
'scripts/bible-1to2-converter.py','scripts/openlp-remoteclient.py'],
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
install_requires=[
|
install_requires=[
|
||||||
|
Loading…
Reference in New Issue
Block a user