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

Added Recent File Menu #209

Open
wants to merge 5 commits into
base: staging
Choose a base branch
from

Conversation

AstroChuck
Copy link
Contributor

OpenMotor now tracks recently opened files and lets you easily return to them.

OpenMotor now tracks recently opened files and lets you easily return to them.
Copy link
Owner

@reilleya reilleya left a comment

Choose a reason for hiding this comment

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

Couple of small things. I'll pull this branch and try it out soon.


def addRecentFile(self, filepath):
recentFilepaths = []
too_long = False
Copy link
Owner

Choose a reason for hiding this comment

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

This appears to be unused

Copy link
Owner

Choose a reason for hiding this comment

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

Still not used?

uilib/recentFile.py Show resolved Hide resolved
@@ -24,6 +25,10 @@ def __init__(self, app):
self.fileName = None

self.newFile()

self.recentlyOpenedFiles = []
self.recentFiles = getConfigPath() + 'recentfiles.txt'
Copy link
Owner

Choose a reason for hiding this comment

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

It is a pretty minor difference here, but I'd prefer the use of a yaml file with the same fileIO setup I used for preferences. That is consistent with the rest of the application and gets us things like migrations if we ever need them. You should just be able to stick a list in one of them.

Copy link
Owner

Choose a reason for hiding this comment

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

Another thing: concatenating file paths like that isn't always good practice because different operating systems might have different schemes for it. The safest way is with os.path.join. I know I used the + for this in the application myself, but I have learned since then!

@AstroChuck
Copy link
Contributor Author

Hi Andrew,
I'm ready for another review here!

Copy link
Owner

@reilleya reilleya left a comment

Choose a reason for hiding this comment

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

Thanks for coming back to this, much closer! Couple of minor comments.

I pulled the branch down and played with it for a bit and liked it! I did find one bug, though. I noticed that it doesn't update the propellant selector when you load a motor using the recent files menu. After digging around for a bit, it seems like it is because of a confusing interaction between the FileManager and the main window. Basically, in other places that motors are loaded, the main window calls the fileManager.load method, then, if a motor was loaded, a function calls postLoadUpdate, which among other things, disables events on the prop selector and changes what it is pointing to, After calling postLoadUpdate, it then calls enablePropSelector. This is pretty confusing and probably should be refactored, but is out of scope for this PR.

Instead, the quick fix here is to pass in the main window instance to each RecentFile object we instantiate instead of the file manager, and call the loadMotor on that instead of load. I think that should "just work".

self.recentlyOpenedFiles = []

self.recentFilesList = loadFile(self.recentFiles, fileTypes.RECENTFILES)["recentfileslist"]
if len(self.recentFilesList) >= 1:
Copy link
Owner

Choose a reason for hiding this comment

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

Nitpick: This if is redundant, as looping over an empty array does nothing.


def updateRecentlyOpenedMenu(self):
self.recentlyOpenedMenu.clear()
self.recentlyOpenedFiles = []
Copy link
Owner

Choose a reason for hiding this comment

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

Nit: please name this something that indicates that it contains the menu actions. I was briefly confused about what the difference between self.recentlyOpenedFiles and self.recentFilesList was.


def addRecentFile(self, filepath):
recentFilepaths = []
too_long = False
Copy link
Owner

Choose a reason for hiding this comment

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

Still not used?

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.

2 participants