mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-08-05 00:05:57 +08:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user