From a415ab0c714986588d5ac3c4c7eef4a9c7a2d4f2 Mon Sep 17 00:00:00 2001 From: "hang.xu" Date: Tue, 3 Sep 2024 17:59:44 +0800 Subject: [PATCH] FIX: Interactive UI for installing network plugins jira: none Change-Id: I2a99917cab90eda26335be38cccbf17cd2d5342b --- src/slic3r/GUI/DownloadProgressDialog.cpp | 27 ++++++++++++++++------- src/slic3r/GUI/GUI_App.cpp | 25 +++++++++++++++++++-- src/slic3r/GUI/MainFrame.cpp | 3 +++ src/slic3r/GUI/SelectMachine.cpp | 16 +++++++++++++- 4 files changed, 60 insertions(+), 11 deletions(-) diff --git a/src/slic3r/GUI/DownloadProgressDialog.cpp b/src/slic3r/GUI/DownloadProgressDialog.cpp index 00b7463be..5d6d07681 100644 --- a/src/slic3r/GUI/DownloadProgressDialog.cpp +++ b/src/slic3r/GUI/DownloadProgressDialog.cpp @@ -148,14 +148,25 @@ bool DownloadProgressDialog::Show(bool show) m_upgrade_job->set_event_handle(this); m_status_bar->set_progress(0); Bind(EVT_UPGRADE_NETWORK_SUCCESS, [this](wxCommandEvent& evt) { - m_status_bar->change_button_label(_L("OK")); - on_finish(); - m_status_bar->set_cancel_callback_fina( - [this]() { - this->Close(); - wxGetApp().request_login(); - } - ); + if (wxGetApp().check_networking_version()) { + m_status_bar->change_button_label(_L("OK")); + on_finish(); + m_status_bar->set_cancel_callback_fina( + [this]() { + this->Close(); + wxGetApp().request_login(); + } + ); + } + else { + on_finish(); + m_status_bar->change_button_label(_L("Close")); + m_status_bar->set_cancel_callback_fina( + [this]() { + this->Close(); + } + ); + } }); //download failed diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index c1c2b2f3c..5ec74dffc 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -4233,8 +4233,29 @@ std::string GUI_App::handle_web_request(std::string cmd) if (mainframe && mainframe->m_webview) { mainframe->m_webview->OpenOneMakerlab(strUrl); } } - } - else if (command_str.compare("makerworld_model_open") == 0) + } + else if (command_str.compare("homepage_need_networkplugin") == 0){ + if (mainframe){ + if (mainframe->m_confirm_download_plugin_dlg == nullptr) { + mainframe->m_confirm_download_plugin_dlg = new SecondaryCheckDialog(mainframe, wxID_ANY, _L("Install network plug-in"), SecondaryCheckDialog::ButtonStyle::ONLY_CONFIRM); + mainframe->m_confirm_download_plugin_dlg->SetSize(wxSize(270, 158)); + mainframe->m_confirm_download_plugin_dlg->update_text(_L("Please Install network plug-in before log in.")); + mainframe->m_confirm_download_plugin_dlg->update_btn_label(_L("Install Network Plug-in"), _L("")); + + mainframe->m_confirm_download_plugin_dlg->Bind(EVT_SECONDARY_CHECK_CONFIRM, [this](wxCommandEvent& e) { + mainframe->m_confirm_download_plugin_dlg->Close(); + ShowDownNetPluginDlg(); + return; + }); + } + auto dlg_width = mainframe->m_confirm_download_plugin_dlg->GetSize(); + int xPos = mainframe->GetRect().GetX() + (mainframe->GetSize().x - dlg_width.x) / 2; + int yPos = mainframe->GetRect().GetY() + (mainframe->GetSize().y - dlg_width.y) / 2; + mainframe->m_confirm_download_plugin_dlg->SetPosition(wxPoint(xPos, yPos)); + mainframe->m_confirm_download_plugin_dlg->on_show(); + } + } + else if (command_str.compare("makerworld_model_open") == 0) { if (root.get_child_optional("model") != boost::none) { pt::ptree data_node = root.get_child("model"); diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 8cf38ca3f..49604f2b3 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -1045,6 +1045,9 @@ void MainFrame::init_tabpanel() return; }); } + int xPos = GetRect().GetX() + (GetSize().x - m_confirm_download_plugin_dlg->GetSize().x) / 2; + int yPos = GetRect().GetY() + (GetSize().y - m_confirm_download_plugin_dlg->GetSize().y) / 2; + m_confirm_download_plugin_dlg->SetPosition(wxPoint(xPos, yPos)); m_confirm_download_plugin_dlg->on_show(); } } diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index 1a0cf4ab5..8ac331f0d 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -4926,7 +4926,21 @@ void EditDevNameDialog::on_edit_name(wxCommandEvent &e) void PinCodePanel::on_mouse_left_up(wxMouseEvent& evt) { if (m_type == 0) { - wxGetApp().popup_ping_bind_dialog(); + if (wxGetApp().getAgent() && wxGetApp().getAgent()->is_user_login()){ + wxGetApp().popup_ping_bind_dialog(); + } + else{ + auto m_confirm_login_dlg = new SecondaryCheckDialog(nullptr, wxID_ANY, _L("Bind with Pin Code"), SecondaryCheckDialog::ButtonStyle::ONLY_CONFIRM, wxDefaultPosition); + m_confirm_login_dlg->SetSize(wxSize(FromDIP(270), FromDIP(158))); + m_confirm_login_dlg->update_text(_L("Please log in before binding your device with a PIN code.\nAlternatively, you can use LAN mode to bind your device. Learn about LAN mode.")); + m_confirm_login_dlg->update_btn_label(_L("Go to Login"), _L("")); + m_confirm_login_dlg->Bind(EVT_SECONDARY_CHECK_CONFIRM, [this](wxCommandEvent& e) { + //m_confirm_login_dlg->on_hide(); + wxGetApp().request_login(); + return; + }); + m_confirm_login_dlg->on_show(); + } } else if (m_type == 1) { InputIpAddressDialog dlgo;