-
Notifications
You must be signed in to change notification settings - Fork 47
Implemented Close Project functionality #3757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e5e52c6
1cbc138
7fe9767
e4f6a6e
f4d9650
47b9003
200b517
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ | |
| from packaging.version import Version | ||
| from PySide6.QtCore import QLocale, Qt | ||
| from PySide6.QtGui import QStandardItem | ||
| from PySide6.QtWidgets import QDockWidget, QLabel, QProgressBar, QTextBrowser | ||
| from PySide6.QtWidgets import QDockWidget, QLabel, QMessageBox, QProgressBar, QTextBrowser | ||
| from twisted.internet import reactor | ||
|
|
||
| import sas | ||
|
|
@@ -706,6 +706,7 @@ def addTriggers(self): | |
| self._workspace.actionOpen_Analysis.triggered.connect(self.actionOpen_Analysis) | ||
| self._workspace.actionSave.triggered.connect(self.actionSave_Project) | ||
| self._workspace.actionSave_Analysis.triggered.connect(self.actionSave_Analysis) | ||
| self._workspace.actionClose_Project.triggered.connect(self.actionClose_Project) | ||
| self._workspace.actionPreferences.triggered.connect(self.actionOpen_Preferences) | ||
| self._workspace.actionQuit.triggered.connect(self.actionQuit) | ||
| # Edit | ||
|
|
@@ -809,13 +810,14 @@ def actionOpen_Analysis(self): | |
| self.filesWidget.loadAnalysis() | ||
|
|
||
|
|
||
| def actionSave_Project(self): | ||
| def actionSave_Project(self) -> bool: | ||
| """ | ||
| Menu Save Project | ||
| return: True if save was successful, False otherwise | ||
| """ | ||
| filename = self.filesWidget.saveProject() | ||
| if not filename: | ||
| return | ||
| return False | ||
|
|
||
| # datasets | ||
| all_data = self.filesWidget.getSerializedData() | ||
|
|
@@ -840,6 +842,7 @@ def actionSave_Project(self): | |
|
|
||
| with open(filename, 'w') as outfile: | ||
| GuiUtils.saveData(outfile, final_data) | ||
| return True | ||
|
|
||
| def actionSave_Analysis(self): | ||
| """ | ||
|
|
@@ -1319,6 +1322,24 @@ def actionAbout(self): | |
| about = About() | ||
| about.exec() | ||
|
|
||
| def actionClose_Project(self): | ||
| """ | ||
| Menu File/Close Project | ||
| """ | ||
| # Make sure this is what the user really wants | ||
| reply = QMessageBox.question(self._parent, 'Close Project', | ||
| "Do you want to save the project before closing?\n" | ||
| "All unsaved changes will be lost if you don't save.", | ||
| QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel, | ||
| QMessageBox.Cancel) | ||
| if reply == QMessageBox.Save: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the saving project dialog is cancelled, the project reset still happens with no project saved, which may not be ideal. Maybe
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Errr.. nope :) we have if reply == QMessageBox.Save:
...
elif reply == QMessageBox.Discard:
....
# else Cancel, do nothingThe
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think my original point was clear. Try the following steps:
I don't think users will appreciate all of their work being thrown away without warning.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah! This makes sense. Indeed cancelling the "Save Project" does the wrong thing. thanks! |
||
| saved = self.actionSave_Project() | ||
| if saved: | ||
| self.resetProject() | ||
| elif reply == QMessageBox.Discard: | ||
| self.resetProject() | ||
| # else Cancel, do nothing | ||
|
|
||
| def actionCheck_for_update(self): | ||
| """ | ||
| Menu Help/Check for Update | ||
|
|
@@ -1396,3 +1417,15 @@ def saveCustomConfig(self): | |
| Save the config file based on current session values | ||
| """ | ||
| config.save() | ||
|
|
||
| def resetProject(self): | ||
| """ | ||
| Reset the project to an empty state | ||
| """ | ||
| # perspectives | ||
| for per in self.loadedPerspectives.values(): | ||
| if hasattr(per, 'reset'): | ||
| per.reset() | ||
| # file manager | ||
| self.filesWidget.reset() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,7 @@ | |
| <x>0</x> | ||
| <y>0</y> | ||
| <width>915</width> | ||
| <height>20</height> | ||
| <height>26</height> | ||
| </rect> | ||
| </property> | ||
| <widget class="QMenu" name="menu_File"> | ||
|
|
@@ -42,6 +42,8 @@ | |
| <addaction name="separator"/> | ||
| <addaction name="actionPreferences"/> | ||
| <addaction name="separator"/> | ||
| <addaction name="actionClose_Project"/> | ||
| <addaction name="separator"/> | ||
|
Comment on lines
+45
to
+46
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Logically, this would make more sense to be above the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think I fully agree - closing and quitting actions are usually on the bottom of the list, cf. |
||
| <addaction name="actionQuit"/> | ||
| </widget> | ||
| <widget class="QMenu" name="menuEdit"> | ||
|
|
@@ -632,13 +634,18 @@ | |
| <action name="actionMuMag_Fitter"> | ||
| <property name="text"> | ||
| <string>MuMag Fitter (Experimental)</string> | ||
| </property> | ||
| </property> | ||
| </action> | ||
| <action name="actionWhat_s_New"> | ||
| <property name="text"> | ||
| <string>What's New</string> | ||
| </property> | ||
| </action> | ||
| <action name="actionClose_Project"> | ||
| <property name="text"> | ||
| <string>Close Project</string> | ||
| </property> | ||
| </action> | ||
| </widget> | ||
| <resources/> | ||
| <connections/> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.