settings: Add resetSettings() method

Allows the GUI to clear settings.json file and save settings.json.bak file when
GUI "Reset Options" button is pressed or -resetguisettings command line option
is used. (GUI code already backs up and resets the "guisettings.ini" file this
way, so this just makes the same behavior possible for "settings.json")
This commit is contained in:
Ryan Ofsky
2022-05-16 14:37:00 -04:00
parent 77fabffef4
commit f9fdcec7e9
4 changed files with 22 additions and 6 deletions

View File

@@ -144,6 +144,14 @@ public:
}
});
}
void resetSettings() override
{
gArgs.WriteSettingsFile(/*errors=*/nullptr, /*backup=*/true);
gArgs.LockSettings([&](util::Settings& settings) {
settings.rw_settings.clear();
});
gArgs.WriteSettingsFile();
}
void mapPort(bool use_upnp, bool use_natpmp) override { StartMapPort(use_upnp, use_natpmp); }
bool getProxy(Network net, Proxy& proxy_info) override { return GetProxy(net, proxy_info); }
size_t getNodeCount(ConnectionDirection flags) override