forked from openlp/openlp
Add version number to splash screem
Add ability to preview to preview controller Add render manager to control rendering Fix bugs in renderer Add inital rendering to custom and bible plugins
This commit is contained in:
parent
aeb79120f4
commit
2457da9d88
@ -46,7 +46,7 @@ class OpenLP(QtGui.QApplication):
|
||||
|
||||
self.setApplicationName(u'openlp.org')
|
||||
self.setApplicationVersion(u'1.9.0')
|
||||
self.splash = SplashScreen()
|
||||
self.splash = SplashScreen(self.applicationVersion())
|
||||
self.splash.show()
|
||||
# make sure Qt really display the splash screen
|
||||
self.processEvents()
|
||||
|
@ -92,6 +92,7 @@ class Plugin(object):
|
||||
self.live_controller=plugin_helpers[u'live']
|
||||
self.theme_manager=plugin_helpers[u'theme']
|
||||
self.event_manager=plugin_helpers[u'event']
|
||||
self.render_manager=plugin_helpers[u'render']
|
||||
|
||||
def check_pre_conditions(self):
|
||||
"""
|
||||
|
@ -97,19 +97,18 @@ class Renderer:
|
||||
if self._bg_image_filename is not None:
|
||||
self.scale_bg_image()
|
||||
|
||||
def set_words_openlp(self, words):
|
||||
# log.debug(u" "set words openlp", words
|
||||
def format_slide(self, words, footer):
|
||||
log.debug(u'format_slide %s', words)
|
||||
verses=[]
|
||||
words=words.replace(u'\r\n', u'\n')
|
||||
verses_text=words.split(u'\n\n')
|
||||
verses_text = words.split(u'\n')
|
||||
for v in verses_text:
|
||||
lines=v.split(u'\n')
|
||||
verses.append(self.split_set_of_lines(lines)[0])
|
||||
verses.append(self.split_set_of_lines(lines, footer)[0])
|
||||
self.words = verses
|
||||
verses_text=[]
|
||||
for v in verses:
|
||||
verses_text.append(u'\n'.join(v).lstrip()) # remove first \n
|
||||
|
||||
return verses_text
|
||||
|
||||
def render_screen(self, screennum):
|
||||
@ -172,22 +171,22 @@ class Renderer:
|
||||
p.end()
|
||||
log.debug(u'render background done')
|
||||
|
||||
def split_set_of_lines(self, lines):
|
||||
def split_set_of_lines(self, lines, footer):
|
||||
|
||||
"""Given a list of lines, decide how to split them best if they don't all fit on the screen
|
||||
- this is done by splitting at 1/2, 1/3 or 1/4 of the set
|
||||
If it doesn't fit, even at this size, just split at each opportunity
|
||||
|
||||
We'll do this by getting the bounding box of each line, and then summing them appropriately
|
||||
We'll do this by getting the bounding box of each lline, and then summing them appropriately
|
||||
|
||||
Returns a list of [lists of lines], one set for each screenful
|
||||
"""
|
||||
# log.debug(u" "Split set of lines"
|
||||
log.debug(u'Split set of lines')
|
||||
# Probably ought to save the rendering results to a pseudoDC for redrawing efficiency. But let's not optimse prematurely!
|
||||
|
||||
bboxes = []
|
||||
for line in lines:
|
||||
bboxes.append(self._render_single_line(line))
|
||||
bboxes.append(self._render_single_line(line, footer))
|
||||
numlines=len(lines)
|
||||
bottom=self._rect.bottom()
|
||||
for ratio in (numlines, numlines/2, numlines/3, numlines/4):
|
||||
@ -281,8 +280,8 @@ class Renderer:
|
||||
brx=x
|
||||
bry=y
|
||||
for line in lines:
|
||||
if (line == ''):
|
||||
continue
|
||||
#if (line == ''):
|
||||
# continue
|
||||
# render after current bottom, but at original left edge
|
||||
# keep track of right edge to see which is biggest
|
||||
(thisx, bry) = self._render_single_line(line, footer, (x,bry))
|
||||
@ -309,7 +308,7 @@ class Renderer:
|
||||
|
||||
Returns the bottom-right corner (of what was rendered) as a tuple(x, y).
|
||||
"""
|
||||
#log.debug(u'Render single line %s @ %s '%( line, tlcorner))
|
||||
log.debug(u'Render single line %s @ %s '%( line, tlcorner))
|
||||
x, y=tlcorner
|
||||
# We draw the text to see how big it is and then iterate to make it fit
|
||||
# when we line wrap we do in in the "lyrics" style, so the second line is
|
||||
|
@ -33,33 +33,42 @@ class RenderManager:
|
||||
log=logging.getLogger(u'RenderManager')
|
||||
log.info(u'RenderManager Loaded')
|
||||
|
||||
def __init__(self, screen_list):
|
||||
def __init__(self, theme_manager, screen_list):
|
||||
log.debug(u'Initilisation started')
|
||||
self.screen_list = screen_list
|
||||
self.theme_manager = theme_manager
|
||||
self.displays = len(screen_list)
|
||||
self.current_display = 1
|
||||
self.renderer = Renderer()
|
||||
self.renderer = Renderer(None)
|
||||
self.calculate_default(self.screen_list[self.current_display-1][1])
|
||||
self.frame = None
|
||||
|
||||
def set_default_theme(self, theme):
|
||||
log.debug("default theme set to %s", theme)
|
||||
self.default_theme = self.theme_manager.getThemeData(theme)
|
||||
self.renderer.set_theme(self.default_theme)
|
||||
|
||||
self.renderer.set_text_rectangle(QtCore.QRect(10,0, self.width-1, self.height-1),
|
||||
QtCore.QRect(10,self.footer_start, self.width-1, self.height-self.footer_start))
|
||||
|
||||
|
||||
def set_theme(self, theme):
|
||||
log.debug("theme set to %s", theme)
|
||||
self.theme = theme
|
||||
if theme.font_main_override == False:
|
||||
pass
|
||||
if theme.font_footer_override == False:
|
||||
pass
|
||||
|
||||
|
||||
def generate_preview(self):
|
||||
self.calculate_default(QtCore.QSize(800,600))
|
||||
|
||||
frame = QtGui.QPixmap(self.width, self.height)
|
||||
renderer=Renderer(None)
|
||||
renderer.set_paint_dest(frame)
|
||||
|
||||
renderer.set_theme(self.theme)
|
||||
renderer.set_text_rectangle(QtCore.QRect(10,0, self.width-1, self.height-1),
|
||||
self.renderer.set_text_rectangle(QtCore.QRect(10,0, self.width-1, self.height-1),
|
||||
QtCore.QRect(10,self.footer_start, self.width-1, self.height-self.footer_start))
|
||||
|
||||
frame = QtGui.QPixmap(self.width, self.height)
|
||||
self.renderer.set_paint_dest(frame)
|
||||
|
||||
lines=[]
|
||||
lines.append(u'Amazing Grace!')
|
||||
lines.append(u'How sweet the sound')
|
||||
@ -69,13 +78,34 @@ class RenderManager:
|
||||
lines1=[]
|
||||
lines1.append(u'Amazing Grace (John Newton)' )
|
||||
lines1.append(u'CCLI xxx (c)Openlp.org')
|
||||
answer=renderer.render_lines(lines, lines1)
|
||||
answer=self.renderer.render_lines(lines, lines1)
|
||||
return frame
|
||||
|
||||
def generate_bible(self):
|
||||
pass
|
||||
def format_slide(self, words, footer):
|
||||
self.calculate_default(QtCore.QSize(800,600))
|
||||
|
||||
self.renderer.set_text_rectangle(QtCore.QRect(10,0, self.width-1, self.height-1),
|
||||
QtCore.QRect(10,self.footer_start, self.width-1, self.height-self.footer_start))
|
||||
|
||||
return self.renderer.format_slide(words, footer)
|
||||
|
||||
def generate_slide(self,main_text, footer_text, preview=True):
|
||||
if preview == True:
|
||||
self.calculate_default(QtCore.QSize(800,600))
|
||||
|
||||
self.renderer.set_text_rectangle(QtCore.QRect(10,0, self.width-1, self.height-1),
|
||||
QtCore.QRect(10,self.footer_start, self.width-1, self.height-self.footer_start))
|
||||
|
||||
#frame = QtGui.QPixmap(self.width, self.height)
|
||||
#self.renderer.set_paint_dest(frame)
|
||||
print main_text
|
||||
answer=self.renderer.render_lines(main_text, footer_text)
|
||||
return self.frame
|
||||
|
||||
def calculate_default(self, screen):
|
||||
self.width = screen.width()
|
||||
self.height = screen.height()
|
||||
self.footer_start = int(self.height*0.95) # 95% is start of footer
|
||||
#update the rederer frame
|
||||
self.frame = QtGui.QPixmap(self.width, self.height)
|
||||
self.renderer.set_paint_dest(self.frame)
|
||||
|
@ -44,7 +44,6 @@ class MainWindow(object):
|
||||
self.alert_form = AlertForm()
|
||||
self.about_form = AboutForm()
|
||||
self.settings_form = SettingsForm(self.screen_list)
|
||||
self.RenderManager = RenderManager(self.screen_list)
|
||||
|
||||
pluginpath = os.path.split(os.path.abspath(__file__))[0]
|
||||
pluginpath = os.path.abspath(os.path.join(pluginpath, '..', '..','plugins'))
|
||||
@ -53,6 +52,11 @@ class MainWindow(object):
|
||||
|
||||
self.setupUi()
|
||||
|
||||
#warning cyclic dependency
|
||||
#RenderManager needs to call ThemeManager and
|
||||
#ThemeManager needs to call RenderManager
|
||||
self.RenderManager = RenderManager(self.ThemeManagerContents, self.screen_list)
|
||||
|
||||
log.info(u'Load Plugins')
|
||||
self.plugin_helpers[u'preview'] = self.PreviewController
|
||||
self.plugin_helpers[u'live'] = self.LiveController
|
||||
@ -87,6 +91,7 @@ class MainWindow(object):
|
||||
log.info(u'Load Themes')
|
||||
self.ThemeManagerContents.setEventManager(self.EventManager)
|
||||
self.ThemeManagerContents.setRenderManager(self.RenderManager)
|
||||
self.ServiceManagerContents.setRenderManager(self.RenderManager)
|
||||
self.ThemeManagerContents.setServiceManager(self.ServiceManagerContents)
|
||||
self.ThemeManagerContents.loadThemes()
|
||||
|
||||
|
@ -29,6 +29,7 @@ from PyQt4.QtGui import *
|
||||
# from openlp.core.ui import AboutForm, AlertForm, SettingsForm, SlideController
|
||||
from openlp.core.lib import OpenLPToolbar
|
||||
from openlp.core.lib import ServiceItem
|
||||
from openlp.core.lib import RenderManager
|
||||
|
||||
# from openlp.core import PluginManager
|
||||
import logging
|
||||
@ -138,6 +139,14 @@ class ServiceManager(QWidget):
|
||||
self.service_data=ServiceData()
|
||||
self.TreeView.setModel(self.service_data)
|
||||
self.Layout.addWidget(self.TreeView)
|
||||
QtCore.QObject.connect(self.ThemeComboBox,
|
||||
QtCore.SIGNAL("activated(int)"), self.onThemeComboBoxSelected)
|
||||
|
||||
def setRenderManager(self, renderManager):
|
||||
self.renderManager = renderManager
|
||||
|
||||
def onThemeComboBoxSelected(self, currentIndex):
|
||||
self.renderManager.set_default_theme(self.ThemeComboBox.currentText())
|
||||
|
||||
def addServiceItem(self, item):
|
||||
"""Adds service item"""
|
||||
@ -191,3 +200,5 @@ class ServiceManager(QWidget):
|
||||
self.ThemeComboBox.clear()
|
||||
for theme in theme_list:
|
||||
self.ThemeComboBox.addItem(theme)
|
||||
self.renderManager.set_default_theme(self.ThemeComboBox.currentText())
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
"""
|
||||
OpenLP - Open Source Lyrics Projection
|
||||
Copyright (c) 2008 Raoul Snyman
|
||||
Portions copyright (c) 2008 Martin Thompson, Tim Bentley,
|
||||
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley,
|
||||
|
||||
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
|
||||
@ -41,6 +41,23 @@ class SlideController(QtGui.QWidget):
|
||||
self.Controller.setGeometry(QtCore.QRect(0, 0, 828, 536))
|
||||
self.Controller.setWidget(self.ControllerContents)
|
||||
|
||||
self.Screen = QtGui.QGraphicsView(self.Splitter)
|
||||
self.Screen.setMaximumSize(QtCore.QSize(16777215, 250))
|
||||
#self.Screen = QtGui.QGraphicsView(self.Splitter)
|
||||
#self.Screen.setMaximumSize(QtCore.QSize(16777215, 250))
|
||||
|
||||
|
||||
self.ThemePreview = QtGui.QLabel(self.Splitter)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.ThemePreview.sizePolicy().hasHeightForWidth())
|
||||
self.ThemePreview.setSizePolicy(sizePolicy)
|
||||
self.ThemePreview.setMinimumSize(QtCore.QSize(250, 190))
|
||||
self.ThemePreview.setFrameShape(QtGui.QFrame.WinPanel)
|
||||
self.ThemePreview.setFrameShadow(QtGui.QFrame.Sunken)
|
||||
self.ThemePreview.setLineWidth(1)
|
||||
self.ThemePreview.setScaledContents(True)
|
||||
self.ThemePreview.setObjectName("ThemePreview")
|
||||
|
||||
|
||||
def previewFrame(self, frame):
|
||||
self.ThemePreview.setPixmap(frame)
|
||||
|
@ -20,12 +20,15 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.resources import *
|
||||
#from openlp.core.resources import *
|
||||
from openlp.core import translate
|
||||
|
||||
class SplashScreen(object):
|
||||
def __init__(self):
|
||||
def __init__(self, version):
|
||||
self.splash_screen = QtGui.QSplashScreen()
|
||||
self.setupUi()
|
||||
starting = translate('SplashScreen',u'Starting')
|
||||
self.message=starting+u'..... '+version
|
||||
|
||||
def setupUi(self):
|
||||
self.splash_screen.setObjectName("splash_screen")
|
||||
@ -60,7 +63,7 @@ class SplashScreen(object):
|
||||
|
||||
def show(self):
|
||||
self.splash_screen.show()
|
||||
self.splash_screen.showMessage(u'Starting...', QtCore.Qt.AlignLeft | QtCore.Qt.AlignBottom, QtCore.Qt.black)
|
||||
self.splash_screen.showMessage(self.message, QtCore.Qt.AlignLeft | QtCore.Qt.AlignBottom, QtCore.Qt.black)
|
||||
self.splash_screen.repaint()
|
||||
|
||||
def finish(self, widget):
|
||||
|
@ -33,6 +33,7 @@ from PyQt4.QtGui import *
|
||||
from openlp.core.ui import AmendThemeForm
|
||||
from openlp.core.ui import ServiceManager
|
||||
from openlp.core import translate
|
||||
from openlp.core import fileToXML
|
||||
from openlp.core.theme import Theme
|
||||
from openlp.core.lib import Event
|
||||
from openlp.core.lib import EventType
|
||||
@ -248,6 +249,13 @@ class ThemeManager(QWidget):
|
||||
def getThemes(self):
|
||||
return self.Theme_data.getList()
|
||||
|
||||
def getThemeData(self, themename):
|
||||
xml_file = os.path.join(self.path, str(themename), str(themename)+u'.xml')
|
||||
xml = fileToXML(xml_file)
|
||||
theme = ThemeXML()
|
||||
theme.parse(xml)
|
||||
return theme
|
||||
|
||||
def checkThemesExists(self, dir):
|
||||
log.debug(u'check themes')
|
||||
if os.path.exists(dir) == False:
|
||||
|
@ -183,6 +183,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||
self.BibleListView.setAlternatingRowColors(True)
|
||||
self.BibleListData = TextListData()
|
||||
self.BibleListView.setModel(self.BibleListData)
|
||||
self.BibleListView.setSelectionMode(2)
|
||||
|
||||
self.PageLayout.addWidget(self.BibleListView)
|
||||
|
||||
@ -328,6 +329,8 @@ class BibleMediaItem(MediaManagerItem):
|
||||
log.debug(u'Bible Preview Button pressed')
|
||||
items = self.BibleListView.selectedIndexes()
|
||||
old_chapter = ''
|
||||
main_lines=[]
|
||||
footer_lines = []
|
||||
for item in items:
|
||||
text = self.BibleListData.getValue(item)
|
||||
verse = text[:text.find("(")]
|
||||
@ -348,15 +351,18 @@ class BibleMediaItem(MediaManagerItem):
|
||||
else:
|
||||
loc = self.formatVerse(old_chapter, chapter, verse, u'', u'')
|
||||
old_chapter = chapter
|
||||
print book
|
||||
print loc
|
||||
print text
|
||||
main_lines.append(loc + u' '+text)
|
||||
if len(footer_lines) <= 1:
|
||||
footer_lines.append(book)
|
||||
|
||||
frame=self.parent.render_manager.generate_slide(main_lines, footer_lines)
|
||||
self.parent.preview_controller.previewFrame(frame)
|
||||
|
||||
def formatVerse(self, old_chapter, chapter, verse, opening, closing):
|
||||
loc = opening
|
||||
if old_chapter != chapter:
|
||||
loc += chapter + u':'
|
||||
elif not self.parent.bibles_tab.new_chapter_check:
|
||||
elif not self.parent.bibles_tab.show_new_chapters:
|
||||
loc += chapter + u':'
|
||||
loc += verse
|
||||
loc += closing
|
||||
|
@ -23,7 +23,7 @@ from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core import translate
|
||||
from openlp.core.lib import MediaManagerItem
|
||||
from openlp.core.resources import *
|
||||
from openlp.core.lib import SongXMLParser
|
||||
|
||||
from openlp.plugins.custom.lib import TextListData
|
||||
|
||||
@ -185,7 +185,25 @@ class CustomMediaItem(MediaManagerItem):
|
||||
self.CustomListData.deleteRow(index)
|
||||
|
||||
def onCustomPreviewClick(self):
|
||||
pass
|
||||
indexes = self.CustomListView.selectedIndexes()
|
||||
main_lines=[]
|
||||
footer_lines = []
|
||||
slide = None
|
||||
for index in indexes:
|
||||
id = self.CustomListData.getId(index)
|
||||
customSlide = self.parent.custommanager.get_custom(id)
|
||||
title = customSlide.title
|
||||
credit = customSlide.title
|
||||
|
||||
songXML=SongXMLParser(customSlide.text)
|
||||
verseList = songXML.get_verses()
|
||||
for verse in verseList:
|
||||
slide = self.parent.render_manager.format_slide(verse[1], False)
|
||||
|
||||
footer_lines.append(title + u' '+ credit)
|
||||
|
||||
frame=self.parent.render_manager.generate_slide(slide, footer_lines)
|
||||
self.parent.preview_controller.previewFrame(frame)
|
||||
|
||||
def onCustomLiveClick(self):
|
||||
pass
|
||||
|
@ -80,3 +80,7 @@ class FileListData(QAbstractListModel):
|
||||
def getFilename(self, index):
|
||||
row = index.row()
|
||||
return self.items[row][0]
|
||||
|
||||
def getValue(self, index):
|
||||
row = index.row()
|
||||
return self.items[row][0]
|
||||
|
@ -24,7 +24,6 @@ from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core import translate
|
||||
from openlp.core.lib import MediaManagerItem
|
||||
from openlp.core.resources import *
|
||||
|
||||
from openlp.plugins.videos.lib import VideoTab
|
||||
from openlp.plugins.videos.lib import FileListData
|
||||
@ -123,7 +122,11 @@ class VideoMediaItem(MediaManagerItem):
|
||||
self.parent.config.set_list(u'videos', self.VideoListData.getFileList())
|
||||
|
||||
def onVideoPreviewClick(self):
|
||||
pass
|
||||
log.debug(u'Video Preview Button pressed')
|
||||
items = self.VideoListView.selectedIndexes()
|
||||
for item in items:
|
||||
text = self.VideoListData.getValue(item)
|
||||
print text
|
||||
|
||||
def onVideoLiveClick(self):
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user