Skip to content

React to scale or color changes in editor tables

Andrei Kortunov requested to merge akortunov/openmw:datadisplaydelegate into master

In master editor's tables do not react when UI scale or color scheme changes during runtime, so user may get something like this:

image

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:

  1. Install DataDisplayDelegate as an event filter for the table window.
  2. Store current font color from system palette. If the table get a PaletteChange event and text color changed, rebuild pixmaps.
  3. 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.

Edited by Andrei Kortunov

Merge request reports