-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathslipbutton.h
47 lines (37 loc) · 1.44 KB
/
slipbutton.h
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
40
41
42
43
44
45
46
47
#ifndef SLIPBUTTON_H
#define SLIPBUTTON_H
#include <QAbstractButton>
class SlipButton : public QAbstractButton
{
Q_OBJECT
Q_PROPERTY(int offset READ offset WRITE setOffset)
Q_PROPERTY(
QColor checkedBackgroundColor READ checkedBackgroundColor WRITE setCheckedBackgroundColor)
Q_PROPERTY(QColor uncheckedBackgroundColor READ uncheckedBackgroundColor WRITE
setUncheckedBackgroundColor)
public:
explicit SlipButton(QWidget *parent = nullptr);
~SlipButton() override;
[[nodiscard]] auto sizeHint() const -> QSize override;
[[nodiscard]] auto minimumSizeHint() const -> QSize override;
public slots:
void setCheckedBackgroundColor(const QColor &color);
[[nodiscard]] auto checkedBackgroundColor() const -> QColor;
void setUncheckedBackgroundColor(const QColor &color);
[[nodiscard]] auto uncheckedBackgroundColor() const -> QColor;
protected:
void paintEvent(QPaintEvent *event) override;
void enterEvent(QEnterEvent *event) override;
void leaveEvent(QEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
private slots:
void onStartAnimation();
[[nodiscard]] auto offset() const -> int;
void setOffset(int offset);
private:
[[nodiscard]] inline auto widthMargin() const -> double;
[[nodiscard]] inline auto heightMargin() const -> double;
struct SlipButtonPrivate;
QScopedPointer<SlipButtonPrivate> d_ptr;
};
#endif // SLIPBUTTON_H