React to scale or color changes in editor tables
In master editor's tables do not react when UI scale or color scheme changes during runtime, so user may get something like this:
That's because a code which handles icons in these tables caches pixmaps (otherwise we would need to render new pixmaps every time when user scrolls the table content).
To avoid this issue, we need to somehow detect when UI scale or color scheme changes. The problem is that the event for UI scale change was added only in Qt 6.6 (while we still support Qt 5) and it is fired too early (so pixmap is still rendered with old resolution). Also the DataDisplayDelegate
is not a QWidget
, so it does not get any related events.
So use an another approach:
- Install
DataDisplayDelegate
as an event filter for the table window. - Store current font color from system palette. If the table get a
PaletteChange
event and text color changed, rebuild pixmaps. - Store current logical DPI ratio. If the table get a
Resize
event and DPI ratio changed, rebuild pixmaps.
Note that an approach is a bit hackish (an event filter API is used to invalidate a cache instead of events filtering), but I did not find a better solution.