correctly align the button pixmap

svn path=/trunk/KDE/kdelibs/; revision=1025760
This commit is contained in:
Marco Martin 2009-09-19 15:59:20 +00:00
parent 48fe7cee90
commit 7e23f237c6

View File

@ -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);
}
}