QLineEdit: take the size of actions' icons from a style
The height of a line edit depends on the height of its font, which in turn depends on DPI. So use the DPI-scaled icon size from a style instead of hard-coded values. Task-number: QTBUG-65627 Change-Id: Ic1f5af61b0d6346cfbc828817c4a3a39296a41ba Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>bb10
parent
cd3374c4ef
commit
05b8ba5155
|
|
@ -680,7 +680,8 @@ QSize QLineEdit::sizeHint() const
|
|||
Q_D(const QLineEdit);
|
||||
ensurePolished();
|
||||
QFontMetrics fm(font());
|
||||
int h = qMax(fm.height(), 14) + 2*d->verticalMargin
|
||||
const int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this);
|
||||
int h = qMax(fm.height(), iconSize - 2) + 2*d->verticalMargin
|
||||
+ d->topTextMargin + d->bottomTextMargin
|
||||
+ d->topmargin + d->bottommargin;
|
||||
int w = fm.horizontalAdvance(QLatin1Char('x')) * 17 + 2*d->horizontalMargin
|
||||
|
|
|
|||
|
|
@ -441,7 +441,7 @@ QLineEditPrivate::SideWidgetParameters QLineEditPrivate::sideWidgetParameters()
|
|||
{
|
||||
Q_Q(const QLineEdit);
|
||||
SideWidgetParameters result;
|
||||
result.iconSize = q->height() < 34 ? 16 : 32;
|
||||
result.iconSize = q->style()->pixelMetric(QStyle::PM_SmallIconSize, 0, q);
|
||||
result.margin = result.iconSize / 4;
|
||||
result.widgetWidth = result.iconSize + 6;
|
||||
result.widgetHeight = result.iconSize + 2;
|
||||
|
|
|
|||
Loading…
Reference in New Issue