return a size hint based on font metrics

svn path=/trunk/KDE/kdelibs/; revision=1046144
This commit is contained in:
Marco Martin 2009-11-07 16:44:56 +00:00
parent 4f6ff5ef68
commit a5f39f0f06
2 changed files with 34 additions and 22 deletions

View File

@ -212,6 +212,15 @@ void FlashingLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
}
}
QSizeF FlashingLabel::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
{
if (which == Qt::PreferredSize) {
QFontMetrics fm(d->font);
return fm.boundingRect(d->text).size();
}
return QGraphicsWidget::sizeHint(which, constraint);
}
void FlashingLabelPrivate::renderPixmap(const QSize &size)
{
if (renderedPixmap.size() != size) {

View File

@ -57,6 +57,9 @@ class PLASMA_EXPORT FlashingLabel : public QGraphicsWidget
void setAutohide(bool autohide);
bool autohide() const;
protected:
QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const;
public Q_SLOTS:
void kill();