wip
This commit is contained in:
@@ -30,6 +30,7 @@ HomeWindow::HomeWindow(QWidget* parent) : QWidget(parent) {
|
||||
sidebar = new Sidebar(this);
|
||||
main_layout->addWidget(sidebar);
|
||||
QObject::connect(sidebar, &Sidebar::openSettings, this, &HomeWindow::openSettings);
|
||||
QObject::connect(sidebar, &Sidebar::openOnroad, this, &HomeWindow::openOnroad);
|
||||
|
||||
slayout = new QStackedLayout();
|
||||
main_layout->addLayout(slayout);
|
||||
@@ -42,9 +43,6 @@ HomeWindow::HomeWindow(QWidget* parent) : QWidget(parent) {
|
||||
QObject::connect(onroad, &OnroadWindow::mapPanelRequested, this, [=] { sidebar->hide(); });
|
||||
slayout->addWidget(onroad);
|
||||
|
||||
body = new BodyWindow(this);
|
||||
slayout->addWidget(body);
|
||||
|
||||
// CLEARPILOT
|
||||
ready = new ReadyWindow(this);
|
||||
slayout->addWidget(ready);
|
||||
@@ -62,6 +60,11 @@ HomeWindow::HomeWindow(QWidget* parent) : QWidget(parent) {
|
||||
QObject::connect(uiState(), &UIState::offroadTransition, sidebar, &Sidebar::offroadTransition);
|
||||
}
|
||||
|
||||
// Debug function to activate onroad UI
|
||||
void HomeWindow::openOnroad() {
|
||||
sidebar->setVisible(false);
|
||||
}
|
||||
|
||||
void HomeWindow::showSidebar(bool show) {
|
||||
sidebar->setVisible(show);
|
||||
}
|
||||
@@ -72,26 +75,15 @@ 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 (s.scene.started) {
|
||||
showDriverView(s.scene.driver_camera_timer >= 10, true);
|
||||
}
|
||||
}
|
||||
|
||||
void HomeWindow::offroadTransition(bool offroad) {
|
||||
body->setEnabled(false);
|
||||
if (offroad) {
|
||||
sidebar->setVisible(false);
|
||||
slayout->setCurrentWidget(ready);
|
||||
// slayout->setCurrentWidget(home);
|
||||
// this->showDriverView(true, true); // Temp
|
||||
} else {
|
||||
sidebar->setVisible(false);
|
||||
slayout->setCurrentWidget(onroad);
|
||||
@@ -119,13 +111,6 @@ void HomeWindow::mousePressEvent(QMouseEvent* e) {
|
||||
// CLEARPILOT todo - tap on main goes straight to settings
|
||||
// Unless we click a debug widget.
|
||||
|
||||
// Handle sidebar collapsing
|
||||
// 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()) {
|
||||
sidebar->setVisible(true);
|
||||
@@ -141,14 +126,6 @@ void HomeWindow::mousePressEvent(QMouseEvent* e) {
|
||||
void HomeWindow::mouseDoubleClickEvent(QMouseEvent* e) {
|
||||
HomeWindow::mousePressEvent(e);
|
||||
const SubMaster &sm = *(uiState()->sm);
|
||||
if (sm["carParams"].getCarParams().getNotCar()) {
|
||||
if (onroad->isVisible()) {
|
||||
slayout->setCurrentWidget(body);
|
||||
} else if (body->isVisible()) {
|
||||
slayout->setCurrentWidget(onroad);
|
||||
}
|
||||
showSidebar(false);
|
||||
}
|
||||
}
|
||||
|
||||
// OffroadHome: the offroad home page
|
||||
@@ -250,8 +227,10 @@ void OffroadHome::refresh() {
|
||||
date->setText(QLocale(uiState()->language.mid(5)).toString(QDateTime::currentDateTime(), "dddd, MMMM d"));
|
||||
version->setText(getBrand() + " v" + getVersion().left(14).trimmed() + " - " + model);
|
||||
|
||||
bool updateAvailable = update_widget->refresh();
|
||||
// bool updateAvailable = update_widget->refresh();
|
||||
|
||||
int alerts = alerts_widget->refresh();
|
||||
|
||||
if (alerts > 0 && !alerts_widget->isVisible()) {
|
||||
alerts_widget->setVisible(true);
|
||||
} else if (alerts == 0 && alerts_widget->isVisible()) {
|
||||
@@ -260,20 +239,19 @@ void OffroadHome::refresh() {
|
||||
|
||||
// pop-up new notification
|
||||
// CLEARPILOT temp disabled update notifications
|
||||
int idx = center_layout->currentIndex();
|
||||
if (!updateAvailable && !alerts && false) {
|
||||
idx = 0;
|
||||
} else if (updateAvailable && (!update_notif->isVisible() || (!alerts && idx == 2))) {
|
||||
idx = 1;
|
||||
} else if (alerts && (!alert_notif->isVisible() || (!updateAvailable && idx == 1))) {
|
||||
idx = 2;
|
||||
}
|
||||
center_layout->setCurrentIndex(idx);
|
||||
// int idx = center_layout->currentIndex();
|
||||
// if (!updateAvailable && !alerts && false) {
|
||||
// idx = 0;
|
||||
// } else if (updateAvailable && (!update_notif->isVisible() || (!alerts && idx == 2))) {
|
||||
// idx = 1;
|
||||
// } else if (alerts && (!alert_notif->isVisible() || (!updateAvailable && idx == 1))) {
|
||||
// idx = 2;
|
||||
// }
|
||||
// center_layout->setCurrentIndex(idx);
|
||||
|
||||
// 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")));
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#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"
|
||||
@@ -70,7 +69,6 @@ private:
|
||||
Sidebar *sidebar;
|
||||
OffroadHome *home;
|
||||
OnroadWindow *onroad;
|
||||
BodyWindow *body;
|
||||
DriverViewWindow *driver_view;
|
||||
QStackedLayout *slayout;
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ Sidebar::Sidebar(QWidget *parent) : QFrame(parent), onroad(false), flag_pressed(
|
||||
home_img = loadPixmap("../assets/images/button_home.png", home_btn.size());
|
||||
flag_img = loadPixmap("../assets/images/button_flag.png", home_btn.size());
|
||||
settings_img = loadPixmap("../assets/images/button_settings.png", settings_btn.size(), Qt::IgnoreAspectRatio);
|
||||
currentColors = QColor(255, 255, 255);
|
||||
|
||||
connect(this, &Sidebar::valueChanged, [=] { update(); });
|
||||
|
||||
@@ -49,52 +50,6 @@ Sidebar::Sidebar(QWidget *parent) : QFrame(parent), onroad(false), flag_pressed(
|
||||
isStorageLeft = params.getBool("ShowStorageLeft");
|
||||
isStorageUsed = params.getBool("ShowStorageUsed");
|
||||
|
||||
holidayThemeConfiguration = {
|
||||
{0, {"stock", {QColor(255, 255, 255)}}},
|
||||
{1, {"april_fools", {QColor(255, 165, 0)}}},
|
||||
{2, {"christmas", {QColor(0, 72, 255)}}},
|
||||
{3, {"cinco_de_mayo", {QColor(0, 104, 71)}}},
|
||||
{4, {"easter", {QColor(200, 150, 200)}}},
|
||||
{5, {"fourth_of_july", {QColor(0, 72, 255)}}},
|
||||
{6, {"halloween", {QColor(255, 0, 0)}}},
|
||||
{7, {"new_years_day", {QColor(23, 134, 68)}}},
|
||||
{8, {"st_patricks_day", {QColor(0, 128, 0)}}},
|
||||
{9, {"thanksgiving", {QColor(255, 0, 0)}}},
|
||||
{10, {"valentines_day", {QColor(23, 134, 68)}}},
|
||||
{11, {"world_frog_day", {QColor(23, 134, 68)}}},
|
||||
};
|
||||
|
||||
for (auto &[key, themeData] : holidayThemeConfiguration) {
|
||||
QString &themeName = themeData.first;
|
||||
QString base = themeName == "stock" ? "../assets/images" : QString("../frogpilot/assets/holiday_themes/%1/images").arg(themeName);
|
||||
std::vector<QString> paths = {base + "/button_home.png", base + "/button_flag.png", base + "/button_settings.png"};
|
||||
|
||||
holiday_home_imgs[key] = loadPixmap(paths[0], home_btn.size());
|
||||
holiday_flag_imgs[key] = loadPixmap(paths[1], home_btn.size());
|
||||
holiday_settings_imgs[key] = loadPixmap(paths[2], settings_btn.size(), Qt::IgnoreAspectRatio);
|
||||
}
|
||||
|
||||
themeConfiguration = {
|
||||
{0, {"stock", {QColor(255, 255, 255)}}},
|
||||
{1, {"frog_theme", {QColor(255, 255, 255)}}},
|
||||
{2, {"tesla_theme", {QColor(255, 255, 255)}}},
|
||||
{3, {"stalin_theme", {QColor(255, 255, 255)}}}
|
||||
};
|
||||
|
||||
for (auto &[key, themeData] : themeConfiguration) {
|
||||
QString &themeName = themeData.first;
|
||||
QString base = themeName == "stock" ? "../assets/images" : QString("../frogpilot/assets/custom_themes/%1/images").arg(themeName);
|
||||
std::vector<QString> paths = {base + "/button_home.png", base + "/button_flag.png", base + "/button_settings.png"};
|
||||
|
||||
home_imgs[key] = loadPixmap(paths[0], home_btn.size());
|
||||
flag_imgs[key] = loadPixmap(paths[1], home_btn.size());
|
||||
settings_imgs[key] = loadPixmap(paths[2], settings_btn.size(), Qt::IgnoreAspectRatio);
|
||||
}
|
||||
|
||||
home_img = home_imgs[scene.custom_icons];
|
||||
flag_img = flag_imgs[scene.custom_icons];
|
||||
settings_img = settings_imgs[scene.custom_icons];
|
||||
currentColors = themeConfiguration[scene.custom_colors].second;
|
||||
}
|
||||
|
||||
void Sidebar::mousePressEvent(QMouseEvent *event) {
|
||||
@@ -163,9 +118,14 @@ void Sidebar::mouseReleaseEvent(QMouseEvent *event) {
|
||||
update();
|
||||
}
|
||||
if (home_btn.contains(event->pos())) {
|
||||
|
||||
// ?? remove?
|
||||
MessageBuilder msg;
|
||||
msg.initEvent().initUserFlag();
|
||||
pm->send("userFlag", msg);
|
||||
|
||||
emit openOnroad();
|
||||
|
||||
} else if (settings_btn.contains(event->pos())) {
|
||||
emit openSettings();
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ public:
|
||||
|
||||
signals:
|
||||
void openSettings(int index = 0, const QString ¶m = "");
|
||||
void openOnroad(int index = 0, const QString ¶m = "");
|
||||
void valueChanged();
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -30,6 +30,7 @@ typedef enum UIStatus {
|
||||
STATUS_TRAFFIC_MODE_ACTIVE,
|
||||
STATUS_EXPERIMENTAL_ACTIVE,
|
||||
CENTER_LANE_COLOR,
|
||||
CHANGE_LANE_PATH_COLOR,
|
||||
} UIStatus;
|
||||
|
||||
// Clearpilot new alpha constants
|
||||
@@ -39,16 +40,18 @@ const float OTHER_LANE_ALPHA = 0.75;
|
||||
const int CENTER_LANE_WIDTH = 70;
|
||||
const int OTHER_LANE_WIDTH = 16;
|
||||
|
||||
const ACTIVE_COLOR = QColor(189, 199, 252, 0xd1);
|
||||
|
||||
// Clearpilot custom colors
|
||||
const QColor bg_colors [] = {
|
||||
[STATUS_DISENGAGED] = QColor(0x17, 0x33, 0x49, 0xc8),
|
||||
[STATUS_OVERRIDE] = QColor(94, 112, 255, 0xd1),
|
||||
[STATUS_ENGAGED] = QColor(76, 97, 255, 0xd1),
|
||||
[STATUS_ALWAYS_ON_LATERAL_ACTIVE] = QColor(209, 215, 250, 0xd1),
|
||||
// [STATUS_ALWAYS_ON_LATERAL_ACTIVE] = QColor(184, 193, 255, 0xd1),
|
||||
[STATUS_TRAFFIC_MODE_ACTIVE] = QColor(0xc9, 0x22, 0x31, 0xd1), // ? unused?
|
||||
[STATUS_EXPERIMENTAL_ACTIVE] = QColor(201, 41, 204, 0xd1), // Magenta
|
||||
[CENTER_LANE_COLOR] = QColor(150, 150, 150, 0xd1), // Gray
|
||||
[STATUS_OVERRIDE] = ACTIVE_COLOR,
|
||||
[STATUS_ENGAGED] = ACTIVE_COLOR,
|
||||
[STATUS_ALWAYS_ON_LATERAL_ACTIVE] = ACTIVE_COLOR,
|
||||
[STATUS_TRAFFIC_MODE_ACTIVE] = ACTIVE_COLOR,
|
||||
[STATUS_EXPERIMENTAL_ACTIVE] = QColor(201, 41, 204, 0xd1),
|
||||
[CENTER_LANE_COLOR] = QColor(150, 150, 150, 0xd1),
|
||||
[CHANGE_LANE_PATH_COLOR] = QColor(245, 241, 93, 0xd1),
|
||||
};
|
||||
|
||||
static std::map<cereal::ControlsState::AlertStatus, QColor> alert_colors = {
|
||||
|
||||
Reference in New Issue
Block a user