backport size hints fix

svn path=/branches/KDE/4.4/kdelibs/; revision=1071056
This commit is contained in:
Marco Martin 2010-01-07 12:52:35 +00:00
parent 292ad2ee4a
commit 66e7fa884b
2 changed files with 20 additions and 0 deletions

View File

@ -196,6 +196,7 @@ PushButton::~PushButton()
void PushButton::setText(const QString &text)
{
static_cast<KPushButton*>(widget())->setText(text);
updateGeometry();
}
QString PushButton::text() const
@ -509,6 +510,24 @@ void PushButton::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
QGraphicsProxyWidget::hoverLeaveEvent(event);
}
QSizeF PushButton::sizeHint(Qt::SizeHint which, const QSizeF & constraint) const
{
QSizeF hint = QGraphicsProxyWidget::sizeHint(which, constraint);
if (hint.isEmpty()) {
return hint;
}
//replace the native margin with the Svg one
QStyleOption option;
option.initFrom(nativeWidget());
int nativeMargin = nativeWidget()->style()->pixelMetric(QStyle::PM_ButtonMargin, &option, nativeWidget());
qreal left, top, right, bottom;
d->background->getMargins(left, top, right, bottom);
hint = hint - QSize(nativeMargin, nativeMargin) + QSize(left+right, top+bottom);
return hint;
}
} // namespace Plasma
#include <pushbutton.moc>

View File

@ -217,6 +217,7 @@ protected:
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
void changeEvent(QEvent *event);
QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint) const;
private:
Q_PRIVATE_SLOT(d, void syncBorders())