Diffusion Krita ed1bf6eefcc9

Fix Brush HUD width adjustment

Authored by mwein on May 1 2020, 1:06 AM.

Description

Fix Brush HUD width adjustment

This time hopefully for real.
There are two issues to bypass:

  1. Layouts don't just instantly calculate new dimension as you modify them, it would be way too expensive, so Qt has a delayed pass for that in the event loop. So we need to wait until this has happened for the properties layout before resizing.
  2. QScrollArea has a pretty broken sizeHint() implementation. It will just not give us a useful size that we could use. See also QTBUG-76256 and QTBUG-58447

The most sane solution I could come up with is to install the
HUD widget as event filter for the content widget of the scroll
area, and catch the LayoutRequest event. This event gets sent
by the layout to the parent widget to indicate its new dimension
are now available.
This is what Q(Abstract)ScrollArea does internally anyway, so
even fixing the sizeHint and waiting for the event to trigger
again on the outer layout just costs another loop iteration
and results in multiple screen updates.

Since we need to adjust the width a few levels up, we need to
calculate the margins our self, but the layout is not overly
complex luckily.

BUG:409661
(cherry picked from commit 93bdd1d6f56092e2f229dc6202aa068f4526ddbc)

Details

Committed
remptMay 2 2020, 8:07 AM
Parents
R37:7735a5651a45: Fix memory leaks in KisMergeLabeledLayersCommand
Branches
Unknown
Tags
Unknown