From 0cf3da17be09b5cb5f3d4ea2aee5e7d927be9281 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Mon, 4 Jan 2021 11:24:06 +0100 Subject: [PATCH] offroad alerts: put back reboot button --- selfdrive/ui/qt/widgets/offroad_alerts.cc | 17 ++++++++++++++--- selfdrive/ui/qt/widgets/offroad_alerts.hpp | 2 ++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/selfdrive/ui/qt/widgets/offroad_alerts.cc b/selfdrive/ui/qt/widgets/offroad_alerts.cc index 5a31935f02..0bd0bcf128 100644 --- a/selfdrive/ui/qt/widgets/offroad_alerts.cc +++ b/selfdrive/ui/qt/widgets/offroad_alerts.cc @@ -1,7 +1,7 @@ #include #include -#include #include +#include #include #include #include @@ -26,14 +26,23 @@ OffroadAlert::OffroadAlert(QWidget* parent) { main_layout->addWidget(alerts_stack, 1); // bottom footer - QVBoxLayout *footer_layout = new QVBoxLayout(); + QHBoxLayout *footer_layout = new QHBoxLayout(); main_layout->addLayout(footer_layout); QPushButton *dismiss_btn = new QPushButton("Dismiss"); dismiss_btn->setFixedSize(453, 125); footer_layout->addWidget(dismiss_btn, 0, Qt::AlignLeft); + + reboot_btn = new QPushButton("Reboot and Update"); + reboot_btn->setFixedSize(453, 125); + reboot_btn->setVisible(false); + footer_layout->addWidget(reboot_btn, 0, Qt::AlignRight); + QObject::connect(dismiss_btn, SIGNAL(released()), this, SIGNAL(closeAlerts())); - +#ifdef __aarch64__ + QObject::connect(reboot_btn, &QPushButton::released, [=]() {std::system("sudo reboot");}); +#endif + setLayout(main_layout); setStyleSheet(R"( * { @@ -60,6 +69,8 @@ void OffroadAlert::refresh() { std::vector bytes = Params().read_db_bytes("UpdateAvailable"); updateAvailable = bytes.size() && bytes[0] == '1'; + reboot_btn->setVisible(updateAvailable); + QVBoxLayout *layout = new QVBoxLayout; if (updateAvailable) { diff --git a/selfdrive/ui/qt/widgets/offroad_alerts.hpp b/selfdrive/ui/qt/widgets/offroad_alerts.hpp index f8ad3aba01..edd37dd898 100644 --- a/selfdrive/ui/qt/widgets/offroad_alerts.hpp +++ b/selfdrive/ui/qt/widgets/offroad_alerts.hpp @@ -2,6 +2,7 @@ #include #include +#include struct Alert { QString text; @@ -18,6 +19,7 @@ public: private: QStackedWidget *alerts_stack; + QPushButton *reboot_btn; void parse_alerts(); signals: