-
Notifications
You must be signed in to change notification settings - Fork 37
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
Fonticon color matching theme #159
Comments
I think you'd want to use the setTextIcon function in that case (rather than using the icon() -> Qicon function). |
hey @Czaki, I'm thinking about this a bit more, for both fonticon and iconify QIcons. One thing we can do here is to install an event filter on the object that listens for Stripped of all the error catching conditionals it would look something like this: class PaletteEventFilter(QObject):
def eventFilter(self, obj: QObject, event: QEvent) -> bool:
"""Change icon color when palette changes."""
if event.type() == QEvent.Type.PaletteChange:
pal = (
obj.palette() if hasattr(obj, "palette") else QGuiApplication.palette()
)
new_color = pal.color(QPalette.ColorRole.ButtonText)
new_icon = self.getNewIcon(obj, new_color)
obj.setIcon(new_icon)
return False
def getNewIcon(self, obj: QObject, color: QColor) -> QIcon | None:
"""Return an instance of QIcon suitable for obj using `color`.""" That event filter could be installed on any QObject that supports Want me to put together a more complete proposal like that? |
It looks promising. I do not know about this event. |
I try to use
superqt.fonticon
in napari widget. I observe that icons are dark when enabled. It does not look best when selecting a dark theme.Is there a way to such an icon automatically match the text color for the current qss? Or does the QSS for the theme need to be updated to handle icons?
The text was updated successfully, but these errors were encountered: