End of Operation Cleanup for now

Fix more bugs 
Start to sort out Service Item
This commit is contained in:
Tim Bentley 2009-05-22 19:30:25 +01:00
parent 4c76ffdbaa
commit 8acc980ce4
13 changed files with 152 additions and 126 deletions

View File

@ -43,6 +43,19 @@ def buildIcon(icon):
QtGui.QIcon.Normal, QtGui.QIcon.Off)
return ButtonIcon
def contextMenuAction(base, icon, text, slot):
"""
Utility method to help build context menus for plugins
"""
action = QtGui.QAction(text, base)
action .setIcon(buildIcon(icon))
QtCore.QObject.connect(action, QtCore.SIGNAL("triggered()"), slot)
return action
def contextMenuSeparator(base):
action = QtGui.QAction("", base)
action.setSeparator(True)
return action
from pluginconfig import PluginConfig
from plugin import Plugin
@ -66,7 +79,7 @@ from rendermanager import RenderManager
# 'XmlRootClass', 'ServiceItem', 'Receiver', 'OpenLPToolbar', 'SongXMLBuilder',
# 'SongXMLParser', 'EventManager', 'ThemeXML', 'RenderManager']
__all__ = [ 'translate', 'file_to_xml', 'str_to_bool']
__all__ = [ 'translate', 'file_to_xml', 'str_to_bool', 'contextMenuAction', 'contextMenuSeparator']

View File

@ -120,7 +120,7 @@ class RenderManager:
def generate_preview(self, themedata):
log.debug(u'generate preview')
self.calculate_default(QtCore.QSize(800, 600))
self.calculate_default(QtCore.QSize(1024, 768))
self.renderer.set_theme(themedata)
self.build_text_rectangle(themedata)

View File

@ -42,6 +42,8 @@ class ServiceItem():
self.items = []
self.iconic_representation = None
self.raw_slides = None
self.frame_titles = []
self.command_files = []
self.frames = []
self.raw_footer = None
self.theme = None
@ -60,11 +62,14 @@ class ServiceItem():
else:
self.render_manager.set_override_theme(self.theme)
log.debug(u'Formatting slides')
if len(self.frames) == 0 :
if len(self.frames) == 0 and len(self.raw_slides) > 0 :
for slide in self.raw_slides:
formated = self.render_manager.format_slide(slide, False)
frame = self.render_manager.generate_slide(formated, self.raw_footer)
self.frames.append({u'formatted': formated, u'image': frame})
self.frames.append({u'title': formated, u'image': frame})
else:
if len(self.command_files) > 0:
pass
def get_parent_node(self):

View File

@ -29,116 +29,117 @@ class AboutForm(QtGui.QDialog):
self.setupUi(self)
def setupUi(self, AboutForm):
AboutForm.setObjectName("AboutForm")
AboutForm.setObjectName(u'AboutForm')
AboutForm.resize(470, 481)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/icon/openlp-logo-16x16.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon.addPixmap(QtGui.QPixmap(u':/icon/openlp-logo-16x16.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
AboutForm.setWindowIcon(icon)
AboutFormLayout = QtGui.QVBoxLayout(AboutForm)
AboutFormLayout.setSpacing(8)
AboutFormLayout.setMargin(8)
AboutFormLayout.setObjectName("AboutDialogLayout")
AboutFormLayout.setObjectName(u'AboutDialogLayout')
self.Logo = QtGui.QLabel(AboutForm)
self.Logo.setAutoFillBackground(False)
self.Logo.setStyleSheet("background-color: rgb(255, 255, 255);")
self.Logo.setStyleSheet(u'background-color: rgb(255, 255, 255);')
self.Logo.setFrameShape(QtGui.QFrame.StyledPanel)
self.Logo.setLineWidth(1)
self.Logo.setPixmap(QtGui.QPixmap(":/graphics/openlp-about-logo.png"))
self.Logo.setPixmap(QtGui.QPixmap(u':/graphics/openlp-about-logo.png'))
self.Logo.setScaledContents(False)
self.Logo.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter)
self.Logo.setObjectName("Logo")
self.Logo.setObjectName(u'Logo')
AboutFormLayout.addWidget(self.Logo)
self.AboutNotebook = QtGui.QTabWidget(AboutForm)
self.AboutNotebook.setObjectName("AboutNotebook")
self.AboutNotebook.setObjectName(u'AboutNotebook')
self.LicenseTab = QtGui.QWidget()
self.LicenseTab.setObjectName("LicenseTab")
self.LicenseTab.setObjectName(u'LicenseTab')
self.LicenseTabLayout = QtGui.QVBoxLayout(self.LicenseTab)
self.LicenseTabLayout.setSpacing(8)
self.LicenseTabLayout.setMargin(8)
self.LicenseTabLayout.setObjectName("LicenseTabLayout")
self.LicenseTabLayout.setObjectName(u'LicenseTabLayout')
self.CopyrightLabel = QtGui.QLabel(self.LicenseTab)
self.CopyrightLabel.setObjectName("CopyrightLabel")
self.CopyrightLabel.setObjectName(u'CopyrightLabel')
self.LicenseTabLayout.addWidget(self.CopyrightLabel)
self.AboutAuthors = QtGui.QLabel(self.LicenseTab)
self.AboutAuthors.setAlignment(QtCore.Qt.AlignJustify|QtCore.Qt.AlignVCenter)
self.AboutAuthors.setWordWrap(True)
self.AboutAuthors.setObjectName("AboutAuthors")
self.AboutAuthors.setObjectName(u'AboutAuthors')
self.LicenseTabLayout.addWidget(self.AboutAuthors)
self.License1Label = QtGui.QLabel(self.LicenseTab)
self.License1Label.setAlignment(QtCore.Qt.AlignJustify|QtCore.Qt.AlignVCenter)
self.License1Label.setWordWrap(True)
self.License1Label.setObjectName("License1Label")
self.License1Label.setObjectName(u'License1Label')
self.LicenseTabLayout.addWidget(self.License1Label)
self.License2Label = QtGui.QLabel(self.LicenseTab)
self.License2Label.setAlignment(QtCore.Qt.AlignJustify|QtCore.Qt.AlignVCenter)
self.License2Label.setWordWrap(True)
self.License2Label.setObjectName("License2Label")
self.License2Label.setObjectName(u'License2Label')
self.LicenseTabLayout.addWidget(self.License2Label)
self.License3Label = QtGui.QLabel(self.LicenseTab)
self.License3Label.setAlignment(QtCore.Qt.AlignJustify|QtCore.Qt.AlignVCenter)
self.License3Label.setWordWrap(True)
self.License3Label.setObjectName("License3Label")
self.License3Label.setObjectName(u'License3Label')
self.LicenseTabLayout.addWidget(self.License3Label)
self.AboutNotebook.addTab(self.LicenseTab, "License")
self.AboutNotebook.addTab(self.LicenseTab, u'License')
self.CreditsTab = QtGui.QWidget()
self.CreditsTab.setObjectName("CreditsTab")
self.CreditsTab.setObjectName(u'CreditsTab')
self.CreditsTabLayout = QtGui.QVBoxLayout(self.CreditsTab)
self.CreditsTabLayout.setSpacing(0) #
self.CreditsTabLayout.setMargin(8) #
self.CreditsTabLayout.setObjectName("CreditsTabLayout")
self.CreditsTabLayout.setObjectName(u'CreditsTabLayout')
self.CreditsTextEdit = QtGui.QTextEdit(self.CreditsTab)
self.CreditsTextEdit.setReadOnly(True)
self.CreditsTextEdit.setObjectName("CreditsTextEdit")
self.CreditsTextEdit.setObjectName(u'CreditsTextEdit')
self.CreditsTabLayout.addWidget(self.CreditsTextEdit)
self.AboutNotebook.addTab(self.CreditsTab, "Credits")
self.AboutNotebook.addTab(self.CreditsTab, u'Credits')
AboutFormLayout.addWidget(self.AboutNotebook)
self.ButtonWidget = QtGui.QWidget(AboutForm)
self.ButtonWidget.setObjectName("ButtonWidget")
self.ButtonWidget.setObjectName(u'ButtonWidget')
self.ButtonWidgetLayout = QtGui.QHBoxLayout(self.ButtonWidget)
self.ButtonWidgetLayout.setSpacing(8)
self.ButtonWidgetLayout.setMargin(0)
self.ButtonWidgetLayout.setObjectName("ButtonWidgetLayout")
self.ButtonWidgetLayout.setObjectName(u'ButtonWidgetLayout')
spacerItem = QtGui.QSpacerItem(275, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.ButtonWidgetLayout.addItem(spacerItem)
self.ContributeButton = QtGui.QPushButton(self.ButtonWidget)
self.ContributeButton.setObjectName("ContributeButton")
self.ContributeButton.setObjectName(u'ContributeButton')
self.ButtonWidgetLayout.addWidget(self.ContributeButton)
self.CloseButton = QtGui.QPushButton(self.ButtonWidget)
self.CloseButton.setObjectName("CloseButton")
self.CloseButton.setObjectName(u'CloseButton')
self.ButtonWidgetLayout.addWidget(self.CloseButton)
AboutFormLayout.addWidget(self.ButtonWidget)
self.extContributeItem = QtGui.QAction(AboutForm)
self.extContributeItem.setObjectName("extContributeItem")
self.extContributeItem.setObjectName(u'extContributeItem')
self.retranslateUi(AboutForm)
self.AboutNotebook.setCurrentIndex(0)
QtCore.QObject.connect(self.CloseButton, QtCore.SIGNAL("clicked()"), AboutForm.close)
QtCore.QObject.connect(self.CloseButton, QtCore.SIGNAL(u'clicked()'), AboutForm.close)
QtCore.QMetaObject.connectSlotsByName(AboutForm)
QtCore.QObject.connect(self.ContributeButton, QtCore.SIGNAL("clicked()"), self.onContributeButtonClicked)
QtCore.QObject.connect(self.ContributeButton, QtCore.SIGNAL(u'clicked()'), self.onContributeButtonClicked)
def retranslateUi(self, AboutForm):
AboutForm.setWindowTitle(translate("AboutDialog", "About openlp.org",))
self.CopyrightLabel.setText(translate("AboutDialog", "Copyright © 2004-2009 openlp.org Foundation"))
self.AboutAuthors.setText(translate("AboutDialog", "openlp.org is written and maintained by volunteers. If you would like to see more free Christian software being written, please consider contributing by using the button below."))
self.License1Label.setText(translate("AboutDialog", "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 Foundation; either version 2 of the License, or (at your option) any later version."))
self.License2Label.setText(translate("AboutDialog", "You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA."))
self.License3Label.setText(translate("AboutDialog", "This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details."))
self.AboutNotebook.setTabText(self.AboutNotebook.indexOf(self.LicenseTab), translate("AboutDialog", "License"))
self.CreditsTextEdit.setPlainText(translate("AboutDialog", "Project Lead\n"
" Raoul \"superfly\" Snyman\n"
"\n"
"Developers\n"
" Tim \"TRB143\" Bentley\n"
" Jonathan \"gushie\" Corwin\n"
" Scott \"sguerrieri\" Guerrieri\n"
" Raoul \"superfly\" Snyman\n"
" Martin \"mijiti\" Thompson\n"
" Carsten \"catini\" Tingaard"))
self.AboutNotebook.setTabText(self.AboutNotebook.indexOf(self.CreditsTab), translate("AboutDialog", "Credits"))
self.ContributeButton.setText(translate("AboutDialog", "Contribute"))
self.CloseButton.setText(translate("AboutDialog", "Close"))
self.extContributeItem.setText(translate("AboutDialog", "&Contribute"))
AboutForm.setWindowTitle(translate(u'AboutDialog', u'About openlp.org',))
self.CopyrightLabel.setText(translate(u'AboutDialog', u'Copyright © 2004-2009 openlp.org Foundation'))
self.AboutAuthors.setText(translate(u'AboutDialog', u'openlp.org is written and maintained by volunteers. If you would like to see more free Christian software being written, please consider contributing by using the button below.'))
self.License1Label.setText(translate(u'AboutDialog', u'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 Foundation; either version 2 of the License, or (at your option) any later version.'))
self.License2Label.setText(translate(u'AboutDialog', u'You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.'))
self.License3Label.setText(translate(u'AboutDialog', u'This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.'))
self.AboutNotebook.setTabText(self.AboutNotebook.indexOf(self.LicenseTab), translate(u'AboutDialog', u'License'))
self.CreditsTextEdit.setPlainText(translate(u'AboutDialog',
u'Project Lead\n'
u' Raoul \"superfly\" Snyman\n'
u'\n'
u'Developers\n'
u' Tim \"TRB143\" Bentley\n'
u' Jonathan \"gushie\" Corwin\n'
u' Scott \"sguerrieri\" Guerrieri\n'
u' Raoul \"superfly\" Snyman\n'
u' Martin \"mijiti\" Thompson\n'
u' Carsten \"catini\" Tingaard'))
self.AboutNotebook.setTabText(self.AboutNotebook.indexOf(self.CreditsTab), translate(u'AboutDialog', u'Credits'))
self.ContributeButton.setText(translate(u'AboutDialog', u'Contribute'))
self.CloseButton.setText(translate(u'AboutDialog', u'Close'))
self.extContributeItem.setText(translate(u'AboutDialog', u'&Contribute'))
def onContributeButtonClicked(self):
import webbrowser

View File

@ -456,7 +456,7 @@ class Ui_AmendThemeDialog(object):
self.ThemePreviewLayout.setSpacing(8)
self.ThemePreviewLayout.setMargin(8)
self.ThemePreviewLayout.setObjectName("ThemePreviewLayout")
spacerItem7 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
spacerItem7 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
self.ThemePreviewLayout.addItem(spacerItem7)
self.ThemePreview = QtGui.QLabel(self.PreviewGroupBox)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
@ -464,14 +464,14 @@ class Ui_AmendThemeDialog(object):
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.ThemePreview.sizePolicy().hasHeightForWidth())
self.ThemePreview.setSizePolicy(sizePolicy)
self.ThemePreview.setMinimumSize(QtCore.QSize(300, 225))
self.ThemePreview.setMaximumSize(QtCore.QSize(300, 225))
self.ThemePreview.setFrameShape(QtGui.QFrame.WinPanel)
self.ThemePreview.setFrameShadow(QtGui.QFrame.Sunken)
self.ThemePreview.setLineWidth(1)
self.ThemePreview.setScaledContents(True)
self.ThemePreview.setObjectName("ThemePreview")
self.ThemePreviewLayout.addWidget(self.ThemePreview)
spacerItem8 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
spacerItem8 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
self.ThemePreviewLayout.addItem(spacerItem8)
self.AmendThemeLayout.addWidget(self.PreviewGroupBox)
self.ThemeButtonBox = QtGui.QDialogButtonBox(AmendThemeDialog)

View File

@ -21,7 +21,7 @@ import os
import logging
from PyQt4 import QtCore, QtGui
from openlp.core.lib import PluginConfig, OpenLPToolbar, ServiceItem, RenderManager, Event, EventType, EventManager, translate, buildIcon
from openlp.core.lib import PluginConfig, OpenLPToolbar, ServiceItem, RenderManager, Event, EventType, EventManager, translate, buildIcon, contextMenuAction, contextMenuSeparator
class ServiceManager(QtGui.QWidget):
@ -32,12 +32,12 @@ class ServiceManager(QtGui.QWidget):
Also handles the UI tasks of moving things up and down etc.
"""
global log
log=logging.getLogger(u'ServiceManager')
log = logging.getLogger(u'ServiceManager')
def __init__(self, parent):
QtGui.QWidget.__init__(self)
self.parent=parent
self.serviceItems=[]
self.parent = parent
self.serviceItems = []
self.Layout = QtGui.QVBoxLayout(self)
self.Layout.setSpacing(0)
self.Layout.setMargin(0)
@ -51,15 +51,15 @@ class ServiceManager(QtGui.QWidget):
self.Toolbar.addToolbarButton(u'Move to bottom', u':/services/service_bottom.png',
translate(u'ServiceManager', u'Move to end'), self.onServiceEnd)
self.Toolbar.addSeparator()
self.Toolbar.addToolbarButton(u'New Service', u':/services/service_new.png',
translate(u'ServiceManager', u'Create a new Service'), self.onNewService)
self.Toolbar.addToolbarButton(u'Delete From Service', u':/services/service_delete.png',
translate(u'ServiceManager', u'Delete From Service'), self.onDeleteFromService)
self.Toolbar.addToolbarButton(u'New Service', u':/services/service_new.png',
translate(u'ServiceManager', u'Create a new Service'), self.onNewService)
self.Toolbar.addToolbarButton(u'Open Service', u':/services/service_open.png',
translate(u'ServiceManager', u'Load Existing'), self.onLoadService)
self.Toolbar.addSeparator()
self.Toolbar.addToolbarButton(u'Save Service', u':/services/service_save.png',
translate(u'ServiceManager', u'Save Service'), self.onSaveService)
self.Toolbar.addToolbarButton(u'Load Service', u':/services/service_open.png',
translate(u'ServiceManager', u'Load Existing'), self.onLoadService)
self.Toolbar.addSeparator()
self.ThemeComboBox = QtGui.QComboBox(self.Toolbar)
@ -81,14 +81,14 @@ class ServiceManager(QtGui.QWidget):
self.ServiceManagerList.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.ServiceManagerList.addAction(self.contextMenuAction(
self.ServiceManagerList.addAction(contextMenuAction(
self.ServiceManagerList, ':/system/system_preview.png',
translate(u'ServiceManager',u'&Preview Verse'), self.makePreview))
self.ServiceManagerList.addAction(self.contextMenuAction(
self.ServiceManagerList.addAction(contextMenuAction(
self.ServiceManagerList, ':/system/system_live.png',
translate(u'ServiceManager',u'&Show Live'), self.makeLive))
self.ServiceManagerList.addAction(self.contextMenuSeparator(self.ServiceManagerList))
self.ServiceManagerList.addAction(self.contextMenuAction(
self.ServiceManagerList.addAction(contextMenuSeparator(self.ServiceManagerList))
self.ServiceManagerList.addAction(contextMenuAction(
self.ServiceManagerList, ':/services/service_delete',
translate(u'ServiceManager',u'&Remove from Service'), self.onDeleteFromService))
@ -100,20 +100,6 @@ class ServiceManager(QtGui.QWidget):
self.config = PluginConfig(u'Main')
self.service_theme = self.config.get_config(u'theme service theme', u'')
def contextMenuAction(self, base, icon, text, slot):
"""
Utility method to help build context menus for plugins
"""
action = QtGui.QAction(text, base)
action .setIcon(buildIcon(icon))
QtCore.QObject.connect(action, QtCore.SIGNAL("triggered()"), slot)
return action
def contextMenuSeparator(self, base):
action = QtGui.QAction("", base)
action.setSeparator(True)
return action
def onServiceTop(self):
pass
@ -154,7 +140,7 @@ class ServiceManager(QtGui.QWidget):
count = 0
for frame in item.frames:
treewidgetitem1 = QtGui.QTreeWidgetItem(treewidgetitem)
text = frame[u'formatted'][0]
text = frame[u'title'][0]
treewidgetitem1.setText(0,text[:30])
treewidgetitem1.setData(0, QtCore.Qt.UserRole,QtCore.QVariant(count))
count = count + 1
@ -193,7 +179,7 @@ class ServiceManager(QtGui.QWidget):
Handle the release of the event and trigger the plugin
to add the data
"""
link=event.mimeData()
link = event.mimeData()
if link.hasText():
plugin = event.mimeData().text()
self.EventManager.post_event(Event(EventType.LoadServiceItem, plugin))
@ -227,8 +213,9 @@ class ServiceManager(QtGui.QWidget):
for theme in theme_list:
self.ThemeComboBox.addItem(theme)
id = self.ThemeComboBox.findText(str(self.service_theme), QtCore.Qt.MatchExactly)
# Not Found
if id == -1:
id = 0 # Not Found
id = 0
self.service_theme = u''
self.ThemeComboBox.setCurrentIndex(id)
self.RenderManager.set_service_theme(self.service_theme)

View File

@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
"""
from PyQt4 import QtCore, QtGui
import logging
from PyQt4 import QtCore, QtGui
from openlp.core.lib import ServiceItem
from listwithpreviews import ListWithPreviews

View File

@ -1,51 +1,74 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
"""
OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman
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
Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
"""
import os
import logging
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class ListWithPreviews(QAbstractListModel):
from PyQt4 import QtCore, QtGui
class ListWithPreviews(QtCore.QAbstractListModel):
"""
An abstract list of strings and the preview icon to go with them
"""
global log
log=logging.getLogger("ListWithPreviews")
log = logging.getLogger("ListWithPreviews")
log.info("started")
def __init__(self):
QAbstractListModel.__init__(self)
self.items=[] # will be a list of (full filename, QPixmap, shortname) tuples
self.rowheight=50
self.maximagewidth=self.rowheight*16/9.0;
QtCore.QAbstractListModel.__init__(self)
self.items = [] # will be a list of (full filename, QPixmap, shortname) tuples
self.rowheight = 50
self.maximagewidth = self.rowheight*16/9.0;
def rowCount(self, parent):
return len(self.items)
def insertRow(self, row, filename):
self.beginInsertRows(QModelIndex(),row,row)
log.info("insert row %d:%s"%(row,filename))
self.beginInsertRows(QtCore.QModelIndex(),row,row)
log.info("insert row %d:%s"% (row,filename))
# get short filename to display next to image
(prefix, shortfilename) = os.path.split(str(filename))
log.info("shortfilename=%s"%(shortfilename))
log.info("shortfilename=%s"% (shortfilename))
# create a preview image
if os.path.exists(filename):
preview = QPixmap(str(filename))
w=self.maximagewidth;h=self.rowheight
preview = preview.scaled(w,h, Qt.KeepAspectRatio, Qt.SmoothTransformation)
realw=preview.width(); realh=preview.height()
preview = QtGui.QPixmap(str(filename))
w = self.maximagewidth;
h = self.rowheight
preview = preview.scaled(w, h, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)
realw = preview.width();
realh = preview.height()
# and move it to the centre of the preview space
p=QPixmap(w,h)
p.fill(Qt.transparent)
painter=QPainter(p)
p = QtGui.QPixmap(w,h)
p.fill(QtCore.Qt.transparent)
painter = QtGui.QPainter(p)
painter.drawPixmap((w-realw)/2,(h-realh)/2,preview)
else:
w=self.maximagewidth;h=self.rowheight
p=QPixmap(w,h)
p.fill(Qt.transparent)
w = self.maximagewidth;
h = self.rowheight
p = QtGui.QPixmap(w,h)
p.fill(QtCore.Qt.transparent)
# finally create the row
self.items.insert(row, (filename, p, shortfilename))
self.endInsertRows()
def removeRow(self, row):
self.beginRemoveRows(QModelIndex(), row,row)
self.beginRemoveRows(QtCore.QModelIndex(), row, row)
self.items.pop(row)
self.endRemoveRows()
@ -53,19 +76,19 @@ class ListWithPreviews(QAbstractListModel):
self.insertRow(len(self.items), filename)
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 QVariant()
if role==Qt.DisplayRole:
retval= self.items[row][2]
elif role == Qt.DecorationRole:
retval= self.items[row][1]
elif role == Qt.ToolTipRole:
retval= self.items[row][0]
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.DisplayRole:
retval = self.items[row][2]
elif role == QtCore.Qt.DecorationRole:
retval = self.items[row][1]
elif role == QtCore.Qt.ToolTipRole:
retval = self.items[row][0]
else:
retval= QVariant()
# log.info("Returning"+ str(retval))
if type(retval) is not type(QVariant):
retval = QtCore.QVariant()
if type(retval) is not type(QtCore.QVariant):
return QVariant(retval)
else:
return retval

View File

@ -153,7 +153,7 @@ class ImageMediaItem(MediaManagerItem):
for index in indexes:
filename = self.ImageListData.getFilename(index)
frame = QtGui.QPixmap(str(filename))
service_item.frames.append({u'formatted': u'Image', u'image': frame})
service_item.frames.append({u'title': filename , u'image': frame})
def onImagePreviewClick(self):
log.debug(u'Image Preview Requested')

View File

@ -32,7 +32,7 @@ class MediaMediaItem(MediaManagerItem):
This is the custom media manager item for Media Slides.
"""
global log
log=logging.getLogger(u'MediaMediaItem')
log = logging.getLogger(u'MediaMediaItem')
log.info(u'Media Media Item loaded')
def __init__(self, parent, icon, title):

View File

@ -21,9 +21,7 @@ import logging
import os
from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, translate
from openlp.plugins.presentations.lib import FileListData
class PresentationMediaItem(MediaManagerItem):

View File

@ -30,7 +30,7 @@ class SongMediaItem(MediaManagerItem):
This is the custom media manager item for Songs.
"""
global log
log=logging.getLogger("SongMediaItem")
log = logging.getLogger("SongMediaItem")
log.info("Song Media Item loaded")
def __init__(self, parent, icon, title):

View File

@ -21,7 +21,6 @@ import logging
from PyQt4 import QtCore, QtGui
from openlp.core.resources import *
from openlp.core.lib import Plugin, Event
from openlp.core.lib import EventType
from openlp.plugins.songs.lib import SongManager, SongsTab, SongMediaItem
@ -31,7 +30,7 @@ from openlp.plugins.songs.forms import OpenLPImportForm, OpenSongExportForm, \
class SongsPlugin(Plugin):
global log
log=logging.getLogger(u'SongsPlugin')
log = logging.getLogger(u'SongsPlugin')
log.info(u'Song Plugin loaded')
def __init__(self, plugin_helpers):
@ -124,7 +123,7 @@ class SongsPlugin(Plugin):
"""
Handle the event contained in the event object.
"""
log.debug(u'Handle event called with event %s'%event.event_type)
log.debug(u'Handle event called with event %s' % event.event_type)
if event.event_type == EventType.ThemeListChanged:
log.debug(u'New Theme request received')
#self.edit_custom_form.loadThemes(self.theme_manager.getThemes())