FIX: optimize the GUI dialog

jira: [STUDIO-9580]
Change-Id: I01bb5b116f472d2b5de51cdff4f074aca2f3447c
This commit is contained in:
xin.zhang 2025-01-09 10:54:04 +08:00 committed by lane.wei
parent b9056ee3ff
commit 98f076c049
4 changed files with 82 additions and 42 deletions

View File

@ -1316,30 +1316,31 @@ void ConfirmBeforeSendDialog::update_text(wxString text)
Fit();
}
void ConfirmBeforeSendDialog::update_text(std::vector<ConfirmBeforeSendInfo> texts)
void ConfirmBeforeSendDialog::update_text(std::vector<ConfirmBeforeSendInfo> texts, bool enable_warning_clr /*= true*/)
{
wxBoxSizer* sizer_text_release_note = new wxBoxSizer(wxVERTICAL);
m_vebview_release_note->SetSizer(sizer_text_release_note);
auto height = 0;
for (auto text : texts) {
auto label_item = new Label(m_vebview_release_note, text.text, LB_AUTO_WRAP);
if (text.level == ConfirmBeforeSendInfo::InfoLevel::Warning) {
if (enable_warning_clr && text.level == ConfirmBeforeSendInfo::InfoLevel::Warning) {
label_item->SetForegroundColour(wxColour(0xFF, 0x6F, 0x00));
}
label_item->SetMaxSize(wxSize(FromDIP(380), -1));
label_item->SetMinSize(wxSize(FromDIP(380), -1));
label_item->Wrap(FromDIP(380));
label_item->SetMaxSize(wxSize(FromDIP(500), -1));
label_item->SetMinSize(wxSize(FromDIP(500), -1));
label_item->Wrap(FromDIP(500));
label_item->Layout();
sizer_text_release_note->Add(label_item, 0, wxALIGN_CENTER | wxALL, FromDIP(3));
height += label_item->GetSize().y;
}
m_vebview_release_note->Layout();
if (height < FromDIP(380))
m_vebview_release_note->SetMinSize(wxSize(FromDIP(400), height + FromDIP(25)));
if (height < FromDIP(500))
m_vebview_release_note->SetMinSize(wxSize(FromDIP(500), height + FromDIP(25)));
else {
m_vebview_release_note->SetMinSize(wxSize(FromDIP(400), FromDIP(380)));
m_vebview_release_note->SetMinSize(wxSize(FromDIP(500), FromDIP(500)));
}
Layout();
@ -1412,9 +1413,19 @@ void ConfirmBeforeSendDialog::hide_button_ok()
m_button_ok->Hide();
}
void ConfirmBeforeSendDialog::edit_cancel_button_txt(wxString txt)
void ConfirmBeforeSendDialog::edit_cancel_button_txt(const wxString& txt, bool switch_green)
{
m_button_cancel->SetLabel(txt);
if (switch_green)
{
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));
m_button_cancel->SetBackgroundColor(btn_bg_green);
m_button_cancel->SetBorderColor(*wxWHITE);
m_button_cancel->SetTextColor(wxColour("#FFFFFE"));
}
}
void ConfirmBeforeSendDialog::disable_button_ok()

View File

@ -245,7 +245,7 @@ public:
bool not_show_again_check = false
);
void update_text(wxString text);
void update_text(std::vector<ConfirmBeforeSendInfo> texts);
void update_text(std::vector<ConfirmBeforeSendInfo> texts, bool enable_warning_clr = true);
void on_show();
void on_hide();
void update_btn_label(wxString ok_btn_text, wxString cancel_btn_text);
@ -253,13 +253,14 @@ public:
void on_dpi_changed(const wxRect& suggested_rect);
void show_update_nozzle_button(bool show = false);
void hide_button_ok();
void edit_cancel_button_txt(wxString txt);
void edit_cancel_button_txt(const wxString& txt, bool switch_green = false);
void disable_button_ok();
void enable_button_ok();
wxString format_text(wxString str, int warp);
~ConfirmBeforeSendDialog();
protected:
wxBoxSizer* m_sizer_main;
wxScrolledWindow* m_vebview_release_note{ nullptr };
Label* m_staticText_release_note{ nullptr };

View File

@ -2093,7 +2093,6 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event)
std::vector<ConfirmBeforeSendInfo> confirm_text;
confirm_text.push_back(ConfirmBeforeSendInfo(_L("Please check the following:")));
//Check Printer Model Id
bool is_same_printer_type = is_same_printer_model();
@ -2260,42 +2259,71 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event)
}
}
if (has_slice_warnings) {
wxString confirm_title = _L("Warning");
ConfirmBeforeSendDialog confirm_dlg(this, wxID_ANY, confirm_title);
if(is_printing_block){
if (has_slice_warnings)
{
ConfirmBeforeSendDialog confirm_dlg(this, wxID_ANY, _L("Warning"));
if (is_printing_block)
{
confirm_dlg.hide_button_ok();
confirm_dlg.edit_cancel_button_txt(_L("Close"));
confirm_text.push_back(ConfirmBeforeSendInfo(_L("Please fix the error above, otherwise printing cannot continue."), ConfirmBeforeSendInfo::InfoLevel::Warning));
}
else {
confirm_text.push_back(ConfirmBeforeSendInfo(_L("Please click the confirm button if you still want to proceed with printing.")));
confirm_dlg.edit_cancel_button_txt(_L("Close"), true);
}
confirm_dlg.Bind(EVT_SECONDARY_CHECK_CONFIRM, [this, &confirm_dlg](wxCommandEvent& e)
{
confirm_dlg.on_hide();
this->on_send_print();
});
confirm_dlg.Bind(EVT_SECONDARY_CHECK_CONFIRM, [this, &confirm_dlg](wxCommandEvent& e) {
confirm_dlg.on_hide();
this->on_send_print();
});
wxString info_msg = wxEmptyString;
for (auto i = 0; i < confirm_text.size(); i++) {
if (i == 0) {
//info_msg += confirm_text[i];
}
else if (i == confirm_text.size() - 1) {
//info_msg += confirm_text[i];
}
else {
confirm_text[i].text = wxString::Format("%d. %s",i, confirm_text[i].text);
// STUDIO-9580
/* use warning color if there are warning and normal messages* /
/* use indexes if there are several messages*/
/* add header and ending if there are several messages or has none block warnings*/
if (confirm_text.size() > 1 || !is_printing_block)
{
bool has_warning_msg = false;
bool has_normal_msg = false;
if (confirm_text.size() > 1)
{
for (auto i = 0; i < confirm_text.size(); i++)
{
confirm_text[i].text = wxString::Format("%d. %s", i + 1, confirm_text[i].text);
if (confirm_text[i].level == ConfirmBeforeSendInfo::InfoLevel::Warning)
{
has_warning_msg = true;
}
else
{
has_normal_msg = true;
}
}
}
std::vector<ConfirmBeforeSendInfo> shown_infos;
shown_infos.emplace_back(ConfirmBeforeSendInfo(_L("Please check the following:")));
for (const auto& item : confirm_text)
{
shown_infos.emplace_back(item);
}
if (is_printing_block)
{
shown_infos.emplace_back(ConfirmBeforeSendInfo(_L("Please fix the error above, otherwise printing cannot continue."), ConfirmBeforeSendInfo::InfoLevel::Warning));
}
else
{
shown_infos.emplace_back(ConfirmBeforeSendInfo(_L("Please click the confirm button if you still want to proceed with printing.")));
}
confirm_dlg.update_text(shown_infos, has_warning_msg&& has_normal_msg);
}
confirm_dlg.update_text(confirm_text);
else
{
confirm_dlg.update_text(confirm_text, false);
}
confirm_dlg.on_show();
} else {
}
else
{
this->on_send_print();
}
}

View File

@ -2380,7 +2380,7 @@ void SyncAmsInfoDialog::on_ok_btn(wxCommandEvent &event)
if (is_printing_block) {
confirm_dlg.hide_button_ok();
confirm_dlg.edit_cancel_button_txt(_L("Close"));
confirm_dlg.edit_cancel_button_txt(_L("Close"), true);
confirm_text.push_back(ConfirmBeforeSendInfo(_L("Please fix the error above, otherwise printing cannot continue."), ConfirmBeforeSendInfo::InfoLevel::Warning));
} else {
confirm_text.push_back(ConfirmBeforeSendInfo(_L("Please click the confirm button if you still want to proceed with printing.")));