Fix up rendering a bit

Re-write the slide controller so it looks better (big clean up)
Fix themes where backgrounds are png files so they do not become phantom themes
start to sort out conversions
Hide openoffice at startup
This commit is contained in:
Tim Bentley 2009-07-02 20:04:50 +01:00
parent 9318cc3ec0
commit 3c71e91498
7 changed files with 86 additions and 186 deletions

View File

@ -30,6 +30,9 @@ class Convert():
infile = codecs.open(inname, 'r', encoding='iso-8859-1') infile = codecs.open(inname, 'r', encoding='iso-8859-1')
writefile = codecs.open(outname, 'w', encoding='utf-8') writefile = codecs.open(outname, 'w', encoding='utf-8')
for line in infile: for line in infile:
#replace the quotes with quotes
line, replace(u'\x93', "'")
line, replace(u'\x94', "'")
writefile.write(line) writefile.write(line)
infile.close() infile.close()
writefile.close() writefile.close()

View File

@ -155,8 +155,12 @@ class RenderManager:
def calculate_default(self, screen): def calculate_default(self, screen):
log.debug(u'calculate default %s' , screen) log.debug(u'calculate default %s' , screen)
self.width = screen.width() if self.current_display == 0:
self.height = screen.height() self.width = 1024
self.height = 768
else:
self.width = screen.width()
self.height = screen.height()
log.debug(u'calculate default %d,%d' , self.width, self.height) log.debug(u'calculate default %d,%d' , self.width, self.height)
# 90% is start of footer # 90% is start of footer
self.footer_start = int(self.height * 0.90) self.footer_start = int(self.height * 0.90)

View File

@ -21,84 +21,12 @@ import logging
import os import os
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import OpenLPToolbar, translate from openlp.core.lib import OpenLPToolbar, translate, buildIcon
class SlideData(QtCore.QAbstractListModel): class SlideList(QtGui.QTableWidget):
"""
List of frames to be displayed on the list and the main display.
"""
global log
log = logging.getLogger(u'SlideData')
def __init__(self):
QtCore.QAbstractListModel.__init__(self)
self.items = []
self.rowheight = 50
self.maximagewidth = self.rowheight * 16 / 9.0;
log.info(u'Starting')
def clear(self):
self.items = []
def columnCount(self, parent):
return 1
def rowCount(self, parent=None):
return len(self.items)
def insertRow(self, row, frame, framenumber):
self.beginInsertRows(QtCore.QModelIndex(), row, row)
log.info(u'insert row %d' % row)
# create a preview image
frame1 = frame.scaled(QtCore.QSize(280, 210), QtCore.Qt.KeepAspectRatio,
QtCore.Qt.SmoothTransformation)
self.items.insert(row, (frame1, framenumber))
log.info(u'Item loaded')
self.endInsertRows()
def removeRow(self, row):
self.beginRemoveRows(QtCore.QModelIndex(), row, row)
self.items.pop(row)
self.endRemoveRows()
def addRow(self, frame, framenumber):
self.insertRow(len(self.items), frame, framenumber)
def data(self, index, role):
row = index.row()
if row > len(self.items):
# if the last row is selected and deleted, we then get called with
# an empty row!
return QtCore.QVariant()
if role == QtCore.Qt.DecorationRole:
retval = self.items[row][0]
else:
retval = QtCore.QVariant()
if type(retval) is not type(QtCore.QVariant):
return QtCore.QVariant(retval)
else:
return retval
def __iter__(self):
for item in self.items:
yield item
def getValue(self, index):
row = index.row()
return self.items[row]
def getItem(self, row):
log.info(u'Get Item:%d -> %s' %(row, unicode(self.items)))
return self.items[row]
def getList(self):
filelist = [item[3] for item in self.items];
return filelist
class SlideList(QtGui.QListView):
def __init__(self,parent=None,name=None): def __init__(self,parent=None,name=None):
QtGui.QListView.__init__(self,parent.Controller) QtGui.QTableWidget.__init__(self,parent.Controller)
self.parent = parent self.parent = parent
def keyPressEvent(self, event): def keyPressEvent(self, event):
@ -145,7 +73,7 @@ class SlideController(QtGui.QWidget):
self.PanelLayout.setMargin(0) self.PanelLayout.setMargin(0)
# Actual controller section # Actual controller section
self.Controller = QtGui.QWidget(self.Splitter) self.Controller = QtGui.QWidget(self.Splitter)
self.Controller.setGeometry(QtCore.QRect(0, 0, 800, 536)) self.Controller.setGeometry(QtCore.QRect(0, 0, 100, 536))
self.Controller.setSizePolicy( self.Controller.setSizePolicy(
QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred,
QtGui.QSizePolicy.Maximum)) QtGui.QSizePolicy.Maximum))
@ -153,19 +81,14 @@ class SlideController(QtGui.QWidget):
self.ControllerLayout.setSpacing(0) self.ControllerLayout.setSpacing(0)
self.ControllerLayout.setMargin(0) self.ControllerLayout.setMargin(0)
# Controller list view # Controller list view
self.PreviewListView = SlideList(self) self.PreviewListWidget = SlideList(self)
self.PreviewListView.setUniformItemSizes(True) self.PreviewListWidget.setColumnCount(1)
self.PreviewListView.setIconSize(QtCore.QSize(250, 190)) self.PreviewListWidget.horizontalHeader().setVisible(False)
self.PreviewListData = SlideData() self.PreviewListWidget.verticalHeader().setVisible(False)
self.PreviewListView.isLive = self.isLive self.PreviewListWidget.setColumnWidth(1, self.Controller.width())
if QtCore.QT_VERSION_STR > u'4.4.0': self.PreviewListWidget.isLive = self.isLive
self.PreviewListView.setFlow(1) self.PreviewListWidget.setObjectName(u'PreviewListWidget')
self.PreviewListView.setViewMode(1) self.ControllerLayout.addWidget(self.PreviewListWidget)
self.PreviewListView.setWrapping(False)
self.PreviewListView.setModel(self.PreviewListData)
self.PreviewListView.setSpacing(0)
self.PreviewListView.setObjectName(u'PreviewListView')
self.ControllerLayout.addWidget(self.PreviewListView)
# Plugin the Base Toolbar class # Plugin the Base Toolbar class
self.BaseToolbar = BaseToolbar(self.isLive) self.BaseToolbar = BaseToolbar(self.isLive)
self.Toolbar = self.BaseToolbar.getToolbar() self.Toolbar = self.BaseToolbar.getToolbar()
@ -179,7 +102,7 @@ class SlideController(QtGui.QWidget):
self.Toolbar.setSizePolicy(sizeToolbarPolicy) self.Toolbar.setSizePolicy(sizeToolbarPolicy)
# Screen preview area # Screen preview area
self.PreviewFrame = QtGui.QFrame(self.Splitter) self.PreviewFrame = QtGui.QFrame(self.Splitter)
self.PreviewFrame.setGeometry(QtCore.QRect(0, 0, 250, 190)) self.PreviewFrame.setGeometry(QtCore.QRect(0, 0, 280, 190))
self.PreviewFrame.setSizePolicy(QtGui.QSizePolicy( self.PreviewFrame.setSizePolicy(QtGui.QSizePolicy(
QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum)) QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum))
self.PreviewFrame.setFrameShape(QtGui.QFrame.StyledPanel) self.PreviewFrame.setFrameShape(QtGui.QFrame.StyledPanel)
@ -197,20 +120,20 @@ class SlideController(QtGui.QWidget):
sizePolicy.setHeightForWidth( sizePolicy.setHeightForWidth(
self.SlidePreview.sizePolicy().hasHeightForWidth()) self.SlidePreview.sizePolicy().hasHeightForWidth())
self.SlidePreview.setSizePolicy(sizePolicy) self.SlidePreview.setSizePolicy(sizePolicy)
self.SlidePreview.setMinimumSize(QtCore.QSize(280, 210)) self.SlidePreview.setFixedSize(QtCore.QSize(250, 210))
self.SlidePreview.setFrameShape(QtGui.QFrame.Box) self.SlidePreview.setFrameShape(QtGui.QFrame.Box)
self.SlidePreview.setFrameShadow(QtGui.QFrame.Plain) self.SlidePreview.setFrameShadow(QtGui.QFrame.Plain)
self.SlidePreview.setLineWidth(1) self.SlidePreview.setLineWidth(1)
self.SlidePreview.setScaledContents(True) self.SlidePreview.setScaledContents(True)
self.SlidePreview.setObjectName(u'SlidePreview') self.SlidePreview.setObjectName(u'SlidePreview')
self.grid.addWidget(self.SlidePreview, 0, 0, 1, 1) self.grid.addWidget(self.SlidePreview, 0, 0, 1, 1)
QtCore.QObject.connect(self.PreviewListView, # Signals
QtCore.QObject.connect(self.PreviewListWidget,
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.BaseToolbar.onSlideSelected) QtCore.SIGNAL(u'clicked(QModelIndex)'), self.BaseToolbar.onSlideSelected)
QtCore.QObject.connect(self.PreviewListView, QtCore.QObject.connect(self.PreviewListWidget,
QtCore.SIGNAL(u'activated(QModelIndex)'), self.BaseToolbar.onSlideSelected) QtCore.SIGNAL(u'activated(QModelIndex)'), self.BaseToolbar.onSlideSelected)
# Add Late Arrivals # Add Late Arrivals
self.BaseToolbar.PreviewListView = self.PreviewListView self.BaseToolbar.PreviewListWidget = self.PreviewListWidget
self.BaseToolbar.PreviewListData = self.PreviewListData
self.BaseToolbar.SlidePreview = self.SlidePreview self.BaseToolbar.SlidePreview = self.SlidePreview
self.BaseToolbar.mainDisplay = self.parent.mainDisplay self.BaseToolbar.mainDisplay = self.parent.mainDisplay
@ -224,8 +147,7 @@ class BaseToolbar(object):
def __init__(self, isLive): def __init__(self, isLive):
self.Toolbar = None self.Toolbar = None
self.PreviewListView = QtGui.QListWidget() self.PreviewListWidget = QtGui.QListWidget()
self.PreviewListData = None
self.isLive = isLive self.isLive = isLive
self.defineToolbar() self.defineToolbar()
@ -272,56 +194,35 @@ class BaseToolbar(object):
""" """
Go to the first slide. Go to the first slide.
""" """
row = self.PreviewListData.createIndex(0, 0) self.PreviewListWidget.selectRow(0)
if row.isValid(): self.onSlideSelected()
self.PreviewListView.selectionModel().setCurrentIndex(row,
QtGui.QItemSelectionModel.SelectCurrent)
self.onSlideSelected(row)
def onSlideSelectedNext(self): def onSlideSelectedNext(self):
""" """
Go to the next slide. Go to the next slide.
""" """
indexes = self.PreviewListView.selectedIndexes() row = self.PreviewListWidget.currentRow() + 1
rowNumber = 0 if row == self.PreviewListWidget.rowCount():
for index in indexes: row = 0
if index.row() == self.PreviewListData.rowCount() - 1: self.PreviewListWidget.selectRow(row)
rowNumber = 0 self.onSlideSelected()
else:
rowNumber = index.row() + 1
row = self.PreviewListData.createIndex(rowNumber, 0)
if row.isValid():
self.PreviewListView.selectionModel().setCurrentIndex(row,
QtGui.QItemSelectionModel.SelectCurrent)
self.onSlideSelected(row)
def onSlideSelectedPrevious(self): def onSlideSelectedPrevious(self):
""" """
Go to the previous slide. Go to the previous slide.
""" """
indexes = self.PreviewListView.selectedIndexes() row = self.PreviewListWidget.currentRow() - 1
rowNumber = 0 if row == -1:
for index in indexes: row = self.PreviewListWidget.rowCount() - 1
if index.row() == 0: self.PreviewListWidget.selectRow(row)
rowNumber = self.PreviewListData.rowCount() - 1 self.onSlideSelected()
else:
rowNumber = index.row() - 1
row = self.PreviewListData.createIndex(rowNumber, 0)
if row.isValid():
self.PreviewListView.selectionModel().setCurrentIndex(row,
QtGui.QItemSelectionModel.SelectCurrent)
self.onSlideSelected(row)
def onSlideSelectedLast(self): def onSlideSelectedLast(self):
""" """
Go to the last slide. Go to the last slide.
""" """
row = self.PreviewListData.createIndex( self.PreviewListWidget.selectRow(self.PreviewListWidget.rowCount())
self.PreviewListData.rowCount() - 1, 0) self.onSlideSelected()
if row.isValid():
self.PreviewListView.selectionModel().setCurrentIndex(row,
QtGui.QItemSelectionModel.SelectCurrent)
self.onSlideSelected(row)
def onBlankScreen(self): def onBlankScreen(self):
""" """
@ -329,54 +230,56 @@ class BaseToolbar(object):
""" """
self.mainDisplay.blankDisplay() self.mainDisplay.blankDisplay()
def onSlideSelected(self, index): def onSlideSelected(self):
""" """
Generate the preview when you click on a slide. Generate the preview when you click on a slide.
if this is the Live Controller also display on the screen
""" """
frame = self.PreviewListData.getValue(index) row = self.PreviewListWidget.currentRow()
self.previewFrame(frame) if row > -1 and row < self.PreviewListWidget.rowCount():
label = self.PreviewListWidget.cellWidget(row, 0)
smallframe = label.pixmap()
frame = self.serviceitem.frames[row][u'image']
self.SlidePreview.setPixmap(smallframe)
if self.isLive:
self.mainDisplay.frameView(frame)
def previewFrame(self, frame): def addServiceItem(self, serviceitem, slideno= 1):
""" """
Generates a preview of the current slide. Loads a ServiceItem into the system from plugins
""" Display the first slide
self.SlidePreview.setPixmap(QtGui.QPixmap.fromImage(frame[0]))
if self.isLive:
no = frame[1]
LiveFrame = self.serviceitem.frames[no][u'image']
self.mainDisplay.frameView(LiveFrame)
def addServiceItem(self, serviceitem):
"""
Loads a ServiceItem.
""" """
log.debug(u'add Service Item') log.debug(u'add Service Item')
self.serviceitem = serviceitem serviceitem.render()
self.serviceitem.render() self.addServiceManagerItem(serviceitem, 0)
self.PreviewListData.clear()
framenumber = 0
for frame in self.serviceitem.frames:
self.PreviewListData.addRow(frame[u'image'], framenumber)
framenumber += 1
row = self.PreviewListData.createIndex(0, 0)
if row.isValid():
self.PreviewListView.selectionModel().setCurrentIndex(row,
QtGui.QItemSelectionModel.SelectCurrent)
self.onSlideSelected(row)
def addServiceManagerItem(self, serviceitem, slideno): def addServiceManagerItem(self, serviceitem, slideno):
""" """
Loads a ServiceManagerItem. Loads a ServiceItem into the system from ServiceManager
Display the Slide Passed
""" """
log.debug(u'add Service Manager Item') log.debug(u'add Service Manager Item')
self.PreviewListData.clear() self.PreviewListWidget.clear()
self.PreviewListWidget.setRowCount(0)
self.serviceitem = serviceitem self.serviceitem = serviceitem
framenumber = 0 framenumber = 0
for frame in self.serviceitem.frames: for frame in self.serviceitem.frames:
self.PreviewListData.addRow(frame[u'image'], framenumber) self.PreviewListWidget.setRowCount(self.PreviewListWidget.rowCount() + 1)
pixmap = QtGui.QPixmap.fromImage(frame[u'image'])
item = QtGui.QTableWidgetItem()
label = QtGui.QLabel()
label.setMargin(15)
label.setScaledContents(True)
width = 300
height = width * pixmap.height() / pixmap.width()
label.setPixmap(pixmap)
self.PreviewListWidget.setCellWidget(framenumber, 0,label)
self.PreviewListWidget.setItem( framenumber, 0, item)
self.PreviewListWidget.setRowHeight(framenumber, height)
self.PreviewListWidget.setColumnWidth(0, width)
framenumber += 1 framenumber += 1
row = self.PreviewListData.createIndex(slideno, 0) if slideno > self.PreviewListWidget.rowCount():
if row.isValid(): self.PreviewListWidget.selectRow(self.PreviewListWidget.rowCount())
self.PreviewListView.selectionModel().setCurrentIndex(row, else:
QtGui.QItemSelectionModel.SelectCurrent) self.PreviewListWidget.selectRow(slideno)
self.onSlideSelected(row) self.onSlideSelected()

View File

@ -177,7 +177,6 @@ class ThemeManager(QtGui.QWidget):
items = self.ThemeListView.selectedIndexes() items = self.ThemeListView.selectedIndexes()
if len(items) > 0: if len(items) > 0:
for item in items: for item in items:
print item
data = self.themeData.getValue(item) data = self.themeData.getValue(item)
self.amendThemeForm.loadTheme(data[3]) self.amendThemeForm.loadTheme(data[3])
self.amendThemeForm.exec_() self.amendThemeForm.exec_()
@ -222,7 +221,10 @@ class ThemeManager(QtGui.QWidget):
for root, dirs, files in os.walk(self.path): for root, dirs, files in os.walk(self.path):
for name in files: for name in files:
if name.endswith(u'.png'): if name.endswith(u'.png'):
self.themeData.addRow(os.path.join(self.path, name)) #check to see file is in route directory
theme = os.path.join(self.path, name)
if os.path.exists(theme):
self.themeData.addRow(theme)
self.parent.EventManager.post_event(Event(EventType.ThemeListChanged)) self.parent.EventManager.post_event(Event(EventType.ThemeListChanged))
self.parent.ServiceManagerContents.updateThemeList(self.getThemes()) self.parent.ServiceManagerContents.updateThemeList(self.getThemes())
self.parent.settingsForm.ThemesTab.updateThemeList(self.getThemes()) self.parent.settingsForm.ThemesTab.updateThemeList(self.getThemes())

View File

@ -29,7 +29,6 @@ class ImageToolbar(BaseToolbar):
def __init__(self, isLive): def __init__(self, isLive):
self.Toolbar = None self.Toolbar = None
self.PreviewListView = QtGui.QListWidget() self.PreviewListView = QtGui.QListWidget()
self.PreviewListData = None
self.isLive = isLive self.isLive = isLive
self.defineToolbar() self.defineToolbar()
@ -84,20 +83,10 @@ class ImageToolbar(BaseToolbar):
""" """
Go to the last slide. Go to the last slide.
""" """
row = self.PreviewListData.createIndex( pass
self.PreviewListData.rowCount() - 1, 0)
if row.isValid():
self.PreviewListView.selectionModel().setCurrentIndex(row,
QtGui.QItemSelectionModel.SelectCurrent)
self.onSlideSelected(row)
def onStopLoop(self): def onStopLoop(self):
""" """
Go to the last slide. Go to the last slide.
""" """
row = self.PreviewListData.createIndex( pass
self.PreviewListData.rowCount() - 1, 0)
if row.isValid():
self.PreviewListView.selectionModel().setCurrentIndex(row,
QtGui.QItemSelectionModel.SelectCurrent)
self.onSlideSelected(row)

View File

@ -55,7 +55,6 @@ class ImageMediaItem(MediaManagerItem):
self.ListViewWithDnD_class = ImageListView self.ListViewWithDnD_class = ImageListView
MediaManagerItem.__init__(self, parent, icon, title) MediaManagerItem.__init__(self, parent, icon, title)
#create and install our own slide controllers #create and install our own slide controllers
#a=c
# live_controller = ImageSlideController(self.parent.slideManager.parent, True) # live_controller = ImageSlideController(self.parent.slideManager.parent, True)
# preview_controller = ImageSlideController(self.parent.slideManager.parent) # preview_controller = ImageSlideController(self.parent.slideManager.parent)
# self.parent.slideManager.add_controllers(u'image', preview_controller, live_controller) # self.parent.slideManager.add_controllers(u'image', preview_controller, live_controller)

View File

@ -57,7 +57,7 @@ class Openoffice(object):
self.createApp() self.createApp()
def startOpenoffice(self): def startOpenoffice(self):
cmd = u'openoffice.org -nologo -norestore -minimized -impress' + u'"' + u'-accept=socket,host=localhost,port=2002;urp;'+ u'"' cmd = u'openoffice.org -nologo -norestore -invisible -minimized -impress' + u'"' + u'-accept=socket,host=localhost,port=2002;urp;'+ u'"'
retval = subprocess.Popen(cmd, shell=True) retval = subprocess.Popen(cmd, shell=True)
self.oopid = retval.pid self.oopid = retval.pid