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.
Please register or sign in to comment