Skip to content
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

Add reset to default layout #833

Merged

Conversation

larsbijl
Copy link
Contributor

Add menu option to reset to default layout option.

Users sometimes remove widgets by accident, this helps to give them a simple way to restore to defaults.

Closes #832

@@ -422,3 +429,37 @@ def __saveSettings(self):
self.size())
self.settings.setValue("%s/Position" % self.name,
self.pos())

def __removeConfig(self, config_file):
try:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain this chunk of code? I'm having a hard time following it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we fork the process and let the parent process shutdown, the child then sleep for 3 seconds and remove the config file.
If we remove the config file before saving it's overwritten by Qsettings on closure. this is a very Unix specific hack on our part.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thanks, I see now. A quick search didn't turn up a way to disable this QSettings behavior, so that makes sense.

What if instead we saved a "setting" that actually means "restore the default settings on next startup"? Then in Main.startup we could change the check to be "if local settings don't exist or they contain the overwrite-me setting, then copy the default config files into place".

@larsbijl larsbijl force-pushed the 832-reset-default-layout branch 2 times, most recently from f718fa2 to 04d5c7f Compare December 13, 2020 11:56
Add menu option to reset to default layout option.

Users sometime remove widgets by accident, this helps giving them a
simple way to restore to defaults.

Closes AcademySoftwareFoundation#832
@larsbijl
Copy link
Contributor Author

@bcipriano this seems to work well and will be cross-platform.

Copy link
Collaborator

@bcipriano bcipriano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you!

@bcipriano bcipriano merged commit 96cefe2 into AcademySoftwareFoundation:master Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reset window layout option
2 participants