QPushButton: fix text truncating when icon+text+menu is drawn

When a QPushButton has an icon, text and menu, the text is truncated. In
RTL mode the menu indicator is also drawn on the wrong side.

Fixes: QTBUG-81784
Change-Id: I27ecb67d12c68ac939540f0f836b2e2875706b4b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Christian Ehrlicher 2020-02-01 22:04:09 +01:00
parent ef7773e566
commit f9cd8fef5e

View File

@ -1350,6 +1350,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
QRect ir = btn->rect;
QStyleOptionButton newBtn = *btn;
newBtn.rect = QRect(ir.right() - mbi + 2, ir.height()/2 - mbi/2 + 3, mbi - 6, mbi - 6);
newBtn.rect = visualRect(btn->direction, br, newBtn.rect);
proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget);
}
}
@ -1378,7 +1379,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
int iconSpacing = 4;//### 4 is currently hardcoded in QPushButton::sizeHint()
if (!button->text.isEmpty()) {
int textWidth = button->fontMetrics.boundingRect(opt->rect, tf, button->text).width();
labelWidth += (textWidth + iconSpacing);
labelWidth += (textWidth + iconSpacing * 2);
}
QRect iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2,