[bugfix] fixed behavior of createNewProject, changed some hotkeys and renamed actions in file tools

[new] added saveAs button for prject, TO DO: possibly change saveAs icon slightly from save icon
This commit is contained in:
Marcel Paffrath 2017-05-31 14:30:06 +02:00
parent eb5cf08d58
commit 5897113140
2 changed files with 58 additions and 49 deletions

View File

@ -287,32 +287,37 @@ class MainWindow(QMainWindow):
self.createNewProject, self.createNewProject,
QKeySequence.New, newIcon, QKeySequence.New, newIcon,
"Create a new Project.") "Create a new Project.")
self.openProjectAction = self.createAction(self, "Load project ...", self.openProjectAction = self.createAction(self, "&Open project ...",
self.loadProject, self.loadProject,
QKeySequence.Open, QKeySequence.Open,
openIcon, openIcon,
"Load project file") "Load project file")
self.saveProjectAction = self.createAction(self, "Save project ...", self.saveProjectAction = self.createAction(self, "&Save project ...",
self.saveProject, self.saveProject,
QKeySequence.Save, QKeySequence.Save,
saveProjectIcon, saveProjectIcon,
"Save project file") "Save project file")
self.saveProjectAction.setEnabled(False) self.saveProjectAction.setEnabled(False)
self.saveProjectAsAction = self.createAction(self, "Save project as ...",
self.saveProjectAs,
QKeySequence.SaveAs,
saveProjectIcon,
"Save project file as...")
self.saveProjectAsAction.setEnabled(False)
# newEventAction = self.createAction(self, "&New event ...", # newEventAction = self.createAction(self, "&New event ...",
# self.createNewEvent, # self.createNewEvent,
# QKeySequence.New, newIcon, # QKeySequence.New, newIcon,
# "Create a new event.") # "Create a new event.")
self.openmanualpicksaction = self.createAction(self, "Load &picks ...", self.openmanualpicksaction = self.createAction(self, "Load %manual picks ...",
self.load_data, self.load_data,
QKeySequence.Open, "Ctrl+M",
manupicksicon, manupicksicon,
"Load manual picks for " "Load manual picks for "
"the displayed event.") "the displayed event.")
self.openmanualpicksaction.setEnabled(False) self.openmanualpicksaction.setEnabled(False)
self.openmanualpicksaction.setData(None) self.openmanualpicksaction.setData(None)
self.openautopicksaction = self.createAction(self, "Load &automatic picks " self.openautopicksaction = self.createAction(self, "Load &automatic picks ... ",
"...",
self.load_autopicks, self.load_autopicks,
"Ctrl+A", "Ctrl+A",
autopicksicon, autopicksicon,
@ -328,21 +333,21 @@ class MainWindow(QMainWindow):
"the displayed event.") "the displayed event.")
self.loadlocationaction.setEnabled(False) self.loadlocationaction.setEnabled(False)
self.loadpilotevent = self.createAction(self, "Load PILOT &event ...", self.loadpilotevent = self.createAction(self, "Load PILOT &event ...",
self.load_pilotevent, "Ctrl+E", self.load_pilotevent, None,
loadpiloticon, loadpiloticon,
"Load PILOT event from information " "Load PILOT event from information "
"MatLab binary collections (created" "MatLab binary collections (created"
" in former MatLab based version).") " in former MatLab based version).")
self.loadpilotevent.setEnabled(False) self.loadpilotevent.setEnabled(False)
self.saveEventAction = self.createAction(self, "&Save event ...", self.saveManualPicksAction = self.createAction(self, "Save &picks ...",
self.saveData, QKeySequence.Save, self.saveData, "Ctrl+P",
saveIcon, "Save actual event data.") saveIcon, "Save event pick data.")
self.saveEventAction.setEnabled(False) self.saveManualPicksAction.setEnabled(False)
self.addEventDataAction = self.createAction(self, "Add &events ...", self.addEventDataAction = self.createAction(self, "Add &events ...",
self.add_events, self.add_events,
"Ctrl+W", newFolderIcon, "Ctrl+E", newFolderIcon,
"Add event data") "Add event data")
prefsEventAction = self.createAction(self, "Preferences", prefsEventAction = self.createAction(self, "Preferences",
self.PyLoTprefs, self.PyLoTprefs,
@ -391,7 +396,8 @@ class MainWindow(QMainWindow):
self.fileMenu = self.menuBar().addMenu('&File') self.fileMenu = self.menuBar().addMenu('&File')
self.fileMenuActions = (self.newProjectAction, self.addEventDataAction, self.fileMenuActions = (self.newProjectAction, self.addEventDataAction,
self.openProjectAction, self.saveProjectAction, self.openProjectAction, self.saveProjectAction,
self.openmanualpicksaction, self.saveEventAction, None, self.saveProjectAsAction,
self.openmanualpicksaction, self.saveManualPicksAction, None,
prefsEventAction, quitAction) prefsEventAction, quitAction)
self.fileMenu.aboutToShow.connect(self.updateFileMenu) self.fileMenu.aboutToShow.connect(self.updateFileMenu)
self.updateFileMenu() self.updateFileMenu()
@ -409,9 +415,9 @@ class MainWindow(QMainWindow):
fileToolBar = self.addToolBar("FileTools") fileToolBar = self.addToolBar("FileTools")
fileToolActions = (self.newProjectAction, self.addEventDataAction, fileToolActions = (self.newProjectAction, self.addEventDataAction,
self.openProjectAction, self.saveProjectAction, self.openProjectAction, self.saveProjectAction,
self.openmanualpicksaction, self.saveProjectAsAction, self.openmanualpicksaction,
self.openautopicksaction, self.loadlocationaction, self.openautopicksaction, self.loadlocationaction,
self.loadpilotevent, self.saveEventAction) self.loadpilotevent, self.saveManualPicksAction)
fileToolBar.setObjectName("FileTools") fileToolBar.setObjectName("FileTools")
self.addActions(fileToolBar, fileToolActions) self.addActions(fileToolBar, fileToolActions)
@ -1197,7 +1203,7 @@ class MainWindow(QMainWindow):
self.openmanualpicksaction.setEnabled(True) self.openmanualpicksaction.setEnabled(True)
self.openautopicksaction.setEnabled(True) self.openautopicksaction.setEnabled(True)
self.loadpilotevent.setEnabled(True) self.loadpilotevent.setEnabled(True)
self.saveEventAction.setEnabled(True) self.saveManualPicksAction.setEnabled(True)
event = self.get_current_event() event = self.get_current_event()
if event.picks: if event.picks:
self.picks = event.picks self.picks = event.picks
@ -1220,7 +1226,7 @@ class MainWindow(QMainWindow):
self.openmanualpicksaction.setEnabled(False) self.openmanualpicksaction.setEnabled(False)
self.openautopicksaction.setEnabled(False) self.openautopicksaction.setEnabled(False)
self.loadpilotevent.setEnabled(False) self.loadpilotevent.setEnabled(False)
self.saveEventAction.setEnabled(False) self.saveManualPicksAction.setEnabled(False)
self.draw() self.draw()
def plotWaveformDataThread(self): def plotWaveformDataThread(self):
@ -2012,7 +2018,6 @@ class MainWindow(QMainWindow):
if not exists: if not exists:
if not self.okToContinue(): if not self.okToContinue():
return 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]
@ -2062,6 +2067,9 @@ class MainWindow(QMainWindow):
self.init_array_tab() self.init_array_tab()
self.setDirty(False) self.setDirty(False)
def saveProjectAs(self):
self.saveProject(new=True)
def saveProject(self, new=False): def saveProject(self, new=False):
''' '''
Save back project to pickle file. Save back project to pickle file.
@ -2091,6 +2099,7 @@ class MainWindow(QMainWindow):
def setDirty(self, value): def setDirty(self, value):
self.saveProjectAction.setEnabled(value) self.saveProjectAction.setEnabled(value)
self.saveProjectAsAction.setEnabled(value)
self.project.setDirty(value) self.project.setDirty(value)
self.dirty = value self.dirty = value

View File

@ -1 +1 @@
c540-dirty eb5c-dirty