From f4d25560e979b501ec4bf6b513e6b128106ba558 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 2 Feb 2011 23:12:31 +0000 Subject: [PATCH] UI library - critical_error_message_box --- openlp/core/lib/ui.py | 33 +++++++++++++++-- openlp/core/ui/__init__.py | 34 ++---------------- openlp/core/ui/displaytagtab.py | 6 ++-- openlp/core/ui/servicemanager.py | 14 ++++---- openlp/core/ui/themeform.py | 6 ++-- openlp/core/ui/thememanager.py | 22 ++++++------ .../plugins/bibles/forms/bibleimportform.py | 20 +++++------ openlp/plugins/bibles/lib/db.py | 4 +-- openlp/plugins/bibles/lib/http.py | 8 ++--- openlp/plugins/bibles/lib/mediaitem.py | 8 +++-- openlp/plugins/custom/forms/editcustomform.py | 4 +-- openlp/plugins/images/lib/mediaitem.py | 6 ++-- openlp/plugins/media/lib/mediaitem.py | 6 ++-- openlp/plugins/presentations/lib/mediaitem.py | 10 +++--- openlp/plugins/songs/forms/authorsform.py | 10 +++--- openlp/plugins/songs/forms/editsongform.py | 15 ++++---- openlp/plugins/songs/forms/editverseform.py | 4 +-- openlp/plugins/songs/forms/songbookform.py | 4 +-- openlp/plugins/songs/forms/songimportform.py | 24 ++++++------- .../songs/forms/songmaintenanceform.py | 36 +++++++++---------- openlp/plugins/songs/forms/topicsform.py | 5 +-- 21 files changed, 143 insertions(+), 136 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index faca42119..f87ac68d1 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -28,7 +28,9 @@ The :mod:`ui` module provides standard UI components for OpenLP. """ import logging -from PyQt4 import QtGui +from PyQt4 import QtCore, QtGui + +from openlp.core.lib import translate log = logging.getLogger(__name__) @@ -68,4 +70,31 @@ def save_cancel_button_box(parent): parent.accept) QtCore.QObject.connect(button_box, QtCore.SIGNAL(u'rejected()'), parent.reject) - return button_box + return button_box + +def critical_error_message_box(title=None, message=None, parent=None, + question=False): + """ + Provides a standard critical message box for errors that OpenLP displays + to users. + + ``title`` + The title for the message box. + + ``message`` + The message to display to the user. + + ``parent`` + The parent UI element to attach the dialog to. + + ``question`` + Should this message box question the user. + """ + error = translate('OpenLP.Ui', 'Error') + if question: + return QtGui.QMessageBox.critical(parent, error, message, + QtGui.QMessageBox.StandardButtons( + QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) + data = {u'message': message} + data[u'title'] = title if title else error + return Receiver.send_message(u'openlp_error_message', data) diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py index 80124c2be..eb0e89775 100644 --- a/openlp/core/ui/__init__.py +++ b/openlp/core/ui/__init__.py @@ -51,34 +51,6 @@ class HideMode(object): Theme = 2 Screen = 3 - -def criticalErrorMessageBox(title=None, message=None, parent=None, - question=False): - """ - Provides a standard critical message box for errors that OpenLP displays - to users. - - ``title`` - The title for the message box. - - ``message`` - The message to display to the user. - - ``parent`` - The parent UI element to attach the dialog to. - - ``question`` - Should this message box question the user. - """ - error = translate('OpenLP.Ui', 'Error') - if question: - return QtGui.QMessageBox.critical(parent, error, message, - QtGui.QMessageBox.StandardButtons( - QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) - data = {u'message': message} - data[u'title'] = title if title else error - return Receiver.send_message(u'openlp_error_message', data) - from themeform import ThemeForm from filerenameform import FileRenameForm from maindisplay import MainDisplay @@ -99,6 +71,6 @@ from mediadockmanager import MediaDockManager from servicemanager import ServiceManager from thememanager import ThemeManager -__all__ = ['criticalErrorMessageBox', 'SplashScreen', 'AboutForm', - 'SettingsForm', 'MainDisplay', 'SlideController', 'ServiceManager', - 'ThemeManager', 'MediaDockManager', 'ServiceItemEditForm'] +__all__ = ['SplashScreen', 'AboutForm', 'SettingsForm', 'MainDisplay', + 'SlideController', 'ServiceManager', 'ThemeManager', 'MediaDockManager', + 'ServiceItemEditForm'] diff --git a/openlp/core/ui/displaytagtab.py b/openlp/core/ui/displaytagtab.py index 1c77084b9..983bc17a8 100644 --- a/openlp/core/ui/displaytagtab.py +++ b/openlp/core/ui/displaytagtab.py @@ -34,7 +34,7 @@ import cPickle from PyQt4 import QtCore, QtGui from openlp.core.lib import SettingsTab, translate, DisplayTags -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box class DisplayTagTab(SettingsTab): ''' @@ -276,7 +276,7 @@ class DisplayTagTab(SettingsTab): """ for html in DisplayTags.get_html_tags(): if self._strip(html[u'start tag']) == u'n': - criticalErrorMessageBox( + critical_error_message_box( translate('OpenLP.DisplayTagTab', 'Update Error'), translate('OpenLP.DisplayTagTab', 'Tag "n" already defined.')) @@ -317,7 +317,7 @@ class DisplayTagTab(SettingsTab): for linenumber, html1 in enumerate(html_expands): if self._strip(html1[u'start tag']) == tag and \ linenumber != self.selected: - criticalErrorMessageBox( + critical_error_message_box( translate('OpenLP.DisplayTagTab', 'Update Error'), unicode(translate('OpenLP.DisplayTagTab', 'Tag %s already defined.')) % tag) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 9082c7a80..ace678c75 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -36,8 +36,8 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import OpenLPToolbar, ServiceItem, context_menu_action, \ Receiver, build_icon, ItemCapabilities, SettingsManager, translate, \ ThemeLevel -from openlp.core.ui import criticalErrorMessageBox, ServiceNoteForm, \ - ServiceItemEditForm +from openlp.core.lib.ui import critical_error_message_box +from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \ split_filename @@ -491,7 +491,7 @@ class ServiceManager(QtGui.QWidget): for file in zip.namelist(): ucsfile = file_is_unicode(file) if not ucsfile: - criticalErrorMessageBox( + critical_error_message_box( message=translate('OpenLP.ServiceManager', 'File is not a valid service.\n' 'The content encoding is not UTF-8.')) @@ -521,7 +521,7 @@ class ServiceManager(QtGui.QWidget): serviceItem.name.lower(), serviceItem) delete_file(p_file) else: - criticalErrorMessageBox( + critical_error_message_box( message=translate('OpenLP.ServiceManager', 'File is not a valid service.')) log.exception(u'File contains no service data') @@ -993,7 +993,7 @@ class ServiceManager(QtGui.QWidget): self.mainwindow.previewController.addServiceManagerItem( self.serviceItems[item][u'service_item'], child) else: - criticalErrorMessageBox( + critical_error_message_box( translate('OpenLP.ServiceManager', 'Missing Display Handler'), translate('OpenLP.ServiceManager', 'Your item cannot be ' 'displayed as there is no handler to display it')) @@ -1027,7 +1027,7 @@ class ServiceManager(QtGui.QWidget): self.serviceItems[item][u'service_item'], 0) self.mainwindow.liveController.previewListWidget.setFocus() else: - criticalErrorMessageBox( + critical_error_message_box( translate('OpenLP.ServiceManager', 'Missing Display Handler'), translate('OpenLP.ServiceManager', 'Your item cannot be ' 'displayed as the plugin required to display it is missing ' @@ -1188,7 +1188,7 @@ class ServiceManager(QtGui.QWidget): Print a Service Order Sheet. """ if not self.serviceItems: - criticalErrorMessageBox( + critical_error_message_box( message=translate('OpenLP.ServiceManager', 'There is no service item in this service.')) return diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 8d10f21fa..018df7597 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, BackgroundType, BackgroundGradientType, \ Receiver -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import get_images_filter from themewizard import Ui_ThemeWizard @@ -567,13 +567,13 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): # Save the theme name self.theme.theme_name = unicode(self.field(u'name').toString()) if not self.theme.theme_name: - criticalErrorMessageBox( + critical_error_message_box( translate('OpenLP.ThemeForm', 'Theme Name Missing'), translate('OpenLP.ThemeForm', 'There is no name for this theme. Please enter one.')) return if self.theme.theme_name == u'-1' or self.theme.theme_name == u'None': - criticalErrorMessageBox( + critical_error_message_box( translate('OpenLP.ThemeForm', 'Theme Name Invalid'), translate('OpenLP.ThemeForm', 'Invalid theme name. Please enter one.')) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index df1f1f775..f403d7441 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -32,11 +32,12 @@ import logging from xml.etree.ElementTree import ElementTree, XML from PyQt4 import QtCore, QtGui -from openlp.core.ui import criticalErrorMessageBox, FileRenameForm, ThemeForm -from openlp.core.theme import Theme from openlp.core.lib import OpenLPToolbar, ThemeXML, get_text_file_string, \ build_icon, Receiver, SettingsManager, translate, check_item_selected, \ BackgroundType, BackgroundGradientType, check_directory_exists +from openlp.core.lib.ui import critical_error_message_box +from openlp.core.theme import Theme +from openlp.core.ui import FileRenameForm, ThemeForm from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \ get_filesystem_encoding @@ -359,7 +360,7 @@ class ThemeManager(QtGui.QWidget): """ item = self.themeListWidget.currentItem() if item is None: - criticalErrorMessageBox(message=translate('OpenLP.ThemeManager', + critical_error_message_box(message=translate('OpenLP.ThemeManager', 'You have not selected a theme.')) return theme = unicode(item.data(QtCore.Qt.UserRole).toString()) @@ -386,7 +387,7 @@ class ThemeManager(QtGui.QWidget): 'Your theme has been successfully exported.')) except (IOError, OSError): log.exception(u'Export Theme Failed') - criticalErrorMessageBox( + critical_error_message_box( translate('OpenLP.ThemeManager', 'Theme Export Failed'), translate('OpenLP.ThemeManager', 'Your theme could not be exported due to an error.')) @@ -496,7 +497,7 @@ class ThemeManager(QtGui.QWidget): for file in zip.namelist(): ucsfile = file_is_unicode(file) if not ucsfile: - criticalErrorMessageBox( + critical_error_message_box( message=translate('OpenLP.ThemeManager', 'File is not a valid theme.\n' 'The content encoding is not UTF-8.')) @@ -531,14 +532,14 @@ class ThemeManager(QtGui.QWidget): theme = self._createThemeFromXml(filexml, self.path) self.generateAndSaveImage(dir, themename, theme) else: - criticalErrorMessageBox( + critical_error_message_box( translate('OpenLP.ThemeManager', 'Validation Error'), translate('OpenLP.ThemeManager', 'File is not a valid theme.')) log.exception(u'Theme file does not contain XML data %s' % filename) except (IOError, NameError): - criticalErrorMessageBox( + critical_error_message_box( translate('OpenLP.ThemeManager', 'Validation Error'), translate('OpenLP.ThemeManager', 'File is not a valid theme.')) @@ -558,7 +559,7 @@ class ThemeManager(QtGui.QWidget): """ theme_dir = os.path.join(self.path, themeName) if os.path.exists(theme_dir): - criticalErrorMessageBox( + critical_error_message_box( translate('OpenLP.ThemeManager', 'Validation Error'), translate('OpenLP.ThemeManager', 'A theme with this name already exists.')) @@ -688,7 +689,7 @@ class ThemeManager(QtGui.QWidget): return False # should be the same unless default if theme != unicode(item.data(QtCore.Qt.UserRole).toString()): - criticalErrorMessageBox( + critical_error_message_box( message=translate('OpenLP.ThemeManager', 'You are unable to delete the default theme.')) return False @@ -696,7 +697,8 @@ class ThemeManager(QtGui.QWidget): if testPlugin: for plugin in self.mainwindow.pluginManager.plugins: if plugin.usesTheme(theme): - criticalErrorMessageBox(translate('OpenLP.ThemeManager', + critical_error_message_box( + translate('OpenLP.ThemeManager', 'Validation Error'), unicode(translate('OpenLP.ThemeManager', 'Theme %s is used in the %s plugin.')) % \ diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 3e43d19aa..a2509ba97 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -35,7 +35,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import Receiver, SettingsManager, translate from openlp.core.lib.db import delete_database -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard from openlp.core.utils import AppLocation, string_is_unicode from openlp.plugins.bibles.lib.manager import BibleFormat @@ -486,7 +486,7 @@ class BibleImportForm(OpenLPWizard): elif self.currentPage() == self.selectPage: if self.field(u'source_format').toInt()[0] == BibleFormat.OSIS: if not self.field(u'osis_location').toString(): - criticalErrorMessageBox( + critical_error_message_box( translate('BiblesPlugin.ImportWizardForm', 'Invalid Bible Location'), translate('BiblesPlugin.ImportWizardForm', @@ -496,7 +496,7 @@ class BibleImportForm(OpenLPWizard): return False elif self.field(u'source_format').toInt()[0] == BibleFormat.CSV: if not self.field(u'csv_testamentsfile').toString(): - answer = criticalErrorMessageBox(translate( + answer = critical_error_message_box(translate( 'BiblesPlugin.ImportWizardForm', 'No Testaments File'), translate('BiblesPlugin.ImportWizardForm', 'You have not specified a testaments file. Do you ' @@ -505,7 +505,7 @@ class BibleImportForm(OpenLPWizard): self.csvTestamentsEdit.setFocus() return False elif not self.field(u'csv_booksfile').toString(): - criticalErrorMessageBox( + critical_error_message_box( translate('BiblesPlugin.ImportWizardForm', 'Invalid Books File'), translate('BiblesPlugin.ImportWizardForm', @@ -514,7 +514,7 @@ class BibleImportForm(OpenLPWizard): self.csvBooksEdit.setFocus() return False elif not self.field(u'csv_versefile').toString(): - criticalErrorMessageBox( + critical_error_message_box( translate('BiblesPlugin.ImportWizardForm', 'Invalid Verse File'), translate('BiblesPlugin.ImportWizardForm', @@ -525,7 +525,7 @@ class BibleImportForm(OpenLPWizard): elif self.field(u'source_format').toInt()[0] == \ BibleFormat.OpenSong: if not self.field(u'opensong_file').toString(): - criticalErrorMessageBox( + critical_error_message_box( translate('BiblesPlugin.ImportWizardForm', 'Invalid OpenSong Bible'), translate('BiblesPlugin.ImportWizardForm', @@ -535,7 +535,7 @@ class BibleImportForm(OpenLPWizard): return False elif self.field(u'source_format').toInt()[0] == BibleFormat.OpenLP1: if not self.field(u'openlp1_location').toString(): - criticalErrorMessageBox( + critical_error_message_box( translate('BiblesPlugin.ImportWizardForm', 'Invalid Bible Location'), translate('BiblesPlugin.ImportWizardForm', @@ -549,7 +549,7 @@ class BibleImportForm(OpenLPWizard): license_copyright = \ unicode(self.field(u'license_copyright').toString()) if not license_version: - criticalErrorMessageBox( + critical_error_message_box( translate('BiblesPlugin.ImportWizardForm', 'Empty Version Name'), translate('BiblesPlugin.ImportWizardForm', @@ -557,7 +557,7 @@ class BibleImportForm(OpenLPWizard): self.versionNameEdit.setFocus() return False elif not license_copyright: - criticalErrorMessageBox( + critical_error_message_box( translate('BiblesPlugin.ImportWizardForm', 'Empty Copyright'), translate('BiblesPlugin.ImportWizardForm', @@ -566,7 +566,7 @@ class BibleImportForm(OpenLPWizard): self.copyrightEdit.setFocus() return False elif self.manager.exists(license_version): - criticalErrorMessageBox( + critical_error_message_box( translate('BiblesPlugin.ImportWizardForm', 'Bible Exists'), translate('BiblesPlugin.ImportWizardForm', 'This Bible already exists. Please import ' diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index a9444d88b..b986b0d66 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -35,7 +35,7 @@ from sqlalchemy.orm.exc import UnmappedClassError from openlp.core.lib import translate from openlp.core.lib.db import BaseModel, init_db, Manager -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box log = logging.getLogger(__name__) @@ -361,7 +361,7 @@ class BibleDB(QtCore.QObject, Manager): verse_list.extend(verses) else: log.debug(u'OpenLP failed to find book %s', book) - criticalErrorMessageBox( + critical_error_message_box( translate('BiblesPlugin', 'No Book Found'), translate('BiblesPlugin', 'No matching book ' 'could be found in this Bible. Check that you have ' diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index e004be9df..8db214140 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -38,7 +38,7 @@ from HTMLParser import HTMLParseError from BeautifulSoup import BeautifulSoup, NavigableString from openlp.core.lib import Receiver, translate -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import AppLocation, get_web_page from openlp.plugins.bibles.lib import SearchResults from openlp.plugins.bibles.lib.db import BibleDB, Book @@ -431,7 +431,7 @@ class HTTPBible(BibleDB): if not db_book: book_details = HTTPBooks.get_book(book) if not book_details: - criticalErrorMessageBox( + critical_error_message_box( translate('BiblesPlugin', 'No Book Found'), translate('BiblesPlugin', 'No matching ' 'book could be found in this Bible. Check that you ' @@ -552,14 +552,14 @@ def send_error_message(error_type): The type of error that occured for the issue. """ if error_type == u'download': - criticalErrorMessageBox( + critical_error_message_box( translate('BiblePlugin.HTTPBible', 'Download Error'), translate('BiblePlugin.HTTPBible', 'There was a ' 'problem downloading your verse selection. Please check your ' 'Internet connection, and if this error continues to occur ' 'please consider reporting a bug.')) elif error_type == u'parse': - criticalErrorMessageBox( + critical_error_message_box( translate('BiblePlugin.HTTPBible', 'Parse Error'), translate('BiblePlugin.HTTPBible', 'There was a ' 'problem extracting your verse selection. If this error continues ' diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index de2649b31..c66b83dfc 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -30,7 +30,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, Receiver, BaseListWithDnD, \ ItemCapabilities, translate -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.bibles.forms import BibleImportForm from openlp.plugins.bibles.lib import get_reference_match @@ -387,7 +387,8 @@ class BibleMediaItem(MediaManagerItem): verse_count = self.parent.manager.get_verse_count(bible, book, 1) if verse_count == 0: self.advancedSearchButton.setEnabled(False) - criticalErrorMessageBox(message=translate('BiblePlugin.MediaItem', + critical_error_message_box( + message=translate('BiblePlugin.MediaItem', 'Bible not fully loaded')) else: self.advancedSearchButton.setEnabled(True) @@ -581,7 +582,8 @@ class BibleMediaItem(MediaManagerItem): if item_second_bible and second_bible or not item_second_bible and \ not second_bible: self.displayResults(bible, second_bible) - elif criticalErrorMessageBox(message=translate('BiblePlugin.MediaItem', + elif critical_error_message_box( + message=translate('BiblePlugin.MediaItem', 'You cannot combine single and second bible verses. Do you ' 'want to delete your search results and start a new search?'), parent=self, question=True) == QtGui.QMessageBox.Yes: diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 60b313284..e8dfa20aa 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -29,7 +29,7 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import Receiver, translate -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.custom.lib import CustomXMLBuilder, CustomXMLParser from openlp.plugins.custom.lib.db import CustomSlide from editcustomdialog import Ui_CustomEditDialog @@ -152,7 +152,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): """ valid, message = self._validate() if not valid: - criticalErrorMessageBox(message=message) + critical_error_message_box(message=message) return False sxml = CustomXMLBuilder() sxml.new_document() diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 25d9811f1..cbefc7171 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -32,7 +32,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ ItemCapabilities, SettingsManager, translate, check_item_selected, \ check_directory_exists, Receiver -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import AppLocation, delete_file, get_images_filter log = logging.getLogger(__name__) @@ -161,7 +161,7 @@ class ImageMediaItem(MediaManagerItem): items.remove(item) # We cannot continue, as all images do not exist. if not items: - criticalErrorMessageBox( + critical_error_message_box( translate('ImagePlugin.MediaItem', 'Missing Image(s)'), unicode(translate('ImagePlugin.MediaItem', 'The following image(s) no longer exist: %s')) % @@ -214,7 +214,7 @@ class ImageMediaItem(MediaManagerItem): self.parent.liveController.display.directImage(name, filename) self.resetAction.setVisible(True) else: - criticalErrorMessageBox( + critical_error_message_box( translate('ImagePlugin.MediaItem', 'Live Background Error'), unicode(translate('ImagePlugin.MediaItem', 'There was a problem replacing your background, ' diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index c68b11c85..ea1b679b4 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ ItemCapabilities, SettingsManager, translate, check_item_selected, Receiver -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box log = logging.getLogger(__name__) @@ -120,7 +120,7 @@ class MediaMediaItem(MediaManagerItem): self.parent.liveController.display.video(filename, 0, True) self.resetAction.setVisible(True) else: - criticalErrorMessageBox(translate('MediaPlugin.MediaItem', + critical_error_message_box(translate('MediaPlugin.MediaItem', 'Live Background Error'), unicode(translate('MediaPlugin.MediaItem', 'There was a problem replacing your background, ' @@ -144,7 +144,7 @@ class MediaMediaItem(MediaManagerItem): return True else: # File is no longer present - criticalErrorMessageBox( + critical_error_message_box( translate('MediaPlugin.MediaItem', 'Missing Media File'), unicode(translate('MediaPlugin.MediaItem', 'The file %s no longer exists.')) % filename) diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 43cb3dab0..7b07a26c9 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ SettingsManager, translate, check_item_selected, Receiver, ItemCapabilities -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.presentations.lib import MessageListener log = logging.getLogger(__name__) @@ -181,7 +181,7 @@ class PresentationMediaItem(MediaManagerItem): filename = os.path.split(unicode(file))[1] if titles.count(filename) > 0: if not initialLoad: - criticalErrorMessageBox( + critical_error_message_box( translate('PresentationPlugin.MediaItem', 'File Exists'), translate('PresentationPlugin.MediaItem', @@ -205,7 +205,7 @@ class PresentationMediaItem(MediaManagerItem): if initialLoad: icon = build_icon(u':/general/general_delete.png') else: - criticalErrorMessageBox( + critical_error_message_box( self, translate('PresentationPlugin.MediaItem', 'Unsupported File'), translate('PresentationPlugin.MediaItem', @@ -278,7 +278,7 @@ class PresentationMediaItem(MediaManagerItem): return True else: # File is no longer present - criticalErrorMessageBox( + critical_error_message_box( translate('PresentationPlugin.MediaItem', 'Missing Presentation'), unicode(translate('PresentationPlugin.MediaItem', @@ -287,7 +287,7 @@ class PresentationMediaItem(MediaManagerItem): return False else: # File is no longer present - criticalErrorMessageBox( + critical_error_message_box( translate('PresentationPlugin.MediaItem', 'Missing Presentation'), unicode(translate('PresentationPlugin.MediaItem', diff --git a/openlp/plugins/songs/forms/authorsform.py b/openlp/plugins/songs/forms/authorsform.py index 091618bde..3a37cf290 100644 --- a/openlp/plugins/songs/forms/authorsform.py +++ b/openlp/plugins/songs/forms/authorsform.py @@ -27,7 +27,7 @@ from PyQt4 import QtGui, QtCore from openlp.core.lib import translate -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.songs.forms.authorsdialog import Ui_AuthorsDialog class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog): @@ -80,17 +80,19 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog): def accept(self): if not self.firstNameEdit.text(): - criticalErrorMessageBox(message=translate('SongsPlugin.AuthorsForm', + critical_error_message_box( + message=translate('SongsPlugin.AuthorsForm', 'You need to type in the first name of the author.')) self.firstNameEdit.setFocus() return False elif not self.lastNameEdit.text(): - criticalErrorMessageBox(message=translate('SongsPlugin.AuthorsForm', + critical_error_message_box( + message=translate('SongsPlugin.AuthorsForm', 'You need to type in the last name of the author.')) self.lastNameEdit.setFocus() return False elif not self.displayEdit.text(): - if criticalErrorMessageBox( + if critical_error_message_box( message=translate('SongsPlugin.AuthorsForm', 'You have not set a display name for the ' 'author, combine the first and last names?'), diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index c3279e1a9..bf94503ff 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -30,7 +30,7 @@ import re from PyQt4 import QtCore, QtGui from openlp.core.lib import Receiver, translate -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.songs.forms import EditVerseForm from openlp.plugins.songs.lib import SongXML, VerseType from openlp.plugins.songs.lib.db import Book, Song, Author, Topic @@ -255,7 +255,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.songBookNumberEdit.setText(self.song.song_number) else: self.songBookNumberEdit.setText(u'') - # lazy xml migration for now self.verseListWidget.clear() self.verseListWidget.setRowCount(0) @@ -343,7 +342,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): author = self.manager.get_object(Author, item_id) if self.authorsListView.findItems(unicode(author.display_name), QtCore.Qt.MatchExactly): - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.EditSongForm', 'This author is already in the list.')) else: @@ -400,7 +399,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): topic = self.manager.get_object(Topic, item_id) if self.topicsListView.findItems(unicode(topic.name), QtCore.Qt.MatchExactly): - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.EditSongForm', 'This topic is already in the list.')) else: @@ -533,21 +532,21 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): if not self.titleEdit.text(): self.songTabWidget.setCurrentIndex(0) self.titleEdit.setFocus() - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.EditSongForm', 'You need to type in a song title.')) return False if self.verseListWidget.rowCount() == 0: self.songTabWidget.setCurrentIndex(0) self.verseListWidget.setFocus() - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.EditSongForm', 'You need to type in at least one verse.')) return False if self.authorsListView.count() == 0: self.songTabWidget.setCurrentIndex(1) self.authorsListView.setFocus() - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.EditSongForm', 'You need to have an author for this song.')) return False @@ -575,7 +574,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): valid = verses.pop(0) for verse in verses: valid = valid + u', ' + verse - criticalErrorMessageBox( + critical_error_message_box( message=unicode(translate('SongsPlugin.EditSongForm', 'The verse order is invalid. There is no verse ' 'corresponding to %s. Valid entries are %s.')) % \ diff --git a/openlp/plugins/songs/forms/editverseform.py b/openlp/plugins/songs/forms/editverseform.py index c10e48cb7..e67e0733a 100644 --- a/openlp/plugins/songs/forms/editverseform.py +++ b/openlp/plugins/songs/forms/editverseform.py @@ -29,7 +29,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.songs.lib import VerseType, translate from editversedialog import Ui_EditVerseDialog @@ -168,7 +168,7 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): else: value = self.getVerse()[0].split(u'\n')[1] if len(value) == 0: - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.EditSongForm', 'You need to type some text in to the verse.')) return False diff --git a/openlp/plugins/songs/forms/songbookform.py b/openlp/plugins/songs/forms/songbookform.py index 8341a7c4c..3f054fe8d 100644 --- a/openlp/plugins/songs/forms/songbookform.py +++ b/openlp/plugins/songs/forms/songbookform.py @@ -27,7 +27,7 @@ from PyQt4 import QtGui from openlp.core.lib import translate -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.songs.forms.songbookdialog import Ui_SongBookDialog class SongBookForm(QtGui.QDialog, Ui_SongBookDialog): @@ -50,7 +50,7 @@ class SongBookForm(QtGui.QDialog, Ui_SongBookDialog): def accept(self): if not self.nameEdit.text(): - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.SongBookForm', 'You need to type in a name for the book.')) self.nameEdit.setFocus() diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index a5b0e713a..f1e1f82ed 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -32,7 +32,7 @@ import os from PyQt4 import QtCore, QtGui from openlp.core.lib import Receiver, SettingsManager, translate -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard from openlp.plugins.songs.lib.importer import SongFormat @@ -329,7 +329,7 @@ class SongImportForm(OpenLPWizard): source_format = self.formatComboBox.currentIndex() if source_format == SongFormat.OpenLP2: if self.openLP2FilenameEdit.text().isEmpty(): - criticalErrorMessageBox( + critical_error_message_box( translate('SongsPlugin.ImportWizardForm', 'No OpenLP 2.0 Song Database Selected'), translate('SongsPlugin.ImportWizardForm', @@ -339,7 +339,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.OpenLP1: if self.openLP1FilenameEdit.text().isEmpty(): - criticalErrorMessageBox( + critical_error_message_box( translate('SongsPlugin.ImportWizardForm', 'No openlp.org 1.x Song Database Selected'), translate('SongsPlugin.ImportWizardForm', @@ -349,7 +349,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.OpenLyrics: if self.openLyricsFileListWidget.count() == 0: - criticalErrorMessageBox( + critical_error_message_box( translate('SongsPlugin.ImportWizardForm', 'No OpenLyrics Files Selected'), translate('SongsPlugin.ImportWizardForm', @@ -359,7 +359,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.OpenSong: if self.openSongFileListWidget.count() == 0: - criticalErrorMessageBox( + critical_error_message_box( translate('SongsPlugin.ImportWizardForm', 'No OpenSong Files Selected'), translate('SongsPlugin.ImportWizardForm', @@ -369,7 +369,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.WordsOfWorship: if self.wordsOfWorshipFileListWidget.count() == 0: - criticalErrorMessageBox( + critical_error_message_box( translate('SongsPlugin.ImportWizardForm', 'No Words of Worship Files Selected'), translate('SongsPlugin.ImportWizardForm', @@ -379,7 +379,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.CCLI: if self.ccliFileListWidget.count() == 0: - criticalErrorMessageBox( + critical_error_message_box( translate('SongsPlugin.ImportWizardForm', 'No CCLI Files Selected'), translate('SongsPlugin.ImportWizardForm', @@ -389,7 +389,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.SongsOfFellowship: if self.songsOfFellowshipFileListWidget.count() == 0: - criticalErrorMessageBox( + critical_error_message_box( translate('SongsPlugin.ImportWizardForm', 'No Songs of Fellowship File Selected'), translate('SongsPlugin.ImportWizardForm', @@ -399,7 +399,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.Generic: if self.genericFileListWidget.count() == 0: - criticalErrorMessageBox( + critical_error_message_box( translate('SongsPlugin.ImportWizardForm', 'No Document/Presentation Selected'), translate('SongsPlugin.ImportWizardForm', @@ -409,7 +409,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.EasiSlides: if self.easiSlidesFilenameEdit.text().isEmpty(): - criticalErrorMessageBox( + critical_error_message_box( translate('SongsPlugin.ImportWizardForm', 'No Easislides Songs file selected'), translate('SongsPlugin.ImportWizardForm', @@ -419,7 +419,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.EasyWorship: if self.ewFilenameEdit.text().isEmpty(): - criticalErrorMessageBox( + critical_error_message_box( translate('SongsPlugin.ImportWizardForm', 'No EasyWorship Song Database Selected'), translate('SongsPlugin.ImportWizardForm', @@ -429,7 +429,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.SongBeamer: if self.songBeamerFileListWidget.count() == 0: - criticalErrorMessageBox( + critical_error_message_box( translate('SongsPlugin.ImportWizardForm', 'No SongBeamer File Selected'), translate('SongsPlugin.ImportWizardForm', diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 441182424..e98bc3a6f 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -29,7 +29,7 @@ from PyQt4 import QtGui, QtCore from sqlalchemy.sql import and_ from openlp.core.lib import Receiver, translate -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.songs.forms import AuthorsForm, TopicsForm, SongBookForm from openlp.plugins.songs.lib.db import Author, Book, Topic, Song from songmaintenancedialog import Ui_SongMaintenanceDialog @@ -108,14 +108,14 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): if item_id != -1: item = self.manager.get_object(item_class, item_id) if item and len(item.songs) == 0: - if criticalErrorMessageBox(title=dlg_title, message=del_text, + if critical_error_message_box(title=dlg_title, message=del_text, parent=self, question=True) == QtGui.QMessageBox.Yes: self.manager.delete_object(item_class, item.id) reset_func() else: - criticalErrorMessageBox(dlg_title, err_text) + critical_error_message_box(dlg_title, err_text) else: - criticalErrorMessageBox(dlg_title, sel_text) + critical_error_message_box(dlg_title, sel_text) def resetAuthors(self): """ @@ -237,11 +237,11 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): if self.manager.save_object(author): self.resetAuthors() else: - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.SongMaintenanceForm', 'Could not add your author.')) else: - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.SongMaintenanceForm', 'This author already exists.')) @@ -252,11 +252,11 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): if self.manager.save_object(topic): self.resetTopics() else: - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.SongMaintenanceForm', 'Could not add your topic.')) else: - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.SongMaintenanceForm', 'This topic already exists.')) @@ -268,11 +268,11 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): if self.manager.save_object(book): self.resetBooks() else: - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.SongMaintenanceForm', 'Could not add your book.')) else: - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.SongMaintenanceForm', 'This book already exists.')) @@ -301,10 +301,10 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): self.resetAuthors() Receiver.send_message(u'songs_load_list') else: - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.SongMaintenanceForm', 'Could not save your changes.')) - elif criticalErrorMessageBox(message=unicode(translate( + elif critical_error_message_box(message=unicode(translate( 'SongsPlugin.SongMaintenanceForm', 'The author %s already ' 'exists. Would you like to make songs with author %s use ' 'the existing author %s?')) % (author.display_name, @@ -318,7 +318,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): author.first_name = temp_first_name author.last_name = temp_last_name author.display_name = temp_display_name - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.SongMaintenanceForm', 'Could not save your modified author, because the ' 'author already exists.')) @@ -337,10 +337,10 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): if self.manager.save_object(topic): self.resetTopics() else: - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.SongMaintenanceForm', 'Could not save your changes.')) - elif criticalErrorMessageBox( + elif critical_error_message_box( message=unicode(translate('SongsPlugin.SongMaintenanceForm', 'The topic %s already exists. Would you like to make songs ' 'with topic %s use the existing topic %s?')) % (topic.name, @@ -350,7 +350,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): else: # We restore the topics's old name. topic.name = temp_name - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.SongMaintenanceForm', 'Could not save your modified topic, because it ' 'already exists.')) @@ -375,10 +375,10 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): if self.manager.save_object(book): self.resetBooks() else: - criticalErrorMessageBox( + critical_error_message_box( message=translate('SongsPlugin.SongMaintenanceForm', 'Could not save your changes.')) - elif criticalErrorMessageBox( + elif critical_error_message_box( message=unicode(translate('SongsPlugin.SongMaintenanceForm', 'The book %s already exists. Would you like to make songs ' 'with book %s use the existing book %s?')) % (book.name, diff --git a/openlp/plugins/songs/forms/topicsform.py b/openlp/plugins/songs/forms/topicsform.py index 4ab2b63fa..792570c93 100644 --- a/openlp/plugins/songs/forms/topicsform.py +++ b/openlp/plugins/songs/forms/topicsform.py @@ -27,7 +27,7 @@ from PyQt4 import QtGui from openlp.core.lib import translate -from openlp.core.ui import criticalErrorMessageBox +from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.songs.forms.topicsdialog import Ui_TopicsDialog class TopicsForm(QtGui.QDialog, Ui_TopicsDialog): @@ -49,7 +49,8 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog): def accept(self): if not self.nameEdit.text(): - criticalErrorMessageBox(message=translate('SongsPlugin.TopicsForm', + critical_error_message_box( + message=translate('SongsPlugin.TopicsForm', 'You need to type in a topic name.')) self.nameEdit.setFocus() return False