2
* Copyright (C) 2009 by Ana Cecília Martins <anaceciliamb@gmail.com>
3
* Copyright (C) 2010 by Chani Armitage <chani@kde.org>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU Library/Lesser General Public License
7
* version 2, or (at your option) any later version, as published by the
8
* Free Software Foundation
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details
15
* You should have received a copy of the GNU Library/Lesser General Public
16
* License along with this program; if not, write to the
17
* Free Software Foundation, Inc.,
18
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
#ifndef ABSTRACTICON_H
22
#define ABSTRACTICON_H
24
#include <QGraphicsWidget>
25
#include "plasmagenericshell_export.h"
27
class QPropertyAnimation;
33
class PLASMAGENERICSHELL_EXPORT AbstractIcon : public QGraphicsWidget
36
Q_PROPERTY(qreal backgroundFadeAlpha READ backgroundFadeAlpha WRITE setBackgroundFadeAlpha)
39
explicit AbstractIcon(QGraphicsItem *parent = 0);
42
void setIconSize(int height);
45
bool isSelected() const;
46
void setSelected(bool selected);
48
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
49
void paintForeground(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
50
void paintBackground(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
58
* return the background image
60
virtual QPixmap pixmap(const QSize &size) = 0;
63
* return the mime data for d&d
65
virtual QMimeData* mimeData() = 0;
67
static const int DEFAULT_ICON_SIZE = 16;
70
void hoverEnter(Plasma::AbstractIcon *applet);
71
void hoverLeave(Plasma::AbstractIcon *applet);
72
void dragging(Plasma::AbstractIcon *applet);
73
void clicked(Plasma::AbstractIcon *applet);
74
void doubleClicked(Plasma::AbstractIcon *applet);
77
void setName(const QString &name);
83
//listen to events and emit signals
84
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
85
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
86
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
87
void mousePressEvent(QGraphicsSceneMouseEvent *event);
88
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
89
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
90
void resizeEvent(QGraphicsSceneResizeEvent *);
91
QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const;
93
bool isDraggable() const;
94
void setDraggable(bool draggable);
97
qreal backgroundFadeAlpha() const;
98
void setBackgroundFadeAlpha(qreal progress);
99
void fadeBackground(int duration);
101
Plasma::FrameSvg *m_background;
102
QPropertyAnimation *m_backgroundFadeAnim;
103
QString m_backgroundPrefix;
104
QString m_oldBackgroundPrefix;
108
qreal m_backgroundAlpha;
113
#endif //APPLETICON_H