fixed application version

This commit is contained in:
Andreas Preikschat 2011-03-25 17:29:39 +01:00
parent 4c81c55918
commit 24b58ff518
4 changed files with 20 additions and 29 deletions

View File

@ -71,7 +71,6 @@ 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.
"""
app_version = None
def run(self):
"""
@ -103,8 +102,7 @@ class OpenLP(QtGui.QApplication):
# make sure Qt really display the splash screen
self.processEvents()
# start the main app window
self.mainWindow = MainWindow(screens, self.app_version,
self.clipboard())
self.mainWindow = MainWindow(screens, self.clipboard())
self.mainWindow.show()
if show_splash:
# now kill the splashscreen
@ -116,7 +114,7 @@ class OpenLP(QtGui.QApplication):
update_check = QtCore.QSettings().value(
u'general/update check', QtCore.QVariant(True)).toBool()
if update_check:
VersionThread(self.mainWindow, self.app_version).start()
VersionThread(self.mainWindow).start()
return self.exec_()
def hookException(self, exctype, value, traceback):
@ -194,7 +192,7 @@ def main():
app.setOrganizationName(u'OpenLP')
app.setOrganizationDomain(u'openlp.org')
app.setApplicationName(u'OpenLP')
app.setApplicationVersion(app.get_version()[u'version'])
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():

View File

@ -28,25 +28,26 @@ from PyQt4 import QtCore, QtGui
from aboutdialog import Ui_AboutDialog
from openlp.core.lib import translate
from openlp.core.utils import get_application_version
class AboutForm(QtGui.QDialog, Ui_AboutDialog):
"""
The About dialog
"""
def __init__(self, parent, applicationVersion):
def __init__(self, parent):
"""
Do some initialisation stuff
"""
QtGui.QDialog.__init__(self, parent)
self.applicationVersion = applicationVersion
applicationVersion = get_application_version()
self.setupUi(self)
about_text = self.aboutTextEdit.toPlainText()
about_text = about_text.replace(u'<version>',
self.applicationVersion[u'version'])
if self.applicationVersion[u'build']:
applicationVersion[u'version'])
if applicationVersion[u'build']:
build_text = unicode(translate('OpenLP.AboutForm', ' build %s')) % \
self.applicationVersion[u'build']
applicationVersion[u'build']
else:
build_text = u''
about_text = about_text.replace(u'<revision>', build_text)

View File

@ -38,7 +38,7 @@ from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \
ThemeManager, SlideController, PluginForm, MediaDockManager, \
ShortcutListForm, DisplayTagForm
from openlp.core.utils import AppLocation, add_actions, LanguageManager, \
ActionList
ActionList, get_application_version
log = logging.getLogger(__name__)
@ -469,14 +469,13 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
actionList = ActionList()
def __init__(self, screens, applicationVersion, clipboard):
def __init__(self, screens, clipboard):
"""
This constructor sets up the interface, the various managers, and the
plugins.
"""
QtGui.QMainWindow.__init__(self)
self.screens = screens
self.applicationVersion = applicationVersion
self.clipboard = clipboard
# Set up settings sections for the main application
# (not for use by plugins)
@ -487,7 +486,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.serviceNotSaved = False
self.actionList = ActionList()
self.settingsmanager = SettingsManager(screens)
self.aboutForm = AboutForm(self, applicationVersion)
self.aboutForm = AboutForm(self)
self.settingsForm = SettingsForm(self.screens, self, self)
self.displayTagForm = DisplayTagForm(self)
self.shortcutForm = ShortcutListForm(self)
@ -651,7 +650,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
'version from http://openlp.org/.'))
QtGui.QMessageBox.question(self,
translate('OpenLP.MainWindow', 'OpenLP Version Updated'),
version_text % (version, self.applicationVersion[u'full']))
version_text % (version, get_application_version()[u'full']))
def show(self):
"""
@ -734,7 +733,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
"""
Show the About form
"""
self.aboutForm.applicationVersion = self.applicationVersion
self.aboutForm.exec_()
def onPluginItemClicked(self):

View File

@ -48,19 +48,18 @@ import openlp
from openlp.core.lib import Receiver, translate, check_directory_exists
log = logging.getLogger(__name__)
APPLICATION_VERSION = {}
IMAGES_FILTER = None
UNO_CONNECTION_TYPE = u'pipe'
#UNO_CONNECTION_TYPE = u'socket'
APPLICATION_VERSION = u''
class VersionThread(QtCore.QThread):
"""
A special Qt thread class to fetch the version of OpenLP from the website.
This is threaded so that it doesn't affect the loading time of OpenLP.
"""
def __init__(self, parent, app_version):
def __init__(self, parent):
QtCore.QThread.__init__(self, parent)
self.app_version = app_version
self.version_splitter = re.compile(
r'([0-9]+).([0-9]+).([0-9]+)(?:-bzr([0-9]+))?')
@ -70,7 +69,8 @@ class VersionThread(QtCore.QThread):
"""
time.sleep(1)
Receiver.send_message(u'maindisplay_blank_check')
version = check_latest_version(self.app_version)
app_version = get_application_version()
version = check_latest_version(app_version)
remote_version = {}
local_version = {}
match = self.version_splitter.match(version)
@ -82,7 +82,7 @@ class VersionThread(QtCore.QThread):
remote_version[u'revision'] = int(match.group(4))
else:
return
match = self.version_splitter.match(self.app_version[u'full'])
match = self.version_splitter.match(app_version[u'full'])
if match:
local_version[u'major'] = int(match.group(1))
local_version[u'minor'] = int(match.group(2))
@ -208,22 +208,16 @@ def _get_frozen_path(frozen_option, non_frozen_option):
return frozen_option
return non_frozen_option
def get_application_version(dev_version=False):
def get_application_version():
"""
Returns the application version of the running instance of OpenLP::
{u'full': u'1.9.4-bzr1249', u'version': u'1.9.4', u'build': u'bzr1249'}
``dev_version``
If ``True``, then it is assumed, that we are running a dev version and
attempt to receive the version number using bzr. **Note**, that this
argument is only important the first time the function is called.
"""
global APPLICATION_VERSION
if APPLICATION_VERSION:
# We already know the version, so just return it.
return APPLICATION_VERSION
if dev_version:
if u'--dev-version' in sys.argv or u'-d' in sys.argv:
# If we're running the dev version, let's use bzr to get the version.
try:
# If bzrlib is available, use it.