diff --git a/openlp/core/ui/aboutform.py b/openlp/core/ui/aboutform.py index 933a12b56..4f9519eb8 100644 --- a/openlp/core/ui/aboutform.py +++ b/openlp/core/ui/aboutform.py @@ -44,8 +44,8 @@ class AboutForm(QtGui.QDialog, Ui_AboutDialog): about_text = about_text.replace(u'', self.applicationVersion[u'version']) if self.applicationVersion[u'build']: - build_text = u' %s %s' % (translate(u'AboutForm', u'build'), - self.applicationVersion[u'build']) + build_text = unicode(translate(u'AboutForm', u' build %s')) % \ + self.applicationVersion[u'build'] else: build_text = u'' about_text = about_text.replace(u'', build_text) diff --git a/openlp/core/ui/amendthemeform.py b/openlp/core/ui/amendthemeform.py index 1ae9caa79..fb91a5bc0 100644 --- a/openlp/core/ui/amendthemeform.py +++ b/openlp/core/ui/amendthemeform.py @@ -155,7 +155,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.theme.background_direction) else: filename = \ - os.path.split(unicode(self.theme.background_filename))[0] + os.path.split(unicode(self.theme.background_filename))[1] new_theme.add_background_image(filename) save_to = os.path.join(self.path, theme_name, filename) save_from = self.theme.background_filename diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index c65fa2ec0..271a05d23 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -452,8 +452,8 @@ class Ui_MainWindow(object): translate(u'MainWindow', u'Choose System language, if available')) for item in self.LanguageGroup.actions(): item.setText(item.objectName()) - item.setStatusTip(translate(u'MainWindow', - u'Set the interface language to %1').arg(item.objectName())) + item.setStatusTip(unicode(translate(u'MainWindow', + u'Set the interface language to %s')) % item.objectName()) self.ToolsAddToolItem.setText(translate(u'MainWindow', u'Add &Tool...')) self.ToolsAddToolItem.setStatusTip( translate(u'MainWindow', diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index a794a1c21..66bee9417 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -597,11 +597,11 @@ class ServiceManager(QtGui.QWidget): path_from = unicode(os.path.join( frame[u'path'], frame[u'title'])) - zip.write(path_from) + zip.write(path_from.encode(u'utf-8')) file = open(servicefile, u'wb') cPickle.dump(service, file) file.close() - zip.write(servicefile) + zip.write(servicefile.encode(u'utf-8')) except IOError: log.exception(u'Failed to save service to disk') finally: @@ -667,7 +667,18 @@ class ServiceManager(QtGui.QWidget): try: zip = zipfile.ZipFile(unicode(filename)) for file in zip.namelist(): - osfile = unicode(QtCore.QDir.toNativeSeparators(file)) + try: + ucsfile = file.decode(u'utf-8') + except UnicodeDecodeError: + QtGui.QMessageBox.critical( + self, translate(u'ServiceManager', u'Error'), + translate(u'ServiceManager', + u'File is not a valid service.\n' + u'The content encoding is not UTF-8.')) + log.exception(u'Filename "%s" is no valid UTF-8' % \ + file.decode(u'utf-8', u'replace')) + continue + osfile = unicode(QtCore.QDir.toNativeSeparators(ucsfile)) names = osfile.split(os.path.sep) file_path = os.path.join(self.servicePath, names[len(names) - 1]) @@ -677,21 +688,28 @@ class ServiceManager(QtGui.QWidget): file_to.close() if file_path.endswith(u'osd'): p_file = file_path - file_to = open(p_file, u'r') - items = cPickle.load(file_to) - file_to.close() - self.onNewService() - for item in items: - serviceitem = ServiceItem() - serviceitem.RenderManager = self.parent.RenderManager - serviceitem.set_from_service(item, self.servicePath) - self.validateItem(serviceitem) - self.addServiceItem(serviceitem) - try: - if os.path.isfile(p_file): - os.remove(p_file) - except (IOError, OSError): - log.exception(u'Failed to remove osd file') + if 'p_file' in locals(): + file_to = open(p_file, u'r') + items = cPickle.load(file_to) + file_to.close() + self.onNewService() + for item in items: + serviceitem = ServiceItem() + serviceitem.RenderManager = self.parent.RenderManager + serviceitem.set_from_service(item, self.servicePath) + self.validateItem(serviceitem) + self.addServiceItem(serviceitem) + try: + if os.path.isfile(p_file): + os.remove(p_file) + except (IOError, OSError): + log.exception(u'Failed to remove osd file') + else: + QtGui.QMessageBox.critical( + self, translate(u'ServiceManager', u'Error'), + translate(u'ServiceManager', + u'File is not a valid service.')) + log.exception(u'File contains no service data') except IOError: log.exception(u'Problem loading a service file') finally: diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 3a96279f5..64261511d 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -562,8 +562,7 @@ class SlideController(QtGui.QWidget): if self.isLive and frame[u'verseTag'] is not None: if tag1 not in self.slideList: self.slideList[tag1] = framenumber - self.SongMenu.menu().addAction( - translate(u'SlideController', u'%s'%tag1), + self.SongMenu.menu().addAction(tag1, self.onSongBarHandler) item.setText(frame[u'text']) else: diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index f1d5ece34..9c1ad8653 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -131,8 +131,8 @@ class ThemeManager(QtGui.QWidget): self.ThemeListWidget.item(count).setText(newName) #Set the new name if themeName == newName: - name = u'%s (%s)' % (newName, - translate(u'ThemeManager', u'default')) + name = unicode(translate(u'ThemeManager', u'%s (default)')) % \ + newName self.ThemeListWidget.item(count).setText(name) def changeGlobalFromScreen(self, index = -1): @@ -149,8 +149,8 @@ class ThemeManager(QtGui.QWidget): if count == selected_row: self.global_theme = unicode( self.ThemeListWidget.item(count).text()) - name = u'%s (%s)' % (self.global_theme, - translate(u'ThemeManager', u'default')) + name = unicode(translate(u'ThemeManager', u'%s (default)')) % \ + self.global_theme self.ThemeListWidget.item(count).setText(name) QtCore.QSettings().setValue( self.settingsSection + u'/global theme', @@ -246,8 +246,8 @@ class ThemeManager(QtGui.QWidget): for files in os.walk(source)[2]: for name in files: zip.write( - os.path.join(source, name), - os.path.join(theme, name)) + os.path.join(source, name).encode(u'utf-8'), + os.path.join(theme, name).encode(u'utf-8')) except (IOError, OSError): log.exception(u'Export Theme Failed') finally: @@ -284,8 +284,8 @@ class ThemeManager(QtGui.QWidget): if os.path.exists(theme): textName = os.path.splitext(name)[0] if textName == self.global_theme: - name = u'%s (%s)' % (textName, - translate(u'ThemeManager', u'default')) + name = unicode(translate(u'ThemeManager', + u'%s (default)')) % textName else: name = textName thumb = os.path.join(self.thumbPath, u'%s.png' % textName) @@ -338,7 +338,17 @@ class ThemeManager(QtGui.QWidget): filexml = None themename = None for file in zip.namelist(): - osfile = unicode(QtCore.QDir.toNativeSeparators(file)) + try: + ucsfile = file.decode(u'utf-8') + except UnicodeDecodeError: + QtGui.QMessageBox.critical( + self, translate(u'ThemeManager', u'Error'), + translate(u'ThemeManager', u'File is not a valid ' + u'theme.\nThe content encoding is not UTF-8.')) + log.exception(u'Filename "%s" is no valid UTF-8' % \ + file.decode(u'utf-8', u'replace')) + continue + osfile = unicode(QtCore.QDir.toNativeSeparators(ucsfile)) theme_dir = None if osfile.endswith(os.path.sep): theme_dir = os.path.join(dir, osfile) @@ -356,7 +366,7 @@ class ThemeManager(QtGui.QWidget): if not os.path.exists(theme_dir): os.mkdir(os.path.join(dir, names[0])) xml_data = zip.read(file) - if os.path.splitext(file)[1].lower() in [u'.xml']: + if os.path.splitext(ucsfile)[1].lower() in [u'.xml']: if self.checkVersion1(xml_data): # upgrade theme xml filexml = self.migrateVersion122(filename, @@ -368,7 +378,13 @@ class ThemeManager(QtGui.QWidget): else: outfile = open(fullpath, u'wb') outfile.write(zip.read(file)) - self.generateAndSaveImage(dir, themename, filexml) + if filexml: + self.generateAndSaveImage(dir, themename, filexml) + else: + QtGui.QMessageBox.critical( + self, translate(u'ThemeManager', u'Error'), + translate(u'ThemeManager', u'File is not a valid theme.')) + log.exception(u'Theme file dosen\'t contain XML data %s' % filename) except IOError: QtGui.QMessageBox.critical( self, translate(u'ThemeManager', u'Error'), diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index d23bcd298..b8b2e905f 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -504,7 +504,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): def onCopyrightInsertButtonTriggered(self): text = self.CopyrightEditItem.text() pos = self.CopyrightEditItem.cursorPosition() - text = text[:pos] + u'©' + text[pos:] + text = text[:pos] + u'\xa9' + text[pos:] self.CopyrightEditItem.setText(text) self.CopyrightEditItem.setFocus() self.CopyrightEditItem.setCursorPosition(pos + 1) diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index fa016729d..2d0d7807f 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -66,7 +66,7 @@ class SongImport(object): self.copyright_string = unicode(QtGui.QApplication.translate( \ u'SongsPlugin.SongImport', u'copyright')) self.copyright_symbol = unicode(QtGui.QApplication.translate( \ - u'SongsPlugin.SongImport', u'©')) + u'SongsPlugin.SongImport', u'\xa9')) @staticmethod def process_songs_text(manager, text):