Skip to content
Verified Commit e6deaa17 authored by Fushan Wen's avatar Fushan Wen
Browse files

kstyle: Properly align text in ToolButton with icon

Sometimes button labels in a ToolButton without icon and a ToolButton
with icon are not vertically aligned even if all buttons have the same
height. This is caused by double-to-int.

The original top padding `(contentsRect.height() - textSize.height()) / 2`
can be rounded down, and when the padding is rounded down, so
`contentsRect.height() - padding - textSize.height() ≠ padding`.

After this change, textRect is calculated based on the remaining space.

For example, `contentsRect.height() = 32`, and `textSize.height() = 15`,
so the padding is 8. Before this commit, the bottom padding will be
`32 - 8 - 15 = 9 ≠ 8`. After this change, the bottom padding is the
same as the top padding (8), so the visual glitch is fixed.
parent a907a4aa
Pipeline #174131 passed with stage
in 2 minutes and 34 seconds
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment