From bffa44a1cb1c3bd9099bc168b568866ea8c28dc3 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 12 Feb 2011 20:25:40 +0000 Subject: [PATCH] Wizards and applications --- openlp/core/lib/ui.py | 1 + openlp/core/ui/wizard.py | 17 +++ .../plugins/bibles/forms/bibleimportform.py | 48 +++--- openlp/plugins/songs/forms/songimportform.py | 140 +++++------------- 4 files changed, 75 insertions(+), 131 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 5a8293617..737bb75d2 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -74,6 +74,7 @@ class UiStrings(object): NFSp = translate('OpenLP.Ui', 'No Files Selected', 'Plural') NISs = translate('OpenLP.Ui', 'No Item Selected', 'Singular') NISp = translate('OpenLP.Ui', 'No Items Selected', 'Plural') + OLPV1 = translate('OpenLP.Ui', 'openlp.org 1.x') OLPV2 = translate('OpenLP.Ui', 'OpenLP 2.0') OpenType = unicode(translate('OpenLP.Ui', 'Open %s')) Preview = translate('OpenLP.Ui', 'Preview') diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index 0bb610104..14511f21f 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -41,6 +41,20 @@ class WizardStrings(object): """ Provide standard strings for wizards to use. """ + # Applications/Formats we import from or export to. These get used in + # multiple places but do not need translating unless you find evidence of + # the writers translating their own product name. + CCLI = u'CCLI/SongSelect' + CSV = u'CSV' + EW = u'EasyWorship' + ES = u'EasiSlides' + GDP = translate('OpenLP.Ui', 'Generic Document or Presentation') + OL = u'OpenLyrics' + OS = u'OpenSong' + OSIS = u'OSIS' + SB = u'SongBeamer' + SoF = u'Songs of Fellowship' + WoW = u'Words of Worship' # These strings should need a good reason to be retranslated elsewhere. Description = unicode(translate('OpenLP.Ui', 'This wizard will help you ' 'to %s %s from a variety of formats. Click the next button ' @@ -52,9 +66,12 @@ class WizardStrings(object): ImportSelect = translate('OpenLP.Ui', 'Select Import Source') ImportSelectLong = unicode(translate('OpenLP.Ui', 'Select the import format and the location to import from.')) + OpenTypeFile = unicode(translate('OpenLP.Ui', 'Open %s File')) Welcome = u'%s' % \ translate('OpenLP.Ui', 'Welcome to the %s %s Wizard', 'Variable 1 is the type e.g. Bible and variable 2 is import/export') + YouSpecifyFile = unicode(translate('OpenLP.Ui', 'You need to specify at ' + 'least one %s file to import from.', 'A file type e.g. OpenSong')) class OpenLPWizard(QtGui.QWizard): diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index b3fa403e8..80f44e481 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -370,12 +370,9 @@ class BibleImportForm(OpenLPWizard): self.selectPage.setTitle(WizardStrings.ImportSelect) self.selectPage.setSubTitle(WizardStrings.ImportSelectLong) self.formatLabel.setText(WizardStrings.FormatLabel) - self.formatComboBox.setItemText(0, - translate('BiblesPlugin.ImportWizardForm', 'OSIS')) - self.formatComboBox.setItemText(1, - translate('BiblesPlugin.ImportWizardForm', 'CSV')) - self.formatComboBox.setItemText(2, - translate('BiblesPlugin.ImportWizardForm', 'OpenSong')) + self.formatComboBox.setItemText(0, WizardStrings.OSIS) + self.formatComboBox.setItemText(1, WizardStrings.CSV) + self.formatComboBox.setItemText(2, WizardStrings.OS) self.formatComboBox.setItemText(3, translate('BiblesPlugin.ImportWizardForm', 'Web Download')) self.formatComboBox.setItemText(4, @@ -459,9 +456,7 @@ class BibleImportForm(OpenLPWizard): if self.field(u'source_format').toInt()[0] == BibleFormat.OSIS: if not self.field(u'osis_location').toString(): critical_error_message_box(UiStrings.NFSs, - translate('BiblesPlugin.ImportWizardForm', - 'You need to specify a file to import your ' - 'Bible from.')) + WizardStrings.YouSpecifyFile % WizardStrings.OSIS) self.osisFileEdit.setFocus() return False elif self.field(u'source_format').toInt()[0] == BibleFormat.CSV: @@ -473,7 +468,7 @@ class BibleImportForm(OpenLPWizard): if answer == QtGui.QMessageBox.No: self.csvTestamentsEdit.setFocus() return False - elif not self.field(u'csv_booksfile').toString(): + if not self.field(u'csv_booksfile').toString(): critical_error_message_box(UiStrings.NFSs, translate('BiblesPlugin.ImportWizardForm', 'You need to specify a file with books of ' @@ -491,17 +486,13 @@ class BibleImportForm(OpenLPWizard): BibleFormat.OpenSong: if not self.field(u'opensong_file').toString(): critical_error_message_box(UiStrings.NFSs, - translate('BiblesPlugin.ImportWizardForm', - 'You need to specify an OpenSong Bible ' - 'file to import.')) + WizardStrings.YouSpecifyFile % WizardStrings.OS) self.openSongFileEdit.setFocus() return False elif self.field(u'source_format').toInt()[0] == BibleFormat.OpenLP1: if not self.field(u'openlp1_location').toString(): critical_error_message_box(UiStrings.NFSs, - translate('BiblesPlugin.ImportWizardForm', - 'You need to specify a file to import your ' - 'Bible from.')) + WizardStrings.YouSpecifyFile % UiStrings.OLPV1) self.openlp1FileEdit.setFocus() return False return True @@ -551,24 +542,22 @@ class BibleImportForm(OpenLPWizard): """ Show the file open dialog for the OSIS file. """ - self.getFileName( - translate('BiblesPlugin.ImportWizardForm', 'Open OSIS File'), + self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.OSIS, self.osisFileEdit) def onCsvTestamentsBrowseButtonClicked(self): """ Show the file open dialog for the testaments CSV file. """ - self.getFileName(translate('BiblesPlugin.ImportWizardForm', - 'Open Testaments CSV File'), self.csvTestamentsEdit, u'%s (*.csv)' + self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.CSV, + self.csvTestamentsEdit, u'%s (*.csv)' % translate('BiblesPlugin.ImportWizardForm', 'CSV File')) def onCsvBooksBrowseButtonClicked(self): """ Show the file open dialog for the books CSV file. """ - self.getFileName( - translate('BiblesPlugin.ImportWizardForm', 'Open Books CSV File'), + self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.CSV, self.csvBooksEdit, u'%s (*.csv)' % translate('BiblesPlugin.ImportWizardForm', 'CSV File')) @@ -576,27 +565,24 @@ class BibleImportForm(OpenLPWizard): """ Show the file open dialog for the verses CSV file. """ - self.getFileName(translate('BiblesPlugin.ImportWizardForm', - 'Open Verses CSV File'), self.csvVersesEdit, u'%s (*.csv)' + self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.CSV, + self.csvVersesEdit, u'%s (*.csv)' % translate('BiblesPlugin.ImportWizardForm', 'CSV File')) def onOpenSongBrowseButtonClicked(self): """ Show the file open dialog for the OpenSong file. """ - self.getFileName( - translate('BiblesPlugin.ImportWizardForm', 'Open OpenSong Bible'), + self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.OS, self.openSongFileEdit) def onOpenlp1BrowseButtonClicked(self): """ Show the file open dialog for the openlp.org 1.x file. """ - self.getFileName( - translate('BiblesPlugin.ImportWizardForm', - 'Open openlp.org 1.x Bible'), self.openlp1FileEdit, - u'%s (*.bible)' % translate('BiblesPlugin.ImportWizardForm', - 'openlp.org 1.x bible')) + self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.OLPV1, + self.openlp1FileEdit, u'%s (*.bible)' % + translate('BiblesPlugin.ImportWizardForm', 'openlp.org 1.x bible')) def registerFields(self): """ diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 8d79acec0..6c851b04b 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -207,29 +207,17 @@ class SongImportForm(OpenLPWizard): self.sourcePage.setSubTitle(WizardStrings.ImportSelectLong) self.formatLabel.setText(WizardStrings.FormatLabel) self.formatComboBox.setItemText(0, UiStrings.OLPV2) - self.formatComboBox.setItemText(1, - translate('SongsPlugin.ImportWizardForm', 'openlp.org 1.x')) - self.formatComboBox.setItemText(2, - translate('SongsPlugin.ImportWizardForm', 'OpenLyrics')) - self.formatComboBox.setItemText(3, - translate('SongsPlugin.ImportWizardForm', 'OpenSong')) - self.formatComboBox.setItemText(4, - translate('SongsPlugin.ImportWizardForm', 'Words of Worship')) - self.formatComboBox.setItemText(5, - translate('SongsPlugin.ImportWizardForm', 'CCLI/SongSelect')) - self.formatComboBox.setItemText(6, - translate('SongsPlugin.ImportWizardForm', 'Songs of Fellowship')) - self.formatComboBox.setItemText(7, - translate('SongsPlugin.ImportWizardForm', - 'Generic Document/Presentation')) - self.formatComboBox.setItemText(8, - translate('SongsPlugin.ImportWizardForm', 'EasiSlides')) - self.formatComboBox.setItemText(9, - translate('SongsPlugin.ImportWizardForm', 'EasyWorship')) - self.formatComboBox.setItemText(10, - translate('SongsPlugin.ImportWizardForm', 'SongBeamer')) -# self.formatComboBox.setItemText(11, -# translate('SongsPlugin.ImportWizardForm', 'CSV')) + self.formatComboBox.setItemText(1, UiStrings.OLPV1) + self.formatComboBox.setItemText(2, WizardStrings.OL) + self.formatComboBox.setItemText(3, WizardStrings.OS) + self.formatComboBox.setItemText(4, WizardStrings.WoW) + self.formatComboBox.setItemText(5, WizardStrings.CCLI) + self.formatComboBox.setItemText(6, WizardStrings.SoF) + self.formatComboBox.setItemText(7, WizardStrings.GDP) + self.formatComboBox.setItemText(8, WizardStrings.ES) + self.formatComboBox.setItemText(9, WizardStrings.EW) + self.formatComboBox.setItemText(10, WizardStrings.SB) +# self.formatComboBox.setItemText(11, WizardStrings.CSV) self.openLP2FilenameLabel.setText( translate('SongsPlugin.ImportWizardForm', 'Filename:')) self.openLP2BrowseButton.setText(UiStrings.Browse) @@ -316,89 +304,68 @@ class SongImportForm(OpenLPWizard): if source_format == SongFormat.OpenLP2: if self.openLP2FilenameEdit.text().isEmpty(): critical_error_message_box(UiStrings.NFSs, - translate('SongsPlugin.ImportWizardForm', - 'You need to select an OpenLP 2.0 song database ' - 'file to import from.')) + WizardStrings.YouSpecifyFile % UiStrings.OLPV2) self.openLP2BrowseButton.setFocus() return False elif source_format == SongFormat.OpenLP1: if self.openLP1FilenameEdit.text().isEmpty(): critical_error_message_box(UiStrings.NFSs, - translate('SongsPlugin.ImportWizardForm', - 'You need to select an openlp.org 1.x song ' - 'database file to import from.')) + WizardStrings.YouSpecifyFile % UiStrings.OLPV1) self.openLP1BrowseButton.setFocus() return False elif source_format == SongFormat.OpenLyrics: if self.openLyricsFileListWidget.count() == 0: critical_error_message_box(UiStrings.NFSp, - translate('SongsPlugin.ImportWizardForm', - 'You need to add at least one OpenLyrics ' - 'song file to import from.')) + WizardStrings.YouSpecifyFile % WizardStrings.OL) self.openLyricsAddButton.setFocus() return False elif source_format == SongFormat.OpenSong: if self.openSongFileListWidget.count() == 0: critical_error_message_box(UiStrings.NFSp, - translate('SongsPlugin.ImportWizardForm', - 'You need to add at least one OpenSong ' - 'song file to import from.')) + WizardStrings.YouSpecifyFile % WizardStrings.OS) self.openSongAddButton.setFocus() return False elif source_format == SongFormat.WordsOfWorship: if self.wordsOfWorshipFileListWidget.count() == 0: critical_error_message_box(UiStrings.NFSp, - translate('SongsPlugin.ImportWizardForm', - 'You need to add at least one Words of Worship ' - 'file to import from.')) + WizardStrings.YouSpecifyFile % WizardStrings.WoW) self.wordsOfWorshipAddButton.setFocus() return False elif source_format == SongFormat.CCLI: if self.ccliFileListWidget.count() == 0: critical_error_message_box(UiStrings.NFSp, - translate('SongsPlugin.ImportWizardForm', - 'You need to add at least one CCLI file ' - 'to import from.')) + WizardStrings.YouSpecifyFile % WizardStrings.CCLI) self.ccliAddButton.setFocus() return False elif source_format == SongFormat.SongsOfFellowship: if self.songsOfFellowshipFileListWidget.count() == 0: critical_error_message_box(UiStrings.NFSp, - translate('SongsPlugin.ImportWizardForm', - 'You need to add at least one Songs of Fellowship ' - 'file to import from.')) + WizardStrings.YouSpecifyFile % WizardStrings.SoF) self.songsOfFellowshipAddButton.setFocus() return False elif source_format == SongFormat.Generic: if self.genericFileListWidget.count() == 0: critical_error_message_box(UiStrings.NFSp, - translate('SongsPlugin.ImportWizardForm', - 'You need to add at least one document or ' - 'presentation file to import from.')) + WizardStrings.YouSpecifyFile % + WizardStrings.GDP.toLower()) self.genericAddButton.setFocus() return False elif source_format == SongFormat.EasiSlides: if self.easiSlidesFilenameEdit.text().isEmpty(): critical_error_message_box(UiStrings.NFSp, - translate('SongsPlugin.ImportWizardForm', - 'You need to select an xml song file exported from ' - 'EasiSlides, to import from.')) + WizardStrings.YouSpecifyFile % WizardStrings.ES) self.easiSlidesBrowseButton.setFocus() return False elif source_format == SongFormat.EasyWorship: if self.ewFilenameEdit.text().isEmpty(): critical_error_message_box(UiStrings.NFSs, - translate('SongsPlugin.ImportWizardForm', - 'You need to select an EasyWorship song database ' - 'file to import from.')) + WizardStrings.YouSpecifyFile % WizardStrings.EW) self.ewBrowseButton.setFocus() return False elif source_format == SongFormat.SongBeamer: if self.songBeamerFileListWidget.count() == 0: critical_error_message_box(UiStrings.NFSp, - translate('SongsPlugin.ImportWizardForm', - 'You need to add at least one SongBeamer ' - 'file to import from.')) + WizardStrings.YouSpecifyFile % WizardStrings.SB) self.songBeamerAddButton.setFocus() return False return True @@ -454,9 +421,7 @@ class SongImportForm(OpenLPWizard): """ Get OpenLP v2 song database file """ - self.getFileName( - translate('SongsPlugin.ImportWizardForm', - 'Select OpenLP 2.0 Database File'), + self.getFileName(WizardStrings.OpenTypeFile % UiStrings.OLPV2, self.openLP2FilenameEdit, u'%s (*.sqlite)' % (translate('SongsPlugin.ImportWizardForm', 'OpenLP 2.0 Databases')) @@ -466,9 +431,7 @@ class SongImportForm(OpenLPWizard): """ Get OpenLP v1 song database file """ - self.getFileName( - translate('SongsPlugin.ImportWizardForm', - 'Select openlp.org 1.x Database File'), + self.getFileName(WizardStrings.OpenTypeFile % UiStrings.OLPV1, self.openLP1FilenameEdit, u'%s (*.olp)' % translate('SongsPlugin.ImportWizardForm', 'openlp.org v1.x Databases') @@ -478,11 +441,8 @@ class SongImportForm(OpenLPWizard): """ Get OpenLyrics song database files """ - self.getFiles( - translate('SongsPlugin.ImportWizardForm', - 'Select OpenLyrics Files'), - self.openLyricsFileListWidget - ) + self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.OL, + self.openLyricsFileListWidget) def onOpenLyricsRemoveButtonClicked(self): """ @@ -494,10 +454,8 @@ class SongImportForm(OpenLPWizard): """ Get OpenSong song database files """ - self.getFiles( - translate('SongsPlugin.ImportWizardForm', 'Select Open Song Files'), - self.openSongFileListWidget - ) + self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.OS, + self.openSongFileListWidget) def onOpenSongRemoveButtonClicked(self): """ @@ -509,9 +467,7 @@ class SongImportForm(OpenLPWizard): """ Get Words of Worship song database files """ - self.getFiles( - translate('SongsPlugin.ImportWizardForm', - 'Select Words of Worship Files'), + self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.WoW, self.wordsOfWorshipFileListWidget, u'%s (*.wsg *.wow-song)' % translate('SongsPlugin.ImportWizardForm', 'Words Of Worship Song Files') @@ -527,11 +483,8 @@ class SongImportForm(OpenLPWizard): """ Get CCLI song database files """ - self.getFiles( - translate('SongsPlugin.ImportWizardForm', - 'Select CCLI Files'), - self.ccliFileListWidget - ) + self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.CCLI, + self.ccliFileListWidget) def onCCLIRemoveButtonClicked(self): """ @@ -543,9 +496,7 @@ class SongImportForm(OpenLPWizard): """ Get Songs of Fellowship song database files """ - self.getFiles( - translate('SongsPlugin.ImportWizardForm', - 'Select Songs of Fellowship Files'), + self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.SoF, self.songsOfFellowshipFileListWidget, u'%s (*.rtf)' % translate('SongsPlugin.ImportWizardForm', 'Songs Of Fellowship Song Files') @@ -561,11 +512,8 @@ class SongImportForm(OpenLPWizard): """ Get song database files """ - self.getFiles( - translate('SongsPlugin.ImportWizardForm', - 'Select Document/Presentation Files'), - self.genericFileListWidget - ) + self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.GDP, + self.genericFileListWidget) def onGenericRemoveButtonClicked(self): """ @@ -574,29 +522,21 @@ class SongImportForm(OpenLPWizard): self.removeSelectedItems(self.genericFileListWidget) def onEasiSlidesBrowseButtonClicked(self): - self.getFileName( - translate('SongsPlugin.ImportWizardForm', - 'Select EasiSlides songfile'), - self.easiSlidesFilenameEdit - ) + self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.ES, + self.easiSlidesFilenameEdit) def onEWBrowseButtonClicked(self): """ Get EasyWorship song database files """ - self.getFileName( - translate('SongsPlugin.ImportWizardForm', - 'Select EasyWorship Database File'), - self.ewFilenameEdit - ) + self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.EW, + self.ewFilenameEdit) def onSongBeamerAddButtonClicked(self): """ Get SongBeamer song database files """ - self.getFiles( - translate('SongsPlugin.ImportWizardForm', - 'Select SongBeamer Files'), + self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.SB, self.songBeamerFileListWidget, u'%s (*.sng)' % translate('SongsPlugin.ImportWizardForm', 'SongBeamer files') )