This commit is contained in:
Andreas Preikschat 2011-05-01 07:56:39 +02:00
commit 03f10e72f2
10 changed files with 98 additions and 68 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

View File

@ -46,7 +46,7 @@ from openlp.core.ui.firsttimeform import FirstTimeForm
from openlp.core.ui.exceptionform import ExceptionForm from openlp.core.ui.exceptionform import ExceptionForm
from openlp.core.ui import SplashScreen, ScreenList from openlp.core.ui import SplashScreen, ScreenList
from openlp.core.utils import AppLocation, LanguageManager, VersionThread, \ from openlp.core.utils import AppLocation, LanguageManager, VersionThread, \
get_application_version get_application_version, DelayStartThread
log = logging.getLogger() log = logging.getLogger()
@ -130,6 +130,7 @@ class OpenLP(QtGui.QApplication):
u'general/update check', QtCore.QVariant(True)).toBool() u'general/update check', QtCore.QVariant(True)).toBool()
if update_check: if update_check:
VersionThread(self.mainWindow).start() VersionThread(self.mainWindow).start()
DelayStartThread(self.mainWindow).start()
return self.exec_() return self.exec_()
def isAlreadyRunning(self): def isAlreadyRunning(self):

View File

@ -222,13 +222,13 @@ class Renderer(object):
# Songs and Custom # Songs and Custom
if item.is_capable(ItemCapabilities.AllowsVirtualSplit): if item.is_capable(ItemCapabilities.AllowsVirtualSplit):
# Do not forget the line breaks ! # Do not forget the line breaks !
slides = text.split(u'\n[---]\n') slides = text.split(u'[---]')
pages = [] pages = []
for slide in slides: for slide in slides:
lines = self._lines(slide) lines = slide.strip(u'\n').split(u'\n')
new_pages = self._paginate_slide(lines, line_break, new_pages = self._paginate_slide(lines, line_break,
self.force_page) self.force_page)
pages.extend([page for page in new_pages]) pages.extend(new_pages)
# Bibles # Bibles
elif item.is_capable(ItemCapabilities.AllowsWordSplit): elif item.is_capable(ItemCapabilities.AllowsWordSplit):
pages = self._paginate_slide_words(text, line_break) pages = self._paginate_slide_words(text, line_break)
@ -341,12 +341,14 @@ class Renderer(object):
if force_page and line_count > 0: if force_page and line_count > 0:
Receiver.send_message(u'theme_line_count', line_count) Receiver.send_message(u'theme_line_count', line_count)
line_count = -1 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) formatted.append(html_text)
html_text = u'' html_text = u''
styled_text = styled_line styled_text = styled_line
html_text += line + line_end 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) formatted.append(html_text)
log.debug(u'_paginate_slide - End') log.debug(u'_paginate_slide - End')
return formatted return formatted
@ -371,7 +373,7 @@ class Renderer(object):
formatted = [] formatted = []
previous_html = u'' previous_html = u''
previous_raw = u'' previous_raw = u''
lines = self._lines(text) lines = text.split(u'\n')
for line in lines: for line in lines:
styled_line = expand_tags(line) styled_line = expand_tags(line)
html = self.page_shell + previous_html + styled_line + HTML_END html = self.page_shell + previous_html + styled_line + HTML_END
@ -385,7 +387,8 @@ class Renderer(object):
self.web.setHtml(html) self.web.setHtml(html)
if self.web_frame.contentsSize().height() <= \ if self.web_frame.contentsSize().height() <= \
self.page_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) formatted.append(previous_raw)
previous_html = u'' previous_html = u''
previous_raw = u'' previous_raw = u''
@ -408,7 +411,8 @@ class Renderer(object):
# Text too long so go to next page # Text too long so go to next page
if self.web_frame.contentsSize().height() > \ if self.web_frame.contentsSize().height() > \
self.page_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) formatted.append(previous_raw)
previous_html = u'' previous_html = u''
previous_raw = u'' previous_raw = u''
@ -419,36 +423,20 @@ class Renderer(object):
else: else:
previous_html += styled_line + line_end previous_html += styled_line + line_end
previous_raw += 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) formatted.append(previous_raw)
log.debug(u'_paginate_slide_words - End') log.debug(u'_paginate_slide_words - End')
return formatted 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): def _words_split(self, line):
""" """
Split the slide up by word so can wrap better Split the slide up by word so can wrap better
""" """
# this parse we are to be wordy # this parse we are to be wordy
line = line.replace(u'\n', u' ') line = line.replace(u'\n', u' ')
verses_text = line.split(u' ') words = line.split(u' ')
text = [] return [word + u' ' for word in words]
for verse in verses_text:
lines = verse.split(u' ')
text.extend([line + u' ' for line in lines])
return text
def _lines_split(self, text): def _lines_split(self, text):
""" """
@ -457,9 +445,4 @@ class Renderer(object):
# this parse we do not want to use this so remove it # this parse we do not want to use this so remove it
text = text.replace(u'\n[---]', u'') text = text.replace(u'\n[---]', u'')
lines = text.split(u'\n') lines = text.split(u'\n')
real_lines = [] return [line.replace(u'[---]', u'') for line in 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

View File

@ -70,6 +70,8 @@ class MainDisplay(DisplayWidget):
self.videoHide = False self.videoHide = False
self.override = {} self.override = {}
self.retranslateUi() self.retranslateUi()
self.mediaObject = None
self.firstTime = True
self.setStyleSheet(u'border: 0px; margin: 0px; padding: 0px;') self.setStyleSheet(u'border: 0px; margin: 0px; padding: 0px;')
self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool | self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool |
QtCore.Qt.WindowStaysOnTopHint) QtCore.Qt.WindowStaysOnTopHint)
@ -78,6 +80,9 @@ class MainDisplay(DisplayWidget):
QtCore.SIGNAL(u'maindisplay_hide'), self.hideDisplay) QtCore.SIGNAL(u'maindisplay_hide'), self.hideDisplay)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'maindisplay_show'), self.showDisplay) QtCore.SIGNAL(u'maindisplay_show'), self.showDisplay)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'openlp_phonon_creation'),
self.createMediaObject)
def retranslateUi(self): def retranslateUi(self):
""" """
@ -102,19 +107,9 @@ class MainDisplay(DisplayWidget):
self.videoWidget.setGeometry(QtCore.QRect(0, 0, self.videoWidget.setGeometry(QtCore.QRect(0, 0,
self.screen[u'size'].width(), self.screen[u'size'].height())) self.screen[u'size'].width(), self.screen[u'size'].height()))
log.debug(u'Setup Phonon for monitor %s' % self.screens.monitor_number) log.debug(u'Setup Phonon for monitor %s' % self.screens.monitor_number)
self.mediaObject = Phonon.MediaObject(self) if self.isLive:
self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self.mediaObject) if not self.firstTime:
Phonon.createPath(self.mediaObject, self.videoWidget) self.createMediaObject()
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'Setup webView for monitor %s' % self.screens.monitor_number) log.debug(u'Setup webView for monitor %s' % self.screens.monitor_number)
self.webView = QtWebKit.QWebView(self) self.webView = QtWebKit.QWebView(self)
self.webView.setGeometry(0, 0, self.webView.setGeometry(0, 0,
@ -175,6 +170,24 @@ class MainDisplay(DisplayWidget):
log.debug( log.debug(
u'Finished setup for monitor %s' % self.screens.monitor_number) 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): def text(self, slide):
""" """
Add the slide text from slideController Add the slide text from slideController
@ -348,6 +361,8 @@ class MainDisplay(DisplayWidget):
""" """
Loads and starts a video to run with the option of sound Loads and starts a video to run with the option of sound
""" """
if not self.mediaObject:
self.createMediaObject()
log.debug(u'video') log.debug(u'video')
self.webLoaded = True self.webLoaded = True
self.setGeometry(self.screen[u'size']) self.setGeometry(self.screen[u'size'])

View File

@ -277,15 +277,16 @@ class SlideController(QtGui.QWidget):
self.slideLayout.setSpacing(0) self.slideLayout.setSpacing(0)
self.slideLayout.setMargin(0) self.slideLayout.setMargin(0)
self.slideLayout.setObjectName(u'SlideLayout') 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: 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.video.setGeometry(QtCore.QRect(0, 0, 300, 225))
self.slideLayout.insertWidget(0, self.video) self.slideLayout.insertWidget(0, self.video)
# Actual preview screen # Actual preview screen
self.slidePreview = QtGui.QLabel(self) self.slidePreview = QtGui.QLabel(self)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,

View File

@ -101,6 +101,20 @@ class VersionThread(QtCore.QThread):
Receiver.send_message(u'openlp_version_check', u'%s' % version) Receiver.send_message(u'openlp_version_check', u'%s' % version)
class DelayStartThread(QtCore.QThread):
"""
A special Qt thread class to build things after OpenLP has started
"""
def __init__(self, parent):
QtCore.QThread.__init__(self, parent)
def run(self):
"""
Run the thread.
"""
Receiver.send_message(u'openlp_phonon_creation')
class AppLocation(object): class AppLocation(object):
""" """
The :class:`AppLocation` class is a static class which retrieves a The :class:`AppLocation` class is a static class which retrieves a

View File

@ -50,10 +50,13 @@ class MediaMediaItem(MediaManagerItem):
u':/media/media_video.png').toImage() u':/media/media_video.png').toImage()
MediaManagerItem.__init__(self, parent, self, icon) MediaManagerItem.__init__(self, parent, self, icon)
self.singleServiceItem = False self.singleServiceItem = False
self.mediaObject = Phonon.MediaObject(self) self.mediaObject = None
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'video_background_replaced'), QtCore.SIGNAL(u'video_background_replaced'),
self.videobackgroundReplaced) self.videobackgroundReplaced)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'openlp_phonon_creation'),
self.createPhonon)
def retranslateUi(self): def retranslateUi(self):
self.onNewPrompt = translate('MediaPlugin.MediaItem', 'Select Media') self.onNewPrompt = translate('MediaPlugin.MediaItem', 'Select Media')
@ -210,3 +213,8 @@ class MediaMediaItem(MediaManagerItem):
item_name.setIcon(build_icon(img)) item_name.setIcon(build_icon(img))
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file)) item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
self.listView.addItem(item_name) self.listView.addItem(item_name)
def createPhonon(self):
log.debug(u'CreatePhonon')
if not self.mediaObject:
self.mediaObject = Phonon.MediaObject(self)

View File

@ -219,7 +219,6 @@ class ImpressDocument(PresentationDocument):
The file name of the presentatios to the run. The file name of the presentatios to the run.
""" """
log.debug(u'Load Presentation OpenOffice') log.debug(u'Load Presentation OpenOffice')
#print "s.dsk1 ", self.desktop
if os.name == u'nt': if os.name == u'nt':
desktop = self.controller.get_com_desktop() desktop = self.controller.get_com_desktop()
if desktop is None: if desktop is None:
@ -234,7 +233,10 @@ class ImpressDocument(PresentationDocument):
return False return False
self.desktop = desktop self.desktop = desktop
properties = [] properties = []
properties.append(self.create_property(u'Minimized', True)) if os.name != u'nt':
# Recent versions of Impress on Windows won't start the presentation
# if it starts as minimized. It seems OK on Linux though.
properties.append(self.create_property(u'Minimized', True))
properties = tuple(properties) properties = tuple(properties)
try: try:
self.document = desktop.loadComponentFromURL(url, u'_blank', self.document = desktop.loadComponentFromURL(url, u'_blank',
@ -242,6 +244,12 @@ class ImpressDocument(PresentationDocument):
except: except:
log.exception(u'Failed to load presentation %s' % url) log.exception(u'Failed to load presentation %s' % url)
return False return False
if os.name == u'nt':
# As we can't start minimized the Impress window gets in the way.
# Either window.setPosSize(0, 0, 200, 400, 12) or .setVisible(False)
window = self.document.getCurrentController().getFrame() \
.getContainerWindow()
window.setVisible(False)
self.presentation = self.document.getPresentation() self.presentation = self.document.getPresentation()
self.presentation.Display = \ self.presentation.Display = \
self.controller.plugin.renderer.screens.current_display + 1 self.controller.plugin.renderer.screens.current_display + 1
@ -387,14 +395,14 @@ class ImpressDocument(PresentationDocument):
log.debug(u'start presentation OpenOffice') log.debug(u'start presentation OpenOffice')
if self.control is None or not self.control.isRunning(): if self.control is None or not self.control.isRunning():
self.presentation.start() self.presentation.start()
# start() returns before the getCurrentComponent is ready. self.control = self.presentation.getController()
# Try for 5 seconds # start() returns before the Component is ready.
# Try for 15 seconds
i = 1 i = 1
while self.desktop.getCurrentComponent() is None and i < 50: while not self.control and i < 150:
time.sleep(0.1) time.sleep(0.1)
i = i + 1 i = i + 1
self.control = \ self.control = self.presentation.getController()
self.desktop.getCurrentComponent().Presentation.getController()
else: else:
self.control.activate() self.control.activate()
self.goto_slide(1) self.goto_slide(1)

View File

@ -293,7 +293,7 @@ class PresentationMediaItem(MediaManagerItem):
"supports" the extension. If none found, then look for a controller "supports" the extension. If none found, then look for a controller
which "also supports" it instead. which "also supports" it instead.
""" """
filetype = filename.split(u'.')[1] filetype = os.path.splitext(filename)[1][1:]
if not filetype: if not filetype:
return None return None
for controller in self.controllers: for controller in self.controllers: