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.
|
|
|
|
*/
|
|
|
|
|
2008-02-19 10:12:34 +01:00
|
|
|
#ifndef PLASMA_APPLETHANDLE_P_H
|
|
|
|
#define PLASMA_APPLETHANDLE_P_H
|
2007-11-12 20:27:21 +01:00
|
|
|
|
|
|
|
#include <QtCore/QObject>
|
|
|
|
#include <QtGui/QGraphicsItem>
|
2008-01-10 00:43:49 +01:00
|
|
|
#include <QTimer>
|
2007-11-12 20:27:21 +01:00
|
|
|
|
2008-04-25 05:23:31 +02:00
|
|
|
#include "animator.h"
|
2007-11-12 20:27:21 +01:00
|
|
|
#include "svg.h"
|
|
|
|
|
2008-09-09 02:23:02 +02:00
|
|
|
class QGraphicsView;
|
|
|
|
|
2007-11-12 20:27:21 +01:00
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
class Applet;
|
|
|
|
class Containment;
|
2008-10-29 18:46:33 +01:00
|
|
|
class FrameSvg;
|
2008-05-11 15:56:35 +02:00
|
|
|
class View;
|
2007-11-12 20:27:21 +01:00
|
|
|
|
|
|
|
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:
|
2008-10-12 01:28:20 +02:00
|
|
|
enum FadeType {
|
|
|
|
FadeIn,
|
|
|
|
FadeOut
|
|
|
|
};
|
|
|
|
enum ButtonType {
|
|
|
|
NoButton,
|
|
|
|
MoveButton,
|
|
|
|
RotateButton,
|
|
|
|
ConfigureButton,
|
|
|
|
RemoveButton,
|
|
|
|
ResizeButton
|
|
|
|
};
|
2007-11-12 20:27:21 +01:00
|
|
|
|
2008-07-10 03:35:51 +02:00
|
|
|
AppletHandle(Containment *parent, Applet *applet, const QPointF &hoverPos);
|
2007-11-12 20:27:21 +01:00
|
|
|
virtual ~AppletHandle();
|
|
|
|
|
2008-08-20 11:14:27 +02:00
|
|
|
void detachApplet ();
|
|
|
|
|
2007-11-12 20:27:21 +01:00
|
|
|
Applet *applet() const;
|
|
|
|
|
|
|
|
QRectF boundingRect() const;
|
2008-07-06 02:18:43 +02:00
|
|
|
QPainterPath shape() const;
|
2007-11-12 20:27:21 +01:00
|
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
2008-07-10 03:35:51 +02:00
|
|
|
void startFading(FadeType anim, const QPointF &hoverPos);
|
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);
|
2008-07-10 03:35:51 +02:00
|
|
|
void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
|
2007-11-12 20:27:21 +01:00
|
|
|
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();
|
2008-06-22 15:47:04 +02:00
|
|
|
void leaveTimeout();
|
2008-09-22 21:28:11 +02:00
|
|
|
void emitDisappear();
|
2007-11-12 20:27:21 +01:00
|
|
|
|
|
|
|
private:
|
2008-07-16 05:53:07 +02:00
|
|
|
static const int HANDLE_MARGIN = 3;
|
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-07-10 22:16:10 +02:00
|
|
|
int minimumHeight();
|
|
|
|
|
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);
|
2008-05-26 17:09:06 +02:00
|
|
|
bool leaveCurrentView(const QPoint &pos) const;
|
2007-11-12 20:27:21 +01:00
|
|
|
|
|
|
|
QRectF m_rect;
|
2008-09-18 21:40:46 +02:00
|
|
|
QRectF m_decorationRect;
|
2008-07-06 02:18:43 +02:00
|
|
|
QRectF m_totalRect;
|
2007-11-12 20:27:21 +01:00
|
|
|
ButtonType m_pressedButton;
|
|
|
|
Containment *m_containment;
|
|
|
|
Applet *m_applet;
|
2008-07-16 19:23:35 +02:00
|
|
|
int m_iconSize;
|
2007-11-12 20:27:21 +01:00
|
|
|
qreal m_opacity;
|
|
|
|
FadeType m_anim;
|
2008-04-24 23:26:36 +02:00
|
|
|
int m_animId;
|
2007-11-12 20:27:21 +01:00
|
|
|
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-06-22 15:47:04 +02:00
|
|
|
QTimer *m_leaveTimer;
|
2008-05-11 15:56:35 +02:00
|
|
|
View *m_topview;
|
2008-09-18 21:40:46 +02:00
|
|
|
QPixmap *m_backgroundBuffer;
|
2008-09-09 02:23:02 +02:00
|
|
|
QGraphicsView *m_currentView;
|
2008-05-16 15:28:33 +02:00
|
|
|
|
2008-09-18 21:40:46 +02:00
|
|
|
Svg *m_configureIcons;
|
2008-10-29 18:46:33 +01:00
|
|
|
FrameSvg *m_background;
|
2008-09-15 22:08:21 +02:00
|
|
|
|
2008-05-16 15:28:33 +02:00
|
|
|
QPoint m_mousePos; //mousepos relative to applet
|
2008-07-10 03:35:51 +02:00
|
|
|
QPointF m_entryPos; //where the hover in event occurred
|
2008-05-16 15:28:33 +02:00
|
|
|
QPointF m_pos; //current position of applet in sceneCoords
|
2008-05-19 18:20:27 +02:00
|
|
|
qreal m_zValue; //current zValue of the applet, so it can be restored after drag.
|
2008-09-09 02:23:02 +02:00
|
|
|
|
|
|
|
bool m_buttonsOnRight : 1;
|
|
|
|
bool m_pendingFade : 1;
|
2007-11-12 20:27:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // multiple inclusion guard
|