ui: use allKeys to reset sunnypilot settings (#699)

* ui: exclude certain params from deletion during settings reset

* clear all and exclude directly and only reboot after confirmation

* cleaner

* handle this instead

* send it

* 1-liner

* nuke nuke

* space

* less
This commit is contained in:
Jason Wen
2025-03-22 22:41:42 -04:00
committed by GitHub
parent bab2d776b6
commit ed39aaddbc
2 changed files with 15 additions and 8 deletions
@@ -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<std::string> keys = params.allKeys();
for (const auto& key : keys) {
params.remove(key);
}
Hardware::reboot();
}
}
}
void DevicePanelSP::showEvent(QShowEvent *event) {
updateState();
}
@@ -18,6 +18,7 @@ public:
void showEvent(QShowEvent *event) override;
void setOffroadMode();
void updateState();
void resetSettings();
private:
std::map<QString, PushButtonSP*> buttons;