#include "selfdrive/ui/qt/home.h" #include #include #include #include #include "selfdrive/ui/qt/util.h" // HomeWindow: the container for the offroad and onroad UIs HomeWindow::HomeWindow(QWidget* parent) : QWidget(parent) { // CLEARPILOT Sidebar set to invisible in drive view. params.putBool("Sidebar", false); QHBoxLayout *main_layout = new QHBoxLayout(this); main_layout->setMargin(0); main_layout->setSpacing(0); sidebar = new Sidebar(this); main_layout->addWidget(sidebar); QObject::connect(sidebar, &Sidebar::openSettings, this, &HomeWindow::openSettings); QObject::connect(sidebar, &Sidebar::openOnroad, this, &HomeWindow::showOnroad); slayout = new QStackedLayout(); main_layout->addLayout(slayout); home = new OffroadHome(this); QObject::connect(home, &OffroadHome::openSettings, this, &HomeWindow::openSettings); slayout->addWidget(home); onroad = new OnroadWindow(this); slayout->addWidget(onroad); // CLEARPILOT ready = new ReadyWindow(this); slayout->addWidget(ready); driver_view = new DriverViewWindow(this); connect(driver_view, &DriverViewWindow::done, [=] { showDriverView(false); }); slayout->addWidget(driver_view); setAttribute(Qt::WA_NoSystemBackground); QObject::connect(uiState(), &UIState::uiUpdate, this, &HomeWindow::updateState); QObject::connect(uiState(), &UIState::offroadTransition, this, &HomeWindow::offroadTransition); QObject::connect(uiState(), &UIState::offroadTransition, sidebar, &Sidebar::offroadTransition); } // Debug function to activate onroad UI void HomeWindow::showOnroad() { sidebar->setVisible(false); slayout->setCurrentWidget(onroad); // sidebar->setVisible(params.getBool("Sidebar")); } void HomeWindow::showSidebar(bool show) { sidebar->setVisible(show); } void HomeWindow::updateState(const UIState &s) { // const SubMaster &sm = *(s.sm); if (s.scene.started) { showDriverView(s.scene.driver_camera_timer >= 10, true); } } void HomeWindow::offroadTransition(bool offroad) { if (offroad) { sidebar->setVisible(false); slayout->setCurrentWidget(ready); } else { sidebar->setVisible(false); slayout->setCurrentWidget(onroad); } } void HomeWindow::showDriverView(bool show, bool started) { if (show) { emit closeSettings(); slayout->setCurrentWidget(driver_view); sidebar->setVisible(show == false); } else { if (started) { slayout->setCurrentWidget(onroad); sidebar->setVisible(params.getBool("Sidebar")); } else { slayout->setCurrentWidget(home); sidebar->setVisible(show == false); } } } void HomeWindow::mousePressEvent(QMouseEvent* e) { // CLEARPILOT todo - tap on main goes straight to settings // Unless we click a debug widget. // CLEARPILOT - click ready shows home (no sidebar) if (!onroad->isVisible() && ready->isVisible()) { sidebar->setVisible(false); slayout->setCurrentWidget(home); } // Todo: widgets if (onroad->isVisible()) { emit openSettings(); } } void HomeWindow::mouseDoubleClickEvent(QMouseEvent* e) { HomeWindow::mousePressEvent(e); // const SubMaster &sm = *(uiState()->sm); } // CLEARPILOT: OffroadHome — clean grid launcher OffroadHome::OffroadHome(QWidget* parent) : QFrame(parent) { QVBoxLayout* main_layout = new QVBoxLayout(this); main_layout->setContentsMargins(80, 80, 80, 80); main_layout->setSpacing(0); // grid of launcher buttons QGridLayout *grid = new QGridLayout(); grid->setSpacing(40); // Dashcam viewer button QPushButton *dashcam_btn = new QPushButton("Dashcam"); dashcam_btn->setFixedSize(400, 300); dashcam_btn->setStyleSheet(R"( QPushButton { background-color: #333333; color: white; border-radius: 20px; font-size: 48px; font-weight: 600; } QPushButton:pressed { background-color: #555555; } )"); grid->addWidget(dashcam_btn, 0, 0); // Settings button QPushButton *settings_btn = new QPushButton("Settings"); settings_btn->setFixedSize(400, 300); settings_btn->setStyleSheet(R"( QPushButton { background-color: #333333; color: white; border-radius: 20px; font-size: 48px; font-weight: 600; } QPushButton:pressed { background-color: #555555; } )"); QObject::connect(settings_btn, &QPushButton::clicked, [=]() { emit openSettings(); }); grid->addWidget(settings_btn, 0, 1); main_layout->addStretch(); main_layout->addLayout(grid); main_layout->addStretch(); setStyleSheet(R"( OffroadHome { background-color: black; } )"); }