diff --git a/selfdrive/ui/qt/setup/updater.cc b/selfdrive/ui/qt/setup/updater.cc index 548e0c2..15c5332 100644 --- a/selfdrive/ui/qt/setup/updater.cc +++ b/selfdrive/ui/qt/setup/updater.cc @@ -54,7 +54,12 @@ Updater::Updater(const QString &updater_path, const QString &manifest_path, QWid background-color: #3049F4; } )"); - QObject::connect(install, &QPushButton::clicked, this, &Updater::installUpdate); + + QObject::connect(connect, &QPushButton::clicked, [=]() { + countdownTimer->stop(); + setCurrentWidget(wifi); + }); + hlayout->addWidget(install); } @@ -114,6 +119,20 @@ 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; @@ -142,8 +161,16 @@ Updater::Updater(const QString &updater_path, const QString &manifest_path, QWid background-color: #364DEF; } )"); +} - Updater::installUpdate(); +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() { diff --git a/selfdrive/ui/qt/setup/updater.h b/selfdrive/ui/qt/setup/updater.h index ce46c0a..ba9737f 100644 --- a/selfdrive/ui/qt/setup/updater.h +++ b/selfdrive/ui/qt/setup/updater.h @@ -26,4 +26,7 @@ private: QProgressBar *bar; QPushButton *reboot; QWidget *prompt, *wifi, *progress; + QTimer *countdownTimer; + int countdownValue; + };