2007-03-05 05:13:22 +01:00
|
|
|
/*
|
2007-03-13 01:32:17 +01:00
|
|
|
* Copyright (C) 2007 by Siraj Razick siraj@kde.org
|
2007-07-23 00:16:40 +02:00
|
|
|
* and Matias Valdenegro <mvaldenegro@informatica.utem.cl>
|
2007-03-05 05:13:22 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PUSHBUTTON_H
|
|
|
|
#define PUSHBUTTON_H
|
|
|
|
|
2007-04-22 11:35:04 +02:00
|
|
|
#include <QtCore/QObject>
|
|
|
|
#include <QtGui/QGraphicsTextItem>
|
|
|
|
#include <QtGui/QLayoutItem>
|
2007-05-25 04:27:33 +02:00
|
|
|
|
2007-06-02 19:29:39 +02:00
|
|
|
#include <plasma/dataengine.h>
|
2007-07-23 00:16:40 +02:00
|
|
|
#include <plasma/widgets/widget.h>
|
2007-06-02 19:29:39 +02:00
|
|
|
#include <plasma/plasma_export.h>
|
2007-03-05 05:13:22 +01:00
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2007-05-20 18:25:07 +02:00
|
|
|
/**
|
2007-07-23 00:16:40 +02:00
|
|
|
* Class that emulates a QPushButton inside Plasma
|
|
|
|
*
|
|
|
|
* @author Siraj Razick and Matias Valdenegro.
|
|
|
|
*
|
|
|
|
*
|
2007-05-20 18:25:07 +02:00
|
|
|
*/
|
2007-08-03 18:00:10 +02:00
|
|
|
class PLASMA_EXPORT PushButton : public Plasma::Widget
|
2007-03-05 05:13:22 +01:00
|
|
|
{
|
2007-05-25 04:27:33 +02:00
|
|
|
Q_OBJECT
|
2007-07-23 00:16:40 +02:00
|
|
|
|
2007-03-05 05:13:22 +01:00
|
|
|
public:
|
2007-03-13 04:00:09 +01:00
|
|
|
enum ButtonShape
|
|
|
|
{
|
|
|
|
Rectangle = 0,
|
|
|
|
Round,
|
|
|
|
Custom
|
|
|
|
};
|
2007-03-05 05:13:22 +01:00
|
|
|
|
2007-03-13 04:00:09 +01:00
|
|
|
enum ButtonState
|
|
|
|
{
|
|
|
|
None,
|
|
|
|
Hover,
|
|
|
|
Pressed,
|
|
|
|
Released
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
2007-03-05 05:13:22 +01:00
|
|
|
|
2007-07-23 00:16:40 +02:00
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*/
|
|
|
|
PushButton(Widget *parent = 0);
|
2007-03-13 04:00:09 +01:00
|
|
|
|
2007-07-23 00:16:40 +02:00
|
|
|
/**
|
|
|
|
* Virtual Destructor.
|
|
|
|
*/
|
|
|
|
virtual ~PushButton();
|
2007-03-13 04:00:09 +01:00
|
|
|
|
2007-07-23 00:16:40 +02:00
|
|
|
/**
|
|
|
|
* Returns the text of this Button.
|
|
|
|
*/
|
|
|
|
QString text() const;
|
2007-03-13 04:00:09 +01:00
|
|
|
|
2007-07-23 00:16:40 +02:00
|
|
|
/**
|
|
|
|
* Sets the text of this Button.
|
|
|
|
*/
|
|
|
|
void setText(const QString &text);
|
2007-03-13 04:00:09 +01:00
|
|
|
|
2007-07-23 00:16:40 +02:00
|
|
|
/**
|
|
|
|
* Sets the icon of this Button.
|
|
|
|
* @param path Path to the icon file. TODO : WTF is path?
|
|
|
|
*/
|
2007-03-13 04:00:09 +01:00
|
|
|
void setIcon(const QString& path);
|
2007-03-05 05:13:22 +01:00
|
|
|
|
2007-07-23 00:16:40 +02:00
|
|
|
/**
|
|
|
|
* Paint function.
|
|
|
|
*/
|
2007-08-01 22:51:27 +02:00
|
|
|
virtual void paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
2007-03-13 04:00:09 +01:00
|
|
|
|
2007-07-23 00:16:40 +02:00
|
|
|
/**
|
|
|
|
* Reimplemented from Plasma::Widget.
|
|
|
|
*/
|
|
|
|
virtual QSizeF sizeHint() const ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reimplemented from Plasma::Widget.
|
|
|
|
*/
|
|
|
|
virtual QSizeF minimumSize() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reimplemented from Plasma::Widget.
|
|
|
|
*/
|
|
|
|
virtual QSizeF maximumSize() const ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Buttons prefer to expand in Horizontal direction.
|
|
|
|
*/
|
2007-03-13 04:00:09 +01:00
|
|
|
virtual Qt::Orientations expandingDirections() const;
|
2007-07-23 00:16:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* TODO: What does this function do?
|
|
|
|
*/
|
2007-07-20 10:06:27 +02:00
|
|
|
virtual bool isEmpty() const;
|
2007-03-13 04:00:09 +01:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
2007-07-23 00:16:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Triggers whatever this button is clicked.
|
|
|
|
*/
|
2007-03-05 05:13:22 +01:00
|
|
|
void clicked();
|
2007-03-13 04:00:09 +01:00
|
|
|
|
2007-03-13 04:25:19 +01:00
|
|
|
public Q_SLOTS:
|
2007-05-25 04:27:33 +02:00
|
|
|
void updated(const QString&, const DataEngine::Data &);
|
2007-03-13 04:25:19 +01:00
|
|
|
|
2007-03-05 05:13:22 +01:00
|
|
|
protected:
|
|
|
|
bool isDown();
|
2007-03-13 04:00:09 +01:00
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
2007-03-13 04:25:19 +01:00
|
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
2007-03-13 04:00:09 +01:00
|
|
|
|
2007-03-05 05:13:22 +01:00
|
|
|
private:
|
|
|
|
class Private ;
|
|
|
|
Private * const d;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Plasma
|
|
|
|
|
|
|
|
#endif
|