Add (and install) svg for the new krunner interface.
[kdebase/uwolfer.git] / workspace / libs / plasma / applethandle_p.h
blob30780cff5c56163836a08f163f20288c86d023fa
1 /*
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>
25 #include <QTimer>
27 #include "phase.h"
28 #include "svg.h"
30 namespace Plasma
32 class Applet;
33 class Containment;
35 class AppletHandle : public QObject, public QGraphicsItem
37 Q_OBJECT
38 public:
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);
51 protected:
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);
60 Q_SIGNALS:
61 void disappearDone(AppletHandle *self);
63 private Q_SLOTS:
64 void fadeAnimation(qreal progress);
65 void appletDestroyed();
66 void appletResized();
67 void fadeIn();
69 private:
70 static const int HANDLE_WIDTH = 5;
71 static const int ICON_SIZE = 16;
72 static const int ICON_MARGIN = 8;
74 void calculateSize();
75 ButtonType mapToButton(const QPointF &point) const;
76 void forceDisappear();
77 /**
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);
84 QRectF m_rect;
85 ButtonType m_pressedButton;
86 Containment *m_containment;
87 Applet *m_applet;
88 qreal m_opacity;
89 FadeType m_anim;
90 Phase::AnimId m_animId;
91 qreal m_angle;
92 qreal m_tempAngle;
93 qreal m_scaleWidth;
94 qreal m_scaleHeight;
95 QColor m_gradientColor;
96 QTimer *m_hoverTimer;
97 bool m_buttonsOnRight;
98 bool m_pendingFade;
103 #endif // multiple inclusion guard