mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-07-31 12:12:09 +08:00
Actually set percent flag when setting through Config.
Strings will detect, everything else will default to off.
This commit is contained in:
parent
41bb9e2575
commit
61c60d6d32
@ -115,10 +115,13 @@ Config::set(const t_config_option_key& opt_key, const std::string& value)
|
|||||||
auto* ptr {dynamic_cast<ConfigOptionFloatOrPercent*>(this->_config.optptr(opt_key, true))};
|
auto* ptr {dynamic_cast<ConfigOptionFloatOrPercent*>(this->_config.optptr(opt_key, true))};
|
||||||
const size_t perc = value.find("%");
|
const size_t perc = value.find("%");
|
||||||
ptr->percent = (perc != std::string::npos);
|
ptr->percent = (perc != std::string::npos);
|
||||||
if (ptr->percent)
|
if (ptr->percent) {
|
||||||
ptr->setFloat(std::stod(std::string(value).replace(value.find("%"), std::string("%").length(), "")));
|
ptr->setFloat(std::stod(std::string(value).replace(value.find("%"), std::string("%").length(), "")));
|
||||||
else
|
ptr->percent = true;
|
||||||
|
} else {
|
||||||
ptr->setFloat(std::stod(value));
|
ptr->setFloat(std::stod(value));
|
||||||
|
ptr->percent = false;
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
case coFloats:
|
case coFloats:
|
||||||
{
|
{
|
||||||
@ -169,6 +172,7 @@ Config::set(const t_config_option_key& opt_key, const int value)
|
|||||||
{
|
{
|
||||||
auto* ptr {dynamic_cast<ConfigOptionFloatOrPercent*>(this->_config.optptr(opt_key, true))};
|
auto* ptr {dynamic_cast<ConfigOptionFloatOrPercent*>(this->_config.optptr(opt_key, true))};
|
||||||
ptr->setFloat(value);
|
ptr->setFloat(value);
|
||||||
|
ptr->percent = false;
|
||||||
} break;
|
} break;
|
||||||
case coFloats:
|
case coFloats:
|
||||||
{
|
{
|
||||||
@ -216,6 +220,7 @@ Config::set(const t_config_option_key& opt_key, const double value)
|
|||||||
{
|
{
|
||||||
auto* ptr {dynamic_cast<ConfigOptionFloatOrPercent*>(this->_config.optptr(opt_key, true))};
|
auto* ptr {dynamic_cast<ConfigOptionFloatOrPercent*>(this->_config.optptr(opt_key, true))};
|
||||||
ptr->setFloat(value);
|
ptr->setFloat(value);
|
||||||
|
ptr->percent = false;
|
||||||
} break;
|
} break;
|
||||||
case coFloats:
|
case coFloats:
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user