From 313343856a64912a5f1bff30c11841d31b8b7817 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 21 Dec 2010 14:40:41 +0100 Subject: [PATCH 1/3] f --- openlp/plugins/songs/forms/songimportform.py | 166 +++++++++++-------- 1 file changed, 94 insertions(+), 72 deletions(-) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index f62c88063..81acea00f 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -152,101 +152,101 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard): if self.openLP2FilenameEdit.text().isEmpty(): QtGui.QMessageBox.critical(self, translate('SongsPlugin.ImportWizardForm', - 'No OpenLP 2.0 Song Database Selected'), + 'No OpenLP 2.0 Song Database Selected'), translate('SongsPlugin.ImportWizardForm', - 'You need to select an OpenLP 2.0 song database ' - 'file to import from.')) + 'You need to select an OpenLP 2.0 song database ' + 'file to import from.')) self.openLP2BrowseButton.setFocus() return False elif source_format == SongFormat.OpenLP1: if self.openLP1FilenameEdit.text().isEmpty(): QtGui.QMessageBox.critical(self, translate('SongsPlugin.ImportWizardForm', - 'No openlp.org 1.x Song Database Selected'), + 'No openlp.org 1.x Song Database Selected'), translate('SongsPlugin.ImportWizardForm', - 'You need to select an openlp.org 1.x song ' - 'database file to import from.')) + 'You need to select an openlp.org 1.x song ' + 'database file to import from.')) self.openLP1BrowseButton.setFocus() return False elif source_format == SongFormat.OpenLyrics: - #if self.openLyricsFileListWidget.count() == 0: - # QtGui.QMessageBox.critical(self, - # translate('SongsPlugin.ImportWizardForm', - # 'No OpenLyrics Files Selected'), - # translate('SongsPlugin.ImportWizardForm', - # 'You need to add at least one OpenLyrics ' - # 'song file to import from.')) - # self.openLyricsAddButton.setFocus() - # return False +# if self.openLyricsFileListWidget.count() == 0: +# QtGui.QMessageBox.critical(self, +# translate('SongsPlugin.ImportWizardForm', +# 'No OpenLyrics Files Selected'), +# translate('SongsPlugin.ImportWizardForm', +# 'You need to add at least one OpenLyrics ' +# 'song file to import from.')) +# self.openLyricsAddButton.setFocus() +# return False return False elif source_format == SongFormat.OpenSong: if self.openSongFileListWidget.count() == 0: QtGui.QMessageBox.critical(self, translate('SongsPlugin.ImportWizardForm', - 'No OpenSong Files Selected'), + 'No OpenSong Files Selected'), translate('SongsPlugin.ImportWizardForm', - 'You need to add at least one OpenSong ' - 'song file to import from.')) + 'You need to add at least one OpenSong ' + 'song file to import from.')) self.openSongAddButton.setFocus() return False elif source_format == SongFormat.WordsOfWorship: if self.wordsOfWorshipFileListWidget.count() == 0: QtGui.QMessageBox.critical(self, translate('SongsPlugin.ImportWizardForm', - 'No Words of Worship Files Selected'), + 'No Words of Worship Files Selected'), translate('SongsPlugin.ImportWizardForm', - 'You need to add at least one Words of Worship ' - 'file to import from.')) + 'You need to add at least one Words of Worship ' + 'file to import from.')) self.wordsOfWorshipAddButton.setFocus() return False elif source_format == SongFormat.CCLI: if self.ccliFileListWidget.count() == 0: QtGui.QMessageBox.critical(self, translate('SongsPlugin.ImportWizardForm', - 'No CCLI Files Selected'), + 'No CCLI Files Selected'), translate('SongsPlugin.ImportWizardForm', - 'You need to add at least one CCLI file ' - 'to import from.')) + 'You need to add at least one CCLI file ' + 'to import from.')) self.ccliAddButton.setFocus() return False elif source_format == SongFormat.SongsOfFellowship: if self.songsOfFellowshipFileListWidget.count() == 0: QtGui.QMessageBox.critical(self, translate('SongsPlugin.ImportWizardForm', - 'No Songs of Fellowship File Selected'), + 'No Songs of Fellowship File Selected'), translate('SongsPlugin.ImportWizardForm', - 'You need to add at least one Songs of Fellowship ' - 'file to import from.')) + 'You need to add at least one Songs of Fellowship ' + 'file to import from.')) self.songsOfFellowshipAddButton.setFocus() return False elif source_format == SongFormat.Generic: if self.genericFileListWidget.count() == 0: QtGui.QMessageBox.critical(self, translate('SongsPlugin.ImportWizardForm', - 'No Document/Presentation Selected'), + 'No Document/Presentation Selected'), translate('SongsPlugin.ImportWizardForm', - 'You need to add at least one document or ' - 'presentation file to import from.')) + 'You need to add at least one document or ' + 'presentation file to import from.')) self.genericAddButton.setFocus() return False elif source_format == SongFormat.EasyWorship: if self.ewFilenameEdit.text().isEmpty(): QtGui.QMessageBox.critical(self, translate('SongsPlugin.ImportWizardForm', - 'No EasyWorship Song Database Selected'), + 'No EasyWorship Song Database Selected'), translate('SongsPlugin.ImportWizardForm', - 'You need to select an EasyWorship song database ' - 'file to import from.')) + 'You need to select an EasyWorship song database ' + 'file to import from.')) self.ewBrowseButton.setFocus() return False elif source_format == SongFormat.SongBeamer: if self.songBeamerFileListWidget.count() == 0: QtGui.QMessageBox.critical(self, translate('SongsPlugin.ImportWizardForm', - 'No SongBeamer File Selected'), + 'No SongBeamer File Selected'), translate('SongsPlugin.ImportWizardForm', - 'You need to add at least one SongBeamer ' - 'file to import from.')) + 'You need to add at least one SongBeamer ' + 'file to import from.')) self.songBeamerAddButton.setFocus() return False return True @@ -254,24 +254,57 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard): # Progress page return True - def getFileName(self, title, editbox, - filters = '%s (*)' % translate('SongsPlugin.ImportWizardForm', - 'All Files')): + def getFileName(self, title, editbox, filters=u''): + """ + Opens a QFileDialog and writes the filename to the given editbox. + + ``title`` + The title of the dialog (unicode). + + ``editbox`` + A editbox (QLineEdit). + + ``filters`` + The file extension filters. It should contain the file descriptions + as well as the file extensions. For example:: + + u'OpenLP 2.0 Databases (*.sqlite)' + """ + if filters: + filters += u';;' + filters += u'%s (*)' % translate('SongsPlugin.ImportWizardForm', + 'All Files') filename = QtGui.QFileDialog.getOpenFileName(self, title, - SettingsManager.get_last_dir(self.plugin.settingsSection, 1), - filters) + os.path.dirname(SettingsManager.get_last_dir( + self.plugin.settingsSection, 1)), filters) if filename: editbox.setText(filename) - SettingsManager.set_last_dir( - self.plugin.settingsSection, + SettingsManager.set_last_dir(self.plugin.settingsSection, os.path.split(unicode(filename))[0], 1) - def getFiles(self, title, listbox, - filters = u'%s (*)' % translate('SongsPlugin.ImportWizardForm', - 'All Files')): + def getFiles(self, title, listbox, filters=u''): + """ + Opens a QFileDialog and writes the filenames to the given listbox. + + ``title`` + The title of the dialog (unicode). + + ``listbox`` + A listbox (QListWidget). + + ``filters`` + The file extension filters. It should contain the file descriptions + as well as the file extensions. For example:: + + u'SongBeamer files (*.sng)' + """ + if filters: + filters += u';;' + filters += u'%s (*)' % translate('SongsPlugin.ImportWizardForm', + 'All Files') filenames = QtGui.QFileDialog.getOpenFileNames(self, title, - SettingsManager.get_last_dir(self.plugin.settingsSection, 1), - filters) + os.path.dirname(SettingsManager.get_last_dir( + self.plugin.settingsSection, 1)), filters) if filenames: listbox.addItems(filenames) SettingsManager.set_last_dir( @@ -293,24 +326,18 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard): self.getFileName( translate('SongsPlugin.ImportWizardForm', 'Select OpenLP 2.0 Database File'), - self.openLP2FilenameEdit, - u'%s (*.sqlite);;%s (*)' + self.openLP2FilenameEdit, u'%s (*.sqlite)' % (translate('SongsPlugin.ImportWizardForm', - 'OpenLP 2.0 Databases'), - translate('SongsPlugin.ImportWizardForm', - 'All Files')) + 'OpenLP 2.0 Databases')) ) def onOpenLP1BrowseButtonClicked(self): self.getFileName( translate('SongsPlugin.ImportWizardForm', 'Select openlp.org 1.x Database File'), - self.openLP1FilenameEdit, - u'%s (*.olp);;%s (*)' - % (translate('SongsPlugin.ImportWizardForm', - 'openlp.org v1.x Databases'), - translate('SongsPlugin.ImportWizardForm', - 'All Files')) + self.openLP1FilenameEdit, u'%s (*.olp)' + % translate('SongsPlugin.ImportWizardForm', + 'openlp.org v1.x Databases') ) #def onOpenLyricsAddButtonClicked(self): @@ -337,12 +364,9 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard): self.getFiles( translate('SongsPlugin.ImportWizardForm', 'Select Words of Worship Files'), - self.wordsOfWorshipFileListWidget, - u'%s (*.wsg *.wow-song);;%s (*)' - % (translate('SongsPlugin.ImportWizardForm', - 'Words Of Worship Song Files'), - translate('SongsPlugin.ImportWizardForm', - 'All Files')) + self.wordsOfWorshipFileListWidget, u'%s (*.wsg *.wow-song)' + % translate('SongsPlugin.ImportWizardForm', + 'Words Of Worship Song Files') ) def onWordsOfWorshipRemoveButtonClicked(self): @@ -362,12 +386,9 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard): self.getFiles( translate('SongsPlugin.ImportWizardForm', 'Select Songs of Fellowship Files'), - self.songsOfFellowshipFileListWidget, - u'%s (*.rtf);;%s (*)' - % (translate('SongsPlugin.ImportWizardForm', - 'Songs Of Felloship Song Files'), - translate('SongsPlugin.ImportWizardForm', - 'All Files')) + self.songsOfFellowshipFileListWidget, u'%s (*.rtf)' + % translate('SongsPlugin.ImportWizardForm', + 'Songs Of Felloship Song Files') ) def onSongsOfFellowshipRemoveButtonClicked(self): @@ -394,7 +415,8 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard): self.getFiles( translate('SongsPlugin.ImportWizardForm', 'Select SongBeamer Files'), - self.songBeamerFileListWidget + self.songBeamerFileListWidget, u'%s (*.sng)' % + translate('SongsPlugin.ImportWizardForm', 'SongBeamer files') ) def onSongBeamerRemoveButtonClicked(self): From 87e7cb6242e200775a30766acea67e2111d7bdc2 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 21 Dec 2010 15:26:20 +0100 Subject: [PATCH 2/3] translate file description --- openlp/plugins/bibles/forms/bibleimportform.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 4ec71b436..a903d636f 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -253,15 +253,16 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): """ self.getFileName( translate('BiblesPlugin.ImportWizardForm', 'Open Books CSV File'), - self.booksLocationEdit, u'CSV File (*.csv)') + self.booksLocationEdit, u'%s (*.csv)' + % translate('BiblesPlugin.ImportWizardForm', 'CSV File')) def onCsvVersesFileButtonClicked(self): """ Show the file open dialog for the verses CSV file. """ self.getFileName(translate('BiblesPlugin.ImportWizardForm', - 'Open Verses CSV File'), self.csvVerseLocationEdit, - u'CSV File (*.csv)') + 'Open Verses CSV File'), self.csvVerseLocationEdit, u'%s (*.csv)' + % translate('BiblesPlugin.ImportWizardForm', 'CSV File')) def onOpenSongBrowseButtonClicked(self): """ @@ -278,7 +279,8 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): self.getFileName( translate('BiblesPlugin.ImportWizardForm', 'Open openlp.org 1.x Bible'), self.openlp1LocationEdit, - u'openlp.org (*.bible)') + u'%s (*.bible)' % translate('BiblesPlugin.ImportWizardForm', + 'openlp.org 1.x bible')) def onCurrentIdChanged(self, pageId): if pageId == 3: From 8f99aa4c96ffacdcd2f3949bb49940cf0d99bff6 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 21 Dec 2010 15:31:18 +0100 Subject: [PATCH 3/3] fixed doc --- openlp/plugins/bibles/forms/bibleimportform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index a903d636f..0cc62074c 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -420,7 +420,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): The file extension filters. It should contain the file description as well as the file extension. For example:: - u'openlp.org (*.bible)' + u'openlp.org 1.x bible (*.bible)' """ if filters: filters += u';;'