-
-
Notifications
You must be signed in to change notification settings - Fork 394
feat(ui): add more default icons and file type equivalencies #882
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
Conversation
Note: a lot of the zip-based code is becoming duplicated - this should be consolidated in the future.
I apologize for the barrage of new commits - I've updated the database icon in addition to adding a few more tweaks and additions, most notably the addition of iWork and PowerPoint thumbnail extraction. I've noticed a lot of overlap with these zip-based thumbnail formats, so I'd be interested in refactoring all of them into a single method in a future PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just two nits, otherwise this seems ready to merge to me (don't really have files to test the thumbnails on, but I trust that that works)
Edit: Also maybe add the refactoring idea as a TODO so we don't forget, because I definitely agree with that
@classmethod | ||
def _powerpoint_thumb(cls, filepath: Path) -> Image.Image | None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest changing this and the _iwork_thumb
to staticmethod
s since these don't actually use the class they are part of and might as well be independet methods
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's quite a few @classmethod
methods in here, with none of them (plus the regular self
methods) seemingly needing to be that way. I've locally tested making the vast majority of them static methods and there doesn't seem to be a downside. Should I go ahead and do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good
cached_path = Path( | ||
self.lib.library_dir | ||
/ TS_FOLDER_NAME | ||
/ THUMB_CACHE_NAME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change? Afaik the /
operator only works on Path
s and also returns a Path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On paper it should be functionally the same, but Pyright gives a reportUnknownVariableType
warning here since it can't deduce that the parenthesis syntax will always give a Path
. I figured I could either add an ignore comment for the warning, or just explicitly call the Path constructor to provide the type hint.
Type of "cached_path" is partially unknown
Type of "cached_path" is "Unknown | Path | None"
basedpyright[reportUnknownVariableType](https://docs.basedpyright.com/v1.28.3/configuration/config-files/#reportUnknownVariableType)
Everything should be addressed now, though I did add some quick error handling for PowerPoint thumbs since I came across that while testing the static methods, plus some quick type hints for some of the thumb renderer dicts. I'll refrain from doing any more type hint fixing for now, since that's better off in a dedicated PR... |
Thank you so much for the review! |
Funfact: I had actually done all these refactors already, but then decided not to push them because I had originally wanted to include them in a PR that uncouples the image loading (only to then discover that it kept SEGFAULTing) |
Summary
This PR adds various new fallback icons, file type equivalencies, and explicitly defined media types.
Tasks Completed