From fbd5349c2f2ce4f1d355667263da88883cb3b8e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sun, 15 May 2011 20:42:08 +0200 Subject: [PATCH] small bugfixes hide entry in tools menu if there are no bibles to upgrade --- openlp/plugins/bibles/bibleplugin.py | 6 ++++-- openlp/plugins/bibles/forms/bibleupgradeform.py | 10 ++++++++-- openlp/plugins/bibles/lib/db.py | 1 - 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index bc986e464..fd56d9d32 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -28,7 +28,8 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import Plugin, StringContent, build_icon, translate +from openlp.core.lib import Plugin, StringContent, build_icon, translate, \ + SettingsManager from openlp.core.lib.ui import base_action, UiStrings from openlp.core.utils.actions import ActionList from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem @@ -59,7 +60,8 @@ class BiblePlugin(Plugin): #action_list.add_action(self.exportBibleItem, UiStrings().Export) # Set to invisible until we can export bibles self.exportBibleItem.setVisible(False) - self.toolsUpgradeItem.setVisible(True) + if SettingsManager.get_files(u'bibles', u'.sqlite'): + self.toolsUpgradeItem.setVisible(True) def finalise(self): """ diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index f521fffc5..7e55a6c41 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -422,8 +422,6 @@ class BibleUpgradeForm(OpenLPWizard): self.customSignals() self.retranslateUi() self.maxBibles = len(self.files) - self.finishButton.setVisible(False) - self.cancelButton.setVisible(True) for number, filename in enumerate(self.files): self.checkBox[number].setCheckState(QtCore.Qt.Checked) if os.path.exists(os.path.join(self.newpath, filename)): @@ -439,6 +437,8 @@ class BibleUpgradeForm(OpenLPWizard): self.deleteAllCheckBox.hide() self.deleteAllCheckBox.setCheckState(QtCore.Qt.Unchecked) self.restart() + self.finishButton.setVisible(False) + self.cancelButton.setVisible(True) settings.endGroup() def preWizard(self): @@ -469,6 +469,8 @@ class BibleUpgradeForm(OpenLPWizard): self.maxBibles += 1 number = 0 for biblenumber, filename in enumerate(self.files): + if self.stop_import_flag: + break bible_failed = False self.success[biblenumber] = False if not self.checkBox[biblenumber].checkState() == QtCore.Qt.Checked: @@ -563,6 +565,8 @@ class BibleUpgradeForm(OpenLPWizard): continue self.progressBar.setMaximum(len(books)) for book in books: + if self.stop_import_flag: + break self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\n' @@ -604,6 +608,8 @@ class BibleUpgradeForm(OpenLPWizard): books = oldbible.get_books() self.progressBar.setMaximum(len(books)) for book in books: + if self.stop_import_flag: + break self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\n' diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 3ef73e334..6452a2fca 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -799,7 +799,6 @@ class BiblesResourcesDB(QtCore.QObject, Manager): log.debug(u'BiblesResourcesDB.get_language("%s")', name) if not isinstance(name, unicode): name = unicode(name) - name = name.title() language = BiblesResourcesDB.run_sql(u'SELECT id, name, code FROM ' u'language WHERE name = ? OR code = ?', (name, name.lower())) if language: