#pragma once #include #include #include #include "ui_switchbutton.h" class SwitchButton : public QWidget { Q_OBJECT public: SwitchButton(int action, QWidget * parent); ~SwitchButton(); private: int action; Ui::SwitchButton ui; bool checked; QColor bgColorOff; QColor bgColorOn; QColor sliderColorOff; QColor sliderColorOn; int space; int rectRadius; int step; int startX; int endX; QTimer *timer; void updateValue(); void drawBg(QPainter * painter); void drawSlider(QPainter * painter); protected: void paintEvent(QPaintEvent *); void resizeEvent(QResizeEvent *); void mousePressEvent(QMouseEvent *); };