From a35b50e7277b77104f0764d604fe7b0ae82e4362 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 3 Jan 2011 22:14:56 +0100 Subject: [PATCH 01/31] reindex tool adds 'author unknown' if songs do not have any author --- openlp/plugins/songs/songsplugin.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 545497acb..63d104d24 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -32,7 +32,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import Plugin, StringContent, build_icon, translate from openlp.core.lib.db import Manager from openlp.plugins.songs.lib import SongMediaItem, SongsTab, SongXMLParser -from openlp.plugins.songs.lib.db import init_schema, Song +from openlp.plugins.songs.lib.db import Author, init_schema, Song from openlp.plugins.songs.lib.importer import SongFormat log = logging.getLogger(__name__) @@ -146,6 +146,15 @@ class SongsPlugin(Plugin): counter = 0 for song in songs: counter += 1 + # The song does not have any author, add one. + if not song.authors: + name = unicode(translate('SongsPlugin', 'Author unknown')) + author = self.manager.get_object_filtered(Author, + Author.display_name == name) + if author is None: + author = Author.populate(first_name=name.rsplit(u' ', 1)[0], + last_name=name.rsplit(u' ', 1)[1], display_name=name) + song.authors.append(author) if song.title is None: song.title = u'' if song.alternate_title is None: From 8498b3e2ae4380f3fbed7a965570331702c862ee Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 10 Feb 2011 18:11:14 +0100 Subject: [PATCH 02/31] --- openlp/plugins/songs/songsplugin.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 37f11582a..2bd636097 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -149,12 +149,14 @@ class SongsPlugin(Plugin): counter += 1 # The song does not have any author, add one. if not song.authors: - name = unicode(translate('SongsPlugin', 'Author unknown')) + name = unicode(translate('SongsPlugin', 'Author unknown', + 'Translation must contain a blank character!')) author = self.manager.get_object_filtered(Author, Author.display_name == name) if author is None: - author = Author.populate(first_name=name.rsplit(u' ', 1)[0], - last_name=name.rsplit(u' ', 1)[1], display_name=name) + author = Author.populate( + first_name=name.split(u' ', 1)[:-1], + last_name=name.split(u' ', 1)[-1], display_name=name) song.authors.append(author) if song.title is None: song.title = u'' From 68d6bc46d682d3f87bf9b27461f01f7a8b797eff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Mon, 14 Feb 2011 13:20:30 +0100 Subject: [PATCH 03/31] Comment 14.02.2011 --- openlp/plugins/songs/forms/songimportform.py | 46 ++++++++++++++++++++ openlp/plugins/songs/lib/importer.py | 7 ++- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 433c9abfc..e07b8c019 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -140,6 +140,12 @@ class SongImportForm(OpenLPWizard): QtCore.QObject.connect(self.songBeamerRemoveButton, QtCore.SIGNAL(u'clicked()'), self.onSongBeamerRemoveButtonClicked) + QtCore.QObject.connect(self.foilPresenterAddButton, + QtCore.SIGNAL(u'clicked()'), + self.onFoilPresenterAddButtonClicked), + QtCore.QObject.connect(self.foilPresenterRemoveButton, + QtCore.SIGNAL(u'clicked()'), + self.onFoilPresenterRemoveButtonClicked) def addCustomPages(self): """ @@ -186,6 +192,8 @@ class SongImportForm(OpenLPWizard): self.addSingleFileSelectItem(u'ew') # Words of Worship self.addMultiFileSelectItem(u'songBeamer') + # Foilpresenter + self.addMultiFileSelectItem(u'foilPresenter') # Commented out for future use. # self.addSingleFileSelectItem(u'csv', u'CSV') self.sourceLayout.addLayout(self.formatStack) @@ -236,6 +244,8 @@ class SongImportForm(OpenLPWizard): translate('SongsPlugin.ImportWizardForm', 'EasyWorship')) self.formatComboBox.setItemText(10, translate('SongsPlugin.ImportWizardForm', 'SongBeamer')) + self.formatComboBox.setItemText(11, + translate('SongsPlugin.ImportWizardForm', 'FoilPresenter')) # self.formatComboBox.setItemText(11, # translate('SongsPlugin.ImportWizardForm', 'CSV')) self.openLP2FilenameLabel.setText( @@ -300,6 +310,10 @@ class SongImportForm(OpenLPWizard): translate('SongsPlugin.ImportWizardForm', 'Add Files...')) self.songBeamerRemoveButton.setText( translate('SongsPlugin.ImportWizardForm', 'Remove File(s)')) + self.foilPresenterAddButton.setText( + translate('SongsPlugin.ImportWizardForm', 'Add Files...')) + self.foilPresenterRemoveButton.setText( + translate('SongsPlugin.ImportWizardForm', 'Remove File(s)')) # self.csvFilenameLabel.setText( # translate('SongsPlugin.ImportWizardForm', 'Filename:')) # self.csvBrowseButton.setText( @@ -447,6 +461,16 @@ class SongImportForm(OpenLPWizard): 'file to import from.')) self.songBeamerAddButton.setFocus() return False + elif source_format == SongFormat.FoilPresenter: + if self.foilPresenterFileListWidget.count() == 0: + criticalErrorMessageBox( + translate('SongsPlugin.ImportWizardForm', + 'No Foilpresenter Files Selected'), + translate('SongsPlugin.ImportWizardForm', + 'You need to add at least one Foilpresenter ' + 'song file to import from.')) + self.foilPresenterAddButton.setFocus() + return False return True elif self.currentPage() == self.progressPage: return True @@ -682,6 +706,22 @@ class SongImportForm(OpenLPWizard): """ self.removeSelectedItems(self.songBeamerFileListWidget) + def onFoilPresenterAddButtonClicked(self): + """ + Get FoilPresenter song database files + """ + self.getFiles( + translate('SongsPlugin.ImportWizardForm', + 'Select FoilPresenter Files'), + self.foilPresenterFileListWidget + ) + + def onFoilPresenterRemoveButtonClicked(self): + """ + Remove selected FoilPresenter files from the import list + """ + self.removeSelectedItems(self.foilPresenterFileListWidget) + def registerFields(self): """ Register song import wizard fields. @@ -707,6 +747,7 @@ class SongImportForm(OpenLPWizard): self.easiSlidesFilenameEdit.setText(u'') self.ewFilenameEdit.setText(u'') self.songBeamerFileListWidget.clear() + self.foilPresenterFileListWidget.clear() #self.csvFilenameEdit.setText(u'') def preWizard(self): @@ -783,6 +824,11 @@ class SongImportForm(OpenLPWizard): importer = self.plugin.importSongs(SongFormat.SongBeamer, filenames=self.getListOfFiles(self.songBeamerFileListWidget) ) + elif source_format == SongFormat.FoilPresenter: + # Import Foilpresenter songs + importer = self.plugin.importSongs(SongFormat.FoilPresenter, + filenames=self.getListOfFiles(self.foilPresenterFileListWidget) + ) if importer.do_import(): # reload songs self.progressLabel.setText( diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index 91d3d7e6f..e914cc6ac 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -34,6 +34,7 @@ from wowimport import WowImport from cclifileimport import CCLIFileImport from ewimport import EasyWorshipSongImport from songbeamerimport import SongBeamerImport +from foilpresenterimport import FoilPresenterImport # Imports that might fail try: from olp1import import OpenLP1SongImport @@ -71,6 +72,7 @@ class SongFormat(object): EasiSlides = 8 EasyWorship = 9 SongBeamer = 10 + FoilPresenter = 11 @staticmethod def get_class(format): @@ -102,6 +104,8 @@ class SongFormat(object): return EasyWorshipSongImport elif format == SongFormat.SongBeamer: return SongBeamerImport + elif format == SongFormat.FoilPresenter: + return FoilPresenterImport return None @staticmethod @@ -120,7 +124,8 @@ class SongFormat(object): SongFormat.Generic, SongFormat.EasiSlides, SongFormat.EasyWorship, - SongFormat.SongBeamer + SongFormat.SongBeamer, + SongFormat.FoilPresenter ] @staticmethod From cafd7b397d3301431d05ef6a6c01aafaa3798fc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Mon, 14 Feb 2011 14:01:52 +0100 Subject: [PATCH 04/31] 14.02.2011 --- openlp/plugins/songs/forms/songimportform.py | 17 +++++++++-------- openlp/plugins/songs/lib/importer.py | 5 +---- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 6c5c90838..b6c7286bc 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -140,18 +140,18 @@ class SongImportForm(OpenLPWizard): QtCore.QObject.connect(self.songBeamerRemoveButton, QtCore.SIGNAL(u'clicked()'), self.onSongBeamerRemoveButtonClicked) - QtCore.QObject.connect(self.foilPresenterAddButton, - QtCore.SIGNAL(u'clicked()'), - self.onFoilPresenterAddButtonClicked), - QtCore.QObject.connect(self.foilPresenterRemoveButton, - QtCore.SIGNAL(u'clicked()'), - self.onFoilPresenterRemoveButtonClicked) QtCore.QObject.connect(self.songShowPlusAddButton, QtCore.SIGNAL(u'clicked()'), self.onSongShowPlusAddButtonClicked) QtCore.QObject.connect(self.songShowPlusRemoveButton, QtCore.SIGNAL(u'clicked()'), self.onSongShowPlusRemoveButtonClicked) + QtCore.QObject.connect(self.foilPresenterAddButton, + QtCore.SIGNAL(u'clicked()'), + self.onFoilPresenterAddButtonClicked) + QtCore.QObject.connect(self.foilPresenterRemoveButton, + QtCore.SIGNAL(u'clicked()'), + self.onFoilPresenterRemoveButtonClicked) def addCustomPages(self): """ @@ -200,10 +200,10 @@ class SongImportForm(OpenLPWizard): self.addFileSelectItem(u'ew', single_select=True) # Words of Worship self.addFileSelectItem(u'songBeamer') - # Foilpresenter - self.addFileSelectItem(u'foilPresenter') # Song Show Plus self.addFileSelectItem(u'songShowPlus') + # Foilpresenter + self.addFileSelectItem(u'foilPresenter') # Commented out for future use. # self.addFileSelectItem(u'csv', u'CSV', single_select=True) self.sourceLayout.addLayout(self.formatStack) @@ -475,6 +475,7 @@ class SongImportForm(OpenLPWizard): 'You need to add at least one SongShow Plus ' 'file to import from.')) self.wordsOfWorshipAddButton.setFocus() + return False elif source_format == SongFormat.FoilPresenter: if self.foilPresenterFileListWidget.count() == 0: criticalErrorMessageBox( diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index dbbcad596..53ba17de9 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -34,11 +34,8 @@ from wowimport import WowImport from cclifileimport import CCLIFileImport from ewimport import EasyWorshipSongImport from songbeamerimport import SongBeamerImport -<<<<<<< TREE -from foilpresenterimport import FoilPresenterImport -======= from songshowplusimport import SongShowPlusImport ->>>>>>> MERGE-SOURCE +from foilpresenterimport import FoilPresenterImport # Imports that might fail try: from olp1import import OpenLP1SongImport From e75c24bdd785d060e35a6e9ddd3121ab239b70ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Fri, 18 Feb 2011 21:40:07 +0100 Subject: [PATCH 05/31] Changed 18.02.2011 --- openlp/plugins/songs/forms/songimportform.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index b6c7286bc..361a076da 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -256,7 +256,7 @@ class SongImportForm(OpenLPWizard): self.formatComboBox.setItemText(11, translate('SongsPlugin.ImportWizardForm', 'SongShow Plus')) self.formatComboBox.setItemText(12, - translate('SongsPlugin.ImportWizardForm', 'FoilPresenter')) + translate('SongsPlugin.ImportWizardForm', 'Foilpresenter')) # self.formatComboBox.setItemText(11, # translate('SongsPlugin.ImportWizardForm', 'CSV')) self.openLP2FilenameLabel.setText( @@ -711,7 +711,9 @@ class SongImportForm(OpenLPWizard): self.getFiles( translate('SongsPlugin.ImportWizardForm', 'Select FoilPresenter Files'), - self.foilPresenterFileListWidget + self.foilPresenterFileListWidget, u'%s (*.foil)' + % translate('SongsPlugin.ImportWizardForm', + 'Foilpresenter Song Files') ) def onFoilPresenterRemoveButtonClicked(self): From ac8e435f93d22cab32c66fe722a68f2b15396963 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 19 Feb 2011 19:25:14 +0100 Subject: [PATCH 07/31] --- openlp/plugins/songs/songsplugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 3620fcf82..ef89212f1 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -35,6 +35,7 @@ from openlp.core.lib.ui import UiStrings from openlp.plugins.songs.lib import SongMediaItem, SongsTab, SongXML from openlp.plugins.songs.lib.db import Author, init_schema, Song from openlp.plugins.songs.lib.importer import SongFormat +from openlp.plugins.songs.lib.ui import SongStrings log = logging.getLogger(__name__) @@ -147,8 +148,7 @@ class SongsPlugin(Plugin): counter += 1 # The song does not have any author, add one. if not song.authors: - name = unicode(translate('SongsPlugin', 'Author unknown', - 'Translation must contain a blank character!')) + name = unicode(SongStrings.AuthorUnknownUnT) author = self.manager.get_object_filtered(Author, Author.display_name == name) if author is None: From 6208587b939333766412500d6552f2394598ed99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sat, 19 Feb 2011 22:34:51 +0100 Subject: [PATCH 08/31] foilpresenterimport - some changes --- openlp/core/ui/wizard.py | 1 + openlp/plugins/songs/forms/songimportform.py | 12 ++----- .../plugins/songs/lib/foilpresenterimport.py | 36 +++++++++---------- 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index 2960607e4..fc1edeecb 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -54,6 +54,7 @@ class WizardStrings(object): SoF = u'Songs of Fellowship' SSP = u'SongShow Plus' WoW = u'Words of Worship' + FP = u'Foilpresenter' # These strings should need a good reason to be retranslated elsewhere. FinishedImport = translate('OpenLP.Ui', 'Finished import.') FormatLabel = translate('OpenLP.Ui', 'Format:') diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index bc3e28a33..06de08a93 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -410,12 +410,8 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.FoilPresenter: if self.foilPresenterFileListWidget.count() == 0: - criticalErrorMessageBox( - translate('SongsPlugin.ImportWizardForm', - 'No Foilpresenter Files Selected'), - translate('SongsPlugin.ImportWizardForm', - 'You need to add at least one Foilpresenter ' - 'song file to import from.')) + critical_error_message_box(UiStrings.NFSp, + WizardStrings.YouSpecifyFile % WizardStrings.FP) self.foilPresenterAddButton.setFocus() return False return True @@ -613,9 +609,7 @@ class SongImportForm(OpenLPWizard): """ Get FoilPresenter song database files """ - self.getFiles( - translate('SongsPlugin.ImportWizardForm', - 'Select FoilPresenter Files'), + self.getFiles(WizardStrings.OpenTypeFile % WizardStrings.FP, self.foilPresenterFileListWidget, u'%s (*.foil)' % translate('SongsPlugin.ImportWizardForm', 'Foilpresenter Song Files') diff --git a/openlp/plugins/songs/lib/foilpresenterimport.py b/openlp/plugins/songs/lib/foilpresenterimport.py index 919901694..635137b00 100644 --- a/openlp/plugins/songs/lib/foilpresenterimport.py +++ b/openlp/plugins/songs/lib/foilpresenterimport.py @@ -94,6 +94,7 @@ import os from lxml import etree, objectify from openlp.core.lib import translate +from openlp.core.ui.wizard import WizardStrings from openlp.plugins.songs.lib import VerseType from openlp.plugins.songs.lib.songimport import SongImport from openlp.plugins.songs.lib.db import Author, Book, Song, Topic @@ -110,32 +111,27 @@ class FoilPresenterImport(SongImport): Initialise the import. """ log.debug(u'initialise FoilPresenterImport') - SongImport.__init__(self, master_manager) - self.master_manager = master_manager - self.FoilPresenter = FoilPresenter(master_manager) - if kwargs.has_key(u'filename'): - self.import_source = kwargs[u'filename'] - if kwargs.has_key(u'filenames'): - self.import_source = kwargs[u'filenames'] + SongImport.__init__(self, master_manager, **kwargs) + self.FoilPresenter = FoilPresenter(self.manager) def do_import(self): """ Imports the songs. """ self.import_wizard.progressBar.setMaximum(len(self.import_source)) + parser = etree.XMLParser(remove_blank_text=True) for file_path in self.import_source: if self.stop_import_flag: return False - self.import_wizard.incrementProgressBar(unicode(translate( - 'SongsPlugin.FoilPresenterImport', 'Importing %s...')) % - os.path.basename(file_path)) - parser = etree.XMLParser(remove_blank_text=True) - parsed_file = etree.parse(file_path, parser) - xml = unicode(etree.tostring(parsed_file)) - if self.FoilPresenter.xml_to_song(xml) is None: - log.debug(u'File could not be imported: %s' % file_path) - # Importing this song failed! For now we stop import. - return False + self.import_wizard.incrementProgressBar( + WizardStrings.ImportingType % os.path.basename(file_path)) + try: + parsed_file = etree.parse(file_path, parser) + xml = unicode(etree.tostring(parsed_file)) + if self.FoilPresenter.xml_to_song(xml) is None: + log.debug(u'File could not be imported: %s' % file_path) + except etree.XMLSyntaxError: + log.exception(u'XML syntax error in file %s' % file_path) return True class FoilPresenter(object): @@ -325,9 +321,9 @@ class FoilPresenter(object): for test_temp in test: author_temp.append(test_temp) for author in author_temp: - author = re.compile( - u'^[\/,;\-\s]+|[\/,;\-\s]+$|\s*[0-9]{4}\s*[\-\/]?\s*([0-9]{4})?[\/,;\-\s]*$' - ).sub(u'', author) + regex = u'^[\/,;\-\s]+|[\/,;\-\s]+$|'\ + '\s*[0-9]{4}\s*[\-\/]?\s*([0-9]{4})?[\/,;\-\s]*$' + author = re.compile(regex).sub(u'', author) author = re.compile( u'[0-9]{1,2}\.\s?J(ahr)?h\.|um\s*$|vor\s*$').sub(u'', author) From 265aeebf4bbca34afe5c157ba689d710a4acdb17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Mon, 21 Feb 2011 14:45:14 +0100 Subject: [PATCH 09/31] sort WizardStrings in alphapetical order --- openlp/core/ui/wizard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index fc1edeecb..209f3f212 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -47,6 +47,7 @@ class WizardStrings(object): CSV = u'CSV' EW = u'EasyWorship' ES = u'EasiSlides' + FP = u'Foilpresenter' OL = u'OpenLyrics' OS = u'OpenSong' OSIS = u'OSIS' @@ -54,7 +55,6 @@ class WizardStrings(object): SoF = u'Songs of Fellowship' SSP = u'SongShow Plus' WoW = u'Words of Worship' - FP = u'Foilpresenter' # These strings should need a good reason to be retranslated elsewhere. FinishedImport = translate('OpenLP.Ui', 'Finished import.') FormatLabel = translate('OpenLP.Ui', 'Format:') From 4aa69e53bbf0c70615bafa929a987273322799b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Mon, 21 Feb 2011 15:59:01 +0100 Subject: [PATCH 10/31] removed duplicate method registerFields() and sort some lines --- openlp/plugins/songs/forms/songimportform.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 06de08a93..3eecac4ba 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -604,6 +604,12 @@ class SongImportForm(OpenLPWizard): % translate('SongsPlugin.ImportWizardForm', 'SongShow Plus Song Files') ) + + def onSongShowPlusRemoveButtonClicked(self): + """ + Remove selected SongShow Plus files from the import list + """ + self.removeSelectedItems(self.songShowPlusFileListWidget) def onFoilPresenterAddButtonClicked(self): """ @@ -621,18 +627,6 @@ class SongImportForm(OpenLPWizard): """ self.removeSelectedItems(self.foilPresenterFileListWidget) - def registerFields(self): - """ - Register song import wizard fields. - """ - pass - - def onSongShowPlusRemoveButtonClicked(self): - """ - Remove selected SongShow Plus files from the import list - """ - self.removeSelectedItems(self.songShowPlusFileListWidget) - def setDefaults(self): """ Set default form values for the song import wizard. From 7d7f9a7d98172d4cf26ecc1e5f0f9a889fb8acde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Mon, 21 Feb 2011 17:16:56 +0200 Subject: [PATCH 11/31] fix #99 --- openlp/plugins/songs/lib/cclifileimport.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/cclifileimport.py b/openlp/plugins/songs/lib/cclifileimport.py index 3d08584d0..28c487a78 100644 --- a/openlp/plugins/songs/lib/cclifileimport.py +++ b/openlp/plugins/songs/lib/cclifileimport.py @@ -78,7 +78,20 @@ class CCLIFileImport(SongImport): details = chardet.detect(detect_content) detect_file.close() infile = codecs.open(filename, u'r', details['encoding']) - lines = infile.readlines() + try: + lines = infile.readlines() + infile.close() + except UnicodeDecodeError: + # First 2kB were not sufficient to detect file encoding. + # This time we read entire file. + detect_file = open(filename, u'r') + detect_content = detect_file.read() + details = chardet.detect(detect_content) + detect_file.close() + # We read the contents again. Should it be a try as well? + infile = codecs.open(filename, u'r', details['encoding']) + lines = infile.readlines() + infile.close() ext = os.path.splitext(filename)[1] if ext.lower() == u'.usr': log.info(u'SongSelect .usr format file found %s: ', From 24519832dfb8ebf8b70a88d5af494013bd9639d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Mon, 21 Feb 2011 17:49:09 +0200 Subject: [PATCH 12/31] More informational noise to debug log, extensions by mimetype. To justify: it seems that extension list is an important thing. --- openlp/plugins/media/mediaplugin.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index 12887a76c..bfe9dbff0 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -54,19 +54,16 @@ class MediaPlugin(Plugin): self._addToList(self.audio_list, mimetype) elif mimetype.startswith(u'video/'): self._addToList(self.video_list, mimetype) - log.info(u'MediaPlugin handles audio extensions: %s', - u' '.join(self.audio_list)) - log.info(u'MediaPlugin handles video extensions: %s', - u' '.join(self.video_list)) def _addToList(self, list, mimetype): - # Is it a media type extensions = mimetypes.guess_all_extensions(unicode(mimetype)) for extension in extensions: ext = u'*%s' % extension if ext not in list: list.append(ext) self.serviceManager.supportedSuffixes(extension[1:]) + log.info(u'MediaPlugin: %s extensions: %s' % (mimetype, + u' '.join(extensions))) def about(self): about_text = translate('MediaPlugin', 'Media Plugin' From e8b6bbe14179ff37a6da5aa3b4c4bb1ad430f939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Mon, 21 Feb 2011 17:56:23 +0200 Subject: [PATCH 13/31] revert a change --- openlp/plugins/songs/lib/cclifileimport.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/openlp/plugins/songs/lib/cclifileimport.py b/openlp/plugins/songs/lib/cclifileimport.py index 28c487a78..3d08584d0 100644 --- a/openlp/plugins/songs/lib/cclifileimport.py +++ b/openlp/plugins/songs/lib/cclifileimport.py @@ -78,20 +78,7 @@ class CCLIFileImport(SongImport): details = chardet.detect(detect_content) detect_file.close() infile = codecs.open(filename, u'r', details['encoding']) - try: - lines = infile.readlines() - infile.close() - except UnicodeDecodeError: - # First 2kB were not sufficient to detect file encoding. - # This time we read entire file. - detect_file = open(filename, u'r') - detect_content = detect_file.read() - details = chardet.detect(detect_content) - detect_file.close() - # We read the contents again. Should it be a try as well? - infile = codecs.open(filename, u'r', details['encoding']) - lines = infile.readlines() - infile.close() + lines = infile.readlines() ext = os.path.splitext(filename)[1] if ext.lower() == u'.usr': log.info(u'SongSelect .usr format file found %s: ', From 1e041d9158d72aa1f7ad177f38c756f55da07c5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Mon, 21 Feb 2011 17:02:28 +0100 Subject: [PATCH 14/31] remove some whitespaces --- openlp/plugins/songs/forms/songimportform.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 3eecac4ba..16c0f9edb 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -594,7 +594,7 @@ class SongImportForm(OpenLPWizard): Remove selected SongBeamer files from the import list """ self.removeSelectedItems(self.songBeamerFileListWidget) - + def onSongShowPlusAddButtonClicked(self): """ Get SongShow Plus song database files @@ -604,7 +604,7 @@ class SongImportForm(OpenLPWizard): % translate('SongsPlugin.ImportWizardForm', 'SongShow Plus Song Files') ) - + def onSongShowPlusRemoveButtonClicked(self): """ Remove selected SongShow Plus files from the import list From d486547abd5cfa3e248e471fe86cf62d58eb5c2f Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 21 Feb 2011 20:06:55 +0000 Subject: [PATCH 15/31] Fixes from last merge --- openlp/core/ui/__init__.py | 1 - openlp/core/ui/displaytagdialog.py | 24 +++++------ openlp/core/ui/displaytagform.py | 66 ++++++++++++++++-------------- 3 files changed, 47 insertions(+), 44 deletions(-) diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py index 5763b3470..0f62a6dcf 100644 --- a/openlp/core/ui/__init__.py +++ b/openlp/core/ui/__init__.py @@ -63,7 +63,6 @@ from splashscreen import SplashScreen from generaltab import GeneralTab from themestab import ThemesTab from advancedtab import AdvancedTab -from displaytagtab import DisplayTagTab from aboutform import AboutForm from pluginform import PluginForm from settingsform import SettingsForm diff --git a/openlp/core/ui/displaytagdialog.py b/openlp/core/ui/displaytagdialog.py index ab3363058..edb8567cf 100644 --- a/openlp/core/ui/displaytagdialog.py +++ b/openlp/core/ui/displaytagdialog.py @@ -123,30 +123,30 @@ class Ui_DisplayTagDialog(object): QtCore.QMetaObject.connectSlotsByName(displayTagDialog) def retranslateUi(self, displayTagDialog): - displayTagDialog.setWindowTitle(translate('OpenLP.displayTagForm', + displayTagDialog.setWindowTitle(translate('OpenLP.displayTagDialog', 'Configure Display Tags')) self.editGroupBox.setTitle( - translate('OpenLP.DisplayTagTab', 'Edit Selection')) + translate('OpenLP.DisplayTagDialog', 'Edit Selection')) self.updatePushButton.setText( - translate('OpenLP.DisplayTagTab', 'Update')) + translate('OpenLP.DisplayTagDialog', 'Update')) self.descriptionLabel.setText( - translate('OpenLP.DisplayTagTab', 'Description')) - self.tagLabel.setText(translate('OpenLP.DisplayTagTab', 'Tag')) + translate('OpenLP.DisplayTagDialog', 'Description')) + self.tagLabel.setText(translate('OpenLP.DisplayTagDialog', 'Tag')) self.startTagLabel.setText( - translate('OpenLP.DisplayTagTab', 'Start tag')) - self.endTagLabel.setText(translate('OpenLP.DisplayTagTab', 'End tag')) + translate('OpenLP.DisplayTagDialog', 'Start tag')) + self.endTagLabel.setText(translate('OpenLP.DisplayTagDialog', 'End tag')) self.deletePushButton.setText(UiStrings.Delete) self.defaultPushButton.setText( - translate('OpenLP.DisplayTagTab', 'Default')) + translate('OpenLP.DisplayTagDialog', 'Default')) self.newPushButton.setText(UiStrings.New) self.tagTableWidget.horizontalHeaderItem(0).setText( - translate('OpenLP.DisplayTagTab', 'Description')) + translate('OpenLP.DisplayTagDialog', 'Description')) self.tagTableWidget.horizontalHeaderItem(1).setText( - translate('OpenLP.DisplayTagTab', 'Tag id')) + translate('OpenLP.DisplayTagDialog', 'Tag id')) self.tagTableWidget.horizontalHeaderItem(2).setText( - translate('OpenLP.DisplayTagTab', 'Start Html')) + translate('OpenLP.DisplayTagDialog', 'Start Html')) self.tagTableWidget.horizontalHeaderItem(3).setText( - translate('OpenLP.DisplayTagTab', 'End Html')) + translate('OpenLP.DisplayTagDialog', 'End Html')) self.tagTableWidget.setColumnWidth(0, 120) self.tagTableWidget.setColumnWidth(1, 40) self.tagTableWidget.setColumnWidth(2, 240) diff --git a/openlp/core/ui/displaytagform.py b/openlp/core/ui/displaytagform.py index f7a8e7740..fa05c578a 100644 --- a/openlp/core/ui/displaytagform.py +++ b/openlp/core/ui/displaytagform.py @@ -47,6 +47,7 @@ class DisplayTagForm(QtGui.QDialog, Ui_DisplayTagDialog): """ QtGui.QDialog.__init__(self, parent) self.setupUi(self) + self.preLoad() QtCore.QObject.connect(self.tagTableWidget, QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onRowSelected) QtCore.QObject.connect(self.defaultPushButton, @@ -63,7 +64,18 @@ class DisplayTagForm(QtGui.QDialog, Ui_DisplayTagDialog): Load Display and set field state. """ # Create initial copy from master + self.preLoad() self._resetTable() + self.selected = -1 + return QtGui.QDialog.exec_(self) + + def preLoad(self): + """ + Load the Tags from store so can be used in the system or used to + update the display. If Cancel was selected this is needed to reset the + dsiplay to the correct version. + """ + # Initial Load of the Tags DisplayTags.reset_html_tags() user_expands = QtCore.QSettings().value(u'displayTags/html_tags', QtCore.QVariant(u'')).toString() @@ -74,37 +86,6 @@ class DisplayTagForm(QtGui.QDialog, Ui_DisplayTagDialog): # If we have some user ones added them as well for t in user_tags: DisplayTags.add_html_tag(t) - self.selected = -1 - self.load() - return QtGui.QDialog.exec_(self) - - def load(self): - """ - Load the form with data and set the initial state of the buttons - """ - self.newPushButton.setEnabled(True) - self.updatePushButton.setEnabled(False) - self.deletePushButton.setEnabled(False) - for linenumber, html in enumerate(DisplayTags.get_html_tags()): - self.tagTableWidget.setRowCount( - self.tagTableWidget.rowCount() + 1) - self.tagTableWidget.setItem(linenumber, 0, - QtGui.QTableWidgetItem(html[u'desc'])) - self.tagTableWidget.setItem(linenumber, 1, - QtGui.QTableWidgetItem(self._strip(html[u'start tag']))) - self.tagTableWidget.setItem(linenumber, 2, - QtGui.QTableWidgetItem(html[u'start html'])) - self.tagTableWidget.setItem(linenumber, 3, - QtGui.QTableWidgetItem(html[u'end html'])) - self.tagTableWidget.resizeRowsToContents() - self.descriptionLineEdit.setText(u'') - self.tagLineEdit.setText(u'') - self.startTagLineEdit.setText(u'') - self.endTagLineEdit.setText(u'') - self.descriptionLineEdit.setEnabled(False) - self.tagLineEdit.setEnabled(False) - self.startTagLineEdit.setEnabled(False) - self.endTagLineEdit.setEnabled(False) def accept(self): """ @@ -223,6 +204,29 @@ class DisplayTagForm(QtGui.QDialog, Ui_DisplayTagDialog): """ self.tagTableWidget.clearContents() self.tagTableWidget.setRowCount(0) + self.newPushButton.setEnabled(True) + self.updatePushButton.setEnabled(False) + self.deletePushButton.setEnabled(False) + for linenumber, html in enumerate(DisplayTags.get_html_tags()): + self.tagTableWidget.setRowCount( + self.tagTableWidget.rowCount() + 1) + self.tagTableWidget.setItem(linenumber, 0, + QtGui.QTableWidgetItem(html[u'desc'])) + self.tagTableWidget.setItem(linenumber, 1, + QtGui.QTableWidgetItem(self._strip(html[u'start tag']))) + self.tagTableWidget.setItem(linenumber, 2, + QtGui.QTableWidgetItem(html[u'start html'])) + self.tagTableWidget.setItem(linenumber, 3, + QtGui.QTableWidgetItem(html[u'end html'])) + self.tagTableWidget.resizeRowsToContents() + self.descriptionLineEdit.setText(u'') + self.tagLineEdit.setText(u'') + self.startTagLineEdit.setText(u'') + self.endTagLineEdit.setText(u'') + self.descriptionLineEdit.setEnabled(False) + self.tagLineEdit.setEnabled(False) + self.startTagLineEdit.setEnabled(False) + self.endTagLineEdit.setEnabled(False) def _strip(self, tag): """ From fdb5c574683b755b99f5aaa29f192040ef381fdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Mon, 21 Feb 2011 22:37:18 +0200 Subject: [PATCH 16/31] Additional extensions hack. --- openlp/plugins/media/lib/mediaitem.py | 4 ++-- openlp/plugins/media/mediaplugin.py | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 9f3f98636..8bf201180 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -61,8 +61,8 @@ class MediaMediaItem(MediaManagerItem): self.onNewPrompt = translate('MediaPlugin.MediaItem', 'Select Media') self.onNewFileMasks = unicode(translate('MediaPlugin.MediaItem', 'Videos (%s);;Audio (%s);;%s (*)')) % ( - u' '.join(self.parent.video_list), - u' '.join(self.parent.audio_list), UiStrings.AllFiles) + u' '.join(self.parent.video_extensions_list), + u' '.join(self.parent.audio_extensions_list), UiStrings.AllFiles) self.replaceAction.setText(UiStrings.ReplaceBG) self.replaceAction.setToolTip(UiStrings.ReplaceLiveBG) self.resetAction.setText(UiStrings.ResetBG) diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index bfe9dbff0..1514b6cb2 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -45,15 +45,19 @@ class MediaPlugin(Plugin): self.icon = build_icon(self.icon_path) # passed with drag and drop messages self.dnd_id = u'Media' - self.audio_list = [] - self.video_list = [] + # This is yet a dummy example: + self.additional_extensions = { + 'audio/msaudio': ['.mp3', '.aac'], + 'video/msvideo': ['.wmv', '.avi']} + self.audio_extensions_list = [] + self.video_extensions_list = [] mimetypes.init() for mimetype in Phonon.BackendCapabilities.availableMimeTypes(): mimetype = unicode(mimetype) if mimetype.startswith(u'audio/'): - self._addToList(self.audio_list, mimetype) + self._addToList(self.audio_extensions_list, mimetype) elif mimetype.startswith(u'video/'): - self._addToList(self.video_list, mimetype) + self._addToList(self.video_extensions_list, mimetype) def _addToList(self, list, mimetype): extensions = mimetypes.guess_all_extensions(unicode(mimetype)) @@ -64,6 +68,14 @@ class MediaPlugin(Plugin): self.serviceManager.supportedSuffixes(extension[1:]) log.info(u'MediaPlugin: %s extensions: %s' % (mimetype, u' '.join(extensions))) + if mimetype in self.additional_extensions.keys(): + for extension in self.additional_extensions[mimetype]: + ext = u'*%s' % extensions + if ext not in list: + list.append(ext) + self.serviceManager.supportedSuffixes(extension[1:]) + log.info(u'MediaPlugin: %s additional extensions: %s' % (mimetype, + u' '.join(self.additional_extensions[mimetype]))) def about(self): about_text = translate('MediaPlugin', 'Media Plugin' From 0ecc3c2dc9e5924559ed9222f0229526163c5bb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Mon, 21 Feb 2011 23:03:09 +0100 Subject: [PATCH 17/31] adapt "Author unknown" similar to xml.py correct some whitespaces and quotation marks --- .../plugins/songs/lib/foilpresenterimport.py | 85 +++++++++---------- 1 file changed, 42 insertions(+), 43 deletions(-) diff --git a/openlp/plugins/songs/lib/foilpresenterimport.py b/openlp/plugins/songs/lib/foilpresenterimport.py index 635137b00..963561cb5 100644 --- a/openlp/plugins/songs/lib/foilpresenterimport.py +++ b/openlp/plugins/songs/lib/foilpresenterimport.py @@ -99,6 +99,7 @@ from openlp.plugins.songs.lib import VerseType from openlp.plugins.songs.lib.songimport import SongImport from openlp.plugins.songs.lib.db import Author, Book, Song, Topic from openlp.plugins.songs.lib.xml import SongXML +from openlp.plugins.songs.lib.ui import SongStrings log = logging.getLogger(__name__) @@ -261,40 +262,40 @@ class FoilPresenter(object): if copyright: strings = [] author_temp = [] - if copyright.find(u"Copyright") != -1: - test = copyright.partition(u"Copyright") + if copyright.find(u'Copyright') != -1: + test = copyright.partition(u'Copyright') copyright = test[0] - elif copyright.find(u"copyright") != -1: - test = copyright.partition(u"copyright") + elif copyright.find(u'copyright') != -1: + test = copyright.partition(u'copyright') copyright = test[0] - elif copyright.find(u"©") != -1: - test = copyright.partition(u"©") + elif copyright.find(u'©') != -1: + test = copyright.partition(u'©') copyright = test[0] - elif copyright.find(u"(c)") != -1: - test = copyright.partition(u"(c)") + elif copyright.find(u'(c)') != -1: + test = copyright.partition(u'(c)') copyright = test[0] - elif copyright.find(u"(C)") != -1: - test = copyright.partition(u"(C)") + elif copyright.find(u'(C)') != -1: + test = copyright.partition(u'(C)') copyright = test[0] - elif copyright.find(u"c)") != -1: - test = copyright.partition(u"c)") + elif copyright.find(u'c)') != -1: + test = copyright.partition(u'c)') copyright = test[0] - elif copyright.find(u"C)") != -1: - test = copyright.partition(u"C)") + elif copyright.find(u'C)') != -1: + test = copyright.partition(u'C)') copyright = test[0] - elif copyright.find(u"C:") != -1: - test = copyright.partition(u"C:") + elif copyright.find(u'C:') != -1: + test = copyright.partition(u'C:') copyright = test[0] - elif copyright.find(u"C,)") != -1: - test = copyright.partition(u"C,)") + elif copyright.find(u'C,)') != -1: + test = copyright.partition(u'C,)') copyright = test[0] copyright = re.compile(u'\\n').sub(u' ', copyright) copyright = re.compile(u'\(.*\)').sub(u'', copyright) - if copyright.find(u"Rechte") != -1: - test = copyright.partition(u"Rechte") + if copyright.find(u'Rechte') != -1: + test = copyright.partition(u'Rechte') copyright = test[0] markers = [u'Text +u\.?n?d? +Melodie[a-zA-Z0-9\,\. ]*:', - u'Text +u\.?n?d? +Musik', u"T & M", u'Melodie und Satz', + u'Text +u\.?n?d? +Musik', u'T & M', u'Melodie und Satz', u'Text[a-zA-Z0-9\,\. ]*:', u'Melodie', u'Musik', u'Satz', u'Weise', u'[dD]eutsch', u'[dD]t[\.\:]', u'Englisch', u'[oO]riginal', u'Bearbeitung', u'[R|r]efrain'] @@ -304,9 +305,9 @@ class FoilPresenter(object): i = 0 x = 0 while i != 1: - if copyright.find(u"") != -1: - test = copyright.partition(u"") - if (test[0].strip() != u"") & (x > 0): + if copyright.find(u'') != -1: + test = copyright.partition(u'') + if (test[0].strip() != u'') & (x > 0): strings.append(test[0]) copyright = test[2] x += 1 @@ -316,7 +317,7 @@ class FoilPresenter(object): else: i = 1 for author in strings: - test = re.split(u",(?=\D{2})|(?<=\D),|\/(?=\D{3,})|(?<=\D);", + test = re.split(u',(?=\D{2})|(?<=\D),|\/(?=\D{3,})|(?<=\D);', author) for test_temp in test: author_temp.append(test_temp) @@ -332,16 +333,14 @@ class FoilPresenter(object): if re.search( u'\w+\.?\s+\w{3,}\s+[a|u]nd\s|\w+\.?\s+\w{3,}\s+&\s', author, re.U) != None: - temp = re.split(u'\s[a|u]nd\s|\s&\s',author) + temp = re.split(u'\s[a|u]nd\s|\s&\s', author) for temp_temp in temp: temp_temp = temp_temp.strip() authors.append(temp_temp) elif (len(author) > 2): authors.append(author) if not authors: - # Add "Author unknown" (can be translated). - authors.append((unicode(translate('SongsPlugin.XML', - 'Author unknown')))) + authors.append(SongStrings.AuthorUnknownUnT) for display_name in authors: author = self.manager.get_object_filtered(Author, Author.display_name == display_name) @@ -415,18 +414,18 @@ class FoilPresenter(object): search_text = u'' temp_verse_order = {} temp_verse_order_backup = [] - temp_verse_sort= [] + temp_verse_sort = [] temp_sortnr_backup = 1 temp_sortnr_liste = [] - versenumber = {u"V":1, u"C": 1, u"B": 1, u"E": 1, u"O": 1, u"I": 1, - u"P": 1 } + versenumber = {u'V': 1, u'C': 1, u'B': 1, u'E': 1, u'O': 1, u'I': 1, + u'P': 1 } for strophe in foilpresenterfolie.strophen.strophe: text = self._child(strophe.text_) verse_name = self._child(strophe.key) children = strophe.getchildren() sortnr = 0 for child in children: - if child.tag == "sortnr": + if child.tag == 'sortnr': verse_sortnr = self._child(strophe.sortnr) sortnr = 1 # In older Version there is no sortnr, but we need one @@ -437,26 +436,26 @@ class FoilPresenter(object): temp_sortnr_liste.append(verse_sortnr) temp_verse_name = re.compile(u'[0-9].*').sub(u'', verse_name) temp_verse_name = temp_verse_name[:3].lower() - if temp_verse_name == u"ref": + if temp_verse_name == u'ref': verse_type = u'C' - elif temp_verse_name == u"r": + elif temp_verse_name == u'r': verse_type = u'C' - elif temp_verse_name == u"": + elif temp_verse_name == u'': verse_type = u'V' - elif temp_verse_name == u"v": + elif temp_verse_name == u'v': verse_type = u'V' - elif temp_verse_name == u"bri": + elif temp_verse_name == u'bri': verse_type = u'B' - elif temp_verse_name == u"cod": + elif temp_verse_name == u'cod': verse_type = u'E' - elif temp_verse_name == u"sch": + elif temp_verse_name == u'sch': verse_type = u'E' - elif temp_verse_name == u"pre": + elif temp_verse_name == u'pre': verse_type = u'P' - elif temp_verse_name == u"int": + elif temp_verse_name == u'int': verse_type = u'I' else: - verse_type = u"O" + verse_type = u'O' verse_number = re.compile(u'[a-zA-Z.+-_ ]*').sub(u'', verse_name) verse_part = re.compile(u'[0-9]*').sub(u'', verse_name[1:]) # Foilpresenter allows e. g. "C", but we need "C1". From a5e8833132f1893069a76cf71d76da32b0af4c2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Tue, 22 Feb 2011 08:58:32 +0200 Subject: [PATCH 18/31] Remove bogus data. --- openlp/plugins/media/mediaplugin.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index 1514b6cb2..51cf1b9ad 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -47,8 +47,7 @@ class MediaPlugin(Plugin): self.dnd_id = u'Media' # This is yet a dummy example: self.additional_extensions = { - 'audio/msaudio': ['.mp3', '.aac'], - 'video/msvideo': ['.wmv', '.avi']} + 'video/msvideo': ['.avi']} # only an example line, unnecessary self.audio_extensions_list = [] self.video_extensions_list = [] mimetypes.init() From 29207d8dffe07417ae968e742928092be86dcf59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Tue, 22 Feb 2011 11:09:47 +0200 Subject: [PATCH 19/31] Added comments to code blocks. --- openlp/plugins/media/mediaplugin.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index 51cf1b9ad..d76df6897 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -45,9 +45,8 @@ class MediaPlugin(Plugin): self.icon = build_icon(self.icon_path) # passed with drag and drop messages self.dnd_id = u'Media' - # This is yet a dummy example: - self.additional_extensions = { - 'video/msvideo': ['.avi']} # only an example line, unnecessary + self.additional_extensions = {} + #'video/msvideo': ['.avi']} This is an example line. self.audio_extensions_list = [] self.video_extensions_list = [] mimetypes.init() @@ -59,6 +58,7 @@ class MediaPlugin(Plugin): self._addToList(self.video_extensions_list, mimetype) def _addToList(self, list, mimetype): + # Add all extensions which mimetypes provides us for supported types. extensions = mimetypes.guess_all_extensions(unicode(mimetype)) for extension in extensions: ext = u'*%s' % extension @@ -67,6 +67,8 @@ class MediaPlugin(Plugin): self.serviceManager.supportedSuffixes(extension[1:]) log.info(u'MediaPlugin: %s extensions: %s' % (mimetype, u' '.join(extensions))) + # Add all extensions listed in self.additional_extensions, to hack + # away mimetypes' shortcomings. if mimetype in self.additional_extensions.keys(): for extension in self.additional_extensions[mimetype]: ext = u'*%s' % extensions From 98d8b1f5902c481656ae9e6a850ad3f799403216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Tue, 22 Feb 2011 17:01:07 +0200 Subject: [PATCH 20/31] More clear comment. Unfortunately there is no need to change few lines of code between these two changes, to include these into diff. That would be self-explanantory. --- openlp/plugins/media/mediaplugin.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index d76df6897..a92de5314 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -46,7 +46,7 @@ class MediaPlugin(Plugin): # passed with drag and drop messages self.dnd_id = u'Media' self.additional_extensions = {} - #'video/msvideo': ['.avi']} This is an example line. + # 'video/msvideo': ['.avi']} This is an example line. self.audio_extensions_list = [] self.video_extensions_list = [] mimetypes.init() @@ -67,8 +67,9 @@ class MediaPlugin(Plugin): self.serviceManager.supportedSuffixes(extension[1:]) log.info(u'MediaPlugin: %s extensions: %s' % (mimetype, u' '.join(extensions))) - # Add all extensions listed in self.additional_extensions, to hack - # away mimetypes' shortcomings. + # Add all extensions listed in self.additional_extensions, which + # have this mimetype, previously claimed to be supported by Phonon, + # to hack away mimetypes' shortcomings in providing some extensions. if mimetype in self.additional_extensions.keys(): for extension in self.additional_extensions[mimetype]: ext = u'*%s' % extensions From 642934a999f7dfc8a0d0e272de3ad50782e51530 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Tue, 22 Feb 2011 20:41:35 +0200 Subject: [PATCH 21/31] Fixed a bug where the settings for the remotes plugin were not actually used. --- openlp/plugins/remotes/lib/httpserver.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 6ec9476a8..7ced66103 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -68,11 +68,13 @@ class HttpServer(object): """ log.debug(u'Start TCP server') port = QtCore.QSettings().value( - self.parent.settingsSection + u'/remote port', + self.parent.settingsSection + u'/port', QtCore.QVariant(4316)).toInt()[0] + address = QtCore.QSettings().value( + self.parent.settingsSection + u'/ip address', + QtCore.QVariant(u'0.0.0.0')).toString() self.server = QtNetwork.QTcpServer() - self.server.listen(QtNetwork.QHostAddress(QtNetwork.QHostAddress.Any), - port) + self.server.listen(QtNetwork.QHostAddress(address), port) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'slidecontroller_live_changed'), self.slide_change) @@ -347,4 +349,4 @@ class HttpConnection(object): log.debug(u'close socket') self.socket.close() self.socket = None - self.parent.close_connection(self) \ No newline at end of file + self.parent.close_connection(self) From 71068d4eb65eb8d214d0e0f8df7ec6c711fa1fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Tue, 22 Feb 2011 21:35:18 +0100 Subject: [PATCH 22/31] fix inconsistant field names, refer now to the xml file --- .../plugins/songs/lib/foilpresenterimport.py | 91 +++++++++---------- 1 file changed, 44 insertions(+), 47 deletions(-) diff --git a/openlp/plugins/songs/lib/foilpresenterimport.py b/openlp/plugins/songs/lib/foilpresenterimport.py index 963561cb5..30c94303b 100644 --- a/openlp/plugins/songs/lib/foilpresenterimport.py +++ b/openlp/plugins/songs/lib/foilpresenterimport.py @@ -105,7 +105,7 @@ log = logging.getLogger(__name__) class FoilPresenterImport(SongImport): """ - This provides the Openlyrics import. + This provides the Foilpresenter import. """ def __init__(self, master_manager, **kwargs): """ @@ -263,37 +263,37 @@ class FoilPresenter(object): strings = [] author_temp = [] if copyright.find(u'Copyright') != -1: - test = copyright.partition(u'Copyright') - copyright = test[0] + temp = copyright.partition(u'Copyright') + copyright = temp[0] elif copyright.find(u'copyright') != -1: - test = copyright.partition(u'copyright') - copyright = test[0] + temp = copyright.partition(u'copyright') + copyright = temp[0] elif copyright.find(u'©') != -1: - test = copyright.partition(u'©') - copyright = test[0] + temp = copyright.partition(u'©') + copyright = temp[0] elif copyright.find(u'(c)') != -1: - test = copyright.partition(u'(c)') - copyright = test[0] + temp = copyright.partition(u'(c)') + copyright = temp[0] elif copyright.find(u'(C)') != -1: - test = copyright.partition(u'(C)') - copyright = test[0] + temp = copyright.partition(u'(C)') + copyright = temp[0] elif copyright.find(u'c)') != -1: - test = copyright.partition(u'c)') - copyright = test[0] + temp = copyright.partition(u'c)') + copyright = temp[0] elif copyright.find(u'C)') != -1: - test = copyright.partition(u'C)') - copyright = test[0] + temp = copyright.partition(u'C)') + copyright = temp[0] elif copyright.find(u'C:') != -1: - test = copyright.partition(u'C:') - copyright = test[0] + temp = copyright.partition(u'C:') + copyright = temp[0] elif copyright.find(u'C,)') != -1: - test = copyright.partition(u'C,)') - copyright = test[0] + temp = copyright.partition(u'C,)') + copyright = temp[0] copyright = re.compile(u'\\n').sub(u' ', copyright) copyright = re.compile(u'\(.*\)').sub(u'', copyright) if copyright.find(u'Rechte') != -1: - test = copyright.partition(u'Rechte') - copyright = test[0] + temp = copyright.partition(u'Rechte') + copyright = temp[0] markers = [u'Text +u\.?n?d? +Melodie[a-zA-Z0-9\,\. ]*:', u'Text +u\.?n?d? +Musik', u'T & M', u'Melodie und Satz', u'Text[a-zA-Z0-9\,\. ]*:', u'Melodie', u'Musik', u'Satz', @@ -306,10 +306,10 @@ class FoilPresenter(object): x = 0 while i != 1: if copyright.find(u'') != -1: - test = copyright.partition(u'') - if (test[0].strip() != u'') & (x > 0): - strings.append(test[0]) - copyright = test[2] + temp = copyright.partition(u'') + if (temp[0].strip() != u'') & (x > 0): + strings.append(temp[0]) + copyright = temp[2] x += 1 elif x > 0: strings.append(copyright) @@ -317,10 +317,10 @@ class FoilPresenter(object): else: i = 1 for author in strings: - test = re.split(u',(?=\D{2})|(?<=\D),|\/(?=\D{3,})|(?<=\D);', + temp = re.split(u',(?=\D{2})|(?<=\D),|\/(?=\D{3,})|(?<=\D);', author) - for test_temp in test: - author_temp.append(test_temp) + for tempx in temp: + author_temp.append(tempx) for author in author_temp: regex = u'^[\/,;\-\s]+|[\/,;\-\s]+$|'\ '\s*[0-9]{4}\s*[\-\/]?\s*([0-9]{4})?[\/,;\-\s]*$' @@ -334,9 +334,9 @@ class FoilPresenter(object): u'\w+\.?\s+\w{3,}\s+[a|u]nd\s|\w+\.?\s+\w{3,}\s+&\s', author, re.U) != None: temp = re.split(u'\s[a|u]nd\s|\s&\s', author) - for temp_temp in temp: - temp_temp = temp_temp.strip() - authors.append(temp_temp) + for tempx in temp: + tempx = tempx.strip() + authors.append(tempx) elif (len(author) > 2): authors.append(author) if not authors: @@ -347,8 +347,8 @@ class FoilPresenter(object): if author is None: # We need to create a new author, as the author does not exist. author = Author.populate(display_name=display_name, - last_name=display_name.split(u' ')[-1], - first_name=u' '.join(display_name.split(u' ')[:-1])) + last_name = display_name.split(u' ')[-1], + first_name = u' '.join(display_name.split(u' ')[:-1])) self.manager.save_object(author) song.authors.append(author) @@ -404,9 +404,6 @@ class FoilPresenter(object): ``foilpresenterfolie`` The foilpresenterfolie object (lxml.objectify.ObjectifiedElement). - ``lyrics`` - The lyrics object (lxml.objectify.ObjectifiedElement). - ``song`` The song object. """ @@ -418,14 +415,14 @@ class FoilPresenter(object): temp_sortnr_backup = 1 temp_sortnr_liste = [] versenumber = {u'V': 1, u'C': 1, u'B': 1, u'E': 1, u'O': 1, u'I': 1, - u'P': 1 } + u'P': 1} for strophe in foilpresenterfolie.strophen.strophe: text = self._child(strophe.text_) verse_name = self._child(strophe.key) children = strophe.getchildren() sortnr = 0 for child in children: - if child.tag == 'sortnr': + if child.tag == u'sortnr': verse_sortnr = self._child(strophe.sortnr) sortnr = 1 # In older Version there is no sortnr, but we need one @@ -506,8 +503,8 @@ class FoilPresenter(object): song.song_book_id = 0 song.song_number = u'' try: - for songbook in foilpresenterfolie.buch.bucheintrag: - bookname = self._child(songbook.name) + for bucheintrag in foilpresenterfolie.buch.bucheintrag: + bookname = self._child(bucheintrag.name) if bookname: book = self.manager.get_object_filtered(Book, Book.name == bookname) @@ -517,8 +514,8 @@ class FoilPresenter(object): self.manager.save_object(book) song.song_book_id = book.id try: - if self._child(songbook.nummer): - song.song_number = self._child(songbook.nummer) + if self._child(bucheintrag.nummer): + song.song_number = self._child(bucheintrag.nummer) except AttributeError: pass # We only support one song book, so take the first one. @@ -536,13 +533,13 @@ class FoilPresenter(object): ``song`` The song object. """ - for title in foilpresenterfolie.titel.titelstring: + for titelstring in foilpresenterfolie.titel.titelstring: if not song.title: - song.title = self._child(title) + song.title = self._child(titelstring) song.search_title = unicode(song.title) song.alternate_title = u'' else: - song.alternate_title = self._child(title) + song.alternate_title = self._child(titelstring) song.search_title += u'@' + song.alternate_title song.search_title = re.sub(r'[\'"`,;:(){}?]+', u'', unicode(song.search_title)).lower() @@ -558,8 +555,8 @@ class FoilPresenter(object): The song object. """ try: - for topictext in foilpresenterfolie.kategorien.name: - topictext = self._child(topictext) + for name in foilpresenterfolie.kategorien.name: + topictext = self._child(name) if topictext: topic = self.manager.get_object_filtered(Topic, Topic.name == topictext) From 9f9720e3682fa6cdc2aa4a78dbdc6313e42e2868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Tue, 22 Feb 2011 23:32:07 +0200 Subject: [PATCH 23/31] Added some extensions. --- openlp/plugins/media/mediaplugin.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index a92de5314..08d21e6ce 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -45,8 +45,16 @@ class MediaPlugin(Plugin): self.icon = build_icon(self.icon_path) # passed with drag and drop messages self.dnd_id = u'Media' - self.additional_extensions = {} - # 'video/msvideo': ['.avi']} This is an example line. + self.additional_extensions = { + u'audio/ac3': [u'.ac3'], + u'audio/qcelp': [u'.qcp'], + u'audio/riff-midi': [u'.rmi'], + u'audio/x-alaw': [u'.alaw'], + u'audio/x-m4a': [u'.m4a'], + u'audio/x-mp3': [u'.mp3'], + u'audio/x-wma': [u'.wma'], + u'video/x-wmv': [u'.wmv'], + u'video/x-xvid': [u'.xvid']} self.audio_extensions_list = [] self.video_extensions_list = [] mimetypes.init() @@ -65,7 +73,7 @@ class MediaPlugin(Plugin): if ext not in list: list.append(ext) self.serviceManager.supportedSuffixes(extension[1:]) - log.info(u'MediaPlugin: %s extensions: %s' % (mimetype, + log.info(u'MediaPlugin: %s extensions: %s' % (mimetype, u' '.join(extensions))) # Add all extensions listed in self.additional_extensions, which # have this mimetype, previously claimed to be supported by Phonon, @@ -76,7 +84,7 @@ class MediaPlugin(Plugin): if ext not in list: list.append(ext) self.serviceManager.supportedSuffixes(extension[1:]) - log.info(u'MediaPlugin: %s additional extensions: %s' % (mimetype, + log.info(u'MediaPlugin: %s additional extensions: %s' % (mimetype, u' '.join(self.additional_extensions[mimetype]))) def about(self): From 158b358bae2ae16b96782847ea0e183249ca981a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Tue, 22 Feb 2011 23:35:25 +0200 Subject: [PATCH 24/31] Removed hack, leave only more detailed logging. --- openlp/plugins/media/mediaplugin.py | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index 08d21e6ce..74a8f3f2e 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -45,16 +45,6 @@ class MediaPlugin(Plugin): self.icon = build_icon(self.icon_path) # passed with drag and drop messages self.dnd_id = u'Media' - self.additional_extensions = { - u'audio/ac3': [u'.ac3'], - u'audio/qcelp': [u'.qcp'], - u'audio/riff-midi': [u'.rmi'], - u'audio/x-alaw': [u'.alaw'], - u'audio/x-m4a': [u'.m4a'], - u'audio/x-mp3': [u'.mp3'], - u'audio/x-wma': [u'.wma'], - u'video/x-wmv': [u'.wmv'], - u'video/x-xvid': [u'.xvid']} self.audio_extensions_list = [] self.video_extensions_list = [] mimetypes.init() @@ -75,17 +65,6 @@ class MediaPlugin(Plugin): self.serviceManager.supportedSuffixes(extension[1:]) log.info(u'MediaPlugin: %s extensions: %s' % (mimetype, u' '.join(extensions))) - # Add all extensions listed in self.additional_extensions, which - # have this mimetype, previously claimed to be supported by Phonon, - # to hack away mimetypes' shortcomings in providing some extensions. - if mimetype in self.additional_extensions.keys(): - for extension in self.additional_extensions[mimetype]: - ext = u'*%s' % extensions - if ext not in list: - list.append(ext) - self.serviceManager.supportedSuffixes(extension[1:]) - log.info(u'MediaPlugin: %s additional extensions: %s' % (mimetype, - u' '.join(self.additional_extensions[mimetype]))) def about(self): about_text = translate('MediaPlugin', 'Media Plugin' From a5b278b87129b65d7e1ab9d671e1806ee8588c7e Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Wed, 23 Feb 2011 08:42:33 +0200 Subject: [PATCH 25/31] Added a setting in the advanced tab to give the users the option of changing the default display screen. --- openlp/core/ui/advancedtab.py | 86 +++++++++++++++++++---------------- openlp/core/ui/maindisplay.py | 12 ++++- 2 files changed, 56 insertions(+), 42 deletions(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 39fec1f9d..5395e59ef 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -41,6 +41,8 @@ class AdvancedTab(SettingsTab): Initialise the settings tab """ SettingsTab.__init__(self, u'Advanced') + self.default_image = u':/graphics/openlp-splash-screen.png' + self.default_color = u'#ffffff' def setupUi(self): """ @@ -81,33 +83,28 @@ class AdvancedTab(SettingsTab): self.hideMouseCheckBox.setObjectName(u'hideMouseCheckBox') self.hideMouseLayout.addWidget(self.hideMouseCheckBox) self.leftLayout.addWidget(self.hideMouseGroupBox) -# self.sharedDirGroupBox = QtGui.QGroupBox(self.leftColumn) -# self.sharedDirGroupBox.setObjectName(u'sharedDirGroupBox') -# self.sharedDirLayout = QtGui.QFormLayout(self.sharedDirGroupBox) -# self.sharedCheckBox = QtGui.QCheckBox(self.sharedDirGroupBox) -# self.sharedCheckBox.setObjectName(u'sharedCheckBox') -# self.sharedDirLayout.addRow(self.sharedCheckBox) -# self.sharedLabel = QtGui.QLabel(self.sharedDirGroupBox) -# self.sharedLabel.setObjectName(u'sharedLabel') -# self.sharedSubLayout = QtGui.QHBoxLayout() -# self.sharedSubLayout.setObjectName(u'sharedSubLayout') -# self.sharedLineEdit = QtGui.QLineEdit(self.sharedDirGroupBox) -# self.sharedLineEdit.setObjectName(u'sharedLineEdit') -# self.sharedSubLayout.addWidget(self.sharedLineEdit) -# self.sharedPushButton = QtGui.QPushButton(self.sharedDirGroupBox) -# self.sharedPushButton.setObjectName(u'sharedPushButton') -# self.sharedSubLayout.addWidget(self.sharedPushButton) -# self.sharedDirLayout.addRow(self.sharedLabel, self.sharedSubLayout) -# self.leftLayout.addWidget(self.sharedDirGroupBox) self.leftLayout.addStretch() -# self.databaseGroupBox = QtGui.QGroupBox(self.rightColumn) -# self.databaseGroupBox.setObjectName(u'databaseGroupBox') -# self.databaseGroupBox.setEnabled(False) -# self.databaseLayout = QtGui.QVBoxLayout(self.databaseGroupBox) -# self.rightLayout.addWidget(self.databaseGroupBox) + self.defaultImageGroupBox = QtGui.QGroupBox(self.rightColumn) + self.defaultImageGroupBox.setObjectName(u'defaultImageGroupBox') + self.defaultImageLayout = QtGui.QFormLayout(self.defaultImageGroupBox) + self.defaultImageLayout.setObjectName(u'defaultImageLayout') + self.defaultColorLabel = QtGui.QLabel(self.defaultImageGroupBox) + self.defaultColorLabel.setObjectName(u'defaultColorLabel') + self.defaultColorButton = QtGui.QPushButton(self.defaultImageGroupBox) + self.defaultColorButton.setObjectName(u'defaultColorButton') + self.defaultImageLayout.addRow(self.defaultColorLabel, + self.defaultColorButton) + self.defaultFileLabel = QtGui.QLabel(self.defaultImageGroupBox) + self.defaultFileLabel.setObjectName(u'defaultFileLabel') + self.defaultFileEdit = QtGui.QLineEdit(self.defaultImageGroupBox) + self.defaultFileEdit.setObjectName(u'defaultFileEdit') + self.defaultImageLayout.addRow(self.defaultFileLabel, + self.defaultFileEdit) + self.rightLayout.addWidget(self.defaultImageGroupBox) self.rightLayout.addStretch() -# QtCore.QObject.connect(self.sharedCheckBox, -# QtCore.SIGNAL(u'stateChanged(int)'), self.onSharedCheckBoxChanged) + + QtCore.QObject.connect(self.defaultColorButton, + QtCore.SIGNAL(u'pressed()'), self.onDefaultColorButtonPressed) def retranslateUi(self): """ @@ -129,14 +126,13 @@ class AdvancedTab(SettingsTab): self.hideMouseGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Mouse Cursor')) self.hideMouseCheckBox.setText(translate('OpenLP.AdvancedTab', - 'Hide the mouse cursor when moved over the display window')) -# self.sharedDirGroupBox.setTitle( -# translate('AdvancedTab', 'Central Data Store')) -# self.sharedCheckBox.setText( -# translate('AdvancedTab', 'Enable a shared data location')) -# self.sharedLabel.setText(translate('AdvancedTab', 'Store location:')) -# self.sharedPushButton.setText(UiStrings.Browse) -# self.databaseGroupBox.setTitle(translate('AdvancedTab', 'Databases')) + 'Hide mouse cursor when over display window')) + self.defaultImageGroupBox.setTitle(translate('OpenLP.AdvancedTab', + 'Default Image')) + self.defaultColorLabel.setText(translate('OpenLP.AdvancedTab', + 'Background color:')) + self.defaultFileLabel.setText(translate('OpenLP.AdvancedTab', + 'Image file:')) def load(self): """ @@ -165,7 +161,14 @@ class AdvancedTab(SettingsTab): QtCore.QVariant(True)).toBool()) self.hideMouseCheckBox.setChecked( settings.value(u'hide mouse', QtCore.QVariant(False)).toBool()) + self.default_color = settings.value(u'default color', + QtCore.QVariant(u'#ffffff')).toString() + self.defaultFileEdit.setText(settings.value(u'default image', + QtCore.QVariant(u':/graphics/openlp-splash-screen.png'))\ + .toString()) settings.endGroup() + self.defaultColorButton.setStyleSheet( + u'background-color: %s' % self.default_color) def save(self): """ @@ -185,12 +188,15 @@ class AdvancedTab(SettingsTab): QtCore.QVariant(self.enableAutoCloseCheckBox.isChecked())) settings.setValue(u'hide mouse', QtCore.QVariant(self.hideMouseCheckBox.isChecked())) + settings.setValue(u'default background color', self.default_color) + settings.setValue(u'default image', self.default_image) settings.endGroup() -# def onSharedCheckBoxChanged(self, checked): -# """ -# Enables the widgets to allow a shared data location -# """ -# self.sharedLabel.setEnabled(checked) -# self.sharedTextEdit.setEnabled(checked) -# self.sharedPushButton.setEnabled(checked) + def onDefaultColorButtonPressed(self): + new_color = QtGui.QColorDialog.getColor( + QtGui.QColor(self.default_color), self) + if new_color.isValid(): + self.default_color = new_color.name() + self.defaultColorButton.setStyleSheet( + u'background-color: %s' % self.default_color) + diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 90042f80b..91d61f1d7 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -132,14 +132,22 @@ class MainDisplay(DisplayWidget): painter_image.begin(self.black) painter_image.fillRect(self.black.rect(), QtCore.Qt.black) # Build the initial frame. + image_file = QtCore.QSettings().value(u'advanced/default image', + QtCore.QVariant(u':/graphics/openlp-splash-screen.png'))\ + .toString() + background_color = QtGui.QColor(QtCore.QSettings().value( + u'advanced/default color', + QtCore.QVariant(u'#ffffff')).toString()) + if not background_color.isValid(): + background_color = QtCore.Qt.white + splash_image = QtGui.QImage(image_file) initialFrame = QtGui.QImage( self.screens.current[u'size'].width(), self.screens.current[u'size'].height(), QtGui.QImage.Format_ARGB32_Premultiplied) - splash_image = QtGui.QImage(u':/graphics/openlp-splash-screen.png') painter_image = QtGui.QPainter() painter_image.begin(initialFrame) - painter_image.fillRect(initialFrame.rect(), QtCore.Qt.white) + painter_image.fillRect(initialFrame.rect(), background_color) painter_image.drawImage( (self.screens.current[u'size'].width() - splash_image.width()) / 2, From 99635299ead388ddd99b3a363564e41fc1d0cc5d Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Wed, 23 Feb 2011 15:55:36 +0200 Subject: [PATCH 26/31] Updated with browse button. --- openlp/core/ui/advancedtab.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 5395e59ef..35bc167c0 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -98,8 +98,14 @@ class AdvancedTab(SettingsTab): self.defaultFileLabel.setObjectName(u'defaultFileLabel') self.defaultFileEdit = QtGui.QLineEdit(self.defaultImageGroupBox) self.defaultFileEdit.setObjectName(u'defaultFileEdit') + self.defaultBrowseButton = QtGui.QToolButton(self.defaultImageGroupBox) + self.defaultBrowseButton.setObjectName(u'defaultBrowseButton') + self.defaultFileLayout = QtGui.QHBoxLayout() + self.defaultFileLayout.setObjectName(u'defaultFileLayout') + self.defaultFileLayout.addWidget(self.defaultFileEdit) + self.defaultFileLayout.addWidget(self.defaultBrowseButton) self.defaultImageLayout.addRow(self.defaultFileLabel, - self.defaultFileEdit) + self.defaultFileLayout) self.rightLayout.addWidget(self.defaultImageGroupBox) self.rightLayout.addStretch() @@ -133,6 +139,7 @@ class AdvancedTab(SettingsTab): 'Background color:')) self.defaultFileLabel.setText(translate('OpenLP.AdvancedTab', 'Image file:')) + self.defaultBrowseButton.setTitle('...') def load(self): """ From de584a8945e02f73d1a52c950caa8306912b15c1 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 23 Feb 2011 18:35:27 +0100 Subject: [PATCH 27/31] reworked author unknown --- openlp/plugins/songs/lib/songimport.py | 13 ++++++++++--- openlp/plugins/songs/lib/ui.py | 3 +-- openlp/plugins/songs/lib/xml.py | 11 ++++++++--- openlp/plugins/songs/songsplugin.py | 5 ++--- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index 40be1675e..a8ca5d7b3 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -270,8 +270,6 @@ class SongImport(QtCore.QObject): """ All fields have been set to this song. Write the song to disk. """ - if not self.authors: - self.authors.append(SongStrings.AuthorUnknownUnT) log.info(u'committing song %s to database', self.title) song = Song() song.title = self.title @@ -315,10 +313,19 @@ class SongImport(QtCore.QObject): author = self.manager.get_object_filtered(Author, Author.display_name == authortext) if not author: - author = Author.populate(display_name = authortext, + author = Author.populate(display_name=authortext, last_name=authortext.split(u' ')[-1], first_name=u' '.join(authortext.split(u' ')[:-1])) song.authors.append(author) + # No author, add the default author. + if not song.authors: + name = SongStrings.AuthorUnknown + author = self.manager.get_object_filtered( + Author, Author.display_name == name) + if not author: + author = Author.populate( + display_name=name, last_name=u'', first_name=u'') + song.authors.append(author) for filename in self.media_files: media_file = self.manager.get_object_filtered(MediaFile, MediaFile.file_name == filename) diff --git a/openlp/plugins/songs/lib/ui.py b/openlp/plugins/songs/lib/ui.py index 65f473e63..6415c48c9 100644 --- a/openlp/plugins/songs/lib/ui.py +++ b/openlp/plugins/songs/lib/ui.py @@ -36,8 +36,7 @@ class SongStrings(object): # These strings should need a good reason to be retranslated elsewhere. Author = translate('OpenLP.Ui', 'Author', 'Singular') Authors = translate('OpenLP.Ui', 'Authors', 'Plural') - AuthorUnknown = translate('OpenLP.Ui', 'Author Unknown') # Used in the UI. - AuthorUnknownUnT = u'Author Unknown' # Used to populate the database. + AuthorUnknown = u'Author Unknown' # Used to populate the database. CopyrightSymbol = translate('OpenLP.Ui', '\xa9', 'Copyright symbol.') SongBook = translate('OpenLP.Ui', 'Song Book', 'Singular') SongBooks = translate('OpenLP.Ui', 'Song Books', 'Plural') diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index a552a42a1..2aa51c99e 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -374,8 +374,6 @@ class OpenLyrics(object): display_name = self._text(author) if display_name: authors.append(display_name) - if not authors: - authors.append(SongStrings.AuthorUnknownUnT) for display_name in authors: author = self.manager.get_object_filtered(Author, Author.display_name == display_name) @@ -384,7 +382,14 @@ class OpenLyrics(object): author = Author.populate(display_name=display_name, last_name=display_name.split(u' ')[-1], first_name=u' '.join(display_name.split(u' ')[:-1])) - self.manager.save_object(author) + # The song does not have an author, add a default author. + if not song.authors: + name = SongStrings.AuthorUnknown + author = self.manager.get_object_filtered( + Author, Author.display_name == name) + if author is None: + author = Author.populate( + display_name=name, last_name=u'', first_name=u'') song.authors.append(author) def _process_cclinumber(self, properties, song): diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 3800d00dc..1932a8384 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -148,13 +148,12 @@ class SongsPlugin(Plugin): counter += 1 # The song does not have any author, add one. if not song.authors: - name = unicode(SongStrings.AuthorUnknownUnT) + name = SongStrings.AuthorUnknown author = self.manager.get_object_filtered(Author, Author.display_name == name) if author is None: author = Author.populate( - first_name=u' '.join(name.split(u' ', 1)[:-1]), - last_name=name.split(u' ', 1)[-1], display_name=name) + display_name=name, last_name=u'', first_name=u'') song.authors.append(author) if song.title is None: song.title = u'' From b4b6fef70a2e107c024f360f736f429412409a1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Wed, 23 Feb 2011 20:48:37 +0100 Subject: [PATCH 28/31] change value to True/False --- openlp/plugins/songs/lib/foilpresenterimport.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/songs/lib/foilpresenterimport.py b/openlp/plugins/songs/lib/foilpresenterimport.py index 30c94303b..2eded332f 100644 --- a/openlp/plugins/songs/lib/foilpresenterimport.py +++ b/openlp/plugins/songs/lib/foilpresenterimport.py @@ -420,13 +420,13 @@ class FoilPresenter(object): text = self._child(strophe.text_) verse_name = self._child(strophe.key) children = strophe.getchildren() - sortnr = 0 + sortnr = False for child in children: if child.tag == u'sortnr': verse_sortnr = self._child(strophe.sortnr) - sortnr = 1 + sortnr = True # In older Version there is no sortnr, but we need one - if sortnr == 0: + if sortnr == False: verse_sortnr = unicode(temp_sortnr_backup) temp_sortnr_backup += 1 # Foilpresenter allows e. g. "Ref" or "1", but we need "C1" or "V1". From 1eea1c97a498068933ee33aa3ea04e03db0700ea Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 23 Feb 2011 21:22:29 +0100 Subject: [PATCH 29/31] moved code --- openlp/plugins/songs/lib/__init__.py | 21 ++++++++++++++++ openlp/plugins/songs/lib/olpimport.py | 33 +++++++++++++------------- openlp/plugins/songs/lib/songimport.py | 10 ++------ openlp/plugins/songs/lib/xml.py | 11 ++------- openlp/plugins/songs/songsplugin.py | 14 ++++------- 5 files changed, 45 insertions(+), 44 deletions(-) diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index 95fae92a8..0396122f5 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -25,7 +25,10 @@ ############################################################################### from PyQt4 import QtGui + from openlp.core.lib import translate +from db import Author +from ui import SongStrings class VerseType(object): """ @@ -241,6 +244,24 @@ def retrieve_windows_encoding(recommendation=None): return None return filter(lambda item: item[1] == choice[0], encodings)[0][0] +def add_author_unknown(manager, song): + """ + Add the default author *Author Unknown* to the song. + + ``manager`` + The song's manager. + + ``song`` + The song object. + """ + name = SongStrings.AuthorUnknown + author = manager.get_object_filtered(Author, Author.display_name == name) + if author is None: + author = Author.populate( + display_name=name, last_name=u'', first_name=u'') + song.authors.append(author) + from xml import OpenLyrics, SongXML from songstab import SongsTab from mediaitem import SongMediaItem + diff --git a/openlp/plugins/songs/lib/olpimport.py b/openlp/plugins/songs/lib/olpimport.py index b3f03b951..fba518772 100644 --- a/openlp/plugins/songs/lib/olpimport.py +++ b/openlp/plugins/songs/lib/olpimport.py @@ -36,6 +36,7 @@ from sqlalchemy.orm.exc import UnmappedClassError from openlp.core.lib import translate from openlp.core.lib.db import BaseModel +from openlp.plugins.songs.lib import add_author_unknown from openlp.plugins.songs.lib.db import Author, Book, Song, Topic #, MediaFile from songimport import SongImport @@ -47,30 +48,35 @@ class OldAuthor(BaseModel): """ pass + class OldBook(BaseModel): """ Book model """ pass + class OldMediaFile(BaseModel): """ MediaFile model """ pass + class OldSong(BaseModel): """ Song model """ pass + class OldTopic(BaseModel): """ Topic model """ pass + class OpenLPSongImport(SongImport): """ The :class:`OpenLPSongImport` class provides OpenLP with the ability to @@ -170,25 +176,18 @@ class OpenLPSongImport(SongImport): new_song.comments = song.comments new_song.theme_name = song.theme_name new_song.ccli_number = song.ccli_number - if song.authors: - for author in song.authors: - existing_author = self.manager.get_object_filtered( - Author, Author.display_name == author.display_name) - if existing_author: - new_song.authors.append(existing_author) - else: - new_song.authors.append(Author.populate( - first_name=author.first_name, - last_name=author.last_name, - display_name=author.display_name)) - else: - au = self.manager.get_object_filtered(Author, - Author.display_name == u'Author Unknown') - if au: - new_song.authors.append(au) + for author in song.authors: + existing_author = self.manager.get_object_filtered( + Author, Author.display_name == author.display_name) + if existing_author: + new_song.authors.append(existing_author) else: new_song.authors.append(Author.populate( - display_name=u'Author Unknown')) + first_name=author.first_name, + last_name=author.last_name, + display_name=author.display_name)) + if not new_song.authors: + add_author_unknown(self.manager, new_song) if song.book: existing_song_book = self.manager.get_object_filtered( Book, Book.name == song.book.name) diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index a8ca5d7b3..36f2e3504 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -29,7 +29,7 @@ import re from PyQt4 import QtCore from openlp.core.lib import Receiver, translate -from openlp.plugins.songs.lib import VerseType +from openlp.plugins.songs.lib import add_author_unknown, VerseType from openlp.plugins.songs.lib.db import Song, Author, Topic, Book, MediaFile from openlp.plugins.songs.lib.ui import SongStrings from openlp.plugins.songs.lib.xml import SongXML @@ -319,13 +319,7 @@ class SongImport(QtCore.QObject): song.authors.append(author) # No author, add the default author. if not song.authors: - name = SongStrings.AuthorUnknown - author = self.manager.get_object_filtered( - Author, Author.display_name == name) - if not author: - author = Author.populate( - display_name=name, last_name=u'', first_name=u'') - song.authors.append(author) + add_author_unknown(self.manager, song) for filename in self.media_files: media_file = self.manager.get_object_filtered(MediaFile, MediaFile.file_name == filename) diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index 2aa51c99e..8f5c35c0a 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -66,7 +66,7 @@ import re from lxml import etree, objectify -from openlp.plugins.songs.lib import VerseType +from openlp.plugins.songs.lib import add_author_unknown, VerseType from openlp.plugins.songs.lib.db import Author, Book, Song, Topic from openlp.plugins.songs.lib.ui import SongStrings @@ -382,15 +382,8 @@ class OpenLyrics(object): author = Author.populate(display_name=display_name, last_name=display_name.split(u' ')[-1], first_name=u' '.join(display_name.split(u' ')[:-1])) - # The song does not have an author, add a default author. if not song.authors: - name = SongStrings.AuthorUnknown - author = self.manager.get_object_filtered( - Author, Author.display_name == name) - if author is None: - author = Author.populate( - display_name=name, last_name=u'', first_name=u'') - song.authors.append(author) + add_author_unknown(self.manager, song) def _process_cclinumber(self, properties, song): """ diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 1932a8384..609c1990d 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -32,10 +32,10 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import Plugin, StringContent, build_icon, translate from openlp.core.lib.db import Manager from openlp.core.lib.ui import UiStrings -from openlp.plugins.songs.lib import SongMediaItem, SongsTab, SongXML -from openlp.plugins.songs.lib.db import Author, init_schema, Song +from openlp.plugins.songs.lib import add_author_unknown, SongMediaItem, \ + SongsTab, SongXML +from openlp.plugins.songs.lib.db import init_schema, Song from openlp.plugins.songs.lib.importer import SongFormat -from openlp.plugins.songs.lib.ui import SongStrings log = logging.getLogger(__name__) @@ -148,13 +148,7 @@ class SongsPlugin(Plugin): counter += 1 # The song does not have any author, add one. if not song.authors: - name = SongStrings.AuthorUnknown - author = self.manager.get_object_filtered(Author, - Author.display_name == name) - if author is None: - author = Author.populate( - display_name=name, last_name=u'', first_name=u'') - song.authors.append(author) + add_author_unknown(self.manager, song) if song.title is None: song.title = u'' if song.alternate_title is None: From 8661c6e38e5bae6db0b9d8c599c6d8a1791d520f Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 23 Feb 2011 21:28:25 +0100 Subject: [PATCH 30/31] removed line --- openlp/plugins/songs/lib/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index 0396122f5..70a47a239 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -264,4 +264,3 @@ def add_author_unknown(manager, song): from xml import OpenLyrics, SongXML from songstab import SongsTab from mediaitem import SongMediaItem - From c74b2fc964fa34d9c8fe84e7db6b74d12da9452e Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Wed, 23 Feb 2011 22:55:55 +0200 Subject: [PATCH 31/31] Updated the settings tab. --- openlp/core/ui/advancedtab.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 35bc167c0..5cb22cb8b 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -28,8 +28,9 @@ The :mod:`advancedtab` provides an advanced settings facility. """ from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, translate +from openlp.core.lib import SettingsTab, translate, build_icon from openlp.core.lib.ui import UiStrings +from openlp.core.utils import get_images_filter class AdvancedTab(SettingsTab): """ @@ -100,6 +101,8 @@ class AdvancedTab(SettingsTab): self.defaultFileEdit.setObjectName(u'defaultFileEdit') self.defaultBrowseButton = QtGui.QToolButton(self.defaultImageGroupBox) self.defaultBrowseButton.setObjectName(u'defaultBrowseButton') + self.defaultBrowseButton.setIcon( + build_icon(u':/general/general_open.png')) self.defaultFileLayout = QtGui.QHBoxLayout() self.defaultFileLayout.setObjectName(u'defaultFileLayout') self.defaultFileLayout.addWidget(self.defaultFileEdit) @@ -111,6 +114,8 @@ class AdvancedTab(SettingsTab): QtCore.QObject.connect(self.defaultColorButton, QtCore.SIGNAL(u'pressed()'), self.onDefaultColorButtonPressed) + QtCore.QObject.connect(self.defaultBrowseButton, + QtCore.SIGNAL(u'pressed()'), self.onDefaultBrowseButtonPressed) def retranslateUi(self): """ @@ -139,7 +144,6 @@ class AdvancedTab(SettingsTab): 'Background color:')) self.defaultFileLabel.setText(translate('OpenLP.AdvancedTab', 'Image file:')) - self.defaultBrowseButton.setTitle('...') def load(self): """ @@ -195,8 +199,8 @@ class AdvancedTab(SettingsTab): QtCore.QVariant(self.enableAutoCloseCheckBox.isChecked())) settings.setValue(u'hide mouse', QtCore.QVariant(self.hideMouseCheckBox.isChecked())) - settings.setValue(u'default background color', self.default_color) - settings.setValue(u'default image', self.default_image) + settings.setValue(u'default color', self.default_color) + settings.setValue(u'default image', self.defaultFileEdit.text()) settings.endGroup() def onDefaultColorButtonPressed(self): @@ -207,3 +211,12 @@ class AdvancedTab(SettingsTab): self.defaultColorButton.setStyleSheet( u'background-color: %s' % self.default_color) + def onDefaultBrowseButtonPressed(self): + file_filters = u'%s;;%s (*.*) (*)' % (get_images_filter(), + UiStrings.AllFiles) + filename = QtGui.QFileDialog.getOpenFileName(self, + translate('OpenLP.AdvancedTab', 'Open File'), '', + file_filters) + if filename: + self.defaultFileEdit.setText(filename) + self.defaultFileEdit.setFocus()