From 68facbf2b50fabe2283b7981cf54e06b92707424 Mon Sep 17 00:00:00 2001 From: Martin Zibricky Date: Thu, 25 Aug 2011 11:04:41 +0200 Subject: [PATCH 1/7] Move class OpenLP from openlp.pyw to openlp.core.__init__ --- openlp.pyw | 146 +-------------------------------- openlp/core/__init__.py | 177 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 178 insertions(+), 145 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 962109592..378b78c37 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -38,6 +38,7 @@ from traceback import format_exception from PyQt4 import QtCore, QtGui +from openlp.core import OpenLP from openlp.core.lib import Receiver, check_directory_exists from openlp.core.lib.ui import UiStrings from openlp.core.resources import qInitResources @@ -51,151 +52,6 @@ from openlp.core.utils import AppLocation, LanguageManager, VersionThread, \ log = logging.getLogger() -application_stylesheet = u""" -QMainWindow::separator -{ - border: none; -} - -QDockWidget::title -{ - border: 1px solid palette(dark); - padding-left: 5px; - padding-top: 2px; - margin: 1px 0; -} - -QToolBar -{ - border: none; - margin: 0; - padding: 0; -} -""" - -class OpenLP(QtGui.QApplication): - """ - The core application class. This class inherits from Qt's QApplication - class in order to provide the core of the application. - """ - - args = [] - - def exec_(self): - """ - Override exec method to allow the shared memory to be released on exit - """ - QtGui.QApplication.exec_() - self.sharedMemory.detach() - - def run(self, args): - """ - Run the OpenLP application. - """ - # On Windows, the args passed into the constructor are - # ignored. Not very handy, so set the ones we want to use. - 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) - # Decide how many screens we have and their size - screens = ScreenList(self.desktop()) - # First time checks in settings - has_run_wizard = QtCore.QSettings().value( - u'general/has run wizard', QtCore.QVariant(False)).toBool() - if not has_run_wizard: - if FirstTimeForm(screens).exec_() == QtGui.QDialog.Accepted: - QtCore.QSettings().setValue(u'general/has run wizard', - QtCore.QVariant(True)) - if os.name == u'nt': - self.setStyleSheet(application_stylesheet) - show_splash = QtCore.QSettings().value( - u'general/show splash', QtCore.QVariant(True)).toBool() - if show_splash: - self.splash = SplashScreen() - self.splash.show() - # make sure Qt really display the splash screen - self.processEvents() - # start the main app window - self.mainWindow = MainWindow(self.clipboard(), self.args) - self.mainWindow.show() - if show_splash: - # now kill the splashscreen - self.splash.finish(self.mainWindow) - log.debug(u'Splashscreen closed') - # make sure Qt really display the splash screen - self.processEvents() - self.mainWindow.repaint() - self.processEvents() - if not has_run_wizard: - self.mainWindow.firstTime() - update_check = QtCore.QSettings().value( - u'general/update check', QtCore.QVariant(True)).toBool() - if update_check: - VersionThread(self.mainWindow).start() - Receiver.send_message(u'maindisplay_blank_check') - self.mainWindow.appStartup() - DelayStartThread(self.mainWindow).start() - return self.exec_() - - def isAlreadyRunning(self): - """ - Look to see if OpenLP is already running and ask if a 2nd copy - is to be started. - """ - 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)) - if status == QtGui.QMessageBox.No: - return True - return False - else: - self.sharedMemory.create(1) - return False - - def hookException(self, exctype, value, traceback): - if not hasattr(self, u'mainWindow'): - log.exception(''.join(format_exception(exctype, value, traceback))) - return - if not hasattr(self, u'exceptionForm'): - self.exceptionForm = ExceptionForm(self.mainWindow) - self.exceptionForm.exceptionTextEdit.setPlainText( - ''.join(format_exception(exctype, value, traceback))) - self.setNormalCursor() - self.exceptionForm.exec_() - - def setBusyCursor(self): - """ - Sets the Busy Cursor for the Application - """ - self.setOverrideCursor(QtCore.Qt.BusyCursor) - self.processEvents() - - def setNormalCursor(self): - """ - Sets the Normal Cursor for the Application - """ - self.restoreOverrideCursor() - - def event(self, event): - """ - Enables direct file opening on OS X - """ - if event.type() == QtCore.QEvent.FileOpen: - file_name = event.file() - log.debug(u'Got open file event for %s!', file_name) - self.args.insert(0, unicode(file_name)) - return True - else: - return QtGui.QApplication.event(self, event) - def main(): """ The main function which parses command line options and then runs diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index e19b9a257..b06fffe79 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -24,9 +24,186 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### + +__all__ = ('OpenLP', 'main') + +import os +import sys +import logging +# Import uuid now, to avoid the rare bug described in the support system: +# http://support.openlp.org/issues/102 +# If https://bugs.gentoo.org/show_bug.cgi?id=317557 is fixed, the import can be +# removed. +import uuid +from optparse import OptionParser +from traceback import format_exception + +from PyQt4 import QtCore, QtGui + +from openlp.core.lib import Receiver, check_directory_exists +from openlp.core.lib.ui import UiStrings +from openlp.core.resources import qInitResources +from openlp.core.ui.mainwindow import MainWindow +from openlp.core.ui.firsttimelanguageform import FirstTimeLanguageForm +from openlp.core.ui.firsttimeform import FirstTimeForm +from openlp.core.ui.exceptionform import ExceptionForm +from openlp.core.ui import SplashScreen, ScreenList +from openlp.core.utils import AppLocation, LanguageManager, VersionThread, \ + get_application_version, DelayStartThread + +log = logging.getLogger() + + """ The :mod:`core` module provides all core application functions All the core functions of the OpenLP application including the GUI, settings, logging and a plugin framework are contained within the openlp.core module. """ + +application_stylesheet = u""" +QMainWindow::separator +{ + border: none; +} + +QDockWidget::title +{ + border: 1px solid palette(dark); + padding-left: 5px; + padding-top: 2px; + margin: 1px 0; +} + +QToolBar +{ + border: none; + margin: 0; + padding: 0; +} +""" + +class OpenLP(QtGui.QApplication): + """ + The core application class. This class inherits from Qt's QApplication + class in order to provide the core of the application. + """ + + args = [] + + def exec_(self): + """ + Override exec method to allow the shared memory to be released on exit + """ + QtGui.QApplication.exec_() + self.sharedMemory.detach() + + def run(self, args): + """ + Run the OpenLP application. + """ + # On Windows, the args passed into the constructor are + # ignored. Not very handy, so set the ones we want to use. + 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) + # Decide how many screens we have and their size + screens = ScreenList(self.desktop()) + # First time checks in settings + has_run_wizard = QtCore.QSettings().value( + u'general/has run wizard', QtCore.QVariant(False)).toBool() + if not has_run_wizard: + if FirstTimeForm(screens).exec_() == QtGui.QDialog.Accepted: + QtCore.QSettings().setValue(u'general/has run wizard', + QtCore.QVariant(True)) + if os.name == u'nt': + self.setStyleSheet(application_stylesheet) + show_splash = QtCore.QSettings().value( + u'general/show splash', QtCore.QVariant(True)).toBool() + if show_splash: + self.splash = SplashScreen() + self.splash.show() + # make sure Qt really display the splash screen + self.processEvents() + # start the main app window + self.mainWindow = MainWindow(self.clipboard(), self.args) + self.mainWindow.show() + if show_splash: + # now kill the splashscreen + self.splash.finish(self.mainWindow) + log.debug(u'Splashscreen closed') + # make sure Qt really display the splash screen + self.processEvents() + self.mainWindow.repaint() + self.processEvents() + if not has_run_wizard: + self.mainWindow.firstTime() + update_check = QtCore.QSettings().value( + u'general/update check', QtCore.QVariant(True)).toBool() + if update_check: + VersionThread(self.mainWindow).start() + Receiver.send_message(u'maindisplay_blank_check') + self.mainWindow.appStartup() + DelayStartThread(self.mainWindow).start() + return self.exec_() + + def isAlreadyRunning(self): + """ + Look to see if OpenLP is already running and ask if a 2nd copy + is to be started. + """ + 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)) + if status == QtGui.QMessageBox.No: + return True + return False + else: + self.sharedMemory.create(1) + return False + + def hookException(self, exctype, value, traceback): + if not hasattr(self, u'mainWindow'): + log.exception(''.join(format_exception(exctype, value, traceback))) + return + if not hasattr(self, u'exceptionForm'): + self.exceptionForm = ExceptionForm(self.mainWindow) + self.exceptionForm.exceptionTextEdit.setPlainText( + ''.join(format_exception(exctype, value, traceback))) + self.setNormalCursor() + self.exceptionForm.exec_() + + def setBusyCursor(self): + """ + Sets the Busy Cursor for the Application + """ + self.setOverrideCursor(QtCore.Qt.BusyCursor) + self.processEvents() + + def setNormalCursor(self): + """ + Sets the Normal Cursor for the Application + """ + self.restoreOverrideCursor() + + def event(self, event): + """ + Enables direct file opening on OS X + """ + if event.type() == QtCore.QEvent.FileOpen: + file_name = event.file() + log.debug(u'Got open file event for %s!', file_name) + self.args.insert(0, unicode(file_name)) + return True + else: + return QtGui.QApplication.event(self, event) + + From 7fae06483a615da3c314e72d84b393ade1e3f011 Mon Sep 17 00:00:00 2001 From: Martin Zibricky Date: Thu, 25 Aug 2011 12:04:17 +0200 Subject: [PATCH 2/7] Move main() from openlp.pyw to openlp.core.__init__ --- openlp.pyw | 99 +---------------------------------------- openlp/core/__init__.py | 83 +++++++++++++++++++++++++++++++--- 2 files changed, 80 insertions(+), 102 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 378b78c37..64ffb3321 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -25,110 +25,15 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -import os -import sys -import logging + # Import uuid now, to avoid the rare bug described in the support system: # http://support.openlp.org/issues/102 # If https://bugs.gentoo.org/show_bug.cgi?id=317557 is fixed, the import can be # removed. import uuid -from optparse import OptionParser -from traceback import format_exception -from PyQt4 import QtCore, QtGui +from openlp.core import main -from openlp.core import OpenLP -from openlp.core.lib import Receiver, check_directory_exists -from openlp.core.lib.ui import UiStrings -from openlp.core.resources import qInitResources -from openlp.core.ui.mainwindow import MainWindow -from openlp.core.ui.firsttimelanguageform import FirstTimeLanguageForm -from openlp.core.ui.firsttimeform import FirstTimeForm -from openlp.core.ui.exceptionform import ExceptionForm -from openlp.core.ui import SplashScreen, ScreenList -from openlp.core.utils import AppLocation, LanguageManager, VersionThread, \ - get_application_version, DelayStartThread - -log = logging.getLogger() - -def main(): - """ - The main function which parses command line options and then runs - the PyQt4 Application. - """ - # 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).') - # Set up logging - log_path = AppLocation.get_directory(AppLocation.CacheDir) - 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')) - log.addHandler(logfile) - logging.addLevelName(15, u'Timer') - # Parse command line options and deal with them. - (options, args) = parser.parse_args() - qt_args = [] - if options.loglevel.lower() in ['d', 'debug']: - log.setLevel(logging.DEBUG) - print 'Logging to:', filename - elif options.loglevel.lower() in ['w', 'warning']: - log.setLevel(logging.WARNING) - else: - log.setLevel(logging.INFO) - if options.style: - qt_args.extend(['-style', options.style]) - # Throw the rest of the arguments at Qt, just in case. - qt_args.extend(args) - # Initialise the resources - qInitResources() - # Now create and actually run the application. - app = OpenLP(qt_args) - # Instance check - if app.isAlreadyRunning(): - sys.exit() - app.setOrganizationName(u'OpenLP') - app.setOrganizationDomain(u'openlp.org') - app.setApplicationName(u'OpenLP') - app.setApplicationVersion(get_application_version()[u'version']) - # First time checks in settings - if not QtCore.QSettings().value(u'general/has run wizard', - QtCore.QVariant(False)).toBool(): - if not FirstTimeLanguageForm().exec_(): - # if cancel then stop processing - sys.exit() - if sys.platform == u'darwin': - OpenLP.addLibraryPath(QtGui.QApplication.applicationDirPath() - + "/qt4_plugins") - # i18n Set Language - language = LanguageManager.get_language() - app_translator, default_translator = \ - LanguageManager.get_translator(language) - if not app_translator.isEmpty(): - app.installTranslator(app_translator) - if not default_translator.isEmpty(): - app.installTranslator(default_translator) - else: - log.debug(u'Could not find default_translator.') - if not options.no_error_form: - sys.excepthook = app.hookException - sys.exit(app.run(qt_args)) if __name__ == u'__main__': """ diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index b06fffe79..d9a671f65 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -30,11 +30,6 @@ __all__ = ('OpenLP', 'main') import os import sys import logging -# Import uuid now, to avoid the rare bug described in the support system: -# http://support.openlp.org/issues/102 -# If https://bugs.gentoo.org/show_bug.cgi?id=317557 is fixed, the import can be -# removed. -import uuid from optparse import OptionParser from traceback import format_exception @@ -83,6 +78,7 @@ QToolBar } """ + class OpenLP(QtGui.QApplication): """ The core application class. This class inherits from Qt's QApplication @@ -102,6 +98,10 @@ class OpenLP(QtGui.QApplication): """ Run the OpenLP application. """ + self.setOrganizationName(u'OpenLP') + self.setOrganizationDomain(u'openlp.org') + self.setApplicationName(u'OpenLP') + self.setApplicationVersion(get_application_version()[u'version']) # On Windows, the args passed into the constructor are # ignored. Not very handy, so set the ones we want to use. self.args.extend(args) @@ -207,3 +207,76 @@ class OpenLP(QtGui.QApplication): return QtGui.QApplication.event(self, event) +def main(): + """ + The main function which parses command line options and then runs + the PyQt4 Application. + """ + # 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).') + # Set up logging + log_path = AppLocation.get_directory(AppLocation.CacheDir) + 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')) + log.addHandler(logfile) + logging.addLevelName(15, u'Timer') + # Parse command line options and deal with them. + (options, args) = parser.parse_args() + qt_args = [] + if options.loglevel.lower() in ['d', 'debug']: + log.setLevel(logging.DEBUG) + print 'Logging to:', filename + elif options.loglevel.lower() in ['w', 'warning']: + log.setLevel(logging.WARNING) + else: + log.setLevel(logging.INFO) + if options.style: + qt_args.extend(['-style', options.style]) + # Throw the rest of the arguments at Qt, just in case. + qt_args.extend(args) + # Initialise the resources + qInitResources() + # Now create and actually run the application. + app = OpenLP(qt_args) + # Instance check + if app.isAlreadyRunning(): + sys.exit() + # First time checks in settings + if not QtCore.QSettings().value(u'general/has run wizard', + QtCore.QVariant(False)).toBool(): + if not FirstTimeLanguageForm().exec_(): + # if cancel then stop processing + sys.exit() + #if sys.platform == u'darwin': + # OpenLP.addLibraryPath(QtGui.QApplication.applicationDirPath() + # + "/qt4_plugins") + # i18n Set Language + language = LanguageManager.get_language() + app_translator, default_translator = \ + LanguageManager.get_translator(language) + if not app_translator.isEmpty(): + app.installTranslator(app_translator) + if not default_translator.isEmpty(): + app.installTranslator(default_translator) + else: + log.debug(u'Could not find default_translator.') + if not options.no_error_form: + sys.excepthook = app.hookException + sys.exit(app.run(qt_args)) From 1dc05c0f662032b8324bac430efd4c8ae8df68e2 Mon Sep 17 00:00:00 2001 From: Martin Zibricky Date: Thu, 25 Aug 2011 13:16:04 +0200 Subject: [PATCH 3/7] Add ability to run openlp without app.exec_() method (needed to run gui tests) --- openlp/core/__init__.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index d9a671f65..8493b7b65 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -94,7 +94,7 @@ class OpenLP(QtGui.QApplication): QtGui.QApplication.exec_() self.sharedMemory.detach() - def run(self, args): + def run(self, args, testing=False): """ Run the OpenLP application. """ @@ -150,7 +150,9 @@ class OpenLP(QtGui.QApplication): Receiver.send_message(u'maindisplay_blank_check') self.mainWindow.appStartup() DelayStartThread(self.mainWindow).start() - return self.exec_() + # Skip exec_() for gui tests + if not testing: + return self.exec_() def isAlreadyRunning(self): """ @@ -207,7 +209,7 @@ class OpenLP(QtGui.QApplication): return QtGui.QApplication.event(self, event) -def main(): +def main(args=None): """ The main function which parses command line options and then runs the PyQt4 Application. @@ -228,6 +230,8 @@ def main(): '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') # Set up logging log_path = AppLocation.get_directory(AppLocation.CacheDir) check_directory_exists(log_path) @@ -238,7 +242,9 @@ def main(): log.addHandler(logfile) logging.addLevelName(15, u'Timer') # Parse command line options and deal with them. - (options, args) = parser.parse_args() + if not args: + args = sys.argv # Use args not supplied programatically + (options, args) = parser.parse_args(args) qt_args = [] if options.loglevel.lower() in ['d', 'debug']: log.setLevel(logging.DEBUG) @@ -279,4 +285,8 @@ def main(): log.debug(u'Could not find default_translator.') if not options.no_error_form: sys.excepthook = app.hookException - sys.exit(app.run(qt_args)) + # Do not run method app.exec_() when running gui tests + if options.testing: + app.run(qt_args, testing=True) + else: + sys.exit(app.run(qt_args)) From 20c431a6e503b891e4bf81962c59611c63c48b76 Mon Sep 17 00:00:00 2001 From: Martin Zibricky Date: Thu, 25 Aug 2011 17:33:21 +0200 Subject: [PATCH 4/7] - Remove darwin specific dead code - Move app.setOrganization and app.setApplication to orgininal place --- openlp/core/__init__.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 8493b7b65..e1d85fd8f 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -98,10 +98,6 @@ class OpenLP(QtGui.QApplication): """ Run the OpenLP application. """ - self.setOrganizationName(u'OpenLP') - self.setOrganizationDomain(u'openlp.org') - self.setApplicationName(u'OpenLP') - self.setApplicationVersion(get_application_version()[u'version']) # On Windows, the args passed into the constructor are # ignored. Not very handy, so set the ones we want to use. self.args.extend(args) @@ -261,6 +257,10 @@ def main(args=None): qInitResources() # Now create and actually run the application. app = OpenLP(qt_args) + app.setOrganizationName(u'OpenLP') + app.setOrganizationDomain(u'openlp.org') + app.setApplicationName(u'OpenLP') + app.setApplicationVersion(get_application_version()[u'version']) # Instance check if app.isAlreadyRunning(): sys.exit() @@ -270,9 +270,6 @@ def main(args=None): if not FirstTimeLanguageForm().exec_(): # if cancel then stop processing sys.exit() - #if sys.platform == u'darwin': - # OpenLP.addLibraryPath(QtGui.QApplication.applicationDirPath() - # + "/qt4_plugins") # i18n Set Language language = LanguageManager.get_language() app_translator, default_translator = \ From eef0af11ac0ab4d59cf2729e1b056bca33e1772a Mon Sep 17 00:00:00 2001 From: Martin Zibricky Date: Fri, 26 Aug 2011 13:04:56 +0200 Subject: [PATCH 5/7] Fix error msg with corrupted file --- openlp/core/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index e1d85fd8f..896066e73 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -238,9 +238,8 @@ def main(args=None): log.addHandler(logfile) logging.addLevelName(15, u'Timer') # Parse command line options and deal with them. - if not args: - args = sys.argv # Use args not supplied programatically - (options, args) = parser.parse_args(args) + # Use args supplied programatically if possible. + (options, args) = parser.parse_args(args) if args else parser.parse_args() qt_args = [] if options.loglevel.lower() in ['d', 'debug']: log.setLevel(logging.DEBUG) From ccd0a46e2b337c51adcf63ae187b39ade2b86129 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 29 Aug 2011 22:56:07 +0200 Subject: [PATCH 6/7] do not expand the tags --- openlp/core/lib/renderer.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 8c63facb8..e0a07a556 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -259,8 +259,7 @@ class Renderer(object): else: html_text = text text = u'' - lines = expand_tags(html_text) - lines = lines.strip(u'\n').split(u'\n') + lines = html_text.strip(u'\n').split(u'\n') slides = self._paginate_slide(lines, line_end) if len(slides) > 1 and text: # Add all slides apart from the last one the @@ -274,8 +273,7 @@ class Renderer(object): else: pages.extend(slides) if u'[---]' not in text: - lines = expand_tags(text) - lines = lines.strip(u'\n').split(u'\n') + lines = text.strip(u'\n').split(u'\n') pages.extend(self._paginate_slide(lines, line_end)) break new_pages = [] From 6c7527349d4fe5a3b3e388a2325a7074b3bde37f Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 29 Aug 2011 22:58:32 +0200 Subject: [PATCH 7/7] do not use the same name twice --- openlp/core/lib/renderer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index e0a07a556..3fff5cbe0 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -255,11 +255,11 @@ class Renderer(object): # we have to render the first virtual slide. text_contains_break = u'[---]' in text if text_contains_break: - html_text, text = text.split(u'\n[---]\n', 1) + text_to_render, text = text.split(u'\n[---]\n', 1) else: - html_text = text + text_to_render = text text = u'' - lines = html_text.strip(u'\n').split(u'\n') + lines = text_to_render.strip(u'\n').split(u'\n') slides = self._paginate_slide(lines, line_end) if len(slides) > 1 and text: # Add all slides apart from the last one the