| 1 |
|
| 2 |
|
| 3 |
#pragma once |
| 4 |
|
| 5 |
#include <QCheckBox> |
| 6 |
#include <QFile> |
| 7 |
#include <QObject> |
| 8 |
#include <QSvgRenderer> |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
class ToggleSwitch : public QCheckBox { |
| 15 |
Q_OBJECT |
| 16 |
public: |
| 17 |
explicit ToggleSwitch(QWidget* parent = nullptr); |
| 18 |
|
| 19 |
private: |
| 20 |
QSvgRenderer m_svgr; |
| 21 |
|
| 22 |
static const QByteArray s_toggleOnSvgContent; |
| 23 |
static const QByteArray s_toggleOffSvgContent; |
| 24 |
static const int s_colorPosInToggleOn; |
| 25 |
|
| 26 |
QByteArray m_toggleOnSvgContentColored; |
| 27 |
|
| 28 |
|
| 29 |
protected: |
| 30 |
void paintEvent(QPaintEvent *event) override; |
| 31 |
|
| 32 |
|
| 33 |
protected: |
| 34 |
bool hitButton(const QPoint &pos) const override |
| 35 |
{ |
| 36 |
|
| 37 |
return rect().contains(pos); |
| 38 |
} |
| 39 |
}; |