UI widgets: remove unnecessary setLayout (#21232)

* remove setlayout

* remove setLayout

* space

* Update selfdrive/ui/qt/maps/map.cc

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
pull/21244/head^2
Dean Lee 4 years ago committed by GitHub
parent af8d417627
commit 8f5c7e7bb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      selfdrive/ui/qt/home.cc
  2. 29
      selfdrive/ui/qt/maps/map.cc
  3. 9
      selfdrive/ui/qt/maps/map_settings.cc
  4. 66
      selfdrive/ui/qt/offroad/networking.cc
  5. 4
      selfdrive/ui/qt/offroad/networking.h
  6. 6
      selfdrive/ui/qt/offroad/onboarding.cc
  7. 46
      selfdrive/ui/qt/offroad/settings.cc
  8. 15
      selfdrive/ui/qt/onroad.cc
  9. 2
      selfdrive/ui/qt/onroad.h
  10. 11
      selfdrive/ui/qt/setup/reset.cc
  11. 25
      selfdrive/ui/qt/setup/setup.cc
  12. 8
      selfdrive/ui/qt/setup/wifi.cc
  13. 3
      selfdrive/ui/qt/spinner.cc
  14. 9
      selfdrive/ui/qt/text.cc
  15. 9
      selfdrive/ui/qt/widgets/controls.cc
  16. 1
      selfdrive/ui/qt/widgets/drive_stats.cc
  17. 25
      selfdrive/ui/qt/widgets/input.cc
  18. 4
      selfdrive/ui/qt/widgets/input.h
  19. 16
      selfdrive/ui/qt/widgets/keyboard.cc
  20. 16
      selfdrive/ui/qt/widgets/offroad_alerts.cc
  21. 37
      selfdrive/ui/qt/widgets/setup.cc
  22. 3
      selfdrive/ui/qt/window.cc

@ -16,17 +16,17 @@
// HomeWindow: the container for the offroad and onroad UIs // HomeWindow: the container for the offroad and onroad UIs
HomeWindow::HomeWindow(QWidget* parent) : QWidget(parent) { HomeWindow::HomeWindow(QWidget* parent) : QWidget(parent) {
QHBoxLayout *layout = new QHBoxLayout(this); QHBoxLayout *main_layout = new QHBoxLayout(this);
layout->setMargin(0); main_layout->setMargin(0);
layout->setSpacing(0); main_layout->setSpacing(0);
sidebar = new Sidebar(this); sidebar = new Sidebar(this);
layout->addWidget(sidebar); main_layout->addWidget(sidebar);
QObject::connect(this, &HomeWindow::update, sidebar, &Sidebar::updateState); QObject::connect(this, &HomeWindow::update, sidebar, &Sidebar::updateState);
QObject::connect(sidebar, &Sidebar::openSettings, this, &HomeWindow::openSettings); QObject::connect(sidebar, &Sidebar::openSettings, this, &HomeWindow::openSettings);
slayout = new QStackedLayout(); slayout = new QStackedLayout();
layout->addLayout(slayout); main_layout->addLayout(slayout);
onroad = new OnroadWindow(this); onroad = new OnroadWindow(this);
slayout->addWidget(onroad); slayout->addWidget(onroad);
@ -43,8 +43,6 @@ HomeWindow::HomeWindow(QWidget* parent) : QWidget(parent) {
showDriverView(false); showDriverView(false);
}); });
slayout->addWidget(driver_view); slayout->addWidget(driver_view);
setLayout(layout);
} }
void HomeWindow::offroadTransition(bool offroad) { void HomeWindow::offroadTransition(bool offroad) {
@ -88,7 +86,7 @@ void HomeWindow::mousePressEvent(QMouseEvent* e) {
// OffroadHome: the offroad home page // OffroadHome: the offroad home page
OffroadHome::OffroadHome(QWidget* parent) : QFrame(parent) { OffroadHome::OffroadHome(QWidget* parent) : QFrame(parent) {
QVBoxLayout* main_layout = new QVBoxLayout(); QVBoxLayout* main_layout = new QVBoxLayout(this);
main_layout->setMargin(50); main_layout->setMargin(50);
// top header // top header
@ -140,7 +138,6 @@ OffroadHome::OffroadHome(QWidget* parent) : QFrame(parent) {
QObject::connect(timer, &QTimer::timeout, this, &OffroadHome::refresh); QObject::connect(timer, &QTimer::timeout, this, &OffroadHome::refresh);
timer->start(10 * 1000); timer->start(10 * 1000);
setLayout(main_layout);
setStyleSheet(R"( setStyleSheet(R"(
OffroadHome { OffroadHome {
background-color: black; background-color: black;

@ -441,18 +441,19 @@ void MapWindow::offroadTransition(bool offroad) {
} }
MapInstructions::MapInstructions(QWidget * parent) : QWidget(parent) { MapInstructions::MapInstructions(QWidget * parent) : QWidget(parent) {
QHBoxLayout *layout_outer = new QHBoxLayout; QHBoxLayout *main_layout = new QHBoxLayout(this);
layout_outer->setContentsMargins(11, 50, 11, 11); main_layout->setContentsMargins(11, 50, 11, 11);
{ {
QVBoxLayout *layout = new QVBoxLayout; QVBoxLayout *layout = new QVBoxLayout;
icon_01 = new QLabel; icon_01 = new QLabel;
layout->addWidget(icon_01); layout->addWidget(icon_01);
layout->addStretch(); layout->addStretch();
layout_outer->addLayout(layout); main_layout->addLayout(layout);
} }
{ {
QVBoxLayout *layout = new QVBoxLayout; QWidget *w = new QWidget;
QVBoxLayout *layout = new QVBoxLayout(w);
distance = new QLabel; distance = new QLabel;
distance->setStyleSheet(R"(font-size: 75px; )"); distance->setStyleSheet(R"(font-size: 75px; )");
@ -471,12 +472,9 @@ MapInstructions::MapInstructions(QWidget * parent) : QWidget(parent) {
lane_layout = new QHBoxLayout; lane_layout = new QHBoxLayout;
layout->addLayout(lane_layout); layout->addLayout(lane_layout);
QWidget * w = new QWidget; main_layout->addWidget(w);
w->setLayout(layout);
layout_outer->addWidget(w);
} }
setLayout(layout_outer);
setStyleSheet(R"( setStyleSheet(R"(
* { * {
color: white; color: white;
@ -608,8 +606,8 @@ void MapInstructions::updateInstructions(QMap<QString, QVariant> banner, bool fu
} }
MapETA::MapETA(QWidget * parent) : QWidget(parent) { MapETA::MapETA(QWidget * parent) : QWidget(parent) {
QHBoxLayout *layout_outer = new QHBoxLayout; QHBoxLayout *main_layout = new QHBoxLayout(this);
layout_outer->setContentsMargins(20, 25, 20, 25); main_layout->setContentsMargins(20, 25, 20, 25);
{ {
QVBoxLayout *layout = new QVBoxLayout; QVBoxLayout *layout = new QVBoxLayout;
@ -623,9 +621,9 @@ MapETA::MapETA(QWidget * parent) : QWidget(parent) {
layout->addWidget(eta); layout->addWidget(eta);
layout->addWidget(eta_unit); layout->addWidget(eta_unit);
layout->addStretch(); layout->addStretch();
layout_outer->addLayout(layout); main_layout->addLayout(layout);
} }
layout_outer->addSpacing(30); main_layout->addSpacing(30);
{ {
QVBoxLayout *layout = new QVBoxLayout; QVBoxLayout *layout = new QVBoxLayout;
time = new QLabel; time = new QLabel;
@ -638,9 +636,9 @@ MapETA::MapETA(QWidget * parent) : QWidget(parent) {
layout->addWidget(time); layout->addWidget(time);
layout->addWidget(time_unit); layout->addWidget(time_unit);
layout->addStretch(); layout->addStretch();
layout_outer->addLayout(layout); main_layout->addLayout(layout);
} }
layout_outer->addSpacing(30); main_layout->addSpacing(30);
{ {
QVBoxLayout *layout = new QVBoxLayout; QVBoxLayout *layout = new QVBoxLayout;
distance = new QLabel; distance = new QLabel;
@ -652,10 +650,9 @@ MapETA::MapETA(QWidget * parent) : QWidget(parent) {
layout->addWidget(distance); layout->addWidget(distance);
layout->addWidget(distance_unit); layout->addWidget(distance_unit);
layout->addStretch(); layout->addStretch();
layout_outer->addLayout(layout); main_layout->addLayout(layout);
} }
setLayout(layout_outer);
setStyleSheet(R"( setStyleSheet(R"(
* { * {
color: white; color: white;

@ -4,17 +4,16 @@
MapPanel::MapPanel(QWidget* parent) : QWidget(parent) { MapPanel::MapPanel(QWidget* parent) : QWidget(parent) {
QVBoxLayout *layout = new QVBoxLayout; QVBoxLayout *main_layout = new QVBoxLayout(this);
Params params = Params(); Params params = Params();
QString dongle = QString::fromStdString(params.get("DongleId", false)); QString dongle = QString::fromStdString(params.get("DongleId", false));
// TODO: Add buttons for home/work shortcuts // TODO: Add buttons for home/work shortcuts
layout->addWidget(new ParamControl("NavSettingTime24h", main_layout->addWidget(new ParamControl("NavSettingTime24h",
"Show ETA in 24h format", "Show ETA in 24h format",
"Use 24h format instead of am/pm", "Use 24h format instead of am/pm",
"", "",
this)); this));
layout->addStretch(); main_layout->addStretch();
setLayout(layout); }
}

@ -24,14 +24,13 @@ void NetworkStrengthWidget::paintEvent(QPaintEvent* event) {
// Networking functions // Networking functions
Networking::Networking(QWidget* parent, bool show_advanced) : QWidget(parent), show_advanced(show_advanced) { Networking::Networking(QWidget* parent, bool show_advanced) : QWidget(parent), show_advanced(show_advanced) {
s = new QStackedLayout; main_layout = new QStackedLayout(this);
QLabel* warning = new QLabel("Network manager is inactive!"); QLabel* warning = new QLabel("Network manager is inactive!");
warning->setAlignment(Qt::AlignCenter); warning->setAlignment(Qt::AlignCenter);
warning->setStyleSheet(R"(font-size: 65px;)"); warning->setStyleSheet(R"(font-size: 65px;)");
s->addWidget(warning); main_layout->addWidget(warning);
setLayout(s);
QTimer* timer = new QTimer(this); QTimer* timer = new QTimer(this);
QObject::connect(timer, &QTimer::timeout, this, &Networking::refresh); QObject::connect(timer, &QTimer::timeout, this, &Networking::refresh);
@ -49,13 +48,13 @@ void Networking::attemptInitialization() {
connect(wifi, &WifiManager::wrongPassword, this, &Networking::wrongPassword); connect(wifi, &WifiManager::wrongPassword, this, &Networking::wrongPassword);
QVBoxLayout* vlayout = new QVBoxLayout; QWidget* wifiScreen = new QWidget(this);
QVBoxLayout* vlayout = new QVBoxLayout(wifiScreen);
if (show_advanced) { if (show_advanced) {
QPushButton* advancedSettings = new QPushButton("Advanced"); QPushButton* advancedSettings = new QPushButton("Advanced");
advancedSettings->setStyleSheet("margin-right: 30px;"); advancedSettings->setStyleSheet("margin-right: 30px;");
advancedSettings->setFixedSize(350, 100); advancedSettings->setFixedSize(350, 100);
connect(advancedSettings, &QPushButton::released, [=]() { s->setCurrentWidget(an); }); connect(advancedSettings, &QPushButton::released, [=]() { main_layout->setCurrentWidget(an); });
vlayout->addSpacing(10); vlayout->addSpacing(10);
vlayout->addWidget(advancedSettings, 0, Qt::AlignRight); vlayout->addWidget(advancedSettings, 0, Qt::AlignRight);
vlayout->addSpacing(10); vlayout->addSpacing(10);
@ -65,13 +64,11 @@ void Networking::attemptInitialization() {
connect(wifiWidget, &WifiUI::connectToNetwork, this, &Networking::connectToNetwork); connect(wifiWidget, &WifiUI::connectToNetwork, this, &Networking::connectToNetwork);
vlayout->addWidget(new ScrollView(wifiWidget, this), 1); vlayout->addWidget(new ScrollView(wifiWidget, this), 1);
QWidget* wifiScreen = new QWidget(this); main_layout->addWidget(wifiScreen);
wifiScreen->setLayout(vlayout);
s->addWidget(wifiScreen);
an = new AdvancedNetworking(this, wifi); an = new AdvancedNetworking(this, wifi);
connect(an, &AdvancedNetworking::backPress, [=]() { s->setCurrentWidget(wifiScreen); }); connect(an, &AdvancedNetworking::backPress, [=]() { main_layout->setCurrentWidget(wifiScreen); });
s->addWidget(an); main_layout->addWidget(an);
setStyleSheet(R"( setStyleSheet(R"(
QPushButton { QPushButton {
@ -88,7 +85,7 @@ void Networking::attemptInitialization() {
background-color: #222222; background-color: #222222;
} }
)"); )");
s->setCurrentWidget(wifiScreen); main_layout->setCurrentWidget(wifiScreen);
ui_setup_complete = true; ui_setup_complete = true;
} }
@ -129,21 +126,21 @@ void Networking::wrongPassword(const QString &ssid) {
AdvancedNetworking::AdvancedNetworking(QWidget* parent, WifiManager* wifi): QWidget(parent), wifi(wifi) { AdvancedNetworking::AdvancedNetworking(QWidget* parent, WifiManager* wifi): QWidget(parent), wifi(wifi) {
QVBoxLayout* vlayout = new QVBoxLayout; QVBoxLayout* main_layout = new QVBoxLayout(this);
vlayout->setMargin(40); main_layout->setMargin(40);
vlayout->setSpacing(20); main_layout->setSpacing(20);
// Back button // Back button
QPushButton* back = new QPushButton("Back"); QPushButton* back = new QPushButton("Back");
back->setFixedSize(500, 100); back->setFixedSize(500, 100);
connect(back, &QPushButton::released, [=]() { emit backPress(); }); connect(back, &QPushButton::released, [=]() { emit backPress(); });
vlayout->addWidget(back, 0, Qt::AlignLeft); main_layout->addWidget(back, 0, Qt::AlignLeft);
// Enable tethering layout // Enable tethering layout
ToggleControl *tetheringToggle = new ToggleControl("Enable Tethering", "", "", wifi->tetheringEnabled()); ToggleControl *tetheringToggle = new ToggleControl("Enable Tethering", "", "", wifi->tetheringEnabled());
vlayout->addWidget(tetheringToggle); main_layout->addWidget(tetheringToggle);
QObject::connect(tetheringToggle, &ToggleControl::toggleFlipped, this, &AdvancedNetworking::toggleTethering); QObject::connect(tetheringToggle, &ToggleControl::toggleFlipped, this, &AdvancedNetworking::toggleTethering);
vlayout->addWidget(horizontal_line(), 0); main_layout->addWidget(horizontal_line(), 0);
// Change tethering password // Change tethering password
editPasswordButton = new ButtonControl("Tethering Password", "EDIT", "", [=]() { editPasswordButton = new ButtonControl("Tethering Password", "EDIT", "", [=]() {
@ -152,21 +149,20 @@ AdvancedNetworking::AdvancedNetworking(QWidget* parent, WifiManager* wifi): QWid
wifi->changeTetheringPassword(pass); wifi->changeTetheringPassword(pass);
} }
}); });
vlayout->addWidget(editPasswordButton, 0); main_layout->addWidget(editPasswordButton, 0);
vlayout->addWidget(horizontal_line(), 0); main_layout->addWidget(horizontal_line(), 0);
// IP address // IP address
ipLabel = new LabelControl("IP Address", wifi->ipv4_address); ipLabel = new LabelControl("IP Address", wifi->ipv4_address);
vlayout->addWidget(ipLabel, 0); main_layout->addWidget(ipLabel, 0);
vlayout->addWidget(horizontal_line(), 0); main_layout->addWidget(horizontal_line(), 0);
// SSH keys // SSH keys
vlayout->addWidget(new SshToggle()); main_layout->addWidget(new SshToggle());
vlayout->addWidget(horizontal_line(), 0); main_layout->addWidget(horizontal_line(), 0);
vlayout->addWidget(new SshControl()); main_layout->addWidget(new SshControl());
vlayout->addStretch(1); main_layout->addStretch(1);
setLayout(vlayout);
} }
void AdvancedNetworking::refresh() { void AdvancedNetworking::refresh() {
@ -187,21 +183,19 @@ void AdvancedNetworking::toggleTethering(bool enable) {
// WifiUI functions // WifiUI functions
WifiUI::WifiUI(QWidget *parent, WifiManager* wifi) : QWidget(parent), wifi(wifi) { WifiUI::WifiUI(QWidget *parent, WifiManager* wifi) : QWidget(parent), wifi(wifi) {
vlayout = new QVBoxLayout; main_layout = new QVBoxLayout(this);
// Scan on startup // Scan on startup
QLabel *scanning = new QLabel("Scanning for networks"); QLabel *scanning = new QLabel("Scanning for networks");
scanning->setStyleSheet(R"(font-size: 65px;)"); scanning->setStyleSheet(R"(font-size: 65px;)");
vlayout->addWidget(scanning, 0, Qt::AlignCenter); main_layout->addWidget(scanning, 0, Qt::AlignCenter);
vlayout->setSpacing(25); main_layout->setSpacing(25);
setLayout(vlayout);
} }
void WifiUI::refresh() { void WifiUI::refresh() {
wifi->request_scan(); wifi->request_scan();
wifi->refreshNetworks(); wifi->refreshNetworks();
clearLayout(vlayout); clearLayout(main_layout);
connectButtons = new QButtonGroup(this); // TODO check if this is a leak connectButtons = new QButtonGroup(this); // TODO check if this is a leak
QObject::connect(connectButtons, qOverload<QAbstractButton*>(&QButtonGroup::buttonClicked), this, &WifiUI::handleButton); QObject::connect(connectButtons, qOverload<QAbstractButton*>(&QButtonGroup::buttonClicked), this, &WifiUI::handleButton);
@ -227,14 +221,14 @@ void WifiUI::refresh() {
connectButtons->addButton(btn, i); connectButtons->addButton(btn, i);
vlayout->addLayout(hlayout, 1); main_layout->addLayout(hlayout, 1);
// Don't add the last horizontal line // Don't add the last horizontal line
if (i+1 < wifi->seen_networks.size()) { if (i+1 < wifi->seen_networks.size()) {
vlayout->addWidget(horizontal_line(), 0); main_layout->addWidget(horizontal_line(), 0);
} }
i++; i++;
} }
vlayout->addStretch(3); main_layout->addStretch(3);
} }
void WifiUI::handleButton(QAbstractButton* button) { void WifiUI::handleButton(QAbstractButton* button) {

@ -30,7 +30,7 @@ public:
private: private:
WifiManager *wifi = nullptr; WifiManager *wifi = nullptr;
QVBoxLayout *vlayout; QVBoxLayout* main_layout;
QButtonGroup *connectButtons; QButtonGroup *connectButtons;
bool tetheringEnabled; bool tetheringEnabled;
@ -68,7 +68,7 @@ public:
explicit Networking(QWidget* parent = 0, bool show_advanced = true); explicit Networking(QWidget* parent = 0, bool show_advanced = true);
private: private:
QStackedLayout* s = nullptr; // nm_warning, wifiScreen, advanced QStackedLayout* main_layout = nullptr; // nm_warning, wifiScreen, advanced
QWidget* wifiScreen = nullptr; QWidget* wifiScreen = nullptr;
AdvancedNetworking* an = nullptr; AdvancedNetworking* an = nullptr;
bool ui_setup_complete = false; bool ui_setup_complete = false;

@ -58,7 +58,7 @@ void TermsPage::showEvent(QShowEvent *event) {
return; return;
} }
QVBoxLayout *main_layout = new QVBoxLayout; QVBoxLayout *main_layout = new QVBoxLayout(this);
main_layout->setMargin(40); main_layout->setMargin(40);
main_layout->setSpacing(40); main_layout->setSpacing(40);
@ -93,7 +93,6 @@ void TermsPage::showEvent(QShowEvent *event) {
buttons->addWidget(accept_btn); buttons->addWidget(accept_btn);
QObject::connect(accept_btn, &QPushButton::released, this, &TermsPage::acceptedTerms); QObject::connect(accept_btn, &QPushButton::released, this, &TermsPage::acceptedTerms);
setLayout(main_layout);
setStyleSheet(R"( setStyleSheet(R"(
QPushButton { QPushButton {
padding: 50px; padding: 50px;
@ -115,7 +114,7 @@ void DeclinePage::showEvent(QShowEvent *event) {
return; return;
} }
QVBoxLayout *main_layout = new QVBoxLayout; QVBoxLayout *main_layout = new QVBoxLayout(this);
main_layout->setMargin(40); main_layout->setMargin(40);
main_layout->setSpacing(40); main_layout->setSpacing(40);
@ -143,7 +142,6 @@ void DeclinePage::showEvent(QShowEvent *event) {
} }
}); });
setLayout(main_layout);
setStyleSheet(R"( setStyleSheet(R"(
QPushButton { QPushButton {
padding: 50px; padding: 50px;

@ -24,7 +24,7 @@
#include "selfdrive/ui/qt/util.h" #include "selfdrive/ui/qt/util.h"
TogglesPanel::TogglesPanel(QWidget *parent) : QWidget(parent) { TogglesPanel::TogglesPanel(QWidget *parent) : QWidget(parent) {
QVBoxLayout *toggles_list = new QVBoxLayout(); QVBoxLayout *main_layout = new QVBoxLayout(this);
QList<ParamControl*> toggles; QList<ParamControl*> toggles;
@ -93,25 +93,23 @@ TogglesPanel::TogglesPanel(QWidget *parent) : QWidget(parent) {
record_toggle->setEnabled(!record_lock); record_toggle->setEnabled(!record_lock);
for(ParamControl *toggle : toggles) { for(ParamControl *toggle : toggles) {
if(toggles_list->count() != 0) { if(main_layout->count() != 0) {
toggles_list->addWidget(horizontal_line()); main_layout->addWidget(horizontal_line());
} }
toggles_list->addWidget(toggle); main_layout->addWidget(toggle);
} }
setLayout(toggles_list);
} }
DevicePanel::DevicePanel(QWidget* parent) : QWidget(parent) { DevicePanel::DevicePanel(QWidget* parent) : QWidget(parent) {
QVBoxLayout *device_layout = new QVBoxLayout; QVBoxLayout *main_layout = new QVBoxLayout(this);
Params params = Params(); Params params = Params();
QString dongle = QString::fromStdString(params.get("DongleId", false)); QString dongle = QString::fromStdString(params.get("DongleId", false));
device_layout->addWidget(new LabelControl("Dongle ID", dongle)); main_layout->addWidget(new LabelControl("Dongle ID", dongle));
device_layout->addWidget(horizontal_line()); main_layout->addWidget(horizontal_line());
QString serial = QString::fromStdString(params.get("HardwareSerial", false)); QString serial = QString::fromStdString(params.get("HardwareSerial", false));
device_layout->addWidget(new LabelControl("Serial", serial)); main_layout->addWidget(new LabelControl("Serial", serial));
// offroad-only buttons // offroad-only buttons
QList<ButtonControl*> offroad_btns; QList<ButtonControl*> offroad_btns;
@ -164,9 +162,9 @@ DevicePanel::DevicePanel(QWidget* parent) : QWidget(parent) {
}, "", this)); }, "", this));
for(auto &btn : offroad_btns) { for(auto &btn : offroad_btns) {
device_layout->addWidget(horizontal_line()); main_layout->addWidget(horizontal_line());
QObject::connect(parent, SIGNAL(offroadTransition(bool)), btn, SLOT(setEnabled(bool))); QObject::connect(parent, SIGNAL(offroadTransition(bool)), btn, SLOT(setEnabled(bool)));
device_layout->addWidget(btn); main_layout->addWidget(btn);
} }
// power buttons // power buttons
@ -190,9 +188,8 @@ DevicePanel::DevicePanel(QWidget* parent) : QWidget(parent) {
} }
}); });
device_layout->addLayout(power_layout); main_layout->addLayout(power_layout);
setLayout(device_layout);
setStyleSheet(R"( setStyleSheet(R"(
QPushButton { QPushButton {
padding: 0; padding: 0;
@ -204,8 +201,7 @@ DevicePanel::DevicePanel(QWidget* parent) : QWidget(parent) {
} }
SoftwarePanel::SoftwarePanel(QWidget* parent) : QWidget(parent) { SoftwarePanel::SoftwarePanel(QWidget* parent) : QWidget(parent) {
QVBoxLayout *main_layout = new QVBoxLayout(this); setLayout(new QVBoxLayout());
setLayout(main_layout);
setStyleSheet(R"(QLabel {font-size: 50px;})"); setStyleSheet(R"(QLabel {font-size: 50px;})");
fs_watch = new QFileSystemWatcher(this); fs_watch = new QFileSystemWatcher(this);
@ -286,7 +282,8 @@ void SoftwarePanel::updateLabels() {
QWidget * network_panel(QWidget * parent) { QWidget * network_panel(QWidget * parent) {
#ifdef QCOM #ifdef QCOM
QVBoxLayout *layout = new QVBoxLayout; QWidget *w = new QWidget(parent);
QVBoxLayout *layout = new QVBoxLayout(w);
layout->setSpacing(30); layout->setSpacing(30);
// wifi + tethering buttons // wifi + tethering buttons
@ -304,9 +301,6 @@ QWidget * network_panel(QWidget * parent) {
layout->addWidget(new SshControl()); layout->addWidget(new SshControl());
layout->addStretch(1); layout->addStretch(1);
QWidget *w = new QWidget(parent);
w->setLayout(layout);
#else #else
Networking *w = new Networking(parent); Networking *w = new Networking(parent);
#endif #endif
@ -324,7 +318,8 @@ void SettingsWindow::showEvent(QShowEvent *event) {
SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) { SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) {
// setup two main layouts // setup two main layouts
QVBoxLayout *sidebar_layout = new QVBoxLayout(); sidebar_widget = new QWidget;
QVBoxLayout *sidebar_layout = new QVBoxLayout(sidebar_widget);
sidebar_layout->setMargin(0); sidebar_layout->setMargin(0);
panel_widget = new QStackedWidget(); panel_widget = new QStackedWidget();
panel_widget->setStyleSheet(R"( panel_widget->setStyleSheet(R"(
@ -400,15 +395,12 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) {
sidebar_layout->setContentsMargins(50, 50, 100, 50); sidebar_layout->setContentsMargins(50, 50, 100, 50);
// main settings layout, sidebar + main panel // main settings layout, sidebar + main panel
QHBoxLayout *settings_layout = new QHBoxLayout(); QHBoxLayout *main_layout = new QHBoxLayout(this);
sidebar_widget = new QWidget;
sidebar_widget->setLayout(sidebar_layout);
sidebar_widget->setFixedWidth(500); sidebar_widget->setFixedWidth(500);
settings_layout->addWidget(sidebar_widget); main_layout->addWidget(sidebar_widget);
settings_layout->addWidget(panel_widget); main_layout->addWidget(panel_widget);
setLayout(settings_layout);
setStyleSheet(R"( setStyleSheet(R"(
* { * {
color: white; color: white;

@ -12,34 +12,31 @@
#endif #endif
OnroadWindow::OnroadWindow(QWidget *parent) : QWidget(parent) { OnroadWindow::OnroadWindow(QWidget *parent) : QWidget(parent) {
layout = new QStackedLayout(this); main_layout = new QStackedLayout(this);
layout->setStackingMode(QStackedLayout::StackAll); main_layout->setStackingMode(QStackedLayout::StackAll);
// old UI on bottom // old UI on bottom
nvg = new NvgWindow(this); nvg = new NvgWindow(this);
QObject::connect(this, &OnroadWindow::update, nvg, &NvgWindow::update); QObject::connect(this, &OnroadWindow::update, nvg, &NvgWindow::update);
split = new QHBoxLayout(); QWidget * split_wrapper = new QWidget;
split = new QHBoxLayout(split_wrapper);
split->setContentsMargins(0, 0, 0, 0); split->setContentsMargins(0, 0, 0, 0);
split->setSpacing(0); split->setSpacing(0);
split->addWidget(nvg); split->addWidget(nvg);
main_layout->addWidget(split_wrapper);
QWidget * split_wrapper = new QWidget;
split_wrapper->setLayout(split);
layout->addWidget(split_wrapper);
alerts = new OnroadAlerts(this); alerts = new OnroadAlerts(this);
alerts->setAttribute(Qt::WA_TransparentForMouseEvents, true); alerts->setAttribute(Qt::WA_TransparentForMouseEvents, true);
QObject::connect(this, &OnroadWindow::update, alerts, &OnroadAlerts::updateState); QObject::connect(this, &OnroadWindow::update, alerts, &OnroadAlerts::updateState);
QObject::connect(this, &OnroadWindow::offroadTransitionSignal, alerts, &OnroadAlerts::offroadTransition); QObject::connect(this, &OnroadWindow::offroadTransitionSignal, alerts, &OnroadAlerts::offroadTransition);
QObject::connect(this, &OnroadWindow::offroadTransitionSignal, this, &OnroadWindow::offroadTransition); QObject::connect(this, &OnroadWindow::offroadTransitionSignal, this, &OnroadWindow::offroadTransition);
layout->addWidget(alerts); main_layout->addWidget(alerts);
// setup stacking order // setup stacking order
alerts->raise(); alerts->raise();
setLayout(layout);
setAttribute(Qt::WA_OpaquePaintEvent); setAttribute(Qt::WA_OpaquePaintEvent);
} }

@ -86,7 +86,7 @@ public:
private: private:
OnroadAlerts *alerts; OnroadAlerts *alerts;
NvgWindow *nvg; NvgWindow *nvg;
QStackedLayout *layout; QStackedLayout *main_layout;
QHBoxLayout* split; QHBoxLayout* split;
signals: signals:

@ -31,21 +31,21 @@ int main(int argc, char *argv[]) {
QWidget window; QWidget window;
setMainWindow(&window); setMainWindow(&window);
QVBoxLayout *layout = new QVBoxLayout(); QVBoxLayout *main_layout = new QVBoxLayout(&window);
layout->setContentsMargins(125, 125, 125, 125); main_layout->setContentsMargins(125, 125, 125, 125);
QLabel *title = new QLabel("System Reset"); QLabel *title = new QLabel("System Reset");
title->setStyleSheet(R"( title->setStyleSheet(R"(
font-weight: 500; font-weight: 500;
font-size: 100px; font-size: 100px;
)"); )");
layout->addWidget(title, 0, Qt::AlignTop); main_layout->addWidget(title, 0, Qt::AlignTop);
QLabel *body = new QLabel("System reset triggered. Press confirm to erase all content and settings. Press cancel to resume boot."); QLabel *body = new QLabel("System reset triggered. Press confirm to erase all content and settings. Press cancel to resume boot.");
body->setWordWrap(true); body->setWordWrap(true);
body->setAlignment(Qt::AlignCenter); body->setAlignment(Qt::AlignCenter);
body->setStyleSheet("font-size: 65px;"); body->setStyleSheet("font-size: 65px;");
layout->addWidget(body, 1, Qt::AlignCenter); main_layout->addWidget(body, 1, Qt::AlignCenter);
QHBoxLayout *btn_layout = new QHBoxLayout(); QHBoxLayout *btn_layout = new QHBoxLayout();
@ -74,9 +74,8 @@ int main(int argc, char *argv[]) {
} }
}); });
layout->addLayout(btn_layout); main_layout->addLayout(btn_layout);
window.setLayout(layout);
window.setStyleSheet(R"( window.setStyleSheet(R"(
* { * {
color: white; color: white;

@ -56,7 +56,9 @@ QLabel * title_label(QString text) {
} }
QWidget * Setup::build_page(QString title, QWidget *content, bool next, bool prev) { QWidget * Setup::build_page(QString title, QWidget *content, bool next, bool prev) {
QVBoxLayout *main_layout = new QVBoxLayout(); QWidget *widget = new QWidget();
QVBoxLayout *main_layout = new QVBoxLayout(widget);
main_layout->setMargin(50); main_layout->setMargin(50);
main_layout->addWidget(title_label(title), 0, Qt::AlignLeft | Qt::AlignTop); main_layout->addWidget(title_label(title), 0, Qt::AlignLeft | Qt::AlignTop);
@ -77,9 +79,6 @@ QWidget * Setup::build_page(QString title, QWidget *content, bool next, bool pre
} }
main_layout->addLayout(nav_layout, 0); main_layout->addLayout(nav_layout, 0);
QWidget *widget = new QWidget();
widget->setLayout(main_layout);
return widget; return widget;
} }
@ -96,7 +95,8 @@ QWidget * Setup::network_setup() {
} }
QWidget * Setup::software_selection() { QWidget * Setup::software_selection() {
QVBoxLayout *main_layout = new QVBoxLayout(); QWidget *widget = new QWidget();
QVBoxLayout *main_layout = new QVBoxLayout(widget);
QPushButton *dashcam_btn = new QPushButton("Dashcam"); QPushButton *dashcam_btn = new QPushButton("Dashcam");
main_layout->addWidget(dashcam_btn); main_layout->addWidget(dashcam_btn);
@ -114,23 +114,19 @@ QWidget * Setup::software_selection() {
this->download(input_url); this->download(input_url);
} }
}); });
QWidget *widget = new QWidget();
widget->setLayout(main_layout);
return build_page("Choose Software", widget, false, true); return build_page("Choose Software", widget, false, true);
} }
QWidget * Setup::downloading() { QWidget * Setup::downloading() {
QVBoxLayout *main_layout = new QVBoxLayout();
main_layout->addWidget(title_label("Downloading..."), 0, Qt::AlignCenter);
QWidget *widget = new QWidget(); QWidget *widget = new QWidget();
widget->setLayout(main_layout); QVBoxLayout *main_layout = new QVBoxLayout(widget);
main_layout->addWidget(title_label("Downloading..."), 0, Qt::AlignCenter);
return widget; return widget;
} }
QWidget * Setup::download_failed() { QWidget * Setup::download_failed() {
QVBoxLayout *main_layout = new QVBoxLayout(); QWidget *widget = new QWidget();
QVBoxLayout *main_layout = new QVBoxLayout(widget);
main_layout->setContentsMargins(50, 50, 50, 50); main_layout->setContentsMargins(50, 50, 50, 50);
main_layout->addWidget(title_label("Download Failed"), 0, Qt::AlignLeft | Qt::AlignTop); main_layout->addWidget(title_label("Download Failed"), 0, Qt::AlignLeft | Qt::AlignTop);
@ -157,9 +153,6 @@ QWidget * Setup::download_failed() {
}); });
main_layout->addLayout(nav_layout, 0); main_layout->addLayout(nav_layout, 0);
QWidget *widget = new QWidget();
widget->setLayout(main_layout);
return widget; return widget;
} }

@ -18,7 +18,7 @@ void WifiSetup::finish() {
} }
WifiSetup::WifiSetup(QWidget *parent) : QWidget(parent) { WifiSetup::WifiSetup(QWidget *parent) : QWidget(parent) {
QHBoxLayout *main_layout = new QHBoxLayout(); QHBoxLayout *main_layout = new QHBoxLayout(this);
QPushButton *finish_btn = new QPushButton("Exit"); QPushButton *finish_btn = new QPushButton("Exit");
finish_btn->setFixedSize(400, 200); finish_btn->setFixedSize(400, 200);
@ -29,10 +29,9 @@ WifiSetup::WifiSetup(QWidget *parent) : QWidget(parent) {
QWidget* n = new Networking(this, true); QWidget* n = new Networking(this, true);
// Next 5 lines to keep the same stylesheet on the networking widget // Next 5 lines to keep the same stylesheet on the networking widget
QLayout* backgroundLayout = new QVBoxLayout();
backgroundLayout->addWidget(n);
QWidget* q = new QWidget(); QWidget* q = new QWidget();
q->setLayout(backgroundLayout); QLayout* backgroundLayout = new QVBoxLayout(q);
backgroundLayout->addWidget(n);
q->setStyleSheet(R"( q->setStyleSheet(R"(
* { * {
background-color: #292929; background-color: #292929;
@ -40,7 +39,6 @@ WifiSetup::WifiSetup(QWidget *parent) : QWidget(parent) {
)"); )");
main_layout->addWidget(q, 1); main_layout->addWidget(q, 1);
setLayout(main_layout);
setStyleSheet(R"( setStyleSheet(R"(
* { * {
background-color: black; background-color: black;

@ -54,7 +54,7 @@ void TrackWidget::paintEvent(QPaintEvent *event) {
// Spinner // Spinner
Spinner::Spinner(QWidget *parent) : QWidget(parent) { Spinner::Spinner(QWidget *parent) : QWidget(parent) {
QGridLayout *main_layout = new QGridLayout(); QGridLayout *main_layout = new QGridLayout(this);
main_layout->setSpacing(0); main_layout->setSpacing(0);
main_layout->setMargin(200); main_layout->setMargin(200);
@ -71,7 +71,6 @@ Spinner::Spinner(QWidget *parent) : QWidget(parent) {
progress_bar->setFixedHeight(20); progress_bar->setFixedHeight(20);
main_layout->addWidget(progress_bar, 1, 0, Qt::AlignHCenter); main_layout->addWidget(progress_bar, 1, 0, Qt::AlignHCenter);
setLayout(main_layout);
setStyleSheet(R"( setStyleSheet(R"(
Spinner { Spinner {
background-color: black; background-color: black;

@ -17,15 +17,15 @@ int main(int argc, char *argv[]) {
Hardware::set_display_power(true); Hardware::set_display_power(true);
Hardware::set_brightness(65); Hardware::set_brightness(65);
QGridLayout *layout = new QGridLayout; QGridLayout *main_layout = new QGridLayout(&window);
layout->setMargin(50); main_layout->setMargin(50);
QLabel *label = new QLabel(argv[1]); QLabel *label = new QLabel(argv[1]);
label->setWordWrap(true); label->setWordWrap(true);
label->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); label->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
ScrollView *scroll = new ScrollView(label); ScrollView *scroll = new ScrollView(label);
scroll->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); scroll->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
layout->addWidget(scroll, 0, 0, Qt::AlignTop); main_layout->addWidget(scroll, 0, 0, Qt::AlignTop);
// Scroll to the bottom // Scroll to the bottom
QObject::connect(scroll->verticalScrollBar(), &QAbstractSlider::rangeChanged, [=]() { QObject::connect(scroll->verticalScrollBar(), &QAbstractSlider::rangeChanged, [=]() {
@ -42,9 +42,8 @@ int main(int argc, char *argv[]) {
btn->setText("Exit"); btn->setText("Exit");
QObject::connect(btn, &QPushButton::released, &a, &QApplication::quit); QObject::connect(btn, &QPushButton::released, &a, &QApplication::quit);
#endif #endif
layout->addWidget(btn, 0, 0, Qt::AlignRight | Qt::AlignBottom); main_layout->addWidget(btn, 0, 0, Qt::AlignRight | Qt::AlignBottom);
window.setLayout(layout);
window.setStyleSheet(R"( window.setStyleSheet(R"(
* { * {
outline: none; outline: none;

@ -15,8 +15,8 @@ QFrame *horizontal_line(QWidget *parent) {
} }
AbstractControl::AbstractControl(const QString &title, const QString &desc, const QString &icon, QWidget *parent) : QFrame(parent) { AbstractControl::AbstractControl(const QString &title, const QString &desc, const QString &icon, QWidget *parent) : QFrame(parent) {
QVBoxLayout *vlayout = new QVBoxLayout(); QVBoxLayout *main_layout = new QVBoxLayout(this);
vlayout->setMargin(0); main_layout->setMargin(0);
hlayout = new QHBoxLayout; hlayout = new QHBoxLayout;
hlayout->setMargin(0); hlayout->setMargin(0);
@ -36,7 +36,7 @@ AbstractControl::AbstractControl(const QString &title, const QString &desc, cons
title_label->setStyleSheet("font-size: 50px; font-weight: 400; text-align: left;"); title_label->setStyleSheet("font-size: 50px; font-weight: 400; text-align: left;");
hlayout->addWidget(title_label); hlayout->addWidget(title_label);
vlayout->addLayout(hlayout); main_layout->addLayout(hlayout);
// description // description
if (!desc.isEmpty()) { if (!desc.isEmpty()) {
@ -45,7 +45,7 @@ AbstractControl::AbstractControl(const QString &title, const QString &desc, cons
description->setStyleSheet("font-size: 40px; color:grey"); description->setStyleSheet("font-size: 40px; color:grey");
description->setWordWrap(true); description->setWordWrap(true);
description->setVisible(false); description->setVisible(false);
vlayout->addWidget(description); main_layout->addWidget(description);
connect(title_label, &QPushButton::clicked, [=]() { connect(title_label, &QPushButton::clicked, [=]() {
if (!description->isVisible()) { if (!description->isVisible()) {
@ -55,7 +55,6 @@ AbstractControl::AbstractControl(const QString &title, const QString &desc, cons
}); });
} }
setLayout(vlayout);
setStyleSheet("background-color: transparent;"); setStyleSheet("background-color: transparent;");
} }

@ -65,6 +65,5 @@ DriveStats::DriveStats(QWidget* parent) : QWidget(parent) {
RequestRepeater *repeater = new RequestRepeater(this, url, "ApiCache_DriveStats", 30); RequestRepeater *repeater = new RequestRepeater(this, url, "ApiCache_DriveStats", 30);
QObject::connect(repeater, &RequestRepeater::receivedResponse, this, &DriveStats::parseResponse); QObject::connect(repeater, &RequestRepeater::receivedResponse, this, &DriveStats::parseResponse);
setLayout(gl);
setStyleSheet(R"(QLabel {font-size: 48px; font-weight: 500;})"); setStyleSheet(R"(QLabel {font-size: 48px; font-weight: 500;})");
} }

@ -6,9 +6,9 @@
#include "selfdrive/hardware/hw.h" #include "selfdrive/hardware/hw.h"
InputDialog::InputDialog(const QString &prompt_text, QWidget *parent) : QDialog(parent) { InputDialog::InputDialog(const QString &prompt_text, QWidget *parent) : QDialog(parent) {
layout = new QVBoxLayout(); main_layout = new QVBoxLayout(this);
layout->setContentsMargins(50, 50, 50, 50); main_layout->setContentsMargins(50, 50, 50, 50);
layout->setSpacing(20); main_layout->setSpacing(20);
// build header // build header
QHBoxLayout *header_layout = new QHBoxLayout(); QHBoxLayout *header_layout = new QHBoxLayout();
@ -30,10 +30,10 @@ InputDialog::InputDialog(const QString &prompt_text, QWidget *parent) : QDialog(
QObject::connect(cancel_btn, &QPushButton::released, this, &InputDialog::reject); QObject::connect(cancel_btn, &QPushButton::released, this, &InputDialog::reject);
QObject::connect(cancel_btn, &QPushButton::released, this, &InputDialog::cancel); QObject::connect(cancel_btn, &QPushButton::released, this, &InputDialog::cancel);
layout->addLayout(header_layout); main_layout->addLayout(header_layout);
// text box // text box
layout->addSpacing(20); main_layout->addSpacing(20);
line = new QLineEdit(); line = new QLineEdit();
line->setStyleSheet(R"( line->setStyleSheet(R"(
border: none; border: none;
@ -42,11 +42,11 @@ InputDialog::InputDialog(const QString &prompt_text, QWidget *parent) : QDialog(
font-weight: 500; font-weight: 500;
padding: 10px; padding: 10px;
)"); )");
layout->addWidget(line, 1, Qt::AlignTop); main_layout->addWidget(line, 1, Qt::AlignTop);
k = new Keyboard(this); k = new Keyboard(this);
QObject::connect(k, &Keyboard::emitButton, this, &InputDialog::handleInput); QObject::connect(k, &Keyboard::emitButton, this, &InputDialog::handleInput);
layout->addWidget(k, 2, Qt::AlignBottom); main_layout->addWidget(k, 2, Qt::AlignBottom);
setStyleSheet(R"( setStyleSheet(R"(
* { * {
@ -55,7 +55,6 @@ InputDialog::InputDialog(const QString &prompt_text, QWidget *parent) : QDialog(
} }
)"); )");
setLayout(layout);
} }
QString InputDialog::getText(const QString &prompt, int minLength) { QString InputDialog::getText(const QString &prompt, int minLength) {
@ -116,20 +115,20 @@ void InputDialog::setMinLength(int length) {
ConfirmationDialog::ConfirmationDialog(const QString &prompt_text, const QString &confirm_text, const QString &cancel_text, ConfirmationDialog::ConfirmationDialog(const QString &prompt_text, const QString &confirm_text, const QString &cancel_text,
QWidget *parent):QDialog(parent) { QWidget *parent):QDialog(parent) {
setWindowFlags(Qt::Popup); setWindowFlags(Qt::Popup);
layout = new QVBoxLayout(); main_layout = new QVBoxLayout(this);
layout->setMargin(25); main_layout->setMargin(25);
prompt = new QLabel(prompt_text, this); prompt = new QLabel(prompt_text, this);
prompt->setWordWrap(true); prompt->setWordWrap(true);
prompt->setAlignment(Qt::AlignHCenter); prompt->setAlignment(Qt::AlignHCenter);
prompt->setStyleSheet(R"(font-size: 55px; font-weight: 400;)"); prompt->setStyleSheet(R"(font-size: 55px; font-weight: 400;)");
layout->addWidget(prompt, 1, Qt::AlignTop | Qt::AlignHCenter); main_layout->addWidget(prompt, 1, Qt::AlignTop | Qt::AlignHCenter);
// cancel + confirm buttons // cancel + confirm buttons
QHBoxLayout *btn_layout = new QHBoxLayout(); QHBoxLayout *btn_layout = new QHBoxLayout();
btn_layout->setSpacing(20); btn_layout->setSpacing(20);
btn_layout->addStretch(1); btn_layout->addStretch(1);
layout->addLayout(btn_layout); main_layout->addLayout(btn_layout);
if (cancel_text.length()) { if (cancel_text.length()) {
QPushButton* cancel_btn = new QPushButton(cancel_text); QPushButton* cancel_btn = new QPushButton(cancel_text);
@ -158,8 +157,6 @@ ConfirmationDialog::ConfirmationDialog(const QString &prompt_text, const QString
background-color: #44444400; background-color: #44444400;
} }
)"); )");
setLayout(layout);
} }
bool ConfirmationDialog::alert(const QString &prompt_text, QWidget *parent) { bool ConfirmationDialog::alert(const QString &prompt_text, QWidget *parent) {

@ -25,7 +25,7 @@ private:
QLineEdit *line; QLineEdit *line;
Keyboard *k; Keyboard *k;
QLabel *label; QLabel *label;
QVBoxLayout *layout; QVBoxLayout *main_layout;
public slots: public slots:
int exec() override; int exec() override;
@ -49,7 +49,7 @@ public:
private: private:
QLabel *prompt; QLabel *prompt;
QVBoxLayout *layout; QVBoxLayout *main_layout;
public slots: public slots:
int exec() override; int exec() override;

@ -11,9 +11,9 @@ const int DEFAULT_STRETCH = 1;
const int SPACEBAR_STRETCH = 3; const int SPACEBAR_STRETCH = 3;
KeyboardLayout::KeyboardLayout(QWidget* parent, const std::vector<QVector<QString>>& layout) : QWidget(parent) { KeyboardLayout::KeyboardLayout(QWidget* parent, const std::vector<QVector<QString>>& layout) : QWidget(parent) {
QVBoxLayout* vlayout = new QVBoxLayout; QVBoxLayout* main_layout = new QVBoxLayout(this);
vlayout->setMargin(0); main_layout->setMargin(0);
vlayout->setSpacing(35); main_layout->setSpacing(35);
QButtonGroup* btn_group = new QButtonGroup(this); QButtonGroup* btn_group = new QButtonGroup(this);
QObject::connect(btn_group, SIGNAL(buttonClicked(QAbstractButton*)), parent, SLOT(handleButton(QAbstractButton*))); QObject::connect(btn_group, SIGNAL(buttonClicked(QAbstractButton*)), parent, SLOT(handleButton(QAbstractButton*)));
@ -22,7 +22,7 @@ KeyboardLayout::KeyboardLayout(QWidget* parent, const std::vector<QVector<QStrin
QHBoxLayout *hlayout = new QHBoxLayout; QHBoxLayout *hlayout = new QHBoxLayout;
hlayout->setSpacing(25); hlayout->setSpacing(25);
if (vlayout->count() == 1) { if (main_layout->count() == 1) {
hlayout->addSpacing(90); hlayout->addSpacing(90);
} }
@ -33,11 +33,11 @@ KeyboardLayout::KeyboardLayout(QWidget* parent, const std::vector<QVector<QStrin
hlayout->addWidget(btn, p == QString(" ") ? SPACEBAR_STRETCH : DEFAULT_STRETCH); hlayout->addWidget(btn, p == QString(" ") ? SPACEBAR_STRETCH : DEFAULT_STRETCH);
} }
if (vlayout->count() == 1) { if (main_layout->count() == 1) {
hlayout->addSpacing(90); hlayout->addSpacing(90);
} }
vlayout->addLayout(hlayout); main_layout->addLayout(hlayout);
} }
setStyleSheet(R"( setStyleSheet(R"(
@ -56,11 +56,10 @@ KeyboardLayout::KeyboardLayout(QWidget* parent, const std::vector<QVector<QStrin
background-color: #000000; background-color: #000000;
} }
)"); )");
setLayout(vlayout);
} }
Keyboard::Keyboard(QWidget *parent) : QFrame(parent) { Keyboard::Keyboard(QWidget *parent) : QFrame(parent) {
main_layout = new QStackedLayout; main_layout = new QStackedLayout(this);
main_layout->setMargin(0); main_layout->setMargin(0);
// lowercase // lowercase
@ -99,7 +98,6 @@ Keyboard::Keyboard(QWidget *parent) : QFrame(parent) {
}; };
main_layout->addWidget(new KeyboardLayout(this, specials)); main_layout->addWidget(new KeyboardLayout(this, specials));
setLayout(main_layout);
main_layout->setCurrentIndex(0); main_layout->setCurrentIndex(0);
} }

@ -9,15 +9,14 @@
#include "selfdrive/hardware/hw.h" #include "selfdrive/hardware/hw.h"
OffroadAlert::OffroadAlert(QWidget* parent) : QFrame(parent) { OffroadAlert::OffroadAlert(QWidget* parent) : QFrame(parent) {
QVBoxLayout *layout = new QVBoxLayout; QVBoxLayout *main_layout = new QVBoxLayout(this);
layout->setMargin(50); main_layout->setMargin(50);
layout->setSpacing(30); main_layout->setSpacing(30);
QWidget *alerts_widget = new QWidget(this); QWidget *alerts_widget = new QWidget(this);
alerts_layout = new QVBoxLayout; alerts_layout = new QVBoxLayout(alerts_widget);
alerts_layout->setMargin(0); alerts_layout->setMargin(0);
alerts_layout->setSpacing(30); alerts_layout->setSpacing(30);
alerts_widget->setLayout(alerts_layout);
alerts_widget->setStyleSheet("background-color: transparent;"); alerts_widget->setStyleSheet("background-color: transparent;");
// release notes // release notes
@ -27,14 +26,14 @@ OffroadAlert::OffroadAlert(QWidget* parent) : QFrame(parent) {
releaseNotes.setAlignment(Qt::AlignTop); releaseNotes.setAlignment(Qt::AlignTop);
releaseNotesScroll = new ScrollView(&releaseNotes, this); releaseNotesScroll = new ScrollView(&releaseNotes, this);
layout->addWidget(releaseNotesScroll); main_layout->addWidget(releaseNotesScroll);
alertsScroll = new ScrollView(alerts_widget, this); alertsScroll = new ScrollView(alerts_widget, this);
layout->addWidget(alertsScroll); main_layout->addWidget(alertsScroll);
// bottom footer, dismiss + reboot buttons // bottom footer, dismiss + reboot buttons
QHBoxLayout *footer_layout = new QHBoxLayout(); QHBoxLayout *footer_layout = new QHBoxLayout();
layout->addLayout(footer_layout); main_layout->addLayout(footer_layout);
QPushButton *dismiss_btn = new QPushButton("Dismiss"); QPushButton *dismiss_btn = new QPushButton("Dismiss");
dismiss_btn->setFixedSize(400, 125); dismiss_btn->setFixedSize(400, 125);
@ -47,7 +46,6 @@ OffroadAlert::OffroadAlert(QWidget* parent) : QFrame(parent) {
footer_layout->addWidget(&rebootBtn, 0, Qt::AlignBottom | Qt::AlignRight); footer_layout->addWidget(&rebootBtn, 0, Qt::AlignBottom | Qt::AlignRight);
QObject::connect(&rebootBtn, &QPushButton::released, [=]() { Hardware::reboot(); }); QObject::connect(&rebootBtn, &QPushButton::released, [=]() { Hardware::reboot(); });
setLayout(layout);
setStyleSheet(R"( setStyleSheet(R"(
* { * {
font-size: 48px; font-size: 48px;

@ -18,9 +18,8 @@ using qrcodegen::QrCode;
PairingQRWidget::PairingQRWidget(QWidget* parent) : QWidget(parent) { PairingQRWidget::PairingQRWidget(QWidget* parent) : QWidget(parent) {
qrCode = new QLabel; qrCode = new QLabel;
qrCode->setScaledContents(true); qrCode->setScaledContents(true);
QVBoxLayout* v = new QVBoxLayout; QVBoxLayout* main_layout = new QVBoxLayout(this);
v->addWidget(qrCode, 0, Qt::AlignCenter); main_layout->addWidget(qrCode, 0, Qt::AlignCenter);
setLayout(v);
QTimer* timer = new QTimer(this); QTimer* timer = new QTimer(this);
timer->start(30 * 1000); timer->start(30 * 1000);
@ -73,7 +72,7 @@ void PairingQRWidget::updateQrCode(const QString &text) {
} }
PrimeUserWidget::PrimeUserWidget(QWidget* parent) : QWidget(parent) { PrimeUserWidget::PrimeUserWidget(QWidget* parent) : QWidget(parent) {
mainLayout = new QVBoxLayout; mainLayout = new QVBoxLayout(this);
mainLayout->setMargin(30); mainLayout->setMargin(30);
QLabel* commaPrime = new QLabel("COMMA PRIME"); QLabel* commaPrime = new QLabel("COMMA PRIME");
@ -94,7 +93,6 @@ PrimeUserWidget::PrimeUserWidget(QWidget* parent) : QWidget(parent) {
points = new QLabel(); points = new QLabel();
mainLayout->addWidget(points, 0, Qt::AlignTop); mainLayout->addWidget(points, 0, Qt::AlignTop);
setLayout(mainLayout);
setStyleSheet(R"( setStyleSheet(R"(
QLabel { QLabel {
font-size: 70px; font-size: 70px;
@ -132,11 +130,11 @@ void PrimeUserWidget::replyFinished(const QString &response) {
} }
PrimeAdWidget::PrimeAdWidget(QWidget* parent) : QWidget(parent) { PrimeAdWidget::PrimeAdWidget(QWidget* parent) : QWidget(parent) {
QVBoxLayout* vlayout = new QVBoxLayout; QVBoxLayout* main_layout = new QVBoxLayout(this);
vlayout->setMargin(30); main_layout->setMargin(30);
vlayout->setSpacing(15); main_layout->setSpacing(15);
vlayout->addWidget(new QLabel("Upgrade now"), 1, Qt::AlignTop); main_layout->addWidget(new QLabel("Upgrade now"), 1, Qt::AlignTop);
QLabel* description = new QLabel("Become a comma prime member at my.comma.ai and get premium features!"); QLabel* description = new QLabel("Become a comma prime member at my.comma.ai and get premium features!");
description->setStyleSheet(R"( description->setStyleSheet(R"(
@ -144,16 +142,14 @@ PrimeAdWidget::PrimeAdWidget(QWidget* parent) : QWidget(parent) {
color: #b8b8b8; color: #b8b8b8;
)"); )");
description->setWordWrap(true); description->setWordWrap(true);
vlayout->addWidget(description, 2, Qt::AlignTop); main_layout->addWidget(description, 2, Qt::AlignTop);
QVector<QString> features = {"✓ REMOTE ACCESS", "✓ 14 DAYS OF STORAGE", "✓ DEVELOPER PERKS"}; QVector<QString> features = {"✓ REMOTE ACCESS", "✓ 14 DAYS OF STORAGE", "✓ DEVELOPER PERKS"};
for (auto &f: features) { for (auto &f: features) {
QLabel* feature = new QLabel(f); QLabel* feature = new QLabel(f);
feature->setStyleSheet(R"(font-size: 40px;)"); feature->setStyleSheet(R"(font-size: 40px;)");
vlayout->addWidget(feature, 0, Qt::AlignBottom); main_layout->addWidget(feature, 0, Qt::AlignBottom);
} }
setLayout(vlayout);
} }
@ -162,7 +158,8 @@ SetupWidget::SetupWidget(QWidget* parent) : QFrame(parent) {
// Unpaired, registration prompt layout // Unpaired, registration prompt layout
QVBoxLayout* finishRegistationLayout = new QVBoxLayout; QWidget* finishRegistration = new QWidget;
QVBoxLayout* finishRegistationLayout = new QVBoxLayout(finishRegistration);
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");
@ -186,13 +183,12 @@ SetupWidget::SetupWidget(QWidget* parent) : QFrame(parent) {
finishRegistationLayout->addWidget(finishButton); finishRegistationLayout->addWidget(finishButton);
QObject::connect(finishButton, &QPushButton::released, this, &SetupWidget::showQrCode); QObject::connect(finishButton, &QPushButton::released, this, &SetupWidget::showQrCode);
QWidget* finishRegistration = new QWidget;
finishRegistration->setLayout(finishRegistationLayout);
mainLayout->addWidget(finishRegistration); mainLayout->addWidget(finishRegistration);
// Pairing QR code layout // Pairing QR code layout
QVBoxLayout* qrLayout = new QVBoxLayout; QWidget* q = new QWidget;
QVBoxLayout* qrLayout = new QVBoxLayout(q);
qrLayout->addSpacing(30); qrLayout->addSpacing(30);
QLabel* qrLabel = new QLabel("Scan with comma connect!"); QLabel* qrLabel = new QLabel("Scan with comma connect!");
@ -206,8 +202,6 @@ SetupWidget::SetupWidget(QWidget* parent) : QFrame(parent) {
qrLayout->addWidget(new PairingQRWidget, 1); qrLayout->addWidget(new PairingQRWidget, 1);
QWidget* q = new QWidget;
q->setLayout(qrLayout);
mainLayout->addWidget(q); mainLayout->addWidget(q);
primeAd = new PrimeAdWidget; primeAd = new PrimeAdWidget;
@ -218,9 +212,8 @@ SetupWidget::SetupWidget(QWidget* parent) : QFrame(parent) {
mainLayout->setCurrentWidget(primeAd); mainLayout->setCurrentWidget(primeAd);
QVBoxLayout *layout = new QVBoxLayout; QVBoxLayout *main_layout = new QVBoxLayout(this);
layout->addWidget(mainLayout); main_layout->addWidget(mainLayout);
setLayout(layout);
setStyleSheet(R"( setStyleSheet(R"(
SetupWidget { SetupWidget {

@ -3,7 +3,7 @@
#include "selfdrive/hardware/hw.h" #include "selfdrive/hardware/hw.h"
MainWindow::MainWindow(QWidget *parent) : QWidget(parent) { MainWindow::MainWindow(QWidget *parent) : QWidget(parent) {
main_layout = new QStackedLayout; main_layout = new QStackedLayout(this);
main_layout->setMargin(0); main_layout->setMargin(0);
homeWindow = new HomeWindow(this); homeWindow = new HomeWindow(this);
@ -46,7 +46,6 @@ MainWindow::MainWindow(QWidget *parent) : QWidget(parent) {
QFontDatabase::addApplicationFont("../assets/fonts/opensans_semibold.ttf"); QFontDatabase::addApplicationFont("../assets/fonts/opensans_semibold.ttf");
// no outline to prevent the focus rectangle // no outline to prevent the focus rectangle
setLayout(main_layout);
setStyleSheet(R"( setStyleSheet(R"(
* { * {
font-family: Inter; font-family: Inter;

Loading…
Cancel
Save