summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles/qcommonstyle.cpp
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2020-08-17 14:53:39 +0200
committerAndy Shaw <andy.shaw@qt.io>2020-08-19 12:46:10 +0200
commitc3f74bdc3ffdc69dce17530f9fafb2d6d15b746b (patch)
treea56300fd082e5276c259e5c425334d78858275e0 /src/widgets/styles/qcommonstyle.cpp
parent7e10dcb1d4ebd329957e3f4454378870e9d1670d (diff)
Don't crop the icon when it is aligned to the left
When we use double the icon spacing then the area for the pushbutton is not long enough, so in order to account for the gap inbetween then just use half of the icon spacing when positioning the text as it only has spacing on one side of the icon to it. Change-Id: Ib3fe0037835b67efda0fc274421f976ccc98eb06 Pick-to: 5.15 Fixes: QTBUG-85723 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/styles/qcommonstyle.cpp')
-rw-r--r--src/widgets/styles/qcommonstyle.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index bb646accf6..3f86320c5d 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -1379,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 * 2);
+ labelWidth += (textWidth + iconSpacing);
}
QRect iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2,
@@ -1390,10 +1390,10 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
if (button->direction == Qt::RightToLeft) {
tf |= Qt::AlignRight;
- textRect.setRight(iconRect.left() - iconSpacing);
+ textRect.setRight(iconRect.left() - iconSpacing / 2);
} else {
tf |= Qt::AlignLeft; //left align, we adjust the text-rect instead
- textRect.setLeft(iconRect.left() + iconRect.width() + iconSpacing);
+ textRect.setLeft(iconRect.left() + iconRect.width() + iconSpacing / 2);
}
if (button->state & (State_On | State_Sunken))