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 import SplashScreen, ScreenList
from openlp.core.utils import AppLocation, LanguageManager, VersionThread, \
get_application_version
get_application_version, DelayStartThread
log = logging.getLogger()
@ -130,6 +130,7 @@ class OpenLP(QtGui.QApplication):
u'general/update check', QtCore.QVariant(True)).toBool()
if update_check:
VersionThread(self.mainWindow).start()
DelayStartThread(self.mainWindow).start()
return self.exec_()
def isAlreadyRunning(self):
@ -250,4 +251,4 @@ if __name__ == u'__main__':
"""
Instantiate and run the application.
"""
main()
main()

View File

@ -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]

View File

@ -70,6 +70,8 @@ class MainDisplay(DisplayWidget):
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 +80,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 +107,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 +170,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 +361,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'])

View File

@ -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,

View File

@ -101,6 +101,20 @@ class VersionThread(QtCore.QThread):
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):
"""
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()
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):
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.
"""
log.debug(u'Load Presentation OpenOffice')
#print "s.dsk1 ", self.desktop
if os.name == u'nt':
desktop = self.controller.get_com_desktop()
if desktop is None:
@ -234,7 +233,10 @@ class ImpressDocument(PresentationDocument):
return False
self.desktop = desktop
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)
try:
self.document = desktop.loadComponentFromURL(url, u'_blank',
@ -242,6 +244,12 @@ class ImpressDocument(PresentationDocument):
except:
log.exception(u'Failed to load presentation %s' % url)
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.Display = \
self.controller.plugin.renderer.screens.current_display + 1
@ -387,14 +395,14 @@ class ImpressDocument(PresentationDocument):
log.debug(u'start presentation OpenOffice')
if self.control is None or not self.control.isRunning():
self.presentation.start()
# start() returns before the getCurrentComponent is ready.
# Try for 5 seconds
self.control = self.presentation.getController()
# start() returns before the Component is ready.
# Try for 15 seconds
i = 1
while self.desktop.getCurrentComponent() is None and i < 50:
while not self.control and i < 150:
time.sleep(0.1)
i = i + 1
self.control = \
self.desktop.getCurrentComponent().Presentation.getController()
self.control = self.presentation.getController()
else:
self.control.activate()
self.goto_slide(1)
@ -463,4 +471,4 @@ class ImpressDocument(PresentationDocument):
shape = page.getByIndex(idx)
if shape.supportsService("com.sun.star.drawing.Text"):
text += shape.getString() + '\n'
return text
return text

View File

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

View File

@ -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()))