diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 70a06fc0c..087fd7ca5 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -77,6 +77,12 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): QtGui.QWizard.__init__(self, parent) self.setupUi(self) self.registerFields() + if not BibleFormat.get_availability(BibleFormat.OpenLP1): + self.openlp1Page.setVisible(False) + self.openlp1LocationLabel.setVisible(False) + self.openlp1LocationEdit.setVisible(False) + self.openlp1FileButton.setVisible(False) + self.openlp1DisabledLabel.setVisible(True) self.finishButton = self.button(QtGui.QWizard.FinishButton) self.cancelButton = self.button(QtGui.QWizard.CancelButton) self.manager = manager @@ -102,9 +108,6 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): QtCore.QObject.connect(self.openlp1FileButton, QtCore.SIGNAL(u'clicked()'), self.onOpenlp1FileButtonClicked) - QtCore.QObject.connect(self.cancelButton, - QtCore.SIGNAL(u'clicked(bool)'), - self.onCancelButtonClicked) QtCore.QObject.connect(self, QtCore.SIGNAL(u'currentIdChanged(int)'), self.onCurrentIdChanged) @@ -123,8 +126,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): log.debug('Import canceled by user.') if self.currentId() == 3: Receiver.send_message(u'bibles_stop_import') - else: - self.done(QtGui.QDialog.Rejected) + self.done(QtGui.QDialog.Rejected) def validateCurrentPage(self): """ diff --git a/openlp/plugins/bibles/forms/bibleimportwizard.py b/openlp/plugins/bibles/forms/bibleimportwizard.py index 4f6e0f624..a0e90f975 100644 --- a/openlp/plugins/bibles/forms/bibleimportwizard.py +++ b/openlp/plugins/bibles/forms/bibleimportwizard.py @@ -279,6 +279,11 @@ class Ui_BibleImportWizard(object): self.openlp1LocationLayout.addWidget(self.openlp1FileButton) self.openlp1Layout.setLayout(1, QtGui.QFormLayout.FieldRole, self.openlp1LocationLayout) + self.openlp1DisabledLabel = QtGui.QLabel(self.openlp1Page) + self.openlp1DisabledLabel.setObjectName(u'openlp1DisabledLabel') + self.openlp1DisabledLabel.setVisible(False) + self.openlp1DisabledLabel.setWordWrap(True) + self.openlp1Layout.addWidget(self.openlp1DisabledLabel) self.formatWidget.addWidget(self.openlp1Page) self.selectPageLayout.addWidget(self.formatWidget) bibleImportWizard.addPage(self.selectPage) @@ -417,3 +422,8 @@ class Ui_BibleImportWizard(object): self.importProgressLabel.setText( translate('BiblesPlugin.ImportWizardForm', 'Ready.')) self.importProgressBar.setFormat(u'%p%') + self.openlp1DisabledLabel.setText( + translate('BiblesPlugin.ImportWizardForm', 'The openlp.org 1.x ' + 'importer has been disabled due to a missing Python module. If ' + 'you want to use this importer, you will need to install the ' + '"python-sqlite" module.')) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 794c9c5f7..a220b160d 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -35,9 +35,14 @@ from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta from csvbible import CSVBible from http import HTTPBible -from openlp1 import OpenLP1Bible from opensong import OpenSongBible from osis import OSISBible +# Imports that might fail. +try: + from openlp1 import OpenLP1Bible + has_openlp1 = True +except ImportError: + has_openlp1 = False log = logging.getLogger(__name__) @@ -57,6 +62,7 @@ class BibleFormat(object): plus a few helper functions to facilitate generic handling of Bible types for importing. """ + _format_availability = {} Unknown = -1 OSIS = 0 CSV = 1 @@ -98,6 +104,13 @@ class BibleFormat(object): BibleFormat.OpenLP1 ] + @staticmethod + def set_availability(format, available): + BibleFormat._format_availability[format] = available + + @staticmethod + def get_availability(format): + return BibleFormat._format_availability.get(format, True) class BibleManager(object): """ @@ -339,3 +352,7 @@ class BibleManager(object): """ for bible in self.db_cache: self.db_cache[bible].finalise() + +BibleFormat.set_availability(BibleFormat.OpenLP1, has_openlp1) + +__all__ = [u'BibleFormat'] diff --git a/openlp/plugins/bibles/lib/openlp1.py b/openlp/plugins/bibles/lib/openlp1.py index 7f8a8d17e..ba9476fca 100755 --- a/openlp/plugins/bibles/lib/openlp1.py +++ b/openlp/plugins/bibles/lib/openlp1.py @@ -62,6 +62,7 @@ class OpenLP1Bible(BibleDB): # Create all books. cursor.execute(u'SELECT id, testament_id, name, abbreviation FROM book') books = cursor.fetchall() + self.wizard.importProgressBar.setMaximum(len(books) + 1) for book in books: if self.stop_import_flag: connection.close() diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index cade0254a..f62c88063 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -136,8 +136,7 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard): log.debug('Import canceled by user.') if self.currentId() == 2: Receiver.send_message(u'songs_stop_import') - else: - self.done(QtGui.QDialog.Rejected) + self.done(QtGui.QDialog.Rejected) def validateCurrentPage(self): """ diff --git a/openlp/plugins/songs/forms/songimportwizard.py b/openlp/plugins/songs/forms/songimportwizard.py index 5be8ccfba..aafff1051 100644 --- a/openlp/plugins/songs/forms/songimportwizard.py +++ b/openlp/plugins/songs/forms/songimportwizard.py @@ -350,7 +350,7 @@ class Ui_SongImportWizard(object): else: setattr(self, prefix + u'Layout', importLayout) self.formatComboBox.addItem(u'') - + def disablableWidget(self, page, prefix, obj_prefix): layout = QtGui.QVBoxLayout(page) layout.setMargin(0) diff --git a/openlp/plugins/songs/lib/songbeamerimport.py b/openlp/plugins/songs/lib/songbeamerimport.py index 4980c2cff..30d29c1be 100644 --- a/openlp/plugins/songs/lib/songbeamerimport.py +++ b/openlp/plugins/songs/lib/songbeamerimport.py @@ -32,6 +32,7 @@ import os import chardet import codecs +from openlp.core.lib import translate from openlp.plugins.songs.lib.songimport import SongImport log = logging.getLogger(__name__) @@ -54,7 +55,8 @@ class SongBeamerTypes(object): u'Pre-Bridge': u'O', u'Pre-Coda': u'O', u'Unbekannt': u'O', - u'Unknown': u'O' + u'Unknown': u'O', + u'Unbenannt': u'O' } @@ -100,6 +102,7 @@ class SongBeamerImport(SongImport): detect_file.close() infile = codecs.open(file, u'r', details['encoding']) self.songData = infile.readlines() + infile.close() else: return False for line in self.songData: @@ -127,8 +130,9 @@ class SongBeamerImport(SongImport): self.replace_html_tags() self.add_verse(self.current_verse, self.current_verse_type) self.finish() - self.import_wizard.incrementProgressBar( - "Importing %s" % (self.file_name)) + self.import_wizard.incrementProgressBar(u'%s %s...' % + (translate('SongsPlugin.SongBeamerImport', 'Importing'), + self.file_name)) return True def replace_html_tags(self): @@ -263,6 +267,9 @@ class SongBeamerImport(SongImport): pass elif tag_val[0] == u'#Version': pass + elif tag_val[0] == u'#VerseOrder': + # TODO: add the verse order. + pass def check_verse_marks(self, line): """