Fix v1 themes with Unicode file names (Bug #882819)

bzr-revno: 1832
This commit is contained in:
Jon Tibble 2011-12-11 20:23:47 +00:00
commit bd514c2994

View File

@ -526,13 +526,11 @@ class ThemeManager(QtGui.QWidget):
zip = zipfile.ZipFile(filename) zip = zipfile.ZipFile(filename)
themename = None themename = None
for file in zip.namelist(): for file in zip.namelist():
# Handle UTF-8 files
ucsfile = file_is_unicode(file) ucsfile = file_is_unicode(file)
if not ucsfile: if not ucsfile:
critical_error_message_box( # Handle native Unicode files from Windows
message=translate('OpenLP.ThemeManager', ucsfile = file
'File is not a valid theme.\n'
'The content encoding is not UTF-8.'))
continue
osfile = unicode(QtCore.QDir.toNativeSeparators(ucsfile)) osfile = unicode(QtCore.QDir.toNativeSeparators(ucsfile))
theme_dir = None theme_dir = None
if osfile.endswith(os.path.sep): if osfile.endswith(os.path.sep):
@ -620,7 +618,7 @@ class ThemeManager(QtGui.QWidget):
""" """
name = theme.theme_name name = theme.theme_name
theme_pretty_xml = theme.extract_formatted_xml() theme_pretty_xml = theme.extract_formatted_xml()
log.debug(u'saveTheme %s %s', name, theme_pretty_xml) log.debug(u'saveTheme %s %s', name, theme_pretty_xml.decode(u'utf-8'))
theme_dir = os.path.join(self.path, name) theme_dir = os.path.join(self.path, name)
check_directory_exists(theme_dir) check_directory_exists(theme_dir)
theme_file = os.path.join(theme_dir, name + u'.xml') theme_file = os.path.join(theme_dir, name + u'.xml')