Skip to content

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

Merged
merged 11 commits into from
Mar 31, 2025

Conversation

CyanVoxel
Copy link
Member

Summary

This PR adds various new fallback icons, file type equivalencies, and explicitly defined media types.

Tasks Completed

  • Platforms Tested:
    • Windows x86
    • Windows ARM
    • macOS x86
    • macOS ARM
    • Linux x86
    • Linux ARM
  • Tested For:
    • Basic functionality
    • PyInstaller executable

@CyanVoxel CyanVoxel added Type: QoL A quality of life (QoL) enhancement or suggestion Type: UI/UX User interface and/or user experience Priority: Low Doesn't require immediate attention Status: Review Needed A review of this is needed TagStudio: Search The TagStudio search engine labels Mar 21, 2025
@CyanVoxel CyanVoxel added this to the Alpha v9.5.2 milestone Mar 21, 2025
@CyanVoxel CyanVoxel moved this to 🏓 Ready for Review in TagStudio Development Mar 21, 2025
@CyanVoxel
Copy link
Member Author

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.

@CyanVoxel CyanVoxel moved this from 🏓 Ready for Review to 👀 In review in TagStudio Development Mar 30, 2025
Copy link
Collaborator

@Computerdores Computerdores left a 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

Comment on lines 675 to 676
@classmethod
def _powerpoint_thumb(cls, filepath: Path) -> Image.Image | None:
Copy link
Collaborator

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 staticmethods since these don't actually use the class they are part of and might as well be independet methods

Copy link
Member Author

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?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good

Comment on lines +1150 to 1153
cached_path = Path(
self.lib.library_dir
/ TS_FOLDER_NAME
/ THUMB_CACHE_NAME
Copy link
Collaborator

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 Paths and also returns a Path

Copy link
Member Author

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)

@CyanVoxel
Copy link
Member Author

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...

@CyanVoxel
Copy link
Member Author

Thank you so much for the review!

@CyanVoxel CyanVoxel removed the Status: Review Needed A review of this is needed label Mar 30, 2025
@CyanVoxel CyanVoxel moved this from 👀 In review to 🍃 Pending Merge in TagStudio Development Mar 30, 2025
@Computerdores
Copy link
Collaborator

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...

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)

@CyanVoxel CyanVoxel added the Status: Mergeable The code is ready to be merged label Mar 30, 2025
@CyanVoxel CyanVoxel merged commit d7d7e21 into main Mar 31, 2025
10 checks passed
@github-project-automation github-project-automation bot moved this from 🍃 Pending Merge to ✅ Done in TagStudio Development Mar 31, 2025
@CyanVoxel CyanVoxel deleted the icon-tweaks branch March 31, 2025 02:24
@CyanVoxel CyanVoxel removed the Status: Mergeable The code is ready to be merged label Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Low Doesn't require immediate attention TagStudio: Search The TagStudio search engine Type: QoL A quality of life (QoL) enhancement or suggestion Type: UI/UX User interface and/or user experience
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants