forked from openlp/openlp
Add saving check to exit so OOS can be saved
This commit is contained in:
parent
209f92439c
commit
a06b8f0b07
@ -41,6 +41,7 @@ class MainWindow(object):
|
||||
This constructor sets up the interface, the various managers, and the
|
||||
plugins.
|
||||
"""
|
||||
self.oosNotSaved = False
|
||||
self.mainWindow = QtGui.QMainWindow()
|
||||
self.mainWindow.__class__.closeEvent = self.onCloseEvent
|
||||
self.mainDisplay = MainDisplay(None, screens)
|
||||
@ -127,8 +128,46 @@ class MainWindow(object):
|
||||
"""
|
||||
Hook to close the main window and display windows on exit
|
||||
"""
|
||||
self.mainDisplay.close()
|
||||
event.accept()
|
||||
if self.oosNotSaved == True:
|
||||
box = QtGui.QMessageBox()
|
||||
box.setWindowTitle(translate(u'mainWindow', u'Question?'))
|
||||
box.setText(translate(u'mainWindow', u'Save changes to Order of Service?'))
|
||||
box.setIcon(QtGui.QMessageBox.Question)
|
||||
box.setStandardButtons(QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | QtGui.QMessageBox.Cancel);
|
||||
box.setDefaultButton(QtGui.QMessageBox.Save);
|
||||
ret = box.exec_()
|
||||
if ret == QtGui.QMessageBox.Save:
|
||||
self.ServiceManagerContents.onSaveService()
|
||||
self.mainDisplay.close()
|
||||
event.accept()
|
||||
elif ret == QtGui.QMessageBox.Discard:
|
||||
self.mainDisplay.close()
|
||||
event.accept()
|
||||
else:
|
||||
event.ignore()
|
||||
else:
|
||||
self.mainDisplay.close()
|
||||
event.accept()
|
||||
|
||||
def OosChanged(self, reset = False, oosName = None):
|
||||
"""
|
||||
Hook to change the title if the OOS has been changed
|
||||
reset - tells if the OOS has been cleared or saved
|
||||
oosName - is the name of the OOS (if it has one)
|
||||
"""
|
||||
if reset == True:
|
||||
self.oosNotSaved = False
|
||||
if oosName is None:
|
||||
title = self.mainTitle
|
||||
else:
|
||||
title = self.mainTitle + u' - (' + oosName + u')'
|
||||
else:
|
||||
self.oosNotSaved = True
|
||||
if oosName is None:
|
||||
title = self.mainTitle + u' - *'
|
||||
else:
|
||||
title = self.mainTitle + u' - *(' + oosName + u')'
|
||||
self.mainWindow.setWindowTitle(title)
|
||||
|
||||
def setupUi(self):
|
||||
"""
|
||||
@ -409,7 +448,8 @@ class MainWindow(object):
|
||||
"""
|
||||
Set up the translation system
|
||||
"""
|
||||
self.mainWindow.setWindowTitle(translate(u'mainWindow', u'OpenLP 2.0'))
|
||||
self.mainTitle = translate(u'mainWindow', u'OpenLP 2.0')
|
||||
self.mainWindow.setWindowTitle(self.mainTitle)
|
||||
self.FileMenu.setTitle(translate(u'mainWindow', u'&File'))
|
||||
self.FileImportMenu.setTitle(translate(u'mainWindow', u'&Import'))
|
||||
self.FileExportMenu.setTitle(translate(u'mainWindow', u'&Export'))
|
||||
|
@ -63,6 +63,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
QtGui.QWidget.__init__(self)
|
||||
self.parent = parent
|
||||
self.serviceItems = []
|
||||
self.serviceName = u''
|
||||
self.Layout = QtGui.QVBoxLayout(self)
|
||||
self.Layout.setSpacing(0)
|
||||
self.Layout.setMargin(0)
|
||||
@ -151,6 +152,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
self.serviceItems.remove(self.serviceItems[item])
|
||||
self.serviceItems.insert(0, temp)
|
||||
self.repaintServiceList()
|
||||
self.parent.OosChanged(False, self.serviceName)
|
||||
|
||||
def onServiceUp(self):
|
||||
"""
|
||||
@ -163,6 +165,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
self.serviceItems.remove(self.serviceItems[item])
|
||||
self.serviceItems.insert(item - 1, temp)
|
||||
self.repaintServiceList()
|
||||
self.parent.OosChanged(False, self.serviceName)
|
||||
|
||||
def onServiceDown(self):
|
||||
"""
|
||||
@ -175,6 +178,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
self.serviceItems.remove(self.serviceItems[item])
|
||||
self.serviceItems.insert(item + 1, temp)
|
||||
self.repaintServiceList()
|
||||
self.parent.OosChanged(False, self.serviceName)
|
||||
|
||||
def onServiceEnd(self):
|
||||
"""
|
||||
@ -186,6 +190,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
self.serviceItems.remove(self.serviceItems[item])
|
||||
self.serviceItems.insert(len(self.serviceItems), temp)
|
||||
self.repaintServiceList()
|
||||
self.parent.OosChanged(False, self.serviceName)
|
||||
|
||||
def onNewService(self):
|
||||
"""
|
||||
@ -193,6 +198,8 @@ class ServiceManager(QtGui.QWidget):
|
||||
"""
|
||||
self.ServiceManagerList.clear()
|
||||
self.serviceItems = []
|
||||
self.serviceName = u''
|
||||
self.parent.OosChanged(True, self.serviceName)
|
||||
|
||||
def onDeleteFromService(self):
|
||||
"""
|
||||
@ -202,6 +209,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
if item is not -1:
|
||||
self.serviceItems.remove(self.serviceItems[item])
|
||||
self.repaintServiceList()
|
||||
self.parent.OosChanged(False, self.serviceName)
|
||||
|
||||
def repaintServiceList(self):
|
||||
#Correct order of idems in array
|
||||
@ -252,6 +260,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
os.remove(servicefile)
|
||||
except:
|
||||
pass #if not present do not worry
|
||||
self.parent.OosChanged(True, self.serviceName)
|
||||
|
||||
def onLoadService(self):
|
||||
"""
|
||||
@ -260,6 +269,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
filename = QtGui.QFileDialog.getOpenFileName(self, u'Open Order of Service',self.config.get_last_dir(),
|
||||
u'Services (*.oos)')
|
||||
filename = unicode(filename)
|
||||
name = filename.split(os.path.sep)
|
||||
if filename != u'':
|
||||
self.config.set_last_dir(filename)
|
||||
zip = zipfile.ZipFile(unicode(filename))
|
||||
@ -279,7 +289,6 @@ class ServiceManager(QtGui.QWidget):
|
||||
f.close()
|
||||
self.onNewService()
|
||||
for item in items:
|
||||
#print item
|
||||
serviceitem = ServiceItem()
|
||||
serviceitem.RenderManager = self.parent.RenderManager
|
||||
serviceitem.set_from_oos(item, self.servicePath )
|
||||
@ -287,7 +296,10 @@ class ServiceManager(QtGui.QWidget):
|
||||
try:
|
||||
os.remove(p_file)
|
||||
except:
|
||||
pass #if not present do not worry
|
||||
#if not present do not worry
|
||||
pass
|
||||
self.serviceName = name[len(name) - 1]
|
||||
self.parent.OosChanged(True, self.serviceName)
|
||||
|
||||
def onThemeComboBoxSelected(self, currentIndex):
|
||||
"""
|
||||
@ -323,6 +335,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
treewidgetitem1.setText(0,text[:40])
|
||||
treewidgetitem1.setData(0, QtCore.Qt.UserRole,QtCore.QVariant(count))
|
||||
count = count + 1
|
||||
self.parent.OosChanged(False, self.serviceName)
|
||||
|
||||
def makePreview(self):
|
||||
"""
|
||||
|
@ -494,7 +494,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||
if end_verse == '':
|
||||
end_verse = 99
|
||||
if start_chapter == '':
|
||||
message = u'No chapter found for search'
|
||||
message = u'No chapter found for search criteria'
|
||||
#print 'message = ' + unicode(message)
|
||||
#print 'search = ' + unicode(original)
|
||||
#print 'results = ' + unicode(book) + ' @ '+ unicode(start_chapter)+' @ '+ unicode(end_chapter)+' @ '+ unicode(start_verse)+ ' @ '+ unicode(end_verse)
|
||||
|
Loading…
Reference in New Issue
Block a user