qt_demoe/buttondefence/buttondefence.h

100 lines
2.7 KiB
C
Raw Normal View History

2019-11-13 01:28:22 +00:00
#ifndef BUTTONDEFENCE_H
#define BUTTONDEFENCE_H
/**
* :feiyangqingyun(QQ:517216493) 2018-7-2
2020-07-04 02:01:37 +00:00
* 1. 22
* 2.
* 3.
* 4.
* 5.
* 6.
2019-11-13 01:28:22 +00:00
*/
#include <QWidget>
#ifdef quc
2020-12-24 10:00:09 +00:00
class Q_DECL_EXPORT ButtonDefence : public QWidget
2019-11-13 01:28:22 +00:00
#else
class ButtonDefence : public QWidget
#endif
{
Q_OBJECT
Q_ENUMS(ButtonStyle)
Q_ENUMS(ButtonStatus)
Q_PROPERTY(bool canMove READ getCanMove WRITE setCanMove)
Q_PROPERTY(QString text READ getText WRITE setText)
Q_PROPERTY(ButtonStyle buttonStyle READ getButtonStyle WRITE setButtonStyle)
Q_PROPERTY(ButtonStatus buttonStatus READ getButtonStatus WRITE setButtonStatus)
public:
2020-12-24 10:00:09 +00:00
//防区样式 圆形、警察、气泡、气泡2、消息、消息2
2019-11-13 01:28:22 +00:00
enum ButtonStyle {
ButtonStyle_Circle = 0,
ButtonStyle_Police = 1,
ButtonStyle_Bubble = 2,
ButtonStyle_Bubble2 = 3,
ButtonStyle_Msg = 4,
2020-12-24 10:00:09 +00:00
ButtonStyle_Msg2 = 5
2019-11-13 01:28:22 +00:00
};
//防区状态 布防、撤防、报警、旁路、故障
enum ButtonStatus {
ButtonStatus_Arming = 0,
ButtonStatus_Disarming = 1,
ButtonStatus_Alarm = 2,
ButtonStatus_Bypass = 3,
ButtonStatus_Error = 4
};
explicit ButtonDefence(QWidget *parent = 0);
~ButtonDefence();
protected:
void paintEvent(QPaintEvent *);
bool eventFilter(QObject *watched, QEvent *event);
private:
bool canMove; //是否可移动
QString text; //显示文字
ButtonStyle buttonStyle; //防区样式
ButtonStatus buttonStatus; //防区状态
QString type; //图片末尾类型
QString imgName; //背景图片名称
bool isDark; //是否加深报警
QTimer *timer; //报警闪烁定时器
private slots:
void checkAlarm();
public:
bool getCanMove() const;
QString getText() const;
ButtonStyle getButtonStyle() const;
ButtonStatus getButtonStatus() const;
QSize sizeHint() const;
QSize minimumSizeHint() const;
public Q_SLOTS:
//设置可移动
void setCanMove(bool canMove);
//设置显示文字
void setText(const QString &text);
//设置防区样式
void setButtonStyle(const ButtonStyle &buttonStyle);
//设置防区状态
void setButtonStatus(const ButtonStatus &buttonStatus);
Q_SIGNALS:
void clicked();
void doubleClicked();
};
#endif //BUTTONDEFENCE_H