fix offroad home on tici (#20435)

* grid layout was a hack

* duplicate slot

* looks better

* fix that

Co-authored-by: Comma Device <device@comma.ai>
old-commit-hash: 106ed2ea66
commatwo_master
Adeeb Shihadeh 4 years ago committed by GitHub
parent ae0756edc6
commit fe474a58c4
  1. 2
      SConstruct
  2. 38
      selfdrive/ui/qt/home.cc
  3. 9
      selfdrive/ui/qt/home.hpp
  4. 12
      selfdrive/ui/qt/widgets/setup.cc

@ -266,7 +266,7 @@ Export('envCython')
qt_env = env.Clone() qt_env = env.Clone()
qt_modules = ["Widgets", "Gui", "Core", "Network", "Concurrent", "Multimedia"] qt_modules = ["Widgets", "Gui", "Core", "Network", "Concurrent", "Multimedia"]
if arch != "aarch64": if arch != "aarch64":
qt_modules += ["DBus", "WebEngine", "WebEngineWidgets"] qt_modules += ["DBus"]
qt_libs = [] qt_libs = []
if arch == "Darwin": if arch == "Darwin":

@ -6,11 +6,8 @@
#include <QDateTime> #include <QDateTime>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QLayout>
#include <QMouseEvent> #include <QMouseEvent>
#include <QStackedLayout>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QWidget>
#include "common/params.h" #include "common/params.h"
#include "common/timing.h" #include "common/timing.h"
@ -31,37 +28,28 @@
// HomeWindow: the container for the offroad (OffroadHome) and onroad (GLWindow) UIs // HomeWindow: the container for the offroad (OffroadHome) and onroad (GLWindow) UIs
HomeWindow::HomeWindow(QWidget* parent) : QWidget(parent) { HomeWindow::HomeWindow(QWidget* parent) : QWidget(parent) {
layout = new QGridLayout; layout = new QStackedLayout();
layout->setMargin(0); layout->setStackingMode(QStackedLayout::StackAll);
// onroad UI // onroad UI
glWindow = new GLWindow(this); glWindow = new GLWindow(this);
layout->addWidget(glWindow, 0, 0); layout->addWidget(glWindow);
// draw offroad UI on top of onroad UI // draw offroad UI on top of onroad UI
home = new OffroadHome(); home = new OffroadHome();
layout->addWidget(home, 0, 0); layout->addWidget(home);
QObject::connect(glWindow, SIGNAL(offroadTransition(bool)), this, SLOT(setVisibility(bool))); QObject::connect(glWindow, SIGNAL(offroadTransition(bool)), home, SLOT(setVisible(bool)));
QObject::connect(glWindow, SIGNAL(offroadTransition(bool)), this, SIGNAL(offroadTransition(bool))); QObject::connect(glWindow, SIGNAL(offroadTransition(bool)), this, SIGNAL(offroadTransition(bool)));
QObject::connect(glWindow, SIGNAL(screen_shutoff()), this, SIGNAL(closeSettings())); QObject::connect(glWindow, SIGNAL(screen_shutoff()), this, SIGNAL(closeSettings()));
QObject::connect(this, SIGNAL(openSettings()), home, SLOT(refresh())); QObject::connect(this, SIGNAL(openSettings()), home, SLOT(refresh()));
setLayout(layout); setLayout(layout);
setStyleSheet(R"(
* {
color: white;
}
)");
}
void HomeWindow::setVisibility(bool offroad) {
home->setVisible(offroad);
} }
void HomeWindow::mousePressEvent(QMouseEvent* e) { void HomeWindow::mousePressEvent(QMouseEvent* e) {
UIState* ui_state = &glWindow->ui_state; UIState* ui_state = &glWindow->ui_state;
if (GLWindow::ui_state.scene.started && GLWindow::ui_state.scene.driver_view) { if (GLWindow::ui_state.scene.driver_view) {
Params().write_db_value("IsDriverViewEnabled", "0", 1); Params().write_db_value("IsDriverViewEnabled", "0", 1);
return; return;
} }
@ -73,7 +61,7 @@ void HomeWindow::mousePressEvent(QMouseEvent* e) {
emit openSettings(); emit openSettings();
} }
// Vision click // Handle sidebar collapsing
if (ui_state->scene.started && (e->x() >= ui_state->viz_rect.x - bdr_s)) { if (ui_state->scene.started && (e->x() >= ui_state->viz_rect.x - bdr_s)) {
ui_state->sidebar_collapsed = !ui_state->sidebar_collapsed; ui_state->sidebar_collapsed = !ui_state->sidebar_collapsed;
} }
@ -112,11 +100,11 @@ OffroadHome::OffroadHome(QWidget* parent) : QWidget(parent) {
DriveStats* drive = new DriveStats; DriveStats* drive = new DriveStats;
drive->setFixedSize(800, 800); drive->setFixedSize(800, 800);
statsAndSetup->addWidget(drive, 0, Qt::AlignLeft); statsAndSetup->addWidget(drive);
SetupWidget* setup = new SetupWidget; SetupWidget* setup = new SetupWidget;
setup->setFixedSize(700, 700); //setup->setFixedSize(700, 700);
statsAndSetup->addWidget(setup, 0, Qt::AlignRight); statsAndSetup->addWidget(setup);
QWidget* statsAndSetupWidget = new QWidget(); QWidget* statsAndSetupWidget = new QWidget();
statsAndSetupWidget->setLayout(statsAndSetup); statsAndSetupWidget->setLayout(statsAndSetup);
@ -137,7 +125,11 @@ OffroadHome::OffroadHome(QWidget* parent) : QWidget(parent) {
timer->start(10 * 1000); timer->start(10 * 1000);
setLayout(main_layout); setLayout(main_layout);
setStyleSheet(R"(background-color: none;)"); setStyleSheet(R"(
* {
color: white;
}
)");
} }
void OffroadHome::openAlerts() { void OffroadHome::openAlerts() {

@ -1,6 +1,5 @@
#pragma once #pragma once
#include <QGridLayout>
#include <QLabel> #include <QLabel>
#include <QOpenGLFunctions> #include <QOpenGLFunctions>
#include <QOpenGLWidget> #include <QOpenGLWidget>
@ -65,7 +64,6 @@ public:
private: private:
QTimer* timer; QTimer* timer;
// offroad home screen widgets
QLabel* date; QLabel* date;
QStackedLayout* center_layout; QStackedLayout* center_layout;
OffroadAlert* alerts_widget; OffroadAlert* alerts_widget;
@ -85,17 +83,14 @@ public:
GLWindow* glWindow; GLWindow* glWindow;
signals: signals:
void offroadTransition(bool offroad);
void openSettings(); void openSettings();
void closeSettings(); void closeSettings();
void offroadTransition(bool offroad);
protected: protected:
void mousePressEvent(QMouseEvent* e) override; void mousePressEvent(QMouseEvent* e) override;
private: private:
QGridLayout* layout;
OffroadHome* home; OffroadHome* home;
QStackedLayout* layout;
private slots:
void setVisibility(bool offroad);
}; };

@ -158,14 +158,10 @@ PrimeAdWidget::PrimeAdWidget(QWidget* parent) : QWidget(parent) {
SetupWidget::SetupWidget(QWidget* parent) : QFrame(parent) { SetupWidget::SetupWidget(QWidget* parent) : QFrame(parent) {
mainLayout = new QStackedLayout; mainLayout = new QStackedLayout;
QWidget* blankWidget = new QWidget;
//blankWidget->setStyleSheet(R"background-color: transparent;");
mainLayout->addWidget(blankWidget);
// Unpaired, registration prompt layout // Unpaired, registration prompt layout
QVBoxLayout* finishRegistationLayout = new QVBoxLayout; QVBoxLayout* finishRegistationLayout = new QVBoxLayout;
finishRegistationLayout ->setMargin(30); finishRegistationLayout->setMargin(30);
QLabel* registrationDescription = new QLabel("Pair your device with the comma connect app"); QLabel* registrationDescription = new QLabel("Pair your device with the comma connect app");
registrationDescription->setWordWrap(true); registrationDescription->setWordWrap(true);
@ -220,7 +216,7 @@ SetupWidget::SetupWidget(QWidget* parent) : QFrame(parent) {
setLayout(mainLayout); setLayout(mainLayout);
setStyleSheet(R"( setStyleSheet(R"(
QFrame { SetupWidget {
background-color: #292929; background-color: #292929;
} }
* { * {
@ -246,7 +242,7 @@ void SetupWidget::parseError(QString response) {
void SetupWidget::showQrCode(){ void SetupWidget::showQrCode(){
showQr = true; showQr = true;
mainLayout->setCurrentIndex(2); mainLayout->setCurrentIndex(1);
} }
void SetupWidget::replyFinished(QString response) { void SetupWidget::replyFinished(QString response) {
@ -261,7 +257,7 @@ void SetupWidget::replyFinished(QString response) {
bool is_prime = json["prime"].toBool(); bool is_prime = json["prime"].toBool();
if (!is_paired) { if (!is_paired) {
mainLayout->setCurrentIndex(1 + showQr); mainLayout->setCurrentIndex(showQr);
} else if (!is_prime) { } else if (!is_prime) {
showQr = false; showQr = false;
mainLayout->setCurrentWidget(primeAd); mainLayout->setCurrentWidget(primeAd);

Loading…
Cancel
Save