From 7e23f237c6b432b8a1180f65d893fa9c7f47c837 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Sat, 19 Sep 2009 15:59:20 +0000 Subject: [PATCH] correctly align the button pixmap svn path=/trunk/KDE/kdelibs/; revision=1025760 --- widgets/pushbutton.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/widgets/pushbutton.cpp b/widgets/pushbutton.cpp index 22af49c62..08fea1f5d 100644 --- a/widgets/pushbutton.cpp +++ b/widgets/pushbutton.cpp @@ -394,11 +394,17 @@ void PushButton::paint(QPainter *painter, iconPix = effect->apply(iconPix, KIconLoader::Toolbar, KIconLoader::DisabledState); } + QRect pixmapRect; + if (nativeWidget()->text().isEmpty()) { + pixmapRect = nativeWidget()->style()->alignedRect(option->direction, Qt::AlignCenter, iconPix.size(), rect.toRect()); + } else { + pixmapRect = nativeWidget()->style()->alignedRect(option->direction, Qt::AlignLeft|Qt::AlignVCenter, iconPix.size(), rect.toRect()); + } + painter->drawPixmap(pixmapRect.topLeft(), iconPix); + if (option->direction == Qt::LeftToRight) { - painter->drawPixmap(rect.topLeft(), iconPix); rect.adjust(rect.height(), 0, 0, 0); } else { - painter->drawPixmap(rect.topRight() - QPoint(rect.height(), 0), iconPix); rect.adjust(0, 0, -rect.height(), 0); } }