mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 08:47:52 -06:00
Merge branch 'master-remote' into feature/1.5
Signed-off-by: SoftFever <softfeverever@gmail.com> # Conflicts: # bbl/i18n/BambuStudio.pot # bbl/i18n/de/BambuStudio_de.po # bbl/i18n/en/BambuStudio_en.po # bbl/i18n/es/BambuStudio_es.po # bbl/i18n/fr/BambuStudio_fr.po # bbl/i18n/hu/BambuStudio_hu.po # bbl/i18n/it/BambuStudio_it.po # bbl/i18n/nl/BambuStudio_nl.po # bbl/i18n/sv/BambuStudio_sv.po # bbl/i18n/zh_cn/BambuStudio_zh_CN.po # deps/Boost/Boost.cmake # deps/wxWidgets/wxWidgets.cmake # resources/config.json # resources/i18n/de/BambuStudio.mo # resources/i18n/en/BambuStudio.mo # resources/i18n/es/BambuStudio.mo # resources/i18n/fr/BambuStudio.mo # resources/i18n/hu/BambuStudio.mo # resources/i18n/it/BambuStudio.mo # resources/i18n/nl/BambuStudio.mo # resources/i18n/sv/BambuStudio.mo # resources/i18n/zh_cn/BambuStudio.mo # resources/images/tips_arrow.svg # resources/profiles/Anycubic.json # resources/profiles/Anycubic/filament/Anycubic Generic ABS.json # resources/profiles/Anycubic/filament/Anycubic Generic ASA.json # resources/profiles/Anycubic/filament/Anycubic Generic PA-CF.json # resources/profiles/Anycubic/filament/Anycubic Generic PA.json # resources/profiles/Anycubic/filament/Anycubic Generic PC.json # resources/profiles/Anycubic/filament/Anycubic Generic PETG.json # resources/profiles/Anycubic/filament/Anycubic Generic PLA-CF.json # resources/profiles/Anycubic/filament/Anycubic Generic PLA.json # resources/profiles/Anycubic/filament/Anycubic Generic PVA.json # resources/profiles/Anycubic/filament/Anycubic Generic TPU.json # resources/profiles/Anycubic/filament/fdm_filament_common.json # resources/profiles/Anycubic/machine/Anycubic 4Max Pro 0.4 nozzle.json # resources/profiles/Anycubic/machine/Anycubic 4Max Pro.json # resources/profiles/Anycubic/process/0.20mm Standard @4MaxPro.json # resources/profiles/Anycubic/process/fdm_process_common.json # resources/profiles/BBL.json # resources/profiles/BBL/machine/Bambu Lab P1P 0.2 nozzle.json # resources/profiles/BBL/machine/Bambu Lab P1P 0.4 nozzle.json # resources/profiles/BBL/machine/Bambu Lab P1P 0.6 nozzle.json # resources/profiles/BBL/machine/Bambu Lab P1P 0.8 nozzle.json # resources/profiles/BBL/machine/Bambu Lab X1 0.2 nozzle.json # resources/profiles/BBL/machine/Bambu Lab X1 0.4 nozzle.json # resources/profiles/BBL/machine/Bambu Lab X1 0.6 nozzle.json # resources/profiles/BBL/machine/Bambu Lab X1 0.8 nozzle.json # resources/profiles/BBL/machine/Bambu Lab X1 Carbon 0.2 nozzle.json # resources/profiles/BBL/machine/Bambu Lab X1 Carbon 0.4 nozzle.json # resources/profiles/BBL/machine/Bambu Lab X1 Carbon 0.6 nozzle.json # resources/profiles/BBL/machine/Bambu Lab X1 Carbon 0.8 nozzle.json # resources/profiles/BBL/machine/fdm_bbl_3dp_001_common.json # resources/profiles/Voron.json # resources/web/data/text.js # resources/web/image/printer/Anycubic 4Max Pro_cover.png # src/BambuStudio.cpp # src/libslic3r/GCode.cpp # src/libslic3r/GCode.hpp # src/libslic3r/GCode/GCodeProcessor.cpp # src/libslic3r/GCodeWriter.hpp # src/libslic3r/PerimeterGenerator.cpp # src/libslic3r/PresetBundle.cpp # src/libslic3r/Print.cpp # src/libslic3r/Print.hpp # src/libslic3r/PrintConfig.cpp # src/libslic3r/PrintConfig.hpp # src/libslic3r/PrintObject.cpp # src/slic3r/GUI/AMSMaterialsSetting.cpp # src/slic3r/GUI/AMSMaterialsSetting.hpp # src/slic3r/GUI/AmsMappingPopup.cpp # src/slic3r/GUI/AmsMappingPopup.hpp # src/slic3r/GUI/Auxiliary.cpp # src/slic3r/GUI/BackgroundSlicingProcess.cpp # src/slic3r/GUI/ConfigManipulation.cpp # src/slic3r/GUI/DeviceManager.cpp # src/slic3r/GUI/DeviceManager.hpp # src/slic3r/GUI/ExtrusionCalibration.cpp # src/slic3r/GUI/GCodeViewer.cpp # src/slic3r/GUI/GCodeViewer.hpp # src/slic3r/GUI/GUI_App.cpp # src/slic3r/GUI/IMSlider.cpp # src/slic3r/GUI/Jobs/PrintJob.cpp # src/slic3r/GUI/Jobs/PrintJob.hpp # src/slic3r/GUI/Jobs/SendJob.cpp # src/slic3r/GUI/Jobs/SendJob.hpp # src/slic3r/GUI/MainFrame.cpp # src/slic3r/GUI/MainFrame.hpp # src/slic3r/GUI/MediaPlayCtrl.cpp # src/slic3r/GUI/OptionsGroup.cpp # src/slic3r/GUI/PhysicalPrinterDialog.cpp # src/slic3r/GUI/Plater.cpp # src/slic3r/GUI/PrintHostDialogs.cpp # src/slic3r/GUI/Printer/BambuTunnel.h # src/slic3r/GUI/Printer/PrinterFileSystem.cpp # src/slic3r/GUI/Printer/gstbambusrc.c # src/slic3r/GUI/Printer/gstbambusrc.h # src/slic3r/GUI/ReleaseNote.cpp # src/slic3r/GUI/ReleaseNote.hpp # src/slic3r/GUI/SelectMachine.cpp # src/slic3r/GUI/SendToPrinter.cpp # src/slic3r/GUI/SetBedTypeDialog.cpp # src/slic3r/GUI/StatusPanel.cpp # src/slic3r/GUI/StatusPanel.hpp # src/slic3r/GUI/Tab.cpp # src/slic3r/GUI/Widgets/AMSControl.cpp # src/slic3r/GUI/Widgets/AMSControl.hpp # src/slic3r/GUI/Widgets/ImageSwitchButton.cpp # src/slic3r/GUI/Widgets/Label.cpp # src/slic3r/GUI/WipeTowerDialog.cpp # src/slic3r/Utils/Process.cpp # src/slic3r/Utils/bambu_networking.hpp # version.inc
This commit is contained in:
commit
5ef51f6c8a
339 changed files with 37169 additions and 5445 deletions
|
@ -39,6 +39,7 @@
|
|||
#include <wx/textctrl.h>
|
||||
#include <wx/splash.h>
|
||||
#include <wx/fontutil.h>
|
||||
#include <wx/glcanvas.h>
|
||||
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
|
@ -86,8 +87,8 @@
|
|||
//BBS: DailyTip and UserGuide Dialog
|
||||
#include "WebDownPluginDlg.hpp"
|
||||
#include "WebGuideDialog.hpp"
|
||||
#include "WebUserLoginDialog.hpp"
|
||||
#include "ReleaseNote.hpp"
|
||||
#include "PrivacyUpdateDialog.hpp"
|
||||
#include "ModelMall.hpp"
|
||||
|
||||
//#ifdef WIN32
|
||||
|
@ -1016,25 +1017,31 @@ void GUI_App::post_init()
|
|||
mainframe->select_tab(size_t(MainFrame::tp3DEditor));
|
||||
plater_->select_view_3D("3D");
|
||||
//BBS init the opengl resource here
|
||||
Size canvas_size = plater_->canvas3D()->get_canvas_size();
|
||||
wxGetApp().imgui()->set_display_size(static_cast<float>(canvas_size.get_width()), static_cast<float>(canvas_size.get_height()));
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", start to init opengl";
|
||||
wxGetApp().init_opengl();
|
||||
#ifdef __linux__
|
||||
if (plater_->canvas3D()->get_wxglcanvas()->IsShownOnScreen()&&plater_->canvas3D()->make_current_for_postinit()) {
|
||||
#endif
|
||||
Size canvas_size = plater_->canvas3D()->get_canvas_size();
|
||||
wxGetApp().imgui()->set_display_size(static_cast<float>(canvas_size.get_width()), static_cast<float>(canvas_size.get_height()));
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", start to init opengl";
|
||||
wxGetApp().init_opengl();
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", finished init opengl";
|
||||
plater_->canvas3D()->init();
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", finished init opengl";
|
||||
plater_->canvas3D()->init();
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", finished init canvas3D";
|
||||
wxGetApp().imgui()->new_frame();
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", finished init canvas3D";
|
||||
wxGetApp().imgui()->new_frame();
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", finished init imgui frame";
|
||||
plater_->canvas3D()->enable_render(true);
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", finished init imgui frame";
|
||||
plater_->canvas3D()->enable_render(true);
|
||||
|
||||
if (!slow_bootup) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", start to render a first frame for test";
|
||||
plater_->canvas3D()->render(false);
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", finished rendering a first frame for test";
|
||||
if (!slow_bootup) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", start to render a first frame for test";
|
||||
plater_->canvas3D()->render(false);
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", finished rendering a first frame for test";
|
||||
}
|
||||
#ifdef __linux__
|
||||
}
|
||||
#endif
|
||||
if (is_editor())
|
||||
mainframe->select_tab(size_t(0));
|
||||
mainframe->Thaw();
|
||||
|
@ -1119,6 +1126,9 @@ void GUI_App::post_init()
|
|||
|
||||
//BBS: check new version
|
||||
this->check_new_version_sf();
|
||||
//BBS: check privacy version
|
||||
if (is_user_login())
|
||||
this->check_privacy_version(0);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1155,6 +1165,9 @@ void GUI_App::post_init()
|
|||
std::string functional_config_file = Slic3r::resources_dir() + "/config.json";
|
||||
DeviceManager::load_functional_config(encode_path(functional_config_file.c_str()));
|
||||
|
||||
std::string filaments_blacklist_config_file = Slic3r::resources_dir() + "/printers/filaments_blacklist.json";
|
||||
DeviceManager::load_filaments_blacklist_config(encode_path(filaments_blacklist_config_file.c_str()));
|
||||
|
||||
// remove old log files over LOG_FILES_MAX_NUM
|
||||
std::string log_addr = data_dir();
|
||||
if (!log_addr.empty()) {
|
||||
|
@ -1228,6 +1241,13 @@ void GUI_App::shutdown()
|
|||
removable_drive_manager()->shutdown();
|
||||
}
|
||||
|
||||
// destroy login dialog
|
||||
if (login_dlg != nullptr) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< boost::format(": destroy login dialog");
|
||||
delete login_dlg;
|
||||
login_dlg = nullptr;
|
||||
}
|
||||
|
||||
if (m_is_recreating_gui) return;
|
||||
m_is_closing = true;
|
||||
stop_sync_user_preset();
|
||||
|
@ -1646,9 +1666,9 @@ void GUI_App::init_networking_callbacks()
|
|||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< boost::format(": enter, m_agent=%1%")%m_agent;
|
||||
if (m_agent) {
|
||||
//set callbacks
|
||||
m_agent->set_on_user_login_fn([this](int online_login, bool login) {
|
||||
GUI::wxGetApp().request_user_login(online_login);
|
||||
});
|
||||
//m_agent->set_on_user_login_fn([this](int online_login, bool login) {
|
||||
// GUI::wxGetApp().request_user_handle(online_login);
|
||||
// });
|
||||
|
||||
m_agent->set_on_server_connected_fn([this]() {
|
||||
if (m_is_closing) {
|
||||
|
@ -1708,6 +1728,7 @@ void GUI_App::init_networking_callbacks()
|
|||
event.SetString(obj->dev_id);
|
||||
} else if (state == ConnectStatus::ConnectStatusFailed) {
|
||||
obj->set_access_code("");
|
||||
obj->set_user_access_code("");
|
||||
m_device_manager->set_selected_machine("");
|
||||
wxString text;
|
||||
if (msg == "5") {
|
||||
|
@ -1748,8 +1769,9 @@ void GUI_App::init_networking_callbacks()
|
|||
obj->is_ams_need_update = false;
|
||||
obj->parse_json(msg);
|
||||
|
||||
if (this->m_device_manager->get_selected_machine() == obj && obj->is_ams_need_update) {
|
||||
GUI::wxGetApp().sidebar().load_ams_list(obj->amsList);
|
||||
auto sel = this->m_device_manager->get_selected_machine();
|
||||
if ((sel == obj || sel == nullptr) && obj->is_ams_need_update) {
|
||||
GUI::wxGetApp().sidebar().load_ams_list(obj->dev_id, obj->amsList);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1773,7 +1795,7 @@ void GUI_App::init_networking_callbacks()
|
|||
if (obj) {
|
||||
obj->parse_json(msg);
|
||||
if (this->m_device_manager->get_selected_machine() == obj && obj->is_ams_need_update) {
|
||||
GUI::wxGetApp().sidebar().load_ams_list(obj->amsList);
|
||||
GUI::wxGetApp().sidebar().load_ams_list(obj->dev_id, obj->amsList);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1856,10 +1878,8 @@ void GUI_App::init_download_path()
|
|||
fs::path dp(down_path);
|
||||
if (!fs::exists(dp)) {
|
||||
|
||||
if (!fs::create_directory(dp)) {
|
||||
std::string user_down_path = wxStandardPaths::Get().GetUserDir(wxStandardPaths::Dir_Downloads).ToUTF8().data();
|
||||
app_config->set("download_path", user_down_path);
|
||||
}
|
||||
std::string user_down_path = wxStandardPaths::Get().GetUserDir(wxStandardPaths::Dir_Downloads).ToUTF8().data();
|
||||
app_config->set("download_path", user_down_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1978,6 +1998,14 @@ void GUI_App::init_http_extra_header()
|
|||
m_agent->set_extra_http_header(extra_headers);
|
||||
}
|
||||
|
||||
void GUI_App::update_http_extra_header()
|
||||
{
|
||||
std::map<std::string, std::string> extra_headers = get_extra_header();
|
||||
Slic3r::Http::set_extra_headers(extra_headers);
|
||||
if (m_agent)
|
||||
m_agent->set_extra_http_header(extra_headers);
|
||||
}
|
||||
|
||||
std::string GUI_App::get_local_models_path()
|
||||
{
|
||||
std::string local_path = "";
|
||||
|
@ -2064,7 +2092,7 @@ bool GUI_App::on_init_inner()
|
|||
}
|
||||
}
|
||||
for (auto d : dialogStack)
|
||||
d->EndModal(wxID_CANCEL);
|
||||
d->EndModal(wxID_ABORT);
|
||||
});
|
||||
|
||||
std::map<std::string, std::string> extra_headers = get_extra_header();
|
||||
|
@ -2123,7 +2151,7 @@ bool GUI_App::on_init_inner()
|
|||
#endif // __APPLE__
|
||||
|
||||
|
||||
bool init_dark_color_mode = app_config->get("dark_color_mode") == "1";
|
||||
bool init_dark_color_mode = dark_mode();
|
||||
bool init_sys_menu_enabled = app_config->get("sys_menu_enabled") == "1";
|
||||
#ifdef __WINDOWS__
|
||||
NppDarkMode::InitDarkMode(init_dark_color_mode, init_sys_menu_enabled);
|
||||
|
@ -2138,7 +2166,7 @@ bool GUI_App::on_init_inner()
|
|||
|
||||
#ifdef _MSW_DARK_MODE
|
||||
// app_config can be updated in check_older_app_config(), so check if dark_color_mode and sys_menu_enabled was changed
|
||||
if (bool new_dark_color_mode = app_config->get("dark_color_mode") == "1";
|
||||
if (bool new_dark_color_mode = dark_mode();
|
||||
init_dark_color_mode != new_dark_color_mode) {
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
|
@ -2325,7 +2353,13 @@ bool GUI_App::on_init_inner()
|
|||
// Suppress the '- default -' presets.
|
||||
preset_bundle->set_default_suppressed(true);
|
||||
|
||||
Bind(EVT_SET_SELECTED_MACHINE, &GUI_App::on_set_selected_machine, this);
|
||||
Bind(EVT_USER_LOGIN, &GUI_App::on_user_login, this);
|
||||
Bind(EVT_USER_LOGIN_HANDLE, &GUI_App::on_user_login_handle, this);
|
||||
Bind(EVT_CHECK_PRIVACY_VER, &GUI_App::on_check_privacy_update, this);
|
||||
Bind(EVT_CHECK_PRIVACY_SHOW, &GUI_App::show_check_privacy_dlg, this);
|
||||
|
||||
Bind(EVT_SHOW_IP_DIALOG, &GUI_App::show_ip_address_enter_dialog_handler, this);
|
||||
|
||||
Bind(EVT_SHOW_IP_DIALOG, &GUI_App::show_ip_address_enter_dialog_handler, this);
|
||||
|
||||
|
@ -2334,6 +2368,8 @@ bool GUI_App::on_init_inner()
|
|||
|
||||
if (m_agent && m_agent->is_user_login()) {
|
||||
enable_user_preset_folder(true);
|
||||
} else {
|
||||
enable_user_preset_folder(false);
|
||||
}
|
||||
|
||||
// BBS if load user preset failed
|
||||
|
@ -2349,13 +2385,11 @@ bool GUI_App::on_init_inner()
|
|||
}
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
if (app_config->get("sync_user_preset") == "true") {
|
||||
//BBS loading user preset
|
||||
BOOST_LOG_TRIVIAL(info) << "Loading user presets...";
|
||||
scrn->SetText(_L("Loading user presets..."));
|
||||
// Always async, not such startup step
|
||||
//BOOST_LOG_TRIVIAL(info) << "Loading user presets...";
|
||||
//scrn->SetText(_L("Loading user presets..."));
|
||||
if (m_agent) {
|
||||
start_sync_user_preset();
|
||||
}
|
||||
|
@ -2798,6 +2832,7 @@ void GUI_App::UpdateDarkUIWin(wxWindow* win)
|
|||
void GUI_App::Update_dark_mode_flag()
|
||||
{
|
||||
m_is_dark_mode = dark_mode();
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": switch the current dark mode status to %1% ")%m_is_dark_mode;
|
||||
}
|
||||
|
||||
void GUI_App::UpdateDlgDarkUI(wxDialog* dlg)
|
||||
|
@ -3075,6 +3110,11 @@ void GUI_App::ShowUserGuide() {
|
|||
|
||||
void GUI_App::ShowDownNetPluginDlg() {
|
||||
try {
|
||||
auto iter = std::find_if(dialogStack.begin(), dialogStack.end(), [](auto dialog) {
|
||||
return dynamic_cast<DownloadProgressDialog *>(dialog) != nullptr;
|
||||
});
|
||||
if (iter != dialogStack.end())
|
||||
return;
|
||||
DownloadProgressDialog dlg(_L("Downloading Bambu Network Plug-in"));
|
||||
dlg.ShowModal();
|
||||
} catch (std::exception &e) {
|
||||
|
@ -3082,14 +3122,24 @@ void GUI_App::ShowDownNetPluginDlg() {
|
|||
}
|
||||
}
|
||||
|
||||
void GUI_App::ShowUserLogin()
|
||||
void GUI_App::ShowUserLogin(bool show)
|
||||
{
|
||||
// BBS: User Login Dialog
|
||||
try {
|
||||
ZUserLogin LoginDlg;
|
||||
LoginDlg.ShowModal();
|
||||
} catch (std::exception &e) {
|
||||
// wxMessageBox(e.what(), "", MB_OK);
|
||||
if (show) {
|
||||
try {
|
||||
if (!login_dlg)
|
||||
login_dlg = new ZUserLogin();
|
||||
else {
|
||||
delete login_dlg;
|
||||
login_dlg = new ZUserLogin();
|
||||
}
|
||||
login_dlg->ShowModal();
|
||||
} catch (std::exception &e) {
|
||||
;
|
||||
}
|
||||
} else {
|
||||
if (login_dlg)
|
||||
login_dlg->EndModal(wxID_OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3168,7 +3218,7 @@ void GUI_App::force_colors_update()
|
|||
{
|
||||
#ifdef _MSW_DARK_MODE
|
||||
#ifdef __WINDOWS__
|
||||
NppDarkMode::SetDarkMode(app_config->get("dark_color_mode") == "1");
|
||||
NppDarkMode::SetDarkMode(dark_mode());
|
||||
if (WXHWND wxHWND = wxToolTip::GetToolTipCtrl())
|
||||
NppDarkMode::SetDarkExplorerTheme((HWND)wxHWND);
|
||||
NppDarkMode::SetDarkTitleBar(mainframe->GetHWND());
|
||||
|
@ -3321,6 +3371,13 @@ bool GUI_App::check_login()
|
|||
return result;
|
||||
}
|
||||
|
||||
void GUI_App::request_user_handle(int online_login)
|
||||
{
|
||||
auto evt = new wxCommandEvent(EVT_USER_LOGIN_HANDLE);
|
||||
evt->SetInt(online_login);
|
||||
wxQueueEvent(this, evt);
|
||||
}
|
||||
|
||||
void GUI_App::request_user_login(int online_login)
|
||||
{
|
||||
auto evt = new wxCommandEvent(EVT_USER_LOGIN);
|
||||
|
@ -3339,12 +3396,9 @@ void GUI_App::request_user_logout()
|
|||
|
||||
m_agent->user_logout();
|
||||
m_agent->set_user_selected_machine("");
|
||||
BOOST_LOG_TRIVIAL(info) << "preset_folder: set to empty, user_logout";
|
||||
enable_user_preset_folder(false);
|
||||
/* delete old user settings */
|
||||
m_device_manager->clean_user_info();
|
||||
GUI::wxGetApp().sidebar().load_ams_list({});
|
||||
GUI::wxGetApp().remove_user_presets();
|
||||
GUI::wxGetApp().sidebar().load_ams_list({}, {});
|
||||
GUI::wxGetApp().stop_sync_user_preset();
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
|
@ -3375,11 +3429,6 @@ std::string GUI_App::handle_web_request(std::string cmd)
|
|||
std::string web_cmd = j["command"].get<std::string>();
|
||||
|
||||
if (web_cmd == "request_model_download") {
|
||||
/* json j_data = j["data"];
|
||||
json import_j;*/
|
||||
/* import_j["model_id"] = j["data"]["model_id"].get<std::string>();
|
||||
import_j["profile_id"] = j["data"]["profile_id"].get<std::string>();*/
|
||||
|
||||
std::string download_url = "";
|
||||
if (j["data"].contains("download_url"))
|
||||
download_url = j["data"]["download_url"].get<std::string>();
|
||||
|
@ -3575,7 +3624,7 @@ void GUI_App::request_model_download(std::string url, std::string filename)
|
|||
if (!check_login()) return;
|
||||
|
||||
if (plater_) {
|
||||
plater_->request_model_download(url, filename);
|
||||
plater_->request_model_download();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3685,7 +3734,15 @@ void GUI_App::enable_user_preset_folder(bool enable)
|
|||
}
|
||||
}
|
||||
|
||||
void GUI_App::on_user_login(wxCommandEvent &evt)
|
||||
void GUI_App::on_set_selected_machine(wxCommandEvent &evt)
|
||||
{
|
||||
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev || m_agent) return;
|
||||
|
||||
dev->set_selected_machine(m_agent->get_user_selected_machine());
|
||||
}
|
||||
|
||||
void GUI_App::on_user_login_handle(wxCommandEvent &evt)
|
||||
{
|
||||
if (!m_agent) { return; }
|
||||
|
||||
|
@ -3695,8 +3752,12 @@ void GUI_App::on_user_login(wxCommandEvent &evt)
|
|||
// get machine list
|
||||
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev) return;
|
||||
dev->update_user_machine_list_info();
|
||||
dev->set_selected_machine(m_agent->get_user_selected_machine());
|
||||
|
||||
boost::thread update_thread = boost::thread([this, dev] {
|
||||
dev->update_user_machine_list_info();
|
||||
auto evt = new wxCommandEvent(EVT_SET_SELECTED_MACHINE);
|
||||
wxQueueEvent(this, evt);
|
||||
});
|
||||
|
||||
// if (app_config->get("sync_user_preset") == "true") {
|
||||
enable_user_preset_folder(true);
|
||||
|
@ -3723,6 +3784,14 @@ void GUI_App::on_user_login(wxCommandEvent &evt)
|
|||
}
|
||||
}
|
||||
|
||||
void GUI_App::on_user_login(wxCommandEvent &evt)
|
||||
{
|
||||
if (!m_agent) { return; }
|
||||
int online_login = evt.GetInt();
|
||||
// check privacy before handle
|
||||
check_privacy_version(online_login);
|
||||
}
|
||||
|
||||
bool GUI_App::is_studio_active()
|
||||
{
|
||||
auto curr_time = std::chrono::system_clock::now();
|
||||
|
@ -3947,6 +4016,113 @@ void GUI_App::set_skip_version(bool skip)
|
|||
}
|
||||
}
|
||||
|
||||
void GUI_App::show_check_privacy_dlg(wxCommandEvent& evt)
|
||||
{
|
||||
int online_login = evt.GetInt();
|
||||
PrivacyUpdateDialog privacy_dlg(this->mainframe, wxID_ANY, _L("Privacy Policy Update"));
|
||||
privacy_dlg.Bind(EVT_PRIVACY_UPDATE_CONFIRM, [this, online_login](wxCommandEvent &e) {
|
||||
app_config->set("privacy_version", privacy_version_info.version_str);
|
||||
app_config->set_bool("privacy_update_checked", true);
|
||||
app_config->save();
|
||||
request_user_handle(online_login);
|
||||
});
|
||||
privacy_dlg.Bind(EVT_PRIVACY_UPDATE_CANCEL, [this](wxCommandEvent &e) {
|
||||
app_config->set_bool("privacy_update_checked", false);
|
||||
app_config->save();
|
||||
if (m_agent) {
|
||||
m_agent->user_logout();
|
||||
}
|
||||
});
|
||||
|
||||
privacy_dlg.set_text(privacy_version_info.description);
|
||||
privacy_dlg.on_show();
|
||||
}
|
||||
|
||||
void GUI_App::on_show_check_privacy_dlg(int online_login)
|
||||
{
|
||||
auto evt = new wxCommandEvent(EVT_CHECK_PRIVACY_SHOW);
|
||||
evt->SetInt(online_login);
|
||||
wxQueueEvent(this, evt);
|
||||
}
|
||||
|
||||
bool GUI_App::check_privacy_update()
|
||||
{
|
||||
if (privacy_version_info.version_str.empty() || privacy_version_info.description.empty()
|
||||
|| privacy_version_info.url.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string local_privacy_ver = app_config->get("privacy_version");
|
||||
auto curr_version = Semver::parse(local_privacy_ver);
|
||||
auto remote_version = Semver::parse(privacy_version_info.version_str);
|
||||
if (curr_version && remote_version) {
|
||||
if (*remote_version > *curr_version || app_config->get("privacy_update_checked") != "true") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void GUI_App::on_check_privacy_update(wxCommandEvent& evt)
|
||||
{
|
||||
int online_login = evt.GetInt();
|
||||
bool result = check_privacy_update();
|
||||
if (result)
|
||||
on_show_check_privacy_dlg(online_login);
|
||||
else
|
||||
request_user_handle(online_login);
|
||||
}
|
||||
|
||||
void GUI_App::check_privacy_version(int online_login)
|
||||
{
|
||||
update_http_extra_header();
|
||||
std::string query_params = "?policy/privacy=00.00.00.00";
|
||||
std::string url = get_http_url(app_config->get_country_code()) + query_params;
|
||||
Slic3r::Http http = Slic3r::Http::get(url);
|
||||
|
||||
http.header("accept", "application/json")
|
||||
.timeout_connect(TIMEOUT_CONNECT)
|
||||
.timeout_max(TIMEOUT_RESPONSE)
|
||||
.on_complete([this, online_login](std::string body, unsigned) {
|
||||
try {
|
||||
json j = json::parse(body);
|
||||
if (j.contains("message")) {
|
||||
if (j["message"].get<std::string>() == "success") {
|
||||
if (j.contains("resources")) {
|
||||
for (auto it = j["resources"].begin(); it != j["resources"].end(); it++) {
|
||||
if (it->contains("type")) {
|
||||
if ((*it)["type"] == std::string("policy/privacy")
|
||||
&& it->contains("version")
|
||||
&& it->contains("description")
|
||||
&& it->contains("url")
|
||||
&& it->contains("force_update")) {
|
||||
privacy_version_info.version_str = (*it)["version"].get<std::string>();
|
||||
privacy_version_info.description = (*it)["description"].get<std::string>();
|
||||
privacy_version_info.url = (*it)["url"].get<std::string>();
|
||||
privacy_version_info.force_upgrade = (*it)["force_update"].get<bool>();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
CallAfter([this, online_login]() {
|
||||
auto evt = new wxCommandEvent(EVT_CHECK_PRIVACY_VER);
|
||||
evt->SetInt(online_login);
|
||||
wxQueueEvent(this, evt);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
request_user_handle(online_login);
|
||||
}
|
||||
})
|
||||
.on_error([this, online_login](std::string body, std::string error, unsigned int status) {
|
||||
request_user_handle(online_login);
|
||||
BOOST_LOG_TRIVIAL(error) << "check privacy version error" << body;
|
||||
}).perform();
|
||||
}
|
||||
|
||||
void GUI_App::no_new_version()
|
||||
{
|
||||
wxCommandEvent* evt = new wxCommandEvent(EVT_SHOW_NO_NEW_VERSION);
|
||||
|
@ -3986,17 +4162,19 @@ void GUI_App::reload_settings()
|
|||
m_agent->get_user_presets(&user_presets);
|
||||
preset_bundle->load_user_presets(*app_config, user_presets, ForwardCompatibilitySubstitutionRule::Enable);
|
||||
preset_bundle->save_user_presets(*app_config, get_delete_cache_presets());
|
||||
mainframe->update_side_preset_ui();
|
||||
}
|
||||
}
|
||||
|
||||
//BBS reload when login
|
||||
//BBS reload when logout
|
||||
void GUI_App::remove_user_presets()
|
||||
{
|
||||
if (preset_bundle && m_agent) {
|
||||
preset_bundle->remove_users_preset(*app_config);
|
||||
|
||||
std::string user_id = m_agent->get_user_id();
|
||||
preset_bundle->remove_user_presets_directory(user_id);
|
||||
// Not remove user preset cache
|
||||
//std::string user_id = m_agent->get_user_id();
|
||||
//preset_bundle->remove_user_presets_directory(user_id);
|
||||
|
||||
//update ui
|
||||
mainframe->update_side_preset_ui();
|
||||
|
@ -4110,9 +4288,9 @@ void GUI_App::sync_preset(Preset* preset)
|
|||
}
|
||||
}
|
||||
|
||||
void GUI_App::start_sync_user_preset(bool with_progress_dlg)
|
||||
void GUI_App::start_sync_user_preset(bool load_immediately, bool with_progress_dlg)
|
||||
{
|
||||
if (!m_agent) return;
|
||||
if (!m_agent || !m_agent->is_user_login()) return;
|
||||
|
||||
enable_user_preset_folder(true);
|
||||
|
||||
|
@ -4120,32 +4298,51 @@ void GUI_App::start_sync_user_preset(bool with_progress_dlg)
|
|||
if (enable_sync)
|
||||
return;
|
||||
|
||||
if (m_agent->is_user_login()) {
|
||||
// get setting list, update setting list
|
||||
std::string version = preset_bundle->get_vendor_profile_version(PresetBundle::BBL_BUNDLE).to_string();
|
||||
if (with_progress_dlg) {
|
||||
ProgressDialog dlg(_L("Loading"), "", 100, this->mainframe, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT);
|
||||
dlg.Update(0, _L("Loading user preset"));
|
||||
m_agent->get_setting_list(version,
|
||||
[this, &dlg](int percent){
|
||||
dlg.Update(percent, _L("Loading user preset"));
|
||||
},
|
||||
[this, &dlg]() {
|
||||
dlg.GetValue();
|
||||
bool cont = dlg.Update(dlg.GetValue(), _L("Loading user preset"));
|
||||
return !cont;
|
||||
});
|
||||
} else {
|
||||
m_agent->get_setting_list(version);
|
||||
}
|
||||
GUI::wxGetApp().reload_settings();
|
||||
if (load_immediately) {
|
||||
preset_bundle->load_user_presets(m_agent->get_user_id(), ForwardCompatibilitySubstitutionRule::Enable);
|
||||
mainframe->update_side_preset_ui();
|
||||
}
|
||||
|
||||
ProgressFn progressFn;
|
||||
WasCancelledFn cancelFn;
|
||||
std::function<void()> finishFn;
|
||||
|
||||
if (with_progress_dlg) {
|
||||
auto dlg = new ProgressDialog(_L("Loading"), "", 100, this->mainframe, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT);
|
||||
dlg->Update(0, _L("Loading user preset"));
|
||||
progressFn = [this, dlg](int percent) {
|
||||
CallAfter([=]{
|
||||
dlg->Update(percent, _L("Loading user preset"));
|
||||
});
|
||||
};
|
||||
cancelFn = [dlg]() {
|
||||
return dlg->WasCanceled();
|
||||
};
|
||||
finishFn = [this, dlg] {
|
||||
CallAfter([=]{
|
||||
dlg->Destroy();
|
||||
reload_settings();
|
||||
});
|
||||
};
|
||||
}
|
||||
else {
|
||||
finishFn = [this] {
|
||||
CallAfter([=] {
|
||||
reload_settings();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "start_sync_service...";
|
||||
//BBS
|
||||
enable_sync = true;
|
||||
m_sync_update_thread = Slic3r::create_thread(
|
||||
[this] {
|
||||
[this, progressFn, cancelFn, finishFn] {
|
||||
// get setting list, update setting list
|
||||
std::string version = preset_bundle->get_vendor_profile_version(PresetBundle::BBL_BUNDLE).to_string();
|
||||
m_agent->get_setting_list(version, progressFn, cancelFn);
|
||||
finishFn();
|
||||
|
||||
int count = 0, sync_count = 0;
|
||||
std::vector<Preset> presets_to_sync;
|
||||
while (enable_sync) {
|
||||
|
@ -4182,12 +4379,13 @@ void GUI_App::start_sync_user_preset(bool with_progress_dlg)
|
|||
unsigned int http_code = 200;
|
||||
|
||||
/* get list witch need to be deleted*/
|
||||
std::vector<string>& delete_cache_presets = get_delete_cache_presets();
|
||||
std::vector<string> delete_cache_presets = get_delete_cache_presets_lock();
|
||||
for (auto it = delete_cache_presets.begin(); it != delete_cache_presets.end();) {
|
||||
if ((*it).empty()) continue;
|
||||
std::string del_setting_id = *it;
|
||||
int result = m_agent->delete_setting(del_setting_id);
|
||||
if (result == 0) {
|
||||
preset_deleted_from_cloud(del_setting_id);
|
||||
it = delete_cache_presets.erase(it);
|
||||
BOOST_LOG_TRIVIAL(trace) << "sync_preset: sync operation: delete success! setting id = " << del_setting_id;
|
||||
}
|
||||
|
@ -4206,6 +4404,7 @@ void GUI_App::start_sync_user_preset(bool with_progress_dlg)
|
|||
|
||||
void GUI_App::stop_sync_user_preset()
|
||||
{
|
||||
remove_user_presets();
|
||||
enable_user_preset_folder(false);
|
||||
|
||||
if (!enable_sync)
|
||||
|
@ -4216,6 +4415,16 @@ void GUI_App::stop_sync_user_preset()
|
|||
m_sync_update_thread.join();
|
||||
}
|
||||
|
||||
void GUI_App::start_http_server()
|
||||
{
|
||||
if (!m_http_server.is_started())
|
||||
m_http_server.start();
|
||||
}
|
||||
void GUI_App::stop_http_server()
|
||||
{
|
||||
m_http_server.stop();
|
||||
}
|
||||
|
||||
bool GUI_App::switch_language()
|
||||
{
|
||||
if (select_language()) {
|
||||
|
@ -4412,7 +4621,8 @@ bool GUI_App::load_language(wxString language, bool initial)
|
|||
{"fr", wxString::FromUTF8("\x46\x72\x61\x6E\xC3\xA7\x61\x69\x73")},
|
||||
{"it", wxString::FromUTF8("\x49\x74\x61\x6C\x69\x61\x6E\x6F")},
|
||||
{"ru", wxString::FromUTF8("\xD1\x80\xD1\x83\xD1\x81\xD1\x81\xD0\xBA\xD0\xB8\xD0\xB9")},
|
||||
{"hu", wxString::FromUTF8("Magyar")}
|
||||
{"hu", wxString::FromUTF8("Magyar")},
|
||||
{"ja", wxString::FromUTF8("\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E")}
|
||||
};
|
||||
for (auto l : language_descptions) {
|
||||
const wxLanguageInfo *langinfo = wxLocale::FindLanguageInfo(l.first);
|
||||
|
@ -4517,7 +4727,9 @@ bool GUI_App::load_language(wxString language, bool initial)
|
|||
wxLANGUAGE_SPANISH,
|
||||
wxLANGUAGE_SWEDISH,
|
||||
wxLANGUAGE_DUTCH,
|
||||
wxLANGUAGE_HUNGARIAN};
|
||||
wxLANGUAGE_HUNGARIAN,
|
||||
wxLANGUAGE_JAPANESE
|
||||
};
|
||||
std::string cur_language = app_config->get("language");
|
||||
if (cur_language != "") {
|
||||
//cleanup the language wrongly set before
|
||||
|
@ -5027,7 +5239,12 @@ bool GUI_App::check_and_keep_current_preset_changes(const wxString& caption, con
|
|||
static_cast<TabPrinter*>(tab)->cache_extruder_cnt();
|
||||
}
|
||||
}
|
||||
tab->cache_config_diff(selected_options);
|
||||
std::vector<std::string> selected_options2;
|
||||
std::transform(selected_options.begin(), selected_options.end(), std::back_inserter(selected_options2), [](auto & o) {
|
||||
auto i = o.find('#');
|
||||
return i != std::string::npos ? o.substr(0, i) : o;
|
||||
});
|
||||
tab->cache_config_diff(selected_options2);
|
||||
if (!is_called_from_configwizard)
|
||||
tab->m_presets->discard_current_changes();
|
||||
}
|
||||
|
@ -5114,16 +5331,31 @@ void GUI_App::load_current_presets(bool active_preset_combox/*= false*/, bool ch
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<std::string>& GUI_App::get_delete_cache_presets()
|
||||
static std::mutex mutex_delete_cache_presets;
|
||||
|
||||
std::vector<std::string> & GUI_App::get_delete_cache_presets()
|
||||
{
|
||||
return need_delete_presets;
|
||||
}
|
||||
|
||||
std::vector<std::string> GUI_App::get_delete_cache_presets_lock()
|
||||
{
|
||||
std::scoped_lock l(mutex_delete_cache_presets);
|
||||
return need_delete_presets;
|
||||
}
|
||||
|
||||
void GUI_App::delete_preset_from_cloud(std::string setting_id)
|
||||
{
|
||||
std::scoped_lock l(mutex_delete_cache_presets);
|
||||
need_delete_presets.push_back(setting_id);
|
||||
}
|
||||
|
||||
void GUI_App::preset_deleted_from_cloud(std::string setting_id)
|
||||
{
|
||||
std::scoped_lock l(mutex_delete_cache_presets);
|
||||
need_delete_presets.erase(std::remove(need_delete_presets.begin(), need_delete_presets.end(), setting_id), need_delete_presets.end());
|
||||
}
|
||||
|
||||
bool GUI_App::OnExceptionInMainLoop()
|
||||
{
|
||||
generic_exception_handle();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue