blob: 191dc5ef96ceb8d6067ebd2dbb84db1267c8dc20 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
/* SPDX-License-Identifier: GPL-2.0-only */
#pragma once
#include <QCheckBox>
#include <QFile>
#include <QObject>
#include <QSvgRenderer>
/*
* The ToggleSwitch class represents Toggle Switch widget based on QCheckBox and toggles svg with colorscheme support
*/
class ToggleSwitch : public QCheckBox {
Q_OBJECT
public:
explicit ToggleSwitch(QWidget* parent = nullptr);
private:
QSvgRenderer m_svgr;
static const QByteArray s_toggleOnSvgContent;
static const QByteArray s_toggleOffSvgContent;
static const int s_colorPosInToggleOn;
QByteArray m_toggleOnSvgContentColored;
/* QWidget interface */
protected:
void paintEvent(QPaintEvent *event) override;
/* QAbstractButton interface */
protected:
bool hitButton(const QPoint &pos) const override
{
/* needs to be clickable on */
return rect().contains(pos);
}
};
|