NEW: [STUDIO-2476] design_staffpick
Change-Id: Ibe4d540ca31882e199437dc2811925e1a40680ec
This commit is contained in:
parent
20ad3c7f9a
commit
84580f6f94
|
@ -285,6 +285,10 @@ void AppConfig::set_defaults()
|
|||
set("mouse_wheel", "0");
|
||||
}
|
||||
|
||||
if (get("staff_pick_switch").empty()) {
|
||||
set_bool("staff_pick_switch", true);
|
||||
}
|
||||
|
||||
if (get("backup_switch").empty()) {
|
||||
set_bool("backup_switch", true);
|
||||
}
|
||||
|
|
|
@ -3664,6 +3664,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");
|
||||
|
@ -4510,6 +4528,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()) {
|
||||
|
|
|
@ -436,6 +436,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);
|
||||
|
|
|
@ -556,6 +556,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;
|
||||
|
@ -846,6 +851,10 @@ 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("Model Mall"), page, _L("Model Mall"));
|
||||
// auto item_backup = create_item_switch(_L("Backup switch"), page, _L("Backup switch"), "units");
|
||||
auto item_modelmall = create_item_checkbox(_L("Show staff-picks"), page, _L("Show staff-picks"), 50, "staff_pick_switch");
|
||||
|
||||
|
||||
auto title_backup = create_item_title(_L("Backup"), page, _L("Backup"));
|
||||
//auto item_backup = create_item_switch(_L("Backup switch"), page, _L("Backup switch"), "units");
|
||||
|
@ -876,9 +885,12 @@ 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_backup, 0, wxTOP| wxEXPAND, FromDIP(20));
|
||||
sizer_page->Add(item_backup, 0, wxTOP,FromDIP(3));
|
||||
sizer_page->Add(item_backup_interval, 0, wxTOP,FromDIP(3));
|
||||
sizer_page->Add(item_backup_interval, 0, wxTOP, FromDIP(3));
|
||||
|
||||
sizer_page->Add(title_downloads, 0, wxTOP| wxEXPAND, FromDIP(20));
|
||||
sizer_page->Add(item_downloads, 0, wxEXPAND, 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();
|
||||
|
||||
|
|
|
@ -92,10 +92,12 @@ func_get_slice_info NetworkAgent::get_slice_info_ptr = nullptr;
|
|||
func_query_bind_status NetworkAgent::query_bind_status_ptr = nullptr;
|
||||
func_modify_printer_name NetworkAgent::modify_printer_name_ptr = nullptr;
|
||||
func_get_camera_url NetworkAgent::get_camera_url_ptr = nullptr;
|
||||
func_get_design_staffpick NetworkAgent::get_design_staffpick_ptr = nullptr;
|
||||
func_start_pubilsh NetworkAgent::start_publish_ptr = nullptr;
|
||||
func_get_profile_3mf NetworkAgent::get_profile_3mf_ptr = nullptr;
|
||||
func_get_model_publish_url NetworkAgent::get_model_publish_url_ptr = nullptr;
|
||||
func_get_model_mall_home_url NetworkAgent::get_model_mall_home_url_ptr = nullptr;
|
||||
func_get_model_mall_detail_url NetworkAgent::get_model_mall_detail_url_ptr = nullptr;
|
||||
func_get_my_profile NetworkAgent::get_my_profile_ptr = nullptr;
|
||||
func_track_enable NetworkAgent::track_enable_ptr = nullptr;
|
||||
func_track_event NetworkAgent::track_event_ptr = nullptr;
|
||||
|
@ -238,11 +240,13 @@ int NetworkAgent::initialize_network_module(bool using_backup)
|
|||
get_slice_info_ptr = reinterpret_cast<func_get_slice_info>(get_network_function("bambu_network_get_slice_info"));
|
||||
query_bind_status_ptr = reinterpret_cast<func_query_bind_status>(get_network_function("bambu_network_query_bind_status"));
|
||||
modify_printer_name_ptr = reinterpret_cast<func_modify_printer_name>(get_network_function("bambu_network_modify_printer_name"));
|
||||
get_camera_url_ptr = reinterpret_cast<func_get_camera_url>(get_network_function("bambu_network_get_camera_url"));
|
||||
get_camera_url_ptr = reinterpret_cast<func_get_camera_url>(get_network_function("bambu_network_get_camera_url"));
|
||||
get_design_staffpick_ptr = reinterpret_cast<func_get_design_staffpick>(get_network_function("bambu_network_get_design_staffpick"));
|
||||
start_publish_ptr = reinterpret_cast<func_start_pubilsh>(get_network_function("bambu_network_start_publish"));
|
||||
get_profile_3mf_ptr = reinterpret_cast<func_get_profile_3mf>(get_network_function("bambu_network_get_profile_3mf"));
|
||||
get_model_publish_url_ptr = reinterpret_cast<func_get_model_publish_url>(get_network_function("bambu_network_get_model_publish_url"));
|
||||
get_model_mall_home_url_ptr = reinterpret_cast<func_get_model_mall_home_url>(get_network_function("bambu_network_get_model_mall_home_url"));
|
||||
get_model_mall_detail_url_ptr = reinterpret_cast<func_get_model_mall_detail_url>(get_network_function("bambu_network_get_model_mall_detail_url"));
|
||||
get_my_profile_ptr = reinterpret_cast<func_get_my_profile>(get_network_function("bambu_network_get_my_profile"));
|
||||
track_enable_ptr = reinterpret_cast<func_track_enable>(get_network_function("bambu_network_track_enable"));
|
||||
track_event_ptr = reinterpret_cast<func_track_event>(get_network_function("bambu_network_track_event"));
|
||||
|
@ -339,10 +343,12 @@ int NetworkAgent::unload_network_module()
|
|||
query_bind_status_ptr = nullptr;
|
||||
modify_printer_name_ptr = nullptr;
|
||||
get_camera_url_ptr = nullptr;
|
||||
get_design_staffpick_ptr = nullptr;
|
||||
start_publish_ptr = nullptr;
|
||||
get_profile_3mf_ptr = nullptr;
|
||||
get_model_publish_url_ptr = nullptr;
|
||||
get_model_mall_home_url_ptr = nullptr;
|
||||
get_model_mall_detail_url_ptr = nullptr;
|
||||
get_my_profile_ptr = nullptr;
|
||||
track_enable_ptr = nullptr;
|
||||
track_event_ptr = nullptr;
|
||||
|
@ -1088,6 +1094,17 @@ int NetworkAgent::get_camera_url(std::string dev_id, std::function<void(std::str
|
|||
return ret;
|
||||
}
|
||||
|
||||
int NetworkAgent::get_design_staffpick(int offset, int limit, std::function<void(std::string)> callback)
|
||||
{
|
||||
int ret = 0;
|
||||
if (network_agent && get_design_staffpick_ptr) {
|
||||
ret = get_design_staffpick_ptr(network_agent, offset, limit, callback);
|
||||
if (ret)
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%")%network_agent %ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int NetworkAgent::start_publish(PublishParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, std::string *out)
|
||||
{
|
||||
int ret = 0;
|
||||
|
@ -1131,6 +1148,17 @@ int NetworkAgent::get_model_mall_home_url(std::string* url)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int NetworkAgent::get_model_mall_detail_url(std::string* url, std::string id)
|
||||
{
|
||||
int ret = 0;
|
||||
if (network_agent && get_model_publish_url_ptr) {
|
||||
ret = get_model_mall_detail_url_ptr(network_agent, url, id);
|
||||
if (ret)
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%") % network_agent % ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int NetworkAgent::get_my_profile(std::string token, unsigned int *http_code, std::string *http_body)
|
||||
{
|
||||
int ret = 0;
|
||||
|
|
|
@ -72,10 +72,12 @@ typedef int (*func_get_slice_info)(void *agent, std::string project_id, std::str
|
|||
typedef int (*func_query_bind_status)(void *agent, std::vector<std::string> query_list, unsigned int* http_code, std::string* http_body);
|
||||
typedef int (*func_modify_printer_name)(void *agent, std::string dev_id, std::string dev_name);
|
||||
typedef int (*func_get_camera_url)(void *agent, std::string dev_id, std::function<void(std::string)> callback);
|
||||
typedef int (*func_get_design_staffpick)(void *agent, int offset, int limit, std::function<void(std::string)> callback);
|
||||
typedef int (*func_start_pubilsh)(void *agent, PublishParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, std::string* out);
|
||||
typedef int (*func_get_profile_3mf)(void *agent, BBLProfile* profile);
|
||||
typedef int (*func_get_model_publish_url)(void *agent, std::string* url);
|
||||
typedef int (*func_get_model_mall_home_url)(void *agent, std::string* url);
|
||||
typedef int (*func_get_model_mall_detail_url)(void *agent, std::string* url, std::string id);
|
||||
typedef int (*func_get_my_profile)(void *agent, std::string token, unsigned int *http_code, std::string *http_body);
|
||||
typedef int (*func_track_enable)(void *agent, bool enable);
|
||||
typedef int (*func_track_event)(void *agent, std::string evt_key, std::string content);
|
||||
|
@ -161,10 +163,12 @@ public:
|
|||
int query_bind_status(std::vector<std::string> query_list, unsigned int* http_code, std::string* http_body);
|
||||
int modify_printer_name(std::string dev_id, std::string dev_name);
|
||||
int get_camera_url(std::string dev_id, std::function<void(std::string)> callback);
|
||||
int get_design_staffpick(int offset, int limit, std::function<void(std::string)> callback);
|
||||
int start_publish(PublishParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, std::string* out);
|
||||
int get_profile_3mf(BBLProfile* profile);
|
||||
int get_model_publish_url(std::string* url);
|
||||
int get_model_mall_home_url(std::string* url);
|
||||
int get_model_mall_detail_url(std::string* url, std::string id);
|
||||
int get_my_profile(std::string token, unsigned int* http_code, std::string* http_body);
|
||||
int track_enable(bool enable);
|
||||
int track_event(std::string evt_key, std::string content);
|
||||
|
@ -239,10 +243,12 @@ private:
|
|||
static func_query_bind_status query_bind_status_ptr;
|
||||
static func_modify_printer_name modify_printer_name_ptr;
|
||||
static func_get_camera_url get_camera_url_ptr;
|
||||
static func_get_design_staffpick get_design_staffpick_ptr;
|
||||
static func_start_pubilsh start_publish_ptr;
|
||||
static func_get_profile_3mf get_profile_3mf_ptr;
|
||||
static func_get_model_publish_url get_model_publish_url_ptr;
|
||||
static func_get_model_mall_home_url get_model_mall_home_url_ptr;
|
||||
static func_get_model_mall_detail_url get_model_mall_detail_url_ptr;
|
||||
static func_get_my_profile get_my_profile_ptr;
|
||||
static func_track_enable track_enable_ptr;
|
||||
static func_track_event track_event_ptr;
|
||||
|
|
Loading…
Reference in New Issue