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

View File

@@ -39,6 +39,11 @@ HomeWindow::HomeWindow(QWidget* parent) : QWidget(parent) {
body = new BodyWindow(this);
slayout->addWidget(body);
// CLEARPILOT
// show_ready = true;
ready = new ReadyWindow(this);
slayout->addWidget(ready);
driver_view = new DriverViewWindow(this);
connect(driver_view, &DriverViewWindow::done, [=] {
showDriverView(false);
@@ -61,11 +66,12 @@ void HomeWindow::showMapPanel(bool show) {
void HomeWindow::updateState(const UIState &s) {
const SubMaster &sm = *(s.sm);
// CLEARPILOT
// switch to the generic robot UI
if (onroad->isVisible() && !body->isEnabled() && sm["carParams"].getCarParams().getNotCar()) {
body->setEnabled(true);
slayout->setCurrentWidget(body);
}
// if (onroad->isVisible() && !body->isEnabled() && sm["carParams"].getCarParams().getNotCar()) {
// body->setEnabled(true);
// slayout->setCurrentWidget(body);
// }
if (s.scene.started) {
showDriverView(s.scene.driver_camera_timer >= 10, true);
@@ -76,7 +82,8 @@ void HomeWindow::offroadTransition(bool offroad) {
body->setEnabled(false);
sidebar->setVisible(offroad);
if (offroad) {
slayout->setCurrentWidget(home);
slayout->setCurrentWidget(ready);
// slayout->setCurrentWidget(home);
} else {
slayout->setCurrentWidget(onroad);
uiState()->scene.map_open = onroad->isMapVisible();
@@ -101,11 +108,18 @@ void HomeWindow::showDriverView(bool show, bool started) {
void HomeWindow::mousePressEvent(QMouseEvent* e) {
// Handle sidebar collapsing
// CLEARPILOT todo - tap on main goes straight to settings
// Unless we click a debug widget.
if ((onroad->isVisible() || body->isVisible()) && (!sidebar->isVisible() || e->x() > sidebar->width())) {
sidebar->setVisible(!sidebar->isVisible() && !onroad->isMapVisible());
uiState()->scene.map_open = onroad->isMapVisible();
params.putBool("Sidebar", sidebar->isVisible());
}
// CLEARPILOT - click ready shows home
if (!onroad->isVisible() && ready->isVisible()) {
slayout->setCurrentWidget(home);
}
}
void HomeWindow::mouseDoubleClickEvent(QMouseEvent* e) {
@@ -234,7 +248,8 @@ OffroadHome::OffroadHome(QWidget* parent) : QFrame(parent) {
void OffroadHome::showEvent(QShowEvent *event) {
refresh();
timer->start(10 * 1000);
// CLEARPILOT changed timeout to 2 min
timer->start(120 * 1000);
}
void OffroadHome::hideEvent(QHideEvent *event) {
@@ -251,8 +266,9 @@ void OffroadHome::refresh() {
int alerts = alerts_widget->refresh();
// pop-up new notification
// CLEARPILOT temp disabled update notifications
int idx = center_layout->currentIndex();
if (!updateAvailable && !alerts) {
if (!updateAvailable && !alerts && false) {
idx = 0;
} else if (updateAvailable && (!update_notif->isVisible() || (!alerts && idx == 2))) {
idx = 1;
@@ -261,8 +277,11 @@ void OffroadHome::refresh() {
}
center_layout->setCurrentIndex(idx);
update_notif->setVisible(updateAvailable);
alert_notif->setVisible(alerts);
// CLEARPILOT temp disabled update notifications
// update_notif->setVisible(updateAvailable);
// alert_notif->setVisible(alerts);
update_notif->setVisible(false);
alert_notif->setVisible(false);
if (alerts) {
alert_notif->setText(QString::number(alerts) + (alerts > 1 ? tr(" ALERTS") : tr(" ALERT")));
}

View File

@@ -10,6 +10,7 @@
#include "common/params.h"
#include "selfdrive/ui/qt/offroad/driverview.h"
#include "selfdrive/ui/qt/body.h"
#include "selfdrive/ui/qt/ready.h"
#include "selfdrive/ui/qt/onroad.h"
#include "selfdrive/ui/qt/sidebar.h"
#include "selfdrive/ui/qt/widgets/controls.h"
@@ -75,6 +76,10 @@ private:
// FrogPilot variables
Params params;
// CLEARPILOT
// bool show_ready;
ReadyWindow *ready;
private slots:
void updateState(const UIState &s);
};

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) {
}

30
selfdrive/ui/qt/ready.h Normal file
View File

@@ -0,0 +1,30 @@
#pragma once
#include <QMovie>
#include <QLabel>
#include <QPushButton>
#include <QPixmap>
#include <QProgressBar>
#include <QSocketNotifier>
#include <QVariantAnimation>
#include <QWidget>
#include <QTimer>
#include "common/util.h"
#include "selfdrive/ui/ui.h"
class ReadyWindow : public QWidget {
Q_OBJECT
public:
BodyWindow(QWidget* parent = 0);
private:
void paintEvent(QPaintEvent*) override;
private slots:
void updateState(const UIState &s);
void offroadTransition(bool onroad);
void showEvent(QShowEvent *event) override;
void hideEvent(QHideEvent *event) override;
void refresh();
QTimer* timer;
};