diff --git a/resources/web/homepage/css/home.css b/resources/web/homepage/css/home.css index da12d73a3c8..2bcc18451f5 100644 --- a/resources/web/homepage/css/home.css +++ b/resources/web/homepage/css/home.css @@ -71,6 +71,7 @@ body #LeftBoard { + display: none; /* shown by cloud_providers_info from backend */ border-right-width: 1px; border-right-style: solid; width:262px; diff --git a/resources/web/homepage/js/home.js b/resources/web/homepage/js/home.js index 1a632906453..72789cc0885 100644 --- a/resources/web/homepage/js/home.js +++ b/resources/web/homepage/js/home.js @@ -103,11 +103,20 @@ function HandleStudio( pVal ) GotoMenu(strName); } else if (strCmd == "cloud_providers_info") { - if (pVal["data"]["providers"] && pVal["data"]["providers"].indexOf("bbl") >= 0) { + var providers = (pVal["data"] && pVal["data"]["providers"]) || []; + + if (providers.indexOf("bbl") >= 0) { $("#BambuCloudSection").show(); } else { + SetBambuUserOffline(); $("#BambuCloudSection").hide(); } + + if (providers.indexOf("orca") >= 0) { + $("#LeftBoard").show(); + } else { + $("#LeftBoard").hide(); + } } else if (strCmd == "network_plugin_installtip") { let nShow = pVal["show"] * 1; diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 24271d51fae..1546f09fbc1 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -4469,6 +4469,21 @@ std::string GUI_App::handle_web_request(std::string cmd) boost::optional command = root.get_optional("command"); if (command.has_value()) { std::string command_str = command.value(); + static const std::unordered_set stealth_blocked_commands = { + "get_login_info", + "get_orca_login_info", + "get_bambu_login_info", + "homepage_login_or_register", + "homepage_orca_login_or_register", + "homepage_bambu_login_or_register", + }; + if (app_config->get_stealth_mode() && stealth_blocked_commands.count(command_str)) { + CallAfter([this] { + if (mainframe && mainframe->m_webview) + mainframe->m_webview->SendCloudProvidersInfo(); + }); + return ""; + } if (command_str.compare("request_project_download") == 0) { if (root.get_child_optional("data") != boost::none) { pt::ptree data_node = root.get_child("data"); @@ -6731,6 +6746,16 @@ void GUI_App::stop_sync_user_preset() } } +void GUI_App::on_stealth_mode_enter() +{ + stop_sync_user_preset(); + request_user_logout(ORCA_CLOUD_PROVIDER); + request_user_logout(BBL_CLOUD_PROVIDER); + if (mainframe && mainframe->m_webview) { + mainframe->m_webview->SendCloudProvidersInfo(); + } +} + void GUI_App::start_http_server(const std::string& provider) { m_http_server.set_request_handler([provider](const std::string& url) { diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 0ffd3b808be..fac853e65c6 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -530,6 +530,7 @@ public: void sync_preset(Preset* preset); void start_sync_user_preset(bool with_progress_dlg = false); void stop_sync_user_preset(); + void on_stealth_mode_enter(); // Bundle subscription sync void check_bundle_updates(); diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index c5d377b67bc..ccb85ec8131 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -924,6 +924,8 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxString too checkbox->SetValue(app_config->get_bool(param)); checkbox->SetToolTip(tip); + if (param == "sync_user_preset") { m_sync_user_preset_checkbox = checkbox; } + m_sizer_checkbox->Add(checkbox_title, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, FromDIP(3)); m_sizer_checkbox->Add(checkbox , 0, wxALIGN_CENTER | wxRIGHT | wxLEFT, FromDIP(5)); @@ -955,6 +957,12 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxString too } BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " sync_user_preset: " << (sync ? "true" : "false"); } + else if (param == "stealth_mode") { + bool enabled = app_config->get_stealth_mode(); + if (enabled) wxGetApp().on_stealth_mode_enter(); + if (m_sync_user_preset_checkbox) m_sync_user_preset_checkbox->Enable(!enabled); + if (m_bambu_cloud_checkbox) m_bambu_cloud_checkbox->Enable(!enabled); + } #ifdef __WXMSW__ if (param == "associate_3mf") { @@ -1528,7 +1536,7 @@ void PreferencesDialog::create_items() auto item_region = create_item_region_combobox(_L("Login region"), ""); g_sizer->Add(item_region); - auto item_stealth_mode = create_item_checkbox(_L("Stealth mode"), _L("This stops the transmission of data to Bambu's cloud services. Users who don't use BBL machines or use LAN mode only can safely turn on this function."), "stealth_mode"); + auto item_stealth_mode = create_item_checkbox(_L("Stealth mode"), _L("This disables all cloud services e.g. Orca Cloud and Bambu Cloud. This stops the transmission of data to Bambu's cloud services too. Users who don't use BBL machines or use LAN mode only can safely turn on this function."), "stealth_mode"); g_sizer->Add(item_stealth_mode); auto item_network_test = create_item_button(_L("Network test"), _L("Test") + " " + dots, "", _L("Open Network Test"), []() { @@ -1552,6 +1560,7 @@ void PreferencesDialog::create_items() text->Wrap(DESIGN_TITLE_SIZE.x); auto cb = new ::CheckBox(m_parent); + m_bambu_cloud_checkbox = cb; cb->SetValue(app_config->has_cloud_provider(BBL_CLOUD_PROVIDER)); cb->SetToolTip(text->GetToolTipText()); @@ -1585,6 +1594,11 @@ void PreferencesDialog::create_items() auto item_user_sync = create_item_checkbox(_L("Auto sync user presets (Printer/Filament/Process)"), "", "sync_user_preset"); g_sizer->Add(item_user_sync); + if (app_config->get_stealth_mode()) { + if (m_bambu_cloud_checkbox) m_bambu_cloud_checkbox->Enable(false); + if (m_sync_user_preset_checkbox) m_sync_user_preset_checkbox->Enable(false); + } + auto item_system_sync = create_item_checkbox(_L("Update built-in Presets automatically."), "", "sync_system_preset"); g_sizer->Add(item_system_sync); diff --git a/src/slic3r/GUI/Preferences.hpp b/src/slic3r/GUI/Preferences.hpp index 73e61938d67..d7daca5ff87 100644 --- a/src/slic3r/GUI/Preferences.hpp +++ b/src/slic3r/GUI/Preferences.hpp @@ -71,6 +71,8 @@ public: ::CheckBox * m_developer_mode_ckeckbox = {nullptr}; ::CheckBox * m_internal_developer_mode_ckeckbox = {nullptr}; ::CheckBox * m_dark_mode_ckeckbox = {nullptr}; + ::CheckBox * m_sync_user_preset_checkbox = {nullptr}; + ::CheckBox * m_bambu_cloud_checkbox = {nullptr}; ::TextInput *m_backup_interval_textinput = {nullptr}; ::ComboBox * m_network_version_combo = {nullptr}; wxBoxSizer * m_network_version_sizer = {nullptr}; diff --git a/src/slic3r/GUI/WebViewDialog.cpp b/src/slic3r/GUI/WebViewDialog.cpp index 7988f911472..2a88277680f 100644 --- a/src/slic3r/GUI/WebViewDialog.cpp +++ b/src/slic3r/GUI/WebViewDialog.cpp @@ -418,8 +418,9 @@ void WebViewPanel::OnFreshLoginStatus(wxTimerEvent &event) { auto mainframe = Slic3r::GUI::wxGetApp().mainframe; if (mainframe && mainframe->m_webview == this) { - Slic3r::GUI::wxGetApp().get_login_info(ORCA_CLOUD_PROVIDER); auto* app_config = Slic3r::GUI::wxGetApp().app_config; + if (app_config && app_config->get_stealth_mode()) return; + Slic3r::GUI::wxGetApp().get_login_info(ORCA_CLOUD_PROVIDER); if (app_config && app_config->has_cloud_provider(BBL_CLOUD_PROVIDER)) { Slic3r::GUI::wxGetApp().get_login_info(BBL_CLOUD_PROVIDER); } @@ -520,14 +521,18 @@ void WebViewPanel::SendCloudProvidersInfo() if (!app_config) return; - auto providers = app_config->get_cloud_providers(); json j; j["command"] = "cloud_providers_info"; json data; json provider_array = json::array(); - for (const auto& p : providers) { - provider_array.push_back(p); + + if (!app_config->get_stealth_mode()) { + auto providers = app_config->get_cloud_providers(); + for (const auto& p : providers) { + provider_array.push_back(p); + } } + data["providers"] = provider_array; j["data"] = data;