mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 15:37:30 -06:00
ENH: add the logic to prompt user to update network plugins
Change-Id: I73cce20e58783a365ad2665c8e095dcf2e9c02ea
This commit is contained in:
parent
8b5a49f378
commit
697d945ca1
7 changed files with 289 additions and 18 deletions
|
@ -44,7 +44,7 @@ ReleaseNoteDialog::ReleaseNoteDialog(Plater *plater /*= nullptr*/)
|
|||
|
||||
m_sizer_body->Add(0, 0, 0, wxLEFT, FromDIP(38));
|
||||
|
||||
auto sm = create_scaled_bitmap("BambuStudio", nullptr, 70);
|
||||
auto sm = create_scaled_bitmap("BambuStudio", nullptr, 70);
|
||||
auto brand = new wxStaticBitmap(this, wxID_ANY, sm, wxDefaultPosition, wxSize(FromDIP(70), FromDIP(70)));
|
||||
|
||||
m_sizer_body->Add(brand, 0, wxALL, 0);
|
||||
|
@ -85,8 +85,8 @@ void ReleaseNoteDialog::on_dpi_changed(const wxRect &suggested_rect)
|
|||
{
|
||||
}
|
||||
|
||||
void ReleaseNoteDialog::update_release_note(wxString release_note, std::string version)
|
||||
{
|
||||
void ReleaseNoteDialog::update_release_note(wxString release_note, std::string version)
|
||||
{
|
||||
m_text_up_info->SetLabel(wxString::Format(_L("version %s update information :"), version));
|
||||
wxBoxSizer * sizer_text_release_note = new wxBoxSizer(wxVERTICAL);
|
||||
auto m_staticText_release_note = new wxStaticText(m_vebview_release_note, wxID_ANY, release_note, wxDefaultPosition, wxDefaultSize, 0);
|
||||
|
@ -97,6 +97,154 @@ void ReleaseNoteDialog::update_release_note(wxString release_note, std::string v
|
|||
m_vebview_release_note->Fit();
|
||||
}
|
||||
|
||||
UpdatePluginDialog::UpdatePluginDialog(wxWindow* parent /*= nullptr*/)
|
||||
: DPIDialog(static_cast<wxWindow*>(wxGetApp().mainframe), wxID_ANY, _L("Network plug-in update"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
|
||||
{
|
||||
std::string icon_path = (boost::format("%1%/images/BambuStudioTitle.ico") % resources_dir()).str();
|
||||
SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO));
|
||||
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
wxBoxSizer* m_sizer_main = new wxBoxSizer(wxVERTICAL);
|
||||
auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1));
|
||||
m_line_top->SetBackgroundColour(wxColour(166, 169, 170));
|
||||
m_sizer_main->Add(m_line_top, 0, wxEXPAND, 0);
|
||||
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(30));
|
||||
|
||||
wxBoxSizer* m_sizer_body = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
|
||||
|
||||
auto sm = create_scaled_bitmap("BambuStudio", nullptr, 55);
|
||||
auto brand = new wxStaticBitmap(this, wxID_ANY, sm, wxDefaultPosition, wxSize(FromDIP(55), FromDIP(55)));
|
||||
|
||||
wxBoxSizer* m_sizer_right = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
m_text_up_info = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
|
||||
m_text_up_info->SetFont(::Label::Head_13);
|
||||
m_text_up_info->SetMaxSize(wxSize(FromDIP(260), -1));
|
||||
m_text_up_info->Wrap(FromDIP(260));
|
||||
m_text_up_info->SetForegroundColour(wxColour(0x26, 0x2E, 0x30));
|
||||
|
||||
|
||||
operation_tips = new ::Label(this, _L("Click OK to update the Network plug-in when Bambu Studio launches next time."));
|
||||
operation_tips->SetFont(::Label::Body_12);
|
||||
operation_tips->SetSize(wxSize(FromDIP(260), -1));
|
||||
operation_tips->Wrap(FromDIP(260));
|
||||
operation_tips->SetForegroundColour(*wxBLACK);
|
||||
|
||||
|
||||
m_vebview_release_note = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL);
|
||||
m_vebview_release_note->SetScrollRate(5, 5);
|
||||
m_vebview_release_note->SetBackgroundColour(wxColour(0xF8, 0xF8, 0xF8));
|
||||
m_vebview_release_note->SetMinSize(wxSize(FromDIP(260), FromDIP(150)));
|
||||
m_vebview_release_note->SetMaxSize(wxSize(FromDIP(260), FromDIP(150)));
|
||||
|
||||
auto sizer_button = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
|
||||
std::pair<wxColour, int>(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal));
|
||||
|
||||
StateColor btn_bg_white(std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Pressed), std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Hovered),
|
||||
std::pair<wxColour, int>(*wxWHITE, StateColor::Normal));
|
||||
|
||||
auto m_button_ok = new Button(this, _L("OK"));
|
||||
m_button_ok->SetBackgroundColor(btn_bg_green);
|
||||
m_button_ok->SetBorderColor(*wxWHITE);
|
||||
m_button_ok->SetTextColor(wxColour(0xFFFFFE));
|
||||
m_button_ok->SetFont(Label::Body_12);
|
||||
m_button_ok->SetSize(wxSize(FromDIP(58), FromDIP(24)));
|
||||
m_button_ok->SetMinSize(wxSize(FromDIP(58), FromDIP(24)));
|
||||
m_button_ok->SetCornerRadius(FromDIP(12));
|
||||
|
||||
m_button_ok->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
|
||||
EndModal(wxID_OK);
|
||||
});
|
||||
|
||||
auto m_button_cancel = new Button(this, _L("Cancel"));
|
||||
m_button_cancel->SetBackgroundColor(btn_bg_white);
|
||||
m_button_cancel->SetBorderColor(wxColour(38, 46, 48));
|
||||
m_button_cancel->SetFont(Label::Body_12);
|
||||
m_button_cancel->SetSize(wxSize(FromDIP(58), FromDIP(24)));
|
||||
m_button_cancel->SetMinSize(wxSize(FromDIP(58), FromDIP(24)));
|
||||
m_button_cancel->SetCornerRadius(FromDIP(12));
|
||||
|
||||
m_button_cancel->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
|
||||
EndModal(wxID_NO);
|
||||
});
|
||||
|
||||
sizer_button->AddStretchSpacer();
|
||||
sizer_button->Add(m_button_ok, 0, wxALL, FromDIP(5));
|
||||
sizer_button->Add(m_button_cancel, 0, wxALL, FromDIP(5));
|
||||
|
||||
m_sizer_right->Add(m_text_up_info, 0, 0, 0);
|
||||
m_sizer_right->Add(0, 0, 0, wxTOP, FromDIP(5));
|
||||
m_sizer_right->Add(m_vebview_release_note, 0, wxEXPAND | wxRIGHT, FromDIP(20));
|
||||
m_sizer_right->Add(0, 0, 0, wxTOP, FromDIP(5));
|
||||
m_sizer_right->Add(operation_tips, 1, wxEXPAND | wxRIGHT, FromDIP(20));
|
||||
m_sizer_right->Add(0, 0, 0, wxTOP, FromDIP(5));
|
||||
m_sizer_right->Add(sizer_button, 0, wxEXPAND | wxRIGHT, FromDIP(20));
|
||||
|
||||
m_sizer_body->Add(0, 0, 0, wxLEFT, FromDIP(24));
|
||||
m_sizer_body->Add(brand, 0, wxALL, 0);
|
||||
m_sizer_body->Add(0, 0, 0, wxRIGHT, FromDIP(20));
|
||||
m_sizer_body->Add(m_sizer_right, 1, wxBOTTOM | wxEXPAND, FromDIP(18));
|
||||
m_sizer_main->Add(m_sizer_body, 0, wxEXPAND, 0);
|
||||
|
||||
SetSizer(m_sizer_main);
|
||||
Layout();
|
||||
m_sizer_main->Fit(this);
|
||||
|
||||
Centre(wxBOTH);
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
}
|
||||
|
||||
UpdatePluginDialog::~UpdatePluginDialog() {}
|
||||
|
||||
|
||||
void UpdatePluginDialog::on_dpi_changed(const wxRect& suggested_rect)
|
||||
{
|
||||
}
|
||||
|
||||
void UpdatePluginDialog::update_info(std::string json_path)
|
||||
{
|
||||
std::string version_str, description_str;
|
||||
wxString version;
|
||||
wxString description;
|
||||
|
||||
try {
|
||||
boost::nowide::ifstream ifs(json_path);
|
||||
json j;
|
||||
ifs >> j;
|
||||
|
||||
version_str = j["version"];
|
||||
description_str = j["description"];
|
||||
}
|
||||
catch(nlohmann::detail::parse_error &err) {
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__<< ": parse "<<json_path<<" got a nlohmann::detail::parse_error, reason = " << err.what();
|
||||
return;
|
||||
}
|
||||
|
||||
version = from_u8(version_str);
|
||||
description = from_u8(description_str);
|
||||
|
||||
m_text_up_info->SetLabel(wxString::Format(_L("A new Network plug-in(%s) available, Do you want to install it?"), version));
|
||||
m_text_up_info->SetMaxSize(wxSize(FromDIP(260), -1));
|
||||
m_text_up_info->Wrap(FromDIP(260));
|
||||
wxBoxSizer* sizer_text_release_note = new wxBoxSizer(wxVERTICAL);
|
||||
auto m_text_label = new ::Label(m_vebview_release_note, description);
|
||||
m_text_label->SetFont(::Label::Body_13);
|
||||
m_text_label->SetForegroundColour(*wxBLACK);
|
||||
m_text_label->SetMaxSize(wxSize(FromDIP(235), -1));
|
||||
m_text_label->Wrap(FromDIP(235));
|
||||
|
||||
sizer_text_release_note->Add(m_text_label, 0, wxALL, 5);
|
||||
m_vebview_release_note->SetSizer(sizer_text_release_note);
|
||||
m_vebview_release_note->Layout();
|
||||
m_vebview_release_note->Fit();
|
||||
Layout();
|
||||
Fit();
|
||||
}
|
||||
|
||||
void UpdateVersionDialog::alter_choice(wxCommandEvent& event)
|
||||
{
|
||||
wxGetApp().set_skip_version(m_remind_choice->GetValue());
|
||||
|
@ -174,7 +322,7 @@ UpdateVersionDialog::UpdateVersionDialog(wxWindow *parent)
|
|||
|
||||
auto sizer_button = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
|
||||
|
||||
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
|
||||
std::pair<wxColour, int>(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal));
|
||||
|
||||
|
@ -202,19 +350,19 @@ UpdateVersionDialog::UpdateVersionDialog(wxWindow *parent)
|
|||
m_button_cancel->SetMinSize(wxSize(FromDIP(58), FromDIP(24)));
|
||||
m_button_cancel->SetCornerRadius(FromDIP(12));
|
||||
|
||||
m_button_cancel->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) {
|
||||
EndModal(wxID_NO);
|
||||
m_button_cancel->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) {
|
||||
EndModal(wxID_NO);
|
||||
});
|
||||
|
||||
|
||||
sizer_button->Add(m_remind_choice, 0, wxALL | wxEXPAND, FromDIP(5));
|
||||
sizer_button->AddStretchSpacer();
|
||||
sizer_button->Add(m_button_ok, 0, wxALL, FromDIP(5));
|
||||
sizer_button->Add(m_button_cancel, 0, wxALL, FromDIP(5));
|
||||
|
||||
|
||||
|
||||
m_sizer_right->Add(m_simplebook_release_note, 0, wxEXPAND | wxRIGHT, FromDIP(20));
|
||||
m_sizer_right->Add(sizer_button, 0, wxEXPAND | wxRIGHT, FromDIP(20));
|
||||
|
||||
|
||||
m_sizer_body->Add(m_sizer_right, 1, wxBOTTOM | wxEXPAND, FromDIP(8));
|
||||
m_sizer_main->Add(m_sizer_body, 0, wxEXPAND, 0);
|
||||
m_sizer_main->Add(0, 0, 0, wxBOTTOM, 10);
|
||||
|
@ -312,7 +460,7 @@ std::vector<std::string> UpdateVersionDialog::splitWithStl(std::string str,std::
|
|||
}
|
||||
|
||||
void UpdateVersionDialog::update_version_info(wxString release_note, wxString version)
|
||||
{
|
||||
{
|
||||
//bbs check whether the web display is used
|
||||
bool use_web_link = false;
|
||||
std::string url_line = "";
|
||||
|
@ -341,7 +489,7 @@ void UpdateVersionDialog::update_version_info(wxString release_note, wxString ve
|
|||
m_scrollwindows_release_note->SetSizer(sizer_text_release_note);
|
||||
m_scrollwindows_release_note->Layout();
|
||||
m_scrollwindows_release_note->Fit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SecondaryCheckDialog::SecondaryCheckDialog(wxWindow* parent, wxWindowID id, const wxString& title, enum ButtonStyle btn_style, const wxPoint& pos, const wxSize& size, long style, bool not_show_again_check)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue