mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-21 15:51:10 -06:00
NEW: [STUDIO-2476] design_staffpick
This reverts commit 4d13a44a2e4136d0c2e173e367e13f6a6ba00670. Reason for revert: 123 Change-Id: I008a0ab3540589e5938fb3e1814571e00c467227
This commit is contained in:
parent
8eb84e8d4f
commit
0a9d33157a
18 changed files with 363 additions and 556 deletions
|
@ -3685,6 +3685,24 @@ std::string GUI_App::handle_web_request(std::string cmd)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (command_str.compare("modelmall_model_advise_get") == 0) {
|
||||
if (mainframe && this->app_config->get("staff_pick_switch") == "true") {
|
||||
if (mainframe->m_webview) {
|
||||
mainframe->m_webview->SendDesignStaffpick(m_agent);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (command_str.compare("modelmall_model_open") == 0) {
|
||||
if (root.get_child_optional("data") != boost::none) {
|
||||
pt::ptree data_node = root.get_child("data");
|
||||
boost::optional<std::string> id = data_node.get_optional<std::string>("id");
|
||||
if (id.has_value() && m_agent) {
|
||||
std::string url;
|
||||
if (m_agent->get_model_mall_detail_url(&url, id.value()) == 0)
|
||||
wxLaunchDefaultBrowser(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (command_str.compare("homepage_open_recentfile") == 0) {
|
||||
if (root.get_child_optional("data") != boost::none) {
|
||||
pt::ptree data_node = root.get_child("data");
|
||||
|
@ -3773,6 +3791,12 @@ std::string GUI_App::handle_web_request(std::string cmd)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (command_str.compare("common_openurl") == 0) {
|
||||
boost::optional<std::string> path = root.get_optional<std::string>("url");
|
||||
if (path.has_value()) {
|
||||
wxLaunchDefaultBrowser(path.value());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
|
@ -4523,6 +4547,11 @@ void GUI_App::stop_http_server()
|
|||
m_http_server.stop();
|
||||
}
|
||||
|
||||
void GUI_App::switch_staff_pick(bool on)
|
||||
{
|
||||
mainframe->m_webview->SendDesignStaffpick(on ? m_agent : nullptr);
|
||||
}
|
||||
|
||||
bool GUI_App::switch_language()
|
||||
{
|
||||
if (select_language()) {
|
||||
|
|
|
@ -439,6 +439,7 @@ public:
|
|||
void stop_sync_user_preset();
|
||||
void start_http_server();
|
||||
void stop_http_server();
|
||||
void switch_staff_pick(bool on);
|
||||
|
||||
void on_show_check_privacy_dlg(int online_login = 0);
|
||||
void show_check_privacy_dlg(wxCommandEvent& evt);
|
||||
|
|
|
@ -604,6 +604,11 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxWindow *pa
|
|||
app_config->set_bool(param, checkbox->GetValue());
|
||||
app_config->save();
|
||||
|
||||
if (param == "staff_pick_switch") {
|
||||
bool pbool = app_config->get("staff_pick_switch") == "true";
|
||||
wxGetApp().switch_staff_pick(pbool);
|
||||
}
|
||||
|
||||
// backup
|
||||
if (param == "backup_switch") {
|
||||
bool pbool = app_config->get("backup_switch") == "true" ? true : false;
|
||||
|
@ -936,6 +941,11 @@ wxWindow* PreferencesDialog::create_general_page()
|
|||
_L("If enabled, sets BambuStudio as default application to open .step files"), 50, "associate_step");
|
||||
#endif // _WIN32
|
||||
|
||||
auto title_modelmall = create_item_title(_L("Online Models"), page, _L("Online Models"));
|
||||
// auto item_backup = create_item_switch(_L("Backup switch"), page, _L("Backup switch"), "units");
|
||||
auto item_modelmall = create_item_checkbox(_L("Show online staff-picked models on the home page"), page, _L("Show online staff-picked models on the home page"), 50, "staff_pick_switch");
|
||||
|
||||
|
||||
auto title_project = create_item_title(_L("Project"), page, "");
|
||||
auto item_max_recent_count = create_item_input(_L("Maximum recent projects"), "", page, _L("Maximum count of recent projects"), "max_recent_count", [](wxString value) {
|
||||
long max = 0;
|
||||
|
@ -976,6 +986,9 @@ wxWindow* PreferencesDialog::create_general_page()
|
|||
sizer_page->Add(item_associate_stl, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_associate_step, 0, wxTOP, FromDIP(3));
|
||||
#endif // _WIN32
|
||||
sizer_page->Add(title_modelmall, 0, wxTOP | wxEXPAND, FromDIP(20));
|
||||
sizer_page->Add(item_modelmall, 0, wxTOP, FromDIP(3));
|
||||
|
||||
sizer_page->Add(title_project, 0, wxTOP| wxEXPAND, FromDIP(20));
|
||||
sizer_page->Add(item_max_recent_count, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_save_choise, 0, wxTOP, FromDIP(3));
|
||||
|
|
|
@ -427,6 +427,23 @@ void WebViewPanel::SendRecentList(wxString const &sequence_id)
|
|||
RunScript(wxString::Format("window.postMessage(%s)", oss.str()));
|
||||
}
|
||||
|
||||
void WebViewPanel::SendDesignStaffpick(NetworkAgent *agent)
|
||||
{
|
||||
if (agent) {
|
||||
agent->get_design_staffpick(0, 60, [this](std::string body) {
|
||||
if (body.empty() || body.front() != '{') {
|
||||
BOOST_LOG_TRIVIAL(warning) << "get_design_staffpick failed " + body;
|
||||
return;
|
||||
}
|
||||
CallAfter([this, body] {
|
||||
auto body2 = body;
|
||||
body2.insert(1, "\"command\": \"modelmall_model_advise_get\", ");
|
||||
RunScript(wxString::Format("window.postMessage(%s)", body2));
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void WebViewPanel::SendLoginInfo()
|
||||
{
|
||||
if (wxGetApp().getAgent()) {
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
class NetworkAgent;
|
||||
|
||||
namespace GUI {
|
||||
|
||||
|
||||
|
@ -91,6 +94,7 @@ public:
|
|||
|
||||
public:
|
||||
void SendRecentList(wxString const &sequence_id);
|
||||
void SendDesignStaffpick(NetworkAgent *agent);
|
||||
void SendLoginInfo();
|
||||
void ShowNetpluginTip();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue