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 e8756598ed99aea39ef5721453e97920a494051c.

* font family

* undo

* less widgets more better

* font size

---------

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
old-commit-hash: 79e6910106
beeps
Cameron Clough 3 years ago committed by GitHub
parent a55f8d65cd
commit 8491b5db66
  1. 41
      selfdrive/ui/qt/setup/setup.cc
  2. 5
      selfdrive/ui/qt/setup/setup.h
  3. 8
      selfdrive/ui/translations/main_de.ts
  4. 8
      selfdrive/ui/translations/main_ja.ts
  5. 8
      selfdrive/ui/translations/main_ko.ts
  6. 8
      selfdrive/ui/translations/main_pt-BR.ts
  7. 8
      selfdrive/ui/translations/main_zh-CHS.ts
  8. 8
      selfdrive/ui/translations/main_zh-CHT.ts

@ -34,7 +34,7 @@ bool is_elf(char *fname) {
void Setup::download(QString url) {
CURL *curl = curl_easy_init();
if (!curl) {
emit finished(false);
emit finished(url, tr("Something went wrong. Reboot the device."));
return;
}
@ -57,16 +57,19 @@ void Setup::download(QString url) {
int ret = curl_easy_perform(curl);
long res_status = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &res_status);
if (ret == CURLE_OK && res_status == 200 && is_elf(tmpfile)) {
if (ret != CURLE_OK || res_status != 200) {
emit finished(url, tr("Ensure the entered URL is valid, and the device’s internet connection is good."));
} else if (!is_elf(tmpfile)) {
emit finished(url, tr("No custom software found at this URL."));
} else {
rename(tmpfile, "/tmp/installer");
FILE *fp_url = fopen("/tmp/installer_url", "w");
fprintf(fp_url, "%s", url.toStdString().c_str());
fclose(fp_url);
emit finished(true);
} else {
emit finished(false);
emit finished(url);
}
curl_slist_free_all(list);
@ -239,10 +242,10 @@ QWidget * Setup::downloading() {
return widget;
}
QWidget * Setup::download_failed() {
QWidget * Setup::download_failed(QLabel *url, QLabel *body) {
QWidget *widget = new QWidget();
QVBoxLayout *main_layout = new QVBoxLayout(widget);
main_layout->setContentsMargins(55, 225, 55, 55);
main_layout->setContentsMargins(55, 185, 55, 55);
main_layout->setSpacing(0);
QLabel *title = new QLabel(tr("Download Failed"));
@ -251,7 +254,13 @@ QWidget * Setup::download_failed() {
main_layout->addSpacing(67);
QLabel *body = new QLabel(tr("Ensure the entered URL is valid, and the device’s internet connection is good."));
url->setWordWrap(true);
url->setAlignment(Qt::AlignTop | Qt::AlignLeft);
url->setStyleSheet("font-family: \"JetBrains Mono\"; font-size: 64px; font-weight: 400; margin-right: 100px;");
main_layout->addWidget(url);
main_layout->addSpacing(48);
body->setWordWrap(true);
body->setAlignment(Qt::AlignTop | Qt::AlignLeft);
body->setStyleSheet("font-size: 80px; font-weight: 300; margin-right: 100px;");
@ -276,7 +285,7 @@ QWidget * Setup::download_failed() {
restart->setProperty("primary", true);
blayout->addWidget(restart);
QObject::connect(restart, &QPushButton::clicked, this, [=]() {
setCurrentIndex(2);
setCurrentIndex(1);
});
widget->setStyleSheet(R"(
@ -309,15 +318,19 @@ Setup::Setup(QWidget *parent) : QStackedWidget(parent) {
downloading_widget = downloading();
addWidget(downloading_widget);
failed_widget = download_failed();
QLabel *url_label = new QLabel();
QLabel *body_label = new QLabel();
failed_widget = download_failed(url_label, body_label);
addWidget(failed_widget);
QObject::connect(this, &Setup::finished, [=](bool success) {
// hide setup on success
qDebug() << "finished" << success;
if (success) {
QObject::connect(this, &Setup::finished, [=](const QString &url, const QString &error) {
qDebug() << "finished" << url << error;
if (error.isEmpty()) {
// hide setup on success
QTimer::singleShot(3000, this, &QWidget::hide);
} else {
url_label->setText(url);
body_label->setText(error);
setCurrentWidget(failed_widget);
}
});

@ -1,5 +1,6 @@
#pragma once
#include <QLabel>
#include <QStackedWidget>
#include <QString>
#include <QWidget>
@ -15,13 +16,13 @@ private:
QWidget *getting_started();
QWidget *network_setup();
QWidget *downloading();
QWidget *download_failed();
QWidget *download_failed(QLabel *url, QLabel *body);
QWidget *failed_widget;
QWidget *downloading_widget;
signals:
void finished(bool success);
void finished(const QString &url, const QString &error = "");
public slots:
void nextPage();

@ -703,6 +703,14 @@ This may take up to a minute.</source>
<source>Start over</source>
<translation>Von neuem beginnen</translation>
</message>
<message>
<source>No custom software found at this URL.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Something went wrong. Reboot the device.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SetupWidget</name>

@ -701,6 +701,14 @@ This may take up to a minute.</source>
<source>Start over</source>
<translation></translation>
</message>
<message>
<source>No custom software found at this URL.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Something went wrong. Reboot the device.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SetupWidget</name>

@ -701,6 +701,14 @@ This may take up to a minute.</source>
<source>Start over</source>
<translation> </translation>
</message>
<message>
<source>No custom software found at this URL.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Something went wrong. Reboot the device.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SetupWidget</name>

@ -705,6 +705,14 @@ This may take up to a minute.</source>
<source>Start over</source>
<translation>Inicializar</translation>
</message>
<message>
<source>No custom software found at this URL.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Something went wrong. Reboot the device.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SetupWidget</name>

@ -699,6 +699,14 @@ This may take up to a minute.</source>
<source>Start over</source>
<translation></translation>
</message>
<message>
<source>No custom software found at this URL.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Something went wrong. Reboot the device.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SetupWidget</name>

@ -701,6 +701,14 @@ This may take up to a minute.</source>
<source>Start over</source>
<translation></translation>
</message>
<message>
<source>No custom software found at this URL.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Something went wrong. Reboot the device.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SetupWidget</name>

Loading…
Cancel
Save