Feature/tweak stealth mode (#13963)

* Update the stealth mode description to reflect the current code changes in 2.4.

* disable HMS if bambu network plugin is not installed or in stealth mode

* fix build err

* add hide_login_side_panel to control whether to show login panel in home page
This commit is contained in:
SoftFever
2026-05-31 18:04:06 +08:00
committed by GitHub
parent 535911fcfe
commit 372f7823ac
9 changed files with 66 additions and 23 deletions

View File

@@ -93,6 +93,11 @@ bool AppConfig::get_stealth_mode()
return get_bool("stealth_mode");
}
bool AppConfig::get_hide_login_side_panel()
{
return get_bool("hide_login_side_panel");
}
void AppConfig::reset()
{
m_storage.clear();
@@ -347,6 +352,9 @@ void AppConfig::set_defaults()
if (get("stealth_mode").empty()) {
set_bool("stealth_mode", false);
}
if (get("hide_login_side_panel").empty()) {
set_bool("hide_login_side_panel", false);
}
if (get("allow_abnormal_storage").empty()) {
set_bool("allow_abnormal_storage", false);
}

View File

@@ -85,6 +85,7 @@ public:
std::string get_language_code();
std::string get_hms_host();
bool get_stealth_mode();
bool get_hide_login_side_panel();
// Clear and reset to defaults.
void reset();

View File

@@ -4509,21 +4509,46 @@ std::string GUI_App::handle_web_request(std::string cmd)
boost::optional<std::string> command = root.get_optional<std::string>("command");
if (command.has_value()) {
std::string command_str = command.value();
static const std::unordered_set<std::string> stealth_blocked_commands = {
static const std::unordered_set<std::string> stealth_blocked_info_commands = {
"get_login_info",
"get_orca_login_info",
"get_bambu_login_info",
};
static const std::unordered_set<std::string> stealth_blocked_login_commands = {
"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)) {
if (app_config->get_stealth_mode() && stealth_blocked_info_commands.count(command_str)) {
CallAfter([this] {
if (mainframe && mainframe->m_webview)
mainframe->m_webview->SendCloudProvidersInfo();
});
return "";
}
if (app_config->get_stealth_mode() && stealth_blocked_login_commands.count(command_str)) {
CallAfter([this, command_str] {
MessageDialog dlg(mainframe,
_L("You are currently in Stealth Mode. To log into the Cloud, you need to disable Stealth Mode first."),
_L("Stealth Mode"),
wxOK | wxCANCEL | wxCENTRE);
dlg.SetButtonLabel(wxID_OK, _L("Quit Stealth Mode"));
if (dlg.ShowModal() == wxID_OK) {
app_config->set_bool("stealth_mode", false);
app_config->save();
if (mainframe && mainframe->m_webview)
mainframe->m_webview->SendCloudProvidersInfo();
// Continue with login
if (command_str == "homepage_login_or_register")
this->request_login(true);
else if (command_str == "homepage_orca_login_or_register")
this->request_login(true, ORCA_CLOUD_PROVIDER);
else if (command_str == "homepage_bambu_login_or_register")
this->request_login(true, BBL_CLOUD_PROVIDER);
}
});
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");

View File

@@ -4,6 +4,7 @@
#include "DeviceManager.hpp"
#include "DeviceCore/DevManager.h"
#include "DeviceCore/DevUtil.h"
#include "libslic3r/AppConfig.hpp"
#include <boost/log/trivial.hpp>
@@ -13,6 +14,14 @@ static const char* HMS_LOCAL_IMG_PATH = "hms/local_image";
// the local HMS info
static unordered_set<string> package_dev_id_types {"094", "239", "093", "22E"};
// HMS should be disabled when stealth mode is on or networking is not installed
static bool should_disable_hms()
{
Slic3r::AppConfig* config = Slic3r::GUI::wxGetApp().app_config;
if (!config) return true;
return config->get_stealth_mode() || !config->get_bool("installed_networking");
}
namespace Slic3r {
namespace GUI {
@@ -21,7 +30,7 @@ int get_hms_info_version(std::string& version)
AppConfig* config = wxGetApp().app_config;
if (!config)
return -1;
if (config->get_stealth_mode())
if (should_disable_hms())
return -1;
std::string hms_host = config->get_hms_host();
if(hms_host.empty()) {
@@ -61,7 +70,7 @@ int HMSQuery::download_hms_related(const std::string& hms_type, const std::strin
AppConfig* config = wxGetApp().app_config;
if (!config) return -1;
if (config->get_stealth_mode()) return -1;
if (should_disable_hms()) return -1;
std::string hms_host = wxGetApp().app_config->get_hms_host();
std::string lang;
@@ -546,7 +555,7 @@ wxString HMSQuery::query_print_image_action(const MachineObject* obj, int print_
::sprintf(buf, "%08X", print_error);
//The first three digits of SN number
const auto result = _query_error_image_action(get_dev_id_type(obj),std::string(buf), button_action);
if (wxGetApp().app_config->get_stealth_mode() && result.Contains("http")) {
if (should_disable_hms() && result.Contains("http")) {
return wxEmptyString;
}
return result;
@@ -637,7 +646,7 @@ std::string get_hms_wiki_url(std::string error_code)
{
AppConfig* config = wxGetApp().app_config;
if (!config) return "";
if (config->get_stealth_mode()) return "";
if (should_disable_hms()) return "";
std::string hms_host = wxGetApp().app_config->get_hms_host();
std::string lang_code = HMSQuery::hms_language_code();
@@ -663,7 +672,7 @@ std::string get_hms_wiki_url(std::string error_code)
std::string get_error_message(int error_code)
{
if (wxGetApp().app_config->get_stealth_mode()) return "";
if (should_disable_hms()) return "";
char buf[64];
std::string result_str = "";

View File

@@ -968,6 +968,11 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxString too
if (m_sync_user_preset_checkbox) m_sync_user_preset_checkbox->Enable(!enabled);
if (m_bambu_cloud_checkbox) m_bambu_cloud_checkbox->Enable(!enabled);
}
else if (param == "hide_login_side_panel") {
if (wxGetApp().mainframe && wxGetApp().mainframe->m_webview) {
wxGetApp().mainframe->m_webview->SendCloudProvidersInfo();
}
}
#ifdef __WXMSW__
if (param == "associate_3mf") {
@@ -1605,9 +1610,12 @@ 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 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");
auto item_stealth_mode = create_item_checkbox(_L("Stealth mode"), _L("This disables all cloud features, including Orca Cloud profile syncing. Users who prefer to work entirely offline can enable this option.\nNote: When Stealth Mode is enabled, your user profiles will not be backed up to Orca Cloud."), "stealth_mode");
g_sizer->Add(item_stealth_mode);
auto item_hide_login_side_panel = create_item_checkbox(_L("Hide login side panel"), _L("Hide the login side panel on the home page."), "hide_login_side_panel");
g_sizer->Add(item_hide_login_side_panel);
auto item_network_test = create_item_button(_L("Network test"), _L("Test") + " " + dots, "", _L("Open Network Test"), []() {
NetworkTestDialog dlg(wxGetApp().mainframe);
dlg.ShowModal();

View File

@@ -177,11 +177,7 @@ ZUserLogin::ZUserLogin(std::shared_ptr<ICloudServiceAgent> cloud_agent)
wxSize pSize = FromDIP(wxSize(650, 840));
SetSize(pSize);
int screenheight = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y, NULL);
int screenwidth = wxSystemSettings::GetMetric(wxSYS_SCREEN_X, NULL);
int MaxY = (screenheight - pSize.y) > 0 ? (screenheight - pSize.y) / 2 : 0;
wxPoint tmpPT((screenwidth - pSize.x) / 2, MaxY);
Move(tmpPT);
CentreOnParent();
}
wxGetApp().UpdateDlgDarkUI(this);
}

View File

@@ -526,7 +526,7 @@ void WebViewPanel::SendCloudProvidersInfo()
json data;
json provider_array = json::array();
if (!app_config->get_stealth_mode()) {
if (!app_config->get_hide_login_side_panel()) {
auto providers = app_config->get_cloud_providers();
for (const auto& p : providers) {
provider_array.push_back(p);