diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 2d3e55355..75bafc5e8 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -137,13 +137,12 @@ def image_to_byte(image): # convert to base64 encoding so does not get missed! return byte_array.toBase64() -def resize_image(image, width, height, background=QtCore.Qt.black): +def resize_image(image_path, width, height, background=QtCore.Qt.black): """ Resize an image to fit on the current screen. - ``image`` - The image to resize. It has to be either a ``QImage`` instance or the - path to the image. + ``image_path`` + The path to the image to resize. ``width`` The new image width. @@ -155,16 +154,24 @@ def resize_image(image, width, height, background=QtCore.Qt.black): The background colour defaults to black. """ log.debug(u'resize_image - start') - if isinstance(image, QtGui.QImage): - preview = image + reader = QtGui.QImageReader(image_path) + # The image's ratio. + image_ratio = float(reader.size().width()) / float(reader.size().height()) + resize_ratio = float(width) / float(height) + # Figure out the size we want to resize the image to (keep aspect ratio). + if image_ratio == resize_ratio: + size = QtCore.QSize(width, height) + elif image_ratio < resize_ratio: + # Use the image's height as reference for the new size. + size = QtCore.QSize(image_ratio * height, height) else: - preview = QtGui.QImage(image) - if not preview.isNull(): - # Only resize if different size - if preview.width() == width and preview.height == height: - return preview - preview = preview.scaled(width, height, QtCore.Qt.KeepAspectRatio, - QtCore.Qt.SmoothTransformation) + # Use the image's width as reference for the new size. + size = QtCore.QSize(width, 1 / (image_ratio / width)) + reader.setScaledSize(size) + preview = reader.read() + if image_ratio == resize_ratio: + # We neither need to centre the image nor add "bars" to the image. + return preview realw = preview.width() realh = preview.height() # and move it to the centre of the preview space diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 34c1a6b55..b8f7b28ad 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -90,7 +90,7 @@ class MediaManagerItem(QtGui.QWidget): """ Constructor to create the media manager item. """ - QtGui.QWidget.__init__(self, parent) + QtGui.QWidget.__init__(self) self.hide() self.whitespace = re.compile(r'[\W_]+', re.UNICODE) self.plugin = plugin diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 13c421708..c784a7b2b 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -119,6 +119,9 @@ class UiStrings(object): self.Settings = translate('OpenLP.Ui', 'Settings') self.SaveService = translate('OpenLP.Ui', 'Save Service') self.Service = translate('OpenLP.Ui', 'Service') + self.Split = translate('OpenLP.Ui', '&Split') + self.SplitToolTip = translate('OpenLP.Ui', 'Split a slide into two ' + 'only if it does not fit on the screen as one slide.') self.StartTimeCode = unicode(translate('OpenLP.Ui', 'Start %s')) self.Theme = translate('OpenLP.Ui', 'Theme', 'Singular') self.Themes = translate('OpenLP.Ui', 'Themes', 'Plural') diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index faa1a8e82..df103b728 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -732,6 +732,7 @@ class BibleUpgradeForm(OpenLPWizard): self.newbibles[number].session.commit() if not bible_failed: self.newbibles[number].create_meta(u'Version', name) + oldbible.close_connection() delete_file(os.path.join(self.path, filename[0])) self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 41dc947f9..49488be0e 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -1101,3 +1101,7 @@ class OldBibleDB(QtCore.QObject, Manager): ] else: return None + + def close_connection(self): + self.cursor.close() + self.connection.close() diff --git a/openlp/plugins/custom/forms/editcustomslidedialog.py b/openlp/plugins/custom/forms/editcustomslidedialog.py index 165e6d847..022a37a6f 100644 --- a/openlp/plugins/custom/forms/editcustomslidedialog.py +++ b/openlp/plugins/custom/forms/editcustomslidedialog.py @@ -28,7 +28,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, SpellTextEdit, build_icon -from openlp.core.lib.ui import create_accept_reject_button_box +from openlp.core.lib.ui import create_accept_reject_button_box, UiStrings class Ui_CustomSlideEditDialog(object): def setupUi(self, customSlideEditDialog): @@ -54,11 +54,8 @@ class Ui_CustomSlideEditDialog(object): QtCore.QMetaObject.connectSlotsByName(customSlideEditDialog) def retranslateUi(self, customSlideEditDialog): - self.splitButton.setText( - translate('CustomPlugin.EditCustomForm', 'Split Slide')) - self.splitButton.setToolTip( - translate('CustomPlugin.EditCustomForm', 'Split a slide into two ' - 'only if it does not fit on the screen as one slide.')) + self.splitButton.setText(UiStrings().Split) + self.splitButton.setToolTip(UiStrings().SplitToolTip) self.insertButton.setText( translate('CustomPlugin.EditCustomForm', 'Insert Slide')) self.insertButton.setToolTip( diff --git a/openlp/plugins/songs/forms/editversedialog.py b/openlp/plugins/songs/forms/editversedialog.py index 16579f6a9..e03f30b40 100644 --- a/openlp/plugins/songs/forms/editversedialog.py +++ b/openlp/plugins/songs/forms/editversedialog.py @@ -28,7 +28,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, translate, SpellTextEdit -from openlp.core.lib.ui import create_accept_reject_button_box +from openlp.core.lib.ui import create_accept_reject_button_box, UiStrings from openlp.plugins.songs.lib import VerseType class Ui_EditVerseDialog(object): @@ -89,11 +89,8 @@ class Ui_EditVerseDialog(object): VerseType.TranslatedNames[VerseType.Ending]) self.verseTypeComboBox.setItemText(VerseType.Other, VerseType.TranslatedNames[VerseType.Other]) - self.splitButton.setText( - translate('SongsPlugin.EditVerseForm', '&Split')) - self.splitButton.setToolTip( - translate('SongsPlugin.EditVerseForm', 'Split a slide into two ' - 'only if it does not fit on the screen as one slide.')) + self.splitButton.setText(UiStrings().Split) + self.splitButton.setToolTip(UiStrings().SplitToolTip) self.insertButton.setText( translate('SongsPlugin.EditVerseForm', '&Insert')) self.insertButton.setToolTip( diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 914bcab73..d089eb8b4 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -297,7 +297,7 @@ class SongImportForm(OpenLPWizard): self.songsOfFellowshipDisabledLabel.setText( translate('SongsPlugin.ImportWizardForm', 'The Songs of ' 'Fellowship importer has been disabled because OpenLP cannot ' - 'find OpenOffice.org on your computer.')) + 'access OpenOffice or LibreOffice.')) self.genericAddButton.setText( translate('SongsPlugin.ImportWizardForm', 'Add Files...')) self.genericRemoveButton.setText( @@ -305,7 +305,7 @@ class SongImportForm(OpenLPWizard): self.genericDisabledLabel.setText( translate('SongsPlugin.ImportWizardForm', 'The generic document/' 'presentation importer has been disabled because OpenLP cannot ' - 'find OpenOffice.org on your computer.')) + 'access OpenOffice or LibreOffice.')) self.easiSlidesFilenameLabel.setText( translate('SongsPlugin.ImportWizardForm', 'Filename:')) self.easiSlidesBrowseButton.setText(UiStrings().Browse) diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index 85e0b67bc..141366fc3 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -68,7 +68,7 @@ class OooImport(SongImport): self.log_error( self.import_source[0], translate('SongsPlugin.SongImport', - 'Unable to open OpenOffice.org or LibreOffice')) + 'Cannot access OpenOffice or LibreOffice')) log.error(exc) return self.import_wizard.progressBar.setMaximum(len(self.import_source)) diff --git a/resources/openlp.desktop b/resources/openlp.desktop index 07398ede8..b17cbaf96 100755 --- a/resources/openlp.desktop +++ b/resources/openlp.desktop @@ -2,7 +2,6 @@ Categories=AudioVideo; Comment[de]= Comment= -Encoding=UTF-8 Exec=openlp %F GenericName[de]=Church lyrics projection GenericName=Church lyrics projection @@ -13,7 +12,6 @@ Name=OpenLP Path= StartupNotify=true Terminal=false -TerminalOptions= Type=Application X-DBUS-ServiceName= X-DBUS-StartupType=