Files
StarPilot/selfdrive/ui/qt/onroad/alerts.h
T
firestar5683 9910651a9d Carl The Witch
2026-06-20 14:38:56 -05:00

54 lines
1.7 KiB
C++

#pragma once
#include <QWidget>
#include "selfdrive/ui/ui.h"
class OnroadAlerts : public QWidget {
Q_OBJECT
public:
OnroadAlerts(QWidget *parent = 0) : QWidget(parent) {}
void updateState(const UIState &s, const StarPilotUIState &fs);
void clear();
int alertHeight;
QJsonObject starpilot_toggles;
protected:
struct Alert {
QString text1;
QString text2;
QString type;
cereal::SelfdriveState::AlertSize size;
cereal::SelfdriveState::AlertStatus status;
bool equal(const Alert &other) const {
return text1 == other.text1 && text2 == other.text2 && type == other.type &&
size == other.size && status == other.status;
}
};
const QMap<cereal::SelfdriveState::AlertStatus, QColor> alert_colors = {
{cereal::SelfdriveState::AlertStatus::NORMAL, QColor(0x15, 0x15, 0x15, 0xf1)},
{cereal::SelfdriveState::AlertStatus::USER_PROMPT, QColor(0xDA, 0x6F, 0x25, 0xf1)},
{cereal::SelfdriveState::AlertStatus::CRITICAL, QColor(0xC9, 0x22, 0x31, 0xf1)},
};
void paintEvent(QPaintEvent*) override;
OnroadAlerts::Alert getAlert(const SubMaster &sm, const SubMaster &fpsm, uint64_t started_frame);
QColor bg;
Alert alert = {};
bool sidebarsOpen;
const QMap<cereal::StarPilotSelfdriveState::AlertStatus, QColor> starpilot_alert_colors = {
{cereal::StarPilotSelfdriveState::AlertStatus::NORMAL, QColor(0x15, 0x15, 0x15, 0xf1)},
{cereal::StarPilotSelfdriveState::AlertStatus::USER_PROMPT, QColor(0xDA, 0x6F, 0x25, 0xf1)},
{cereal::StarPilotSelfdriveState::AlertStatus::CRITICAL, QColor(0xC9, 0x22, 0x31, 0xf1)},
{cereal::StarPilotSelfdriveState::AlertStatus::STARPILOT, QColor(0x17, 0x86, 0x44, 0xf1)},
};
};