This commit is contained in:
Samuel Findlay 2012-06-01 17:32:58 +10:00
commit 78c4906b55
6 changed files with 21 additions and 12 deletions

View File

@ -91,6 +91,7 @@ class OpenLP(QtGui.QApplication):
"""
Override exec method to allow the shared memory to be released on exit
"""
self.eventLoopIsActive = True
QtGui.QApplication.exec_()
self.sharedMemory.detach()
@ -98,6 +99,7 @@ class OpenLP(QtGui.QApplication):
"""
Run the OpenLP application.
"""
self.eventLoopIsActive = False
# 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)
@ -127,7 +129,7 @@ class OpenLP(QtGui.QApplication):
# make sure Qt really display the splash screen
self.processEvents()
# start the main app window
self.mainWindow = MainWindow(self.clipboard(), self.args)
self.mainWindow = MainWindow(self)
self.mainWindow.show()
if show_splash:
# now kill the splashscreen

View File

@ -542,14 +542,15 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
"""
log.info(u'MainWindow loaded')
def __init__(self, clipboard, arguments):
def __init__(self, application):
"""
This constructor sets up the interface, the various managers, and the
plugins.
"""
QtGui.QMainWindow.__init__(self)
self.clipboard = clipboard
self.arguments = arguments
self.application = application
self.clipboard = self.application.clipboard()
self.arguments = self.application.args
# Set up settings sections for the main application
# (not for use by plugins)
self.uiSettingsSection = u'user interface'
@ -830,7 +831,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
translate('OpenLP.MainWindow',
'OpenLP Main Display Blanked'),
translate('OpenLP.MainWindow',
'The Main Display has been blanked out'))
'The Main Display has been blanked out'))
def onErrorMessage(self, data):
Receiver.send_message(u'close_splash')
@ -1132,6 +1133,11 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
"""
Hook to close the main window and display windows on exit
"""
# The MainApplication did not even enter the event loop (this happens
# when OpenLP is not fully loaded). Just ignore the event.
if not self.application.eventLoopIsActive:
event.ignore()
return
# If we just did a settings import, close without saving changes.
if self.settingsImported:
event.accept()
@ -1184,7 +1190,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
# Save settings
self.saveSettings()
# Close down the display
self.liveController.display.close()
if self.liveController.display:
self.liveController.display.close()
self.liveController.display = None
def serviceChanged(self, reset=False, serviceName=None):
"""

View File

@ -73,6 +73,7 @@ class Controller(QtGui.QWidget):
controller = self
Receiver.send_message('%s' % sender, [controller, args])
class SlideController(Controller):
"""
SlideController is the slide controller widget. This widget is what the
@ -577,8 +578,7 @@ class SlideController(Controller):
# rebuild display as screen size changed
if self.display:
self.display.close()
self.display = MainDisplay(self, self.imageManager, self.isLive,
self)
self.display = MainDisplay(self, self.imageManager, self.isLive, self)
self.display.setup()
if self.isLive:
self.__addActionsToWidget(self.display)

View File

@ -108,7 +108,7 @@ class OpenLPWizard(QtGui.QWizard):
def setupUi(self, image):
"""
Set up the wizard UI
Set up the wizard UI.
"""
self.setModal(True)
self.setWizardStyle(QtGui.QWizard.ModernStyle)

View File

@ -34,7 +34,6 @@ import os
import re
from subprocess import Popen, PIPE
import sys
import time
import urllib2
from PyQt4 import QtGui, QtCore
@ -69,7 +68,7 @@ class VersionThread(QtCore.QThread):
"""
Run the thread.
"""
time.sleep(1)
self.sleep(1)
app_version = get_application_version()
version = check_latest_version(app_version)
if LooseVersion(str(version)) > LooseVersion(str(app_version[u'full'])):

View File

@ -370,7 +370,7 @@ class SongImportForm(OpenLPWizard):
def customPageChanged(self, pageId):
"""
Called when changing to a page other than the progress page
Called when changing to a page other than the progress page.
"""
if self.page(pageId) == self.sourcePage:
self.onCurrentIndexChanged(self.formatStack.currentIndex())