Skip to content

Commit 79e6910

Browse files
setup: detailed error messages (#27429)
* setup: specific error state for non-executable file * Result -> DownloadResult * complete -> finished * rename widgets to be more consistent * fix typos * fix setCurrentIndex This appears to have different behaviour on device than on PC (off by one) * load fonts * copy Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * Revert "load fonts" This reverts commit e875659. * font family * undo * less widgets more better * font size --------- Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
1 parent d5688ae commit 79e6910

File tree

8 files changed

+78
-16
lines changed

8 files changed

+78
-16
lines changed

selfdrive/ui/qt/setup/setup.cc

+27-14
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ bool is_elf(char *fname) {
3434
void Setup::download(QString url) {
3535
CURL *curl = curl_easy_init();
3636
if (!curl) {
37-
emit finished(false);
37+
emit finished(url, tr("Something went wrong. Reboot the device."));
3838
return;
3939
}
4040

@@ -57,16 +57,19 @@ void Setup::download(QString url) {
5757
int ret = curl_easy_perform(curl);
5858
long res_status = 0;
5959
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &res_status);
60-
if (ret == CURLE_OK && res_status == 200 && is_elf(tmpfile)) {
60+
61+
if (ret != CURLE_OK || res_status != 200) {
62+
emit finished(url, tr("Ensure the entered URL is valid, and the device’s internet connection is good."));
63+
} else if (!is_elf(tmpfile)) {
64+
emit finished(url, tr("No custom software found at this URL."));
65+
} else {
6166
rename(tmpfile, "/tmp/installer");
6267

6368
FILE *fp_url = fopen("/tmp/installer_url", "w");
6469
fprintf(fp_url, "%s", url.toStdString().c_str());
6570
fclose(fp_url);
6671

67-
emit finished(true);
68-
} else {
69-
emit finished(false);
72+
emit finished(url);
7073
}
7174

7275
curl_slist_free_all(list);
@@ -239,10 +242,10 @@ QWidget * Setup::downloading() {
239242
return widget;
240243
}
241244

242-
QWidget * Setup::download_failed() {
245+
QWidget * Setup::download_failed(QLabel *url, QLabel *body) {
243246
QWidget *widget = new QWidget();
244247
QVBoxLayout *main_layout = new QVBoxLayout(widget);
245-
main_layout->setContentsMargins(55, 225, 55, 55);
248+
main_layout->setContentsMargins(55, 185, 55, 55);
246249
main_layout->setSpacing(0);
247250

248251
QLabel *title = new QLabel(tr("Download Failed"));
@@ -251,7 +254,13 @@ QWidget * Setup::download_failed() {
251254

252255
main_layout->addSpacing(67);
253256

254-
QLabel *body = new QLabel(tr("Ensure the entered URL is valid, and the device’s internet connection is good."));
257+
url->setWordWrap(true);
258+
url->setAlignment(Qt::AlignTop | Qt::AlignLeft);
259+
url->setStyleSheet("font-family: \"JetBrains Mono\"; font-size: 64px; font-weight: 400; margin-right: 100px;");
260+
main_layout->addWidget(url);
261+
262+
main_layout->addSpacing(48);
263+
255264
body->setWordWrap(true);
256265
body->setAlignment(Qt::AlignTop | Qt::AlignLeft);
257266
body->setStyleSheet("font-size: 80px; font-weight: 300; margin-right: 100px;");
@@ -276,7 +285,7 @@ QWidget * Setup::download_failed() {
276285
restart->setProperty("primary", true);
277286
blayout->addWidget(restart);
278287
QObject::connect(restart, &QPushButton::clicked, this, [=]() {
279-
setCurrentIndex(2);
288+
setCurrentIndex(1);
280289
});
281290

282291
widget->setStyleSheet(R"(
@@ -309,15 +318,19 @@ Setup::Setup(QWidget *parent) : QStackedWidget(parent) {
309318
downloading_widget = downloading();
310319
addWidget(downloading_widget);
311320

312-
failed_widget = download_failed();
321+
QLabel *url_label = new QLabel();
322+
QLabel *body_label = new QLabel();
323+
failed_widget = download_failed(url_label, body_label);
313324
addWidget(failed_widget);
314325

315-
QObject::connect(this, &Setup::finished, [=](bool success) {
316-
// hide setup on success
317-
qDebug() << "finished" << success;
318-
if (success) {
326+
QObject::connect(this, &Setup::finished, [=](const QString &url, const QString &error) {
327+
qDebug() << "finished" << url << error;
328+
if (error.isEmpty()) {
329+
// hide setup on success
319330
QTimer::singleShot(3000, this, &QWidget::hide);
320331
} else {
332+
url_label->setText(url);
333+
body_label->setText(error);
321334
setCurrentWidget(failed_widget);
322335
}
323336
});

selfdrive/ui/qt/setup/setup.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22

3+
#include <QLabel>
34
#include <QStackedWidget>
45
#include <QString>
56
#include <QWidget>
@@ -15,13 +16,13 @@ class Setup : public QStackedWidget {
1516
QWidget *getting_started();
1617
QWidget *network_setup();
1718
QWidget *downloading();
18-
QWidget *download_failed();
19+
QWidget *download_failed(QLabel *url, QLabel *body);
1920

2021
QWidget *failed_widget;
2122
QWidget *downloading_widget;
2223

2324
signals:
24-
void finished(bool success);
25+
void finished(const QString &url, const QString &error = "");
2526

2627
public slots:
2728
void nextPage();

selfdrive/ui/translations/main_de.ts

+8
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,14 @@ This may take up to a minute.</source>
703703
<source>Start over</source>
704704
<translation>Von neuem beginnen</translation>
705705
</message>
706+
<message>
707+
<source>No custom software found at this URL.</source>
708+
<translation type="unfinished"></translation>
709+
</message>
710+
<message>
711+
<source>Something went wrong. Reboot the device.</source>
712+
<translation type="unfinished"></translation>
713+
</message>
706714
</context>
707715
<context>
708716
<name>SetupWidget</name>

selfdrive/ui/translations/main_ja.ts

+8
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,14 @@ This may take up to a minute.</source>
701701
<source>Start over</source>
702702
<translation>最初からやり直す</translation>
703703
</message>
704+
<message>
705+
<source>No custom software found at this URL.</source>
706+
<translation type="unfinished"></translation>
707+
</message>
708+
<message>
709+
<source>Something went wrong. Reboot the device.</source>
710+
<translation type="unfinished"></translation>
711+
</message>
704712
</context>
705713
<context>
706714
<name>SetupWidget</name>

selfdrive/ui/translations/main_ko.ts

+8
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,14 @@ This may take up to a minute.</source>
701701
<source>Start over</source>
702702
<translation>다시 시작</translation>
703703
</message>
704+
<message>
705+
<source>No custom software found at this URL.</source>
706+
<translation type="unfinished"></translation>
707+
</message>
708+
<message>
709+
<source>Something went wrong. Reboot the device.</source>
710+
<translation type="unfinished"></translation>
711+
</message>
704712
</context>
705713
<context>
706714
<name>SetupWidget</name>

selfdrive/ui/translations/main_pt-BR.ts

+8
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,14 @@ This may take up to a minute.</source>
705705
<source>Start over</source>
706706
<translation>Inicializar</translation>
707707
</message>
708+
<message>
709+
<source>No custom software found at this URL.</source>
710+
<translation type="unfinished"></translation>
711+
</message>
712+
<message>
713+
<source>Something went wrong. Reboot the device.</source>
714+
<translation type="unfinished"></translation>
715+
</message>
708716
</context>
709717
<context>
710718
<name>SetupWidget</name>

selfdrive/ui/translations/main_zh-CHS.ts

+8
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,14 @@ This may take up to a minute.</source>
699699
<source>Start over</source>
700700
<translation>重来</translation>
701701
</message>
702+
<message>
703+
<source>No custom software found at this URL.</source>
704+
<translation type="unfinished"></translation>
705+
</message>
706+
<message>
707+
<source>Something went wrong. Reboot the device.</source>
708+
<translation type="unfinished"></translation>
709+
</message>
702710
</context>
703711
<context>
704712
<name>SetupWidget</name>

selfdrive/ui/translations/main_zh-CHT.ts

+8
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,14 @@ This may take up to a minute.</source>
701701
<source>Start over</source>
702702
<translation>重新開始</translation>
703703
</message>
704+
<message>
705+
<source>No custom software found at this URL.</source>
706+
<translation type="unfinished"></translation>
707+
</message>
708+
<message>
709+
<source>Something went wrong. Reboot the device.</source>
710+
<translation type="unfinished"></translation>
711+
</message>
704712
</context>
705713
<context>
706714
<name>SetupWidget</name>

0 commit comments

Comments
 (0)