This commit is contained in:
Jonathan Corwin 2011-06-11 09:32:36 +01:00
commit 0c6049917a
10 changed files with 38 additions and 31 deletions

View File

@ -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

View File

@ -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

View File

@ -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')

View File

@ -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',

View File

@ -1101,3 +1101,7 @@ class OldBibleDB(QtCore.QObject, Manager):
]
else:
return None
def close_connection(self):
self.cursor.close()
self.connection.close()

View File

@ -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(

View File

@ -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(

View File

@ -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)

View File

@ -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))

View File

@ -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=