UI: body support (#24079)
* body ui template * faces * abs * not raw * auto switch * check that * no smoosh * cmathpull/24106/head
parent
0b9790dd24
commit
b51deb97d1
8 changed files with 74 additions and 2 deletions
After Width: | Height: | Size: 68 KiB |
After Width: | Height: | Size: 392 KiB |
@ -0,0 +1,34 @@ |
|||||||
|
#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); |
||||||
|
|
||||||
|
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(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,19 @@ |
|||||||
|
#pragma once |
||||||
|
|
||||||
|
#include <QMovie> |
||||||
|
#include <QLabel> |
||||||
|
|
||||||
|
#include "selfdrive/ui/ui.h" |
||||||
|
|
||||||
|
class BodyWindow : public QLabel { |
||||||
|
Q_OBJECT |
||||||
|
|
||||||
|
public: |
||||||
|
BodyWindow(QWidget* parent = 0); |
||||||
|
|
||||||
|
private: |
||||||
|
QMovie *awake, *sleep; |
||||||
|
|
||||||
|
private slots: |
||||||
|
void updateState(const UIState &s); |
||||||
|
}; |
Loading…
Reference in new issue