forked from openlp/openlp
Head r1308
This commit is contained in:
commit
9b48761590
@ -239,7 +239,8 @@ def resize_image(image, width, height, background=QtCore.Qt.black):
|
|||||||
Resize an image to fit on the current screen.
|
Resize an image to fit on the current screen.
|
||||||
|
|
||||||
``image``
|
``image``
|
||||||
The image to resize.
|
The image to resize. It has to be either a ``QImage`` instance or the
|
||||||
|
path to the image.
|
||||||
|
|
||||||
``width``
|
``width``
|
||||||
The new image width.
|
The new image width.
|
||||||
|
@ -85,8 +85,7 @@ class ImageManager(QtCore.QObject):
|
|||||||
for key in self._cache.keys():
|
for key in self._cache.keys():
|
||||||
image = self._cache[key]
|
image = self._cache[key]
|
||||||
image.dirty = True
|
image.dirty = True
|
||||||
image.image = resize_image(image.path,
|
image.image = resize_image(image.path, self.width, self.height)
|
||||||
self.width, self.height)
|
|
||||||
self._cache_dirty = True
|
self._cache_dirty = True
|
||||||
# only one thread please
|
# only one thread please
|
||||||
if not self._thread_running:
|
if not self._thread_running:
|
||||||
@ -128,8 +127,7 @@ class ImageManager(QtCore.QObject):
|
|||||||
image = Image()
|
image = Image()
|
||||||
image.name = name
|
image.name = name
|
||||||
image.path = path
|
image.path = path
|
||||||
image.image = resize_image(path,
|
image.image = resize_image(path, self.width, self.height)
|
||||||
self.width, self.height)
|
|
||||||
self._cache[name] = image
|
self._cache[name] = image
|
||||||
else:
|
else:
|
||||||
log.debug(u'Image in cache %s:%s' % (name, path))
|
log.debug(u'Image in cache %s:%s' % (name, path))
|
||||||
|
@ -529,6 +529,18 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
else:
|
else:
|
||||||
outfile = open(fullpath, u'wb')
|
outfile = open(fullpath, u'wb')
|
||||||
outfile.write(zip.read(file))
|
outfile.write(zip.read(file))
|
||||||
|
except (IOError, NameError):
|
||||||
|
critical_error_message_box(
|
||||||
|
translate('OpenLP.ThemeManager', 'Validation Error'),
|
||||||
|
translate('OpenLP.ThemeManager', 'File is not a valid theme.'))
|
||||||
|
log.exception(u'Importing theme from zip failed %s' % filename)
|
||||||
|
finally:
|
||||||
|
# Close the files, to be able to continue creating the theme.
|
||||||
|
if zip:
|
||||||
|
zip.close()
|
||||||
|
if outfile:
|
||||||
|
outfile.close()
|
||||||
|
# As all files are closed, we can create the Theme.
|
||||||
if filexml:
|
if filexml:
|
||||||
theme = self._createThemeFromXml(filexml, self.path)
|
theme = self._createThemeFromXml(filexml, self.path)
|
||||||
self.generateAndSaveImage(dir, themename, theme)
|
self.generateAndSaveImage(dir, themename, theme)
|
||||||
@ -539,17 +551,6 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
'File is not a valid theme.'))
|
'File is not a valid theme.'))
|
||||||
log.exception(u'Theme file does not contain XML data %s' %
|
log.exception(u'Theme file does not contain XML data %s' %
|
||||||
filename)
|
filename)
|
||||||
except (IOError, NameError):
|
|
||||||
critical_error_message_box(
|
|
||||||
translate('OpenLP.ThemeManager', 'Validation Error'),
|
|
||||||
translate('OpenLP.ThemeManager',
|
|
||||||
'File is not a valid theme.'))
|
|
||||||
log.exception(u'Importing theme from zip failed %s' % filename)
|
|
||||||
finally:
|
|
||||||
if zip:
|
|
||||||
zip.close()
|
|
||||||
if outfile:
|
|
||||||
outfile.close()
|
|
||||||
|
|
||||||
def checkIfThemeExists(self, themeName):
|
def checkIfThemeExists(self, themeName):
|
||||||
"""
|
"""
|
||||||
|
@ -244,6 +244,7 @@ class SongExportForm(OpenLPWizard):
|
|||||||
self.availableListWidget.clear()
|
self.availableListWidget.clear()
|
||||||
self.selectedListWidget.clear()
|
self.selectedListWidget.clear()
|
||||||
self.directoryLineEdit.clear()
|
self.directoryLineEdit.clear()
|
||||||
|
self.searchLineEdit.clear()
|
||||||
# Load the list of songs.
|
# Load the list of songs.
|
||||||
Receiver.send_message(u'cursor_busy')
|
Receiver.send_message(u'cursor_busy')
|
||||||
songs = self.plugin.manager.get_all_objects(Song)
|
songs = self.plugin.manager.get_all_objects(Song)
|
||||||
@ -332,18 +333,20 @@ class SongExportForm(OpenLPWizard):
|
|||||||
|
|
||||||
def onUncheckButtonClicked(self):
|
def onUncheckButtonClicked(self):
|
||||||
"""
|
"""
|
||||||
The *uncheckButton* has been clicked. Set all songs unchecked.
|
The *uncheckButton* has been clicked. Set all visible songs unchecked.
|
||||||
"""
|
"""
|
||||||
for row in range(self.availableListWidget.count()):
|
for row in range(self.availableListWidget.count()):
|
||||||
item = self.availableListWidget.item(row)
|
item = self.availableListWidget.item(row)
|
||||||
|
if not item.isHidden():
|
||||||
item.setCheckState(QtCore.Qt.Unchecked)
|
item.setCheckState(QtCore.Qt.Unchecked)
|
||||||
|
|
||||||
def onCheckButtonClicked(self):
|
def onCheckButtonClicked(self):
|
||||||
"""
|
"""
|
||||||
The *checkButton* has been clicked. Set all songs checked.
|
The *checkButton* has been clicked. Set all visible songs checked.
|
||||||
"""
|
"""
|
||||||
for row in range(self.availableListWidget.count()):
|
for row in range(self.availableListWidget.count()):
|
||||||
item = self.availableListWidget.item(row)
|
item = self.availableListWidget.item(row)
|
||||||
|
if not item.isHidden():
|
||||||
item.setCheckState(QtCore.Qt.Checked)
|
item.setCheckState(QtCore.Qt.Checked)
|
||||||
|
|
||||||
def onDirectoryButtonClicked(self):
|
def onDirectoryButtonClicked(self):
|
||||||
|
@ -81,14 +81,16 @@ class EasiSlidesImport(SongImport):
|
|||||||
|
|
||||||
def _parse_song(self, song):
|
def _parse_song(self, song):
|
||||||
self._success = True
|
self._success = True
|
||||||
self._add_unicode_attribute(self.title, song.Title1, True)
|
self._add_unicode_attribute(u'title', song.Title1, True)
|
||||||
self._add_unicode_attribute(self.alternate_title, song.Title2)
|
self._add_unicode_attribute(u'alternate_title', song.Title2)
|
||||||
self._add_unicode_attribute(self.song_number, song.SongNumber)
|
self._add_unicode_attribute(u'song_number', song.SongNumber)
|
||||||
if self.song_number == u'0':
|
if self.song_number == u'0':
|
||||||
self.song_number = u''
|
self.song_number = u''
|
||||||
self._add_authors(song)
|
self._add_authors(song)
|
||||||
self._add_copyright(song)
|
self._add_copyright(song.Copyright)
|
||||||
self._add_unicode_attribute(self.song_book_name, song.BookReference)
|
self._add_copyright(song.LicenceAdmin1)
|
||||||
|
self._add_copyright(song.LicenceAdmin2)
|
||||||
|
self._add_unicode_attribute(u'song_book_name', song.BookReference)
|
||||||
self._parse_and_add_lyrics(song)
|
self._parse_and_add_lyrics(song)
|
||||||
return self._success
|
return self._success
|
||||||
|
|
||||||
@ -110,7 +112,7 @@ class EasiSlidesImport(SongImport):
|
|||||||
Signals that this attribute must exist in a valid song.
|
Signals that this attribute must exist in a valid song.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self_attribute = unicode(import_attribute).strip()
|
setattr(self, self_attribute, unicode(import_attribute).strip())
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
log.exception(u'UnicodeDecodeError decoding %s' % import_attribute)
|
log.exception(u'UnicodeDecodeError decoding %s' % import_attribute)
|
||||||
self._success = False
|
self._success = False
|
||||||
@ -124,7 +126,7 @@ class EasiSlidesImport(SongImport):
|
|||||||
authors = unicode(song.Writer).split(u',')
|
authors = unicode(song.Writer).split(u',')
|
||||||
for author in authors:
|
for author in authors:
|
||||||
author = author.strip()
|
author = author.strip()
|
||||||
if len(author) > 0:
|
if len(author):
|
||||||
self.authors.append(author)
|
self.authors.append(author)
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
log.exception(u'Unicode decode error while decoding Writer')
|
log.exception(u'Unicode decode error while decoding Writer')
|
||||||
@ -132,35 +134,18 @@ class EasiSlidesImport(SongImport):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _add_copyright(self, song):
|
def _add_copyright(self, element):
|
||||||
"""
|
|
||||||
Assign the copyright information from the import to the song being
|
|
||||||
created.
|
|
||||||
|
|
||||||
``song``
|
|
||||||
The current song being imported.
|
|
||||||
"""
|
|
||||||
copyright_list = []
|
|
||||||
self.__add_copyright_element(copyright_list, song.Copyright)
|
|
||||||
self.__add_copyright_element(copyright_list, song.LicenceAdmin1)
|
|
||||||
self.__add_copyright_element(copyright_list, song.LicenceAdmin2)
|
|
||||||
self.add_copyright(u' '.join(copyright_list))
|
|
||||||
|
|
||||||
def __add_copyright_element(self, copyright_list, element):
|
|
||||||
"""
|
"""
|
||||||
Add a piece of copyright to the total copyright information for the
|
Add a piece of copyright to the total copyright information for the
|
||||||
song.
|
song.
|
||||||
|
|
||||||
``copyright_list``
|
|
||||||
The array to add the information to.
|
|
||||||
|
|
||||||
``element``
|
``element``
|
||||||
The imported variable to get the data from.
|
The imported variable to get the data from.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
copyright_list.append(unicode(element).strip())
|
self.add_copyright(unicode(element).strip())
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
log.exception(u'Unicode error decoding %s' % element)
|
log.exception(u'Unicode error on decoding copyright: %s' % element)
|
||||||
self._success = False
|
self._success = False
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
@ -285,10 +270,12 @@ class EasiSlidesImport(SongImport):
|
|||||||
# as these appeared originally in the file
|
# as these appeared originally in the file
|
||||||
for [reg, vt, vn, inst] in our_verse_order:
|
for [reg, vt, vn, inst] in our_verse_order:
|
||||||
if self._listHas(verses, [reg, vt, vn, inst]):
|
if self._listHas(verses, [reg, vt, vn, inst]):
|
||||||
|
# this is false, but needs user input
|
||||||
|
lang = None
|
||||||
versetag = u'%s%s' % (vt, vn)
|
versetag = u'%s%s' % (vt, vn)
|
||||||
versetags.append(versetag)
|
versetags.append(versetag)
|
||||||
lines = u'\n'.join(verses[reg][vt][vn][inst])
|
lines = u'\n'.join(verses[reg][vt][vn][inst])
|
||||||
self.verses.append([versetag, lines])
|
self.verses.append([versetag, lines, lang])
|
||||||
|
|
||||||
SeqTypes = {
|
SeqTypes = {
|
||||||
u'p': u'P1',
|
u'p': u'P1',
|
||||||
|
Loading…
Reference in New Issue
Block a user