mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-04 22:31:02 +00:00
Fix AppConfig text persistence and section-specific boolean reads (#16092)
This commit is contained in:
@@ -163,7 +163,7 @@ public:
|
||||
std::string get(const std::string &key) const
|
||||
{ std::string value; this->get("app", key, value); return value; }
|
||||
bool get_bool(const std::string §ion, const std::string &key) const
|
||||
{ return this->get(section, key) == "true" || this->get(key) == "1"; }
|
||||
{ const std::string value = this->get(section, key); return value == "true" || value == "1"; }
|
||||
bool get_bool(const std::string &key) const
|
||||
{ return this->get_bool("app", key); }
|
||||
void set(const std::string §ion, const std::string &key, const std::string &value)
|
||||
@@ -200,6 +200,9 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void set(const std::string& section, const std::string& key, const char* value)
|
||||
{ this->set(section, key, std::string(value)); }
|
||||
|
||||
void set(const std::string& section, const std::string &key, bool value)
|
||||
{
|
||||
if (value){
|
||||
|
||||
@@ -835,7 +835,7 @@ int GuideFrame::SaveProfile()
|
||||
m_MainPtr->app_config->set_bool("stealth_mode", StealthMode);
|
||||
|
||||
//finish
|
||||
m_MainPtr->app_config->set(std::string(m_SectionName.mb_str()), "finish", "1");
|
||||
m_MainPtr->app_config->set(std::string(m_SectionName.mb_str()), "finish", true);
|
||||
|
||||
m_MainPtr->app_config->save();
|
||||
|
||||
|
||||
@@ -45,6 +45,31 @@ TEST_CASE("AppConfig network version helpers", "[AppConfig]") {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Remembered checkbox settings retain both selections", "[AppConfig][Regression]") {
|
||||
AppConfig config;
|
||||
const bool checked = GENERATE(false, true);
|
||||
|
||||
config.set("recent", "checkbox", checked ? "1" : "0");
|
||||
CHECK(config.get("recent", "checkbox") == (checked ? "1" : "0"));
|
||||
}
|
||||
|
||||
TEST_CASE("Boolean setters retain their established encoding", "[AppConfig][Regression]") {
|
||||
AppConfig config;
|
||||
const bool value = GENERATE(false, true);
|
||||
|
||||
config.set("recent", "flag", value);
|
||||
CHECK(config.get("recent", "flag") == (value ? "true" : "false"));
|
||||
}
|
||||
|
||||
TEST_CASE("Boolean reads use only the requested section", "[AppConfig][Regression]") {
|
||||
AppConfig config;
|
||||
const bool value = GENERATE(false, true);
|
||||
config.set("recent", "flag", std::string(value ? "1" : "0"));
|
||||
config.set("app", "flag", std::string(value ? "0" : "1"));
|
||||
|
||||
CHECK(config.get_bool("recent", "flag") == value);
|
||||
}
|
||||
|
||||
TEST_CASE("AppConfig Speed Dial recent count defaults, clamps and parses", "[AppConfig]") {
|
||||
AppConfig config;
|
||||
|
||||
|
||||
@@ -327,7 +327,6 @@ TEST_CASE("Custom bindings replace the default and survive a config round trip",
|
||||
TEST_CASE("A Global shortcut refuses a config binding that would swallow typing", "[Shortcuts]")
|
||||
{
|
||||
AppConfig config;
|
||||
// A string literal would pick AppConfig::set's bool overload.
|
||||
config.set("shortcuts", "save_project", std::string("S"));
|
||||
config.set("shortcuts", "new_project", std::string("F9"));
|
||||
ShortcutRegistry registry;
|
||||
|
||||
Reference in New Issue
Block a user