2026-02-09 16:03:09 +01:00
|
|
|
#ifndef BC_TOGGLESWITCH_H
|
|
|
|
|
#define BC_TOGGLESWITCH_H
|
2026-01-10 16:37:59 +01:00
|
|
|
|
|
|
|
|
#include <QAbstractButton>
|
|
|
|
|
|
2026-01-15 21:26:10 +01:00
|
|
|
|
2026-01-10 16:37:59 +01:00
|
|
|
class QPropertyAnimation;
|
|
|
|
|
|
|
|
|
|
class BCToggleSwitch : public QAbstractButton
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
// Property für die Animation (0.0 bis 1.0)
|
|
|
|
|
Q_PROPERTY(float position READ position WRITE setPosition)
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
explicit BCToggleSwitch(QWidget *parent = nullptr);
|
|
|
|
|
|
|
|
|
|
// Getter & Setter für die Animations-Property
|
|
|
|
|
float position() const;
|
|
|
|
|
void setPosition(float pos);
|
|
|
|
|
|
|
|
|
|
QSize sizeHint() const override;
|
|
|
|
|
|
2026-03-31 18:18:37 +02:00
|
|
|
// Statische Methode zum Zeichnen des passiven/deaktivierten Zustands
|
|
|
|
|
static void paintToggleIndicator(QPainter* p, const QRect& rect, bool isChecked, float position, const QPalette& palette);
|
|
|
|
|
|
2026-01-10 16:37:59 +01:00
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
void paintEvent(QPaintEvent *event) override;
|
|
|
|
|
void enterEvent(QEnterEvent *event) override;
|
|
|
|
|
void leaveEvent(QEvent *event) override;
|
|
|
|
|
|
2026-01-15 21:26:10 +01:00
|
|
|
private:
|
2026-01-10 16:37:59 +01:00
|
|
|
|
2026-01-15 21:26:10 +01:00
|
|
|
float m_position; // 0.0 = Aus, 1.0 = An
|
|
|
|
|
QPropertyAnimation* m_animation;
|
|
|
|
|
};
|
2026-01-10 16:37:59 +01:00
|
|
|
|
2026-02-09 16:03:09 +01:00
|
|
|
#endif // BC_TOGGLESWITCH_H
|