From 69b98a44e852f0adf5b9c72af8100e926edc8257 Mon Sep 17 00:00:00 2001 From: M2j Date: Mon, 7 Jun 2010 11:37:27 +0200 Subject: [PATCH 01/44] fix for image names --- openlp/plugins/images/lib/mediaitem.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 081671fa9..a3b0a1050 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -117,12 +117,13 @@ class ImageMediaItem(MediaManagerItem): if items: for item in items: text = self.ListView.item(item.row()) - try: - os.remove( - os.path.join(self.servicePath, unicode(text.text()))) - except OSError: - #if not present do not worry - pass + if text: + try: + os.remove( + os.path.join(self.servicePath, unicode(text.text()))) + except OSError: + #if not present do not worry + pass self.ListView.takeItem(item.row()) SettingsManager.set_list(self.settingsSection, self.settingsSection, self.getFileList()) From 62d7649e2baae261f460ae689b02ba5280c4b4ef Mon Sep 17 00:00:00 2001 From: M2j Date: Tue, 8 Jun 2010 15:47:23 +0200 Subject: [PATCH 02/44] reenable verses without number in the verse order --- openlp/plugins/songs/lib/mediaitem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index f400d865d..6716cf6b8 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -329,8 +329,8 @@ class SongMediaItem(MediaManagerItem): if len(order) == 0: break for verse in verseList: - if verse[0][u'label'] == order[1:] and \ - verse[0][u'type'][0] == order[0]: + if verse[0][u'type'][0] == order[0] and \ + (verse[0][u'label'] == order[1:] or not order[1:]): verseTag = u'%s:%s' % \ (verse[0][u'type'], verse[0][u'label']) service_item.add_from_text\ From f5b02659b6c064dfc2bf248ba1c1594c52cd7901 Mon Sep 17 00:00:00 2001 From: Frode Woldsund Date: Wed, 9 Jun 2010 13:11:01 +0200 Subject: [PATCH 03/44] Replaces missed trUtf8('...') -> translate(u'PluginName.ClassName', '...') --- openlp/core/lib/mediamanageritem.py | 72 ++++++++++++--------- openlp/core/ui/splashscreen.py | 5 +- openlp/plugins/bibles/bibleplugin.py | 6 +- openlp/plugins/songs/songsplugin.py | 46 +++++++------ openlp/plugins/songusage/songusageplugin.py | 21 ++++-- 5 files changed, 92 insertions(+), 58 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 8bfefceb0..f7b574be1 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -30,7 +30,7 @@ import os from PyQt4 import QtCore, QtGui from openlp.core.lib import contextMenuAction, contextMenuSeparator, \ - SettingsManager, OpenLPToolbar, ServiceItem, build_icon + SettingsManager, OpenLPToolbar, ServiceItem, build_icon, translate log = logging.getLogger(__name__) @@ -210,49 +210,54 @@ class MediaManagerItem(QtGui.QWidget): if self.hasImportIcon: self.addToolbarButton( u'Import %s' % self.PluginNameShort, - u'%s %s' % (self.trUtf8('Import a'), self.PluginNameVisible), + u'%s %s' % (translate(u'MediaManagerItem', u'Import a'), + self.PluginNameVisible), u':/general/general_import.png', self.onImportClick) ## File Button ## if self.hasFileIcon: self.addToolbarButton( u'Load %s' % self.PluginNameShort, - u'%s %s' % (self.trUtf8('Load a new'), self.PluginNameVisible), + u'%s %s' % (translate(u'MediaManagerItem', u'Load a new'), + self.PluginNameVisible), u':/general/general_open.png', self.onFileClick) ## New Button ## if self.hasNewIcon: self.addToolbarButton( u'New %s' % self.PluginNameShort, - u'%s %s' % (self.trUtf8('Add a new'), self.PluginNameVisible), + u'%s %s' % (translate(u'MediaManagerItem', u'Add a new'), + self.PluginNameVisible), u':/general/general_new.png', self.onNewClick) ## Edit Button ## if self.hasEditIcon: self.addToolbarButton( u'Edit %s' % self.PluginNameShort, - u'%s %s' % (self.trUtf8('Edit the selected'), + u'%s %s' % ( + translate(u'MediaManagerItem', u'Edit the selected'), self.PluginNameVisible), u':/general/general_edit.png', self.onEditClick) ## Delete Button ## if self.hasDeleteIcon: self.addToolbarButton( u'Delete %s' % self.PluginNameShort, - self.trUtf8('Delete the selected item'), + translate(u'MediaManagerItem', u'Delete the selected item'), u':/general/general_delete.png', self.onDeleteClick) ## Separator Line ## self.addToolbarSeparator() ## Preview ## self.addToolbarButton( u'Preview %s' % self.PluginNameShort, - self.trUtf8('Preview the selected item'), + translate(u'MediaManagerItem', u'Preview the selected item'), u':/general/general_preview.png', self.onPreviewClick) ## Live Button ## self.addToolbarButton( u'Go Live', - self.trUtf8('Send the selected item live'), + translate(u'MediaManagerItem', u'Send the selected item live'), u':/general/general_live.png', self.onLiveClick) ## Add to service Button ## self.addToolbarButton( u'Add %s to Service' % self.PluginNameShort, - self.trUtf8('Add the selected item(s) to the service'), + translate(u'MediaManagerItem', + u'Add the selected item(s) to the service'), u':/general/general_add.png', self.onAddClick) def addListViewToToolBar(self): @@ -274,34 +279,39 @@ class MediaManagerItem(QtGui.QWidget): self.ListView.addAction( contextMenuAction( self.ListView, u':/general/general_edit.png', - u'%s %s' % (self.trUtf8('&Edit'), self.PluginNameVisible), + u'%s %s' % (translate(u'MediaManagerItem', u'&Edit'), + self.PluginNameVisible), self.onEditClick)) self.ListView.addAction(contextMenuSeparator(self.ListView)) if self.hasDeleteIcon: self.ListView.addAction( contextMenuAction( self.ListView, u':/general/general_delete.png', - u'%s %s' % (self.trUtf8('&Delete'), self.PluginNameVisible), + u'%s %s' % (translate(u'MediaManagerItem', u'&Delete'), + self.PluginNameVisible), self.onDeleteClick)) self.ListView.addAction(contextMenuSeparator(self.ListView)) self.ListView.addAction( contextMenuAction( self.ListView, u':/general/general_preview.png', - u'%s %s' % (self.trUtf8('&Preview'), self.PluginNameVisible), + u'%s %s' % (translate(u'MediaManagerItem', u'&Preview'), + self.PluginNameVisible), self.onPreviewClick)) self.ListView.addAction( contextMenuAction( self.ListView, u':/general/general_live.png', - self.trUtf8('&Show Live'), self.onLiveClick)) + translate(u'MediaManagerItem', u'&Show Live'), self.onLiveClick)) self.ListView.addAction( contextMenuAction( self.ListView, u':/general/general_add.png', - self.trUtf8('&Add to Service'), self.onAddClick)) + translate(u'MediaManagerItem', u'&Add to Service'), + self.onAddClick)) if self.addToServiceItem: self.ListView.addAction( contextMenuAction( self.ListView, u':/general/general_add.png', - self.trUtf8('&Add to selected Service Item'), + translate(u'MediaManagerItem', + u'&Add to selected Service Item'), self.onAddEditClick)) QtCore.QObject.connect( self.ListView, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), @@ -394,8 +404,9 @@ class MediaManagerItem(QtGui.QWidget): def onPreviewClick(self): if not self.ListView.selectedIndexes() and not self.remoteTriggered: QtGui.QMessageBox.information(self, - self.trUtf8('No Items Selected'), - self.trUtf8('You must select one or more items.')) + translate(u'MediaManagerItem', u'No Items Selected'), + translate(u'MediaManagerItem', + u'You must select one or more items.')) else: log.debug(self.PluginNameShort + u' Preview requested') service_item = self.buildServiceItem() @@ -406,8 +417,9 @@ class MediaManagerItem(QtGui.QWidget): def onLiveClick(self): if not self.ListView.selectedIndexes(): QtGui.QMessageBox.information(self, - self.trUtf8('No Items Selected'), - self.trUtf8('You must select one or more items.')) + translate(u'MediaManagerItem', u'No Items Selected'), + translate(u'MediaManagerItem', + u'You must select one or more items.')) else: log.debug(self.PluginNameShort + u' Live requested') service_item = self.buildServiceItem() @@ -418,8 +430,9 @@ class MediaManagerItem(QtGui.QWidget): def onAddClick(self): if not self.ListView.selectedIndexes() and not self.remoteTriggered: QtGui.QMessageBox.information(self, - self.trUtf8('No Items Selected'), - self.trUtf8('You must select one or more items.')) + translate(u'MediaManagerItem', u'No Items Selected'), + translate(u'MediaManagerItem', + u'You must select one or more items.')) else: #Is it posssible to process multiple list items to generate multiple #service items? @@ -441,16 +454,17 @@ class MediaManagerItem(QtGui.QWidget): def onAddEditClick(self): if not self.ListView.selectedIndexes() and not self.remoteTriggered: QtGui.QMessageBox.information(self, - self.trUtf8('No items selected'), - self.trUtf8('You must select one or more items')) + translate(u'MediaManagerItem', u'No items selected'), + translate(u'MediaManagerItem', + u'You must select one or more items')) else: log.debug(self.PluginNameShort + u' Add requested') service_item = self.parent.service_manager.getServiceItem() if not service_item: QtGui.QMessageBox.information(self, - self.trUtf8('No Service Item Selected'), - self.trUtf8( - 'You must select an existing service item to add to.')) + translate(u'MediaManagerItem', u'No Service Item Selected'), + translate(u'MediaManagerItem', + u'You must select an existing service item to add to.')) elif self.title.lower() == service_item.name.lower(): self.generateSlideData(service_item) self.parent.service_manager.addServiceItem(service_item, @@ -458,9 +472,9 @@ class MediaManagerItem(QtGui.QWidget): else: #Turn off the remote edit update message indicator QtGui.QMessageBox.information(self, - self.trUtf8('Invalid Service Item'), - self.trUtf8(unicode( - 'You must select a %s service item.' % self.title))) + translate(u'MediaManagerItem', u'Invalid Service Item'), + translate(unicode(u'MediaManagerItem', + u'You must select a %s service item.' % self.title))) def buildServiceItem(self, item=None): """ diff --git a/openlp/core/ui/splashscreen.py b/openlp/core/ui/splashscreen.py index 10cea5a11..b13c3c8c4 100644 --- a/openlp/core/ui/splashscreen.py +++ b/openlp/core/ui/splashscreen.py @@ -30,7 +30,8 @@ class SplashScreen(object): def __init__(self, version): self.splash_screen = QtGui.QSplashScreen() self.setupUi() - self.message = self.splash_screen.trUtf8('Starting')\ + self.message = self.splash_screen.translate( + u'Splashscreen', u'Starting')\ + '..... ' + version def setupUi(self): @@ -58,7 +59,7 @@ class SplashScreen(object): def retranslateUi(self): self.splash_screen.setWindowTitle( - self.splash_screen.trUtf8('Splash Screen')) + self.splash_screen.translate(u'Splashscreen', u'Splash Screen')) def show(self): self.splash_screen.show() diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index ca018cabd..cfc6aa361 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -70,7 +70,8 @@ class BiblePlugin(Plugin): self.ImportBibleItem = QtGui.QAction(import_menu) self.ImportBibleItem.setObjectName(u'ImportBibleItem') import_menu.addAction(self.ImportBibleItem) - self.ImportBibleItem.setText(import_menu.trUtf8('&Bible')) + self.ImportBibleItem.setText( + import_menu.translate(u'BiblesPlugin.BiblePlugin', u'&Bible')) # Signals and slots QtCore.QObject.connect(self.ImportBibleItem, QtCore.SIGNAL(u'triggered()'), self.onBibleImportClick) @@ -80,7 +81,8 @@ class BiblePlugin(Plugin): self.ExportBibleItem = QtGui.QAction(export_menu) self.ExportBibleItem.setObjectName(u'ExportBibleItem') export_menu.addAction(self.ExportBibleItem) - self.ExportBibleItem.setText(export_menu.trUtf8('&Bible')) + self.ExportBibleItem.setText(export_menu.translate( + u'BiblesPlugin.BiblePlugin', u'&Bible')) self.ExportBibleItem.setVisible(False) def onBibleImportClick(self): diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 993b18bb9..f311d7072 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -94,36 +94,44 @@ class SongsPlugin(Plugin): # Main song import menu item - will eventually be the only one self.SongImportItem = QtGui.QAction(import_menu) self.SongImportItem.setObjectName(u'SongImportItem') - self.SongImportItem.setText(import_menu.trUtf8('&Song')) + self.SongImportItem.setText(import_menu.translate( + u'SongsPlugin.SongsPlugin', u'&Song')) self.SongImportItem.setToolTip( - import_menu.trUtf8('Import songs using the import wizard.')) + import_menu.translate(u'SongsPlugin.SongsPlugin', + u'Import songs using the import wizard.')) import_menu.addAction(self.SongImportItem) # Songs of Fellowship import menu item - will be removed and the # functionality will be contained within the import wizard self.ImportSofItem = QtGui.QAction(import_menu) self.ImportSofItem.setObjectName(u'ImportSofItem') self.ImportSofItem.setText( - import_menu.trUtf8('Songs of Fellowship (temp menu item)')) + import_menu.translate(u'SongsPlugin.SongsPlugin', + u'Songs of Fellowship (temp menu item)')) self.ImportSofItem.setToolTip( - import_menu.trUtf8('Import songs from the VOLS1_2.RTF, sof3words' \ - + '.rtf and sof4words.rtf supplied with the music books')) + import_menu.translate(u'SongsPlugin.SongsPlugin', + u'Import songs from the VOLS1_2.RTF, sof3words' \ + + u'.rtf and sof4words.rtf supplied with the music books')) self.ImportSofItem.setStatusTip( - import_menu.trUtf8('Import songs from the VOLS1_2.RTF, sof3words' \ - + '.rtf and sof4words.rtf supplied with the music books')) + import_menu.translate(u'SongsPlugin.SongsPlugin', + u'Import songs from the VOLS1_2.RTF, sof3words' \ + + u'.rtf and sof4words.rtf supplied with the music books')) import_menu.addAction(self.ImportSofItem) # OpenOffice.org import menu item - will be removed and the # functionality will be contained within the import wizard self.ImportOooItem = QtGui.QAction(import_menu) self.ImportOooItem.setObjectName(u'ImportOooItem') self.ImportOooItem.setText( - import_menu.trUtf8('Generic Document/Presentation Import ' - '(temp menu item)')) + import_menu.translate(u'SongsPlugin.SongsPlugin', + u'Generic Document/Presentation Import ' + u'(temp menu item)')) self.ImportOooItem.setToolTip( - import_menu.trUtf8('Import songs from ' - 'Word/Writer/Powerpoint/Impress')) + import_menu.translate(u'SongsPlugin.SongsPlugin', + u'Import songs from ' + u'Word/Writer/Powerpoint/Impress')) self.ImportOooItem.setStatusTip( - import_menu.trUtf8('Import songs from ' - 'Word/Writer/Powerpoint/Impress')) + import_menu.translate(u'SongsPlugin.SongsPlugin', + u'Import songs from ' + u'Word/Writer/Powerpoint/Impress')) import_menu.addAction(self.ImportOooItem) # Signals and slots QtCore.QObject.connect(self.SongImportItem, @@ -161,11 +169,13 @@ class SongsPlugin(Plugin): except: log.exception('Could not import SoF file') QtGui.QMessageBox.critical(None, - self.ImportSongMenu.trUtf8('Import Error'), - self.ImportSongMenu.trUtf8('Error importing Songs of ' - 'Fellowship file.\nOpenOffice.org must be installed' - ' and you must be using an unedited copy of the RTF' - ' included with the Songs of Fellowship Music Editions'), + self.ImportSongMenu.translate(u'SongsPlugin.SongsPlugin', + u'Import Error'), + self.ImportSongMenu.translate(u'SongsPlugin.SongsPlugin', + u'Error importing Songs of ' + u'Fellowship file.\nOpenOffice.org must be installed' + u' and you must be using an unedited copy of the RTF' + u' included with the Songs of Fellowship Music Editions'), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok), QtGui.QMessageBox.Ok) Receiver.send_message(u'songs_load_list') diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index 6cbb08e1a..35d86a16a 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -59,20 +59,25 @@ class SongUsagePlugin(Plugin): self.toolsMenu = tools_menu self.SongUsageMenu = QtGui.QMenu(tools_menu) self.SongUsageMenu.setObjectName(u'SongUsageMenu') - self.SongUsageMenu.setTitle(tools_menu.trUtf8('&Song Usage')) + self.SongUsageMenu.setTitle(tools_menu.translate( + u'SongUsagePlugin.SongUsagePlugin', u'&Song Usage')) #SongUsage Delete self.SongUsageDelete = QtGui.QAction(tools_menu) self.SongUsageDelete.setText( - tools_menu.trUtf8('&Delete recorded data')) + tools_menu.translate(u'SongUsagePlugin.SongUsagePlugin', + u'&Delete recorded data')) self.SongUsageDelete.setStatusTip( - tools_menu.trUtf8('Delete song usage to specified date')) + tools_menu.translate(u'SongUsagePlugin.SongUsagePlugin', + u'Delete song usage to specified date')) self.SongUsageDelete.setObjectName(u'SongUsageDelete') #SongUsage Report self.SongUsageReport = QtGui.QAction(tools_menu) self.SongUsageReport.setText( - tools_menu.trUtf8('&Extract recorded data')) + tools_menu.translate(u'SongUsagePlugin.SongUsagePlugin', + u'&Extract recorded data')) self.SongUsageReport.setStatusTip( - tools_menu.trUtf8('Generate report on Song Usage')) + tools_menu.translate(u'SongUsagePlugin.SongUsagePlugin', + u'Generate report on Song Usage')) self.SongUsageReport.setObjectName(u'SongUsageReport') #SongUsage activation SongUsageIcon = build_icon(u':/tools/tools_alert.png') @@ -80,9 +85,11 @@ class SongUsagePlugin(Plugin): self.SongUsageStatus.setIcon(SongUsageIcon) self.SongUsageStatus.setCheckable(True) self.SongUsageStatus.setChecked(False) - self.SongUsageStatus.setText(tools_menu.trUtf8('Song Usage Status')) + self.SongUsageStatus.setText(tools_menu.translate( + u'SongUsagePlugin.SongUsagePlugin', u'Song Usage Status')) self.SongUsageStatus.setStatusTip( - tools_menu.trUtf8('Start/Stop live song usage recording')) + tools_menu.translate(u'SongUsagePlugin.SongUsagePlugin', + u'Start/Stop live song usage recording')) self.SongUsageStatus.setShortcut(u'F4') self.SongUsageStatus.setObjectName(u'SongUsageStatus') #Add Menus together From 940c6fd44f85ce905f16943cd5ba43f9a7474982 Mon Sep 17 00:00:00 2001 From: M2j Date: Wed, 9 Jun 2010 21:10:57 +0200 Subject: [PATCH 04/44] Set theme and service file content to UTF-8 Replaced replaced all non-ASCII chars in the sources (exept of comments) Fixed theme background images bug --- openlp/core/ui/aboutform.py | 4 +- openlp/core/ui/amendthemeform.py | 2 +- openlp/core/ui/mainwindow.py | 4 +- openlp/core/ui/servicemanager.py | 54 ++++++++++++++-------- openlp/core/ui/slidecontroller.py | 3 +- openlp/core/ui/thememanager.py | 38 ++++++++++----- openlp/plugins/songs/forms/editsongform.py | 2 +- openlp/plugins/songs/lib/songimport.py | 2 +- 8 files changed, 71 insertions(+), 38 deletions(-) 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): From 8296b8dc84dab179c178ff4927669df8a5a935c2 Mon Sep 17 00:00:00 2001 From: M2j Date: Wed, 9 Jun 2010 23:15:37 +0200 Subject: [PATCH 05/44] Additional translatable strings Removed string_to_unicode and variant_to_unicode --- openlp/core/lib/__init__.py | 4 +-- openlp/core/lib/mediamanageritem.py | 2 +- openlp/core/lib/renderer.py | 2 +- openlp/core/ui/pluginform.py | 11 ++++--- openlp/core/utils/__init__.py | 21 ------------ .../plugins/bibles/forms/importwizardform.py | 32 +++++++++---------- openlp/plugins/bibles/lib/mediaitem.py | 2 +- openlp/plugins/images/lib/mediaitem.py | 4 +-- openlp/plugins/media/lib/mediaitem.py | 4 +-- openlp/plugins/presentations/lib/mediaitem.py | 4 +-- openlp/plugins/songs/forms/editsongform.py | 8 ++--- openlp/plugins/songs/forms/songimportform.py | 16 +++++----- 12 files changed, 45 insertions(+), 65 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index d5b46e6cb..7ecffbe5b 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -80,9 +80,9 @@ def str_to_bool(stringvalue): ``stringvalue`` The string value to examine and convert to a boolean type. """ - if stringvalue is True or stringvalue is False: + if isinstance(stringvalue, bool): return stringvalue - return stringvalue.strip().lower() in (u'true', u'yes', u'y') + return unicode(stringvalue).strip().lower() in (u'true', u'yes', u'y') def build_icon(icon): """ diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 8bfefceb0..7804b3d1b 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -345,7 +345,7 @@ class MediaManagerItem(QtGui.QWidget): filelist = [] while count < self.ListView.count(): bitem = self.ListView.item(count) - filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) + filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) filelist.append(filename) count += 1 return filelist diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 55700ebac..eab0e4d60 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -468,7 +468,7 @@ class Renderer(object): self._get_extent_and_render(line, footer, tlcorner=(x + display_shadow_size, y + display_shadow_size), - draw=True, color = self._theme.display_shadow_color) + draw=True, color=self._theme.display_shadow_color) self._get_extent_and_render(line, footer, tlcorner=(x, y), draw=True, outline_size=display_outline_size) y += h diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index 9969ed165..7100a19a4 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -27,6 +27,7 @@ import logging from PyQt4 import QtCore, QtGui +from openlp.core.lib import translate from openlp.core.lib.plugin import PluginStatus from plugindialog import Ui_PluginViewDialog @@ -63,14 +64,14 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): # sometimes when it's loaded from the config, it isn't cast to int. plugin.status = int(plugin.status) # Set the little status text in brackets next to the plugin name. - status_text = 'Inactive' + status_text = unicode(translate(u'PluginForm', u'%s (Inactive)')) if plugin.status == PluginStatus.Active: - status_text = 'Active' + status_text = unicode(translate(u'PluginForm', u'%s (Active)')) elif plugin.status == PluginStatus.Inactive: - status_text = 'Inactive' + status_text = unicode(translate(u'PluginForm', u'%s (Inactive)')) elif plugin.status == PluginStatus.Disabled: - status_text = 'Disabled' - item.setText(u'%s (%s)' % (plugin.name, status_text)) + status_text = unicode(translate(u'PluginForm', u'%s (Disabled)')) + item.setText(status_text % plugin.name) # If the plugin has an icon, set it! if plugin.icon: item.setIcon(plugin.icon) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 8cbf7657a..00e9c7d6b 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -146,27 +146,6 @@ def check_latest_version(current_version): log.exception(u'Reason for failure: %s', e.reason) return version_string -def string_to_unicode(string): - """ - Converts a QString to a Python unicode object. - """ - if isinstance(string, QtCore.QString): - string = unicode(string.toUtf8(), u'utf8') - return string - -def variant_to_unicode(variant): - """ - Converts a QVariant to a Python unicode object. - - ``variant`` - The QVariant instance to convert to unicode. - """ - if isinstance(variant, QtCore.QVariant): - string = variant.toString() - if not isinstance(string, unicode): - string = string_to_unicode(string) - return string - def add_actions(target, actions): """ Adds multiple actions to a menu or toolbar in one command. diff --git a/openlp/plugins/bibles/forms/importwizardform.py b/openlp/plugins/bibles/forms/importwizardform.py index b1eafcd61..c312b36ec 100644 --- a/openlp/plugins/bibles/forms/importwizardform.py +++ b/openlp/plugins/bibles/forms/importwizardform.py @@ -32,7 +32,7 @@ from PyQt4 import QtCore, QtGui from bibleimportwizard import Ui_BibleImportWizard from openlp.core.lib import Receiver, SettingsManager, translate -from openlp.core.utils import AppLocation, variant_to_unicode +from openlp.core.utils import AppLocation from openlp.plugins.bibles.lib.manager import BibleFormat log = logging.getLogger(__name__) @@ -167,9 +167,9 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): return True elif self.currentId() == 2: # License details - license_version = variant_to_unicode(self.field(u'license_version')) - license_copyright = variant_to_unicode( - self.field(u'license_copyright')) + license_version = unicode(self.field(u'license_version').toString()) + license_copyright = \ + unicode(self.field(u'license_copyright').toString()) if license_version == u'': QtGui.QMessageBox.critical(self, translate(u'BiblesPlugin.ImportWizardForm', @@ -391,29 +391,29 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): def performImport(self): bible_type = self.field(u'source_format').toInt()[0] - license_version = variant_to_unicode(self.field(u'license_version')) - license_copyright = variant_to_unicode(self.field(u'license_copyright')) - license_permission = variant_to_unicode( - self.field(u'license_permission')) + license_version = unicode(self.field(u'license_version').toString()) + license_copyright = unicode(self.field(u'license_copyright').toString()) + license_permission = \ + unicode(self.field(u'license_permission').toString()) importer = None if bible_type == BibleFormat.OSIS: # Import an OSIS bible importer = self.manager.import_bible(BibleFormat.OSIS, name=license_version, - filename=variant_to_unicode(self.field(u'osis_location')) + filename=unicode(self.field(u'osis_location').toString()) ) elif bible_type == BibleFormat.CSV: # Import a CSV bible importer = self.manager.import_bible(BibleFormat.CSV, name=license_version, - booksfile=variant_to_unicode(self.field(u'csv_booksfile')), - versefile=variant_to_unicode(self.field(u'csv_versefile')) + booksfile=unicode(self.field(u'csv_booksfile').toString()), + versefile=unicode(self.field(u'csv_versefile').toString()) ) elif bible_type == BibleFormat.OpenSong: # Import an OpenSong bible importer = self.manager.import_bible(BibleFormat.OpenSong, name=license_version, - filename=variant_to_unicode(self.field(u'opensong_file')) + filename=unicode(self.field(u'opensong_file').toString()) ) elif bible_type == BibleFormat.WebDownload: # Import a bible from the web @@ -433,10 +433,10 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): name=license_version, download_source=WebDownload.get_name(download_location), download_name=bible, - proxy_server=variant_to_unicode(self.field(u'proxy_server')), - proxy_username=variant_to_unicode( - self.field(u'proxy_username')), - proxy_password=variant_to_unicode(self.field(u'proxy_password')) + proxy_server=unicode(self.field(u'proxy_server').toString()), + proxy_username=\ + unicode(self.field(u'proxy_username').toString()), + proxy_password=unicode(self.field(u'proxy_password').toString()) ) success = importer.do_import() if success: diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index d922cb446..6c5f21f23 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -454,7 +454,7 @@ class BibleMediaItem(MediaManagerItem): def onQuickSearchButton(self): log.debug(u'Quick Search Button pressed') bible = unicode(self.QuickVersionComboBox.currentText()) - text = unicode(self.QuickSearchEdit.displayText()) + text = unicode(self.QuickSearchEdit.text()) if self.ClearQuickSearchComboBox.currentIndex() == 0: self.ListView.clear() self.lastReference = [] diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index f846e102f..5abf080bf 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -158,7 +158,7 @@ class ImageMediaItem(MediaManagerItem): service_item.add_capability(ItemCapabilities.AllowsAdditions) for item in items: bitem = self.ListView.item(item.row()) - filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) + filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) frame = QtGui.QImage(unicode(filename)) (path, name) = os.path.split(filename) service_item.add_from_image(path, name, frame) @@ -175,7 +175,7 @@ class ImageMediaItem(MediaManagerItem): items = self.ListView.selectedIndexes() for item in items: bitem = self.ListView.item(item.row()) - filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) + filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) frame = QtGui.QImage(unicode(filename)) self.parent.maindisplay.addImageWithText(frame) diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index dc3cc837e..dd64658cc 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -112,7 +112,7 @@ class MediaMediaItem(MediaManagerItem): items = self.ListView.selectedIndexes() for item in items: bitem = self.ListView.item(item.row()) - filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) + filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) Receiver.send_message(u'videodisplay_background', filename) def generateSlideData(self, service_item, item=None): @@ -120,7 +120,7 @@ class MediaMediaItem(MediaManagerItem): item = self.ListView.currentItem() if item is None: return False - filename = unicode((item.data(QtCore.Qt.UserRole)).toString()) + filename = unicode(item.data(QtCore.Qt.UserRole).toString()) service_item.title = unicode( translate(u'MediaPlugin.MediaItem', u'Media')) service_item.add_capability(ItemCapabilities.RequiresMedia) diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 54c6a9488..be2cecff4 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -180,7 +180,7 @@ class PresentationMediaItem(MediaManagerItem): self.ListView.takeItem(row) SettingsManager.set_list(self.settingsSection, self.settingsSection, self.getFileList()) - filepath = unicode((item.data(QtCore.Qt.UserRole)).toString()) + filepath = unicode(item.data(QtCore.Qt.UserRole).toString()) #not sure of this has errors #John please can you look at . for cidx in self.controllers: @@ -198,7 +198,7 @@ class PresentationMediaItem(MediaManagerItem): if shortname: for item in items: bitem = self.ListView.item(item.row()) - filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) + filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) if shortname == self.Automatic: service_item.shortname = self.findControllerByType(filename) if not service_item.shortname: diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index b8b2e905f..e6c162d0b 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -291,7 +291,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): rowLabel = [] for row in range(0, self.VerseListWidget.rowCount()): item = self.VerseListWidget.item(row, 0) - data = unicode((item.data(QtCore.Qt.UserRole)).toString()) + data = unicode(item.data(QtCore.Qt.UserRole).toString()) bit = data.split(u':') rowTag = u'%s\n%s' % (bit[0][0:1], bit[1]) rowLabel.append(rowTag) @@ -382,7 +382,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): item = self.VerseListWidget.currentItem() if item: tempText = item.text() - verseId = unicode((item.data(QtCore.Qt.UserRole)).toString()) + verseId = unicode(item.data(QtCore.Qt.UserRole).toString()) self.verse_form.setVerse(tempText, True, verseId) if self.verse_form.exec_(): afterText, verse, subVerse = self.verse_form.getVerse() @@ -413,7 +413,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): if self.VerseListWidget.rowCount() > 0: for row in range(0, self.VerseListWidget.rowCount()): item = self.VerseListWidget.item(row, 0) - field = unicode((item.data(QtCore.Qt.UserRole)).toString()) + field = unicode(item.data(QtCore.Qt.UserRole).toString()) verse_list += u'---[%s]---\n' % field verse_list += item.text() verse_list += u'\n' @@ -562,7 +562,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): text = u' ' for i in range (0, self.VerseListWidget.rowCount()): item = self.VerseListWidget.item(i, 0) - verseId = unicode((item.data(QtCore.Qt.UserRole)).toString()) + verseId = unicode(item.data(QtCore.Qt.UserRole).toString()) bits = verseId.split(u':') sxml.add_verse_to_lyrics(bits[0], bits[1], unicode(item.text())) text = text + unicode(self.VerseListWidget.item(i, 0).text()) \ diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 75659da70..b4bb9f4b0 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -29,7 +29,7 @@ from PyQt4 import QtCore, QtGui from songimportwizard import Ui_SongImportWizard from openlp.core.lib import Receiver, SettingsManager, translate -#from openlp.core.utils import AppLocation, variant_to_unicode +#from openlp.core.utils import AppLocation from openlp.plugins.songs.lib.manager import SongFormat log = logging.getLogger(__name__) @@ -203,20 +203,20 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard): # # Import an OSIS bible # importer = self.manager.import_bible(BibleFormat.OSIS, # name=license_version, -# filename=variant_to_unicode(self.field(u'osis_location')) +# filename=unicode(self.field(u'osis_location').toString()) # ) # elif bible_type == BibleFormat.CSV: # # Import a CSV bible # importer = self.manager.import_bible(BibleFormat.CSV, # name=license_version, -# booksfile=variant_to_unicode(self.field(u'csv_booksfile')), -# versefile=variant_to_unicode(self.field(u'csv_versefile')) +# booksfile=unicode(self.field(u'csv_booksfile').toString()), +# versefile=unicode(self.field(u'csv_versefile').toString()) # ) # elif bible_type == BibleFormat.OpenSong: # # Import an OpenSong bible # importer = self.manager.import_bible(BibleFormat.OpenSong, # name=license_version, -# filename=variant_to_unicode(self.field(u'opensong_file')) +# filename=unicode(self.field(u'opensong_file').toString()) # ) # elif bible_type == BibleFormat.WebDownload: # # Import a bible from the web @@ -234,9 +234,9 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard): # name=license_version, # download_source=WebDownload.get_name(download_location), # download_name=bible, -# proxy_server=variant_to_unicode(self.field(u'proxy_server')), -# proxy_username=variant_to_unicode(self.field(u'proxy_username')), -# proxy_password=variant_to_unicode(self.field(u'proxy_password')) +# proxy_server=unicode(self.field(u'proxy_server').toString()), +# proxy_username=unicode(self.field(u'proxy_username').toString()), +# proxy_password=unicode(self.field(u'proxy_password').toString()) # ) # success = importer.do_import() # if success: From 50f123490f6be17c34003f93c032ddc42d634765 Mon Sep 17 00:00:00 2001 From: M2j Date: Wed, 9 Jun 2010 23:50:55 +0200 Subject: [PATCH 06/44] fix: verses in comboBox of editverseform --- openlp/plugins/songs/forms/__init__.py | 2 ++ openlp/plugins/songs/forms/editverseform.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/forms/__init__.py b/openlp/plugins/songs/forms/__init__.py index a336db465..18b83525b 100644 --- a/openlp/plugins/songs/forms/__init__.py +++ b/openlp/plugins/songs/forms/__init__.py @@ -74,6 +74,8 @@ class VerseType(object): elif verse_type == \ unicode(VerseType.to_string(VerseType.Other)).lower(): return VerseType.Other + else: + return -1 from authorsform import AuthorsForm from topicsform import TopicsForm diff --git a/openlp/plugins/songs/forms/editverseform.py b/openlp/plugins/songs/forms/editverseform.py index 56bb5de91..27ec39aed 100644 --- a/openlp/plugins/songs/forms/editverseform.py +++ b/openlp/plugins/songs/forms/editverseform.py @@ -104,7 +104,7 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): verse_type = match.group(1) verse_number = int(match.group(2)) verse_type_index = VerseType.from_string(verse_type) - if verse_type_index: + if verse_type_index >= 0: self.VerseTypeComboBox.setCurrentIndex(verse_type_index) self.VerseNumberBox.setValue(verse_number) From 88930d3600cd9b65711059cfb32b49ed02081120 Mon Sep 17 00:00:00 2001 From: M2j Date: Thu, 10 Jun 2010 00:18:07 +0200 Subject: [PATCH 07/44] fix: Collecting files for theme export was broken --- openlp/core/ui/thememanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 9c1ad8653..7ba4a351c 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -243,7 +243,7 @@ class ThemeManager(QtGui.QWidget): try: zip = zipfile.ZipFile(themePath, u'w') source = os.path.join(self.path, theme) - for files in os.walk(source)[2]: + for root, dirs, files in os.walk(source): for name in files: zip.write( os.path.join(source, name).encode(u'utf-8'), From b022fef955545d35b9799124da35714a9d017fd2 Mon Sep 17 00:00:00 2001 From: M2j Date: Thu, 10 Jun 2010 01:03:08 +0200 Subject: [PATCH 08/44] combining two import statements --- openlp/core/ui/pluginform.py | 3 +-- openlp/core/ui/thememanager.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index 7100a19a4..faa08b3d7 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -27,8 +27,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate -from openlp.core.lib.plugin import PluginStatus +from openlp.core.lib.plugin import PluginStatus, translate from plugindialog import Ui_PluginViewDialog log = logging.getLogger(__name__) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 7ba4a351c..9c1ad8653 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -243,7 +243,7 @@ class ThemeManager(QtGui.QWidget): try: zip = zipfile.ZipFile(themePath, u'w') source = os.path.join(self.path, theme) - for root, dirs, files in os.walk(source): + for files in os.walk(source)[2]: for name in files: zip.write( os.path.join(source, name).encode(u'utf-8'), From 19ca36f94619037b7f36a1d0dc49ba8f5d6c9fc2 Mon Sep 17 00:00:00 2001 From: M2j Date: Thu, 10 Jun 2010 01:08:12 +0200 Subject: [PATCH 09/44] final fine tuning --- openlp/core/ui/pluginform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index faa08b3d7..db8b0a603 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -27,7 +27,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib.plugin import PluginStatus, translate +from openlp.core.lib import PluginStatus, translate from plugindialog import Ui_PluginViewDialog log = logging.getLogger(__name__) From f51d67cd5129faafd9da3ac969eb8bf471b40e01 Mon Sep 17 00:00:00 2001 From: M2j Date: Thu, 10 Jun 2010 09:59:46 +0200 Subject: [PATCH 10/44] exception and string fix --- openlp/core/ui/servicemanager.py | 4 ++-- openlp/core/ui/thememanager.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 66bee9417..058199efd 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -675,7 +675,7 @@ class ServiceManager(QtGui.QWidget): 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' % \ + log.exception(u'Filename "%s" is not valid UTF-8' % \ file.decode(u'utf-8', u'replace')) continue osfile = unicode(QtCore.QDir.toNativeSeparators(ucsfile)) @@ -710,7 +710,7 @@ class ServiceManager(QtGui.QWidget): translate(u'ServiceManager', u'File is not a valid service.')) log.exception(u'File contains no service data') - except IOError: + except (IOError, NameError): log.exception(u'Problem loading a service file') finally: if file_to: diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 9c1ad8653..8d134eddd 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -345,7 +345,7 @@ class ThemeManager(QtGui.QWidget): 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' % \ + log.exception(u'Filename "%s" is not valid UTF-8' % \ file.decode(u'utf-8', u'replace')) continue osfile = unicode(QtCore.QDir.toNativeSeparators(ucsfile)) @@ -385,7 +385,7 @@ class ThemeManager(QtGui.QWidget): 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: + except (IOError, NameError): QtGui.QMessageBox.critical( self, translate(u'ThemeManager', u'Error'), translate(u'ThemeManager', u'File is not a valid theme.')) From 83968d8194e02d4baab8000c8d5ded3391d2bc67 Mon Sep 17 00:00:00 2001 From: M2j Date: Thu, 10 Jun 2010 10:07:58 +0200 Subject: [PATCH 11/44] fix: QStringList has no pop() methode --- openlp/core/ui/mainwindow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 271a05d23..87077820b 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -851,5 +851,5 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if filename and filename not in self.recentFiles: self.recentFiles.insert(0, QtCore.QString(filename)) while self.recentFiles.count() > recentFileCount: - self.recentFiles.pop() + self.recentFiles.removeLast() From 0229b362afbf3a688726231d23324c73845b441b Mon Sep 17 00:00:00 2001 From: M2j Date: Thu, 10 Jun 2010 11:05:56 +0200 Subject: [PATCH 12/44] phrase verse index decoding more pythonish --- openlp/plugins/songs/forms/__init__.py | 2 -- openlp/plugins/songs/forms/editverseform.py | 7 ++++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/songs/forms/__init__.py b/openlp/plugins/songs/forms/__init__.py index 18b83525b..a336db465 100644 --- a/openlp/plugins/songs/forms/__init__.py +++ b/openlp/plugins/songs/forms/__init__.py @@ -74,8 +74,6 @@ class VerseType(object): elif verse_type == \ unicode(VerseType.to_string(VerseType.Other)).lower(): return VerseType.Other - else: - return -1 from authorsform import AuthorsForm from topicsform import TopicsForm diff --git a/openlp/plugins/songs/forms/editverseform.py b/openlp/plugins/songs/forms/editverseform.py index 27ec39aed..169d06218 100644 --- a/openlp/plugins/songs/forms/editverseform.py +++ b/openlp/plugins/songs/forms/editverseform.py @@ -104,7 +104,7 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): verse_type = match.group(1) verse_number = int(match.group(2)) verse_type_index = VerseType.from_string(verse_type) - if verse_type_index >= 0: + if not isinstance(verse_type_index, NoneType): self.VerseTypeComboBox.setCurrentIndex(verse_type_index) self.VerseNumberBox.setValue(verse_number) @@ -112,8 +112,9 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): tag=u'%s:1' % VerseType.to_string(VerseType.Verse)): if single: verse_type, verse_number = tag.split(u':') - self.VerseTypeComboBox.setCurrentIndex( - VerseType.from_string(verse_type)) + verse_type_index = VerseType.from_string(verse_type) + if not isinstance(verse_type_index, NoneType): + self.VerseTypeComboBox.setCurrentIndex(verse_type_index) self.VerseNumberBox.setValue(int(verse_number)) self.InsertButton.setVisible(False) else: From f8580333bdc15a269d9b0bd5114e3947baae4ff3 Mon Sep 17 00:00:00 2001 From: M2j Date: Thu, 10 Jun 2010 11:10:54 +0200 Subject: [PATCH 13/44] realized too late, that you may not test for NoneType --- openlp/plugins/songs/forms/editverseform.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/forms/editverseform.py b/openlp/plugins/songs/forms/editverseform.py index 169d06218..18fae4dd5 100644 --- a/openlp/plugins/songs/forms/editverseform.py +++ b/openlp/plugins/songs/forms/editverseform.py @@ -104,7 +104,7 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): verse_type = match.group(1) verse_number = int(match.group(2)) verse_type_index = VerseType.from_string(verse_type) - if not isinstance(verse_type_index, NoneType): + if verse_type_index is not None: self.VerseTypeComboBox.setCurrentIndex(verse_type_index) self.VerseNumberBox.setValue(verse_number) @@ -113,7 +113,7 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): if single: verse_type, verse_number = tag.split(u':') verse_type_index = VerseType.from_string(verse_type) - if not isinstance(verse_type_index, NoneType): + if verse_type_index is not None: self.VerseTypeComboBox.setCurrentIndex(verse_type_index) self.VerseNumberBox.setValue(int(verse_number)) self.InsertButton.setVisible(False) From 69c6e0ef02db134c12410d839aede9e9b603f361 Mon Sep 17 00:00:00 2001 From: M2j Date: Thu, 10 Jun 2010 16:42:55 +0200 Subject: [PATCH 14/44] use filesystem char encoding for file operations --- openlp/core/ui/thememanager.py | 11 ++++++++--- openlp/core/utils/__init__.py | 12 +++++++++++- openlp/plugins/bibles/forms/importwizardform.py | 4 +--- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 378664a9e..601cfb7de 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -36,7 +36,7 @@ from openlp.core.theme import Theme from openlp.core.lib import OpenLPToolbar, contextMenuAction, \ ThemeXML, str_to_bool, get_text_file_string, build_icon, Receiver, \ contextMenuSeparator, SettingsManager, translate -from openlp.core.utils import AppLocation +from openlp.core.utils import AppLocation, get_filesystem_encoding log = logging.getLogger(__name__) @@ -211,7 +211,9 @@ class ThemeManager(QtGui.QWidget): try: os.remove(os.path.join(self.path, th)) os.remove(os.path.join(self.thumbPath, th)) - shutil.rmtree(os.path.join(self.path, theme)) + encoding = get_filesystem_encoding() + shutil.rmtree( + os.path.join(self.path, theme).encode(encoding)) except OSError: #if not present do not worry pass @@ -495,7 +497,10 @@ class ThemeManager(QtGui.QWidget): outfile.close() if image_from and image_from != image_to: try: - shutil.copyfile(image_from, image_to) + encoding = get_filesystem_encoding() + shutil.copyfile( + unicode(image_from).encode(encoding), + unicode(image_to).encode(encoding)) except IOError: log.exception(u'Failed to save theme image') self.generateAndSaveImage(self.path, name, theme_xml) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 00e9c7d6b..db7eae830 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -163,7 +163,17 @@ def add_actions(target, actions): else: target.addAction(action) +def get_filesystem_encoding(): + """ + Returns the name of the encoding used to convert Unicode filenames into + system file names. + """ + encoding = sys.getfilesystemencoding() + if encoding is None: + encoding = sys.getdefaultencoding() + return encoding + from languagemanager import LanguageManager __all__ = [u'AppLocation', u'check_latest_version', u'add_actions', - u'LanguageManager'] + u'get_filesystem_encoding', u'LanguageManager'] diff --git a/openlp/plugins/bibles/forms/importwizardform.py b/openlp/plugins/bibles/forms/importwizardform.py index c312b36ec..e486b3acd 100644 --- a/openlp/plugins/bibles/forms/importwizardform.py +++ b/openlp/plugins/bibles/forms/importwizardform.py @@ -419,9 +419,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): # Import a bible from the web self.ImportProgressBar.setMaximum(1) download_location = self.field(u'web_location').toInt()[0] - bible_version = self.BibleComboBox.currentText() - if not isinstance(bible_version, unicode): - bible_version = unicode(bible_version, u'utf8') + bible_version = unicode(self.BibleComboBox.currentText()) if download_location == WebDownload.Crosswalk: bible = \ self.web_bible_list[WebDownload.Crosswalk][bible_version] From 752e06383767f75535fe6446183a1b1560808e54 Mon Sep 17 00:00:00 2001 From: Frode Woldsund Date: Fri, 11 Jun 2010 09:36:08 +0200 Subject: [PATCH 15/44] Fixed doublespace in import --- openlp/core/lib/mediamanageritem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index f7b574be1..c9725ab62 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -30,7 +30,7 @@ import os from PyQt4 import QtCore, QtGui from openlp.core.lib import contextMenuAction, contextMenuSeparator, \ - SettingsManager, OpenLPToolbar, ServiceItem, build_icon, translate + SettingsManager, OpenLPToolbar, ServiceItem, build_icon, translate log = logging.getLogger(__name__) From f524c7ff4548f42a524086d21e3c9ccb338fdc82 Mon Sep 17 00:00:00 2001 From: M2j Date: Fri, 11 Jun 2010 15:11:50 +0200 Subject: [PATCH 16/44] On start without configuration recentFiles might become a python list --- openlp/core/ui/mainwindow.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 87077820b..21dc4b67a 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -851,5 +851,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if filename and filename not in self.recentFiles: self.recentFiles.insert(0, QtCore.QString(filename)) while self.recentFiles.count() > recentFileCount: - self.recentFiles.removeLast() + if isinstance(self.recentFiles, QtCore.QStringList): + self.recentFiles.removeLast() + else: + self.recentFiles.pop() From 06549eed0d418ab659e686e11e5db911831ad447 Mon Sep 17 00:00:00 2001 From: M2j Date: Fri, 11 Jun 2010 15:26:24 +0200 Subject: [PATCH 17/44] delclare recentFiles as QStringList --- openlp/core/ui/mainwindow.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 21dc4b67a..02bc9aff0 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -488,7 +488,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.displayManager = DisplayManager(screens) self.aboutForm = AboutForm(self, applicationVersion) self.settingsForm = SettingsForm(self.screens, self, self) - self.recentFiles = [] + self.recentFiles = QtCore.QStringList() # Set up the path with plugins pluginpath = AppLocation.get_directory(AppLocation.PluginsDir) self.plugin_manager = PluginManager(pluginpath) @@ -851,8 +851,4 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if filename and filename not in self.recentFiles: self.recentFiles.insert(0, QtCore.QString(filename)) while self.recentFiles.count() > recentFileCount: - if isinstance(self.recentFiles, QtCore.QStringList): - self.recentFiles.removeLast() - else: - self.recentFiles.pop() - + self.recentFiles.removeLast() From 96415d47a4275d15291dcbca4904e9a55cf3defb Mon Sep 17 00:00:00 2001 From: M2j Date: Fri, 11 Jun 2010 19:07:33 +0200 Subject: [PATCH 18/44] revert change in verse ordering --- openlp/plugins/songs/lib/mediaitem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 3053cc06e..67133f9c6 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -341,8 +341,8 @@ class SongMediaItem(MediaManagerItem): if len(order) == 0: break for verse in verseList: - if verse[0][u'type'][0] == order[0] and \ - (verse[0][u'label'] == order[1:] or not order[1:]): + if verse[0][u'label'] == order[1:] and \ + verse[0][u'type'][0] == order[0]: verseTag = u'%s:%s' % \ (verse[0][u'type'], verse[0][u'label']) service_item.add_from_text\ From 999df4e29617567229cbb4b5b1ab6f9ed2fff39b Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 12 Jun 2010 21:06:01 +0100 Subject: [PATCH 19/44] Fix db settings location --- openlp/plugins/songs/lib/manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/manager.py b/openlp/plugins/songs/lib/manager.py index 0b833fb0b..4276303d5 100644 --- a/openlp/plugins/songs/lib/manager.py +++ b/openlp/plugins/songs/lib/manager.py @@ -96,7 +96,7 @@ class SongManager(object): settings = QtCore.QSettings() settings.beginGroup(u'songs') self.db_url = u'' - db_type = unicode(settings.value(u'songs/db type', + db_type = unicode(settings.value(u'db type', QtCore.QVariant(u'sqlite')).toString()) if db_type == u'sqlite': self.db_url = u'sqlite:///%s/songs.sqlite' % \ From e70ad3ca904f2e876d92e3a88fcbb2c58cb36441 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 12 Jun 2010 21:22:20 +0100 Subject: [PATCH 20/44] addToServiceItem is not an Icon --- openlp/plugins/images/lib/mediaitem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 96584a455..2be83b461 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -54,6 +54,7 @@ class ImageMediaItem(MediaManagerItem): # be instanced by the base MediaManagerItem self.ListViewWithDnD_class = ImageListView MediaManagerItem.__init__(self, parent, icon, title) + self.addToServiceItem = True def initPluginNameVisible(self): self.PluginNameVisible = translate(u'ImagePlugin.MediaItem', u'Image') @@ -73,7 +74,6 @@ class ImageMediaItem(MediaManagerItem): self.hasFileIcon = True self.hasNewIcon = False self.hasEditIcon = False - self.addToServiceItem = True def initialise(self): log.debug(u'initialise') From ec4d54e66a22062d7cd932e82848b1307b3027c0 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 12 Jun 2010 21:22:58 +0100 Subject: [PATCH 21/44] Fix variable naming --- openlp/core/lib/__init__.py | 34 +++++++++++++------------- openlp/core/lib/mediamanageritem.py | 22 ++++++++--------- openlp/core/lib/serviceitem.py | 33 +++++++++++++------------ openlp/core/lib/xmlrootclass.py | 2 +- openlp/core/theme/theme.py | 14 +++++------ openlp/core/ui/servicemanager.py | 4 +-- openlp/core/ui/thememanager.py | 17 +++++++------ openlp/plugins/images/lib/mediaitem.py | 4 +-- openlp/plugins/media/lib/mediaitem.py | 4 +-- openlp/plugins/songs/lib/mediaitem.py | 6 ++--- 10 files changed, 71 insertions(+), 69 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index d5b46e6cb..a3523d042 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -95,24 +95,24 @@ def build_icon(icon): The icon to build. This can be a QIcon, a resource string in the form ``:/resource/file.png``, or a file location like ``/path/to/file.png``. """ - ButtonIcon = None + button_icon = None if isinstance(icon, QtGui.QIcon): - ButtonIcon = icon + button_icon = icon elif isinstance(icon, basestring): - ButtonIcon = QtGui.QIcon() + button_icon = QtGui.QIcon() if icon.startswith(u':/'): - ButtonIcon.addPixmap( - QtGui.QPixmap(icon), QtGui.QIcon.Normal, QtGui.QIcon.Off) + button_icon.addPixmap(QtGui.QPixmap(icon), QtGui.QIcon.Normal, + QtGui.QIcon.Off) else: - ButtonIcon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)), + button_icon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)), QtGui.QIcon.Normal, QtGui.QIcon.Off) elif isinstance(icon, QtGui.QImage): - ButtonIcon = QtGui.QIcon() - ButtonIcon.addPixmap( - QtGui.QPixmap.fromImage(icon), QtGui.QIcon.Normal, QtGui.QIcon.Off) - return ButtonIcon + button_icon = QtGui.QIcon() + button_icon.addPixmap(QtGui.QPixmap.fromImage(icon), + QtGui.QIcon.Normal, QtGui.QIcon.Off) + return button_icon -def contextMenuAction(base, icon, text, slot): +def context_menu_action(base, icon, text, slot): """ Utility method to help build context menus for plugins """ @@ -122,7 +122,7 @@ def contextMenuAction(base, icon, text, slot): QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot) return action -def contextMenu(base, icon, text): +def context_menu(base, icon, text): """ Utility method to help build context menus for plugins """ @@ -130,7 +130,7 @@ def contextMenu(base, icon, text): action.setIcon(build_icon(icon)) return action -def contextMenuSeparator(base): +def context_menu_separator(base): """ Add a separator to a context menu """ @@ -152,12 +152,12 @@ def resize_image(image, width, height): realw = preview.width() realh = preview.height() # and move it to the centre of the preview space - newImage = QtGui.QImage(width, height, + new_image = QtGui.QImage(width, height, QtGui.QImage.Format_ARGB32_Premultiplied) - newImage.fill(QtCore.Qt.black) - painter = QtGui.QPainter(newImage) + new_image.fill(QtCore.Qt.black) + painter = QtGui.QPainter(new_image) painter.drawImage((width - realw) / 2, (height - realh) / 2, preview) - return newImage + return new_image class ThemeLevel(object): diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 61e9cac6e..88b9afb11 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -28,7 +28,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import contextMenuAction, contextMenuSeparator, \ +from openlp.core.lib import context_menu_action, context_menu_separator, \ SettingsManager, OpenLPToolbar, ServiceItem, build_icon log = logging.getLogger(__name__) @@ -271,34 +271,34 @@ class MediaManagerItem(QtGui.QWidget): self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) if self.hasEditIcon: self.ListView.addAction( - contextMenuAction( + context_menu_action( self.ListView, u':/general/general_edit.png', u'%s %s' % (self.trUtf8('&Edit'), self.PluginNameVisible), self.onEditClick)) - self.ListView.addAction(contextMenuSeparator(self.ListView)) + self.ListView.addAction(context_menu_separator(self.ListView)) if self.hasDeleteIcon: self.ListView.addAction( - contextMenuAction( + context_menu_action( self.ListView, u':/general/general_delete.png', u'%s %s' % (self.trUtf8('&Delete'), self.PluginNameVisible), self.onDeleteClick)) - self.ListView.addAction(contextMenuSeparator(self.ListView)) + self.ListView.addAction(context_menu_separator(self.ListView)) self.ListView.addAction( - contextMenuAction( + context_menu_action( self.ListView, u':/general/general_preview.png', u'%s %s' % (self.trUtf8('&Preview'), self.PluginNameVisible), self.onPreviewClick)) self.ListView.addAction( - contextMenuAction( + context_menu_action( self.ListView, u':/general/general_live.png', self.trUtf8('&Show Live'), self.onLiveClick)) self.ListView.addAction( - contextMenuAction( + context_menu_action( self.ListView, u':/general/general_add.png', self.trUtf8('&Add to Service'), self.onAddClick)) if self.addToServiceItem: self.ListView.addAction( - contextMenuAction( + context_menu_action( self.ListView, u':/general/general_add.png', self.trUtf8('&Add to selected Service Item'), self.onAddEditClick)) @@ -465,9 +465,9 @@ class MediaManagerItem(QtGui.QWidget): """ service_item = ServiceItem(self.parent) if self.ServiceItemIconName: - service_item.addIcon(self.ServiceItemIconName) + service_item.add_icon(self.ServiceItemIconName) else: - service_item.addIcon( + service_item.add_icon( u':/media/media_' + self.PluginNameShort.lower() + u'.png') if self.generateSlideData(service_item, item): return service_item diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 6f27ddf34..3d3cec2c9 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -73,9 +73,10 @@ class ServiceItem(object): The plugin that this service item belongs to. """ if plugin: - self.RenderManager = plugin.render_manager + self.render_manager = plugin.render_manager self.name = plugin.name self.title = u'' + self.shortname = u'' self.audit = u'' self.items = [] self.iconic_representation = None @@ -90,6 +91,7 @@ class ServiceItem(object): self.capabilities = [] self.is_valid = True self.cache = [] + self.icon = None def add_capability(self, capability): """ @@ -109,7 +111,7 @@ class ServiceItem(object): """ return capability in self.capabilities - def addIcon(self, icon): + def add_icon(self, icon): """ Add an icon to the service item. This is used when displaying the service item in the service manager. @@ -131,12 +133,12 @@ class ServiceItem(object): if self.service_item_type == ServiceItemType.Text: log.debug(u'Formatting slides') if self.theme is None: - self.RenderManager.set_override_theme(None) + self.render_manager.set_override_theme(None) else: - self.RenderManager.set_override_theme(self.theme) + self.render_manager.set_override_theme(self.theme) for slide in self._raw_frames: before = time.time() - formated = self.RenderManager.format_slide(slide[u'raw_slide']) + formated = self.render_manager.format_slide(slide[u'raw_slide']) for format in formated: lines = u'' title = u'' @@ -151,9 +153,8 @@ class ServiceItem(object): log.log(15, u'Formatting took %4s' % (time.time() - before)) elif self.service_item_type == ServiceItemType.Image: for slide in self._raw_frames: - slide[u'image'] = \ - resize_image(slide[u'image'], self.RenderManager.width, - self.RenderManager.height) + slide[u'image'] = resize_image(slide[u'image'], + self.render_manager.width, self.render_manager.height) elif self.service_item_type == ServiceItemType.Command: pass else: @@ -167,19 +168,19 @@ class ServiceItem(object): """ log.debug(u'render individual') if self.theme is None: - self.RenderManager.set_override_theme(None) + self.render_manager.set_override_theme(None) else: - self.RenderManager.set_override_theme(self.theme) + self.render_manager.set_override_theme(self.theme) format = self._display_frames[row][u'text'].split(u'\n') #if screen blank then do not display footer if self.cache[row] is not None: frame = self.cache[row] else: if format[0]: - frame = self.RenderManager.generate_slide(format, - self.raw_footer) + frame = self.render_manager.generate_slide(format, + self.raw_footer) else: - frame = self.RenderManager.generate_slide(format, u'') + frame = self.render_manager.generate_slide(format, u'') self.cache[row] = frame return frame @@ -200,7 +201,7 @@ class ServiceItem(object): self._raw_frames.append( {u'title': title, u'image': image, u'path': path}) - def add_from_text(self, title, raw_slide, verseTag=None): + def add_from_text(self, title, raw_slide, verse_tag=None): """ Add a text slide to the service item. @@ -213,7 +214,7 @@ class ServiceItem(object): self.service_item_type = ServiceItemType.Text title = title.split(u'\n')[0] self._raw_frames.append( - {u'title': title, u'raw_slide': raw_slide, u'verseTag':verseTag}) + {u'title': title, u'raw_slide': raw_slide, u'verseTag':verse_tag}) def add_from_command(self, path, file_name, image): """ @@ -280,7 +281,7 @@ class ServiceItem(object): self.service_item_type = header[u'type'] self.shortname = header[u'plugin'] self.theme = header[u'theme'] - self.addIcon(header[u'icon']) + self.add_icon(header[u'icon']) self.raw_footer = header[u'footer'] self.audit = header[u'audit'] self.notes = header[u'notes'] diff --git a/openlp/core/lib/xmlrootclass.py b/openlp/core/lib/xmlrootclass.py index b2b37aaf1..1ea1d41a2 100644 --- a/openlp/core/lib/xmlrootclass.py +++ b/openlp/core/lib/xmlrootclass.py @@ -41,7 +41,7 @@ class XmlRootClass(object): (element.tag, val) = self.post_tag_hook(element.tag, val) """ - def _setFromXml(self, xml, root_tag): + def _set_from_xml(self, xml, root_tag): """ Set song properties from given xml content. diff --git a/openlp/core/theme/theme.py b/openlp/core/theme/theme.py index 7bc705fcb..75a2ddd85 100644 --- a/openlp/core/theme/theme.py +++ b/openlp/core/theme/theme.py @@ -153,8 +153,8 @@ class Theme(object): The data to initialise the theme with """ # init to defaults - self._set_from_XML(BLANK_STYLE_XML) - self._set_from_XML(xml) + self._set_from_xml(BLANK_STYLE_XML) + self._set_from_xml(xml) def _get_as_string(self): """ @@ -176,9 +176,9 @@ class Theme(object): The data to apply to the theme """ root = ElementTree(element=XML(xml)) - iter = root.getiterator() - for element in iter: - delphiColorChange = False + xml_iter = root.getiterator() + for element in xml_iter: + delphi_color_change = False if element.tag != u'Theme': element_text = element.text val = 0 @@ -194,7 +194,7 @@ class Theme(object): pass elif DELPHI_COLORS.has_key(element_text): val = DELPHI_COLORS[element_text] - delphiColorChange = True + delphi_color_change = True else: try: val = int(element_text) @@ -204,7 +204,7 @@ class Theme(object): (element.tag.find(u'BackgroundParameter') == 0 and type(val) == type(0))): # convert to a wx.Colour - if not delphiColorChange: + if not delphi_color_change: val = QtGui.QColor( val&0xFF, (val>>8)&0xFF, (val>>16)&0xFF) else: diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index de344a44d..59a52717b 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -32,7 +32,7 @@ log = logging.getLogger(__name__) from PyQt4 import QtCore, QtGui -from openlp.core.lib import OpenLPToolbar, ServiceItem, contextMenuAction, \ +from openlp.core.lib import OpenLPToolbar, ServiceItem, context_menu_action, \ Receiver, build_icon, ItemCapabilities, SettingsManager, translate from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm from openlp.core.utils import AppLocation @@ -954,7 +954,7 @@ class ServiceManager(QtGui.QWidget): self.ThemeComboBox.addItem(u'') for theme in theme_list: self.ThemeComboBox.addItem(theme) - action = contextMenuAction( + action = context_menu_action( self.ServiceManagerList, None, theme , self.onThemeChangeAction) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 1d60d264f..485f2cf30 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -33,9 +33,9 @@ from PyQt4 import QtCore, QtGui from openlp.core.ui import AmendThemeForm from openlp.core.theme import Theme -from openlp.core.lib import OpenLPToolbar, contextMenuAction, \ +from openlp.core.lib import OpenLPToolbar, context_menu_action, \ ThemeXML, str_to_bool, get_text_file_string, build_icon, Receiver, \ - contextMenuSeparator, SettingsManager, translate + context_menu_separator, SettingsManager, translate from openlp.core.utils import AppLocation log = logging.getLogger(__name__) @@ -81,27 +81,28 @@ class ThemeManager(QtGui.QWidget): self.Layout.addWidget(self.ThemeListWidget) self.ThemeListWidget.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.ThemeListWidget.addAction( - contextMenuAction(self.ThemeListWidget, u':/themes/theme_edit.png', + context_menu_action(self.ThemeListWidget, + u':/themes/theme_edit.png', translate(u'ThemeManager', u'Edit a theme'), self.onEditTheme)) self.ThemeListWidget.addAction( - contextMenuSeparator(self.ThemeListWidget)) + context_menu_separator(self.ThemeListWidget)) self.ThemeListWidget.addAction( - contextMenuAction(self.ThemeListWidget, + context_menu_action(self.ThemeListWidget, u':/general/general_delete.png', translate(u'ThemeManager', u'Delete theme'), self.onDeleteTheme)) self.ThemeListWidget.addAction( - contextMenuAction(self.ThemeListWidget, + context_menu_action(self.ThemeListWidget, u':/general/general_export.png', translate(u'ThemeManager', u'Make Global'), self.changeGlobalFromScreen)) self.ThemeListWidget.addAction( - contextMenuAction(self.ThemeListWidget, + context_menu_action(self.ThemeListWidget, u':/general/general_export.png', translate(u'ThemeManager', u'Export theme'), self.onExportTheme)) self.ThemeListWidget.addAction( - contextMenuSeparator(self.ThemeListWidget)) + context_menu_separator(self.ThemeListWidget)) #Signals QtCore.QObject.connect(self.ThemeListWidget, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 2be83b461..2ac701506 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -29,7 +29,7 @@ import os from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ - contextMenuAction, ItemCapabilities, SettingsManager, translate + context_menu_action, ItemCapabilities, SettingsManager, translate from openlp.core.utils import AppLocation log = logging.getLogger(__name__) @@ -93,7 +93,7 @@ class ImageMediaItem(MediaManagerItem): MediaManagerItem.addListViewToToolBar(self) self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.ListView.addAction( - contextMenuAction( + context_menu_action( self.ListView, u':/slides/slide_blank.png', translate(u'ImagePlugin.MediaItem', u'Replace Live Background'), self.onReplaceClick)) diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index dc3cc837e..7d48defd7 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -29,7 +29,7 @@ import os from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ - ItemCapabilities, SettingsManager, contextMenuAction, Receiver, translate + ItemCapabilities, SettingsManager, context_menu_action, Receiver, translate log = logging.getLogger(__name__) @@ -77,7 +77,7 @@ class MediaMediaItem(MediaManagerItem): MediaManagerItem.addListViewToToolBar(self) self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.ListView.addAction( - contextMenuAction(self.ListView, u':/slides/slide_blank.png', + context_menu_action(self.ListView, u':/slides/slide_blank.png', translate(u'MediaPlugin.MediaItem', u'Replace Live Background'), self.onReplaceClick)) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 67133f9c6..d6f2f5ce8 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -333,7 +333,7 @@ class SongMediaItem(MediaManagerItem): for verse in verseList: verseTag = u'%s:%s' % ( verse[0][u'type'], verse[0][u'label']) - service_item.add_from_text(\ + service_item.add_from_text( verse[1][:30], unicode(verse[1]), verseTag) else: #Loop through the verse list and expand the song accordingly. @@ -345,8 +345,8 @@ class SongMediaItem(MediaManagerItem): verse[0][u'type'][0] == order[0]: verseTag = u'%s:%s' % \ (verse[0][u'type'], verse[0][u'label']) - service_item.add_from_text\ - (verse[1][:30], verse[1], verseTag) + service_item.add_from_text( + verse[1][:30], verse[1], verseTag) else: verses = song.lyrics.split(u'\n\n') for slide in verses: From 732ce9555e731531081f74ab415a313f2b677e20 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 13 Jun 2010 20:34:25 +0100 Subject: [PATCH 22/44] Fix up blanks screen issues and cleanups --- openlp/core/ui/maindisplay.py | 10 ++++------ openlp/core/ui/mainwindow.py | 20 +++++++++----------- openlp/core/ui/slidecontroller.py | 14 ++++++++++++-- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 5e8db4934..a3c444097 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -133,7 +133,6 @@ class MainDisplay(DisplayWidget): self.display_alert = QtGui.QLabel(self) self.display_alert.setScaledContents(True) self.primary = True - self.displayBlank = False self.blankFrame = None self.frame = None QtCore.QObject.connect(Receiver.get_receiver(), @@ -280,15 +279,15 @@ class MainDisplay(DisplayWidget): self.display_alert.setPixmap(frame) self.moveToTop() - def frameView(self, frame, transition=False): + def frameView(self, frame, transition=False, display=True): """ Called from a slide controller to display a frame if the alert is in progress the alert is added on top ``frame`` Image frame to be rendered """ - log.debug(u'frameView %d' % (self.displayBlank)) - if not self.displayBlank: + log.debug(u'frameView %d' % (display)) + if display: if transition: if self.frame is not None: self.display_text.setPixmap( @@ -314,8 +313,7 @@ class MainDisplay(DisplayWidget): self.setVisible(True) self.showFullScreen() else: - self.waitingFrame = frame - self.waitingFrameTrans = transition + self.storeText = QtGui.QPixmap.fromImage(frame[u'main']) class VideoDisplay(Phonon.VideoWidget): """ diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index c65fa2ec0..254c4ab7e 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -356,7 +356,7 @@ class Ui_MainWindow(object): """ MainWindow.mainTitle = translate(u'MainWindow', u'OpenLP 2.0') MainWindow.language = translate(u'MainWindow', u'English') - MainWindow.defaultThemeText = translate(u'MainWindow', + MainWindow.defaultThemeText = translate(u'MainWindow', u'Default Theme: ') MainWindow.setWindowTitle(MainWindow.mainTitle) self.FileMenu.setTitle(translate(u'MainWindow', u'&File')) @@ -456,7 +456,7 @@ class Ui_MainWindow(object): u'Set the interface language to %1').arg(item.objectName())) self.ToolsAddToolItem.setText(translate(u'MainWindow', u'Add &Tool...')) self.ToolsAddToolItem.setStatusTip( - translate(u'MainWindow', + translate(u'MainWindow', u'Add an application to the list of tools')) self.action_Preview_Panel.setText( translate(u'MainWindow', u'&Preview Pane')) @@ -652,15 +652,13 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ settings = QtCore.QSettings() settings.beginGroup(self.generalSettingsSection) - if settings.value(u'screen blank', QtCore.QVariant(False)).toBool() \ - and settings.value(u'blank warning', QtCore.QVariant(False)).toBool(): - self.LiveController.onBlankDisplay(True) - QtGui.QMessageBox.question(self, - translate(u'MainWindow', u'OpenLP Main Display Blanked'), - translate(u'MainWindow', - u'The Main Display has been blanked out'), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok), - QtGui.QMessageBox.Ok) + if settings.value(u'screen blank', QtCore.QVariant(False)).toBool(): + self.LiveController.maindDisplaySetBackground() + if settings.value(u'blank warning', QtCore.QVariant(False)).toBool(): + QtGui.QMessageBox.question(self, + translate(u'MainWindow', u'OpenLP Main Display Blanked'), + translate(u'MainWindow', + u'The Main Display has been blanked out')) settings.endGroup() def versionThread(self): diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index fc77166e5..b4edc5056 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -120,6 +120,7 @@ class SlideController(QtGui.QWidget): self.serviceItem = None self.Panel = QtGui.QWidget(parent.ControlSplitter) self.slideList = {} + self.canDisplay = True # Layout for holding panel self.PanelLayout = QtGui.QVBoxLayout(self.Panel) self.PanelLayout.setSpacing(0) @@ -651,6 +652,12 @@ class SlideController(QtGui.QWidget): self.PreviewListWidget.selectRow(index) self.onSlideSelected() + def maindDisplaySetBackground(self): + """ + Allow the main display to blank the main display at startup time + """ + self.blankButton.setChecked(True) + def onSlideBlank(self): """ Handle the slidecontroller blank event @@ -670,6 +677,7 @@ class SlideController(QtGui.QWidget): log.debug(u'onBlankDisplay %d' % checked) self.hideButton.setChecked(False) self.themeButton.setChecked(False) + self.canDisplay = not checked QtCore.QSettings().setValue( self.parent.generalSettingsSection + u'/screen blank', QtCore.QVariant(checked)) @@ -687,6 +695,7 @@ class SlideController(QtGui.QWidget): log.debug(u'onThemeDisplay %d' % checked) self.blankButton.setChecked(False) self.hideButton.setChecked(False) + self.canDisplay = False if checked: Receiver.send_message(u'maindisplay_hide', HideMode.Theme) self.blankPlugin(True) @@ -701,6 +710,7 @@ class SlideController(QtGui.QWidget): log.debug(u'onHideDisplay %d' % checked) self.blankButton.setChecked(False) self.themeButton.setChecked(False) + self.canDisplay = False if checked: Receiver.send_message(u'maindisplay_hide', HideMode.Screen) self.hidePlugin(True) @@ -710,7 +720,7 @@ class SlideController(QtGui.QWidget): def blankPlugin(self, blank): """ - Blank the display screen. + Blank the display screen within a plugin if required. """ if self.serviceItem is not None: if blank: @@ -770,7 +780,7 @@ class SlideController(QtGui.QWidget): log.log( 15, u'Slide Rendering took %4s' % (time.time() - before)) if self.isLive: - self.mainDisplay.frameView(frame, True) + self.mainDisplay.frameView(frame, True, self.canDisplay) self.selectedRow = row Receiver.send_message(u'slidecontroller_%s_changed' % self.typePrefix, row) From f38d97686eba225cdda0b18fc5fde23e721e12ec Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 13 Jun 2010 20:41:11 +0100 Subject: [PATCH 23/44] Fix method --- openlp/core/ui/mainwindow.py | 2 +- openlp/core/ui/slidecontroller.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 254c4ab7e..3caef90c5 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -653,7 +653,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): settings = QtCore.QSettings() settings.beginGroup(self.generalSettingsSection) if settings.value(u'screen blank', QtCore.QVariant(False)).toBool(): - self.LiveController.maindDisplaySetBackground() + self.LiveController.mainDisplaySetBackground() if settings.value(u'blank warning', QtCore.QVariant(False)).toBool(): QtGui.QMessageBox.question(self, translate(u'MainWindow', u'OpenLP Main Display Blanked'), diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index b4edc5056..6e8ba8b22 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -652,7 +652,7 @@ class SlideController(QtGui.QWidget): self.PreviewListWidget.selectRow(index) self.onSlideSelected() - def maindDisplaySetBackground(self): + def mainDisplaySetBackground(self): """ Allow the main display to blank the main display at startup time """ From f54a423832735d72e9e1fc6be803ff99cb09bf00 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Mon, 14 Jun 2010 03:42:47 +0100 Subject: [PATCH 24/44] Fix bible runtime data location --- openlp/plugins/bibles/forms/importwizardform.py | 4 ++-- openlp/plugins/bibles/lib/db.py | 1 + openlp/plugins/bibles/lib/http.py | 7 +++---- openlp/plugins/bibles/lib/osis.py | 5 ++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/openlp/plugins/bibles/forms/importwizardform.py b/openlp/plugins/bibles/forms/importwizardform.py index b1eafcd61..72d6b9f42 100644 --- a/openlp/plugins/bibles/forms/importwizardform.py +++ b/openlp/plugins/bibles/forms/importwizardform.py @@ -322,8 +322,8 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): Load the list of Crosswalk and BibleGateway bibles. """ #Load and store Crosswalk Bibles - filepath = AppLocation.get_directory(AppLocation.PluginsDir) - filepath = os.path.join(filepath, u'bibles', u'resources') + filepath = os.path.join(AppLocation.get_section_data_path( + self.bibleplugin.settingsSection), u'resources') try: self.web_bible_list[WebDownload.Crosswalk] = {} books_file = open( diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 47d9ffdd2..97983e72c 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -59,6 +59,7 @@ class BibleDB(QtCore.QObject): """ log.info(u'BibleDB loaded') QtCore.QObject.__init__(self) + self.bible_plugin = parent if u'path' not in kwargs: raise KeyError(u'Missing keyword argument "path".') if u'name' not in kwargs and u'file' not in kwargs: diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 223d428af..3bff9264c 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -56,8 +56,8 @@ class HTTPBooks(object): """ if HTTPBooks.cursor is None: filepath = os.path.join( - AppLocation.get_directory(AppLocation.PluginsDir), u'bibles', - u'resources', u'httpbooks.sqlite') + AppLocation.get_section_data_path(u'bibles'), u'resources', + u'httpbooks.sqlite') conn = sqlite3.connect(filepath) HTTPBooks.cursor = conn.cursor() return HTTPBooks.cursor @@ -288,8 +288,7 @@ class CWExtract(BibleCommon): ``chapter`` Chapter number """ - log.debug(u'get_bible_chapter %s,%s,%s', - version, bookname, chapter) + log.debug(u'get_bible_chapter %s,%s,%s', version, bookname, chapter) urlbookname = bookname.replace(u' ', u'-') chapter_url = u'http://www.biblestudytools.com/%s/%s/%s.html' % \ (version, urlbookname.lower(), chapter) diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index b4a2a2aa1..6c1342c6f 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -68,9 +68,8 @@ class OSISBible(BibleDB): self.trans_regex = re.compile(r'(.*?)') self.spaces_regex = re.compile(r'([ ]{2,})') self.books = {} - filepath = os.path.join( - AppLocation.get_directory(AppLocation.PluginsDir), u'bibles', - u'resources', u'osisbooks.csv') + filepath = os.path.join(AppLocation.get_section_data_path( + self.bible_plugin.settingsSection), u'resources', u'osisbooks.csv') fbibles = None try: fbibles = open(filepath, u'r') From a4f0df76cc516e395dc8c9b3d5adfdfca6426be5 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Mon, 14 Jun 2010 14:23:19 +0100 Subject: [PATCH 25/44] Fix QColorDialog usage --- openlp/core/ui/amendthemeform.py | 80 +++++++++++++++----------- openlp/plugins/alerts/lib/alertstab.py | 24 ++++---- 2 files changed, 60 insertions(+), 44 deletions(-) diff --git a/openlp/core/ui/amendthemeform.py b/openlp/core/ui/amendthemeform.py index a2db71ff3..00e6a5d16 100644 --- a/openlp/core/ui/amendthemeform.py +++ b/openlp/core/ui/amendthemeform.py @@ -239,12 +239,13 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.previewTheme() def onFontMainColorPushButtonClicked(self): - self.theme.font_main_color = QtGui.QColorDialog.getColor( - QtGui.QColor(self.theme.font_main_color), self).name() - - self.FontMainColorPushButton.setStyleSheet( - u'background-color: %s' % unicode(self.theme.font_main_color)) - self.previewTheme() + new_color = QtGui.QColorDialog.getColor( + QtGui.QColor(self.theme.font_main_color), self) + if new_color.isValid(): + self.theme.font_main_color = new_color.name() + self.FontMainColorPushButton.setStyleSheet( + u'background-color: %s' % unicode(self.theme.font_main_color)) + self.previewTheme() def onFontMainSizeSpinBoxChanged(self): if self.theme.font_main_proportion != self.FontMainSizeSpinBox.value(): @@ -332,11 +333,13 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.previewTheme() def onFontFooterColorPushButtonClicked(self): - self.theme.font_footer_color = QtGui.QColorDialog.getColor( - QtGui.QColor(self.theme.font_footer_color), self).name() - self.FontFooterColorPushButton.setStyleSheet( - 'background-color: %s' % unicode(self.theme.font_footer_color)) - self.previewTheme() + new_color = QtGui.QColorDialog.getColor( + QtGui.QColor(self.theme.background_color), self) + if new_color.isValid(): + self.theme.font_footer_color = new_color.name() + self.FontFooterColorPushButton.setStyleSheet( + u'background-color: %s' % unicode(self.theme.font_footer_color)) + self.previewTheme() def onFontFooterSizeSpinBoxChanged(self): if self.theme.font_footer_proportion != \ @@ -431,24 +434,29 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): def onColor1PushButtonClicked(self): if self.theme.background_type == u'solid': - self.theme.background_color = QtGui.QColorDialog.getColor( - QtGui.QColor(self.theme.background_color), self).name() - self.Color1PushButton.setStyleSheet( - u'background-color: %s' % unicode(self.theme.background_color)) + new_color = QtGui.QColorDialog.getColor( + QtGui.QColor(self.theme.background_color), self) + if new_color.isValid(): + self.theme.background_color = new_color.name() + self.Color1PushButton.setStyleSheet(u'background-color: %s' % + unicode(self.theme.background_color)) else: - self.theme.background_startColor = QtGui.QColorDialog.getColor( - QtGui.QColor(self.theme.background_startColor), self).name() - self.Color1PushButton.setStyleSheet( - u'background-color: %s' % \ + new_color = QtGui.QColorDialog.getColor( + QtGui.QColor(self.theme.background_color), self) + if new_color.isValid(): + self.theme.background_startColor = new_color.name() + self.Color1PushButton.setStyleSheet(u'background-color: %s' % unicode(self.theme.background_startColor)) self.previewTheme() def onColor2PushButtonClicked(self): - self.theme.background_endColor = QtGui.QColorDialog.getColor( - QtGui.QColor(self.theme.background_endColor), self).name() - self.Color2PushButton.setStyleSheet( - u'background-color: %s' % unicode(self.theme.background_endColor)) - self.previewTheme() + new_color = QtGui.QColorDialog.getColor( + QtGui.QColor(self.theme.background_color), self) + if new_color.isValid(): + self.theme.background_endColor = new_color.name() + self.Color2PushButton.setStyleSheet(u'background-color: %s' % + unicode(self.theme.background_endColor)) + self.previewTheme() # #Other Tab @@ -472,11 +480,13 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.previewTheme() def onOutlineColorPushButtonClicked(self): - self.theme.display_outline_color = QtGui.QColorDialog.getColor( - QtGui.QColor(self.theme.display_outline_color), self).name() - self.OutlineColorPushButton.setStyleSheet( - u'background-color: %s' % unicode(self.theme.display_outline_color)) - self.previewTheme() + new_color = QtGui.QColorDialog.getColor( + QtGui.QColor(self.theme.background_color), self) + if new_color.isValid(): + self.theme.display_outline_color = new_color.name() + self.OutlineColorPushButton.setStyleSheet(u'background-color: %s' % + unicode(self.theme.display_outline_color)) + self.previewTheme() def onShadowCheckBoxChanged(self, value): if value == 2: # checked @@ -495,11 +505,13 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.previewTheme() def onShadowColorPushButtonClicked(self): - self.theme.display_shadow_color = QtGui.QColorDialog.getColor( - QtGui.QColor(self.theme.display_shadow_color), self).name() - self.ShadowColorPushButton.setStyleSheet( - u'background-color: %s' % unicode(self.theme.display_shadow_color)) - self.previewTheme() + new_color = QtGui.QColorDialog.getColor( + QtGui.QColor(self.theme.background_color), self) + if new_color.isValid(): + self.theme.display_shadow_color = new_color.name() + self.ShadowColorPushButton.setStyleSheet(u'background-color: %s' % + unicode(self.theme.display_shadow_color)) + self.previewTheme() def onHorizontalComboBoxSelected(self, currentIndex): self.theme.display_horizontalAlign = currentIndex diff --git a/openlp/plugins/alerts/lib/alertstab.py b/openlp/plugins/alerts/lib/alertstab.py index 9e6e98489..43c299070 100644 --- a/openlp/plugins/alerts/lib/alertstab.py +++ b/openlp/plugins/alerts/lib/alertstab.py @@ -214,11 +214,13 @@ class AlertsTab(SettingsTab): translate(u'AlertsPlugin.AlertsTab', u'Bottom')) def onBackgroundColorButtonClicked(self): - self.bg_color = QtGui.QColorDialog.getColor( - QtGui.QColor(self.bg_color), self).name() - self.BackgroundColorButton.setStyleSheet( - u'background-color: %s' % self.bg_color) - self.updateDisplay() + new_color = QtGui.QColorDialog.getColor( + QtGui.QColor(self.theme.background_color), self) + if new_color.isValid(): + self.bg_color = new_color.name() + self.BackgroundColorButton.setStyleSheet( + u'background-color: %s' % self.bg_color) + self.updateDisplay() def onFontComboBoxClicked(self): self.updateDisplay() @@ -227,11 +229,13 @@ class AlertsTab(SettingsTab): self.location = location def onFontColorButtonClicked(self): - self.font_color = QtGui.QColorDialog.getColor( - QtGui.QColor(self.font_color), self).name() - self.FontColorButton.setStyleSheet( - u'background-color: %s' % self.font_color) - self.updateDisplay() + new_color = QtGui.QColorDialog.getColor( + QtGui.QColor(self.theme.background_color), self) + if new_color.isValid(): + self.font_color = new_color.name() + self.FontColorButton.setStyleSheet( + u'background-color: %s' % self.font_color) + self.updateDisplay() def onTimeoutSpinBoxChanged(self): self.timeout = self.TimeoutSpinBox.value() From 754da4c28ecf497c4817c7ee58c631ab9243bf02 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Mon, 14 Jun 2010 14:43:04 +0100 Subject: [PATCH 26/44] Fix PEBKAC --- openlp/core/ui/amendthemeform.py | 10 +++++----- openlp/plugins/alerts/lib/alertstab.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/openlp/core/ui/amendthemeform.py b/openlp/core/ui/amendthemeform.py index 00e6a5d16..0891f128a 100644 --- a/openlp/core/ui/amendthemeform.py +++ b/openlp/core/ui/amendthemeform.py @@ -334,7 +334,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): def onFontFooterColorPushButtonClicked(self): new_color = QtGui.QColorDialog.getColor( - QtGui.QColor(self.theme.background_color), self) + QtGui.QColor(self.theme.font_footer_color), self) if new_color.isValid(): self.theme.font_footer_color = new_color.name() self.FontFooterColorPushButton.setStyleSheet( @@ -442,7 +442,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): unicode(self.theme.background_color)) else: new_color = QtGui.QColorDialog.getColor( - QtGui.QColor(self.theme.background_color), self) + QtGui.QColor(self.theme.background_startColor), self) if new_color.isValid(): self.theme.background_startColor = new_color.name() self.Color1PushButton.setStyleSheet(u'background-color: %s' % @@ -451,7 +451,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): def onColor2PushButtonClicked(self): new_color = QtGui.QColorDialog.getColor( - QtGui.QColor(self.theme.background_color), self) + QtGui.QColor(self.theme.background_endColor), self) if new_color.isValid(): self.theme.background_endColor = new_color.name() self.Color2PushButton.setStyleSheet(u'background-color: %s' % @@ -481,7 +481,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): def onOutlineColorPushButtonClicked(self): new_color = QtGui.QColorDialog.getColor( - QtGui.QColor(self.theme.background_color), self) + QtGui.QColor(self.theme.display_outline_color), self) if new_color.isValid(): self.theme.display_outline_color = new_color.name() self.OutlineColorPushButton.setStyleSheet(u'background-color: %s' % @@ -506,7 +506,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): def onShadowColorPushButtonClicked(self): new_color = QtGui.QColorDialog.getColor( - QtGui.QColor(self.theme.background_color), self) + QtGui.QColor(self.theme.display_shadow_color), self) if new_color.isValid(): self.theme.display_shadow_color = new_color.name() self.ShadowColorPushButton.setStyleSheet(u'background-color: %s' % diff --git a/openlp/plugins/alerts/lib/alertstab.py b/openlp/plugins/alerts/lib/alertstab.py index 43c299070..15f27df6d 100644 --- a/openlp/plugins/alerts/lib/alertstab.py +++ b/openlp/plugins/alerts/lib/alertstab.py @@ -215,7 +215,7 @@ class AlertsTab(SettingsTab): def onBackgroundColorButtonClicked(self): new_color = QtGui.QColorDialog.getColor( - QtGui.QColor(self.theme.background_color), self) + QtGui.QColor(self.bg_color), self) if new_color.isValid(): self.bg_color = new_color.name() self.BackgroundColorButton.setStyleSheet( @@ -230,7 +230,7 @@ class AlertsTab(SettingsTab): def onFontColorButtonClicked(self): new_color = QtGui.QColorDialog.getColor( - QtGui.QColor(self.theme.background_color), self) + QtGui.QColor(self.font_color), self) if new_color.isValid(): self.font_color = new_color.name() self.FontColorButton.setStyleSheet( From 7c2c8f26e1791ea94a201521a05636561c3e3dfe Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Mon, 14 Jun 2010 18:56:42 +0100 Subject: [PATCH 27/44] Revert resource location --- openlp/plugins/bibles/forms/importwizardform.py | 4 ++-- openlp/plugins/bibles/lib/http.py | 4 ++-- openlp/plugins/bibles/lib/osis.py | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/openlp/plugins/bibles/forms/importwizardform.py b/openlp/plugins/bibles/forms/importwizardform.py index 72d6b9f42..b1eafcd61 100644 --- a/openlp/plugins/bibles/forms/importwizardform.py +++ b/openlp/plugins/bibles/forms/importwizardform.py @@ -322,8 +322,8 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): Load the list of Crosswalk and BibleGateway bibles. """ #Load and store Crosswalk Bibles - filepath = os.path.join(AppLocation.get_section_data_path( - self.bibleplugin.settingsSection), u'resources') + filepath = AppLocation.get_directory(AppLocation.PluginsDir) + filepath = os.path.join(filepath, u'bibles', u'resources') try: self.web_bible_list[WebDownload.Crosswalk] = {} books_file = open( diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 3bff9264c..d3d6ca5f6 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -56,8 +56,8 @@ class HTTPBooks(object): """ if HTTPBooks.cursor is None: filepath = os.path.join( - AppLocation.get_section_data_path(u'bibles'), u'resources', - u'httpbooks.sqlite') + AppLocation.get_directory(AppLocation.PluginsDir), u'bibles', + u'resources', u'httpbooks.sqlite') conn = sqlite3.connect(filepath) HTTPBooks.cursor = conn.cursor() return HTTPBooks.cursor diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index 6c1342c6f..b4a2a2aa1 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -68,8 +68,9 @@ class OSISBible(BibleDB): self.trans_regex = re.compile(r'(.*?)') self.spaces_regex = re.compile(r'([ ]{2,})') self.books = {} - filepath = os.path.join(AppLocation.get_section_data_path( - self.bible_plugin.settingsSection), u'resources', u'osisbooks.csv') + filepath = os.path.join( + AppLocation.get_directory(AppLocation.PluginsDir), u'bibles', + u'resources', u'osisbooks.csv') fbibles = None try: fbibles = open(filepath, u'r') From b6057c01567dd895f4e694c019a0b4cf72094cd4 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Mon, 14 Jun 2010 21:59:07 +0100 Subject: [PATCH 28/44] resize thumbs --- openlp/plugins/presentations/lib/powerpointcontroller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/presentations/lib/powerpointcontroller.py b/openlp/plugins/presentations/lib/powerpointcontroller.py index 67870574d..80fc8f54a 100644 --- a/openlp/plugins/presentations/lib/powerpointcontroller.py +++ b/openlp/plugins/presentations/lib/powerpointcontroller.py @@ -142,7 +142,7 @@ class PowerpointDocument(PresentationDocument): if self.check_thumbnails(): return self.presentation.Export(os.path.join(self.thumbnailpath, '') - , 'png', 640, 480) + , 'png', 320, 240) def close_presentation(self): """ From f2a0fb9f2952a3e371960732b7ca77d09c6e11e6 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Mon, 14 Jun 2010 23:01:04 +0100 Subject: [PATCH 29/44] Well at least you can open a presentation now. Can't see it yet though cos of some silly black window in the way --- openlp/plugins/presentations/lib/impresscontroller.py | 2 +- openlp/plugins/presentations/lib/powerpointcontroller.py | 2 +- openlp/plugins/presentations/lib/pptviewcontroller.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 6c360355c..10add26b4 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -181,7 +181,7 @@ class ImpressController(PresentationController): class ImpressDocument(PresentationDocument): def __init__(self, controller, presentation): log.debug(u'Init Presentation OpenOffice') - PresentationDocument.__init__(controller, presentation) + PresentationDocument.__init__(self, controller, presentation) self.document = None self.presentation = None self.control = None diff --git a/openlp/plugins/presentations/lib/powerpointcontroller.py b/openlp/plugins/presentations/lib/powerpointcontroller.py index 32d951c0e..93c48e86c 100644 --- a/openlp/plugins/presentations/lib/powerpointcontroller.py +++ b/openlp/plugins/presentations/lib/powerpointcontroller.py @@ -104,7 +104,7 @@ class PowerpointController(PresentationController): class PowerpointDocument(PresentationDocument): def __init__(self, controller, presentation): log.debug(u'Init Presentation Powerpoint') - PresentationDocument.__init__(controller, presentation) + PresentationDocument.__init__(self, controller, presentation) self.presentation = None def load_presentation(self): diff --git a/openlp/plugins/presentations/lib/pptviewcontroller.py b/openlp/plugins/presentations/lib/pptviewcontroller.py index 409a0b760..42a12be1d 100644 --- a/openlp/plugins/presentations/lib/pptviewcontroller.py +++ b/openlp/plugins/presentations/lib/pptviewcontroller.py @@ -102,7 +102,7 @@ class PptviewController(PresentationController): class PptviewDocument(PresentationDocument): def __init__(self, controller, presentation): log.debug(u'Init Presentation PowerPoint') - PresentationDocument.__init__(controller, presentation) + PresentationDocument.__init__(self, controller, presentation) self.presentation = None self.pptid = None self.blanked = False From 814a4f023dc9c37c4881def86910274dd62409e2 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 16 Jun 2010 01:31:44 +0100 Subject: [PATCH 30/44] Fix Bible Import setField errors --- openlp/core/lib/plugin.py | 3 ++- openlp/plugins/bibles/forms/importwizardform.py | 11 +++++++---- openlp/plugins/bibles/lib/mediaitem.py | 1 - 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index ebb38615d..0c22723a4 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -231,7 +231,8 @@ class Plugin(QtCore.QObject): Show a dialog when the user clicks on the 'About' button in the plugin manager. """ - pass + raise NotImplementedError( + u'Plugin.about needs to be defined by the plugin') def initialise(self): """ diff --git a/openlp/plugins/bibles/forms/importwizardform.py b/openlp/plugins/bibles/forms/importwizardform.py index e486b3acd..fbaa2ec14 100644 --- a/openlp/plugins/bibles/forms/importwizardform.py +++ b/openlp/plugins/bibles/forms/importwizardform.py @@ -303,17 +303,20 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): self.setField(u'csv_versefile', QtCore.QVariant('')) self.setField(u'opensong_file', QtCore.QVariant('')) self.setField(u'web_location', QtCore.QVariant(WebDownload.Crosswalk)) - self.setField(u'web_biblename', QtCore.QVariant(self.BibleComboBox)) + self.setField(u'web_biblename', + QtCore.QVariant(self.BibleComboBox.currentIndex())) self.setField(u'proxy_server', settings.value(u'proxy address', QtCore.QVariant(u''))) self.setField(u'proxy_username', settings.value(u'proxy username', QtCore.QVariant(u''))) self.setField(u'proxy_password', settings.value(u'proxy password', QtCore.QVariant(u''))) - self.setField(u'license_version', QtCore.QVariant(self.VersionNameEdit)) - self.setField(u'license_copyright', QtCore.QVariant(self.CopyrightEdit)) + self.setField(u'license_version', + QtCore.QVariant(self.VersionNameEdit.text())) + self.setField(u'license_copyright', + QtCore.QVariant(self.CopyrightEdit.text())) self.setField(u'license_permission', - QtCore.QVariant(self.PermissionEdit)) + QtCore.QVariant(self.PermissionEdit.text())) self.onLocationComboBoxChanged(WebDownload.Crosswalk) settings.endGroup() diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 6c5f21f23..191f26d44 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -79,7 +79,6 @@ class BibleMediaItem(MediaManagerItem): self.hasNewIcon = False self.hasEditIcon = False self.hasDeleteIcon = False - self.addToServiceItem = True def addEndHeaderBar(self): self.SearchTabWidget = QtGui.QTabWidget(self) From 5e0ab4a7f6d8a06855e7b9803294cbdeecd049d7 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 16 Jun 2010 02:23:57 +0100 Subject: [PATCH 31/44] Fix lack of feedback for edit and delete --- openlp/core/lib/mediamanageritem.py | 17 +++++++++++++++-- openlp/plugins/custom/lib/mediaitem.py | 16 ++++++++++++---- openlp/plugins/images/lib/mediaitem.py | 12 ++++++++---- openlp/plugins/media/lib/mediaitem.py | 9 ++++++--- openlp/plugins/presentations/lib/mediaitem.py | 8 ++++++-- openlp/plugins/songs/lib/mediaitem.py | 17 ++++++++++++----- 6 files changed, 59 insertions(+), 20 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 92efd152c..8df8bded9 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -325,6 +325,19 @@ class MediaManagerItem(QtGui.QWidget): """ pass + def checkItemSelected(self, message): + """ + Check if a list item is selected so an action may be performed on it + + ``message`` + The message to give the user if no item is selected + """ + if not self.ListView.selectedIndexes(): + QtGui.QMessageBox.information(self, + self.trUtf8('No Items Selected'), message) + return False + return True + def onFileClick(self): files = QtGui.QFileDialog.getOpenFileNames( self, self.OnNewPrompt, @@ -392,7 +405,7 @@ class MediaManagerItem(QtGui.QWidget): if not self.ListView.selectedIndexes() and not self.remoteTriggered: QtGui.QMessageBox.information(self, self.trUtf8('No Items Selected'), - self.trUtf8('You must select one or more items.')) + self.trUtf8('You must select one or more items to preview.')) else: log.debug(self.PluginNameShort + u' Preview requested') service_item = self.buildServiceItem() @@ -404,7 +417,7 @@ class MediaManagerItem(QtGui.QWidget): if not self.ListView.selectedIndexes(): QtGui.QMessageBox.information(self, self.trUtf8('No Items Selected'), - self.trUtf8('You must select one or more items.')) + self.trUtf8('You must select one or more items to send live.')) else: log.debug(self.PluginNameShort + u' Live requested') service_item = self.buildServiceItem() diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 581334410..4cbf25476 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -115,16 +115,24 @@ class CustomMediaItem(MediaManagerItem): self.parent.edit_custom_form.exec_() def onEditClick(self): - item = self.ListView.currentItem() - if item: + """ + Edit a custom item + """ + if self.checkItemSelected(translate(u'CustomPlugin.MediaItem', + u'You must select an item to edit.')): + item = self.ListView.currentItem() item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] self.parent.edit_custom_form.loadCustom(item_id, False) self.parent.edit_custom_form.exec_() self.initialise() def onDeleteClick(self): - item = self.ListView.currentItem() - if item: + """ + Remove a custom item from the list and database + """ + if self.checkItemSelected(translate(u'CustomPlugin.MediaItem', + u'You must select an item to delete.')): + item = self.ListView.currentItem() item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] self.parent.custommanager.delete_custom(item_id) row = self.ListView.row(item) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 6e791badd..0ab86f3f7 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -116,14 +116,18 @@ class ImageMediaItem(MediaManagerItem): self.PageLayout.addWidget(self.ImageWidget) def onDeleteClick(self): - items = self.ListView.selectedIndexes() - if items: + """ + Remove an image item from the list + """ + if self.checkItemSelected(translate(u'ImagePlugin.MediaItem', + u'You must select an item to delete.')): + items = self.ListView.selectedIndexes() for item in items: text = self.ListView.item(item.row()) if text: try: - os.remove( - os.path.join(self.servicePath, unicode(text.text()))) + os.remove(os.path.join(self.servicePath, + unicode(text.text()))) except OSError: #if not present do not worry pass diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index fd397a35f..60bc190dc 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -137,8 +137,12 @@ class MediaMediaItem(MediaManagerItem): self.settingsSection)) def onDeleteClick(self): - item = self.ListView.currentItem() - if item: + """ + Remove a media item from the list + """ + if self.checkItemSelected(translate(u'MediaPlugin.MediaItem', + u'You must select an item to delete.')): + item = self.ListView.currentItem() row = self.ListView.row(item) self.ListView.takeItem(row) SettingsManager.set_list(self.settingsSection, @@ -152,4 +156,3 @@ class MediaMediaItem(MediaManagerItem): item_name.setIcon(build_icon(img)) item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file)) self.ListView.addItem(item_name) - diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index be2cecff4..51e2db23b 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -174,8 +174,12 @@ class PresentationMediaItem(MediaManagerItem): self.ListView.addItem(item_name) def onDeleteClick(self): - item = self.ListView.currentItem() - if item: + """ + Remove a presentation item from the list + """ + if self.checkItemSelected(translate(u'PresentationPlugin.MediaItem', + u'You must select an item to delete.')): + item = self.ListView.currentItem() row = self.ListView.row(item) self.ListView.takeItem(row) SettingsManager.set_list(self.settingsSection, diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index d6f2f5ce8..60faaa826 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -275,15 +275,23 @@ class SongMediaItem(MediaManagerItem): self.edit_song_form.exec_() def onEditClick(self): - item = self.ListView.currentItem() - if item: + """ + Edit a song + """ + if self.checkItemSelected(translate(u'SongsPlugin.MediaItem', + u'You must select an item to edit.')): + item = self.ListView.currentItem() item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] self.edit_song_form.loadSong(item_id, False) self.edit_song_form.exec_() def onDeleteClick(self): - items = self.ListView.selectedIndexes() - if items: + """ + Remove a song from the list and database + """ + if self.checkItemSelected(translate(u'SongsPlugin.MediaItem', + u'You must select an item to delete.')): + items = self.ListView.selectedIndexes() if len(items) == 1: del_message = translate(u'SongsPlugin.MediaItem', u'Delete song?') @@ -371,4 +379,3 @@ class SongMediaItem(MediaManagerItem): song.title, author_audit, song.copyright, song.ccli_number ] return True - From 04f2a9797b374f4141cca7c89f398200a3a39e80 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 16 Jun 2010 02:48:52 +0100 Subject: [PATCH 32/44] Bible search fix: * Add feedback * cater for partial file-based bibles * Prevent an uncaught exception --- openlp/plugins/bibles/lib/db.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 97983e72c..377803b19 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -29,8 +29,9 @@ import chardet import re from sqlalchemy import or_ -from PyQt4 import QtCore +from PyQt4 import QtCore, QtGui +from openlp.core.lib import translate from openlp.plugins.bibles.lib.models import * log = logging.getLogger(__name__) @@ -304,14 +305,22 @@ class BibleDB(QtCore.QObject): if db_book: book = db_book.name log.debug(u'Book name corrected to "%s"', book) - verses = self.session.query(Verse)\ - .filter_by(book_id=db_book.id)\ - .filter_by(chapter=chapter)\ - .filter(Verse.verse >= start_verse)\ - .filter(Verse.verse <= end_verse)\ - .order_by(Verse.verse)\ - .all() - verse_list.extend(verses) + verses = self.session.query(Verse)\ + .filter_by(book_id=db_book.id)\ + .filter_by(chapter=chapter)\ + .filter(Verse.verse >= start_verse)\ + .filter(Verse.verse <= end_verse)\ + .order_by(Verse.verse)\ + .all() + verse_list.extend(verses) + else: + log.debug(u'OpenLP failed to find book %s', book) + QtGui.QMessageBox.information(self.bible_plugin.media_item, + translate(u'BibleDB', u'Book not found'), + translate(u'BibleDB', u'The book you requested could not ' + u'be found in this bible. Please check your spelling ' + u'and that this is a complete bible not just one ' + u'testament.')) return verse_list def verse_search(self, text): @@ -383,4 +392,3 @@ class BibleDB(QtCore.QObject): log.debug(u'...............................Verses ') verses = self.session.query(Verse).all() log.debug(verses) - From 674b9e00ad8abaf939cebc652eb214ca522b906c Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Wed, 16 Jun 2010 22:22:02 +0100 Subject: [PATCH 33/44] Remove the main display so we can see the ppt's --- openlp/plugins/presentations/lib/messagelistener.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index 0e98b377a..c6ab1e921 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -29,6 +29,7 @@ import os from PyQt4 import QtCore from openlp.core.lib import Receiver +from openlp.core.ui import HideMode log = logging.getLogger(__name__) @@ -55,7 +56,7 @@ class Controller(object): self.doc.start_presentation() if isBlank: self.blank() - Receiver.send_message(u'maindisplay_hide') + Receiver.send_message(u'maindisplay_hide', HideMode.Screen) self.doc.slidenumber = 0 def activate(self): @@ -179,6 +180,7 @@ class Controller(object): self.doc.slidenumber != self.doc.get_slide_number(): self.doc.goto_slide(self.doc.slidenumber) self.doc.unblank_screen() + Receiver.send_message(u'maindisplay_hide', HideMode.Screen) def poll(self): self.doc.poll_slidenumber(self.isLive) From 40fbf5ad6369590adfe1120c4323a6ac0a1c5835 Mon Sep 17 00:00:00 2001 From: Frode Woldsund Date: Thu, 17 Jun 2010 00:11:11 +0200 Subject: [PATCH 34/44] Fixed syntax in translate() function that contained u'%s' and % stuff --- openlp/core/lib/mediamanageritem.py | 53 ++++++++++++++++------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 1d2c6bd41..0715a0c7f 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -208,43 +208,49 @@ class MediaManagerItem(QtGui.QWidget): ## Import Button ## if self.hasImportIcon: self.addToolbarButton( - u'Import %s' % self.PluginNameShort, - u'%s %s' % (translate(u'MediaManagerItem', u'Import a'), - self.PluginNameVisible), + unicode(translate(u'MediaManagerItem', u'Import %s')) % \ + self.PluginNameShort, + unicode(translate(u'MediaManagerItem', u'Import a %s')) % \ + self.PluginNameVisible, u':/general/general_import.png', self.onImportClick) ## File Button ## if self.hasFileIcon: self.addToolbarButton( - u'Load %s' % self.PluginNameShort, - u'%s %s' % (translate(u'MediaManagerItem', u'Load a new'), - self.PluginNameVisible), + unicode(translate(u'MediaManagerItem', u'Load %s')) % \ + self.PluginNameShort, + unicode(translate(u'MediaManagerItem', u'Load a new %s')) % \ + self.PluginNameVisible, u':/general/general_open.png', self.onFileClick) ## New Button ## if self.hasNewIcon: self.addToolbarButton( - u'New %s' % self.PluginNameShort, - u'%s %s' % (translate(u'MediaManagerItem', u'Add a new'), - self.PluginNameVisible), + unicode(translate(u'MediaManagerItem', u'New %s')) % \ + self.PluginNameShort, + unicode(translate(u'MediaManagerItem', u'Add a new %s')) % \ + self.PluginNameVisible, u':/general/general_new.png', self.onNewClick) ## Edit Button ## if self.hasEditIcon: self.addToolbarButton( - u'Edit %s' % self.PluginNameShort, - u'%s %s' % ( - translate(u'MediaManagerItem', u'Edit the selected'), - self.PluginNameVisible), + unicode(translate(u'MediaManagerItem', u'Edit %s')) % \ + self.PluginNameShort, + unicode(translate( + u'MediaManagerItem', u'Edit the selected %s')) % \ + self.PluginNameVisible, u':/general/general_edit.png', self.onEditClick) ## Delete Button ## if self.hasDeleteIcon: self.addToolbarButton( - u'Delete %s' % self.PluginNameShort, + unicode(translate(u'MediaManagerItem', u'Delete %s')) % \ + self.PluginNameShort, translate(u'MediaManagerItem', u'Delete the selected item'), u':/general/general_delete.png', self.onDeleteClick) ## Separator Line ## self.addToolbarSeparator() ## Preview ## self.addToolbarButton( - u'Preview %s' % self.PluginNameShort, + unicode(translate(u'MediaManagerItem', u'Preview %s')) % \ + self.PluginNameShort, translate(u'MediaManagerItem', u'Preview the selected item'), u':/general/general_preview.png', self.onPreviewClick) ## Live Button ## @@ -254,7 +260,8 @@ class MediaManagerItem(QtGui.QWidget): u':/general/general_live.png', self.onLiveClick) ## Add to service Button ## self.addToolbarButton( - u'Add %s to Service' % self.PluginNameShort, + unicode(translate(u'MediaManagerItem', u'Add %s to Service')) % \ + self.PluginNameShort, translate(u'MediaManagerItem', u'Add the selected item(s) to the service'), u':/general/general_add.png', self.onAddClick) @@ -278,23 +285,23 @@ class MediaManagerItem(QtGui.QWidget): self.ListView.addAction( contextMenuAction( self.ListView, u':/general/general_edit.png', - u'%s %s' % (translate(u'MediaManagerItem', u'&Edit'), - self.PluginNameVisible), + unicode(translate(u'MediaManagerItem', u'&Edit %s')) % \ + self.PluginNameVisible, self.onEditClick)) self.ListView.addAction(contextMenuSeparator(self.ListView)) if self.hasDeleteIcon: self.ListView.addAction( contextMenuAction( self.ListView, u':/general/general_delete.png', - u'%s %s' % (translate(u'MediaManagerItem', u'&Delete'), - self.PluginNameVisible), + unicode(translate(u'MediaManagerItem', u'&Delete %s')) % \ + self.PluginNameVisible, self.onDeleteClick)) self.ListView.addAction(contextMenuSeparator(self.ListView)) self.ListView.addAction( contextMenuAction( self.ListView, u':/general/general_preview.png', - u'%s %s' % (translate(u'MediaManagerItem', u'&Preview'), - self.PluginNameVisible), + unicode(translate(u'MediaManagerItem', u'&Preview %s')) % \ + self.PluginNameVisible, self.onPreviewClick)) self.ListView.addAction( contextMenuAction( @@ -471,7 +478,7 @@ class MediaManagerItem(QtGui.QWidget): QtGui.QMessageBox.information(self, translate(u'MediaManagerItem', u'Invalid Service Item'), translate(unicode(u'MediaManagerItem', - u'You must select a %s service item.' % self.title))) + u'You must select a %s service item.')) % self.title) def buildServiceItem(self, item=None): """ From 99d97a95a31aa1b4e5b88902b8c7d2939f98650e Mon Sep 17 00:00:00 2001 From: Frode Woldsund Date: Thu, 17 Jun 2010 00:17:50 +0200 Subject: [PATCH 35/44] removed a "enter-space" --- openlp/core/lib/mediamanageritem.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index fae9143b3..93cf1f92c 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -31,7 +31,6 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import context_menu_action, context_menu_separator, \ SettingsManager, OpenLPToolbar, ServiceItem, build_icon, translate - log = logging.getLogger(__name__) class MediaManagerItem(QtGui.QWidget): From 4683e208607b936a793479cb3d56e03acd5d09d2 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 17 Jun 2010 02:56:05 +0100 Subject: [PATCH 36/44] Fix addToServiceItem location --- openlp/core/lib/mediamanageritem.py | 2 +- openlp/plugins/bibles/lib/mediaitem.py | 2 +- openlp/plugins/images/lib/mediaitem.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 8df8bded9..f423005b4 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -110,7 +110,6 @@ class MediaManagerItem(QtGui.QWidget): self.remoteTriggered = None self.ServiceItemIconName = None self.singleServiceItem = True - self.addToServiceItem = False self.PageLayout = QtGui.QVBoxLayout(self) self.PageLayout.setSpacing(0) self.PageLayout.setContentsMargins(4, 0, 4, 0) @@ -133,6 +132,7 @@ class MediaManagerItem(QtGui.QWidget): self.hasEditIcon = True self.hasFileIcon = False self.hasDeleteIcon = True + self.addToServiceItem = False def retranslateUi(self): """ diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 191f26d44..9bda44ede 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -57,7 +57,6 @@ class BibleMediaItem(MediaManagerItem): self.IconPath = u'songs/song' self.ListViewWithDnD_class = BibleListView self.lastReference = [] - self.addToServiceItem = True MediaManagerItem.__init__(self, parent, icon, title) # place to store the search results self.search_results = {} @@ -79,6 +78,7 @@ class BibleMediaItem(MediaManagerItem): self.hasNewIcon = False self.hasEditIcon = False self.hasDeleteIcon = False + self.addToServiceItem = True def addEndHeaderBar(self): self.SearchTabWidget = QtGui.QTabWidget(self) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 0ab86f3f7..3fbde6af2 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -54,7 +54,6 @@ class ImageMediaItem(MediaManagerItem): # be instanced by the base MediaManagerItem self.ListViewWithDnD_class = ImageListView MediaManagerItem.__init__(self, parent, icon, title) - self.addToServiceItem = True def initPluginNameVisible(self): self.PluginNameVisible = translate(u'ImagePlugin.MediaItem', u'Image') @@ -74,6 +73,7 @@ class ImageMediaItem(MediaManagerItem): self.hasFileIcon = True self.hasNewIcon = False self.hasEditIcon = False + self.addToServiceItem = True def initialise(self): log.debug(u'initialise') From 143f361f8d3c2ae2dad70aa1ab67f2eb77c6b72b Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 17 Jun 2010 12:43:58 +0100 Subject: [PATCH 37/44] Fix translate and remove unused script --- openlp/core/lib/mediamanageritem.py | 2 +- scripts/get-strings.py | 116 ---------------------------- 2 files changed, 1 insertion(+), 117 deletions(-) delete mode 100755 scripts/get-strings.py diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index f423005b4..6b8d015bb 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -334,7 +334,7 @@ class MediaManagerItem(QtGui.QWidget): """ if not self.ListView.selectedIndexes(): QtGui.QMessageBox.information(self, - self.trUtf8('No Items Selected'), message) + translate(u'MediaManagerItem', u'No Items Selected'), message) return False return True diff --git a/scripts/get-strings.py b/scripts/get-strings.py deleted file mode 100755 index 5fa42a1fc..000000000 --- a/scripts/get-strings.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2010 Raoul Snyman # -# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # -# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin # -# Thompson, Jon Tibble, Carsten Tinggaard # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### - -import os -from cgi import escape -from ast import parse, NodeVisitor, Str - -ts_file = u""" - - -%s - -""" -ts_context = u""" - %s -%s -""" -ts_message = u""" - - %s - - -""" - -class StringExtractor(NodeVisitor): - - def __init__(self, strings, filename, base_path): - self.base_path = base_path - self.filename = filename - self.strings = strings - self.classname = 'unknown' - - def visit_ClassDef(self, node): - self.classname = node.name - self.generic_visit(node) - - def visit_Call(self, node): - if hasattr(node.func, 'attr') and node.func.attr == 'trUtf8' and isinstance(node.args[0], Str): - string = node.args[0].s - key = '%s-%s' % (self.classname, string) - self.strings[key] = [self.classname, self.filename[len(self.base_path) + 1:], node.lineno, escape(string)] - self.generic_visit(node) - -def parse_file(base_path, filename, strings): - file = open(filename, u'r') - try: - ast = parse(file.read()) - except SyntaxError, e: - print "Unable to parse %s: %s" % (filename, e) - return - file.close() - - StringExtractor(strings, filename, base_path).visit(ast) - -def write_file(filename, strings): - translation_file = u'' - translation_contexts = [] - translation_messages = [] - class_name = strings[strings.keys()[0]][0] - current_context = u'' - for key, translation in strings.iteritems(): - if class_name != translation[0]: - current_context = ts_context % (class_name, u''.join(translation_messages)) - translation_contexts.append(current_context) - translation_messages = [] - class_name = translation[0] - translation_messages.append(ts_message % (translation[1], translation[2], translation[3])) - current_context = ts_context % (class_name, u''.join(translation_messages)) - translation_contexts.append(current_context) - translation_file = ts_file % (u''.join(translation_contexts)) - file = open(filename, u'w') - file.write(translation_file.encode('utf8')) - file.close() - -def main(): - strings = {} - start_dir = os.path.abspath(u'..') - for root, dirs, files in os.walk(start_dir): - for file in files: - if file.startswith(u'hook-') or file.startswith(u'test_'): - continue - if file.endswith(u'.py'): - print u'Parsing "%s"' % file - parse_file(start_dir, os.path.join(root, file), strings) - print u'Generating TS file...', - write_file(os.path.join(start_dir, u'resources', u'i18n', u'openlp_en.ts'), strings) - print u'done.' - -if __name__ == u'__main__': - if os.path.split(os.path.abspath(u'.'))[1] != u'scripts': - print u'You need to run this script from the scripts directory.' - else: - main() From 7c6b5c0b9991ce4814e5f71b300a269927548979 Mon Sep 17 00:00:00 2001 From: Frode Woldsund Date: Thu, 17 Jun 2010 14:02:18 +0200 Subject: [PATCH 38/44] translate(pluginName.pluginName) -> translate(pluginName) and removed some spaces --- openlp/core/lib/mediamanageritem.py | 8 +++--- openlp/plugins/alerts/alertsplugin.py | 6 ++--- openlp/plugins/bibles/bibleplugin.py | 6 ++--- openlp/plugins/custom/customplugin.py | 2 +- openlp/plugins/images/imageplugin.py | 2 +- openlp/plugins/media/mediaplugin.py | 2 +- .../presentations/presentationplugin.py | 2 +- openlp/plugins/remotes/remoteplugin.py | 2 +- openlp/plugins/songs/songsplugin.py | 26 +++++++++---------- openlp/plugins/songusage/songusageplugin.py | 16 ++++++------ 10 files changed, 36 insertions(+), 36 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 93cf1f92c..516dd6f44 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -224,7 +224,7 @@ class MediaManagerItem(QtGui.QWidget): ## New Button ## if self.hasNewIcon: self.addToolbarButton( - unicode(translate(u'MediaManagerItem', u'New %s')) % \ + unicode(translate(u'MediaManagerItem', u'New %s')) % \ self.PluginNameShort, unicode(translate(u'MediaManagerItem', u'Add a new %s')) % \ self.PluginNameVisible, @@ -232,7 +232,7 @@ class MediaManagerItem(QtGui.QWidget): ## Edit Button ## if self.hasEditIcon: self.addToolbarButton( - unicode(translate(u'MediaManagerItem', u'Edit %s')) % \ + unicode(translate(u'MediaManagerItem', u'Edit %s')) % \ self.PluginNameShort, unicode(translate( u'MediaManagerItem', u'Edit the selected %s')) % \ @@ -241,7 +241,7 @@ class MediaManagerItem(QtGui.QWidget): ## Delete Button ## if self.hasDeleteIcon: self.addToolbarButton( - unicode(translate(u'MediaManagerItem', u'Delete %s')) % \ + unicode(translate(u'MediaManagerItem', u'Delete %s')) % \ self.PluginNameShort, translate(u'MediaManagerItem', u'Delete the selected item'), u':/general/general_delete.png', self.onDeleteClick) @@ -260,7 +260,7 @@ class MediaManagerItem(QtGui.QWidget): u':/general/general_live.png', self.onLiveClick) ## Add to service Button ## self.addToolbarButton( - unicode(translate(u'MediaManagerItem', u'Add %s to Service')) % \ + unicode(translate(u'MediaManagerItem', u'Add %s to Service')) % \ self.PluginNameShort, translate(u'MediaManagerItem', u'Add the selected item(s) to the service'), diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 7474a0564..eb6d1f116 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -64,9 +64,9 @@ class alertsPlugin(Plugin): self.toolsAlertItem.setIcon(AlertIcon) self.toolsAlertItem.setObjectName(u'toolsAlertItem') self.toolsAlertItem.setText( - translate(u'AlertsPlugin.AlertsPlugin', u'&Alert')) + translate(u'AlertsPlugin', u'&Alert')) self.toolsAlertItem.setStatusTip( - translate(u'AlertsPlugin.AlertsPlugin', u'Show an alert message')) + translate(u'AlertsPlugin', u'Show an alert message')) self.toolsAlertItem.setShortcut(u'F7') self.service_manager.parent.ToolsMenu.addAction(self.toolsAlertItem) QtCore.QObject.connect(self.toolsAlertItem, @@ -94,7 +94,7 @@ class alertsPlugin(Plugin): self.alertForm.exec_() def about(self): - about_text = translate(u'AlertsPlugin.AlertsPlugin', + about_text = translate(u'AlertsPlugin', u'Alerts Plugin
This plugin ' u'controls the displaying of alerts on the presentations screen') return about_text diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index bfaa535a9..f3998e5a5 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -71,7 +71,7 @@ class BiblePlugin(Plugin): self.ImportBibleItem.setObjectName(u'ImportBibleItem') import_menu.addAction(self.ImportBibleItem) self.ImportBibleItem.setText( - translate(u'BiblesPlugin.BiblePlugin', u'&Bible')) + translate(u'BiblePlugin', u'&Bible')) # Signals and slots QtCore.QObject.connect(self.ImportBibleItem, QtCore.SIGNAL(u'triggered()'), self.onBibleImportClick) @@ -82,7 +82,7 @@ class BiblePlugin(Plugin): self.ExportBibleItem.setObjectName(u'ExportBibleItem') export_menu.addAction(self.ExportBibleItem) self.ExportBibleItem.setText(translate( - u'BiblesPlugin.BiblePlugin', u'&Bible')) + u'BiblePlugin', u'&Bible')) self.ExportBibleItem.setVisible(False) def onBibleImportClick(self): @@ -90,7 +90,7 @@ class BiblePlugin(Plugin): self.media_item.onImportClick() def about(self): - about_text = translate(u'BiblesPlugin.BiblePlugin', + about_text = translate(u'BiblePlugin', u'Bible Plugin
This ' u'plugin allows bible verses from different sources to be ' u'displayed on the screen during the service.') diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index 9ae208a28..2ad95b026 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -67,7 +67,7 @@ class CustomPlugin(Plugin): self.remove_toolbox_item() def about(self): - about_text = translate(u'CustomPlugin.CustomPlugin', + about_text = translate(u'CustomPlugin', u'Custom Plugin
This plugin ' u'allows slides to be displayed on the screen in the same way ' u'songs are. This plugin provides greater freedom over the ' diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index ca375ed6c..343a87491 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -56,7 +56,7 @@ class ImagePlugin(Plugin): return ImageMediaItem(self, self.icon, self.name) def about(self): - about_text = translate(u'ImagePlugin.ImagePlugin', u'Image Plugin' + about_text = translate(u'ImagePlugin', u'Image Plugin' u'
Allows images of all types to be displayed. If a number ' u'of images are selected together and presented on the live ' u'controller it is possible to turn them into a timed loop.' diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index 7c773c5a7..7f6e54472 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -81,7 +81,7 @@ class MediaPlugin(Plugin): return MediaMediaItem(self, self.icon, self.name) def about(self): - about_text = translate(u'MediaPlugin.MediaPlugin', + about_text = translate(u'MediaPlugin', u'Media Plugin
This plugin ' u'allows the playing of audio and video media') return about_text diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 036e8fc42..f59968287 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -108,7 +108,7 @@ class PresentationPlugin(Plugin): return False def about(self): - about_text = translate(u'PresentationPlugin.PresentationPlugin', + about_text = translate(u'PresentationPlugin', u'Presentation Plugin
Delivers ' u'the ability to show presentations using a number of different ' u'programs. The choice of available presentation programs is ' diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index e3d68a9a3..c839f1595 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -69,7 +69,7 @@ class RemotesPlugin(Plugin): """ Information about this plugin """ - about_text = translate(u'RemotePlugin.RemotePlugin', + about_text = translate(u'RemotePlugin', u'Remote Plugin
This plugin ' u'provides the ability to send messages to a running version of ' u'openlp on a different computer via a web browser or other app
' diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index dad471043..21ec610b2 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -95,9 +95,9 @@ class SongsPlugin(Plugin): self.SongImportItem = QtGui.QAction(import_menu) self.SongImportItem.setObjectName(u'SongImportItem') self.SongImportItem.setText(translate( - u'SongsPlugin.SongsPlugin', u'&Song')) + u'SongsPlugin', u'&Song')) self.SongImportItem.setToolTip( - translate(u'SongsPlugin.SongsPlugin', + translate(u'SongsPlugin', u'Import songs using the import wizard.')) import_menu.addAction(self.SongImportItem) # Songs of Fellowship import menu item - will be removed and the @@ -105,14 +105,14 @@ class SongsPlugin(Plugin): self.ImportSofItem = QtGui.QAction(import_menu) self.ImportSofItem.setObjectName(u'ImportSofItem') self.ImportSofItem.setText( - translate(u'SongsPlugin.SongsPlugin', + translate(u'SongsPlugin', u'Songs of Fellowship (temp menu item)')) self.ImportSofItem.setToolTip( - translate(u'SongsPlugin.SongsPlugin', + translate(u'SongsPlugin', u'Import songs from the VOLS1_2.RTF, sof3words' \ + u'.rtf and sof4words.rtf supplied with the music books')) self.ImportSofItem.setStatusTip( - translate(u'SongsPlugin.SongsPlugin', + translate(u'SongsPlugin', u'Import songs from the VOLS1_2.RTF, sof3words' \ + u'.rtf and sof4words.rtf supplied with the music books')) import_menu.addAction(self.ImportSofItem) @@ -121,15 +121,15 @@ class SongsPlugin(Plugin): self.ImportOooItem = QtGui.QAction(import_menu) self.ImportOooItem.setObjectName(u'ImportOooItem') self.ImportOooItem.setText( - translate(u'SongsPlugin.SongsPlugin', + translate(u'SongsPlugin', u'Generic Document/Presentation Import ' u'(temp menu item)')) self.ImportOooItem.setToolTip( - translate(u'SongsPlugin.SongsPlugin', + translate(u'SongsPlugin', u'Import songs from ' u'Word/Writer/Powerpoint/Impress')) self.ImportOooItem.setStatusTip( - translate(u'SongsPlugin.SongsPlugin', + translate(u'SongsPlugin', u'Import songs from ' u'Word/Writer/Powerpoint/Impress')) import_menu.addAction(self.ImportOooItem) @@ -159,7 +159,7 @@ class SongsPlugin(Plugin): def onImportSofItemClick(self): filenames = QtGui.QFileDialog.getOpenFileNames( - None, translate(u'SongsPlugin.Songsplugin', + None, translate(u'SongsPlugin', u'Open Songs of Fellowship file'), u'', u'Songs of Fellowship file (*.rtf *.RTF)') try: @@ -169,9 +169,9 @@ class SongsPlugin(Plugin): except: log.exception('Could not import SoF file') QtGui.QMessageBox.critical(None, - translate(u'SongsPlugin.SongsPlugin', + translate(u'SongsPlugin', u'Import Error'), - translate(u'SongsPlugin.SongsPlugin', + translate(u'SongsPlugin', u'Error importing Songs of ' u'Fellowship file.\nOpenOffice.org must be installed' u' and you must be using an unedited copy of the RTF' @@ -182,7 +182,7 @@ class SongsPlugin(Plugin): def onImportOooItemClick(self): filenames = QtGui.QFileDialog.getOpenFileNames( - None, translate(u'SongsPlugin.Songsplugin', + None, translate(u'SongsPlugin', u'Open documents or presentations'), u'', u'All Files(*.*)') oooimport = OooImport(self.manager) @@ -190,7 +190,7 @@ class SongsPlugin(Plugin): Receiver.send_message(u'songs_load_list') def about(self): - about_text = translate(u'SongsPlugin.Songsplugin', + about_text = translate(u'SongsPlugin', u'Song Plugin
' u'This plugin allows songs to be managed and displayed.') return about_text diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index 7cc75f764..0b3d7971c 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -60,23 +60,23 @@ class SongUsagePlugin(Plugin): self.SongUsageMenu = QtGui.QMenu(tools_menu) self.SongUsageMenu.setObjectName(u'SongUsageMenu') self.SongUsageMenu.setTitle(translate( - u'SongUsagePlugin.SongUsagePlugin', u'&Song Usage')) + u'SongUsagePlugin', u'&Song Usage')) #SongUsage Delete self.SongUsageDelete = QtGui.QAction(tools_menu) self.SongUsageDelete.setText( - translate(u'SongUsagePlugin.SongUsagePlugin', + translate(u'SongUsagePlugin', u'&Delete recorded data')) self.SongUsageDelete.setStatusTip( - translate(u'SongUsagePlugin.SongUsagePlugin', + translate(u'SongUsagePlugin', u'Delete song usage to specified date')) self.SongUsageDelete.setObjectName(u'SongUsageDelete') #SongUsage Report self.SongUsageReport = QtGui.QAction(tools_menu) self.SongUsageReport.setText( - translate(u'SongUsagePlugin.SongUsagePlugin', + translate(u'SongUsagePlugin', u'&Extract recorded data')) self.SongUsageReport.setStatusTip( - translate(u'SongUsagePlugin.SongUsagePlugin', + translate(u'SongUsagePlugin', u'Generate report on Song Usage')) self.SongUsageReport.setObjectName(u'SongUsageReport') #SongUsage activation @@ -86,9 +86,9 @@ class SongUsagePlugin(Plugin): self.SongUsageStatus.setCheckable(True) self.SongUsageStatus.setChecked(False) self.SongUsageStatus.setText(translate( - u'SongUsagePlugin.SongUsagePlugin', u'Song Usage Status')) + u'SongUsagePlugin', u'Song Usage Status')) self.SongUsageStatus.setStatusTip( - translate(u'SongUsagePlugin.SongUsagePlugin', + translate(u'SongUsagePlugin', u'Start/Stop live song usage recording')) self.SongUsageStatus.setShortcut(u'F4') self.SongUsageStatus.setObjectName(u'SongUsageStatus') @@ -163,7 +163,7 @@ class SongUsagePlugin(Plugin): self.SongUsagedetailform.exec_() def about(self): - about_text = translate(u'SongsPlugin.SongUsagePlugin', + about_text = translate(u'SongUsagePlugin', u'SongUsage Plugin
This plugin ' u'records the use of songs and when they have been used during ' u'a live service') From 035ae84f39ff9230fa987ff0c396f258cdbbcb3c Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 17 Jun 2010 15:23:50 +0100 Subject: [PATCH 39/44] Import translate --- openlp/core/ui/splashscreen.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/splashscreen.py b/openlp/core/ui/splashscreen.py index d964ed610..f49d73815 100644 --- a/openlp/core/ui/splashscreen.py +++ b/openlp/core/ui/splashscreen.py @@ -24,7 +24,8 @@ ############################################################################### from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon + +from openlp.core.lib import build_icon, translate class SplashScreen(object): def __init__(self, version): From 16ab2da4d68e3d82c9911eaa833aad09ff5d54f3 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 17 Jun 2010 22:01:30 +0100 Subject: [PATCH 40/44] Fix HTTPBible verse counts --- openlp/plugins/bibles/lib/http.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index d3d6ca5f6..073b03118 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -137,10 +137,10 @@ class HTTPBooks(object): u'verses FROM chapters WHERE book_id = ?', (book[u'id'],)) if chapters: return { - u'id': chapters[0][0], - u'book_id': chapters[0][1], - u'chapter': chapters[0][2], - u'verses': chapters[0][3] + u'id': chapters[chapter][0], + u'book_id': chapters[chapter][1], + u'chapter': chapters[chapter][2], + u'verses': chapters[chapter][3] } else: return None From 5dc87d3ede974800cbdf74216d387d239b95edcd Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 17 Jun 2010 22:07:01 +0100 Subject: [PATCH 41/44] Cleanups --- openlp/core/ui/mainwindow.py | 3 ++- openlp/core/ui/pluginform.py | 6 ++++-- openlp/core/ui/thememanager.py | 3 ++- openlp/plugins/songs/forms/songimportwizard.py | 9 ++++++--- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index b016afa58..9efadddd8 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -654,7 +654,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): settings.beginGroup(self.generalSettingsSection) if settings.value(u'screen blank', QtCore.QVariant(False)).toBool(): self.LiveController.mainDisplaySetBackground() - if settings.value(u'blank warning', QtCore.QVariant(False)).toBool(): + if settings.value(u'blank warning', + QtCore.QVariant(False)).toBool(): QtGui.QMessageBox.question(self, translate(u'MainWindow', u'OpenLP Main Display Blanked'), translate(u'MainWindow', diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index db8b0a603..a91dd9a12 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -67,9 +67,11 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): if plugin.status == PluginStatus.Active: status_text = unicode(translate(u'PluginForm', u'%s (Active)')) elif plugin.status == PluginStatus.Inactive: - status_text = unicode(translate(u'PluginForm', u'%s (Inactive)')) + status_text = unicode( + translate(u'PluginForm', u'%s (Inactive)')) elif plugin.status == PluginStatus.Disabled: - status_text = unicode(translate(u'PluginForm', u'%s (Disabled)')) + status_text = unicode( + translate(u'PluginForm', u'%s (Disabled)')) item.setText(status_text % plugin.name) # If the plugin has an icon, set it! if plugin.icon: diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index c19f1d4a2..a5d6644de 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -435,7 +435,8 @@ class ThemeManager(QtGui.QWidget): 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) + log.exception(u'Theme file dosen\'t contain XML data %s' % + filename) except (IOError, NameError): QtGui.QMessageBox.critical( self, translate(u'ThemeManager', u'Error'), diff --git a/openlp/plugins/songs/forms/songimportwizard.py b/openlp/plugins/songs/forms/songimportwizard.py index 0556d1665..c684bd74b 100644 --- a/openlp/plugins/songs/forms/songimportwizard.py +++ b/openlp/plugins/songs/forms/songimportwizard.py @@ -113,7 +113,8 @@ class Ui_SongImportWizard(object): self.OpenIcon.addPixmap(QtGui.QPixmap(u':/general/general_open.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.DeleteIcon = QtGui.QIcon() - self.DeleteIcon.addPixmap(QtGui.QPixmap(u':/general/general_delete.png'), + self.DeleteIcon.addPixmap( + QtGui.QPixmap(u':/general/general_delete.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.OpenLyricsAddButton.setIcon(self.OpenIcon) self.OpenLyricsAddButton.setObjectName(u'OpenLyricsAddButton') @@ -185,7 +186,8 @@ class Ui_SongImportWizard(object): self.CSVLayout.setObjectName(u'CSVLayout') self.CSVFilenameLabel = QtGui.QLabel(self.CSVPage) self.CSVFilenameLabel.setObjectName(u'CSVFilenameLabel') - self.CSVLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.CSVFilenameLabel) + self.CSVLayout.setWidget(0, QtGui.QFormLayout.LabelRole, + self.CSVFilenameLabel) self.CSVFileLayout = QtGui.QHBoxLayout() self.CSVFileLayout.setSpacing(8) self.CSVFileLayout.setObjectName(u'CSVFileLayout') @@ -196,7 +198,8 @@ class Ui_SongImportWizard(object): self.CSVBrowseButton.setIcon(self.OpenIcon) self.CSVBrowseButton.setObjectName(u'CSVBrowseButton') self.CSVFileLayout.addWidget(self.CSVBrowseButton) - self.CSVLayout.setLayout(0, QtGui.QFormLayout.FieldRole, self.CSVFileLayout) + self.CSVLayout.setLayout(0, QtGui.QFormLayout.FieldRole, + self.CSVFileLayout) self.FormatStackedWidget.addWidget(self.CSVPage) self.SourceLayout.addWidget(self.FormatStackedWidget) SongImportWizard.addPage(self.SourcePage) From 8382ea5303b3da443b829e39c7fa550d39586ac2 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 18 Jun 2010 00:17:16 +0100 Subject: [PATCH 42/44] Fix service manager DnD (Bug #595671) --- openlp/core/ui/servicemanager.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 081087a03..03efb514f 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -927,13 +927,9 @@ class ServiceManager(QtGui.QWidget): endpos = len(self.serviceItems) else: endpos = self._getParentItemData(item) - 1 - if endpos < startpos: - newpos = endpos - else: - newpos = endpos + 1 serviceItem = self.serviceItems[startpos] self.serviceItems.remove(serviceItem) - self.serviceItems.insert(newpos, serviceItem) + self.serviceItems.insert(endpos, serviceItem) self.repaintServiceList(endpos, startCount) else: #we are not over anything so drop From e4f77dbacb1c3a982b7dec2d7d3510a2f026b1c5 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 18 Jun 2010 06:58:40 +0100 Subject: [PATCH 43/44] Bug fixes --- openlp/core/lib/serviceitem.py | 2 +- openlp/core/ui/slidecontroller.py | 2 +- openlp/plugins/bibles/lib/mediaitem.py | 16 ++++++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 3d3cec2c9..b3464888e 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -173,7 +173,7 @@ class ServiceItem(object): self.render_manager.set_override_theme(self.theme) format = self._display_frames[row][u'text'].split(u'\n') #if screen blank then do not display footer - if self.cache[row] is not None: + if len(self.cache) > 0 and self.cache[row] is not None: frame = self.cache[row] else: if format[0]: diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 6e8ba8b22..6fd857aa5 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -536,7 +536,7 @@ class SlideController(QtGui.QWidget): self.PreviewListWidget.setCursor(QtCore.Qt.PointingHandCursor) before = time.time() #Clear the old serviceItem cache to release memory - if self.serviceItem: + if self.serviceItem and self.serviceItem is not serviceItem: self.serviceItem.cache = [] self.serviceItem = serviceItem self.PreviewListWidget.clear() diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index d922cb446..724add4d5 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -147,7 +147,7 @@ class BibleMediaItem(MediaManagerItem): self.QuickMessage = QtGui.QLabel(self.QuickTab) self.QuickMessage.setObjectName(u'QuickMessage') self.QuickLayout.addWidget(self.QuickMessage, 6, 0, 1, 3) - self.SearchTabWidget.addTab(self.QuickTab, + self.SearchTabWidget.addTab(self.QuickTab, translate(u'BiblesPlugin.MediaItem', u'Quick')) QuickSpacerItem = QtGui.QSpacerItem(20, 35, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) @@ -232,7 +232,7 @@ class BibleMediaItem(MediaManagerItem): self.AdvancedMessage = QtGui.QLabel(self.AdvancedTab) self.AdvancedMessage.setObjectName(u'AdvancedMessage') self.AdvancedLayout.addWidget(self.AdvancedMessage, 8, 0, 1, 3) - self.SearchTabWidget.addTab(self.AdvancedTab, + self.SearchTabWidget.addTab(self.AdvancedTab, translate(u'BiblesPlugin.MediaItem', u'Advanced')) # Add the search tab widget to the page layout self.PageLayout.addWidget(self.SearchTabWidget) @@ -387,7 +387,7 @@ class BibleMediaItem(MediaManagerItem): def onNoBookFound(self): QtGui.QMessageBox.critical(self, translate(u'BiblesPlugin.MediaItem', u'No Book Found'), - translate(u'BiblesPlugin.MediaItem', + translate(u'BiblesPlugin.MediaItem', u'No matching book could be found in this Bible.'), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok), QtGui.QMessageBox.Ok @@ -495,7 +495,7 @@ class BibleMediaItem(MediaManagerItem): if bible2_version: bible2_version = bible2_version.value else: - bible2_version = u'' + bible2_version = u'' if bible2_copyright: bible2_copyright = bible2_copyright.value else: @@ -558,7 +558,7 @@ class BibleMediaItem(MediaManagerItem): service_item.title = u'%s %s' % (book, verse_text) elif service_item.title.find( translate(u'BiblesPlugin.MediaItem', u'etc')) == -1: - service_item.title = u'%s, %s' % (service_item.title, + service_item.title = u'%s, %s' % (service_item.title, translate(u'BiblesPlugin.MediaItem', u'etc')) if len(self.parent.settings_tab.bible_theme) == 0: service_item.theme = None @@ -569,7 +569,11 @@ class BibleMediaItem(MediaManagerItem): raw_slides.append(bible_text) for slide in raw_slides: service_item.add_from_text(slide[:30], slide) - service_item.raw_footer = raw_footer + if service_item.raw_footer: + for foot in raw_footer: + service_item.raw_footer.append(foot) + else: + service_item.raw_footer = raw_footer return True def formatVerse(self, old_chapter, chapter, verse, opening, closing): From 0d35135945a0edf67f2ae39cfb116a56db781a8f Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 18 Jun 2010 08:42:38 +0100 Subject: [PATCH 44/44] Fix Bug #595672 --- openlp/core/ui/serviceitemeditform.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openlp/core/ui/serviceitemeditform.py b/openlp/core/ui/serviceitemeditform.py index eddf064e9..1ea829f81 100644 --- a/openlp/core/ui/serviceitemeditform.py +++ b/openlp/core/ui/serviceitemeditform.py @@ -96,6 +96,7 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog): self.itemList.remove(self.itemList[row]) self.itemList.insert(row - 1, temp) self.loadData() + self.listWidget.setCurrentRow(row - 1) def onItemDown(self): """ @@ -109,3 +110,4 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog): self.itemList.remove(self.itemList[row]) self.itemList.insert(row + 1, temp) self.loadData() + self.listWidget.setCurrentRow(row + 1)