FIX: replace ConfirmHintDialog with SecondaryCheckDialog
Change-Id: I3a712f838d7a4d8cbfe725c30f3d77813dd80b92
This commit is contained in:
parent
7e96cbf7da
commit
92b0f591d3
|
@ -23,6 +23,8 @@
|
|||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
wxDEFINE_EVENT(EVT_SECONDARY_CHECK_CONFIRM, wxCommandEvent);
|
||||
|
||||
ReleaseNoteDialog::ReleaseNoteDialog(Plater *plater /*= nullptr*/)
|
||||
: DPIDialog(static_cast<wxWindow *>(wxGetApp().mainframe), wxID_ANY, _L("Release Note"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
|
||||
{
|
||||
|
@ -338,8 +340,8 @@ void UpdateVersionDialog::update_version_info(wxString release_note, wxString ve
|
|||
}
|
||||
}
|
||||
|
||||
SecondaryCheckDialog::SecondaryCheckDialog(wxWindow* parent)
|
||||
:DPIDialog(parent, wxID_ANY, _L("Confirm"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
|
||||
SecondaryCheckDialog::SecondaryCheckDialog(wxWindow* parent, wxWindowID id, const wxString& title, enum ButtonStyle btn_style, const wxPoint& pos, const wxSize& size, long style)
|
||||
:DPIDialog(parent, id, title, pos, size, style)
|
||||
{
|
||||
std::string icon_path = (boost::format("%1%/images/BambuStudioTitle.ico") % resources_dir()).str();
|
||||
SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO));
|
||||
|
@ -380,7 +382,13 @@ SecondaryCheckDialog::SecondaryCheckDialog(wxWindow* parent)
|
|||
m_button_ok->SetCornerRadius(FromDIP(12));
|
||||
|
||||
m_button_ok->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
|
||||
EndModal(wxID_YES);
|
||||
wxCommandEvent evt(EVT_SECONDARY_CHECK_CONFIRM, GetId());
|
||||
e.SetEventObject(this);
|
||||
GetEventHandler()->ProcessEvent(evt);
|
||||
if (this->IsModal())
|
||||
EndModal(wxID_YES);
|
||||
else
|
||||
this->Close();
|
||||
});
|
||||
|
||||
m_button_cancel = new Button(this, _L("Cancel"));
|
||||
|
@ -392,9 +400,17 @@ SecondaryCheckDialog::SecondaryCheckDialog(wxWindow* parent)
|
|||
m_button_cancel->SetCornerRadius(FromDIP(12));
|
||||
|
||||
m_button_cancel->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
|
||||
EndModal(wxID_NO);
|
||||
if (this->IsModal())
|
||||
EndModal(wxID_NO);
|
||||
else
|
||||
this->Close();
|
||||
});
|
||||
|
||||
if (btn_style != CONFIRM_AND_CANCEL)
|
||||
m_button_cancel->Hide();
|
||||
else
|
||||
m_button_cancel->Show();
|
||||
|
||||
sizer_button->AddStretchSpacer();
|
||||
sizer_button->Add(m_button_ok, 0, wxALL, FromDIP(5));
|
||||
sizer_button->Add(m_button_cancel, 0, wxALL, FromDIP(5));
|
||||
|
@ -438,6 +454,10 @@ wxString SecondaryCheckDialog::format_text(wxStaticText* st, wxString str, int w
|
|||
int new_line_pos = 0;
|
||||
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
if (str[i] == '\n') {
|
||||
count_txt = "";
|
||||
continue;
|
||||
}
|
||||
auto text_size = st->GetTextExtent(count_txt);
|
||||
if (text_size.x < warp) {
|
||||
count_txt += str[i];
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
wxDECLARE_EVENT(EVT_SECONDARY_CHECK_CONFIRM, wxCommandEvent);
|
||||
|
||||
class ReleaseNoteDialog : public DPIDialog
|
||||
{
|
||||
public:
|
||||
|
@ -81,7 +83,20 @@ public:
|
|||
class SecondaryCheckDialog : public DPIDialog
|
||||
{
|
||||
public:
|
||||
SecondaryCheckDialog(wxWindow* parent);
|
||||
enum ButtonStyle {
|
||||
ONLY_CONFIRM = 0,
|
||||
CONFIRM_AND_CANCEL = 1,
|
||||
MAX_STYLE_NUM = 2
|
||||
};
|
||||
SecondaryCheckDialog(
|
||||
wxWindow* parent,
|
||||
wxWindowID id = wxID_ANY,
|
||||
const wxString& title = wxEmptyString,
|
||||
enum ButtonStyle btn_style = CONFIRM_AND_CANCEL,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxCLOSE_BOX | wxCAPTION
|
||||
);
|
||||
void update_text(wxString text);
|
||||
wxString format_text(wxStaticText* st, wxString str, int warp);
|
||||
~SecondaryCheckDialog();
|
||||
|
|
|
@ -1805,7 +1805,7 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event)
|
|||
|| has_slice_warnings
|
||||
) {
|
||||
wxString confirm_title = _L("Confirm");
|
||||
SecondaryCheckDialog confirm_dlg(this);
|
||||
SecondaryCheckDialog confirm_dlg(this, wxID_ANY, confirm_title);
|
||||
confirm_dlg.update_text(confirm_text);
|
||||
if (confirm_dlg.ShowModal() == wxID_YES) {
|
||||
this->on_ok();
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "slic3r/Utils/Http.hpp"
|
||||
#include "libslic3r/Thread.hpp"
|
||||
#include "RecenterDialog.hpp"
|
||||
#include "ConfirmHintDialog.hpp"
|
||||
#include "ReleaseNote.hpp"
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
|
@ -1226,13 +1226,12 @@ void StatusPanel::on_subtask_pause_resume(wxCommandEvent &event)
|
|||
|
||||
void StatusPanel::on_subtask_abort(wxCommandEvent &event)
|
||||
{
|
||||
ConfirmHintDialog* abort_dlg = new ConfirmHintDialog(this, wxID_ANY, _L("Cancel print"));
|
||||
abort_dlg->SetHint(_L("Are you sure you want to cancel this print?"));
|
||||
abort_dlg->Bind(EVT_CONFIRM_HINT, [this](wxCommandEvent &e) {
|
||||
SecondaryCheckDialog abort_dlg(this->GetParent(), wxID_ANY, _L("Cancel print"));
|
||||
abort_dlg.update_text(_L("Are you sure you want to cancel this print?"));
|
||||
abort_dlg.Bind(EVT_SECONDARY_CHECK_CONFIRM, [this](wxCommandEvent &e) {
|
||||
if (obj) obj->command_task_abort();
|
||||
});
|
||||
if(abort_dlg->ShowModal())
|
||||
delete abort_dlg;
|
||||
abort_dlg.ShowModal();
|
||||
}
|
||||
|
||||
void StatusPanel::error_info_reset()
|
||||
|
@ -1247,6 +1246,7 @@ void StatusPanel::error_info_reset()
|
|||
void StatusPanel::on_subtask_clean(wxCommandEvent &event)
|
||||
{
|
||||
error_info_reset();
|
||||
before_error_code = obj->print_error;
|
||||
}
|
||||
|
||||
void StatusPanel::on_webrequest_state(wxWebRequestEvent &evt)
|
||||
|
@ -1405,16 +1405,16 @@ void StatusPanel::update_error_message()
|
|||
print_error_str.insert(4, " ");
|
||||
}
|
||||
wxString error_msg = wxString::Format("%s[%s]",
|
||||
wxGetApp().get_hms_query()->query_print_error_msg(obj->print_error),
|
||||
print_error_str);
|
||||
wxGetApp().get_hms_query()->query_print_error_msg(obj->print_error),
|
||||
print_error_str);
|
||||
show_error_message(error_msg);
|
||||
//hint dialog
|
||||
BOOST_LOG_TRIVIAL(info) << "Print error! " << error_msg;
|
||||
ConfirmHintDialog print_error_dlg(this->GetParent(), wxID_ANY, _L("Warning"), ConfirmHintDialog::ButtonStyle::ONLY_CONFIRM);
|
||||
print_error_dlg.SetHint(error_msg);
|
||||
SecondaryCheckDialog print_error_dlg(this->GetParent(), wxID_ANY, _L("Warning"), SecondaryCheckDialog::ButtonStyle::ONLY_CONFIRM);
|
||||
print_error_dlg.update_text(error_msg);
|
||||
print_error_dlg.ShowModal();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StatusPanel::show_printing_status(bool ctrl_area, bool temp_area)
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include "GUI_App.hpp"
|
||||
#include "libslic3r/Thread.hpp"
|
||||
#include "ReleaseNote.hpp"
|
||||
#include "ConfirmHintDialog.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
@ -660,30 +659,30 @@ void MachineInfoPanel::upgrade_firmware_internal() {
|
|||
|
||||
void MachineInfoPanel::on_upgrade_firmware(wxCommandEvent &event)
|
||||
{
|
||||
ConfirmHintDialog confirm_dlg(this->GetParent(), wxID_ANY, _L("Upgrade firmware"));
|
||||
confirm_dlg.SetHint(_L(
|
||||
"Are you sure you want to update? This will take about 10 minutes. Do not turn off the power while the printer is updating."
|
||||
));
|
||||
confirm_dlg.Bind(EVT_CONFIRM_HINT, [this](wxCommandEvent &e) {
|
||||
if (m_obj){
|
||||
SecondaryCheckDialog* confirm_dlg = new SecondaryCheckDialog(this->GetParent(), wxID_ANY, _L("Upgrade firmware"));
|
||||
confirm_dlg->update_text(_L("Are you sure you want to update? This will take about 10 minutes. Do not turn off the power while the printer is updating."));
|
||||
confirm_dlg->Bind(EVT_SECONDARY_CHECK_CONFIRM, [this](wxCommandEvent &e) {
|
||||
if (m_obj) {
|
||||
m_obj->command_upgrade_confirm();
|
||||
}
|
||||
});
|
||||
confirm_dlg.ShowModal();
|
||||
if (confirm_dlg->ShowModal()) {
|
||||
delete confirm_dlg;
|
||||
}
|
||||
}
|
||||
|
||||
void MachineInfoPanel::on_consisitency_upgrade_firmware(wxCommandEvent &event)
|
||||
{
|
||||
ConfirmHintDialog confirm_dlg(this->GetParent(), wxID_ANY, _L("Upgrade firmware"));
|
||||
confirm_dlg.SetHint(_L(
|
||||
"Are you sure you want to update? This will take about 10 minutes. Do not turn off the power while the printer is updating."
|
||||
));
|
||||
confirm_dlg.Bind(EVT_CONFIRM_HINT, [this](wxCommandEvent &e) {
|
||||
if (m_obj){
|
||||
SecondaryCheckDialog* confirm_dlg = new SecondaryCheckDialog(this->GetParent(), wxID_ANY, _L("Upgrade firmware"));
|
||||
confirm_dlg->update_text(_L("Are you sure you want to update? This will take about 10 minutes. Do not turn off the power while the printer is updating."));
|
||||
confirm_dlg->Bind(EVT_SECONDARY_CHECK_CONFIRM, [this](wxCommandEvent &e) {
|
||||
if (m_obj) {
|
||||
m_obj->command_consistency_upgrade_confirm();
|
||||
}
|
||||
});
|
||||
confirm_dlg.ShowModal();
|
||||
if (confirm_dlg->ShowModal()) {
|
||||
delete confirm_dlg;
|
||||
}
|
||||
}
|
||||
|
||||
void MachineInfoPanel::on_show_release_note(wxMouseEvent &event)
|
||||
|
@ -798,16 +797,14 @@ void UpgradePanel::update(MachineObject *obj)
|
|||
if (m_obj && m_show_forced_hint) {
|
||||
if (m_obj->upgrade_force_upgrade) {
|
||||
m_show_forced_hint = false; //lock hint
|
||||
ConfirmHintDialog force_dlg(m_scrolledWindow, wxID_ANY, _L("Upgrade firmware"), ConfirmHintDialog::CONFIRM_AND_CANCEL, wxDefaultPosition, wxDefaultSize, wxPD_APP_MODAL);
|
||||
force_dlg.SetHint(_L(
|
||||
SecondaryCheckDialog* force_dlg = new SecondaryCheckDialog(m_scrolledWindow, wxID_ANY, _L("Upgrade firmware"));
|
||||
force_dlg->update_text(_L(
|
||||
"An important update was detected and needs to be run before printing can continue. Do you want to update now? You can also update later from 'Upgrade firmware'."
|
||||
));
|
||||
force_dlg.Bind(EVT_CONFIRM_HINT, [this](wxCommandEvent& e) {
|
||||
if (m_obj) {
|
||||
m_obj->command_upgrade_confirm();
|
||||
}
|
||||
});
|
||||
force_dlg.ShowModal();
|
||||
force_dlg->Bind(EVT_SECONDARY_CHECK_CONFIRM, &MachineInfoPanel::on_upgrade_firmware, m_push_upgrade_panel);
|
||||
if (force_dlg->ShowModal()) {
|
||||
delete force_dlg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -819,16 +816,14 @@ void UpgradePanel::update(MachineObject *obj)
|
|||
if (m_obj && m_show_consistency_hint) {
|
||||
if (m_obj->upgrade_consistency_request) {
|
||||
m_show_consistency_hint = false;
|
||||
ConfirmHintDialog consistency_dlg(m_scrolledWindow, wxID_ANY, _L("Upgrade firmware"), ConfirmHintDialog::CONFIRM_AND_CANCEL, wxDefaultPosition, wxDefaultSize, wxPD_APP_MODAL);
|
||||
consistency_dlg.SetHint(_L(
|
||||
SecondaryCheckDialog* consistency_dlg = new SecondaryCheckDialog(m_scrolledWindow, wxID_ANY, _L("Upgrade firmware"));
|
||||
consistency_dlg->update_text(_L(
|
||||
"The firmware version is abnormal. Repairing and updating are required before printing. Do you want to update now? You can also update later on printer or update next time starting the studio."
|
||||
));
|
||||
consistency_dlg.Bind(EVT_CONFIRM_HINT, [this](wxCommandEvent& e) {
|
||||
if (m_obj) {
|
||||
m_obj->command_consistency_upgrade_confirm();
|
||||
}
|
||||
});
|
||||
consistency_dlg.ShowModal();
|
||||
consistency_dlg->Bind(EVT_SECONDARY_CHECK_CONFIRM, &MachineInfoPanel::on_consisitency_upgrade_firmware, m_push_upgrade_panel);
|
||||
if (consistency_dlg->ShowModal()) {
|
||||
delete consistency_dlg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue