From 9dae67ac0aeb3ba809dfe405fb0aff62b51e3ab0 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 1 Nov 2009 09:07:10 +0000 Subject: [PATCH] Clean up version notifications and checking --- openlp.pyw | 17 ++++++++++++++--- openlp/core/ui/about.py | 13 +++++++++++-- openlp/core/ui/mainwindow.py | 12 ++++++------ openlp/plugins/songs/lib/mediaitem.py | 1 - version.txt | 1 + 5 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 version.txt diff --git a/openlp.pyw b/openlp.pyw index 4c0eb9b14..aaf1867e4 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -71,7 +71,18 @@ class OpenLP(QtGui.QApplication): """ Run the OpenLP application. """ - applicationVersion = u'1.9.0' + #Load and store current Application Version + filepath = os.path.split(os.path.abspath(__file__))[0] + filepath = os.path.abspath(os.path.join(filepath, u'version.txt')) + try: + fversion = open(filepath, 'r') + for line in fversion: + bits = unicode(line).split(u'-') + applicationVersion = {u'Full':unicode(line).rstrip(), + u'version':bits[0], u'build':bits[1]} + except: + applicationVersion = {u'Full':u'1.9.0-000', + u'version':u'1.9.0', u'build':u'000'} #set the default string encoding try: sys.setappdefaultencoding(u'utf-8') @@ -81,7 +92,7 @@ class OpenLP(QtGui.QApplication): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'process_events'), self.processEvents) self.setApplicationName(u'OpenLP') - self.setApplicationVersion(applicationVersion) + self.setApplicationVersion(applicationVersion[u'version']) if os.name == u'nt': self.setStyleSheet(application_stylesheet) show_splash = str_to_bool(ConfigHelper.get_registry().get_value( @@ -100,7 +111,7 @@ class OpenLP(QtGui.QApplication): log.info(u'Screen %d found with resolution %s', screen, self.desktop().availableGeometry(screen)) # start the main app window - self.mainWindow = MainWindow(screens) + self.mainWindow = MainWindow(screens, applicationVersion) self.mainWindow.show() if show_splash: # now kill the splashscreen diff --git a/openlp/core/ui/about.py b/openlp/core/ui/about.py index c1c9006c2..3cc487bea 100644 --- a/openlp/core/ui/about.py +++ b/openlp/core/ui/about.py @@ -31,11 +31,12 @@ class AboutForm(QtGui.QDialog): The About dialog """ - def __init__(self, parent=None): + def __init__(self, parent, applicationVersion): """ Do some initialisation stuff """ QtGui.QDialog.__init__(self, parent) + self.applicationVersion = applicationVersion self.setupUi(self) def setupUi(self, AboutForm): @@ -94,6 +95,12 @@ class AboutForm(QtGui.QDialog): self.License3Label.setWordWrap(True) self.License3Label.setObjectName(u'License3Label') self.LicenseTabLayout.addWidget(self.License3Label) + self.License4Label = QtGui.QLabel(self.LicenseTab) + self.License4Label.setAlignment( + QtCore.Qt.AlignJustify | QtCore.Qt.AlignVCenter) + self.License4Label.setWordWrap(True) + self.License4Label.setObjectName(u'License4Label') + self.LicenseTabLayout.addWidget(self.License4Label) self.LicenseSpacer = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.LicenseTabLayout.addItem(self.LicenseSpacer) @@ -163,6 +170,9 @@ class AboutForm(QtGui.QDialog): u'but WITHOUT ANY WARRANTY; without even the implied warranty of ' u'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ' u'General Public License for more details.')) + self.License4Label.setText(unicode(self.trUtf8( + u'Software version %s, Build %s')) % + (self.applicationVersion[u'version'], self.applicationVersion[u'build'])) self.AboutNotebook.setTabText( self.AboutNotebook.indexOf(self.LicenseTab), self.trUtf8(u'License')) self.CreditsTextEdit.setPlainText(self.trUtf8( @@ -190,4 +200,3 @@ class AboutForm(QtGui.QDialog): import webbrowser url = "http://www.openlp.org/en/documentation/introduction/contributing.html" webbrowser.open_new(url) - diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 51789e225..a2c6c6070 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -408,19 +408,20 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): log = logging.getLogger(u'MainWindow') log.info(u'MainWindow loaded') - def __init__(self, screens): + def __init__(self, screens, applicationVersion): """ This constructor sets up the interface, the various managers, and the plugins. """ QtGui.QMainWindow.__init__(self) self.screenList = screens + self.applicationVersion = applicationVersion self.serviceNotSaved = False self.settingsmanager = SettingsManager(screens) self.generalConfig = PluginConfig(u'General') self.mainDisplay = MainDisplay(self, screens) self.alertForm = AlertForm(self) - self.aboutForm = AboutForm(self) + self.aboutForm = AboutForm(self, applicationVersion) self.settingsForm = SettingsForm(self.screenList, self, self) # Set up the path with plugins pluginpath = os.path.split(os.path.abspath(__file__))[0] @@ -525,18 +526,16 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.settingsForm.postSetUp() def versionCheck(self): - applicationVersion = self.generalConfig.get_config(u'Application version', u'1.9.0-640') + applicationVersion = self.applicationVersion[u'Full'] version = check_latest_version(self.generalConfig, applicationVersion) if applicationVersion != version: version_text = unicode(self.trUtf8(u'OpenLP version %s has been updated ' - u'to version %s\nWould you like to get it?')) + u'to version %s\n\nYou can obtain the latest version from http://openlp.org')) QtGui.QMessageBox.question(None, self.trUtf8(u'OpenLP Version Updated'), version_text % (applicationVersion, version), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok), QtGui.QMessageBox.Ok) - self.generalConfig.set_config(u'Application version', version) - def getMonitorNumber(self): """ @@ -577,6 +576,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ Show the About form """ + self.aboutForm.applicationVersion = self.applicationVersion self.aboutForm.exec_() def onToolsAlertItemClicked(self): diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 506e0f3f8..08005b326 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -289,7 +289,6 @@ class SongMediaItem(MediaManagerItem): song = self.parent.songmanager.get_song(item_id) service_item.theme = song.theme_name service_item.editEnabled = True - service_item.fromPlugin = True service_item.editId = item_id service_item.verse_order = song.verse_order if song.lyrics.startswith(u'