changed some dirty things
This commit is contained in:
parent
3ad82c0c9e
commit
b2d48cd523
27
QtPyLoT.py
27
QtPyLoT.py
@ -983,7 +983,7 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
def okToContinue(self):
|
def okToContinue(self):
|
||||||
if self.dirty:
|
if self.dirty:
|
||||||
return self.saveData()
|
return self.saveProject()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def enableRefTestButtons(self, bool):
|
def enableRefTestButtons(self, bool):
|
||||||
@ -1152,7 +1152,6 @@ class MainWindow(QMainWindow):
|
|||||||
def finishWaveformDataPlot(self):
|
def finishWaveformDataPlot(self):
|
||||||
self.connectWFplotEvents()
|
self.connectWFplotEvents()
|
||||||
self.loadlocationaction.setEnabled(True)
|
self.loadlocationaction.setEnabled(True)
|
||||||
self.saveProjectAction.setEnabled(True)
|
|
||||||
self.auto_tune.setEnabled(True)
|
self.auto_tune.setEnabled(True)
|
||||||
self.auto_pick.setEnabled(True)
|
self.auto_pick.setEnabled(True)
|
||||||
self.z_action.setEnabled(True)
|
self.z_action.setEnabled(True)
|
||||||
@ -1176,7 +1175,6 @@ class MainWindow(QMainWindow):
|
|||||||
self.disconnectWFplotEvents()
|
self.disconnectWFplotEvents()
|
||||||
self.dataPlot.getAxes().cla()
|
self.dataPlot.getAxes().cla()
|
||||||
self.loadlocationaction.setEnabled(False)
|
self.loadlocationaction.setEnabled(False)
|
||||||
self.saveProjectAction.setEnabled(False)
|
|
||||||
self.auto_tune.setEnabled(False)
|
self.auto_tune.setEnabled(False)
|
||||||
self.auto_pick.setEnabled(False)
|
self.auto_pick.setEnabled(False)
|
||||||
self.z_action.setEnabled(False)
|
self.z_action.setEnabled(False)
|
||||||
@ -1945,13 +1943,14 @@ class MainWindow(QMainWindow):
|
|||||||
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]
|
||||||
if not len(fnm[0]):
|
if not len(fnm[0]):
|
||||||
return
|
return False
|
||||||
if not filename.split('.')[-1] == 'plp':
|
if not filename.split('.')[-1] == 'plp':
|
||||||
filename = fnm[0] + '.plp'
|
filename = fnm[0] + '.plp'
|
||||||
if not exists:
|
if not exists:
|
||||||
self.project = Project()
|
self.project = Project()
|
||||||
self.init_events(new=True)
|
self.init_events(new=True)
|
||||||
self.project.save(filename)
|
self.project.save(filename)
|
||||||
|
self.setDirty(False)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def loadProject(self, fnm=None):
|
def loadProject(self, fnm=None):
|
||||||
@ -1985,33 +1984,35 @@ class MainWindow(QMainWindow):
|
|||||||
else:
|
else:
|
||||||
self.init_array_tab()
|
self.init_array_tab()
|
||||||
|
|
||||||
def saveProject(self):
|
def saveProject(self, new=False):
|
||||||
'''
|
'''
|
||||||
Save back project to pickle file.
|
Save back project to pickle file.
|
||||||
'''
|
'''
|
||||||
if self.project:
|
if self.project and not new:
|
||||||
if not self.project.location:
|
if not self.project.location:
|
||||||
if not self.createNewProject(exists=True):
|
if not self.createNewProject(exists=True):
|
||||||
return
|
self.setDirty(True)
|
||||||
|
return False
|
||||||
else:
|
else:
|
||||||
self.project.save()
|
self.project.save()
|
||||||
if not self.project.dirty:
|
if not self.project.dirty:
|
||||||
qmb = QMessageBox(icon=QMessageBox.Information, text='Saved back project to file:\n{}'.format(self.project.location))
|
qmb = QMessageBox(icon=QMessageBox.Information, text='Saved back project to file:\n{}'.format(self.project.location))
|
||||||
qmb.exec_()
|
qmb.exec_()
|
||||||
return
|
self.setDirty(False)
|
||||||
|
return True
|
||||||
else:
|
else:
|
||||||
# if still dirty because saving failed
|
# if still dirty because saving failed
|
||||||
qmb = QMessageBox(icon=QMessageBox.Warning, text='Could not save back to original file.\n'
|
qmb = QMessageBox.warning(self,'Could not save project',
|
||||||
'Choose new file')
|
'Could not save back to original file.\nChoose new file')
|
||||||
qmb.setStandardButtons(QMessageBox.Ok)
|
self.setDirty(True)
|
||||||
qmb.exec_()
|
return self.createNewProject(exists=True)
|
||||||
self.createNewProject(exists=True)
|
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
self.fill_eventbox(self.eventBox)
|
self.fill_eventbox(self.eventBox)
|
||||||
self.getPlotWidget().draw()
|
self.getPlotWidget().draw()
|
||||||
|
|
||||||
def setDirty(self, value):
|
def setDirty(self, value):
|
||||||
|
self.saveProjectAction.setEnabled(value)
|
||||||
self.dirty = value
|
self.dirty = value
|
||||||
|
|
||||||
def closeEvent(self, event):
|
def closeEvent(self, event):
|
||||||
|
@ -1 +1 @@
|
|||||||
8975-dirty
|
3ad8-dirty
|
||||||
|
Loading…
Reference in New Issue
Block a user