Fix size when put in layouts.

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=725390
This commit is contained in:
Andre Duffeck 2007-10-15 08:54:06 +00:00
parent ea36afad03
commit 54211a2f54
2 changed files with 20 additions and 18 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2007 by André Duffeck <andre@duffeck.de> * Copyright 2007 by André Duffeck <duffeck@kde.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as * it under the terms of the GNU Library General Public License as
@ -86,16 +86,6 @@ QRectF Flash::boundingRect() const
return QRectF(0,0,d->width,d->height); return QRectF(0,0,d->width,d->height);
} }
int Flash::height() const
{
return d->height;
}
int Flash::width() const
{
return d->width;
}
void Flash::setHeight(int h) void Flash::setHeight(int h)
{ {
prepareGeometryChange (); prepareGeometryChange ();
@ -115,8 +105,15 @@ void Flash::setDuration( int duration )
d->defaultDuration = duration; d->defaultDuration = duration;
} }
QSize Flash::size() const QSizeF Flash::minimumSize() const
{ {
kDebug() << QSize(d->width,d->height) << endl;
return QSize(d->width,d->height);
}
QSizeF Flash::maximumSize() const
{
kDebug() << QSize(d->width,d->height) << endl;
return QSize(d->width,d->height); return QSize(d->width,d->height);
} }
@ -128,6 +125,11 @@ void Flash::setSize(const QSize &s)
update(); update();
} }
QSizeF Flash::sizeHint() const
{
return minimumSize();
}
void Flash::setColor( const QColor &color ) void Flash::setColor( const QColor &color )
{ {
d->color = color; d->color = color;
@ -184,14 +186,14 @@ void Flash::fadeOut()
QPixmap Flash::renderPixmap() QPixmap Flash::renderPixmap()
{ {
QPixmap pm( width(), height() ); QPixmap pm( size().toSize() );
pm.fill(Qt::transparent); pm.fill(Qt::transparent);
QPainter painter( &pm ); QPainter painter( &pm );
if( d->type == Private::Text ) { if( d->type == Private::Text ) {
painter.setPen( d->color ); painter.setPen( d->color );
painter.setFont( d->font ); painter.setFont( d->font );
painter.drawText( QRect( 0, 0, width(), height() ), d->text, d->textOption); painter.drawText( QRect( QPoint(0, 0), size().toSize() ), d->text, d->textOption);
} else if( d->type == Private::Pixmap ) { } else if( d->type == Private::Pixmap ) {
QPoint p; QPoint p;
if( d->alignment & Qt::AlignLeft ) if( d->alignment & Qt::AlignLeft )

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2007 by André Duffeck <andre@duffeck.de> * Copyright 2007 by André Duffeck <duffeck@kde.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as * it under the terms of the GNU Library General Public License as
@ -43,9 +43,9 @@ class PLASMA_EXPORT Flash : public Plasma::Widget
void paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); void paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
QRectF boundingRect() const; QRectF boundingRect() const;
QSize size() const; QSizeF minimumSize() const;
int height() const; QSizeF maximumSize() const;
int width() const; virtual QSizeF sizeHint() const;
void setSize(const QSize &size); void setSize(const QSize &size);
void setWidth(int width); void setWidth(int width);
void setHeight(int height); void setHeight(int height);