added border indicator

This commit is contained in:
Rick Lan
2024-06-12 13:26:43 +08:00
parent 1a12e52abd
commit 9424caab25
2 changed files with 22 additions and 0 deletions
+17
View File
@@ -48,6 +48,10 @@ OnroadWindow::OnroadWindow(QWidget *parent) : QWidget(parent) {
QObject::connect(uiState(), &UIState::uiUpdate, this, &OnroadWindow::updateState);
QObject::connect(uiState(), &UIState::offroadTransition, this, &OnroadWindow::offroadTransition);
QObject::connect(uiState(), &UIState::primeChanged, this, &OnroadWindow::primeChanged);
#ifdef DP
border_indicator = new BorderIndicator;
#endif
}
void OnroadWindow::updateState(const UIState &s) {
@@ -68,7 +72,12 @@ void OnroadWindow::updateState(const UIState &s) {
const SubMaster &sm = *(s.sm);
bool alka_active = sm["carControl"].getCarControl().getLatActive() && sm["controlsStateExt"].getControlsStateExt().getAlkaActive();
QColor bgColor = bg_colors[alka_active && s.status == STATUS_DISENGAGED? STATUS_ALKA : s.status];
#ifdef DP
border_indicator->update_states(s);
if (bg != bgColor || border_indicator->should_repaint()) {
#else
if (bg != bgColor) {
#endif
// repaint border
bg = bgColor;
update();
@@ -128,5 +137,13 @@ void OnroadWindow::primeChanged(bool prime) {
void OnroadWindow::paintEvent(QPaintEvent *event) {
QPainter p(this);
#ifdef DP
p.fillRect(rect(), QColor(bg.red(), bg.green(), bg.blue(), 180));
border_indicator->paint_bottom(p, QRect(0, height() - UI_BORDER_SIZE, width(), 30));
border_indicator->paint_left(p, QRect(0, 0, width()*0.2, height()));
border_indicator->paint_right(p, QRect(width()*0.8, 0, width()*0.2, height()));
#else
p.fillRect(rect(), QColor(bg.red(), bg.green(), bg.blue(), 255));
#endif
}
+5
View File
@@ -24,6 +24,11 @@ private:
QWidget *map = nullptr;
QHBoxLayout* split;
// dp
#ifdef DP
BorderIndicator *border_indicator;
#endif
private slots:
void offroadTransition(bool offroad);
void primeChanged(bool prime);