From c487d7f33d95ef0c8e2373d97de0eaa1a56cd7de Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 2 Jan 2011 13:57:55 +0000 Subject: [PATCH] Fix the service saving Fixes: https://launchpad.net/bugs/696313 --- openlp/core/ui/mainwindow.py | 1 - openlp/core/ui/servicemanager.py | 22 +++++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 16dbfb2c4..8c6117955 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -701,7 +701,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if QtCore.QSettings().value( self.generalSettingsSection + u'/auto open', QtCore.QVariant(False)).toBool(): - #self.ServiceManagerContents.onLoadService(True) self.ServiceManagerContents.loadLastFile() view_mode = QtCore.QSettings().value(u'%s/view mode' % \ self.generalSettingsSection, u'default') diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index e58e9eaef..8f4e17a0c 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -109,12 +109,12 @@ class ServiceManager(QtGui.QWidget): self.suffixes = [] self.dropPosition = 0 self.expandTabs = False - #is a new service and has not been saved + # is a new service and has not been saved self._modified = False self._fileName = u'' self.serviceNoteForm = ServiceNoteForm(self.parent) self.serviceItemEditForm = ServiceItemEditForm(self.parent) - #start with the layout + # start with the layout self.layout = QtGui.QVBoxLayout(self) self.layout.setSpacing(0) self.layout.setMargin(0) @@ -305,6 +305,8 @@ class ServiceManager(QtGui.QWidget): """ self._fileName = unicode(fileName) self.parent.setServiceModified(self.isModified, self.shortFileName()) + QtCore.QSettings(). \ + setValue(u'service/last file',QtCore.QVariant(fileName)) def fileName(self): """ @@ -390,6 +392,8 @@ class ServiceManager(QtGui.QWidget): self.serviceItems = [] self.setFileName(u'') self.setModified(False) + QtCore.QSettings(). \ + setValue(u'service/last file',QtCore.QVariant(u'')) def saveFile(self): """ @@ -530,13 +534,21 @@ class ServiceManager(QtGui.QWidget): self.setFileName(fileName) self.parent.addRecentFile(fileName) self.setModified(False) + QtCore.QSettings(). \ + setValue(u'service/last file',QtCore.QVariant(fileName)) # Refresh Plugin lists Receiver.send_message(u'plugin_list_refresh') def loadLastFile(self): - if not self.parent.recentFiles: - return - self.loadFile(self.parent.recentFiles[0]) + """ + Load the last service item from the service manager when the + service was last closed. Can be blank if there was no service + present. + """ + fileName = QtCore.QSettings(). \ + value(u'service/last file',QtCore.QVariant(u'')).toString() + if fileName: + self.loadFile(fileName) def contextMenu(self, point): item = self.serviceManagerList.itemAt(point)