2007-05-29 09:59:50 +02:00
|
|
|
/*
|
2007-07-20 08:28:51 +02:00
|
|
|
* Copyright (C) 2007 by Siraj Razick siraj@kde.org
|
|
|
|
* Copyright (C) 2007 by Matt Broadstone <mbroadst@gmail.com>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2007-05-29 09:59:50 +02:00
|
|
|
|
2007-06-05 20:39:59 +02:00
|
|
|
#ifndef ICON_H
|
|
|
|
#define ICON_H
|
2007-05-29 09:59:50 +02:00
|
|
|
|
2007-07-21 00:30:33 +02:00
|
|
|
#include <QObject>
|
|
|
|
#include <QGraphicsTextItem>
|
|
|
|
#include <QAction>
|
2007-05-29 09:59:50 +02:00
|
|
|
|
2007-06-02 19:29:39 +02:00
|
|
|
#include <plasma/dataengine.h>
|
2007-07-21 00:54:56 +02:00
|
|
|
#include <plasma/phase.h>
|
2007-06-02 19:29:39 +02:00
|
|
|
#include <plasma/plasma_export.h>
|
|
|
|
#include <plasma/widgets/layoutitem.h>
|
2007-05-29 09:59:50 +02:00
|
|
|
|
2007-06-17 01:38:56 +02:00
|
|
|
class KUrl;
|
|
|
|
|
2007-05-29 09:59:50 +02:00
|
|
|
//TODO
|
|
|
|
//Please Document this class
|
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2007-07-18 00:56:28 +02:00
|
|
|
class PLASMA_EXPORT Icon : public QObject, public QGraphicsItem, public LayoutItem
|
2007-05-29 09:59:50 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
Icon(QGraphicsItem *parent = 0);
|
2007-07-20 08:28:51 +02:00
|
|
|
Icon(const QString &text, QGraphicsItem *parent = 0);
|
|
|
|
Icon(const QIcon & icon, const QString &text, QGraphicsItem *parent = 0);
|
2007-05-29 09:59:50 +02:00
|
|
|
virtual ~Icon();
|
|
|
|
|
|
|
|
QString text() const;
|
|
|
|
void setText(const QString &name);
|
|
|
|
|
|
|
|
void setIcon(const QString& icon);
|
|
|
|
void setIcon(const QIcon& icon);
|
|
|
|
|
2007-07-20 08:28:51 +02:00
|
|
|
QSizeF iconSize() const;
|
|
|
|
void setIconSize(const QSizeF& size);
|
|
|
|
void setIconSize(int height, int width);
|
2007-05-29 09:59:50 +02:00
|
|
|
|
2007-07-21 06:07:41 +02:00
|
|
|
void addAction(QAction* action);
|
2007-07-20 08:28:51 +02:00
|
|
|
|
|
|
|
// Layout stuff
|
2007-05-29 22:37:21 +02:00
|
|
|
Qt::Orientations expandingDirections() const;
|
2007-05-29 09:59:50 +02:00
|
|
|
|
2007-05-29 22:37:21 +02:00
|
|
|
QSizeF minimumSize() const;
|
|
|
|
QSizeF maximumSize() const;
|
2007-05-29 09:59:50 +02:00
|
|
|
|
|
|
|
bool hasHeightForWidth() const;
|
|
|
|
qreal heightForWidth(qreal w) const;
|
|
|
|
|
|
|
|
bool hasWidthForHeight() const;
|
|
|
|
qreal widthForHeight(qreal h) const;
|
|
|
|
|
2007-05-29 22:37:21 +02:00
|
|
|
QRectF geometry() const;
|
|
|
|
void setGeometry(const QRectF& r);
|
2007-05-29 09:59:50 +02:00
|
|
|
|
2007-05-29 22:37:21 +02:00
|
|
|
QSizeF sizeHint() const;
|
2007-07-20 09:42:02 +02:00
|
|
|
QRectF boundingRect() const;
|
2007-05-29 09:59:50 +02:00
|
|
|
|
2007-07-20 08:28:51 +02:00
|
|
|
protected:
|
|
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
2007-06-05 04:54:48 +02:00
|
|
|
|
2007-07-20 08:28:51 +02:00
|
|
|
Q_SIGNALS:
|
|
|
|
void pressed(bool down);
|
|
|
|
void clicked();
|
2007-05-29 09:59:50 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool isDown();
|
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
2007-07-20 08:28:51 +02:00
|
|
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
2007-05-29 09:59:50 +02:00
|
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
2007-07-20 08:28:51 +02:00
|
|
|
|
2007-06-17 22:56:03 +02:00
|
|
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
|
|
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
2007-05-29 09:59:50 +02:00
|
|
|
|
2007-07-21 06:07:41 +02:00
|
|
|
public:
|
|
|
|
class Private;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
**/
|
|
|
|
void drawActionButtonBase(QPainter* painter, const QSize &size, int element);
|
|
|
|
|
2007-05-29 09:59:50 +02:00
|
|
|
private:
|
2007-06-19 23:56:40 +02:00
|
|
|
QPixmap buttonPixmap();
|
2007-07-20 08:28:51 +02:00
|
|
|
void init();
|
|
|
|
void calculateSize();
|
2007-06-19 23:56:40 +02:00
|
|
|
|
2007-05-29 09:59:50 +02:00
|
|
|
Private * const d;
|
2007-07-21 06:07:41 +02:00
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void actionDestroyed(QObject* obj);
|
2007-05-29 09:59:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Plasma
|
|
|
|
|
2007-07-20 08:28:51 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
// Add these to UrlIcon
|
|
|
|
void setUrl(const KUrl& url);
|
|
|
|
KUrl url() const;
|
|
|
|
*/
|
|
|
|
|
2007-05-29 09:59:50 +02:00
|
|
|
#endif
|