Minor fixes

This commit is contained in:
Tim Bentley 2013-02-03 17:42:31 +00:00
parent ad438ba4b2
commit 28aeed815f
5 changed files with 41 additions and 30 deletions

View File

@ -154,6 +154,12 @@ class OpenLP(QtGui.QApplication):
self.main_window.app_startup()
return self.exec_()
def close_splash_screen(self):
"""
Close the splash screen when requested.
"""
self.splash.close()
def is_already_running(self):
"""
Look to see if OpenLP is already running and ask if a 2nd copy
@ -276,36 +282,36 @@ def main(args=None):
# Initialise the resources
qInitResources()
# Now create and actually run the application.
app = OpenLP(qt_args)
app.setOrganizationName(u'OpenLP')
app.setOrganizationDomain(u'openlp.org')
application = OpenLP(qt_args)
application.setOrganizationName(u'OpenLP')
application.setOrganizationDomain(u'openlp.org')
if options.portable:
app.setApplicationName(u'OpenLPPortable')
application.setApplicationName(u'OpenLPPortable')
Settings.setDefaultFormat(Settings.IniFormat)
# Get location OpenLPPortable.ini
app_path = AppLocation.get_directory(AppLocation.AppDir)
set_up_logging(os.path.abspath(os.path.join(app_path, u'..', u'..', u'Other')))
application_path = AppLocation.get_directory(AppLocation.AppDir)
set_up_logging(os.path.abspath(os.path.join(application_path, u'..', u'..', u'Other')))
log.info(u'Running portable')
portable_settings_file = os.path.abspath(os.path.join(app_path, u'..', u'..', u'Data', u'OpenLP.ini'))
portable_settings_file = os.path.abspath(os.path.join(application_path, u'..', u'..', u'Data', u'OpenLP.ini'))
# Make this our settings file
log.info(u'INI file: %s', portable_settings_file)
Settings.set_filename(portable_settings_file)
portable_settings = Settings()
# Set our data path
data_path = os.path.abspath(os.path.join(app_path, u'..', u'..', u'Data',))
data_path = os.path.abspath(os.path.join(application_path, u'..', u'..', u'Data',))
log.info(u'Data path: %s', data_path)
# Point to our data path
portable_settings.setValue(u'advanced/data path', data_path)
portable_settings.setValue(u'advanced/is portable', True)
portable_settings.sync()
else:
app.setApplicationName(u'OpenLP')
application.setApplicationName(u'OpenLP')
set_up_logging(AppLocation.get_directory(AppLocation.CacheDir))
Registry.create()
Registry().register(u'openlp_core', app)
app.setApplicationVersion(get_application_version()[u'version'])
Registry().register(u'openlp_core', application)
application.setApplicationVersion(get_application_version()[u'version'])
# Instance check
if app.is_already_running():
if application.is_already_running():
sys.exit()
# First time checks in settings
if not Settings().value(u'general/has run wizard'):
@ -314,14 +320,14 @@ def main(args=None):
sys.exit()
# i18n Set Language
language = LanguageManager.get_language()
app_translator, default_translator = LanguageManager.get_translator(language)
if not app_translator.isEmpty():
app.installTranslator(app_translator)
application_translator, default_translator = LanguageManager.get_translator(language)
if not application_translator.isEmpty():
application.installTranslator(application_translator)
if not default_translator.isEmpty():
app.installTranslator(default_translator)
application.installTranslator(default_translator)
else:
log.debug(u'Could not find default_translator.')
if not options.no_error_form:
sys.excepthook = app.hook_exception
sys.exit(app.run(qt_args))
sys.excepthook = application.hook_exception
sys.exit(application.run(qt_args))

View File

@ -47,9 +47,6 @@ class EventReceiver(QtCore.QObject):
``mainwindow_status_text``
Changes the bottom status bar text on the mainwindow.
``openlp_warning_message``
Displays a standalone Warning Message.
``openlp_error_message``
Displays a standalone Error Message.

View File

@ -541,7 +541,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.openlp_core.set_busy_cursor()
# Simple message boxes
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_error_message'), self.onErrorMessage)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_warning_message'), self.onWarningMessage)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_information_message'),
self.onInformationMessage)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'set_new_data_path'), self.setNewDataPath)
@ -724,21 +723,21 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
"""
Display an error message
"""
Receiver.send_message(u'close_splash')
self.openlp_core.close_splash_screen()
QtGui.QMessageBox.critical(self, data[u'title'], data[u'message'])
def onWarningMessage(self, data):
def warning_message(self, message):
"""
Display a warning message
"""
Receiver.send_message(u'close_splash')
QtGui.QMessageBox.warning(self, data[u'title'], data[u'message'])
self.openlp_core.close_splash_screen()
QtGui.QMessageBox.warning(self, message[u'title'], message[u'message'])
def onInformationMessage(self, data):
"""
Display an informational message
"""
Receiver.send_message(u'close_splash')
self.openlp_core.close_splash_screen()
QtGui.QMessageBox.information(self, data[u'title'], data[u'message'])
def onHelpWebSiteClicked(self):

View File

@ -33,7 +33,7 @@ import re
from PyQt4 import QtCore, QtGui
from openlp.core.lib import Receiver, Settings
from openlp.core.lib import Registry, Settings
from openlp.core.utils import translate
from openlp.core.utils.actions import ActionList
from shortcutlistdialog import Ui_ShortcutListDialog
@ -438,7 +438,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
if changing_action.shortcutContext() in [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]:
is_valid = False
if not is_valid:
Receiver.send_message(u'openlp_warning_message', {
self.main_window.warning_message( {
u'title': translate('OpenLP.ShortcutListDialog', 'Duplicate Shortcut'),
u'message': translate('OpenLP.ShortcutListDialog',
'The shortcut "%s" is already assigned to another action, '
@ -478,3 +478,13 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
button.setChecked(checked)
if enabled is not None:
button.setEnabled(enabled)
def _get_main_window(self):
"""
Adds the main window to the class dynamically
"""
if not hasattr(self, u'_main_window'):
self._main_window = Registry().get(u'main_window')
return self._main_window
main_window = property(_get_main_window)

View File

@ -44,7 +44,6 @@ class SplashScreen(QtGui.QSplashScreen):
"""
QtGui.QSplashScreen.__init__(self)
self.setupUi()
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'close_splash'), self.close)
def setupUi(self):
"""