Move class to 120 line width

bzr-revno: 2123
This commit is contained in:
Tim Bentley 2012-12-05 19:01:25 +00:00
commit ec314273b2

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -113,33 +113,24 @@ class OpenLP(QtGui.QApplication):
args.remove('OpenLP')
self.args.extend(args)
# provide a listener for widgets to reqest a screen update.
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'openlp_process_events'), self.processEvents)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'cursor_busy'), self.setBusyCursor)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'cursor_normal'), self.setNormalCursor)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_process_events'), self.processEvents)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cursor_busy'), self.setBusyCursor)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cursor_normal'), self.setNormalCursor)
# Decide how many screens we have and their size
screens = ScreenList.create(self.desktop())
# First time checks in settings
has_run_wizard = Settings().value(
u'general/has run wizard', QtCore.QVariant(False)).toBool()
has_run_wizard = Settings().value(u'general/has run wizard', QtCore.QVariant(False)).toBool()
if not has_run_wizard:
if FirstTimeForm(screens).exec_() == QtGui.QDialog.Accepted:
Settings().setValue(u'general/has run wizard',
QtCore.QVariant(True))
Settings().setValue(u'general/has run wizard', QtCore.QVariant(True))
# Correct stylesheet bugs
if os.name == u'nt':
base_color = self.palette().color(QtGui.QPalette.Active,
QtGui.QPalette.Base)
application_stylesheet = \
u'* {alternate-background-color: ' + \
base_color.name() + ';}\n'
base_color = self.palette().color(QtGui.QPalette.Active, QtGui.QPalette.Base)
application_stylesheet = u'* {alternate-background-color: ' + base_color.name() + ';}\n'
application_stylesheet += nt_repair_stylesheet
self.setStyleSheet(application_stylesheet)
# show the splashscreen
show_splash = Settings().value(
u'general/show splash', QtCore.QVariant(True)).toBool()
show_splash = Settings().value(u'general/show splash', QtCore.QVariant(True)).toBool()
if show_splash:
self.splash = SplashScreen()
self.splash.show()
@ -158,8 +149,7 @@ class OpenLP(QtGui.QApplication):
self.processEvents()
if not has_run_wizard:
self.mainWindow.firstTime()
update_check = Settings().value(
u'general/update check', QtCore.QVariant(True)).toBool()
update_check = Settings().value(u'general/update check', QtCore.QVariant(True)).toBool()
if update_check:
VersionThread(self.mainWindow).start()
Receiver.send_message(u'live_display_blank_check')
@ -175,10 +165,8 @@ class OpenLP(QtGui.QApplication):
"""
self.sharedMemory = QtCore.QSharedMemory('OpenLP')
if self.sharedMemory.attach():
status = QtGui.QMessageBox.critical(None,
UiStrings().Error, UiStrings().OpenLPStart,
QtGui.QMessageBox.StandardButtons(
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No))
status = QtGui.QMessageBox.critical(None, UiStrings().Error, UiStrings().OpenLPStart,
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No))
if status == QtGui.QMessageBox.No:
return True
return False
@ -192,8 +180,7 @@ class OpenLP(QtGui.QApplication):
return
if not hasattr(self, u'exceptionForm'):
self.exceptionForm = ExceptionForm(self.mainWindow)
self.exceptionForm.exceptionTextEdit.setPlainText(
''.join(format_exception(exctype, value, traceback)))
self.exceptionForm.exceptionTextEdit.setPlainText(''.join(format_exception(exctype, value, traceback)))
self.setNormalCursor()
self.exceptionForm.exec_()
@ -230,8 +217,7 @@ def set_up_logging(log_path):
check_directory_exists(log_path)
filename = os.path.join(log_path, u'openlp.log')
logfile = logging.FileHandler(filename, u'w')
logfile.setFormatter(logging.Formatter(
u'%(asctime)s %(name)-55s %(levelname)-8s %(message)s'))
logfile.setFormatter(logging.Formatter(u'%(asctime)s %(name)-55s %(levelname)-8s %(message)s'))
log.addHandler(logfile)
if log.isEnabledFor(logging.DEBUG):
print 'Logging to:', filename
@ -245,28 +231,22 @@ def main(args=None):
# Set up command line options.
usage = 'Usage: %prog [options] [qt-options]'
parser = OptionParser(usage=usage)
parser.add_option('-e', '--no-error-form', dest='no_error_form',
action='store_true', help='Disable the error notification form.')
parser.add_option('-l', '--log-level', dest='loglevel',
default='warning', metavar='LEVEL', help='Set logging to LEVEL '
'level. Valid values are "debug", "info", "warning".')
parser.add_option('-p', '--portable', dest='portable',
action='store_true', help='Specify if this should be run as a '
'portable app, off a USB flash drive (not implemented).')
parser.add_option('-d', '--dev-version', dest='dev_version',
action='store_true', help='Ignore the version file and pull the '
'version directly from Bazaar')
parser.add_option('-s', '--style', dest='style',
help='Set the Qt4 style (passed directly to Qt4).')
parser.add_option('--testing', dest='testing',
action='store_true', help='Run by testing framework')
parser.add_option('-e', '--no-error-form', dest='no_error_form', action='store_true',
help='Disable the error notification form.')
parser.add_option('-l', '--log-level', dest='loglevel', default='warning', metavar='LEVEL',
help='Set logging to LEVEL level. Valid values are "debug", "info", "warning".')
parser.add_option('-p', '--portable', dest='portable', action='store_true',
help='Specify if this should be run as a portable app, off a USB flash drive (not implemented).')
parser.add_option('-d', '--dev-version', dest='dev_version', action='store_true',
help='Ignore the version file and pull the version directly from Bazaar')
parser.add_option('-s', '--style', dest='style', help='Set the Qt4 style (passed directly to Qt4).')
parser.add_option('--testing', dest='testing', action='store_true', help='Run by testing framework')
# Parse command line options and deal with them.
# Use args supplied programatically if possible.
(options, args) = parser.parse_args(args) if args else parser.parse_args()
if options.portable:
app_path = AppLocation.get_directory(AppLocation.AppDir)
set_up_logging(os.path.abspath(os.path.join(app_path, u'..',
u'..', u'Other')))
set_up_logging(os.path.abspath(os.path.join(app_path, u'..', u'..', u'Other')))
log.info(u'Running portable')
else:
set_up_logging(AppLocation.get_directory(AppLocation.CacheDir))
@ -294,8 +274,7 @@ def main(args=None):
app.setApplicationName(u'OpenLPPortable')
Settings.setDefaultFormat(Settings.IniFormat)
# Get location OpenLPPortable.ini
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(app_path, u'..', u'..', u'Data', u'OpenLP.ini'))
# Make this our settings file
log.info(u'INI file: %s', portable_settings_file)
Settings.setFilename(portable_settings_file)
@ -324,8 +303,7 @@ def main(args=None):
sys.exit()
# i18n Set Language
language = LanguageManager.get_language()
app_translator, default_translator = \
LanguageManager.get_translator(language)
app_translator, default_translator = LanguageManager.get_translator(language)
if not app_translator.isEmpty():
app.installTranslator(app_translator)
if not default_translator.isEmpty():
@ -337,7 +315,7 @@ def main(args=None):
# Do not run method app.exec_() when running gui tests
if options.testing:
app.run(qt_args, testing=True)
# For gui tests we need access to window intances and their components
# For gui tests we need access to window instances and their components
return app
else:
sys.exit(app.run(qt_args))