[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

@ -284,65 +284,70 @@ class MainWindow(QMainWindow):
compare_icon = QIcon() compare_icon = QIcon()
compare_icon.addPixmap(QPixmap(':/icons/compare_button.png')) compare_icon.addPixmap(QPixmap(':/icons/compare_button.png'))
self.newProjectAction = self.createAction(self, "&New project ...", self.newProjectAction = self.createAction(self, "&New project ...",
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, "Load automatic picks "
"Load automatic picks " "for the displayed event.")
"for the displayed event.")
self.openautopicksaction.setEnabled(False) self.openautopicksaction.setEnabled(False)
self.openautopicksaction.setData(None) self.openautopicksaction.setData(None)
self.loadlocationaction = self.createAction(self, "Load &location ...", self.loadlocationaction = self.createAction(self, "Load &location ...",
self.load_loc, "Ctrl+L", self.load_loc, "Ctrl+L",
locactionicon, locactionicon,
"Load location information on " "Load location information on "
"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,21 +2018,20 @@ 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] if not len(fnm[0]):
if not len(fnm[0]): return False
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.setDirty(True)
self.setDirty(True) self.project.save(filename)
self.project.save(filename) self.setDirty(False)
self.setDirty(False) return True
return True
def loadProject(self, fnm=None): def loadProject(self, fnm=None):
''' '''
@ -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