mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-07 06:57:36 -06:00
ENH:do not write to config file when user access code is empty
Change-Id: I180e20b7d26fd337eef09ff4267cd4c2c61b6518
This commit is contained in:
parent
4892a0491c
commit
c351ac54aa
4 changed files with 31 additions and 16 deletions
|
@ -337,14 +337,6 @@ std::string MachineObject::get_ftp_folder()
|
|||
return DeviceManager::get_ftp_folder(printer_type);
|
||||
}
|
||||
|
||||
void MachineObject::set_access_code(std::string code)
|
||||
{
|
||||
this->access_code = code;
|
||||
AppConfig *config = GUI::wxGetApp().app_config;
|
||||
if (config && !code.empty()) {
|
||||
GUI::wxGetApp().app_config->set_str("access_code", dev_id, code);
|
||||
}
|
||||
}
|
||||
|
||||
std::string MachineObject::get_access_code()
|
||||
{
|
||||
|
@ -353,12 +345,35 @@ std::string MachineObject::get_access_code()
|
|||
return get_user_access_code();
|
||||
}
|
||||
|
||||
void MachineObject::set_user_access_code(std::string code)
|
||||
void MachineObject::set_access_code(std::string code, bool only_refresh)
|
||||
{
|
||||
this->user_access_code = code;
|
||||
this->access_code = code;
|
||||
if (only_refresh) {
|
||||
AppConfig* config = GUI::wxGetApp().app_config;
|
||||
if (config && !code.empty()) {
|
||||
GUI::wxGetApp().app_config->set_str("access_code", dev_id, code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MachineObject::erase_user_access_code()
|
||||
{
|
||||
this->user_access_code = "";
|
||||
AppConfig* config = GUI::wxGetApp().app_config;
|
||||
if (config) {
|
||||
GUI::wxGetApp().app_config->set_str("user_access_code", dev_id, code);
|
||||
GUI::wxGetApp().app_config->erase("user_access_code", dev_id);
|
||||
GUI::wxGetApp().app_config->save();
|
||||
}
|
||||
}
|
||||
|
||||
void MachineObject::set_user_access_code(std::string code, bool only_refresh)
|
||||
{
|
||||
this->user_access_code = code;
|
||||
if (only_refresh && !code.empty()) {
|
||||
AppConfig* config = GUI::wxGetApp().app_config;
|
||||
if (config) {
|
||||
GUI::wxGetApp().app_config->set_str("user_access_code", dev_id, code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue