78 lines
2.0 KiB
C++
78 lines
2.0 KiB
C++
#ifndef PUSHBUTTON_H
|
|
#define PUSHBUTTON_H
|
|
|
|
//#include <QAbstractButton>
|
|
#include <QGraphicsWidget>
|
|
#include <QGraphicsSceneHoverEvent>
|
|
#include <QGraphicsItem>
|
|
class QGraphicsPixmapItem;
|
|
#include <QObject>
|
|
#include <QtCore/qtimeline.h>
|
|
|
|
class QTimer;
|
|
|
|
#define PRESS_EFFECT_FADE_TIMEOUT 200
|
|
#define MAX_OVERLAY_TEXT_LENGTH 3
|
|
|
|
class CPushButton : public QGraphicsWidget
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
CPushButton(QGraphicsItem *Parent, QString NormalFileName,bool UseTextOverlay = false, int ButtonData = 0);
|
|
virtual ~CPushButton();
|
|
|
|
void setFlashingData(QString FlashingFileName,int FlashingDelay);
|
|
void StartFlashing(void);
|
|
void StopFlashing(void);
|
|
void SetTextOverlay(QString Text);
|
|
void SetButtonData(unsigned long int ButtonData){mButtonData = ButtonData;}
|
|
unsigned long int GetBUttonData(){return mButtonData;}
|
|
|
|
|
|
void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
|
|
// QRectF boundingRect() const;
|
|
|
|
bool ispressed;
|
|
bool isreleasing;
|
|
bool isFlashingValid;
|
|
bool mDisplayFlashIcon;
|
|
bool UseOverlay;
|
|
QTimer *mFlashTimer;
|
|
int mFlashTimeout;
|
|
QString ButtonTextOverlay;
|
|
unsigned long int mButtonData;
|
|
|
|
protected:
|
|
//virtual void paintEvent(QPaintEvent *e);
|
|
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
|
|
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
|
|
virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
|
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event);
|
|
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
|
|
|
private:
|
|
QTimeLine *timeLine;
|
|
qreal ClickTransparency;
|
|
|
|
signals:
|
|
void clicked(CPushButton *ButtonPtr);
|
|
void pressed(CPushButton *ButtonPtr);
|
|
void released(CPushButton *ButtonPtr);
|
|
|
|
public slots:
|
|
void FlashButton();
|
|
void TimeLine(qreal value);
|
|
|
|
private:
|
|
QGraphicsPixmapItem *m_Normal;
|
|
QGraphicsPixmapItem *m_Pressed;
|
|
QGraphicsPixmapItem *m_Hovered;
|
|
QGraphicsPixmapItem *m_Flashing;
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
#endif // PUSHBUTTON_H
|