This commit is contained in:
Your Name
2024-04-27 13:43:16 -05:00
parent 21363ce751
commit ea1aad5ed1
128 changed files with 3533 additions and 1918 deletions

9
selfdrive/ui/qt/setup/reset.cc Executable file → Normal file
View File

@@ -57,7 +57,7 @@ Reset::Reset(ResetMode mode, QWidget *parent) : QWidget(parent) {
main_layout->addSpacing(60);
body = new QLabel(tr("Press confirm to erase all content and settings. Press cancel to resume boot."));
body = new QLabel(tr("System reset triggered. Press confirm to erase all content and settings. Press cancel to resume boot."));
body->setWordWrap(true);
body->setStyleSheet("font-size: 80px; font-weight: light;");
main_layout->addWidget(body, 1, Qt::AlignTop | Qt::AlignLeft);
@@ -97,11 +97,6 @@ Reset::Reset(ResetMode mode, QWidget *parent) : QWidget(parent) {
body->setText(tr("Unable to mount data partition. Partition may be corrupted. Press confirm to erase and reset your device."));
}
// automatically start if we're just finishing up an ABL reset
if (mode == ResetMode::FORMAT) {
startReset();
}
setStyleSheet(R"(
* {
font-family: Inter;
@@ -129,8 +124,6 @@ int main(int argc, char *argv[]) {
if (argc > 1) {
if (strcmp(argv[1], "--recover") == 0) {
mode = ResetMode::RECOVER;
} else if (strcmp(argv[1], "--format") == 0) {
mode = ResetMode::FORMAT;
}
}

1
selfdrive/ui/qt/setup/reset.h Executable file → Normal file
View File

@@ -5,7 +5,6 @@
enum ResetMode {
USER_RESET, // user initiated a factory reset from openpilot
RECOVER, // userdata is corrupt for some reason, give a chance to recover
FORMAT, // finish up an ABL factory reset
};
class Reset : public QWidget {

122
selfdrive/ui/qt/setup/setup.cc Executable file → Normal file
View File

@@ -20,7 +20,7 @@
#include "selfdrive/ui/qt/widgets/input.h"
const std::string USER_AGENT = "AGNOSSetup-";
const QString DASHCAM_URL = "https://dashcam.comma.ai";
const QString OPENPILOT_URL = "https://openpilot.comma.ai";
bool is_elf(char *fname) {
FILE *fp = fopen(fname, "rb");
@@ -201,20 +201,7 @@ QWidget * Setup::network_setup() {
QPushButton *cont = new QPushButton();
cont->setObjectName("navBtn");
cont->setProperty("primary", true);
QObject::connect(cont, &QPushButton::clicked, [=]() {
auto w = currentWidget();
QTimer::singleShot(0, [=]() {
setCurrentWidget(downloading_widget);
});
QString url = InputDialog::getText(tr("Enter URL"), this, tr("for Custom Software"));
if (!url.isEmpty()) {
QTimer::singleShot(1000, this, [=]() {
download(url);
});
} else {
setCurrentWidget(w);
}
});
QObject::connect(cont, &QPushButton::clicked, this, &Setup::nextPage);
blayout->addWidget(cont);
// setup timer for testing internet connection
@@ -229,11 +216,11 @@ QWidget * Setup::network_setup() {
}
repaint();
});
request->sendRequest(DASHCAM_URL);
request->sendRequest(OPENPILOT_URL);
QTimer *timer = new QTimer(this);
QObject::connect(timer, &QTimer::timeout, [=]() {
if (!request->active() && cont->isVisible()) {
request->sendRequest(DASHCAM_URL);
request->sendRequest(OPENPILOT_URL);
}
});
timer->start(1000);
@@ -241,6 +228,106 @@ QWidget * Setup::network_setup() {
return widget;
}
QWidget * radio_button(QString title, QButtonGroup *group) {
QPushButton *btn = new QPushButton(title);
btn->setCheckable(true);
group->addButton(btn);
btn->setStyleSheet(R"(
QPushButton {
height: 230;
padding-left: 100px;
padding-right: 100px;
text-align: left;
font-size: 80px;
font-weight: 400;
border-radius: 10px;
background-color: #4F4F4F;
}
QPushButton:checked {
background-color: #465BEA;
}
)");
// checkmark icon
QPixmap pix(":/img_circled_check.svg");
btn->setIcon(pix);
btn->setIconSize(QSize(0, 0));
btn->setLayoutDirection(Qt::RightToLeft);
QObject::connect(btn, &QPushButton::toggled, [=](bool checked) {
btn->setIconSize(checked ? QSize(104, 104) : QSize(0, 0));
});
return btn;
}
QWidget * Setup::software_selection() {
QWidget *widget = new QWidget();
QVBoxLayout *main_layout = new QVBoxLayout(widget);
main_layout->setContentsMargins(55, 50, 55, 50);
main_layout->setSpacing(0);
// title
QLabel *title = new QLabel(tr("Choose Software to Install"));
title->setStyleSheet("font-size: 90px; font-weight: 500;");
main_layout->addWidget(title, 0, Qt::AlignLeft | Qt::AlignTop);
main_layout->addSpacing(50);
// openpilot + custom radio buttons
QButtonGroup *group = new QButtonGroup(widget);
group->setExclusive(true);
QWidget *openpilot = radio_button(tr("openpilot"), group);
main_layout->addWidget(openpilot);
main_layout->addSpacing(30);
QWidget *custom = radio_button(tr("Custom Software"), group);
main_layout->addWidget(custom);
main_layout->addStretch();
// back + continue buttons
QHBoxLayout *blayout = new QHBoxLayout;
main_layout->addLayout(blayout);
blayout->setSpacing(50);
QPushButton *back = new QPushButton(tr("Back"));
back->setObjectName("navBtn");
QObject::connect(back, &QPushButton::clicked, this, &Setup::prevPage);
blayout->addWidget(back);
QPushButton *cont = new QPushButton(tr("Continue"));
cont->setObjectName("navBtn");
cont->setEnabled(false);
cont->setProperty("primary", true);
blayout->addWidget(cont);
QObject::connect(cont, &QPushButton::clicked, [=]() {
auto w = currentWidget();
QTimer::singleShot(0, [=]() {
setCurrentWidget(downloading_widget);
});
QString url = OPENPILOT_URL;
if (group->checkedButton() != openpilot) {
url = InputDialog::getText(tr("Enter URL"), this, tr("for Custom Software"));
}
if (!url.isEmpty()) {
QTimer::singleShot(1000, this, [=]() {
download(url);
});
} else {
setCurrentWidget(w);
}
});
connect(group, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked), [=](QAbstractButton *btn) {
btn->setChecked(true);
cont->setEnabled(true);
});
return widget;
}
QWidget * Setup::downloading() {
QWidget *widget = new QWidget();
QVBoxLayout *main_layout = new QVBoxLayout(widget);
@@ -326,6 +413,7 @@ Setup::Setup(QWidget *parent) : QStackedWidget(parent) {
addWidget(getting_started());
addWidget(network_setup());
addWidget(software_selection());
downloading_widget = downloading();
addWidget(downloading_widget);

1
selfdrive/ui/qt/setup/setup.h Executable file → Normal file
View File

@@ -17,6 +17,7 @@ private:
QWidget *low_voltage();
QWidget *getting_started();
QWidget *network_setup();
QWidget *software_selection();
QWidget *downloading();
QWidget *download_failed(QLabel *url, QLabel *body);

31
selfdrive/ui/qt/setup/updater.cc Executable file → Normal file
View File

@@ -54,12 +54,7 @@ Updater::Updater(const QString &updater_path, const QString &manifest_path, QWid
background-color: #3049F4;
}
)");
QObject::connect(connect, &QPushButton::clicked, [=]() {
countdownTimer->stop();
setCurrentWidget(wifi);
});
QObject::connect(install, &QPushButton::clicked, this, &Updater::installUpdate);
hlayout->addWidget(install);
}
@@ -119,20 +114,6 @@ Updater::Updater(const QString &updater_path, const QString &manifest_path, QWid
addWidget(wifi);
addWidget(progress);
// Initialize the countdown timer and value
countdownValue = 5; // 5 seconds countdown
countdownTimer = new QTimer(this);
countdownTimer->setInterval(1000); // 1 second interval
// Connect the timer's timeout signal to update the countdown and button text
QObject::connect(countdownTimer, &QTimer::timeout, this, &Updater::updateCountdown);
// Start the countdown
countdownTimer->start();
// Set initial button text
install->setText(tr("Install (5)"));
setStyleSheet(R"(
* {
color: white;
@@ -163,16 +144,6 @@ Updater::Updater(const QString &updater_path, const QString &manifest_path, QWid
)");
}
void Updater::updateCountdown() {
countdownValue--;
if (countdownValue > 0) {
install->setText(tr("Install (%1)").arg(countdownValue));
} else {
countdownTimer->stop();
installUpdate(); // Assuming this is the method that starts the update
}
}
void Updater::installUpdate() {
setCurrentWidget(progress);
QObject::connect(&proc, &QProcess::readyReadStandardOutput, this, &Updater::readProgress);

3
selfdrive/ui/qt/setup/updater.h Executable file → Normal file
View File

@@ -26,7 +26,4 @@ private:
QProgressBar *bar;
QPushButton *reboot;
QWidget *prompt, *wifi, *progress;
QTimer *countdownTimer;
int countdownValue;
};