This commit is contained in:
Your Name
2024-04-28 13:21:06 -05:00
parent 784daf270a
commit dd6ead0477
11 changed files with 150 additions and 32 deletions

64
selfdrive/ui/qt/ready.cc Normal file
View File

@@ -0,0 +1,64 @@
#include "selfdrive/ui/qt/ready.h"
#include <cmath>
#include <algorithm>
#include <QPainter>
#include <QStackedLayout>
#include <QApplication>
#include <QGridLayout>
#include <QString>
#include <QTransform>
#include <QPixmap>
#include "common/params.h"
#include "common/timing.h"
#include "system/hardware/hw.h"
#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);
setAttribute(Qt::WA_OpaquePaintEvent);
setStyleSheet(R"(
BodyWindow {
background-color: black;
}
)");
QObject::connect(uiState(), &UIState::uiUpdate, this, &BodyWindow::updateState);
}
void ReadyWindow::paintEvent(QPaintEvent *event) {
QPainter painter(this);
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()) / 2;
// Draw the pixmap at the calculated position.
painter.drawPixmap(x, y, comma_img);
}
void ReadyWindow::showEvent(QShowEvent *event) {
refresh();
timer->start(180 * 1000);
}
void ReadyWindow::hideEvent(QHideEvent *event) {
timer->stop();
}
void ReadyWindow::updateState(const UIState &s) {
}
void ReadyWindow::offroadTransition(bool offroad) {
}