Fix fusion style QPushButton icon on HiDPI mode

Change-Id: Ie05012266abe52bc33bb9c2e19c93353cac3307f
Task-number: QTBUG-44502
Reviewed-by: Jens Bache-Wiig <jensbw@gmail.com>
This commit is contained in:
Marko Kangas 2015-02-16 16:37:05 +02:00
parent 341a32bcee
commit c974459455

View File

@ -1738,8 +1738,8 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
state = QIcon::On;
QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state);
int w = pixmap.width();
int h = pixmap.height();
int w = pixmap.width() / pixmap.devicePixelRatio();
int h = pixmap.height() / pixmap.devicePixelRatio();
if (!button->text.isEmpty())
w += button->fontMetrics.boundingRect(option->rect, tf, button->text).width() + 2;
@ -1747,15 +1747,17 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
point = QPoint(ir.x() + ir.width() / 2 - w / 2,
ir.y() + ir.height() / 2 - h / 2);
w = pixmap.width() / pixmap.devicePixelRatio();
if (button->direction == Qt::RightToLeft)
point.rx() += pixmap.width();
point.rx() += w;
painter->drawPixmap(visualPos(button->direction, button->rect, point), pixmap);
if (button->direction == Qt::RightToLeft)
ir.translate(-point.x() - 2, 0);
else
ir.translate(point.x() + pixmap.width(), 0);
ir.translate(point.x() + w, 0);
// left-align text if there is
if (!button->text.isEmpty())