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:
Tim Bentley 2009-04-25 07:11:15 +01:00
parent aeb79120f4
commit 2457da9d88
13 changed files with 197 additions and 92 deletions

View File

@ -46,7 +46,7 @@ class OpenLP(QtGui.QApplication):
self.setApplicationName(u'openlp.org') self.setApplicationName(u'openlp.org')
self.setApplicationVersion(u'1.9.0') self.setApplicationVersion(u'1.9.0')
self.splash = SplashScreen() self.splash = SplashScreen(self.applicationVersion())
self.splash.show() self.splash.show()
# make sure Qt really display the splash screen # make sure Qt really display the splash screen
self.processEvents() self.processEvents()

View File

@ -91,8 +91,9 @@ class Plugin(object):
self.preview_controller=plugin_helpers[u'preview'] self.preview_controller=plugin_helpers[u'preview']
self.live_controller=plugin_helpers[u'live'] self.live_controller=plugin_helpers[u'live']
self.theme_manager=plugin_helpers[u'theme'] self.theme_manager=plugin_helpers[u'theme']
self.event_manager=plugin_helpers[u'event'] self.event_manager=plugin_helpers[u'event']
self.render_manager=plugin_helpers[u'render']
def check_pre_conditions(self): def check_pre_conditions(self):
""" """
Provides the Plugin with a handle to check if it can be loaded. Provides the Plugin with a handle to check if it can be loaded.
@ -118,7 +119,7 @@ class Plugin(object):
Create a menu item and add it to the "Export" menu. Create a menu item and add it to the "Export" menu.
""" """
pass pass
def get_settings_tab(self): def get_settings_tab(self):
""" """
Create a menu item and add it to the "Import" menu. Create a menu item and add it to the "Import" menu.

View File

@ -97,19 +97,18 @@ class Renderer:
if self._bg_image_filename is not None: if self._bg_image_filename is not None:
self.scale_bg_image() self.scale_bg_image()
def set_words_openlp(self, words): def format_slide(self, words, footer):
# log.debug(u" "set words openlp", words log.debug(u'format_slide %s', words)
verses=[] verses=[]
words=words.replace(u'\r\n', u'\n') 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: for v in verses_text:
lines=v.split(u'\n') 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 self.words = verses
verses_text=[] verses_text=[]
for v in verses: for v in verses:
verses_text.append(u'\n'.join(v).lstrip()) # remove first \n verses_text.append(u'\n'.join(v).lstrip()) # remove first \n
return verses_text return verses_text
def render_screen(self, screennum): def render_screen(self, screennum):
@ -172,22 +171,22 @@ class Renderer:
p.end() p.end()
log.debug(u'render background done') 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 """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 - 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 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 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! # Probably ought to save the rendering results to a pseudoDC for redrawing efficiency. But let's not optimse prematurely!
bboxes = [] bboxes = []
for line in lines: for line in lines:
bboxes.append(self._render_single_line(line)) bboxes.append(self._render_single_line(line, footer))
numlines=len(lines) numlines=len(lines)
bottom=self._rect.bottom() bottom=self._rect.bottom()
for ratio in (numlines, numlines/2, numlines/3, numlines/4): for ratio in (numlines, numlines/2, numlines/3, numlines/4):
@ -281,8 +280,8 @@ class Renderer:
brx=x brx=x
bry=y bry=y
for line in lines: for line in lines:
if (line == ''): #if (line == ''):
continue # continue
# render after current bottom, but at original left edge # render after current bottom, but at original left edge
# keep track of right edge to see which is biggest # keep track of right edge to see which is biggest
(thisx, bry) = self._render_single_line(line, footer, (x,bry)) (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). 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 x, y=tlcorner
# We draw the text to see how big it is and then iterate to make it fit # 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 # when we line wrap we do in in the "lyrics" style, so the second line is

View File

@ -33,33 +33,42 @@ class RenderManager:
log=logging.getLogger(u'RenderManager') log=logging.getLogger(u'RenderManager')
log.info(u'RenderManager Loaded') log.info(u'RenderManager Loaded')
def __init__(self, screen_list): def __init__(self, theme_manager, screen_list):
log.debug(u'Initilisation started') log.debug(u'Initilisation started')
self.screen_list = screen_list self.screen_list = screen_list
self.theme_manager = theme_manager
self.displays = len(screen_list) self.displays = len(screen_list)
self.current_display = 1 self.current_display = 1
self.renderer = Renderer() self.renderer = Renderer(None)
self.calculate_default(self.screen_list[self.current_display-1][1]) 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): def set_theme(self, theme):
log.debug("theme set to %s", theme)
self.theme = theme self.theme = theme
if theme.font_main_override == False: if theme.font_main_override == False:
pass pass
if theme.font_footer_override == False: if theme.font_footer_override == False:
pass pass
def generate_preview(self): def generate_preview(self):
self.calculate_default(QtCore.QSize(800,600)) self.calculate_default(QtCore.QSize(800,600))
frame = QtGui.QPixmap(self.width, self.height) self.renderer.set_text_rectangle(QtCore.QRect(10,0, self.width-1, self.height-1),
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),
QtCore.QRect(10,self.footer_start, self.width-1, self.height-self.footer_start)) 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=[]
lines.append(u'Amazing Grace!') lines.append(u'Amazing Grace!')
lines.append(u'How sweet the sound') lines.append(u'How sweet the sound')
@ -69,13 +78,34 @@ class RenderManager:
lines1=[] lines1=[]
lines1.append(u'Amazing Grace (John Newton)' ) lines1.append(u'Amazing Grace (John Newton)' )
lines1.append(u'CCLI xxx (c)Openlp.org') lines1.append(u'CCLI xxx (c)Openlp.org')
answer=renderer.render_lines(lines, lines1) answer=self.renderer.render_lines(lines, lines1)
return frame return frame
def generate_bible(self): def format_slide(self, words, footer):
pass 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): def calculate_default(self, screen):
self.width = screen.width() self.width = screen.width()
self.height = screen.height() self.height = screen.height()
self.footer_start = int(self.height*0.95) # 95% is start of footer 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)

View File

@ -44,7 +44,6 @@ class MainWindow(object):
self.alert_form = AlertForm() self.alert_form = AlertForm()
self.about_form = AboutForm() self.about_form = AboutForm()
self.settings_form = SettingsForm(self.screen_list) 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.split(os.path.abspath(__file__))[0]
pluginpath = os.path.abspath(os.path.join(pluginpath, '..', '..','plugins')) pluginpath = os.path.abspath(os.path.join(pluginpath, '..', '..','plugins'))
@ -53,6 +52,11 @@ class MainWindow(object):
self.setupUi() 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') log.info(u'Load Plugins')
self.plugin_helpers[u'preview'] = self.PreviewController self.plugin_helpers[u'preview'] = self.PreviewController
self.plugin_helpers[u'live'] = self.LiveController self.plugin_helpers[u'live'] = self.LiveController
@ -87,6 +91,7 @@ class MainWindow(object):
log.info(u'Load Themes') log.info(u'Load Themes')
self.ThemeManagerContents.setEventManager(self.EventManager) self.ThemeManagerContents.setEventManager(self.EventManager)
self.ThemeManagerContents.setRenderManager(self.RenderManager) self.ThemeManagerContents.setRenderManager(self.RenderManager)
self.ServiceManagerContents.setRenderManager(self.RenderManager)
self.ThemeManagerContents.setServiceManager(self.ServiceManagerContents) self.ThemeManagerContents.setServiceManager(self.ServiceManagerContents)
self.ThemeManagerContents.loadThemes() self.ThemeManagerContents.loadThemes()

View File

@ -29,6 +29,7 @@ from PyQt4.QtGui import *
# from openlp.core.ui import AboutForm, AlertForm, SettingsForm, SlideController # from openlp.core.ui import AboutForm, AlertForm, SettingsForm, SlideController
from openlp.core.lib import OpenLPToolbar from openlp.core.lib import OpenLPToolbar
from openlp.core.lib import ServiceItem from openlp.core.lib import ServiceItem
from openlp.core.lib import RenderManager
# from openlp.core import PluginManager # from openlp.core import PluginManager
import logging import logging
@ -138,6 +139,14 @@ class ServiceManager(QWidget):
self.service_data=ServiceData() self.service_data=ServiceData()
self.TreeView.setModel(self.service_data) self.TreeView.setModel(self.service_data)
self.Layout.addWidget(self.TreeView) 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): def addServiceItem(self, item):
"""Adds service item""" """Adds service item"""
@ -191,3 +200,5 @@ class ServiceManager(QWidget):
self.ThemeComboBox.clear() self.ThemeComboBox.clear()
for theme in theme_list: for theme in theme_list:
self.ThemeComboBox.addItem(theme) self.ThemeComboBox.addItem(theme)
self.renderManager.set_default_theme(self.ThemeComboBox.currentText())

View File

@ -3,7 +3,7 @@
""" """
OpenLP - Open Source Lyrics Projection OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman 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 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 the terms of the GNU General Public License as published by the Free Software
@ -27,7 +27,7 @@ class SlideController(QtGui.QWidget):
self.Pane = QtGui.QWidget(control_splitter) self.Pane = QtGui.QWidget(control_splitter)
self.Splitter = QtGui.QSplitter(self.Pane) self.Splitter = QtGui.QSplitter(self.Pane)
self.Splitter.setOrientation(QtCore.Qt.Vertical) self.Splitter.setOrientation(QtCore.Qt.Vertical)
self.PaneLayout = QtGui.QVBoxLayout(self.Pane) self.PaneLayout = QtGui.QVBoxLayout(self.Pane)
self.PaneLayout.addWidget(self.Splitter) self.PaneLayout.addWidget(self.Splitter)
self.PaneLayout.setSpacing(50) self.PaneLayout.setSpacing(50)
@ -41,6 +41,23 @@ class SlideController(QtGui.QWidget):
self.Controller.setGeometry(QtCore.QRect(0, 0, 828, 536)) self.Controller.setGeometry(QtCore.QRect(0, 0, 828, 536))
self.Controller.setWidget(self.ControllerContents) self.Controller.setWidget(self.ControllerContents)
self.Screen = QtGui.QGraphicsView(self.Splitter) #self.Screen = QtGui.QGraphicsView(self.Splitter)
self.Screen.setMaximumSize(QtCore.QSize(16777215, 250)) #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)

View File

@ -20,12 +20,15 @@ Place, Suite 330, Boston, MA 02111-1307 USA
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.resources import * #from openlp.core.resources import *
from openlp.core import translate
class SplashScreen(object): class SplashScreen(object):
def __init__(self): def __init__(self, version):
self.splash_screen = QtGui.QSplashScreen() self.splash_screen = QtGui.QSplashScreen()
self.setupUi() self.setupUi()
starting = translate('SplashScreen',u'Starting')
self.message=starting+u'..... '+version
def setupUi(self): def setupUi(self):
self.splash_screen.setObjectName("splash_screen") self.splash_screen.setObjectName("splash_screen")
@ -60,7 +63,7 @@ class SplashScreen(object):
def show(self): def show(self):
self.splash_screen.show() 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() self.splash_screen.repaint()
def finish(self, widget): def finish(self, widget):

View File

@ -33,6 +33,7 @@ from PyQt4.QtGui import *
from openlp.core.ui import AmendThemeForm from openlp.core.ui import AmendThemeForm
from openlp.core.ui import ServiceManager from openlp.core.ui import ServiceManager
from openlp.core import translate from openlp.core import translate
from openlp.core import fileToXML
from openlp.core.theme import Theme from openlp.core.theme import Theme
from openlp.core.lib import Event from openlp.core.lib import Event
from openlp.core.lib import EventType from openlp.core.lib import EventType
@ -248,6 +249,13 @@ class ThemeManager(QWidget):
def getThemes(self): def getThemes(self):
return self.Theme_data.getList() 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): def checkThemesExists(self, dir):
log.debug(u'check themes') log.debug(u'check themes')
if os.path.exists(dir) == False: if os.path.exists(dir) == False:

View File

@ -48,19 +48,19 @@ class BibleMediaItem(MediaManagerItem):
# Create buttons for the toolbar # Create buttons for the toolbar
## New Bible Button ## ## New Bible Button ##
self.addToolbarButton( self.addToolbarButton(
translate(u'BibleMediaItem','New Bible'), translate(u'BibleMediaItem','New Bible'),
translate(u'BibleMediaItem','Register a new Bible'), translate(u'BibleMediaItem','Register a new Bible'),
':/themes/theme_import.png', self.onBibleNewClick, 'BibleNewItem') ':/themes/theme_import.png', self.onBibleNewClick, 'BibleNewItem')
## Separator Line ## ## Separator Line ##
self.addToolbarSeparator() self.addToolbarSeparator()
## Preview Bible Button ## ## Preview Bible Button ##
self.addToolbarButton( self.addToolbarButton(
translate(u'BibleMediaItem','Preview Bible'), translate(u'BibleMediaItem','Preview Bible'),
translate(u'BibleMediaItem','Preview the selected Bible Verse'), translate(u'BibleMediaItem','Preview the selected Bible Verse'),
':/system/system_preview.png', self.onBiblePreviewClick, 'BiblePreviewItem') ':/system/system_preview.png', self.onBiblePreviewClick, 'BiblePreviewItem')
## Live Bible Button ## ## Live Bible Button ##
self.addToolbarButton( self.addToolbarButton(
translate(u'BibleMediaItem','Go Live'), translate(u'BibleMediaItem','Go Live'),
translate(u'BibleMediaItem','Send the selected Bible Verse(s) live'), translate(u'BibleMediaItem','Send the selected Bible Verse(s) live'),
':/system/system_live.png', self.onBibleLiveClick, 'BibleLiveItem') ':/system/system_live.png', self.onBibleLiveClick, 'BibleLiveItem')
## Add Bible Button ## ## Add Bible Button ##
@ -183,9 +183,10 @@ class BibleMediaItem(MediaManagerItem):
self.BibleListView.setAlternatingRowColors(True) self.BibleListView.setAlternatingRowColors(True)
self.BibleListData = TextListData() self.BibleListData = TextListData()
self.BibleListView.setModel(self.BibleListData) self.BibleListView.setModel(self.BibleListData)
self.BibleListView.setSelectionMode(2)
self.PageLayout.addWidget(self.BibleListView) self.PageLayout.addWidget(self.BibleListView)
# Combo Boxes # Combo Boxes
QtCore.QObject.connect(self.AdvancedVersionComboBox, QtCore.QObject.connect(self.AdvancedVersionComboBox,
QtCore.SIGNAL("activated(int)"), self.onAdvancedVersionComboBox) QtCore.SIGNAL("activated(int)"), self.onAdvancedVersionComboBox)
@ -215,7 +216,7 @@ class BibleMediaItem(MediaManagerItem):
translate(u'BibleMediaItem',u'&Add to Service'), self.onBibleAddClick)) translate(u'BibleMediaItem',u'&Add to Service'), self.onBibleAddClick))
def retranslateUi(self): def retranslateUi(self):
log.debug(u'retranslateUi') log.debug(u'retranslateUi')
self.QuickVersionLabel.setText(translate(u'BibleMediaItem', u'Version:')) self.QuickVersionLabel.setText(translate(u'BibleMediaItem', u'Version:'))
self.QuickSearchLabel.setText(translate(u'BibleMediaItem', u'Search Type:')) self.QuickSearchLabel.setText(translate(u'BibleMediaItem', u'Search Type:'))
self.QuickSearchLabel.setText(translate(u'BibleMediaItem', u'Find:')) self.QuickSearchLabel.setText(translate(u'BibleMediaItem', u'Find:'))
@ -241,15 +242,15 @@ class BibleMediaItem(MediaManagerItem):
self.loadBibles() self.loadBibles()
def loadBibles(self): def loadBibles(self):
log.debug(u'Loading Bibles') log.debug(u'Loading Bibles')
self.QuickVersionComboBox.clear() self.QuickVersionComboBox.clear()
self.AdvancedVersionComboBox.clear() self.AdvancedVersionComboBox.clear()
bibles = self.parent.biblemanager.get_bibles(u'full') bibles = self.parent.biblemanager.get_bibles(u'full')
for bible in bibles: # load bibles into the combo boxes for bible in bibles: # load bibles into the combo boxes
self.QuickVersionComboBox.addItem(bible) self.QuickVersionComboBox.addItem(bible)
bibles = self.parent.biblemanager.get_bibles(u'partial') # Without HTTP bibles = self.parent.biblemanager.get_bibles(u'partial') # Without HTTP
first = True first = True
for bible in bibles: # load bibles into the combo boxes for bible in bibles: # load bibles into the combo boxes
@ -328,6 +329,8 @@ class BibleMediaItem(MediaManagerItem):
log.debug(u'Bible Preview Button pressed') log.debug(u'Bible Preview Button pressed')
items = self.BibleListView.selectedIndexes() items = self.BibleListView.selectedIndexes()
old_chapter = '' old_chapter = ''
main_lines=[]
footer_lines = []
for item in items: for item in items:
text = self.BibleListData.getValue(item) text = self.BibleListData.getValue(item)
verse = text[:text.find("(")] verse = text[:text.find("(")]
@ -348,16 +351,19 @@ class BibleMediaItem(MediaManagerItem):
else: else:
loc = self.formatVerse(old_chapter, chapter, verse, u'', u'') loc = self.formatVerse(old_chapter, chapter, verse, u'', u'')
old_chapter = chapter old_chapter = chapter
print book main_lines.append(loc + u' '+text)
print loc if len(footer_lines) <= 1:
print text 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): def formatVerse(self, old_chapter, chapter, verse, opening, closing):
loc = opening loc = opening
if old_chapter != chapter: if old_chapter != chapter:
loc += chapter + u':' 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 += chapter + u':'
loc += verse loc += verse
loc += closing loc += closing
return loc return loc

View File

@ -23,7 +23,7 @@ from PyQt4 import QtCore, QtGui
from openlp.core import translate from openlp.core import translate
from openlp.core.lib import MediaManagerItem from openlp.core.lib import MediaManagerItem
from openlp.core.resources import * from openlp.core.lib import SongXMLParser
from openlp.plugins.custom.lib import TextListData from openlp.plugins.custom.lib import TextListData
@ -44,7 +44,7 @@ class CustomMediaItem(MediaManagerItem):
# Create buttons for the toolbar # Create buttons for the toolbar
## New Custom Button ## ## New Custom Button ##
self.addToolbarButton( self.addToolbarButton(
translate('CustomMediaItem',u'New Custom Item'), translate('CustomMediaItem',u'New Custom Item'),
translate('CustomMediaItem',u'Add a new Custom Item'), translate('CustomMediaItem',u'Add a new Custom Item'),
':/custom/custom_new.png', self.onCustomNewClick, 'CustomNewItem') ':/custom/custom_new.png', self.onCustomNewClick, 'CustomNewItem')
## Edit Custom Button ## ## Edit Custom Button ##
@ -72,7 +72,7 @@ class CustomMediaItem(MediaManagerItem):
## Add Custom Button ## ## Add Custom Button ##
self.addToolbarButton( self.addToolbarButton(
translate('CustomMediaItem',u'Add Custom To Service'), translate('CustomMediaItem',u'Add Custom To Service'),
translate('CustomMediaItem',u'Add the selected Custom(s) to the service'), translate('CustomMediaItem',u'Add the selected Custom(s) to the service'),
':/system/system_add.png', self.onCustomAddClick, 'CustomAddItem') ':/system/system_add.png', self.onCustomAddClick, 'CustomAddItem')
# Add the Customlist widget # Add the Customlist widget
self.CustomWidget = QtGui.QWidget(self) self.CustomWidget = QtGui.QWidget(self)
@ -82,7 +82,7 @@ class CustomMediaItem(MediaManagerItem):
sizePolicy.setHeightForWidth(self.CustomWidget.sizePolicy().hasHeightForWidth()) sizePolicy.setHeightForWidth(self.CustomWidget.sizePolicy().hasHeightForWidth())
self.CustomWidget.setSizePolicy(sizePolicy) self.CustomWidget.setSizePolicy(sizePolicy)
self.CustomWidget.setObjectName(u'CustomWidget') self.CustomWidget.setObjectName(u'CustomWidget')
# self.SearchLayout = QtGui.QGridLayout(self.CustomWidget) # self.SearchLayout = QtGui.QGridLayout(self.CustomWidget)
# self.SearchLayout.setObjectName('SearchLayout') # self.SearchLayout.setObjectName('SearchLayout')
# self.SearchTextLabel = QtGui.QLabel(self.CustomWidget) # self.SearchTextLabel = QtGui.QLabel(self.CustomWidget)
@ -92,7 +92,7 @@ class CustomMediaItem(MediaManagerItem):
# self.SearchTextEdit = QtGui.QLineEdit(self.CustomWidget) # self.SearchTextEdit = QtGui.QLineEdit(self.CustomWidget)
# self.SearchTextEdit.setObjectName('SearchTextEdit') # self.SearchTextEdit.setObjectName('SearchTextEdit')
# self.SearchLayout.addWidget(self.SearchTextEdit, 2, 1, 1, 2) # self.SearchLayout.addWidget(self.SearchTextEdit, 2, 1, 1, 2)
# #
# self.ClearTextButton = QtGui.QPushButton(self.CustomWidget) # self.ClearTextButton = QtGui.QPushButton(self.CustomWidget)
# self.ClearTextButton.setObjectName('ClearTextButton') # self.ClearTextButton.setObjectName('ClearTextButton')
# #
@ -102,22 +102,22 @@ class CustomMediaItem(MediaManagerItem):
# self.SearchLayout.addWidget(self.SearchTextButton, 3, 2, 1, 1) # self.SearchLayout.addWidget(self.SearchTextButton, 3, 2, 1, 1)
# Add the Custom widget to the page layout # Add the Custom widget to the page layout
self.PageLayout.addWidget(self.CustomWidget) self.PageLayout.addWidget(self.CustomWidget)
self.CustomListView = QtGui.QListView() self.CustomListView = QtGui.QListView()
self.CustomListView.setAlternatingRowColors(True) self.CustomListView.setAlternatingRowColors(True)
self.CustomListData = TextListData() self.CustomListData = TextListData()
self.CustomListView.setModel(self.CustomListData) self.CustomListView.setModel(self.CustomListData)
self.PageLayout.addWidget(self.CustomListView) self.PageLayout.addWidget(self.CustomListView)
# Signals # Signals
# QtCore.QObject.connect(self.SearchTextButton, # QtCore.QObject.connect(self.SearchTextButton,
# QtCore.SIGNAL("pressed()"), self.onSearchTextButtonClick) # QtCore.SIGNAL("pressed()"), self.onSearchTextButtonClick)
# QtCore.QObject.connect(self.ClearTextButton, # QtCore.QObject.connect(self.ClearTextButton,
# QtCore.SIGNAL("pressed()"), self.onClearTextButtonClick) # QtCore.SIGNAL("pressed()"), self.onClearTextButtonClick)
# QtCore.QObject.connect(self.SearchTextEdit, # QtCore.QObject.connect(self.SearchTextEdit,
# QtCore.SIGNAL("textChanged(const QString&)"), self.onSearchTextEditChanged) # QtCore.SIGNAL("textChanged(const QString&)"), self.onSearchTextEditChanged)
# QtCore.QObject.connect(self.CustomListView, # QtCore.QObject.connect(self.CustomListView,
# QtCore.SIGNAL("itemPressed(QTableWidgetItem * item)"), self.onCustomSelected) # QtCore.SIGNAL("itemPressed(QTableWidgetItem * item)"), self.onCustomSelected)
#define and add the context menu #define and add the context menu
@ -135,14 +135,14 @@ class CustomMediaItem(MediaManagerItem):
self.CustomListView.addAction(self.contextMenuAction( self.CustomListView.addAction(self.contextMenuAction(
self.CustomListView, ':/system/system_add.png', self.CustomListView, ':/system/system_add.png',
translate('CustomMediaItem',u'&Add to Service'), self.onCustomEditClick)) translate('CustomMediaItem',u'&Add to Service'), self.onCustomEditClick))
# def retranslateUi(self): # def retranslateUi(self):
# self.ClearTextButton.setText(translate('CustomMediaItem', u'Clear')) # self.ClearTextButton.setText(translate('CustomMediaItem', u'Clear'))
# self.SearchTextButton.setText(translate('CustomMediaItem', u'Search')) # self.SearchTextButton.setText(translate('CustomMediaItem', u'Search'))
def initialise(self): def initialise(self):
self.loadCustomList(self.parent.custommanager.get_all_slides()) self.loadCustomList(self.parent.custommanager.get_all_slides())
def loadCustomList(self, list): def loadCustomList(self, list):
self.CustomListData.resetStore() self.CustomListData.resetStore()
for CustomSlide in list: for CustomSlide in list:
@ -166,9 +166,9 @@ class CustomMediaItem(MediaManagerItem):
self._display_results(search_results) self._display_results(search_results)
def onCustomNewClick(self): def onCustomNewClick(self):
self.parent.edit_custom_form.loadCustom(0) self.parent.edit_custom_form.loadCustom(0)
self.parent.edit_custom_form.exec_() self.parent.edit_custom_form.exec_()
self.initialise() self.initialise()
def onCustomEditClick(self): def onCustomEditClick(self):
indexes = self.CustomListView.selectedIndexes() indexes = self.CustomListView.selectedIndexes()
@ -185,7 +185,25 @@ class CustomMediaItem(MediaManagerItem):
self.CustomListData.deleteRow(index) self.CustomListData.deleteRow(index)
def onCustomPreviewClick(self): 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): def onCustomLiveClick(self):
pass pass

View File

@ -80,3 +80,7 @@ class FileListData(QAbstractListModel):
def getFilename(self, index): def getFilename(self, index):
row = index.row() row = index.row()
return self.items[row][0] return self.items[row][0]
def getValue(self, index):
row = index.row()
return self.items[row][0]

View File

@ -24,7 +24,6 @@ from PyQt4 import QtCore, QtGui
from openlp.core import translate from openlp.core import translate
from openlp.core.lib import MediaManagerItem from openlp.core.lib import MediaManagerItem
from openlp.core.resources import *
from openlp.plugins.videos.lib import VideoTab from openlp.plugins.videos.lib import VideoTab
from openlp.plugins.videos.lib import FileListData from openlp.plugins.videos.lib import FileListData
@ -40,93 +39,97 @@ class VideoMediaItem(MediaManagerItem):
def __init__(self, parent, icon, title): def __init__(self, parent, icon, title):
MediaManagerItem.__init__(self, parent, icon, title) MediaManagerItem.__init__(self, parent, icon, title)
def setupUi(self): def setupUi(self):
# Add a toolbar # Add a toolbar
self.addToolbar() self.addToolbar()
# Create buttons for the toolbar # Create buttons for the toolbar
## New Video Button ## ## New Video Button ##
self.addToolbarButton( self.addToolbarButton(
translate('VideoMediaItem',u'New Video'), translate('VideoMediaItem',u'New Video'),
translate('VideoMediaItem',u'Load videos into openlp.org'), translate('VideoMediaItem',u'Load videos into openlp.org'),
':/videos/video_load.png', self.onVideoNewClick, 'VideoNewItem') ':/videos/video_load.png', self.onVideoNewClick, 'VideoNewItem')
## Delete Video Button ## ## Delete Video Button ##
self.addToolbarButton( self.addToolbarButton(
translate('VideoMediaItem',u'Delete Video'), translate('VideoMediaItem',u'Delete Video'),
translate('VideoMediaItem',u'Delete the selected video'), translate('VideoMediaItem',u'Delete the selected video'),
':/videos/video_delete.png', self.onVideoDeleteClick, 'VideoDeleteItem') ':/videos/video_delete.png', self.onVideoDeleteClick, 'VideoDeleteItem')
## Separator Line ## ## Separator Line ##
self.addToolbarSeparator() self.addToolbarSeparator()
## Preview Video Button ## ## Preview Video Button ##
self.addToolbarButton( self.addToolbarButton(
translate('VideoMediaItem',u'Preview Video'), translate('VideoMediaItem',u'Preview Video'),
translate('VideoMediaItem',u'Preview the selected video'), translate('VideoMediaItem',u'Preview the selected video'),
':/system/system_preview.png', self.onVideoPreviewClick, 'VideoPreviewItem') ':/system/system_preview.png', self.onVideoPreviewClick, 'VideoPreviewItem')
## Live Video Button ## ## Live Video Button ##
self.addToolbarButton( self.addToolbarButton(
translate('VideoMediaItem',u'Go Live'), translate('VideoMediaItem',u'Go Live'),
translate('VideoMediaItem',u'Send the selected video live'), translate('VideoMediaItem',u'Send the selected video live'),
':/system/system_live.png', self.onVideoLiveClick, 'VideoLiveItem') ':/system/system_live.png', self.onVideoLiveClick, 'VideoLiveItem')
## Add Video Button ## ## Add Video Button ##
self.addToolbarButton( self.addToolbarButton(
translate('VideoMediaItem',u'Add Video To Service'), translate('VideoMediaItem',u'Add Video To Service'),
translate('VideoMediaItem',u'Add the selected video(s) to the service'), translate('VideoMediaItem',u'Add the selected video(s) to the service'),
':/system/system_add.png',self.onVideoAddClick, 'VideoAddItem') ':/system/system_add.png',self.onVideoAddClick, 'VideoAddItem')
## Add the videolist widget ## ## Add the videolist widget ##
self.VideoListView = QtGui.QListView() self.VideoListView = QtGui.QListView()
self.VideoListView.setAlternatingRowColors(True) self.VideoListView.setAlternatingRowColors(True)
self.VideoListData = FileListData() self.VideoListData = FileListData()
self.VideoListView.setModel(self.VideoListData) self.VideoListView.setModel(self.VideoListData)
self.PageLayout.addWidget(self.VideoListView) self.PageLayout.addWidget(self.VideoListView)
#define and add the context menu #define and add the context menu
self.VideoListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.VideoListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.VideoListView.addAction(self.contextMenuAction( self.VideoListView.addAction(self.contextMenuAction(
self.VideoListView, ':/system/system_preview.png', self.VideoListView, ':/system/system_preview.png',
translate('VideoMediaItem',u'&Preview Video'), self.onVideoPreviewClick)) translate('VideoMediaItem',u'&Preview Video'), self.onVideoPreviewClick))
self.VideoListView.addAction(self.contextMenuAction( self.VideoListView.addAction(self.contextMenuAction(
self.VideoListView, ':/system/system_live.png', self.VideoListView, ':/system/system_live.png',
translate('VideoMediaItem',u'&Show Live'), self.onVideoLiveClick)) translate('VideoMediaItem',u'&Show Live'), self.onVideoLiveClick))
self.VideoListView.addAction(self.contextMenuAction( self.VideoListView.addAction(self.contextMenuAction(
self.VideoListView, ':/system/system_add.png', self.VideoListView, ':/system/system_add.png',
translate('VideoMediaItem',u'&Add to Service'), self.onVideoAddClick)) translate('VideoMediaItem',u'&Add to Service'), self.onVideoAddClick))
def initialise(self): def initialise(self):
list = self.parent.config.load_list(u'videos') list = self.parent.config.load_list(u'videos')
self.loadVideoList(list) self.loadVideoList(list)
def onVideoNewClick(self): def onVideoNewClick(self):
files = QtGui.QFileDialog.getOpenFileNames(None, files = QtGui.QFileDialog.getOpenFileNames(None,
translate('VideoMediaItem', u'Select Video(s)'), translate('VideoMediaItem', u'Select Video(s)'),
self.parent.config.get_last_dir(), u'Images (*.avi *.mpeg)') self.parent.config.get_last_dir(), u'Images (*.avi *.mpeg)')
if len(files) > 0: if len(files) > 0:
self.loadVideoList(files) self.loadVideoList(files)
dir, filename = os.path.split(str(files[0])) dir, filename = os.path.split(str(files[0]))
self.parent.config.set_last_dir(dir) self.parent.config.set_last_dir(dir)
self.parent.config.set_list(u'videos', self.VideoListData.getFileList()) self.parent.config.set_list(u'videos', self.VideoListData.getFileList())
def getFileList(self): def getFileList(self):
filelist = [item[0] for item in self.VideoListView]; filelist = [item[0] for item in self.VideoListView];
return filelist return filelist
def loadVideoList(self, list): def loadVideoList(self, list):
for files in list: for files in list:
self.VideoListData.addRow(files) self.VideoListData.addRow(files)
def onVideoDeleteClick(self): def onVideoDeleteClick(self):
indexes = self.VideoListView.selectedIndexes() indexes = self.VideoListView.selectedIndexes()
for index in indexes: for index in indexes:
current_row = int(index.row()) current_row = int(index.row())
self.VideoListData.removeRow(current_row) self.VideoListData.removeRow(current_row)
self.parent.config.set_list(u'videos', self.VideoListData.getFileList()) self.parent.config.set_list(u'videos', self.VideoListData.getFileList())
def onVideoPreviewClick(self): 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): def onVideoLiveClick(self):
pass pass
def onVideoAddClick(self): def onVideoAddClick(self):
pass pass