offroad alerts: put back reboot button

pull/19644/head
Willem Melching 4 years ago
parent 250f285894
commit 0cf3da17be
  1. 15
      selfdrive/ui/qt/widgets/offroad_alerts.cc
  2. 2
      selfdrive/ui/qt/widgets/offroad_alerts.hpp

@ -1,7 +1,7 @@
#include <QFile> #include <QFile>
#include <QLabel> #include <QLabel>
#include <QPushButton>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QHBoxLayout>
#include <QJsonObject> #include <QJsonObject>
#include <QJsonDocument> #include <QJsonDocument>
#include <QDebug> #include <QDebug>
@ -26,13 +26,22 @@ OffroadAlert::OffroadAlert(QWidget* parent) {
main_layout->addWidget(alerts_stack, 1); main_layout->addWidget(alerts_stack, 1);
// bottom footer // bottom footer
QVBoxLayout *footer_layout = new QVBoxLayout(); QHBoxLayout *footer_layout = new QHBoxLayout();
main_layout->addLayout(footer_layout); main_layout->addLayout(footer_layout);
QPushButton *dismiss_btn = new QPushButton("Dismiss"); QPushButton *dismiss_btn = new QPushButton("Dismiss");
dismiss_btn->setFixedSize(453, 125); dismiss_btn->setFixedSize(453, 125);
footer_layout->addWidget(dismiss_btn, 0, Qt::AlignLeft); 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())); 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); setLayout(main_layout);
setStyleSheet(R"( setStyleSheet(R"(
@ -60,6 +69,8 @@ void OffroadAlert::refresh() {
std::vector<char> bytes = Params().read_db_bytes("UpdateAvailable"); std::vector<char> bytes = Params().read_db_bytes("UpdateAvailable");
updateAvailable = bytes.size() && bytes[0] == '1'; updateAvailable = bytes.size() && bytes[0] == '1';
reboot_btn->setVisible(updateAvailable);
QVBoxLayout *layout = new QVBoxLayout; QVBoxLayout *layout = new QVBoxLayout;
if (updateAvailable) { if (updateAvailable) {

@ -2,6 +2,7 @@
#include <QFrame> #include <QFrame>
#include <QStackedWidget> #include <QStackedWidget>
#include <QPushButton>
struct Alert { struct Alert {
QString text; QString text;
@ -18,6 +19,7 @@ public:
private: private:
QStackedWidget *alerts_stack; QStackedWidget *alerts_stack;
QPushButton *reboot_btn;
void parse_alerts(); void parse_alerts();
signals: signals:

Loading…
Cancel
Save