forked from openlp/openlp
Head
This commit is contained in:
commit
16478ed1cd
@ -71,7 +71,7 @@ class Renderer(object):
|
||||
log.debug(u'Initilisation started')
|
||||
self.screens = screens
|
||||
self.image_manager = ImageManager()
|
||||
self.display = MainDisplay(self, screens, False)
|
||||
self.display = MainDisplay(self, screens, False, False)
|
||||
self.display.imageManager = self.image_manager
|
||||
self.theme_manager = theme_manager
|
||||
self.service_theme = u''
|
||||
@ -222,13 +222,13 @@ class Renderer(object):
|
||||
# Songs and Custom
|
||||
if item.is_capable(ItemCapabilities.AllowsVirtualSplit):
|
||||
# Do not forget the line breaks !
|
||||
slides = text.split(u'\n[---]\n')
|
||||
slides = text.split(u'[---]')
|
||||
pages = []
|
||||
for slide in slides:
|
||||
lines = self._lines(slide)
|
||||
lines = slide.strip(u'\n').split(u'\n')
|
||||
new_pages = self._paginate_slide(lines, line_break,
|
||||
self.force_page)
|
||||
pages.extend([page for page in new_pages])
|
||||
pages.extend(new_pages)
|
||||
# Bibles
|
||||
elif item.is_capable(ItemCapabilities.AllowsWordSplit):
|
||||
pages = self._paginate_slide_words(text, line_break)
|
||||
@ -341,12 +341,14 @@ class Renderer(object):
|
||||
if force_page and line_count > 0:
|
||||
Receiver.send_message(u'theme_line_count', line_count)
|
||||
line_count = -1
|
||||
html_text = html_text.rstrip(u'<br>')
|
||||
while html_text.endswith(u'<br>'):
|
||||
html_text = html_text[:-4]
|
||||
formatted.append(html_text)
|
||||
html_text = u''
|
||||
styled_text = styled_line
|
||||
html_text += line + line_end
|
||||
html_text = html_text.rstrip(u'<br>')
|
||||
while html_text.endswith(u'<br>'):
|
||||
html_text = html_text[:-4]
|
||||
formatted.append(html_text)
|
||||
log.debug(u'_paginate_slide - End')
|
||||
return formatted
|
||||
@ -371,7 +373,7 @@ class Renderer(object):
|
||||
formatted = []
|
||||
previous_html = u''
|
||||
previous_raw = u''
|
||||
lines = self._lines(text)
|
||||
lines = text.split(u'\n')
|
||||
for line in lines:
|
||||
styled_line = expand_tags(line)
|
||||
html = self.page_shell + previous_html + styled_line + HTML_END
|
||||
@ -385,7 +387,8 @@ class Renderer(object):
|
||||
self.web.setHtml(html)
|
||||
if self.web_frame.contentsSize().height() <= \
|
||||
self.page_height:
|
||||
previous_raw = previous_raw.rstrip(u'<br>')
|
||||
while previous_raw.endswith(u'<br>'):
|
||||
previous_raw = previous_raw[:-4]
|
||||
formatted.append(previous_raw)
|
||||
previous_html = u''
|
||||
previous_raw = u''
|
||||
@ -408,7 +411,8 @@ class Renderer(object):
|
||||
# Text too long so go to next page
|
||||
if self.web_frame.contentsSize().height() > \
|
||||
self.page_height:
|
||||
previous_raw = previous_raw.rstrip(u'<br>')
|
||||
while previous_raw.endswith(u'<br>'):
|
||||
previous_raw = previous_raw[:-4]
|
||||
formatted.append(previous_raw)
|
||||
previous_html = u''
|
||||
previous_raw = u''
|
||||
@ -419,36 +423,20 @@ class Renderer(object):
|
||||
else:
|
||||
previous_html += styled_line + line_end
|
||||
previous_raw += line + line_end
|
||||
previous_raw = previous_raw.rstrip(u'<br>')
|
||||
while previous_raw.endswith(u'<br>'):
|
||||
previous_raw = previous_raw[:-4]
|
||||
formatted.append(previous_raw)
|
||||
log.debug(u'_paginate_slide_words - End')
|
||||
return formatted
|
||||
|
||||
def _lines(self, text):
|
||||
"""
|
||||
Split the slide up by physical line
|
||||
"""
|
||||
# this parse we do not want to use this so remove it
|
||||
verses_text = text.split(u'\n')
|
||||
text = []
|
||||
for verse in verses_text:
|
||||
lines = verse.split(u'\n')
|
||||
text.extend([line for line in lines])
|
||||
|
||||
return text
|
||||
|
||||
def _words_split(self, line):
|
||||
"""
|
||||
Split the slide up by word so can wrap better
|
||||
"""
|
||||
# this parse we are to be wordy
|
||||
line = line.replace(u'\n', u' ')
|
||||
verses_text = line.split(u' ')
|
||||
text = []
|
||||
for verse in verses_text:
|
||||
lines = verse.split(u' ')
|
||||
text.extend([line + u' ' for line in lines])
|
||||
return text
|
||||
words = line.split(u' ')
|
||||
return [word + u' ' for word in words]
|
||||
|
||||
def _lines_split(self, text):
|
||||
"""
|
||||
@ -457,9 +445,4 @@ class Renderer(object):
|
||||
# this parse we do not want to use this so remove it
|
||||
text = text.replace(u'\n[---]', u'')
|
||||
lines = text.split(u'\n')
|
||||
real_lines = []
|
||||
for line in lines:
|
||||
line = line.replace(u'[---]', u'')
|
||||
sub_lines = line.split(u'\n')
|
||||
real_lines.extend([sub_line for sub_line in sub_lines])
|
||||
return real_lines
|
||||
return [line.replace(u'[---]', u'') for line in lines]
|
||||
|
@ -60,16 +60,19 @@ class MainDisplay(DisplayWidget):
|
||||
"""
|
||||
This is the display screen.
|
||||
"""
|
||||
def __init__(self, parent, screens, live):
|
||||
def __init__(self, parent, screens, live, needsPhonon=True):
|
||||
DisplayWidget.__init__(self, live, parent=None)
|
||||
self.parent = parent
|
||||
self.screens = screens
|
||||
self.isLive = live
|
||||
self.needsPhonon = needsPhonon
|
||||
self.alertTab = None
|
||||
self.hideMode = None
|
||||
self.videoHide = False
|
||||
self.override = {}
|
||||
self.retranslateUi()
|
||||
self.mediaObject = None
|
||||
self.firstTime = True
|
||||
self.setStyleSheet(u'border: 0px; margin: 0px; padding: 0px;')
|
||||
self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool |
|
||||
QtCore.Qt.WindowStaysOnTopHint)
|
||||
@ -78,6 +81,9 @@ class MainDisplay(DisplayWidget):
|
||||
QtCore.SIGNAL(u'maindisplay_hide'), self.hideDisplay)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'maindisplay_show'), self.showDisplay)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'openlp_phonon_creation'),
|
||||
self.createMediaObject)
|
||||
|
||||
def retranslateUi(self):
|
||||
"""
|
||||
@ -102,19 +108,9 @@ class MainDisplay(DisplayWidget):
|
||||
self.videoWidget.setGeometry(QtCore.QRect(0, 0,
|
||||
self.screen[u'size'].width(), self.screen[u'size'].height()))
|
||||
log.debug(u'Setup Phonon for monitor %s' % self.screens.monitor_number)
|
||||
self.mediaObject = Phonon.MediaObject(self)
|
||||
self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self.mediaObject)
|
||||
Phonon.createPath(self.mediaObject, self.videoWidget)
|
||||
Phonon.createPath(self.mediaObject, self.audio)
|
||||
QtCore.QObject.connect(self.mediaObject,
|
||||
QtCore.SIGNAL(u'stateChanged(Phonon::State, Phonon::State)'),
|
||||
self.videoState)
|
||||
QtCore.QObject.connect(self.mediaObject,
|
||||
QtCore.SIGNAL(u'finished()'),
|
||||
self.videoFinished)
|
||||
QtCore.QObject.connect(self.mediaObject,
|
||||
QtCore.SIGNAL(u'tick(qint64)'),
|
||||
self.videoTick)
|
||||
if self.isLive:
|
||||
if not self.firstTime:
|
||||
self.createMediaObject()
|
||||
log.debug(u'Setup webView for monitor %s' % self.screens.monitor_number)
|
||||
self.webView = QtWebKit.QWebView(self)
|
||||
self.webView.setGeometry(0, 0,
|
||||
@ -175,6 +171,24 @@ class MainDisplay(DisplayWidget):
|
||||
log.debug(
|
||||
u'Finished setup for monitor %s' % self.screens.monitor_number)
|
||||
|
||||
def createMediaObject(self):
|
||||
self.firstTime = False
|
||||
log.debug(u'Creating Phonon objects - Start for %s', self.isLive)
|
||||
self.mediaObject = Phonon.MediaObject(self)
|
||||
self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self.mediaObject)
|
||||
Phonon.createPath(self.mediaObject, self.videoWidget)
|
||||
Phonon.createPath(self.mediaObject, self.audio)
|
||||
QtCore.QObject.connect(self.mediaObject,
|
||||
QtCore.SIGNAL(u'stateChanged(Phonon::State, Phonon::State)'),
|
||||
self.videoState)
|
||||
QtCore.QObject.connect(self.mediaObject,
|
||||
QtCore.SIGNAL(u'finished()'),
|
||||
self.videoFinished)
|
||||
QtCore.QObject.connect(self.mediaObject,
|
||||
QtCore.SIGNAL(u'tick(qint64)'),
|
||||
self.videoTick)
|
||||
log.debug(u'Creating Phonon objects - Finished for %s', self.isLive)
|
||||
|
||||
def text(self, slide):
|
||||
"""
|
||||
Add the slide text from slideController
|
||||
@ -348,6 +362,8 @@ class MainDisplay(DisplayWidget):
|
||||
"""
|
||||
Loads and starts a video to run with the option of sound
|
||||
"""
|
||||
if not self.mediaObject:
|
||||
self.createMediaObject()
|
||||
log.debug(u'video')
|
||||
self.webLoaded = True
|
||||
self.setGeometry(self.screen[u'size'])
|
||||
|
@ -277,15 +277,16 @@ class SlideController(QtGui.QWidget):
|
||||
self.slideLayout.setSpacing(0)
|
||||
self.slideLayout.setMargin(0)
|
||||
self.slideLayout.setObjectName(u'SlideLayout')
|
||||
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)
|
||||
if not self.isLive:
|
||||
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.video.setGeometry(QtCore.QRect(0, 0, 300, 225))
|
||||
self.slideLayout.insertWidget(0, self.video)
|
||||
self.slideLayout.insertWidget(0, self.video)
|
||||
# Actual preview screen
|
||||
self.slidePreview = QtGui.QLabel(self)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
|
||||
|
@ -99,6 +99,7 @@ class VersionThread(QtCore.QThread):
|
||||
local_version.get(u'revision') and \
|
||||
remote_version[u'revision'] > local_version[u'revision']:
|
||||
Receiver.send_message(u'openlp_version_check', u'%s' % version)
|
||||
Receiver.send_message(u'openlp_phonon_creation')
|
||||
|
||||
|
||||
class AppLocation(object):
|
||||
|
@ -850,4 +850,4 @@ class BibleMediaItem(MediaManagerItem):
|
||||
self.settings.layout_style)
|
||||
QtCore.QSettings().setValue(
|
||||
self.settingsSection + u'/verse layout style',
|
||||
QtCore.QVariant(self.settings.layout_style))
|
||||
QtCore.QVariant(self.settings.layout_style))
|
||||
|
@ -50,10 +50,13 @@ class MediaMediaItem(MediaManagerItem):
|
||||
u':/media/media_video.png').toImage()
|
||||
MediaManagerItem.__init__(self, parent, self, icon)
|
||||
self.singleServiceItem = False
|
||||
self.mediaObject = Phonon.MediaObject(self)
|
||||
self.mediaObject = None
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'video_background_replaced'),
|
||||
self.videobackgroundReplaced)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'openlp_phonon_creation'),
|
||||
self.createPhonon)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.onNewPrompt = translate('MediaPlugin.MediaItem', 'Select Media')
|
||||
@ -209,4 +212,9 @@ class MediaMediaItem(MediaManagerItem):
|
||||
img = QtGui.QPixmap(u':/media/media_video.png').toImage()
|
||||
item_name.setIcon(build_icon(img))
|
||||
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
|
||||
self.listView.addItem(item_name)
|
||||
self.listView.addItem(item_name)
|
||||
|
||||
def createPhonon(self):
|
||||
if not self.mediaObject:
|
||||
self.mediaObject = Phonon.MediaObject(self)
|
||||
|
||||
|
@ -576,11 +576,13 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
if verse_index is not None:
|
||||
order.append(VerseType.Tags[verse_index] + u'1')
|
||||
else:
|
||||
order.append(u'') # it matches no verses anyway
|
||||
# it matches no verses anyway
|
||||
order.append(u'')
|
||||
else:
|
||||
verse_index = VerseType.from_translated_tag(item[0])
|
||||
if verse_index is None:
|
||||
order.append(u'') # same as above
|
||||
# it matches no verses anyway
|
||||
order.append(u'')
|
||||
else:
|
||||
verse_tag = VerseType.Tags[verse_index]
|
||||
verse_num = item[1:].lower()
|
||||
@ -779,4 +781,4 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
self.song.verse_order)
|
||||
except:
|
||||
log.exception(u'Problem processing song Lyrics \n%s',
|
||||
sxml.dump_xml())
|
||||
sxml.dump_xml())
|
||||
|
@ -257,7 +257,7 @@ def clean_song(manager, song):
|
||||
``song``
|
||||
The song object.
|
||||
"""
|
||||
song.title = song.title.strip() if song.title else u''
|
||||
song.title = song.title.rstrip() if song.title else u''
|
||||
if song.alternate_title is None:
|
||||
song.alternate_title = u''
|
||||
song.alternate_title = song.alternate_title.strip()
|
||||
@ -293,7 +293,10 @@ def clean_song(manager, song):
|
||||
song.lyrics = unicode(sxml.extract_xml(), u'utf-8')
|
||||
# Rebuild the verse order, to convert translated verse tags, which might
|
||||
# have been added prior to 1.9.5.
|
||||
order = song.verse_order.strip().split()
|
||||
if song.verse_order:
|
||||
order = song.verse_order.strip().split()
|
||||
else:
|
||||
order = []
|
||||
new_order = []
|
||||
for verse_def in order:
|
||||
verse_type = VerseType.Tags[VerseType.from_loose_input(verse_def[0])]
|
||||
|
@ -473,4 +473,4 @@ class SongMediaItem(MediaManagerItem):
|
||||
Locale aware collation of song titles
|
||||
"""
|
||||
return locale.strcoll(unicode(song_1.title.lower()),
|
||||
unicode(song_2.title.lower()))
|
||||
unicode(song_2.title.lower()))
|
||||
|
@ -134,14 +134,26 @@ class SongXML(object):
|
||||
[{'lang': 'en', 'type': 'c', 'label': '1'}, u"English chorus"]]
|
||||
"""
|
||||
self.song_xml = None
|
||||
if xml[:5] == u'<?xml':
|
||||
verse_list = []
|
||||
if not xml.startswith(u'<?xml') and not xml.startswith(u'<song'):
|
||||
# This is an old style song, without XML. Let's handle it correctly
|
||||
# by iterating through the verses, and then recreating the internal
|
||||
# xml object as well.
|
||||
self.song_xml = objectify.fromstring(u'<song version="1.0" />')
|
||||
self.lyrics = etree.SubElement(self.song_xml, u'lyrics')
|
||||
verses = xml.split(u'\n\n')
|
||||
for count, verse in enumerate(verses):
|
||||
verse_list.append([{u'type': u'v', u'label': unicode(count)},
|
||||
unicode(verse)])
|
||||
self.add_verse_to_lyrics(u'v', unicode(count), verse)
|
||||
return verse_list
|
||||
elif xml.startswith(u'<?xml'):
|
||||
xml = xml[38:]
|
||||
try:
|
||||
self.song_xml = objectify.fromstring(xml)
|
||||
except etree.XMLSyntaxError:
|
||||
log.exception(u'Invalid xml %s', xml)
|
||||
xml_iter = self.song_xml.getiterator()
|
||||
verse_list = []
|
||||
for element in xml_iter:
|
||||
if element.tag == u'verse':
|
||||
if element.text is None:
|
||||
|
Loading…
Reference in New Issue
Block a user