FIX: cancel switch diameter restore old selection

Change-Id: Ic0919ade0ab3f75c417d87c7cf6c5738958a1cf8
Jira: STUDIO-10069
This commit is contained in:
chunmao.guo 2025-01-20 18:38:41 +08:00 committed by lane.wei
parent 05e006ba11
commit 8d3c346b1a
3 changed files with 14 additions and 12 deletions

View File

@ -178,13 +178,11 @@ Button* MsgDialog::add_button(wxWindowID btn_id, bool set_focus /*= false*/, con
std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Normal)
);
if (btn_id == wxID_OK || btn_id == wxID_YES) {
if (set_focus) {
btn->SetBackgroundColor(btn_bg_green);
btn->SetBorderColor(btn_bd_green);
btn->SetTextColor(btn_text_green);
}
if (btn_id == wxID_CANCEL || btn_id == wxID_NO) {
} else {
btn->SetBackgroundColor(btn_bg_white);
btn->SetBorderColor(btn_bd_white);
btn->SetTextColor(btn_text_white);
@ -213,8 +211,9 @@ Button* MsgDialog::get_button(wxWindowID btn_id){
void MsgDialog::apply_style(long style)
{
if (style & wxOK) add_button(wxID_OK, true, _L("OK"));
if (style & wxYES) add_button(wxID_YES, true, _L("Yes"));
bool focus = (style & wxNO_DEFAULT) == 0;
if (style & wxOK) add_button(wxID_OK, focus, _L("OK"));
if (style & wxYES) add_button(wxID_YES, focus, _L("Yes"));
if (style & wxNO) add_button(wxID_NO, false,_L("No"));
if (style & wxCANCEL) add_button(wxID_CANCEL, false, _L("Cancel"));

View File

@ -1103,13 +1103,13 @@ bool Sidebar::priv::switch_diameter(bool single)
_L("The software does not support using different diameter of nozzles for one print.\n"
"If the left and right nozzles are inconsistent, we can only proceed with single-head printing.\n"
"Please confirm which nozzle you would like to use for this project."),
_L("Switch diameter"), wxNO | wxCANCEL);
dlg.SetButtonLabel(wxID_NO, wxString::Format(_L("Left nozzle: %smm"), diameter_left));
dlg.SetButtonLabel(wxID_CANCEL, wxString::Format(_L("Right nozzle: %smm"), diameter_right));
_L("Switch diameter"), wxYES_NO | wxNO_DEFAULT);
dlg.SetButtonLabel(wxID_YES, wxString::Format(_L("Left nozzle: %smm"), diameter_left));
dlg.SetButtonLabel(wxID_NO, wxString::Format(_L("Right nozzle: %smm"), diameter_right));
int result = dlg.ShowModal();
if (result == wxID_NO)
if (result == wxID_YES)
diameter = diameter_left;
else if (result == wxID_CANCEL)
else if (result == wxID_NO)
diameter = diameter_right;
else
return false;
@ -1660,8 +1660,10 @@ Sidebar::Sidebar(Plater *parent)
auto switch_diameter = [this](wxCommandEvent & evt) {
auto extruder = dynamic_cast<ExtruderGroup *>(dynamic_cast<ComboBox *>(evt.GetEventObject())->GetParent());
p->is_switching_diameter = true;
p->switch_diameter(extruder == p->single_extruder);
auto result = p->switch_diameter(extruder == p->single_extruder);
p->is_switching_diameter = false;
if (!result)
extruder->combo_diameter->SetValue(extruder->diameter);
};
p->left_extruder->combo_diameter->Bind(wxEVT_COMBOBOX, switch_diameter);
p->right_extruder->combo_diameter->Bind(wxEVT_COMBOBOX, switch_diameter);

View File

@ -24,6 +24,7 @@ static std::map<wxColour, wxColour> gDarkColors{
{"#DBFDD5", "#3B3B40"},
{"#000000", "#FFFFFE"},
{"#F4F4F4", "#36363D"},
{"#F7F7F7", "#333337"},
{"#DBDBDB", "#4A4A51"},
{"#EDFAF2", "#283232"},
{"#323A3C", "#E5E5E6"},