NEW:Fixed some mall issues
Change-Id: I1f9105a1a7089457f4ecb327cb5db43ca0d39f4e (cherry picked from commit 975bdcf64f88b4f1e7c0e03abd9dfba6c32c00fe)
This commit is contained in:
parent
2406cc35b6
commit
75e960f999
6 changed files with 78 additions and 30 deletions
3
resources/images/mall_control_refresh.svg
Normal file
3
resources/images/mall_control_refresh.svg
Normal file
|
@ -0,0 +1,3 @@
|
|||
<svg width="33" height="31" viewBox="0 0 33 31" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M32.2153 5.96128C31.5988 5.73822 30.922 6.06267 30.7031 6.68294L29.7873 9.2678C28.7152 6.83324 27.022 4.6933 24.8661 3.08297C18.0116 -2.03427 8.24859 -0.636275 3.10974 6.20103C0.622547 9.50995 -0.425811 13.5882 0.15753 17.6832C0.743239 21.7949 2.90148 25.4283 6.2347 27.9153C9.02362 29.9956 12.2917 31 15.5327 31C20.2668 31 24.9454 28.8589 27.9935 24.802C29.3424 23.008 30.2665 20.9969 30.7374 18.8224C30.877 18.1794 30.4736 17.5437 29.8346 17.4029C29.198 17.2645 28.5662 17.6677 28.4265 18.313C28.0278 20.1464 27.248 21.845 26.1074 23.3623C21.7483 29.1595 13.4643 30.3416 7.64158 25.9985C4.82071 23.8931 2.99496 20.8204 2.49918 17.3445C2.00577 13.8853 2.8932 10.4392 4.99465 7.64198C9.35256 1.84243 17.6329 0.655561 23.4581 5.00105C25.5666 6.57558 27.1498 8.75131 28.0053 11.2121L23.9385 9.61134C23.3315 9.37397 22.644 9.67456 22.4062 10.2889C22.1683 10.9032 22.4701 11.5938 23.0782 11.8336L29.0631 14.1894C29.2039 14.2443 29.3495 14.2717 29.4926 14.2717C29.5128 14.2717 29.5305 14.2646 29.5506 14.2634C29.5956 14.2682 29.6405 14.2872 29.6855 14.2872C30.1706 14.2872 30.6274 13.9831 30.7989 13.4952L32.93 7.48691C33.1512 6.86544 32.8306 6.18195 32.2153 5.96128Z" fill="#353535"/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.3 KiB |
|
@ -4915,10 +4915,15 @@ void GUI_App::open_mall_page_dialog()
|
|||
if (getAgent() && mainframe) {
|
||||
getAgent()->get_model_mall_home_url(&url);
|
||||
|
||||
ModelMallDialog modelMallDialog;
|
||||
modelMallDialog.go_to_mall(url);
|
||||
modelMallDialog.ShowModal();
|
||||
}
|
||||
if (!m_mall_home_dialog) {
|
||||
m_mall_home_dialog = new ModelMallDialog();
|
||||
m_mall_home_dialog->go_to_mall(url);
|
||||
}
|
||||
else {
|
||||
m_mall_home_dialog->go_to_mall(url);
|
||||
}
|
||||
m_mall_home_dialog->Show();
|
||||
}
|
||||
}
|
||||
|
||||
void GUI_App::open_publish_page_dialog()
|
||||
|
@ -4927,9 +4932,14 @@ void GUI_App::open_publish_page_dialog()
|
|||
if (getAgent() && mainframe) {
|
||||
getAgent()->get_model_publish_url(&url);
|
||||
|
||||
ModelMallDialog modelMallDialog;
|
||||
modelMallDialog.go_to_publish(url);
|
||||
modelMallDialog.ShowModal();
|
||||
if (!m_mall_publish_dialog) {
|
||||
m_mall_publish_dialog = new ModelMallDialog();
|
||||
m_mall_publish_dialog->go_to_mall(url);
|
||||
}
|
||||
else {
|
||||
m_mall_publish_dialog->go_to_publish(url);
|
||||
}
|
||||
m_mall_publish_dialog->Show();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ class NotificationManager;
|
|||
struct GUI_InitParams;
|
||||
class ParamsDialog;
|
||||
class HMSQuery;
|
||||
class ModelMallDialog;
|
||||
|
||||
|
||||
enum FileType
|
||||
|
@ -463,7 +464,10 @@ public:
|
|||
ParamsDialog* params_dialog();
|
||||
Model& model();
|
||||
NotificationManager * notification_manager();
|
||||
//BBS
|
||||
|
||||
ModelMallDialog* m_mall_home_dialog{ nullptr };
|
||||
ModelMallDialog* m_mall_publish_dialog{ nullptr };
|
||||
|
||||
void load_url(wxString url);
|
||||
void open_mall_page_dialog();
|
||||
void open_publish_page_dialog();
|
||||
|
|
|
@ -26,6 +26,10 @@ namespace GUI {
|
|||
|
||||
wxBoxSizer* m_sizer_main = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL);
|
||||
m_line_top->SetBackgroundColour(wxColour(166, 169, 170));
|
||||
m_sizer_main->Add(m_line_top, 0, wxEXPAND, 0);
|
||||
|
||||
m_web_control_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, MODEL_MALL_PAGE_CONTROL_SIZE, wxTAB_TRAVERSAL);
|
||||
m_web_control_panel->SetBackgroundColour(*wxWHITE);
|
||||
m_web_control_panel->SetSize(MODEL_MALL_PAGE_CONTROL_SIZE);
|
||||
|
@ -55,6 +59,13 @@ namespace GUI {
|
|||
m_control_forward->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {SetCursor(wxCursor(wxCURSOR_HAND)); });
|
||||
m_control_forward->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {SetCursor(wxCursor(wxCURSOR_ARROW)); });
|
||||
|
||||
auto m_control_refresh = new ScalableButton(m_web_control_panel, wxID_ANY, "mall_control_refresh", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true);
|
||||
m_control_refresh->SetBackgroundColour(*wxWHITE);
|
||||
m_control_refresh->SetSize(wxSize(FromDIP(25), FromDIP(30)));
|
||||
m_control_refresh->SetMinSize(wxSize(FromDIP(25), FromDIP(30)));
|
||||
m_control_refresh->SetMaxSize(wxSize(FromDIP(25), FromDIP(30)));
|
||||
m_control_refresh->Bind(wxEVT_LEFT_DOWN, &ModelMallDialog::on_refresh, this);
|
||||
|
||||
|
||||
#ifdef __APPLE__
|
||||
m_control_back->SetToolTip(_L("Click to return (Command + Left Arrow)"));
|
||||
|
@ -73,6 +84,7 @@ namespace GUI {
|
|||
|
||||
m_sizer_web_control->Add( m_control_back, 0, wxALIGN_CENTER | wxLEFT, FromDIP(26) );
|
||||
m_sizer_web_control->Add(m_control_forward, 0, wxALIGN_CENTER | wxLEFT, FromDIP(26));
|
||||
m_sizer_web_control->Add(m_control_refresh, 0, wxALIGN_CENTER | wxLEFT, FromDIP(26));
|
||||
//m_sizer_web_control->Add(m_button1, 0, wxALIGN_CENTER|wxLEFT, 5);
|
||||
//m_sizer_web_control->Add(m_textCtrl1, 0, wxALIGN_CENTER|wxLEFT, 5);
|
||||
|
||||
|
@ -100,6 +112,10 @@ namespace GUI {
|
|||
|
||||
Centre(wxBOTH);
|
||||
Bind(wxEVT_SHOW, &ModelMallDialog::on_show, this);
|
||||
|
||||
Bind(wxEVT_CLOSE_WINDOW, [this](auto& e) {
|
||||
this->Hide();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -131,7 +147,7 @@ namespace GUI {
|
|||
|
||||
std::string filename = "";
|
||||
if (j["data"].contains("filename"))
|
||||
download_url = j["data"]["filename"].get<std::string>();
|
||||
filename = j["data"]["filename"].get<std::string>();
|
||||
|
||||
if (download_url.empty()) return;
|
||||
wxGetApp().plater()->request_model_download(download_url, filename);
|
||||
|
@ -149,9 +165,22 @@ namespace GUI {
|
|||
|
||||
void ModelMallDialog::on_show(wxShowEvent& event)
|
||||
{
|
||||
if (event.IsShown()) {
|
||||
Centre(wxBOTH);
|
||||
}
|
||||
else {
|
||||
go_to_url(m_url);
|
||||
}
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void ModelMallDialog::on_refresh(wxMouseEvent& evt)
|
||||
{
|
||||
if (!m_browser->GetCurrentURL().empty()) {
|
||||
m_browser->Reload();
|
||||
}
|
||||
}
|
||||
|
||||
void ModelMallDialog::on_back(wxMouseEvent& evt)
|
||||
{
|
||||
if (m_browser->CanGoBack()) {
|
||||
|
@ -181,15 +210,21 @@ namespace GUI {
|
|||
|
||||
void ModelMallDialog::go_to_mall(wxString url)
|
||||
{
|
||||
//show_control(true);
|
||||
//m_browser->ClearHistory();
|
||||
/*if (!url.empty() && m_homepage_url.empty()) {
|
||||
m_homepage_url = url;
|
||||
}*/
|
||||
if(url.empty())return;
|
||||
m_url = url;
|
||||
go_to_url(url);
|
||||
}
|
||||
|
||||
void ModelMallDialog::go_to_publish(wxString url)
|
||||
{
|
||||
//show_control(true);
|
||||
//m_browser->ClearHistory();
|
||||
/*if (!url.empty() && m_publish_url.empty()) {
|
||||
m_publish_url = url;
|
||||
}*/
|
||||
if(url.empty())return;
|
||||
m_url = url;
|
||||
go_to_url(url);
|
||||
}
|
||||
|
||||
|
|
|
@ -56,9 +56,11 @@ namespace Slic3r { namespace GUI {
|
|||
void show_control(bool show);
|
||||
void go_to_mall(wxString url);
|
||||
void go_to_publish(wxString url);
|
||||
void on_refresh(wxMouseEvent& evt);
|
||||
public:
|
||||
wxPanel* m_web_control_panel{nullptr};
|
||||
wxWebView* m_browser{nullptr};
|
||||
wxString m_url;
|
||||
};
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
|
|
@ -7158,7 +7158,7 @@ int Plater::save_project(bool saveAs)
|
|||
void Plater::import_model_id(const std::string& download_info)
|
||||
{
|
||||
std::string download_url = "";
|
||||
wxString filename = "";
|
||||
std::string filename = "";
|
||||
|
||||
auto selection_data_arr = wxSplit(download_info, '|');
|
||||
|
||||
|
@ -7207,17 +7207,6 @@ void Plater::import_model_id(const std::string& download_info)
|
|||
std::string http_body;
|
||||
|
||||
msg = _L("prepare 3mf file...");
|
||||
//BBLProfile* profile = new BBLProfile();
|
||||
//profile->profile_id = profile_id;
|
||||
//profile->model_id = model_id;
|
||||
//res = m_agent->get_profile_3mf(profile);
|
||||
/*if (res < 0 && profile->url.empty() && profile->md5.empty()) {
|
||||
wxString error_msg = wxString::Format(_devL("get_des,err:code=%u,msg=%s"), http_code, http_body);
|
||||
msg = _L("Import project failed, Please try again!") + error_msg;
|
||||
return;
|
||||
}*/
|
||||
//filename = from_u8(profile->filename);
|
||||
//filename = from_u8(fs::path(download_url).filename().string());
|
||||
|
||||
//gets the number of files with the same name
|
||||
std::vector<wxString> vecFiles;
|
||||
|
@ -7225,19 +7214,20 @@ void Plater::import_model_id(const std::string& download_info)
|
|||
|
||||
|
||||
target_path = fs::path(wxGetApp().app_config->get("download_path"));
|
||||
//filename = from_u8(fs::path(download_url).filename().string());
|
||||
|
||||
try
|
||||
{
|
||||
vecFiles.clear();
|
||||
wxString extension = fs::path(filename).extension().c_str();
|
||||
auto name = filename.substr(0, filename.length() - extension.length() - 1);
|
||||
|
||||
for (const auto& iter : boost::filesystem::directory_iterator(target_path))
|
||||
{
|
||||
if (boost::filesystem::is_directory(iter.path()))
|
||||
continue;
|
||||
|
||||
wxString sFile = iter.path().filename().string().c_str();
|
||||
|
||||
if ( strstr(sFile.c_str(), filename.c_str()) != NULL) {
|
||||
if (strstr(sFile.c_str(), name.c_str()) != NULL) {
|
||||
vecFiles.push_back(sFile);
|
||||
}
|
||||
|
||||
|
@ -7252,8 +7242,8 @@ void Plater::import_model_id(const std::string& download_info)
|
|||
//update filename
|
||||
if (is_already_exist && vecFiles.size() >= 1) {
|
||||
wxString extension = fs::path(filename).extension().c_str();
|
||||
wxString name = filename.SubString(0, filename.length() - extension.length() - 1);
|
||||
filename = wxString::Format("%s(%d)%s",name, vecFiles.size() + 1, extension);
|
||||
wxString name = filename.substr(0, filename.length() - extension.length() - 1);
|
||||
filename = wxString::Format("%s(%d)%s", name, vecFiles.size() + 1, extension).ToStdString();
|
||||
}
|
||||
|
||||
|
||||
|
@ -7266,6 +7256,10 @@ void Plater::import_model_id(const std::string& download_info)
|
|||
boost::uuids::uuid uuid = boost::uuids::random_generator()();
|
||||
std::string unique = to_string(uuid).substr(0, 6);
|
||||
|
||||
if (filename.empty()) {
|
||||
filename = "untitled.3mf";
|
||||
}
|
||||
|
||||
//target_path /= (boost::format("%1%_%2%.3mf") % filename % unique).str();
|
||||
target_path /= filename.c_str();
|
||||
fs::path tmp_path = target_path;
|
||||
|
|
Loading…
Reference in a new issue