This commit is contained in:
Andreas Preikschat 2010-10-28 14:01:37 +02:00
commit b21572782b
14 changed files with 98 additions and 48 deletions

View File

@ -81,9 +81,6 @@ html_expands.append({u'desc':u'Italics', u'start tag':u'{it}',
u'start html':u'<em>', u'end tag':u'{/it}', u'end html':u'</em>', u'start html':u'<em>', u'end tag':u'{/it}', u'end html':u'</em>',
u'protected':True}) u'protected':True})
# Image image_cache to stop regualar image resizing
image_cache = {}
def translate(context, text, comment=None): def translate(context, text, comment=None):
""" """
A special shortcut method to wrap around the Qt4 translation functions. A special shortcut method to wrap around the Qt4 translation functions.
@ -261,20 +258,14 @@ def resize_image(image, width, height, background=QtCore.Qt.black):
return preview return preview
preview = preview.scaled(width, height, QtCore.Qt.KeepAspectRatio, preview = preview.scaled(width, height, QtCore.Qt.KeepAspectRatio,
QtCore.Qt.SmoothTransformation) QtCore.Qt.SmoothTransformation)
image_cache_key = u'%s%s%s' % (image, unicode(width), unicode(height))
if image_cache_key in image_cache:
log.debug(u'resize_image - end cache')
return image_cache[image_cache_key]
realw = preview.width() realw = preview.width()
realh = preview.height() realh = preview.height()
# and move it to the centre of the preview space # and move it to the centre of the preview space
new_image = QtGui.QImage(width, height, new_image = QtGui.QImage(width, height,
QtGui.QImage.Format_ARGB32_Premultiplied) QtGui.QImage.Format_ARGB32_Premultiplied)
new_image.fill(background)
painter = QtGui.QPainter(new_image) painter = QtGui.QPainter(new_image)
painter.fillRect(new_image.rect(), background)
painter.drawImage((width - realw) / 2, (height - realh) / 2, preview) painter.drawImage((width - realw) / 2, (height - realh) / 2, preview)
image_cache[image_cache_key] = new_image
log.debug(u'resize_image - end')
return new_image return new_image
def check_item_selected(list_widget, message): def check_item_selected(list_widget, message):

View File

@ -246,3 +246,10 @@ class Manager(object):
self.session.rollback() self.session.rollback()
log.exception(u'Failed to delete %s records', object_class.__name__) log.exception(u'Failed to delete %s records', object_class.__name__)
return False return False
def finalise(self):
"""
VACUUM the database on exit.
"""
engine = create_engine(self.db_url)
engine.execute("vacuum")

View File

@ -781,7 +781,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
QtGui.QMessageBox.Save), QtGui.QMessageBox.Save),
QtGui.QMessageBox.Save) QtGui.QMessageBox.Save)
if ret == QtGui.QMessageBox.Save: if ret == QtGui.QMessageBox.Save:
self.ServiceManagerContents.onSaveService() self.ServiceManagerContents.onSaveService(True)
self.cleanUp() self.cleanUp()
event.accept() event.accept()
elif ret == QtGui.QMessageBox.Discard: elif ret == QtGui.QMessageBox.Discard:

View File

@ -650,9 +650,12 @@ class ServiceManager(QtGui.QWidget):
.get_service_repr()}) .get_service_repr()})
if item[u'service_item'].uses_file(): if item[u'service_item'].uses_file():
for frame in item[u'service_item'].get_frames(): for frame in item[u'service_item'].get_frames():
path_from = unicode(os.path.join( if item[u'service_item'].is_image():
frame[u'path'], path_from = frame[u'path']
frame[u'title'])) else:
path_from = unicode(os.path.join(
frame[u'path'],
frame[u'title']))
# On write a file once # On write a file once
if not path_from in write_list: if not path_from in write_list:
write_list.append(path_from) write_list.append(path_from)

View File

@ -117,3 +117,11 @@ class AlertsPlugin(Plugin):
self.textStrings[StringContent.VisibleName] = { self.textStrings[StringContent.VisibleName] = {
u'title': translate('AlertsPlugin', 'Alerts') u'title': translate('AlertsPlugin', 'Alerts')
} }
def finalise(self):
"""
Time to tidy up on exit
"""
log.info(u'Alerts Finalising')
self.manager.finalise()
Plugin.finalise(self)

View File

@ -133,42 +133,50 @@ class BiblePlugin(Plugin):
## Import Button ## ## Import Button ##
self.textStrings[StringContent.Import] = { self.textStrings[StringContent.Import] = {
u'title': translate('BiblesPlugin', 'Import'), u'title': translate('BiblesPlugin', 'Import'),
u'tooltip': translate('BiblesPlugin', u'tooltip': translate('BiblesPlugin',
'Import a Bible') 'Import a Bible')
} }
## New Button ## ## New Button ##
self.textStrings[StringContent.New] = { self.textStrings[StringContent.New] = {
u'title': translate('BiblesPlugin', 'Add'), u'title': translate('BiblesPlugin', 'Add'),
u'tooltip': translate('BiblesPlugin', u'tooltip': translate('BiblesPlugin',
'Add a new Bible') 'Add a new Bible')
} }
## Edit Button ## ## Edit Button ##
self.textStrings[StringContent.Edit] = { self.textStrings[StringContent.Edit] = {
u'title': translate('BiblesPlugin', 'Edit'), u'title': translate('BiblesPlugin', 'Edit'),
u'tooltip': translate('BiblesPlugin', u'tooltip': translate('BiblesPlugin',
'Edit the selected Bible') 'Edit the selected Bible')
} }
## Delete Button ## ## Delete Button ##
self.textStrings[StringContent.Delete] = { self.textStrings[StringContent.Delete] = {
u'title': translate('BiblesPlugin', 'Delete'), u'title': translate('BiblesPlugin', 'Delete'),
u'tooltip': translate('BiblesPlugin', u'tooltip': translate('BiblesPlugin',
'Delete the selected Bible') 'Delete the selected Bible')
} }
## Preview ## ## Preview ##
self.textStrings[StringContent.Preview] = { self.textStrings[StringContent.Preview] = {
u'title': translate('BiblesPlugin', 'Preview'), u'title': translate('BiblesPlugin', 'Preview'),
u'tooltip': translate('BiblesPlugin', u'tooltip': translate('BiblesPlugin',
'Preview the selected Bible') 'Preview the selected Bible')
} }
## Live Button ## ## Live Button ##
self.textStrings[StringContent.Live] = { self.textStrings[StringContent.Live] = {
u'title': translate('BiblesPlugin', 'Live'), u'title': translate('BiblesPlugin', 'Live'),
u'tooltip': translate('BiblesPlugin', u'tooltip': translate('BiblesPlugin',
'Send the selected Bible live') 'Send the selected Bible live')
} }
## Add to service Button ## ## Add to service Button ##
self.textStrings[StringContent.Service] = { self.textStrings[StringContent.Service] = {
u'title': translate('BiblesPlugin', 'Service'), u'title': translate('BiblesPlugin', 'Service'),
u'tooltip': translate('BiblesPlugin', u'tooltip': translate('BiblesPlugin',
'Add the selected Bible to the service') 'Add the selected Bible to the service')
} }
def finalise(self):
"""
Time to tidy up on exit
"""
log.info(u'Bible Finalising')
self.manager.finalise()
Plugin.finalise(self)

View File

@ -36,7 +36,7 @@ from BeautifulSoup import BeautifulSoup, NavigableString
from openlp.core.lib import Receiver from openlp.core.lib import Receiver
from openlp.core.utils import AppLocation from openlp.core.utils import AppLocation
from openlp.plugins.bibles.lib import SearchResults from openlp.plugins.bibles.lib import SearchResults
from openlp.plugins.bibles.lib.db import BibleDB, Book from openlp.plugins.bibles.lib.db import BibleDB, Book
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View File

@ -310,3 +310,11 @@ class BibleManager(object):
if bible == name: if bible == name:
return True return True
return False return False
def finalise(self):
"""
Loop through the databases to VACUUM them.
"""
for bible in self.db_cache:
self.db_cache[bible].finalise()

View File

@ -49,8 +49,8 @@ class CustomPlugin(Plugin):
def __init__(self, plugin_helpers): def __init__(self, plugin_helpers):
Plugin.__init__(self, u'Custom', u'1.9.3', plugin_helpers) Plugin.__init__(self, u'Custom', u'1.9.3', plugin_helpers)
self.weight = -5 self.weight = -5
self.custommanager = Manager(u'custom', init_schema) self.manager = Manager(u'custom', init_schema)
self.edit_custom_form = EditCustomForm(self.custommanager) self.edit_custom_form = EditCustomForm(self.manager)
self.icon_path = u':/plugins/plugin_custom.png' self.icon_path = u':/plugins/plugin_custom.png'
self.icon = build_icon(self.icon_path) self.icon = build_icon(self.icon_path)
@ -115,48 +115,56 @@ class CustomPlugin(Plugin):
## Import Button ## ## Import Button ##
self.textStrings[StringContent.Import] = { self.textStrings[StringContent.Import] = {
u'title': translate('CustomsPlugin', 'Import'), u'title': translate('CustomsPlugin', 'Import'),
u'tooltip': translate('CustomsPlugin', u'tooltip': translate('CustomsPlugin',
'Import a Custom') 'Import a Custom')
} }
## Load Button ## ## Load Button ##
self.textStrings[StringContent.Load] = { self.textStrings[StringContent.Load] = {
u'title': translate('CustomsPlugin', 'Load'), u'title': translate('CustomsPlugin', 'Load'),
u'tooltip': translate('CustomsPlugin', u'tooltip': translate('CustomsPlugin',
'Load a new Custom') 'Load a new Custom')
} }
## New Button ## ## New Button ##
self.textStrings[StringContent.New] = { self.textStrings[StringContent.New] = {
u'title': translate('CustomsPlugin', 'Add'), u'title': translate('CustomsPlugin', 'Add'),
u'tooltip': translate('CustomsPlugin', u'tooltip': translate('CustomsPlugin',
'Add a new Custom') 'Add a new Custom')
} }
## Edit Button ## ## Edit Button ##
self.textStrings[StringContent.Edit] = { self.textStrings[StringContent.Edit] = {
u'title': translate('CustomsPlugin', 'Edit'), u'title': translate('CustomsPlugin', 'Edit'),
u'tooltip': translate('CustomsPlugin', u'tooltip': translate('CustomsPlugin',
'Edit the selected Custom') 'Edit the selected Custom')
} }
## Delete Button ## ## Delete Button ##
self.textStrings[StringContent.Delete] = { self.textStrings[StringContent.Delete] = {
u'title': translate('CustomsPlugin', 'Delete'), u'title': translate('CustomsPlugin', 'Delete'),
u'tooltip': translate('CustomsPlugin', u'tooltip': translate('CustomsPlugin',
'Delete the selected Custom') 'Delete the selected Custom')
} }
## Preview ## ## Preview ##
self.textStrings[StringContent.Preview] = { self.textStrings[StringContent.Preview] = {
u'title': translate('CustomsPlugin', 'Preview'), u'title': translate('CustomsPlugin', 'Preview'),
u'tooltip': translate('CustomsPlugin', u'tooltip': translate('CustomsPlugin',
'Preview the selected Custom') 'Preview the selected Custom')
} }
## Live Button ## ## Live Button ##
self.textStrings[StringContent.Live] = { self.textStrings[StringContent.Live] = {
u'title': translate('CustomsPlugin', 'Live'), u'title': translate('CustomsPlugin', 'Live'),
u'tooltip': translate('CustomsPlugin', u'tooltip': translate('CustomsPlugin',
'Send the selected Custom live') 'Send the selected Custom live')
} }
## Add to service Button ## ## Add to service Button ##
self.textStrings[StringContent.Service] = { self.textStrings[StringContent.Service] = {
u'title': translate('CustomsPlugin', 'Service'), u'title': translate('CustomsPlugin', 'Service'),
u'tooltip': translate('CustomsPlugin', u'tooltip': translate('CustomsPlugin',
'Add the selected Custom to the service') 'Add the selected Custom to the service')
} }
def finalise(self):
"""
Time to tidy up on exit
"""
log.info(u'Custom Finalising')
self.manager.finalise()
Plugin.finalise(self)

View File

@ -41,7 +41,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
Class documentation goes here. Class documentation goes here.
""" """
log.info(u'Custom Editor loaded') log.info(u'Custom Editor loaded')
def __init__(self, custommanager, parent=None): def __init__(self, manager, parent=None):
""" """
Constructor Constructor
""" """
@ -74,7 +74,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'theme_update_list'), self.loadThemes) QtCore.SIGNAL(u'theme_update_list'), self.loadThemes)
# Create other objects and forms. # Create other objects and forms.
self.custommanager = custommanager self.manager = manager
self.editSlideForm = EditCustomSlideForm(self) self.editSlideForm = EditCustomSlideForm(self)
self.initialise() self.initialise()
@ -115,7 +115,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
self.customSlide = CustomSlide() self.customSlide = CustomSlide()
self.initialise() self.initialise()
if id != 0: if id != 0:
self.customSlide = self.custommanager.get_object(CustomSlide, id) self.customSlide = self.manager.get_object(CustomSlide, id)
self.titleEdit.setText(self.customSlide.title) self.titleEdit.setText(self.customSlide.title)
self.creditEdit.setText(self.customSlide.credits) self.creditEdit.setText(self.customSlide.credits)
customXML = CustomXMLParser(self.customSlide.text) customXML = CustomXMLParser(self.customSlide.text)
@ -168,7 +168,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
u'utf-8') u'utf-8')
self.customSlide.theme_name = unicode(self.themeComboBox.currentText(), self.customSlide.theme_name = unicode(self.themeComboBox.currentText(),
u'utf-8') u'utf-8')
return self.custommanager.save_object(self.customSlide) return self.manager.save_object(self.customSlide)
def onUpButtonPressed(self): def onUpButtonPressed(self):
selectedRow = self.slideListView.currentRow() selectedRow = self.slideListView.currentRow()

View File

@ -56,6 +56,7 @@ class CustomMediaItem(MediaManagerItem):
# Holds information about whether the edit is remotly triggered and # Holds information about whether the edit is remotly triggered and
# which Custom is required. # which Custom is required.
self.remoteCustom = -1 self.remoteCustom = -1
self.manager = parent.manager
def addEndHeaderBar(self): def addEndHeaderBar(self):
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
@ -71,7 +72,7 @@ class CustomMediaItem(MediaManagerItem):
MediaManagerItem.requiredIcons(self) MediaManagerItem.requiredIcons(self)
def initialise(self): def initialise(self):
self.loadCustomListView(self.parent.custommanager.get_all_objects( self.loadCustomListView(self.manager.get_all_objects(
CustomSlide, order_by_ref=CustomSlide.title)) CustomSlide, order_by_ref=CustomSlide.title))
#Called to redisplay the song list screen edith from a search #Called to redisplay the song list screen edith from a search
#or from the exit of the Song edit dialog. If remote editing is active #or from the exit of the Song edit dialog. If remote editing is active
@ -106,7 +107,7 @@ class CustomMediaItem(MediaManagerItem):
type of display is required. type of display is required.
""" """
fields = customid.split(u':') fields = customid.split(u':')
valid = self.parent.custommanager.get_object(CustomSlide, fields[1]) valid = self.manager.get_object(CustomSlide, fields[1])
if valid: if valid:
self.remoteCustom = fields[1] self.remoteCustom = fields[1]
self.remoteTriggered = fields[0] self.remoteTriggered = fields[0]

View File

@ -166,36 +166,44 @@ class SongsPlugin(Plugin):
## New Button ## ## New Button ##
self.textStrings[StringContent.New] = { self.textStrings[StringContent.New] = {
u'title': translate('SongsPlugin', 'Add'), u'title': translate('SongsPlugin', 'Add'),
u'tooltip': translate('SongsPlugin', u'tooltip': translate('SongsPlugin',
'Add a new Song') 'Add a new Song')
} }
## Edit Button ## ## Edit Button ##
self.textStrings[StringContent.Edit] = { self.textStrings[StringContent.Edit] = {
u'title': translate('SongsPlugin', 'Edit'), u'title': translate('SongsPlugin', 'Edit'),
u'tooltip': translate('SongsPlugin', u'tooltip': translate('SongsPlugin',
'Edit the selected Song') 'Edit the selected Song')
} }
## Delete Button ## ## Delete Button ##
self.textStrings[StringContent.Delete] = { self.textStrings[StringContent.Delete] = {
u'title': translate('SongsPlugin', 'Delete'), u'title': translate('SongsPlugin', 'Delete'),
u'tooltip': translate('SongsPlugin', u'tooltip': translate('SongsPlugin',
'Delete the selected Song') 'Delete the selected Song')
} }
## Preview ## ## Preview ##
self.textStrings[StringContent.Preview] = { self.textStrings[StringContent.Preview] = {
u'title': translate('SongsPlugin', 'Preview'), u'title': translate('SongsPlugin', 'Preview'),
u'tooltip': translate('SongsPlugin', u'tooltip': translate('SongsPlugin',
'Preview the selected Song') 'Preview the selected Song')
} }
## Live Button ## ## Live Button ##
self.textStrings[StringContent.Live] = { self.textStrings[StringContent.Live] = {
u'title': translate('SongsPlugin', 'Live'), u'title': translate('SongsPlugin', 'Live'),
u'tooltip': translate('SongsPlugin', u'tooltip': translate('SongsPlugin',
'Send the selected Song live') 'Send the selected Song live')
} }
## Add to service Button ## ## Add to service Button ##
self.textStrings[StringContent.Service] = { self.textStrings[StringContent.Service] = {
u'title': translate('SongsPlugin', 'Service'), u'title': translate('SongsPlugin', 'Service'),
u'tooltip': translate('SongsPlugin', u'tooltip': translate('SongsPlugin',
'Add the selected Song to the service') 'Add the selected Song to the service')
} }
def finalise(self):
"""
Time to tidy up on exit
"""
log.info(u'Songs Finalising')
self.manager.finalise()
Plugin.finalise(self)

View File

@ -175,4 +175,12 @@ class SongUsagePlugin(Plugin):
## Name for MediaDockManager, SettingsManager ## ## Name for MediaDockManager, SettingsManager ##
self.textStrings[StringContent.VisibleName] = { self.textStrings[StringContent.VisibleName] = {
u'title': translate('SongUsagePlugin', 'SongUsage') u'title': translate('SongUsagePlugin', 'SongUsage')
} }
def finalise(self):
"""
Time to tidy up on exit
"""
log.info(u'SongUsage Finalising')
self.manager.finalise()
Plugin.finalise(self)