Plasma Applet layout support for PushButton

svn path=/trunk/KDE/kdebase/workspace/plasma/lib/; revision=641857
This commit is contained in:
Siraj Razick 2007-03-12 19:16:17 +00:00
parent 08366a02c8
commit ed8d4db4aa
2 changed files with 52 additions and 5 deletions

View File

@ -44,14 +44,18 @@ class PushButton::Private
int height;
int width;
int maxWidth;
int minWidth;
int minHeight;
int maxHeight;
int radius;
QTimer * updateTimer;
PushButton::ButtonState state;
};
PushButton::PushButton(QGraphicsItem *parent)
: QGraphicsItem(parent),
DataVisualization(),
: DataVisualization(),
QGraphicsItem(parent),
QLayoutItem (Qt::AlignHCenter),
d(new Private)
{
setAcceptedMouseButtons(Qt::LeftButton);
@ -59,7 +63,10 @@ PushButton::PushButton(QGraphicsItem *parent)
setEnabled(true);
d->height = 40;
d->width = 100 ;
d->maxWidth = 600;
d->minWidth = d->width;
d->maxWidth = d->width;
d->minHeight = d->height;
d->maxHeight = d->height;
setPos(QPointF(0.0,0.0));
d->state= PushButton::NONE;
d->labelText=tr("Plasma");
@ -191,4 +198,35 @@ void PushButton::mousePressEvent ( QGraphicsSceneMouseEvent * event )
update();
emit clicked();
}
QSize PushButton::sizeHint() const
{
return QSize(d->width,d->height);
}
QSize PushButton::minimumSize() const
{
return QSize(d->minWidth,d->minHeight);
}
QSize PushButton::maximumSize() const
{
return QSize(d->maxWidth,d->maxHeight);
}
Qt::Orientations PushButton::expandingDirections() const
{
return Qt::Horizontal;
}
void PushButton::setGeometry(const QRect & r)
{
setSize(r.size());
setPos(r.x(),r.y());
}
QRect PushButton::geometry() const
{
return boundingRect().toRect();
}
} // namespace Plasma

View File

@ -21,7 +21,7 @@
#include <QObject>
#include <QGraphicsTextItem>
#include <QLayoutItem>
#include <kdemacros.h>
#include "datavisualization.h"
@ -32,7 +32,7 @@
namespace Plasma
{
class KDE_EXPORT PushButton : public DataVisualization,public QGraphicsItem
class KDE_EXPORT PushButton : public DataVisualization,public QGraphicsItem, public QLayoutItem
{
Q_OBJECT
public:
@ -55,6 +55,15 @@ class KDE_EXPORT PushButton : public DataVisualization,public QGraphicsItem
void setHeight(int height);
void setMaximumWidth(int maxwidth);
//layout stufff
QSize sizeHint() const ;
QSize minimumSize() const;
QSize maximumSize() const ;
Qt::Orientations expandingDirections() const;
void setGeometry(const QRect& r);
QRect geometry() const ;
bool isEmpty() const {return false;}
public slots:
void data(const DataSource::Data&);
signals: