|
|
@ -3,7 +3,6 @@ |
|
|
|
#include <QHBoxLayout> |
|
|
|
#include <QHBoxLayout> |
|
|
|
#include <QJsonDocument> |
|
|
|
#include <QJsonDocument> |
|
|
|
#include <QJsonObject> |
|
|
|
#include <QJsonObject> |
|
|
|
#include <QPushButton> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "selfdrive/common/util.h" |
|
|
|
#include "selfdrive/common/util.h" |
|
|
|
#include "selfdrive/hardware/hw.h" |
|
|
|
#include "selfdrive/hardware/hw.h" |
|
|
@ -23,17 +22,28 @@ AbstractAlert::AbstractAlert(bool hasRebootBtn, QWidget *parent) : QFrame(parent |
|
|
|
QHBoxLayout *footer_layout = new QHBoxLayout(); |
|
|
|
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("Close"); |
|
|
|
dismiss_btn->setFixedSize(400, 125); |
|
|
|
dismiss_btn->setFixedSize(400, 125); |
|
|
|
footer_layout->addWidget(dismiss_btn, 0, Qt::AlignBottom | Qt::AlignLeft); |
|
|
|
footer_layout->addWidget(dismiss_btn, 0, Qt::AlignBottom | Qt::AlignLeft); |
|
|
|
QObject::connect(dismiss_btn, &QPushButton::clicked, this, &AbstractAlert::dismiss); |
|
|
|
QObject::connect(dismiss_btn, &QPushButton::clicked, this, &AbstractAlert::dismiss); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
snooze_btn = new QPushButton("Snooze Update"); |
|
|
|
|
|
|
|
snooze_btn->setVisible(false); |
|
|
|
|
|
|
|
snooze_btn->setFixedSize(550, 125); |
|
|
|
|
|
|
|
footer_layout->addWidget(snooze_btn, 0, Qt::AlignBottom | Qt::AlignRight); |
|
|
|
|
|
|
|
QObject::connect(snooze_btn, &QPushButton::clicked, [=]() { |
|
|
|
|
|
|
|
params.putBool("SnoozeUpdate", true); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
QObject::connect(snooze_btn, &QPushButton::clicked, this, &AbstractAlert::dismiss); |
|
|
|
|
|
|
|
snooze_btn->setStyleSheet(R"(color: white; background-color: #4F4F4F;)"); |
|
|
|
|
|
|
|
|
|
|
|
if (hasRebootBtn) { |
|
|
|
if (hasRebootBtn) { |
|
|
|
QPushButton *rebootBtn = new QPushButton("Reboot and Update"); |
|
|
|
QPushButton *rebootBtn = new QPushButton("Reboot and Update"); |
|
|
|
rebootBtn->setFixedSize(600, 125); |
|
|
|
rebootBtn->setFixedSize(600, 125); |
|
|
|
footer_layout->addWidget(rebootBtn, 0, Qt::AlignBottom | Qt::AlignRight); |
|
|
|
footer_layout->addWidget(rebootBtn, 0, Qt::AlignBottom | Qt::AlignRight); |
|
|
|
QObject::connect(rebootBtn, &QPushButton::clicked, [=]() { Hardware::reboot(); }); |
|
|
|
QObject::connect(rebootBtn, &QPushButton::clicked, [=]() { Hardware::reboot(); }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setStyleSheet(R"( |
|
|
|
setStyleSheet(R"( |
|
|
|
* { |
|
|
|
* { |
|
|
|
font-size: 48px; |
|
|
|
font-size: 48px; |
|
|
@ -53,10 +63,11 @@ AbstractAlert::AbstractAlert(bool hasRebootBtn, QWidget *parent) : QFrame(parent |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int OffroadAlert::refresh() { |
|
|
|
int OffroadAlert::refresh() { |
|
|
|
|
|
|
|
// build widgets for each offroad alert on first refresh
|
|
|
|
if (alerts.empty()) { |
|
|
|
if (alerts.empty()) { |
|
|
|
// setup labels for each alert
|
|
|
|
|
|
|
|
QString json = util::read_file("../controls/lib/alerts_offroad.json").c_str(); |
|
|
|
QString json = util::read_file("../controls/lib/alerts_offroad.json").c_str(); |
|
|
|
QJsonObject obj = QJsonDocument::fromJson(json.toUtf8()).object(); |
|
|
|
QJsonObject obj = QJsonDocument::fromJson(json.toUtf8()).object(); |
|
|
|
|
|
|
|
|
|
|
|
// descending sort labels by severity
|
|
|
|
// descending sort labels by severity
|
|
|
|
std::vector<std::pair<std::string, int>> sorted; |
|
|
|
std::vector<std::pair<std::string, int>> sorted; |
|
|
|
for (auto it = obj.constBegin(); it != obj.constEnd(); ++it) { |
|
|
|
for (auto it = obj.constBegin(); it != obj.constEnd(); ++it) { |
|
|
@ -87,6 +98,7 @@ int OffroadAlert::refresh() { |
|
|
|
label->setVisible(!text.isEmpty()); |
|
|
|
label->setVisible(!text.isEmpty()); |
|
|
|
alertCount += !text.isEmpty(); |
|
|
|
alertCount += !text.isEmpty(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
snooze_btn->setVisible(!alerts["Offroad_ConnectivityNeeded"]->text().isEmpty()); |
|
|
|
return alertCount; |
|
|
|
return alertCount; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|