mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-03 20:42:09 +08:00
6371a16f4e
* UI: double click to switch between body and onroad views * fix that * Update selfdrive/ui/qt/home.cc Co-authored-by: Comma Device <device@comma.ai> old-commit-hash: 639255bd10e8cf00ccb1c3ef4bc6b47c9a5cb7fb
37 lines
913 B
C++
37 lines
913 B
C++
#include "selfdrive/ui/qt/body.h"
|
|
|
|
#include <cmath>
|
|
|
|
BodyWindow::BodyWindow(QWidget *parent) : QLabel(parent) {
|
|
awake = new QMovie("../assets/body/awake.gif");
|
|
awake->setCacheMode(QMovie::CacheAll);
|
|
sleep = new QMovie("../assets/body/sleep.gif");
|
|
sleep->setCacheMode(QMovie::CacheAll);
|
|
|
|
QPalette p(Qt::black);
|
|
setPalette(p);
|
|
setAutoFillBackground(true);
|
|
|
|
setAlignment(Qt::AlignCenter);
|
|
|
|
setAttribute(Qt::WA_TransparentForMouseEvents, true);
|
|
|
|
QObject::connect(uiState(), &UIState::uiUpdate, this, &BodyWindow::updateState);
|
|
}
|
|
|
|
void BodyWindow::updateState(const UIState &s) {
|
|
if (!isVisible()) {
|
|
return;
|
|
}
|
|
|
|
const SubMaster &sm = *(s.sm);
|
|
|
|
// TODO: use carState.standstill when that's fixed
|
|
const bool standstill = std::abs(sm["carState"].getCarState().getVEgo()) < 0.01;
|
|
QMovie *m = standstill ? sleep : awake;
|
|
if (m != movie()) {
|
|
setMovie(m);
|
|
movie()->start();
|
|
}
|
|
}
|