2 * Copyright 2007 by Kevin Ottens <ervin@kde.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License as
6 * published by the Free Software Foundation; either version 2, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef PLASMA_APPLETHANDLE_P_H
21 #define PLASMA_APPLETHANDLE_P_H
23 #include <QtCore/QObject>
24 #include <QtGui/QGraphicsItem>
35 class AppletHandle
: public QObject
, public QGraphicsItem
39 enum FadeType
{ FadeIn
, FadeOut
};
40 enum ButtonType
{ NoButton
, MoveButton
, RotateButton
, ConfigureButton
, RemoveButton
, ResizeButton
};
42 AppletHandle(Containment
*parent
, Applet
*applet
);
43 virtual ~AppletHandle();
45 Applet
*applet() const;
47 QRectF
boundingRect() const;
48 void paint(QPainter
*painter
, const QStyleOptionGraphicsItem
*option
, QWidget
*widget
= 0);
49 void startFading(FadeType anim
);
52 void mousePressEvent(QGraphicsSceneMouseEvent
*event
);
53 void mouseReleaseEvent(QGraphicsSceneMouseEvent
*event
);
54 void mouseMoveEvent(QGraphicsSceneMouseEvent
*event
);
55 void hoverEnterEvent(QGraphicsSceneHoverEvent
*event
);
56 void hoverLeaveEvent(QGraphicsSceneHoverEvent
*event
);
57 QVariant
itemChange(GraphicsItemChange change
, const QVariant
&value
);
58 bool sceneEventFilter(QGraphicsItem
*watched
, QEvent
*event
);
61 void disappearDone(AppletHandle
*self
);
64 void fadeAnimation(qreal progress
);
65 void appletDestroyed();
70 static const int HANDLE_WIDTH
= 5;
71 static const int ICON_SIZE
= 16;
72 static const int ICON_MARGIN
= 8;
75 ButtonType
mapToButton(const QPointF
&point
) const;
76 void forceDisappear();
78 * move our applet to another containment
79 * @param containment the containment to move to
80 * @param pos the (scene-relative) position to place it at
82 void switchContainment(Containment
*containment
, const QPointF
&pos
);
85 ButtonType m_pressedButton
;
86 Containment
*m_containment
;
90 Phase::AnimId m_animId
;
95 QColor m_gradientColor
;
97 bool m_buttonsOnRight
;
103 #endif // multiple inclusion guard