Add reset button for config

This commit is contained in:
Michael Theall 2020-12-30 13:37:02 -05:00
parent c4f36f165b
commit 607ca560bf

View File

@ -448,11 +448,13 @@ void FtpServer::showSettings ()
ImGui::TextColored (ImVec4 (1.0f, 0.4f, 0.4f, 1.0f), passphraseError);
#endif
auto const apply = ImGui::Button ("Apply", ImVec2 (100, 0));
auto const apply = ImGui::Button ("Apply", ImVec2 (75, 0));
ImGui::SameLine ();
auto const save = ImGui::Button ("Save", ImVec2 (100, 0));
auto const save = ImGui::Button ("Save", ImVec2 (75, 0));
ImGui::SameLine ();
auto const cancel = ImGui::Button ("Cancel", ImVec2 (100, 0));
auto const reset = ImGui::Button ("Reset", ImVec2 (75, 0));
ImGui::SameLine ();
auto const cancel = ImGui::Button ("Cancel", ImVec2 (75, 0));
if (apply || save)
{
@ -482,14 +484,33 @@ void FtpServer::showSettings ()
LOCKED (socket = std::move (m_socket));
}
if (save)
{
#ifndef NDS
auto const lock = m_config->lockGuard ();
#endif
if (save && !m_config->save (FTPDCONFIG))
if (!m_config->save (FTPDCONFIG))
error ("Failed to save config\n");
}
if (reset)
{
static auto const defaults = FtpConfig::create ();
m_userSetting = defaults->user ();
m_passSetting = defaults->pass ();
m_portSetting = defaults->port ();
#ifdef _3DS
m_getMTimeSetting = defaults->getMTime ();
#endif
#ifdef __SWITCH__
m_enableAPSetting = defaults->enableAP ();
m_ssidSetting = defaults->ssid ();
m_passphraseSetting = defaults->passphrase ();
#endif
}
if (apply || save || cancel)
{
m_showSettings = false;