2007-11-12 20:27:21 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2007 by Kevin Ottens <ervin@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 as
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PLASMA_APPLETHANDLE
|
|
|
|
#define PLASMA_APPLETHANDLE
|
|
|
|
|
|
|
|
#include <QtCore/QObject>
|
|
|
|
#include <QtGui/QGraphicsItem>
|
2008-01-10 00:43:49 +01:00
|
|
|
#include <QTimer>
|
2007-11-12 20:27:21 +01:00
|
|
|
|
|
|
|
#include "phase.h"
|
|
|
|
#include "svg.h"
|
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
class Applet;
|
|
|
|
class Containment;
|
|
|
|
|
|
|
|
class AppletHandle : public QObject, public QGraphicsItem
|
|
|
|
{
|
2008-01-10 00:43:49 +01:00
|
|
|
Q_OBJECT
|
2007-11-12 20:27:21 +01:00
|
|
|
public:
|
|
|
|
enum FadeType { FadeIn, FadeOut };
|
2008-01-06 04:13:07 +01:00
|
|
|
enum ButtonType { NoButton, MoveButton, RotateButton, ConfigureButton, RemoveButton, ResizeButton };
|
2007-11-12 20:27:21 +01:00
|
|
|
|
|
|
|
AppletHandle(Containment *parent, Applet *applet);
|
|
|
|
virtual ~AppletHandle();
|
|
|
|
|
|
|
|
Applet *applet() const;
|
|
|
|
|
|
|
|
QRectF boundingRect() const;
|
|
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
2008-01-10 00:43:49 +01:00
|
|
|
void startFading(FadeType anim);
|
2007-11-12 20:27:21 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
|
|
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
2007-12-08 04:38:11 +01:00
|
|
|
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
2008-01-10 02:21:45 +01:00
|
|
|
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event);
|
2007-11-12 20:27:21 +01:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void disappearDone(AppletHandle *self);
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void fadeAnimation(qreal progress);
|
2007-11-22 06:11:06 +01:00
|
|
|
void appletDestroyed();
|
2007-11-23 09:01:29 +01:00
|
|
|
void appletResized();
|
2008-01-10 00:43:49 +01:00
|
|
|
void fadeIn();
|
2007-11-12 20:27:21 +01:00
|
|
|
|
|
|
|
private:
|
2007-11-19 08:23:07 +01:00
|
|
|
static const int HANDLE_WIDTH = 5;
|
2007-11-18 03:00:20 +01:00
|
|
|
static const int ICON_SIZE = 16;
|
|
|
|
static const int ICON_MARGIN = 8;
|
2007-11-18 02:16:47 +01:00
|
|
|
|
2007-11-23 09:01:29 +01:00
|
|
|
void calculateSize();
|
2007-11-12 20:27:21 +01:00
|
|
|
ButtonType mapToButton(const QPointF &point) const;
|
2008-01-10 00:43:49 +01:00
|
|
|
void forceDisappear();
|
2008-02-03 14:09:21 +01:00
|
|
|
/**
|
|
|
|
* move our applet to another containment
|
|
|
|
* @param containment the containment to move to
|
|
|
|
* @param pos the (scene-relative) position to place it at
|
|
|
|
*/
|
|
|
|
void switchContainment(Containment *containment, const QPointF &pos);
|
2007-11-12 20:27:21 +01:00
|
|
|
|
|
|
|
QRectF m_rect;
|
|
|
|
ButtonType m_pressedButton;
|
|
|
|
Containment *m_containment;
|
|
|
|
Applet *m_applet;
|
|
|
|
qreal m_opacity;
|
|
|
|
FadeType m_anim;
|
|
|
|
Phase::AnimId m_animId;
|
|
|
|
qreal m_angle;
|
2008-01-08 02:22:44 +01:00
|
|
|
qreal m_tempAngle;
|
2008-01-05 12:58:48 +01:00
|
|
|
qreal m_scaleWidth;
|
|
|
|
qreal m_scaleHeight;
|
2007-11-18 22:34:27 +01:00
|
|
|
QColor m_gradientColor;
|
2008-01-10 00:43:49 +01:00
|
|
|
QTimer *m_hoverTimer;
|
2008-01-10 02:21:45 +01:00
|
|
|
bool m_buttonsOnRight;
|
|
|
|
bool m_pendingFade;
|
2007-11-12 20:27:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // multiple inclusion guard
|