Make all plasma/widgets inherit Plasma::Widget now. Holding off on committing change for icon as I have a massive patch for the new text drawing

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=696028
This commit is contained in:
Matt Broadstone 2007-08-03 16:00:10 +00:00
parent 8fce372a7c
commit be3c212374
12 changed files with 206 additions and 185 deletions

View File

@ -315,16 +315,14 @@ uint Applet::Private::s_maxAppletId = 0;
Applet::Applet(QGraphicsItem *parent,
const QString& serviceID,
uint appletId)
: QObject(0),
Widget(parent),
: Widget(parent),
d(new Private(KService::serviceByStorageId(serviceID), appletId))
{
d->init(this);
}
Applet::Applet(QObject* parent, const QStringList& args)
: QObject(parent),
Widget(0),
: Widget(0),
d(new Private(KService::serviceByStorageId(args.count() > 0 ? args[0] : QString()),
args.count() > 1 ? args[1].toInt() : 0))
{

View File

@ -53,7 +53,7 @@ class Package;
*
* See techbase.kde.org for tutorial on writing Applets using this class.
*/
class PLASMA_EXPORT Applet : public QObject, public Widget
class PLASMA_EXPORT Applet : public Widget
{
Q_OBJECT
// Q_PROPERTY( QRectF maxSizeHint READ maxSizeHint )

View File

@ -51,31 +51,43 @@ class CheckBox::Private
};
CheckBox::CheckBox(QGraphicsItem *parent)
: QObject(),
QGraphicsItem(parent),
: Plasma::Widget(parent),
d(new Private)
{
init();
}
CheckBox::CheckBox(const QString &text, QGraphicsItem *parent)
: Plasma::Widget(parent),
d(new Private)
{
init();
setText(text);
}
void CheckBox::init()
{
setAcceptedMouseButtons(Qt::LeftButton);
setAcceptsHoverEvents(true);
setAcceptDrops(true);
setEnabled(true);
setPos(QPointF(0.0,0.0));
d->height = 40;
d->width = 100 ;
d->maxWidth = 600;
setPos(QPointF(0.0,0.0));
d->state= Qt::Unchecked;
d->labelText=QString("Plasma");
d->labelTextColor= QColor(201,201,255);
d->hasIcon = false;
d->iconSize = QSize(32,32);
d->hasMouse = false;
d->down = false;
d->hovering = false;
d->down = false;
}
CheckBox::~CheckBox()
{
delete d;
@ -86,9 +98,10 @@ QRectF CheckBox::boundingRect() const
return QRectF(0, 0, d->width, d->height);
}
void CheckBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
void CheckBox::paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(option)
QStyleOptionButton options;
options.rect = boundingRect().toRect();
options.text = text();
@ -105,6 +118,7 @@ void CheckBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
options.state |= QStyle::State_Raised;
options.state |= QStyle::State_On;
}
widget-> style()->drawControl(QStyle::CE_CheckBox, &options, painter, widget);
}

View File

@ -23,8 +23,9 @@
#include <QtGui/QGraphicsItem>
#include <plasma/plasma_export.h>
#include <plasma/dataengine.h>
#include <plasma/widgets/widget.h>
//TODO
//Please Document this class
@ -34,34 +35,40 @@ namespace Plasma
/**
* Class that emulates a QCheckBox inside plasma
*/
class PLASMA_EXPORT CheckBox : public QObject, public QGraphicsItem
class PLASMA_EXPORT CheckBox : public Plasma::Widget
{
Q_OBJECT
public:
CheckBox(QGraphicsItem *parent = 0);
explicit CheckBox(QGraphicsItem *parent = 0);
explicit CheckBox(const QString &text, QGraphicsItem *parent = 0);
virtual ~CheckBox();
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
void paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
QRectF boundingRect() const;
void setText(const QString&) ;
QString text() const;
QSize size() const;
int height() const;
int width() const;
void setSize(const QSize &size);
void setWidth(int width);
void setHeight(int height);
void setMaximumWidth(int maxwidth);
Qt::CheckState checkState() const;
void setChecked(bool checked);
void setCheckState(Qt::CheckState state);
void setText(const QString&) ;
QString text() const;
QSize size() const;
void setSize(const QSize &size);
int height() const;
void setHeight(int height);
int width() const;
void setWidth(int width);
void setMaximumWidth(int maxwidth);
public Q_SLOTS:
void updated(const QString&, const DataEngine::Data&);
Q_SIGNALS:
void clicked();
protected:
//bool isDown();
void mousePressEvent ( QGraphicsSceneMouseEvent * event );
@ -70,7 +77,10 @@ class PLASMA_EXPORT CheckBox : public QObject, public QGraphicsItem
void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
private:
void init();
class Private ;
Private * const d;

View File

@ -62,8 +62,7 @@ class Flash::Private
Flash::Flash(QGraphicsItem *parent)
: QObject(),
QGraphicsItem(parent),
: Plasma::Widget(parent),
d(new Private)
{
d->defaultDuration = 3000;
@ -212,7 +211,7 @@ QPixmap Flash::renderPixmap()
return pm;
}
void Flash::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
void Flash::paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(option)
Q_UNUSED(widget)

View File

@ -24,6 +24,7 @@
#include <QtGui/QTextOption>
#include <plasma/plasma_export.h>
#include <plasma/widgets/widget.h>
namespace Plasma
{
@ -31,14 +32,14 @@ namespace Plasma
/**
* Class that allows to flash text or icons inside plasma
*/
class PLASMA_EXPORT Flash : public QObject, public QGraphicsItem
class PLASMA_EXPORT Flash : public Plasma::Widget
{
Q_OBJECT
public:
Flash(QGraphicsItem *parent = 0);
virtual ~Flash();
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
void paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
QRectF boundingRect() const;
QSize size() const;
int height() const;

View File

@ -16,7 +16,7 @@ class Label::Private
};
Label::Label(Widget *parent)
: Widget(parent),
: Plasma::Widget(parent),
d(new Private)
{
setAlignment(Qt::AlignHCenter);

View File

@ -51,8 +51,7 @@ class PushButton::Private
};
PushButton::PushButton(Widget *parent)
: QObject(),
Widget(parent),
: Plasma::Widget(parent),
d(new Private)
{
setAcceptedMouseButtons(Qt::LeftButton);

View File

@ -38,8 +38,7 @@ namespace Plasma
*
*
*/
class PLASMA_EXPORT PushButton : public QObject,
public Plasma::Widget
class PLASMA_EXPORT PushButton : public Plasma::Widget
{
Q_OBJECT

View File

@ -61,8 +61,7 @@ RadioButton::Private::~Private()
RadioButton::RadioButton(QGraphicsItem *parent)
: QObject(),
QGraphicsItem(parent),
: Plasma::Widget(parent),
d(new Private)
{
setAcceptedMouseButtons(Qt::LeftButton);
@ -79,7 +78,7 @@ QRectF RadioButton::boundingRect() const
return QRectF(0, 0, 150, 30); // FIXME: this is obviously wrong
}
void RadioButton::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
void RadioButton::paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QStyle *style = widget ? widget->style() : QApplication::style();

View File

@ -25,7 +25,7 @@
// KDE includes
#include <plasma/plasma_export.h>
#include <plasma/widgets/widget.h>
#include <plasma/dataengine.h>
namespace Plasma
@ -47,17 +47,16 @@ namespace Plasma
*/
class PLASMA_EXPORT RadioButton : public QObject, public QGraphicsItem
class PLASMA_EXPORT RadioButton : public Plasma::Widget
{
Q_OBJECT
public:
RadioButton(QGraphicsItem *parent = 0);
virtual ~RadioButton();
// QGraphicsItem overridden virtual methods
QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
void paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
// Getters
bool isChecked() const;

View File

@ -36,7 +36,8 @@ class Layout;
/**
* Base class for all Widgets in Plasma.
*
* @author Alexander Wiedenbruch and Matias Valdenegro.
* @author Alexander Wiedenbruch
* @author Matias Valdenegro
*
* Widgets are the basis for User Interfaces inside Plasma.
* Widgets are rectangular, but can be in any visible shape by just using transparency to mask
@ -44,9 +45,11 @@ class Layout;
*
* To implement a Widget, just subclass Plasma::Widget and implement at minimum, sizeHint() and paint()
*/
class PLASMA_EXPORT Widget : public QGraphicsItem,
class PLASMA_EXPORT Widget : public QObject,
public QGraphicsItem,
public LayoutItem
{
Q_OBJECT
public:
/**