UI: add button to check for updates (#21103)

* UI: add button to check for updates

* send signal

* this is better

* that's in the description

* revert that

Co-authored-by: Comma Device <device@comma.ai>
old-commit-hash: 65e1d8f633
commatwo_master
Adeeb Shihadeh 4 years ago committed by GitHub
parent fb62002e92
commit 04e5fbe15e
  1. 20
      selfdrive/ui/qt/offroad/settings.cc
  2. 1
      selfdrive/ui/qt/offroad/settings.h

@ -212,6 +212,8 @@ DeveloperPanel::DeveloperPanel(QWidget* parent) : QFrame(parent) {
int update_failed_count = Params().get<int>("UpdateFailedCount").value_or(0); int update_failed_count = Params().get<int>("UpdateFailedCount").value_or(0);
if (path.contains("UpdateFailedCount") && update_failed_count > 0) { if (path.contains("UpdateFailedCount") && update_failed_count > 0) {
lastUpdateTimeLbl->setText("failed to fetch update"); lastUpdateTimeLbl->setText("failed to fetch update");
updateButton->setText("CHECK");
updateButton->setEnabled(true);
} else if (path.contains("LastUpdateTime")) { } else if (path.contains("LastUpdateTime")) {
updateLabels(); updateLabels();
} }
@ -246,21 +248,27 @@ void DeveloperPanel::updateLabels() {
layout()->addWidget(versionLbl); layout()->addWidget(versionLbl);
layout()->addWidget(horizontal_line()); layout()->addWidget(horizontal_line());
lastUpdateTimeLbl = new LabelControl("Last Update Check", lastUpdateTime, "The last time openpilot checked for an update. Updates are only checked while car is off."); lastUpdateTimeLbl = new LabelControl("Last Update Check", lastUpdateTime, "The last time openpilot successfully checked for an update. The updater only runs while the car is off.");
connect(lastUpdateTimeLbl, &LabelControl::showDescription, [=]() { layout()->addWidget(lastUpdateTimeLbl);
layout()->addWidget(horizontal_line());
updateButton = new ButtonControl("Check for Update", "CHECK", "", [=]() {
Params params = Params(); Params params = Params();
if (params.getBool("IsOffroad")) { if (params.getBool("IsOffroad")) {
fs_watch->addPath(QString::fromStdString(params.getParamsPath()) + "/d/LastUpdateTime"); fs_watch->addPath(QString::fromStdString(params.getParamsPath()) + "/d/LastUpdateTime");
fs_watch->addPath(QString::fromStdString(params.getParamsPath()) + "/d/UpdateFailedCount"); fs_watch->addPath(QString::fromStdString(params.getParamsPath()) + "/d/UpdateFailedCount");
lastUpdateTimeLbl->setText("checking..."); updateButton->setText("CHECKING");
std::system("pkill -1 -f selfdrive.updated"); updateButton->setEnabled(false);
} }
}); std::system("pkill -1 -f selfdrive.updated");
layout()->addWidget(lastUpdateTimeLbl); }, "", this);
layout()->addWidget(updateButton);
layout()->addWidget(horizontal_line()); layout()->addWidget(horizontal_line());
} else { } else {
versionLbl->setText(version); versionLbl->setText(version);
lastUpdateTimeLbl->setText(lastUpdateTime); lastUpdateTimeLbl->setText(lastUpdateTime);
updateButton->setText("CHECK");
updateButton->setEnabled(true);
} }
for (int i = 0; i < dev_params.size(); i++) { for (int i = 0; i < dev_params.size(); i++) {

@ -41,6 +41,7 @@ private:
QList<LabelControl *> labels; QList<LabelControl *> labels;
LabelControl *versionLbl; LabelControl *versionLbl;
LabelControl *lastUpdateTimeLbl; LabelControl *lastUpdateTimeLbl;
ButtonControl *updateButton;
void updateLabels(); void updateLabels();
QFileSystemWatcher *fs_watch; QFileSystemWatcher *fs_watch;

Loading…
Cancel
Save