mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-08-04 15:56:05 +08:00
3966599e9d
* Revert "Revert "ui: sunnypilot offroad UI" (#511)"
This reverts commit 0e264e1b05.
* Revert "move files to sp dir"
This reverts commit c72d732259d35872fca92b90289785e7b4086140.
* remove drive stats for now
* update translation
* update onboarding
* remove sp onboarding for now
* rearrange
* remove more
* shorter license
44 lines
931 B
C++
44 lines
931 B
C++
#pragma once
|
|
|
|
#include <QAbstractButton>
|
|
#include <QMouseEvent>
|
|
#include <QPropertyAnimation>
|
|
|
|
class Toggle : public QAbstractButton {
|
|
Q_OBJECT
|
|
Q_PROPERTY(int offset_circle READ offset_circle WRITE set_offset_circle CONSTANT)
|
|
|
|
public:
|
|
Toggle(QWidget* parent = nullptr);
|
|
void togglePosition();
|
|
bool on;
|
|
int animation_duration = 150;
|
|
int immediateOffset = 0;
|
|
int offset_circle() const {
|
|
return _x_circle;
|
|
}
|
|
|
|
void set_offset_circle(int o) {
|
|
_x_circle = o;
|
|
update();
|
|
}
|
|
bool getEnabled();
|
|
virtual void setEnabled(bool value);
|
|
|
|
protected:
|
|
void paintEvent(QPaintEvent*) override;
|
|
void mouseReleaseEvent(QMouseEvent*) override;
|
|
void enterEvent(QEvent*) override;
|
|
|
|
QColor circleColor;
|
|
QColor green;
|
|
bool enabled = true;
|
|
int _x_circle, _y_circle;
|
|
int _height, _radius;
|
|
int _height_rect, _y_rect;
|
|
QPropertyAnimation *_anim = nullptr;
|
|
|
|
signals:
|
|
void stateChanged(bool new_state);
|
|
};
|