diff --git a/Source/Core/DolphinQt/Config/ConfigControls/ConfigUserPath.cpp b/Source/Core/DolphinQt/Config/ConfigControls/ConfigUserPath.cpp index 1b6c03f915..03030f9666 100644 --- a/Source/Core/DolphinQt/Config/ConfigControls/ConfigUserPath.cpp +++ b/Source/Core/DolphinQt/Config/ConfigControls/ConfigUserPath.cpp @@ -13,13 +13,21 @@ ConfigUserPath::ConfigUserPath(const unsigned int dir_index, const Config::Info& setting) - : ConfigUserPath(dir_index, setting, nullptr) + : ConfigUserPath(dir_index, setting, "", nullptr) { } ConfigUserPath::ConfigUserPath(const unsigned int dir_index, - const Config::Info& setting, Config::Layer* layer) - : ConfigText(setting, layer), m_dir_index(dir_index) + const Config::Info& setting, + const std::string default_value) + : ConfigUserPath(dir_index, setting, default_value, nullptr) +{ +} + +ConfigUserPath::ConfigUserPath(const unsigned int dir_index, + const Config::Info& setting, + const std::string default_value, Config::Layer* layer) + : ConfigText(setting, layer), m_dir_index(dir_index), m_default_value(default_value) { OnConfigChanged(); @@ -57,3 +65,14 @@ void ConfigUserPath::OnConfigChanged() { RefreshText(); } + +void ConfigUserPath::Reset() +{ + if (m_default_value.empty()) + return; + + File::SetUserPath(m_dir_index, m_default_value); + SaveValue(m_setting, m_default_value); + + RefreshText(); +} diff --git a/Source/Core/DolphinQt/Config/ConfigControls/ConfigUserPath.h b/Source/Core/DolphinQt/Config/ConfigControls/ConfigUserPath.h index 40fea63709..a217e42fa6 100644 --- a/Source/Core/DolphinQt/Config/ConfigControls/ConfigUserPath.h +++ b/Source/Core/DolphinQt/Config/ConfigControls/ConfigUserPath.h @@ -15,7 +15,10 @@ class ConfigUserPath final : public ConfigText public: ConfigUserPath(const unsigned int dir_index, const Config::Info& setting); ConfigUserPath(const unsigned int dir_index, const Config::Info& setting, - Config::Layer* layer); + std::string default_value); + ConfigUserPath(const unsigned int dir_index, const Config::Info& setting, + std::string default_value, Config::Layer* layer); + void Reset(); protected: void OnConfigChanged() override; @@ -25,4 +28,5 @@ private: void Update(); const unsigned int m_dir_index; + const std::string m_default_value; };