some updates on saving/closing and user interaction
This commit is contained in:
parent
1ff3b845bb
commit
17cdffe735
50
QtPyLoT.py
50
QtPyLoT.py
@ -1001,7 +1001,14 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
def okToContinue(self):
|
def okToContinue(self):
|
||||||
if self.dirty:
|
if self.dirty:
|
||||||
return self.saveProject()
|
qmb = QMessageBox(self, icon=QMessageBox.Question, text='Do you wish to save changes in the current project?')
|
||||||
|
qmb.setStandardButtons(QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel)
|
||||||
|
qmb.setDefaultButton(QMessageBox.Save)
|
||||||
|
ret = qmb.exec_()
|
||||||
|
if ret == qmb.Save:
|
||||||
|
return self.saveProject()
|
||||||
|
elif ret == qmb.Cancel:
|
||||||
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def enableRefTestButtons(self, bool):
|
def enableRefTestButtons(self, bool):
|
||||||
@ -1495,7 +1502,7 @@ class MainWindow(QMainWindow):
|
|||||||
if not stat_picks:
|
if not stat_picks:
|
||||||
stat_picks = picks
|
stat_picks = picks
|
||||||
else:
|
else:
|
||||||
msgBox = QMessageBox()
|
msgBox = QMessageBox(self)
|
||||||
msgBox.setText("The picks for station {0} have been "
|
msgBox.setText("The picks for station {0} have been "
|
||||||
"changed.".format(station))
|
"changed.".format(station))
|
||||||
msgBox.setDetailedText("Old picks:\n"
|
msgBox.setDetailedText("Old picks:\n"
|
||||||
@ -1970,7 +1977,10 @@ class MainWindow(QMainWindow):
|
|||||||
'''
|
'''
|
||||||
Create new project file.
|
Create new project file.
|
||||||
'''
|
'''
|
||||||
if self.okToContinue():
|
if not exists:
|
||||||
|
if not self.okToContinue():
|
||||||
|
return
|
||||||
|
else:
|
||||||
dlg = QFileDialog()
|
dlg = QFileDialog()
|
||||||
fnm = dlg.getSaveFileName(self, 'Create a new project file...', filter='Pylot project (*.plp)')
|
fnm = dlg.getSaveFileName(self, 'Create a new project file...', filter='Pylot project (*.plp)')
|
||||||
filename = fnm[0]
|
filename = fnm[0]
|
||||||
@ -1990,18 +2000,20 @@ class MainWindow(QMainWindow):
|
|||||||
'''
|
'''
|
||||||
Load an existing project file.
|
Load an existing project file.
|
||||||
'''
|
'''
|
||||||
if self.project:
|
if not self.okToContinue():
|
||||||
if self.project.dirty:
|
return
|
||||||
qmb = QMessageBox(icon=QMessageBox.Question, text='Save changes in current project?')
|
# if self.project:
|
||||||
qmb.setStandardButtons(QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel)
|
# if self.project.dirty:
|
||||||
qmb.setDefaultButton(QMessageBox.Yes)
|
# qmb = QMessageBox(self, icon=QMessageBox.Question, text='Save changes in current project?')
|
||||||
answer = qmb.exec_()
|
# qmb.setStandardButtons(QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel)
|
||||||
if answer == 16384:
|
# qmb.setDefaultButton(QMessageBox.Yes)
|
||||||
self.saveProject()
|
# answer = qmb.exec_()
|
||||||
elif answer == 65536:
|
# if answer == 16384:
|
||||||
pass
|
# self.saveProject()
|
||||||
elif answer == 4194304:
|
# elif answer == 65536:
|
||||||
return
|
# pass
|
||||||
|
# elif answer == 4194304:
|
||||||
|
# return
|
||||||
if not fnm:
|
if not fnm:
|
||||||
dlg = QFileDialog()
|
dlg = QFileDialog()
|
||||||
fnm = dlg.getOpenFileName(self, 'Open project file...', filter='Pylot project (*.plp)')
|
fnm = dlg.getOpenFileName(self, 'Open project file...', filter='Pylot project (*.plp)')
|
||||||
@ -2016,6 +2028,7 @@ class MainWindow(QMainWindow):
|
|||||||
self.init_array_map(index=0)
|
self.init_array_map(index=0)
|
||||||
else:
|
else:
|
||||||
self.init_array_tab()
|
self.init_array_tab()
|
||||||
|
self.setDirty(False)
|
||||||
|
|
||||||
def saveProject(self, new=False):
|
def saveProject(self, new=False):
|
||||||
'''
|
'''
|
||||||
@ -2051,8 +2064,11 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
def closeEvent(self, event):
|
def closeEvent(self, event):
|
||||||
if self.okToContinue():
|
if self.okToContinue():
|
||||||
self.closing.emit()
|
event.accept()
|
||||||
QMainWindow.closeEvent(self, event)
|
else:
|
||||||
|
event.ignore()
|
||||||
|
# self.closing.emit()
|
||||||
|
# QMainWindow.closeEvent(self, event)
|
||||||
|
|
||||||
def PyLoTprefs(self):
|
def PyLoTprefs(self):
|
||||||
if not self._props:
|
if not self._props:
|
||||||
|
@ -1 +1 @@
|
|||||||
60c8-dirty
|
1ff3-dirty
|
||||||
|
Loading…
Reference in New Issue
Block a user