From c8e5f9c07e483d227f3662d6a3457ac97faa755d Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 24 Oct 2010 13:00:20 +0200 Subject: [PATCH 01/16] fixed traceback after editing image item, icons for down/up buttons --- openlp/core/ui/serviceitemeditdialog.py | 26 ++++++++++++++++-------- openlp/core/ui/servicemanager.py | 2 +- resources/forms/serviceitemeditdialog.ui | 22 ++++++++++++++------ 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/openlp/core/ui/serviceitemeditdialog.py b/openlp/core/ui/serviceitemeditdialog.py index 383f34f72..222808ddf 100644 --- a/openlp/core/ui/serviceitemeditdialog.py +++ b/openlp/core/ui/serviceitemeditdialog.py @@ -25,6 +25,7 @@ ############################################################################### from PyQt4 import QtCore, QtGui + from openlp.core.lib import translate class Ui_ServiceItemEditDialog(object): @@ -44,16 +45,26 @@ class Ui_ServiceItemEditDialog(object): self.topLayout.addWidget(self.listWidget) self.buttonLayout = QtGui.QVBoxLayout() self.buttonLayout.setObjectName(u'buttonLayout') - self.upButton = QtGui.QPushButton(self.layoutWidget) - self.upButton.setObjectName(u'upButton') - self.buttonLayout.addWidget(self.upButton) - spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, - QtGui.QSizePolicy.Expanding) - self.buttonLayout.addItem(spacerItem) self.deleteButton = QtGui.QPushButton(self.layoutWidget) self.deleteButton.setObjectName(u'deleteButton') self.buttonLayout.addWidget(self.deleteButton) + spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, + QtGui.QSizePolicy.Expanding) + self.buttonLayout.addItem(spacerItem) + self.upButton = QtGui.QPushButton(self.layoutWidget) + self.upButton.setText(u'') + icon = QtGui.QIcon() + icon.addPixmap(QtGui.QPixmap(u':/services/service_up.png'), + QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.upButton.setIcon(icon) + self.upButton.setObjectName(u'upButton') + self.buttonLayout.addWidget(self.upButton) self.downButton = QtGui.QPushButton(self.layoutWidget) + self.downButton.setText(u'') + icon = QtGui.QIcon() + icon.addPixmap(QtGui.QPixmap(u':/services/service_down.png'), + QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.downButton.setIcon(icon) self.downButton.setObjectName(u'downButton') self.buttonLayout.addWidget(self.downButton) self.topLayout.addLayout(self.buttonLayout) @@ -63,14 +74,11 @@ class Ui_ServiceItemEditDialog(object): QtGui.QDialogButtonBox.Save) self.buttonBox.setObjectName(u'buttonBox') self.outerLayout.addWidget(self.buttonBox) - self.retranslateUi(serviceItemEditDialog) QtCore.QMetaObject.connectSlotsByName(serviceItemEditDialog) def retranslateUi(self, serviceItemEditDialog): serviceItemEditDialog.setWindowTitle( translate('OpenLP.ServiceItemEditForm', 'Reorder Service Item')) - self.upButton.setText(translate('OpenLP.ServiceItemEditForm', 'Up')) self.deleteButton.setText(translate('OpenLP.ServiceItemEditForm', 'Delete')) - self.downButton.setText(translate('OpenLP.ServiceItemEditForm', 'Down')) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index b1140eb49..2bf6394cd 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -346,7 +346,7 @@ class ServiceManager(QtGui.QWidget): self.serviceItems[item][u'service_item']) if self.serviceItemEditForm.exec_(): self.addServiceItem(self.serviceItemEditForm.getServiceItem(), - replace=True, expand=self.serviceItems[item][u'expand']) + replace=True, expand=self.serviceItems[item][u'expanded']) def nextItem(self): """ diff --git a/resources/forms/serviceitemeditdialog.ui b/resources/forms/serviceitemeditdialog.ui index 24c86b966..c5e73ce04 100644 --- a/resources/forms/serviceitemeditdialog.ui +++ b/resources/forms/serviceitemeditdialog.ui @@ -35,9 +35,9 @@ - + - Up + Delete @@ -55,16 +55,24 @@ - + - Delete + + + + + :/services/service_up.png:/services/service_up.png - Down + + + + + :/services/service_down.png:/services/service_down.png @@ -82,6 +90,8 @@ - + + + From 8d82715924dae1948f58aa742b5a092b342b5937 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 24 Oct 2010 13:08:46 +0200 Subject: [PATCH 02/16] added empty lines --- openlp/core/ui/serviceitemeditdialog.py | 1 + openlp/plugins/custom/forms/editcustomdialog.py | 1 + 2 files changed, 2 insertions(+) diff --git a/openlp/core/ui/serviceitemeditdialog.py b/openlp/core/ui/serviceitemeditdialog.py index 222808ddf..215cc6146 100644 --- a/openlp/core/ui/serviceitemeditdialog.py +++ b/openlp/core/ui/serviceitemeditdialog.py @@ -74,6 +74,7 @@ class Ui_ServiceItemEditDialog(object): QtGui.QDialogButtonBox.Save) self.buttonBox.setObjectName(u'buttonBox') self.outerLayout.addWidget(self.buttonBox) + self.retranslateUi(serviceItemEditDialog) QtCore.QMetaObject.connectSlotsByName(serviceItemEditDialog) diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index 89cd0b6df..1b16c6236 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -110,6 +110,7 @@ class Ui_CustomEditDialog(object): self.titleEdit.setObjectName(u'titleEdit') self.horizontalLayout.addWidget(self.titleEdit) self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1) + self.retranslateUi(customEditDialog) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'), customEditDialog.accept) From f67e25c82e0cbbfd646f92656e473aea09376adc Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 26 Oct 2010 20:07:12 +0100 Subject: [PATCH 03/16] Fix Image size backgounds --- openlp/core/lib/__init__.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 402b53798..d5ccb2c93 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -81,9 +81,6 @@ html_expands.append({u'desc':u'Italics', u'start tag':u'{it}', u'start html':u'', u'end tag':u'{/it}', u'end html':u'', u'protected':True}) -# Image image_cache to stop regualar image resizing -image_cache = {} - def translate(context, text, comment=None): """ 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 preview = preview.scaled(width, height, QtCore.Qt.KeepAspectRatio, 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() realh = preview.height() # and move it to the centre of the preview space new_image = QtGui.QImage(width, height, 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) - image_cache[image_cache_key] = new_image - log.debug(u'resize_image - end') return new_image def check_item_selected(list_widget, message): From d3e4cf7a2ddf6721421dd28e0e46598a3cbecd61 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 26 Oct 2010 20:11:26 +0100 Subject: [PATCH 04/16] Remove # --- openlp/core/lib/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index d5ccb2c93..1ad17a039 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -263,7 +263,7 @@ def resize_image(image, width, height, background=QtCore.Qt.black): # and move it to the centre of the preview space new_image = QtGui.QImage(width, height, QtGui.QImage.Format_ARGB32_Premultiplied) - 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) return new_image From 7285490fcbefdc0a370c25ffee1406550a65a1c6 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 26 Oct 2010 20:25:31 +0100 Subject: [PATCH 05/16] Fix Image saving bug --- openlp/core/ui/servicemanager.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 2bf6394cd..629013cc5 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -650,9 +650,12 @@ class ServiceManager(QtGui.QWidget): .get_service_repr()}) if item[u'service_item'].uses_file(): for frame in item[u'service_item'].get_frames(): - path_from = unicode(os.path.join( - frame[u'path'], - frame[u'title'])) + if item[u'service_item'].is_image(): + path_from = frame[u'path'] + else: + path_from = unicode(os.path.join( + frame[u'path'], + frame[u'title'])) # On write a file once if not path_from in write_list: write_list.append(path_from) From b4933ee1d60e66a7ec5a3dc0c25aca5fccbefb7b Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 27 Oct 2010 15:52:03 +0100 Subject: [PATCH 06/16] Rename directory --- resources/{Fedora => fedora}/191/OpenLP.spec | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename resources/{Fedora => fedora}/191/OpenLP.spec (100%) diff --git a/resources/Fedora/191/OpenLP.spec b/resources/fedora/191/OpenLP.spec similarity index 100% rename from resources/Fedora/191/OpenLP.spec rename to resources/fedora/191/OpenLP.spec From 901b9d98c5497d29c36553943219cec803daa095 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 27 Oct 2010 16:20:25 +0100 Subject: [PATCH 07/16] Auto Save service on exit if already saved service Fixes: https://launchpad.net/bugs/657307 --- openlp/core/ui/mainwindow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 81487e4f8..0bc2e63c5 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -781,7 +781,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtGui.QMessageBox.Save), QtGui.QMessageBox.Save) if ret == QtGui.QMessageBox.Save: - self.ServiceManagerContents.onSaveService() + self.ServiceManagerContents.onSaveService(TRUE) self.cleanUp() event.accept() elif ret == QtGui.QMessageBox.Discard: From 8d31844ee09cc95d4716d64c9cb0fe8a946232a3 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 27 Oct 2010 16:30:30 +0100 Subject: [PATCH 08/16] Add Vacuum to databases on exit Tidy up custom plugin naming Fixes: https://launchpad.net/bugs/636835 --- openlp/core/lib/db.py | 7 +++++ openlp/plugins/alerts/alertsplugin.py | 8 +++++ openlp/plugins/bibles/bibleplugin.py | 24 ++++++++++----- openlp/plugins/bibles/lib/manager.py | 8 +++++ openlp/plugins/custom/customplugin.py | 30 ++++++++++++------- openlp/plugins/custom/forms/editcustomform.py | 8 ++--- openlp/plugins/custom/lib/mediaitem.py | 5 ++-- openlp/plugins/songs/songsplugin.py | 22 +++++++++----- openlp/plugins/songusage/songusageplugin.py | 10 ++++++- 9 files changed, 89 insertions(+), 33 deletions(-) diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index 972d849a3..7c4536ccf 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -246,3 +246,10 @@ class Manager(object): self.session.rollback() log.exception(u'Failed to delete %s records', object_class.__name__) return False + + def finalise(self): + """ + VACUUM the database on exit. + """ + engine = create_engine(self.db_url) + engine.execute("vacuum") diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index b48ff4efd..15b1ed6f9 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -117,3 +117,11 @@ class AlertsPlugin(Plugin): self.textStrings[StringContent.VisibleName] = { 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) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 5dec63200..946b4ab93 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -133,42 +133,50 @@ class BiblePlugin(Plugin): ## Import Button ## self.textStrings[StringContent.Import] = { u'title': translate('BiblesPlugin', 'Import'), - u'tooltip': translate('BiblesPlugin', + u'tooltip': translate('BiblesPlugin', 'Import a Bible') } ## New Button ## self.textStrings[StringContent.New] = { u'title': translate('BiblesPlugin', 'Add'), - u'tooltip': translate('BiblesPlugin', + u'tooltip': translate('BiblesPlugin', 'Add a new Bible') } ## Edit Button ## self.textStrings[StringContent.Edit] = { u'title': translate('BiblesPlugin', 'Edit'), - u'tooltip': translate('BiblesPlugin', + u'tooltip': translate('BiblesPlugin', 'Edit the selected Bible') } ## Delete Button ## self.textStrings[StringContent.Delete] = { u'title': translate('BiblesPlugin', 'Delete'), - u'tooltip': translate('BiblesPlugin', + u'tooltip': translate('BiblesPlugin', 'Delete the selected Bible') } ## Preview ## self.textStrings[StringContent.Preview] = { u'title': translate('BiblesPlugin', 'Preview'), - u'tooltip': translate('BiblesPlugin', + u'tooltip': translate('BiblesPlugin', 'Preview the selected Bible') } ## Live Button ## self.textStrings[StringContent.Live] = { u'title': translate('BiblesPlugin', 'Live'), - u'tooltip': translate('BiblesPlugin', + u'tooltip': translate('BiblesPlugin', 'Send the selected Bible live') } ## Add to service Button ## self.textStrings[StringContent.Service] = { u'title': translate('BiblesPlugin', 'Service'), - u'tooltip': translate('BiblesPlugin', + u'tooltip': translate('BiblesPlugin', 'Add the selected Bible to the service') - } \ No newline at end of file + } + + def finalise(self): + """ + Time to tidy up on exit + """ + log.info(u'Bible Finalising') + self.manager.finalise() + Plugin.finalise(self) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 877331341..d5aa4d72b 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -310,3 +310,11 @@ class BibleManager(object): if bible == name: return True return False + + def finalise(self): + """ + Loop through the databases to VACUUM them. + """ + for bible in self.db_cache: + self.db_cache[bible].finalise + diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index 7e4b81b16..63bce3f81 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -49,8 +49,8 @@ class CustomPlugin(Plugin): def __init__(self, plugin_helpers): Plugin.__init__(self, u'Custom', u'1.9.3', plugin_helpers) self.weight = -5 - self.custommanager = Manager(u'custom', init_schema) - self.edit_custom_form = EditCustomForm(self.custommanager) + self.manager = Manager(u'custom', init_schema) + self.edit_custom_form = EditCustomForm(self.manager) self.icon_path = u':/plugins/plugin_custom.png' self.icon = build_icon(self.icon_path) @@ -115,48 +115,56 @@ class CustomPlugin(Plugin): ## Import Button ## self.textStrings[StringContent.Import] = { u'title': translate('CustomsPlugin', 'Import'), - u'tooltip': translate('CustomsPlugin', + u'tooltip': translate('CustomsPlugin', 'Import a Custom') } ## Load Button ## self.textStrings[StringContent.Load] = { u'title': translate('CustomsPlugin', 'Load'), - u'tooltip': translate('CustomsPlugin', + u'tooltip': translate('CustomsPlugin', 'Load a new Custom') } ## New Button ## self.textStrings[StringContent.New] = { u'title': translate('CustomsPlugin', 'Add'), - u'tooltip': translate('CustomsPlugin', + u'tooltip': translate('CustomsPlugin', 'Add a new Custom') } ## Edit Button ## self.textStrings[StringContent.Edit] = { u'title': translate('CustomsPlugin', 'Edit'), - u'tooltip': translate('CustomsPlugin', + u'tooltip': translate('CustomsPlugin', 'Edit the selected Custom') } ## Delete Button ## self.textStrings[StringContent.Delete] = { u'title': translate('CustomsPlugin', 'Delete'), - u'tooltip': translate('CustomsPlugin', + u'tooltip': translate('CustomsPlugin', 'Delete the selected Custom') } ## Preview ## self.textStrings[StringContent.Preview] = { u'title': translate('CustomsPlugin', 'Preview'), - u'tooltip': translate('CustomsPlugin', + u'tooltip': translate('CustomsPlugin', 'Preview the selected Custom') } ## Live Button ## self.textStrings[StringContent.Live] = { u'title': translate('CustomsPlugin', 'Live'), - u'tooltip': translate('CustomsPlugin', + u'tooltip': translate('CustomsPlugin', 'Send the selected Custom live') } ## Add to service Button ## self.textStrings[StringContent.Service] = { u'title': translate('CustomsPlugin', 'Service'), - u'tooltip': translate('CustomsPlugin', + u'tooltip': translate('CustomsPlugin', 'Add the selected Custom to the service') - } \ No newline at end of file + } + + def finalise(self): + """ + Time to tidy up on exit + """ + log.info(u'Custom Finalising') + self.manager.finalise() + Plugin.finalise(self) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 8ee4d2673..8e5312eac 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -41,7 +41,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): Class documentation goes here. """ log.info(u'Custom Editor loaded') - def __init__(self, custommanager, parent=None): + def __init__(self, manager, parent=None): """ Constructor """ @@ -74,7 +74,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.loadThemes) # Create other objects and forms. - self.custommanager = custommanager + self.manager = manager self.editSlideForm = EditCustomSlideForm(self) self.initialise() @@ -115,7 +115,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.customSlide = CustomSlide() self.initialise() 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.creditEdit.setText(self.customSlide.credits) customXML = CustomXMLParser(self.customSlide.text) @@ -168,7 +168,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): u'utf-8') self.customSlide.theme_name = unicode(self.themeComboBox.currentText(), u'utf-8') - return self.custommanager.save_object(self.customSlide) + return self.manager.save_object(self.customSlide) def onUpButtonPressed(self): selectedRow = self.slideListView.currentRow() diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index dd26883e8..3fe8a9b0f 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -56,6 +56,7 @@ class CustomMediaItem(MediaManagerItem): # Holds information about whether the edit is remotly triggered and # which Custom is required. self.remoteCustom = -1 + self.manager = parent.manager def addEndHeaderBar(self): QtCore.QObject.connect(Receiver.get_receiver(), @@ -71,7 +72,7 @@ class CustomMediaItem(MediaManagerItem): MediaManagerItem.requiredIcons(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)) #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 @@ -106,7 +107,7 @@ class CustomMediaItem(MediaManagerItem): type of display is required. """ fields = customid.split(u':') - valid = self.parent.custommanager.get_object(CustomSlide, fields[1]) + valid = self.manager.get_object(CustomSlide, fields[1]) if valid: self.remoteCustom = fields[1] self.remoteTriggered = fields[0] diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 47ae72632..dea60cdc0 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -166,36 +166,44 @@ class SongsPlugin(Plugin): ## New Button ## self.textStrings[StringContent.New] = { u'title': translate('SongsPlugin', 'Add'), - u'tooltip': translate('SongsPlugin', + u'tooltip': translate('SongsPlugin', 'Add a new Song') } ## Edit Button ## self.textStrings[StringContent.Edit] = { u'title': translate('SongsPlugin', 'Edit'), - u'tooltip': translate('SongsPlugin', + u'tooltip': translate('SongsPlugin', 'Edit the selected Song') } ## Delete Button ## self.textStrings[StringContent.Delete] = { u'title': translate('SongsPlugin', 'Delete'), - u'tooltip': translate('SongsPlugin', + u'tooltip': translate('SongsPlugin', 'Delete the selected Song') } ## Preview ## self.textStrings[StringContent.Preview] = { u'title': translate('SongsPlugin', 'Preview'), - u'tooltip': translate('SongsPlugin', + u'tooltip': translate('SongsPlugin', 'Preview the selected Song') } ## Live Button ## self.textStrings[StringContent.Live] = { u'title': translate('SongsPlugin', 'Live'), - u'tooltip': translate('SongsPlugin', + u'tooltip': translate('SongsPlugin', 'Send the selected Song live') } ## Add to service Button ## self.textStrings[StringContent.Service] = { u'title': translate('SongsPlugin', 'Service'), - u'tooltip': translate('SongsPlugin', + u'tooltip': translate('SongsPlugin', 'Add the selected Song to the service') - } \ No newline at end of file + } + + def finalise(self): + """ + Time to tidy up on exit + """ + log.info(u'Songs Finalising') + self.manager.finalise() + Plugin.finalise(self) diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index c4eb55adc..8898721c6 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -175,4 +175,12 @@ class SongUsagePlugin(Plugin): ## Name for MediaDockManager, SettingsManager ## self.textStrings[StringContent.VisibleName] = { u'title': translate('SongUsagePlugin', 'SongUsage') - } \ No newline at end of file + } + + def finalise(self): + """ + Time to tidy up on exit + """ + log.info(u'SongUsage Finalising') + self.manager.finalise() + Plugin.finalise(self) From 53d498bdc9c54c4e2a2fe9304f412be33d062b0b Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 27 Oct 2010 18:42:10 +0100 Subject: [PATCH 09/16] Fix bugs --- openlp/core/ui/mainwindow.py | 2 +- openlp/plugins/bibles/lib/http.py | 2 +- openlp/plugins/bibles/lib/manager.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 0bc2e63c5..0797a7a3e 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -781,7 +781,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtGui.QMessageBox.Save), QtGui.QMessageBox.Save) if ret == QtGui.QMessageBox.Save: - self.ServiceManagerContents.onSaveService(TRUE) + self.ServiceManagerContents.onSaveService(True) self.cleanUp() event.accept() elif ret == QtGui.QMessageBox.Discard: diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 18cdb7223..e6a474f5c 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -36,7 +36,7 @@ from BeautifulSoup import BeautifulSoup, NavigableString from openlp.core.lib import Receiver 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 log = logging.getLogger(__name__) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index d5aa4d72b..9afc4a4b2 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -316,5 +316,5 @@ class BibleManager(object): Loop through the databases to VACUUM them. """ for bible in self.db_cache: - self.db_cache[bible].finalise + self.db_cache[bible].finalise() From 7dcd7f3011bb6c0a4d3844af33f038005d0a6a05 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 27 Oct 2010 20:40:38 +0100 Subject: [PATCH 10/16] Fix Media icon - it went AWOL --- openlp/plugins/media/lib/mediaitem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 61309c174..6e3695149 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -56,7 +56,7 @@ class MediaMediaItem(MediaManagerItem): u':/media/media_video.png').toImage() MediaManagerItem.__init__(self, parent, self, icon) self.singleServiceItem = False - self.serviceItemIconName = u':/media/media_video.png' + self.serviceItemIconName = u':/media/image_clapperboard.png' def retranslateUi(self): self.OnNewPrompt = translate('MediaPlugin.MediaItem', 'Select Media') From d458ac2a98f0f909e47b662e5634cc6b6501f20a Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 28 Oct 2010 14:10:25 +0200 Subject: [PATCH 11/16] replaced songusagemanager --- openlp/plugins/songusage/forms/songusagedeleteform.py | 6 +++--- openlp/plugins/songusage/forms/songusagedetailform.py | 2 +- openlp/plugins/songusage/songusageplugin.py | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/openlp/plugins/songusage/forms/songusagedeleteform.py b/openlp/plugins/songusage/forms/songusagedeleteform.py index 36eda98b2..45e4e91a9 100644 --- a/openlp/plugins/songusage/forms/songusagedeleteform.py +++ b/openlp/plugins/songusage/forms/songusagedeleteform.py @@ -34,11 +34,11 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog): """ Class documentation goes here. """ - def __init__(self, songusagemanager, parent): + def __init__(self, manager, parent): """ Constructor """ - self.songusagemanager = songusagemanager + self.manager = manager QtGui.QDialog.__init__(self, parent) self.setupUi(self) @@ -53,6 +53,6 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog): QtGui.QMessageBox.Cancel) if ret == QtGui.QMessageBox.Ok: deleteDate = self.deleteCalendar.selectedDate().toPyDate() - self.songusagemanager.delete_all_objects(SongUsageItem, + self.manager.delete_all_objects(SongUsageItem, SongUsageItem.usagedate <= deleteDate) self.close() diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index b1668990b..18aa1797f 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -76,7 +76,7 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): filename = u'usage_detail_%s_%s.txt' % ( self.fromDate.selectedDate().toString(u'ddMMyyyy'), self.toDate.selectedDate().toString(u'ddMMyyyy')) - usage = self.plugin.songusagemanager.get_all_objects( + usage = self.plugin.manager.get_all_objects( SongUsageItem, and_( SongUsageItem.usagedate >= self.fromDate.selectedDate().toPyDate(), SongUsageItem.usagedate < self.toDate.selectedDate().toPyDate()), diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index 8898721c6..124fe2863 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -44,7 +44,7 @@ class SongUsagePlugin(Plugin): Plugin.__init__(self, u'SongUsage', u'1.9.3', plugin_helpers) self.weight = -4 self.icon = build_icon(u':/plugins/plugin_songusage.png') - self.songusagemanager = None + self.manager = None self.songusageActive = False def addToolsMenuItem(self, tools_menu): @@ -115,9 +115,9 @@ class SongUsagePlugin(Plugin): self.settingsSection + u'/active', QtCore.QVariant(False)).toBool() self.SongUsageStatus.setChecked(self.SongUsageActive) - if self.songusagemanager is None: - self.songusagemanager = Manager(u'songusage', init_schema) - self.SongUsagedeleteform = SongUsageDeleteForm(self.songusagemanager, + if self.manager is None: + self.manager = Manager(u'songusage', init_schema) + self.SongUsagedeleteform = SongUsageDeleteForm(self.manager, self.formparent) self.SongUsagedetailform = SongUsageDetailForm(self, self.formparent) self.SongUsageMenu.menuAction().setVisible(True) @@ -148,7 +148,7 @@ class SongUsagePlugin(Plugin): song_usage_item.authors = u'' for author in audit[1]: song_usage_item.authors += author + u' ' - self.songusagemanager.save_object(song_usage_item) + self.manager.save_object(song_usage_item) def onSongUsageDelete(self): self.SongUsagedeleteform.exec_() From e3b7cc2c91609827b0256f947b1a3756f7d3e7fb Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 28 Oct 2010 16:56:52 +0200 Subject: [PATCH 12/16] fixed manager for customs --- openlp/plugins/custom/customplugin.py | 8 ++++---- openlp/plugins/custom/lib/mediaitem.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index 63bce3f81..c7fb38e3b 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -59,7 +59,7 @@ class CustomPlugin(Plugin): return CustomTab(self.name, visible_name[u'title']) def getMediaManagerItem(self): - # Create the CustomManagerItem object + # Create the ManagerItem object return CustomMediaItem(self, self, self.icon) def about(self): @@ -76,7 +76,7 @@ class CustomPlugin(Plugin): Returns True if the theme is being used, otherwise returns False. """ - if self.custommanager.get_all_objects(CustomSlide, + if self.manager.get_all_objects(CustomSlide, CustomSlide.theme_name == theme): return True return False @@ -92,11 +92,11 @@ class CustomPlugin(Plugin): ``newTheme`` The new name the plugin should now use. """ - customsUsingTheme = self.custommanager.get_all_objects(CustomSlide, + customsUsingTheme = self.manager.get_all_objects(CustomSlide, CustomSlide.theme_name == oldTheme) for custom in customsUsingTheme: custom.theme_name = newTheme - self.custommanager.save_object(custom) + self.manager.save_object(custom) def setPluginTextStrings(self): """ diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 3fe8a9b0f..9cdcb9ed7 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -140,7 +140,7 @@ class CustomMediaItem(MediaManagerItem): id_list = [(item.data(QtCore.Qt.UserRole)).toInt()[0] for item in self.listView.selectedIndexes()] for id in id_list: - self.parent.custommanager.delete_object(CustomSlide, id) + self.parent.manager.delete_object(CustomSlide, id) for row in row_list: self.listView.takeItem(row) @@ -162,7 +162,7 @@ class CustomMediaItem(MediaManagerItem): service_item.add_capability(ItemCapabilities.AllowsEdit) service_item.add_capability(ItemCapabilities.AllowsPreview) service_item.add_capability(ItemCapabilities.AllowsLoop) - customSlide = self.parent.custommanager.get_object(CustomSlide, item_id) + customSlide = self.parent.manager.get_object(CustomSlide, item_id) title = customSlide.title credit = customSlide.credits service_item.editId = item_id From 5d9ef61e2c9cef827a7a013e370ee9badc0aec0b Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 28 Oct 2010 18:02:28 +0100 Subject: [PATCH 13/16] Only Vacuum changed databases --- openlp/core/lib/db.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index 7c4536ccf..e59a9737b 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -117,6 +117,7 @@ class Manager(object): settings = QtCore.QSettings() settings.beginGroup(plugin_name) self.db_url = u'' + self.is_dirty = False db_type = unicode( settings.value(u'db type', QtCore.QVariant(u'sqlite')).toString()) if db_type == u'sqlite': @@ -150,6 +151,7 @@ class Manager(object): self.session.add(object_instance) if commit: self.session.commit() + self.is_dirty = True return True except InvalidRequestError: self.session.rollback() @@ -220,6 +222,7 @@ class Manager(object): try: self.session.delete(object_instance) self.session.commit() + self.is_dirty = True return True except InvalidRequestError: self.session.rollback() @@ -241,6 +244,7 @@ class Manager(object): query = query.filter(filter_clause) query.delete(synchronize_session=False) self.session.commit() + self.is_dirty = True return True except InvalidRequestError: self.session.rollback() @@ -251,5 +255,6 @@ class Manager(object): """ VACUUM the database on exit. """ - engine = create_engine(self.db_url) - engine.execute("vacuum") + if self.is_dirty: + engine = create_engine(self.db_url) + engine.execute("vacuum") From fff4cf1e1c910fd1776b14a146f646176be4a31e Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 28 Oct 2010 18:23:17 +0100 Subject: [PATCH 14/16] Revert 1102 Fixes: https://launchpad.net/bugs/667837 --- openlp/core/lib/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 1ad17a039..c8551299b 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -263,8 +263,9 @@ def resize_image(image, width, height, background=QtCore.Qt.black): # and move it to the centre of the preview space new_image = QtGui.QImage(width, height, QtGui.QImage.Format_ARGB32_Premultiplied) + new_image.fill(background) painter = QtGui.QPainter(new_image) - painter.fillRect(new_image.rect(), background) + #painter.fillRect(new_image.rect(), background) painter.drawImage((width - realw) / 2, (height - realh) / 2, preview) return new_image From 9ed0ff2ea26a554d4d971ab53bc2ef1472f79db6 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 29 Oct 2010 07:36:17 +0100 Subject: [PATCH 15/16] Proper fix for 1102 --- openlp/core/lib/__init__.py | 3 +-- openlp/core/lib/theme.py | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index c8551299b..1ad17a039 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -263,9 +263,8 @@ def resize_image(image, width, height, background=QtCore.Qt.black): # and move it to the centre of the preview space new_image = QtGui.QImage(width, height, QtGui.QImage.Format_ARGB32_Premultiplied) - new_image.fill(background) painter = QtGui.QPainter(new_image) - #painter.fillRect(new_image.rect(), background) + painter.fillRect(new_image.rect(), background) painter.drawImage((width - realw) / 2, (height - realh) / 2, preview) return new_image diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index ad6ca0f5b..b7ed711f9 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -408,6 +408,9 @@ class ThemeXML(object): elif field in integer_list: setattr(self, master + field, int(value)) else: + # None means an empty sting so lets have one. + if value == u'None': + value = u'' setattr(self, master + field, unicode(value)) def __str__(self): From e6506e74333f4a8f01479ec6eb6a635f4ef342ac Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 29 Oct 2010 07:44:38 +0100 Subject: [PATCH 16/16] Spelling --- openlp/core/lib/theme.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index b7ed711f9..cf1859d0b 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -408,7 +408,7 @@ class ThemeXML(object): elif field in integer_list: setattr(self, master + field, int(value)) else: - # None means an empty sting so lets have one. + # None means an empty string so lets have one. if value == u'None': value = u'' setattr(self, master + field, unicode(value))