mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-17 10:32:20 +00:00
add user name placeholder (#10109)
* Add user name placeholder * non-ASCII character support * fix: Explicitly include <boost/nowide/cstdlib.hpp>
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/nowide/convert.hpp>
|
||||
#include <boost/nowide/cstdlib.hpp>
|
||||
|
||||
// Spirit v2.5 allows you to suppress automatic generation
|
||||
// of predefined terminals to speed up complation. With
|
||||
@@ -71,6 +72,7 @@ PlaceholderParser::PlaceholderParser(const DynamicConfig *external_config) : m_e
|
||||
this->set("version", std::string(SoftFever_VERSION));
|
||||
this->apply_env_variables();
|
||||
this->update_timestamp();
|
||||
this->update_user_name();
|
||||
}
|
||||
|
||||
void PlaceholderParser::update_timestamp(DynamicConfig &config)
|
||||
@@ -98,6 +100,12 @@ void PlaceholderParser::update_timestamp(DynamicConfig &config)
|
||||
config.set_key_value("second", new ConfigOptionInt(timeinfo->tm_sec));
|
||||
}
|
||||
|
||||
void PlaceholderParser::update_user_name(DynamicConfig &config)
|
||||
{
|
||||
const char* user = boost::nowide::getenv("USER") ? boost::nowide::getenv("USER") : boost::nowide::getenv("USERNAME") ? boost::nowide::getenv("USERNAME") : "unknown";
|
||||
config.set_key_value("user", new ConfigOptionString(user));
|
||||
}
|
||||
|
||||
static inline bool opts_equal(const DynamicConfig &config_old, const DynamicConfig &config_new, const std::string &opt_key)
|
||||
{
|
||||
const ConfigOption *opt_old = config_old.option(opt_key);
|
||||
|
||||
Reference in New Issue
Block a user