forked from openlp/openlp
Code cleanups and add text colouring for songs etc
This commit is contained in:
parent
625e652fcc
commit
ee6f6d0618
@ -92,12 +92,21 @@ class ServiceItem(object):
|
||||
self.from_plugin = False
|
||||
self.capabilities = []
|
||||
self.is_valid = True
|
||||
#self.cache = {}
|
||||
self.icon = None
|
||||
self.themedata = None
|
||||
self.main = None
|
||||
self.footer = None
|
||||
|
||||
# TODO make external and configurable
|
||||
self.html_expands = {
|
||||
u'{r}': u'<font color=red>',
|
||||
u'{b}': u'<font color=black>',
|
||||
u'{u}': u'<font color=blue>',
|
||||
u'{y}': u'<font color=yellow>',
|
||||
u'{g}': u'<font color=green>',
|
||||
u'{/}': u'</font>'
|
||||
}
|
||||
|
||||
def add_capability(self, capability):
|
||||
"""
|
||||
Add an ItemCapability to a ServiceItem
|
||||
@ -153,10 +162,9 @@ class ServiceItem(object):
|
||||
for format in formated:
|
||||
self._display_frames.append(
|
||||
{u'title': format.replace(u'<p>', u''),
|
||||
u'text': format.rstrip(),
|
||||
u'text': self.clean(format.rstrip()),
|
||||
u'html': self.expand(format.rstrip()),
|
||||
u'verseTag': slide[u'verseTag'] })
|
||||
# if len(self._display_frames) in self.cache.keys():
|
||||
# del self.cache[len(self._display_frames)]
|
||||
log.log(15, u'Formatting took %4s' % (time.time() - before))
|
||||
elif self.service_item_type == ServiceItemType.Image:
|
||||
for slide in self._raw_frames:
|
||||
@ -174,26 +182,6 @@ class ServiceItem(object):
|
||||
else:
|
||||
self.foot_text = u'%s<br>%s' % (self.foot_text, foot)
|
||||
|
||||
def render_individual(self, row):
|
||||
"""
|
||||
Takes an array of text and generates an Image from the
|
||||
theme. It assumes the text will fit on the screen as it
|
||||
has generated by the render method above.
|
||||
"""
|
||||
log.debug(u'render individual')
|
||||
return self._display_frames[row][u'text'].split(u'\n')[0]
|
||||
# if self.cache.get(row):
|
||||
# frame = self.cache[row]
|
||||
# else:
|
||||
# if raw_html[0]:
|
||||
# frame = self.render_manager.generate_slide(raw_html,
|
||||
# self.raw_footer)
|
||||
# else:
|
||||
# frame = self.render_manager.generate_slide(raw_html, u'')
|
||||
# frame = None
|
||||
# #self.cache[row] = frame
|
||||
# return raw_html[0]
|
||||
|
||||
def add_from_image(self, path, title, image):
|
||||
"""
|
||||
Add an image slide to the service item.
|
||||
@ -379,7 +367,7 @@ class ServiceItem(object):
|
||||
renders it if required.
|
||||
"""
|
||||
if self.service_item_type == ServiceItemType.Text:
|
||||
return None, self.render_individual(row)
|
||||
return None, self._display_frames[row][u'html'].split(u'\n')[0]
|
||||
else:
|
||||
return self._raw_frames[row][u'image'], u''
|
||||
|
||||
@ -395,8 +383,21 @@ class ServiceItem(object):
|
||||
"""
|
||||
return self._raw_frames[row][u'path']
|
||||
|
||||
# def clear_cache(self):
|
||||
# """
|
||||
# Clear's the service item's cache.
|
||||
# """
|
||||
# self.cache = {}
|
||||
def clean(self, text):
|
||||
"""
|
||||
Remove Tags from text for display
|
||||
"""
|
||||
text = text.replace(u'<br>', u'\n').replace(u'<p>', u'')\
|
||||
.replace(u'</p>', u'').replace(u'<sup>', u'')\
|
||||
.replace(u'</sup>', u'')
|
||||
for key, value in self.html_expands.iteritems():
|
||||
text = text.replace(key, u'')
|
||||
return text
|
||||
|
||||
def expand(self, text):
|
||||
"""
|
||||
Expand tags fto HTML for display
|
||||
"""
|
||||
for key, value in self.html_expands.iteritems():
|
||||
text = text.replace(key, value)
|
||||
return text
|
||||
|
@ -37,24 +37,6 @@ from openlp.core.lib import OpenLPToolbar, Receiver, resize_image, \
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
#class SlideThread(QtCore.QThread):
|
||||
# """
|
||||
# A special Qt thread class to speed up the display of text based frames.
|
||||
# This is threaded so it loads the frames in background
|
||||
# """
|
||||
# def __init__(self, parent, prefix, count):
|
||||
# QtCore.QThread.__init__(self, parent)
|
||||
# self.prefix = prefix
|
||||
# self.count = count
|
||||
#
|
||||
# def run(self):
|
||||
# """
|
||||
# Run the thread.
|
||||
# """
|
||||
# time.sleep(1)
|
||||
# for i in range(0, self.count):
|
||||
# Receiver.send_message(u'%s_slide_cache' % self.prefix, i)
|
||||
|
||||
class SlideList(QtGui.QTableWidget):
|
||||
"""
|
||||
Customised version of QTableWidget which can respond to keyboard
|
||||
@ -215,15 +197,17 @@ class SlideController(QtGui.QWidget):
|
||||
self.ThemeScreen.setCheckable(True)
|
||||
QtCore.QObject.connect(self.ThemeScreen,
|
||||
QtCore.SIGNAL("triggered(bool)"), self.onThemeDisplay)
|
||||
self.DesktopScreen = QtGui.QAction(QtGui.QIcon(
|
||||
u':/slides/slide_desktop.png'), u'Show Desktop', self.HideMenu)
|
||||
self.DesktopScreen.setCheckable(True)
|
||||
QtCore.QObject.connect(self.DesktopScreen,
|
||||
QtCore.SIGNAL("triggered(bool)"), self.onHideDisplay)
|
||||
if self.screens.display_count > 1:
|
||||
self.DesktopScreen = QtGui.QAction(QtGui.QIcon(
|
||||
u':/slides/slide_desktop.png'), u'Show Desktop', self.HideMenu)
|
||||
self.DesktopScreen.setCheckable(True)
|
||||
QtCore.QObject.connect(self.DesktopScreen,
|
||||
QtCore.SIGNAL("triggered(bool)"), self.onHideDisplay)
|
||||
self.HideMenu.setDefaultAction(self.BlankScreen)
|
||||
self.HideMenu.menu().addAction(self.BlankScreen)
|
||||
self.HideMenu.menu().addAction(self.ThemeScreen)
|
||||
self.HideMenu.menu().addAction(self.DesktopScreen)
|
||||
if self.screens.display_count > 1:
|
||||
self.HideMenu.menu().addAction(self.DesktopScreen)
|
||||
if not self.isLive:
|
||||
self.Toolbar.addToolbarSeparator(u'Close Separator')
|
||||
self.Toolbar.addToolbarButton(
|
||||
@ -559,9 +543,6 @@ class SlideController(QtGui.QWidget):
|
||||
width = self.parent.ControlSplitter.sizes()[self.split]
|
||||
# Set pointing cursor when we have somthing to point at
|
||||
self.PreviewListWidget.setCursor(QtCore.Qt.PointingHandCursor)
|
||||
# Clear the old serviceItem cache to release memory
|
||||
# if self.serviceItem and self.serviceItem is not serviceItem:
|
||||
# self.serviceItem.clear_cache()
|
||||
self.serviceItem = serviceItem
|
||||
self.PreviewListWidget.clear()
|
||||
self.PreviewListWidget.setRowCount(0)
|
||||
@ -588,7 +569,7 @@ class SlideController(QtGui.QWidget):
|
||||
self.onSongBarHandler)
|
||||
else:
|
||||
row += 1
|
||||
item.setText(self.clean(frame[u'text']))
|
||||
item.setText(frame[u'text'])
|
||||
else:
|
||||
label = QtGui.QLabel()
|
||||
label.setMargin(4)
|
||||
@ -622,10 +603,6 @@ class SlideController(QtGui.QWidget):
|
||||
self.PreviewListWidget.setFocus()
|
||||
Receiver.send_message(u'slidecontroller_%s_started' % self.typePrefix,
|
||||
[serviceItem])
|
||||
# if self.serviceItem.is_text():
|
||||
# st = SlideThread(
|
||||
# self, self.typePrefix, len(self.serviceItem.get_frames()))
|
||||
# st.start()
|
||||
|
||||
def onTextRequest(self):
|
||||
"""
|
||||
@ -637,7 +614,7 @@ class SlideController(QtGui.QWidget):
|
||||
dataItem = {}
|
||||
if self.serviceItem.is_text():
|
||||
dataItem[u'tag'] = unicode(frame[u'verseTag'])
|
||||
dataItem[u'text'] = unicode(frame[u'text'])
|
||||
dataItem[u'text'] = unicode(frame[u'html'])
|
||||
else:
|
||||
dataItem[u'tag'] = unicode(framenumber)
|
||||
dataItem[u'text'] = u''
|
||||
@ -993,9 +970,3 @@ class SlideController(QtGui.QWidget):
|
||||
self.video.hide()
|
||||
self.SlidePreview.clear()
|
||||
self.SlidePreview.show()
|
||||
|
||||
def clean(self, text):
|
||||
text = text.replace(u'<br>', u'\n').replace(u'<p>', u'')\
|
||||
.replace(u'</p>', u'').replace(u'<sup>', u'')\
|
||||
.replace(u'</sup>', u'')
|
||||
return text
|
||||
|
Loading…
Reference in New Issue
Block a user