2007-05-29 09:59:50 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007 by Siraj Razick siraj@kde.org
|
|
|
|
*
|
|
|
|
* 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-06-05 20:39:59 +02:00
|
|
|
#ifndef ICON_H
|
|
|
|
#define ICON_H
|
2007-05-29 09:59:50 +02:00
|
|
|
|
|
|
|
#include <QtCore/QObject>
|
|
|
|
#include <QtGui/QGraphicsTextItem>
|
|
|
|
|
2007-06-02 19:29:39 +02:00
|
|
|
#include <plasma/dataengine.h>
|
|
|
|
#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
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Icon class, for URIs and menu popups in panels
|
|
|
|
*/
|
|
|
|
class PLASMA_EXPORT Icon : public QObject,
|
|
|
|
public QGraphicsItem,
|
|
|
|
public LayoutItem
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
Icon(QGraphicsItem *parent = 0);
|
|
|
|
virtual ~Icon();
|
|
|
|
|
|
|
|
QString text() const;
|
|
|
|
void setText(const QString &name);
|
|
|
|
|
|
|
|
QSizeF size() const;
|
2007-06-05 04:54:48 +02:00
|
|
|
QSizeF iconSize() const;
|
2007-05-29 09:59:50 +02:00
|
|
|
void setSize(const QSizeF& size);
|
|
|
|
void setSize(int height, int width);
|
|
|
|
|
|
|
|
void setIcon(const QString& icon);
|
|
|
|
void setIcon(const QIcon& icon);
|
|
|
|
|
2007-06-17 00:35:31 +02:00
|
|
|
void setUrl(const KUrl& url);
|
|
|
|
|
2007-05-29 09:59:50 +02:00
|
|
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
2007-06-05 04:54:48 +02:00
|
|
|
QRectF boundingRect() const;
|
2007-05-29 09:59:50 +02:00
|
|
|
|
|
|
|
//layout stufff
|
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-05-29 09:59:50 +02:00
|
|
|
|
2007-06-05 04:54:48 +02:00
|
|
|
static int boundsForIconSize(int iconSize);
|
|
|
|
|
2007-05-29 09:59:50 +02:00
|
|
|
Q_SIGNALS:
|
|
|
|
void pressed(bool down);
|
|
|
|
void clicked();
|
2007-06-17 00:35:31 +02:00
|
|
|
void openUrl();
|
2007-05-29 09:59:50 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool isDown();
|
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
2007-06-17 22:56:03 +02:00
|
|
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
|
|
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
|
|
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
2007-05-29 09:59:50 +02:00
|
|
|
|
2007-06-17 00:35:31 +02:00
|
|
|
private Q_SLOTS:
|
|
|
|
void animateBubbles(int step);
|
|
|
|
|
2007-05-29 09:59:50 +02:00
|
|
|
private:
|
|
|
|
class Private;
|
|
|
|
Private * const d;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Plasma
|
|
|
|
|
|
|
|
#endif
|