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