diff --git a/src/common_func/common_func.cpp b/src/common_func/common_func.cpp index 410e31568f..3a0ecaef1f 100644 --- a/src/common_func/common_func.cpp +++ b/src/common_func/common_func.cpp @@ -71,6 +71,44 @@ namespace common #endif // _WIN32 return machineId; } + std::string get_profile_version() + { + std::string versionFilePath = ""; +#ifdef _WIN32 + + + + PWSTR pszPath = nullptr; + char* path = new char[MAX_PATH](); + size_t pathLength = 0; + HRESULT hr = SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, nullptr, &pszPath); + if (SUCCEEDED(hr)) { + wcstombs_s(&pathLength, path, MAX_PATH, pszPath, MAX_PATH); + CoTaskMemFree(pszPath); + } + + std::string filePath = path; + versionFilePath = filePath + "\\" + std::string("Snapmaker_Orca\\system\\Snapmaker.json"); + delete[] path; +#elif __APPLE__ + const char* home_env = getenv("HOME"); + versionFilePath = home_env; + versionFilePath = versionFilePath + "/Library/Application Support/Snapmaker_Orca/system/Snapmaker.json"; +#else + + +#endif + std::ifstream json_file(versionFilePath); + if (!json_file.is_open()) { + std::ifstream json_file(versionFilePath); + return ""; + } + nlohmann::json json_data; + json_file >> json_data; + std::string str_version = json_data.value("version", ""); + + return str_version; + } std::string get_flutter_version() { diff --git a/src/common_func/common_func.hpp b/src/common_func/common_func.hpp index 3711d18b86..a9b8f737d3 100644 --- a/src/common_func/common_func.hpp +++ b/src/common_func/common_func.hpp @@ -23,6 +23,8 @@ namespace common std::string get_flutter_version(); + std::string get_profile_version(); + std::string getMachineId(); std::string getLocalArea(); diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index a3c8a56824..51fed40c67 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1082,7 +1082,9 @@ GUI_App::GUI_App() m_page_http_server.setPort(PAGE_HTTP_PORT); m_page_http_server.set_request_handler(HttpServer::web_server_handle_request); m_page_http_server.start(); - + BOOST_LOG_TRIVIAL(info) << "[Flutter] Version:"<