diff --git a/selfdrive/ui/sunnypilot/qt/offroad/settings/device_panel.cc b/selfdrive/ui/sunnypilot/qt/offroad/settings/device_panel.cc index 46f388c75..ca6d6c62f 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/settings/device_panel.cc +++ b/selfdrive/ui/sunnypilot/qt/offroad/settings/device_panel.cc @@ -67,14 +67,7 @@ DevicePanelSP::DevicePanelSP(SettingsWindowSP *parent) : DevicePanel(parent) { } }); - connect(buttons["resetParams"], &PushButtonSP::clicked, [=]() { - if (ConfirmationDialog::confirm(tr("Are you sure you want to reset all sunnypilot settings to default ? This cannot be undone."), tr("Reset"), this)) { - int rm = std::system("sudo rm -rf /data/params/d/*"); - if (rm == 0) { - Hardware::reboot(); - } - } - }); + connect(buttons["resetParams"], &PushButtonSP::clicked, this, &DevicePanelSP::resetSettings); addItem(device_grid_layout); @@ -141,6 +134,19 @@ void DevicePanelSP::setOffroadMode() { updateState(); } +void DevicePanelSP::resetSettings() { + if (ConfirmationDialog::confirm(tr("Are you sure you want to reset all sunnypilot settings to default? Once the settings are reset, there is no going back."), tr("Reset"), this)) { + if (ConfirmationDialog::confirm(tr("The reset cannot be undone. You have been warned."), tr("Confirm"), this)) { + const std::vector keys = params.allKeys(); + for (const auto& key : keys) { + params.remove(key); + } + + Hardware::reboot(); + } + } +} + void DevicePanelSP::showEvent(QShowEvent *event) { updateState(); } diff --git a/selfdrive/ui/sunnypilot/qt/offroad/settings/device_panel.h b/selfdrive/ui/sunnypilot/qt/offroad/settings/device_panel.h index a781019e5..dc77aa464 100644 --- a/selfdrive/ui/sunnypilot/qt/offroad/settings/device_panel.h +++ b/selfdrive/ui/sunnypilot/qt/offroad/settings/device_panel.h @@ -18,6 +18,7 @@ public: void showEvent(QShowEvent *event) override; void setOffroadMode(); void updateState(); + void resetSettings(); private: std::map buttons;