wip
This commit is contained in:
@@ -19,54 +19,46 @@
|
||||
#include "selfdrive/ui/qt/qt_window.h"
|
||||
#include "selfdrive/ui/qt/util.h"
|
||||
|
||||
|
||||
ReadyWindow::ReadyWindow(QWidget *parent) : QWidget(parent) {
|
||||
QGridLayout *layout = new QGridLayout(this);
|
||||
layout->setSpacing(0);
|
||||
layout->setMargin(0);
|
||||
QGridLayout *layout = new QGridLayout(this);
|
||||
layout->setSpacing(0);
|
||||
layout->setMargin(0);
|
||||
|
||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
|
||||
setStyleSheet(R"(
|
||||
BodyWindow {
|
||||
background-color: black;
|
||||
}
|
||||
)");
|
||||
|
||||
QObject::connect(uiState(), &UIState::uiUpdate, this, &ReadyWindow::updateState);
|
||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
setStyleSheet("ReadyWindow { background-color: black; }");
|
||||
}
|
||||
|
||||
void ReadyWindow::paintEvent(QPaintEvent *event) {
|
||||
QPainter painter(this);
|
||||
QPainter painter(this);
|
||||
QPixmap *img_shown = nullptr;
|
||||
|
||||
QPixmap comma_img = loadPixmap("/data/openpilot/selfdrive/clearpilot/theme/clearpilot/images/ready.png");
|
||||
|
||||
// Calculate the top-left position to center the image in the window.
|
||||
int x = (this->width() - comma_img.width()) / 2;
|
||||
int y = ((this->height() - comma_img.height()) / 20) * 9;
|
||||
|
||||
// Draw the pixmap at the calculated position.
|
||||
painter.drawPixmap(x, y, comma_img);
|
||||
|
||||
// TODO: Referencw widgets/offroad_alert.cc
|
||||
// std::string bytes = params.get(key);
|
||||
// if params value Offroad_TemperatureTooHigh is set with bytes > 0, then
|
||||
// temp is too high. show hot.png. Add current temp to the right of the logo.
|
||||
// otherwise, if offroad_alert widget would otherwise display, then ditch the ready.cc
|
||||
// screen and go to home.cc.
|
||||
if (is_hot) {
|
||||
if (img_hot.isNull()) {
|
||||
img_hot.load("/data/openpilot/selfdrive/clearpilot/theme/clearpilot/images/hot.png");
|
||||
}
|
||||
img_shown = &img_hot;
|
||||
} else {
|
||||
if (img_ready.isNull()) {
|
||||
img_ready.load("/data/openpilot/selfdrive/clearpilot/theme/clearpilot/images/ready.png");
|
||||
}
|
||||
img_shown = &img_ready;
|
||||
}
|
||||
|
||||
int x = (width() - img_shown->width()) / 2;
|
||||
int y = (height() - img_shown->height()) / 2;
|
||||
painter.drawPixmap(x, y, *img_shown);
|
||||
}
|
||||
|
||||
void ReadyWindow::showEvent(QShowEvent *event) {
|
||||
// refresh();
|
||||
// timer->start(120 * 1000);
|
||||
}
|
||||
|
||||
void ReadyWindow::hideEvent(QHideEvent *event) {
|
||||
// timer->stop();
|
||||
}
|
||||
|
||||
void ReadyWindow::updateState(const UIState &s) {
|
||||
}
|
||||
|
||||
void ReadyWindow::offroadTransition(bool offroad) {
|
||||
}
|
||||
void ReadyWindow::refresh() {
|
||||
std::string bytes = params.get("Offroad_TemperatureTooHigh");
|
||||
if (!bytes.empty()) {
|
||||
auto doc = QJsonDocument::fromJson(bytes.data());
|
||||
is_hot = true;
|
||||
cur_temp = doc["extra"].toString();
|
||||
update();
|
||||
} else if (is_hot) {
|
||||
is_hot = false;
|
||||
update();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user