Plasma Applet layout support for PushButton
svn path=/trunk/KDE/kdebase/workspace/plasma/lib/; revision=641857
This commit is contained in:
parent
08366a02c8
commit
ed8d4db4aa
@ -44,14 +44,18 @@ class PushButton::Private
|
|||||||
int height;
|
int height;
|
||||||
int width;
|
int width;
|
||||||
int maxWidth;
|
int maxWidth;
|
||||||
|
int minWidth;
|
||||||
|
int minHeight;
|
||||||
|
int maxHeight;
|
||||||
int radius;
|
int radius;
|
||||||
QTimer * updateTimer;
|
QTimer * updateTimer;
|
||||||
PushButton::ButtonState state;
|
PushButton::ButtonState state;
|
||||||
};
|
};
|
||||||
|
|
||||||
PushButton::PushButton(QGraphicsItem *parent)
|
PushButton::PushButton(QGraphicsItem *parent)
|
||||||
: QGraphicsItem(parent),
|
: DataVisualization(),
|
||||||
DataVisualization(),
|
QGraphicsItem(parent),
|
||||||
|
QLayoutItem (Qt::AlignHCenter),
|
||||||
d(new Private)
|
d(new Private)
|
||||||
{
|
{
|
||||||
setAcceptedMouseButtons(Qt::LeftButton);
|
setAcceptedMouseButtons(Qt::LeftButton);
|
||||||
@ -59,7 +63,10 @@ PushButton::PushButton(QGraphicsItem *parent)
|
|||||||
setEnabled(true);
|
setEnabled(true);
|
||||||
d->height = 40;
|
d->height = 40;
|
||||||
d->width = 100 ;
|
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));
|
setPos(QPointF(0.0,0.0));
|
||||||
d->state= PushButton::NONE;
|
d->state= PushButton::NONE;
|
||||||
d->labelText=tr("Plasma");
|
d->labelText=tr("Plasma");
|
||||||
@ -191,4 +198,35 @@ void PushButton::mousePressEvent ( QGraphicsSceneMouseEvent * event )
|
|||||||
update();
|
update();
|
||||||
emit clicked();
|
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
|
} // namespace Plasma
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QGraphicsTextItem>
|
#include <QGraphicsTextItem>
|
||||||
|
#include <QLayoutItem>
|
||||||
#include <kdemacros.h>
|
#include <kdemacros.h>
|
||||||
|
|
||||||
#include "datavisualization.h"
|
#include "datavisualization.h"
|
||||||
@ -32,7 +32,7 @@
|
|||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
class KDE_EXPORT PushButton : public DataVisualization,public QGraphicsItem
|
class KDE_EXPORT PushButton : public DataVisualization,public QGraphicsItem, public QLayoutItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@ -55,6 +55,15 @@ class KDE_EXPORT PushButton : public DataVisualization,public QGraphicsItem
|
|||||||
void setHeight(int height);
|
void setHeight(int height);
|
||||||
void setMaximumWidth(int maxwidth);
|
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:
|
public slots:
|
||||||
void data(const DataSource::Data&);
|
void data(const DataSource::Data&);
|
||||||
signals:
|
signals:
|
||||||
|
Loading…
Reference in New Issue
Block a user