mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-24 23:23:59 -06:00
ENH: SaveProfileData to AppConfig in MainThread
JIRA: none Change-Id: I22ae3dac5e2bed42a2edfb848d627cd5092ef171 (cherry picked from commit c2042d7e20ab03001e4b38f366d0f129f2ee0918) (cherry picked from commit d027e098acf37330076273799d2ff873a07044b5)
This commit is contained in:
parent
d753292823
commit
5e79e9196f
2 changed files with 28 additions and 14 deletions
|
@ -296,7 +296,7 @@ void GuideFrame::OnNavigationComplete(wxWebViewEvent &evt)
|
|||
{
|
||||
//wxLogMessage("%s", "Navigation complete; url='" + evt.GetURL() + "'");
|
||||
if (!bFirstComplete) {
|
||||
boost::thread LoadProfileThread(boost::bind(&GuideFrame::LoadProfile, this));
|
||||
boost::thread LoadProfileThread(boost::bind(&GuideFrame::LoadProfileData, this));
|
||||
LoadProfileThread.detach();
|
||||
|
||||
bFirstComplete = true;
|
||||
|
@ -977,8 +977,7 @@ int GuideFrame::GetFilamentInfo( std::string VendorDirectory, json & pFilaList,
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int GuideFrame::LoadProfile()
|
||||
int GuideFrame::LoadProfileData()
|
||||
{
|
||||
try {
|
||||
m_ProfileJson = json::parse("{}");
|
||||
|
@ -987,7 +986,7 @@ int GuideFrame::LoadProfile()
|
|||
m_ProfileJson["filament"] = json::object();
|
||||
m_ProfileJson["process"] = json::array();
|
||||
|
||||
vendor_dir = (boost::filesystem::path(Slic3r::data_dir()) / PRESET_SYSTEM_DIR ).make_preferred();
|
||||
vendor_dir = (boost::filesystem::path(Slic3r::data_dir()) / PRESET_SYSTEM_DIR).make_preferred();
|
||||
rsrc_vendor_dir = (boost::filesystem::path(resources_dir()) / "profiles").make_preferred();
|
||||
|
||||
// Orca: add custom as default
|
||||
|
@ -1046,8 +1045,31 @@ int GuideFrame::LoadProfile()
|
|||
}
|
||||
}
|
||||
|
||||
//sync to web
|
||||
std::string strAll = m_ProfileJson.dump(-1, ' ', false, json::error_handler_t::ignore);
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", finished, json contents: " << std::endl << strAll;
|
||||
json m_Res = json::object();
|
||||
m_Res["command"] = "userguide_profile_load_finish";
|
||||
m_Res["sequence_id"] = "10001";
|
||||
wxString strJS = wxString::Format("HandleStudio(%s)", m_Res.dump(-1, ' ', true));
|
||||
wxGetApp().CallAfter([this, strJS] { RunScript(strJS); });
|
||||
|
||||
//sync to appconfig
|
||||
wxGetApp().CallAfter([this] { SaveProfileData(); });
|
||||
|
||||
} catch (std::exception &e) {
|
||||
// wxLogMessage("GUIDE: load_profile_error %s ", e.what());
|
||||
// wxMessageBox(e.what(), "", MB_OK);
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ", error: " << e.what() << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GuideFrame::SaveProfileData()
|
||||
{
|
||||
try {
|
||||
const auto enabled_filaments = wxGetApp().app_config->has_section(AppConfig::SECTION_FILAMENTS) ? wxGetApp().app_config->get_section(AppConfig::SECTION_FILAMENTS) : std::map<std::string, std::string>();
|
||||
m_appconfig_new.set_vendors(*wxGetApp().app_config);
|
||||
m_appconfig_new.set_section(AppConfig::SECTION_FILAMENTS, enabled_filaments);
|
||||
|
@ -1120,15 +1142,6 @@ int GuideFrame::LoadProfile()
|
|||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ", error: "<< e.what() <<std::endl;
|
||||
}
|
||||
|
||||
std::string strAll = m_ProfileJson.dump(-1, ' ', false, json::error_handler_t::ignore);
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", finished, json contents: "<< std::endl<<strAll;
|
||||
json m_Res = json::object();
|
||||
m_Res["command"] = "userguide_profile_load_finish";
|
||||
m_Res["sequence_id"] = "10001";
|
||||
wxString strJS = wxString::Format("HandleStudio(%s)", m_Res.dump(-1, ' ', true));
|
||||
wxGetApp().CallAfter([this, strJS] { RunScript(strJS); });
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,8 @@ public:
|
|||
bool IsFirstUse();
|
||||
|
||||
//Model - Machine - Filaments
|
||||
int LoadProfile();
|
||||
int LoadProfileData();
|
||||
int SaveProfileData();
|
||||
int LoadProfileFamily(std::string strVendor, std::string strFilePath);
|
||||
int SaveProfile();
|
||||
int GetFilamentInfo( std::string VendorDirectory,json & pFilaList, std::string filepath, std::string &sVendor, std::string &sType);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue