Skip to content

Add custom image/GIF option to icon state customizations#23

Open
Dav1d-Fn wants to merge 5 commits into
gensyn:mainfrom
Dav1d-Fn:main
Open

Add custom image/GIF option to icon state customizations#23
Dav1d-Fn wants to merge 5 commits into
gensyn:mainfrom
Dav1d-Fn:main

Conversation

@Dav1d-Fn
Copy link
Copy Markdown

Summary

  • Adds a new "Image" field to the icon customization window, allowing users to set a custom image or GIF file per state instead of an MDI icon
  • Includes a "Browse..." button that opens a native file picker filtered for image formats (PNG, JPG, GIF, WEBP, SVG)
  • Custom images take priority over MDI icon names when a matching state condition is met
  • Fully backwards compatible: existing customizations without a custom image continue to work unchanged

Details

  • IconCustomization gains an optional custom_image field (file path), stored and loaded via export()/from_dict()
  • icon_helper.get_icon() returns the file path directly when a custom image is set, bypassing SVG rendering
  • German and English locale strings added
image

@gensyn
Copy link
Copy Markdown
Owner

gensyn commented May 14, 2026

Thank you for the effort! 👍

For me, the customizations represent a different state of the original options and I would like them to have a 1:1 relationship. What I mean is that I would also expect the new image option in the basic (non-customization) action settings. I know that this is also supported by vanilla StreamController, but it makes more sense to me to have the option in the action settings as well. So please also add the image field to the action settings and I'll happily merge the PR.

@Dav1d-Fn
Copy link
Copy Markdown
Author

Thanks for the feedback! Totally makes sense to have it as a base option as well. I'll add the image field to the action settings and update the PR.

Extends the existing image customization (previously only available in
state filters) to the main Show Icon action settings. A custom image
overrides the icon, color, scale and opacity when set. The other fields
are disabled when an image is active to make the relationship clear.
Also hardens settings initialization to fill in missing keys from
defaults, preventing KeyErrors on actions with incomplete saved state.
@Dav1d-Fn
Copy link
Copy Markdown
Author

Done! Added the image field to the action settings. When an image is set the other fields (icon, color, scale, opacity) are automatically disabled and there's a small hint in the label so it's clear why 🙂 Also made the default value initialization more robust so missing keys get filled in dynamically instead of causing errors on existing configs 👍

image

@gensyn
Copy link
Copy Markdown
Owner

gensyn commented May 14, 2026

I cleaned up the code to align with my vision and fixed some issues. Please check whether the branch still works for you. If it does, I think it can be merged.

@gensyn
Copy link
Copy Markdown
Owner

gensyn commented May 14, 2026

I thought some more about this and realized something: it is a viable option to integrate the image into the icon field. If the entered text is a valid MDI string, the icon is used, otherwise it is treated as a file path. The only neccessary change to the current main branch would be adding a file picker and probably some checks and tweaks. I think I like that idea - what do you think?

Instead of a separate image field, the icon field now accepts both MDI
icon names and file paths. If the entered value is a valid MDI icon it
is rendered as before, otherwise it is treated as an image/GIF path.
Scale works for both. The filter customizations follow the same
logic.
@Dav1d-Fn
Copy link
Copy Markdown
Author

Dav1d-Fn commented May 14, 2026

Thanks for the review and the idea, really like how it turned out! 🔥 Went ahead and merged the image option into the icon field, if the value is a valid MDI icon it works as before, otherwise it's treated as a file path. Noticed that scale actually works for images too so I left it enabled 🙌

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