46 lines
1.4 KiB
C++
46 lines
1.4 KiB
C++
#ifndef CTAISWITCHBUTTON_H
|
|
#define CTAISWITCHBUTTON_H
|
|
|
|
#include <QWidget>
|
|
#include <QTimer>
|
|
#include <QPainter>
|
|
#include <QMouseEvent>
|
|
#include <QPainterPath>
|
|
|
|
class ctaiSwitchButton : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit ctaiSwitchButton(QWidget *parent = nullptr);
|
|
bool SwBtn_isChecked() const;
|
|
void setSwBtn_Status(bool check);
|
|
void setSwBtn_BackgroundColor(QColor color);
|
|
void setSwBtn_CheckedColor(QColor color);
|
|
void setSwBtn_DisabilityColor(QColor color);
|
|
void setSwBtn_WidgetSize(int m_width,int m_height);
|
|
protected:
|
|
void paintEvent(QPaintEvent *event) override;
|
|
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
|
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
|
void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
|
|
QSize sizeHint() const Q_DECL_OVERRIDE;
|
|
QSize minimumSizeHint() const Q_DECL_OVERRIDE;
|
|
signals:
|
|
void SwBtn_SWITCH(bool check);
|
|
private slots:
|
|
void SwBtn_Slide();
|
|
private:
|
|
bool m_SwBtn_Status;
|
|
QColor m_SwBtn_background;
|
|
QColor m_SwBtn_checkedColor;
|
|
QColor m_SwBtn_disabilityColor;
|
|
QColor m_SwBtn_thumbColor;
|
|
qreal m_SwBtn_radius;
|
|
qreal m_SwBtn_X;
|
|
qreal m_SwBtn_Y;
|
|
qint16 m_SwBtn_Height;
|
|
qint16 m_SwBtn_Margin;
|
|
QTimer m_SwBtn_timer;
|
|
};
|
|
|
|
#endif // SWITCH_CONTROL
|