mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 12:11:15 -06:00 
			
		
		
		
	ENH: add confirm dialog for cancel-print button
Change-Id: I0a97c7a3122b1b5dd0b306212292e8c51b9acd9b
This commit is contained in:
		
							parent
							
								
									1b4486cc5d
								
							
						
					
					
						commit
						8386b48554
					
				
					 5 changed files with 40 additions and 33 deletions
				
			
		|  | @ -1,4 +1,4 @@ | |||
| #include "FirmwareUpdateDialog.hpp" | ||||
| #include "ConfirmHintDialog.hpp" | ||||
| #include <slic3r/GUI/I18N.hpp> | ||||
| #include <wx/dcgraph.h> | ||||
| #include <wx/dcmemory.h> | ||||
|  | @ -7,10 +7,10 @@ | |||
| 
 | ||||
| namespace Slic3r { namespace GUI { | ||||
| 
 | ||||
| wxDEFINE_EVENT(EVT_UPGRADE_FIRMWARE, wxCommandEvent); | ||||
| wxDEFINE_EVENT(EVT_CONFIRM_HINT, wxCommandEvent); | ||||
| 
 | ||||
| FirmwareUpdateDialog::FirmwareUpdateDialog(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) | ||||
|       : DPIDialog(parent, id, _L("Upgrade firmware"), pos, size, style) | ||||
| ConfirmHintDialog::ConfirmHintDialog(wxWindow* parent, wxWindowID id, const wxString& title, 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)); | ||||
|  | @ -58,23 +58,23 @@ FirmwareUpdateDialog::FirmwareUpdateDialog(wxWindow* parent, wxWindowID id, cons | |||
|     this->SetMinSize(wxSize(wxSize(FromDIP(475), FromDIP(100)).x, -1)); | ||||
|     Layout(); | ||||
|     Fit(); | ||||
|     this->Bind(wxEVT_PAINT, &FirmwareUpdateDialog::OnPaint, this); | ||||
|     m_button_confirm->Bind(wxEVT_BUTTON, &FirmwareUpdateDialog::on_button_confirm, this); | ||||
|     m_button_close->Bind(wxEVT_BUTTON, &FirmwareUpdateDialog::on_button_close, this); | ||||
|     this->Bind(wxEVT_PAINT, &ConfirmHintDialog::OnPaint, this); | ||||
|     m_button_confirm->Bind(wxEVT_BUTTON, &ConfirmHintDialog::on_button_confirm, this); | ||||
|     m_button_close->Bind(wxEVT_BUTTON, &ConfirmHintDialog::on_button_close, this); | ||||
| } | ||||
| 
 | ||||
| FirmwareUpdateDialog::~FirmwareUpdateDialog() {} | ||||
| ConfirmHintDialog::~ConfirmHintDialog() {} | ||||
| 
 | ||||
| void FirmwareUpdateDialog::SetHint(const wxString& hint){ | ||||
| void ConfirmHintDialog::SetHint(const wxString& hint){ | ||||
|     firm_up_hint = hint; | ||||
| } | ||||
| 
 | ||||
| void FirmwareUpdateDialog::OnPaint(wxPaintEvent& event){ | ||||
| void ConfirmHintDialog::OnPaint(wxPaintEvent& event){ | ||||
|     wxPaintDC dc(this); | ||||
|     render(dc); | ||||
| } | ||||
| 
 | ||||
| void FirmwareUpdateDialog::render(wxDC& dc) { | ||||
| void ConfirmHintDialog::render(wxDC& dc) { | ||||
|     wxSize     size = GetSize(); | ||||
| 
 | ||||
|     dc.SetFont(Label::Body_14); | ||||
|  | @ -147,8 +147,8 @@ void FirmwareUpdateDialog::render(wxDC& dc) { | |||
|         dc.DrawText(firm_up_hint, pos_firm_up_hint); | ||||
| } | ||||
| 
 | ||||
| void FirmwareUpdateDialog::on_button_confirm(wxCommandEvent& event) { | ||||
|     wxCommandEvent evt(EVT_UPGRADE_FIRMWARE, GetId()); | ||||
| void ConfirmHintDialog::on_button_confirm(wxCommandEvent& event) { | ||||
|     wxCommandEvent evt(EVT_CONFIRM_HINT, GetId()); | ||||
|     event.SetEventObject(this); | ||||
|     GetEventHandler()->ProcessEvent(evt); | ||||
| 
 | ||||
|  | @ -158,11 +158,11 @@ void FirmwareUpdateDialog::on_button_confirm(wxCommandEvent& event) { | |||
|         this->Close(); | ||||
| } | ||||
| 
 | ||||
| void FirmwareUpdateDialog::on_button_close(wxCommandEvent& event) { | ||||
| void ConfirmHintDialog::on_button_close(wxCommandEvent& event) { | ||||
|     this->Close(); | ||||
| } | ||||
| 
 | ||||
| void FirmwareUpdateDialog::on_dpi_changed(const wxRect& suggested_rect) { | ||||
| void ConfirmHintDialog::on_dpi_changed(const wxRect& suggested_rect) { | ||||
|     m_button_confirm->SetMinSize(wxSize(-1, FromDIP(24))); | ||||
|     m_button_confirm->SetCornerRadius(FromDIP(12)); | ||||
|     m_button_close->SetMinSize(wxSize(-1, FromDIP(24))); | ||||
|  | @ -1,5 +1,5 @@ | |||
| #ifndef slic3r_GUI_FirmwareUpdateDialog_hpp_ | ||||
| #define slic3r_GUI_FirmwareUpdateDialog_hpp_ | ||||
| #ifndef slic3r_GUI_ConfirmHintDialog_hpp_ | ||||
| #define slic3r_GUI_ConfirmHintDialog_hpp_ | ||||
| 
 | ||||
| #include "GUI_Utils.hpp" | ||||
| #include <wx/statbmp.h> | ||||
|  | @ -8,9 +8,9 @@ | |||
| 
 | ||||
| namespace Slic3r { namespace GUI { | ||||
| 
 | ||||
| wxDECLARE_EVENT(EVT_UPGRADE_FIRMWARE, wxCommandEvent); | ||||
| wxDECLARE_EVENT(EVT_CONFIRM_HINT, wxCommandEvent); | ||||
| 
 | ||||
| class FirmwareUpdateDialog : public DPIDialog | ||||
| class ConfirmHintDialog : public DPIDialog | ||||
| { | ||||
| private: | ||||
|     wxStaticText* m_staticText_hint; | ||||
|  | @ -27,7 +27,7 @@ private: | |||
|     void on_dpi_changed(const wxRect& suggested_rect) override; | ||||
| 
 | ||||
| public: | ||||
|     FirmwareUpdateDialog(wxWindow* parent, | ||||
|     ConfirmHintDialog(wxWindow* parent, | ||||
|         wxWindowID      id = wxID_ANY, | ||||
|         const wxString& title = wxEmptyString, | ||||
|         const wxPoint& pos = wxDefaultPosition, | ||||
|  | @ -38,7 +38,7 @@ public: | |||
| 
 | ||||
|     void SetHint(const wxString &hint); | ||||
| 
 | ||||
|     ~FirmwareUpdateDialog(); | ||||
|     ~ConfirmHintDialog(); | ||||
| }; | ||||
| }} // namespace Slic3r::GUI
 | ||||
| 
 | ||||
|  | @ -10,6 +10,7 @@ | |||
| #include "slic3r/Utils/Http.hpp" | ||||
| #include "libslic3r/Thread.hpp" | ||||
| #include "RecenterDialog.hpp" | ||||
| #include "ConfirmHintDialog.hpp" | ||||
| 
 | ||||
| namespace Slic3r { namespace GUI { | ||||
| 
 | ||||
|  | @ -1222,7 +1223,13 @@ void StatusPanel::on_subtask_pause_resume(wxCommandEvent &event) | |||
| 
 | ||||
| void StatusPanel::on_subtask_abort(wxCommandEvent &event) | ||||
| { | ||||
|     if (obj) obj->command_task_abort(); | ||||
|     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) { | ||||
|         if (obj) obj->command_task_abort(); | ||||
|     }); | ||||
|     if(abort_dlg->ShowModal()) | ||||
|        delete abort_dlg; | ||||
| } | ||||
| 
 | ||||
| void StatusPanel::error_info_reset() | ||||
|  |  | |||
|  | @ -5,7 +5,7 @@ | |||
| #include "GUI_App.hpp" | ||||
| #include "libslic3r/Thread.hpp" | ||||
| #include "ReleaseNote.hpp" | ||||
| #include "FirmwareUpdateDialog.hpp" | ||||
| #include "ConfirmHintDialog.hpp" | ||||
| 
 | ||||
| namespace Slic3r { | ||||
| namespace GUI { | ||||
|  | @ -657,9 +657,9 @@ void MachineInfoPanel::upgrade_firmware_internal() { | |||
| 
 | ||||
| void MachineInfoPanel::on_upgrade_firmware(wxCommandEvent &event) | ||||
| { | ||||
|     FirmwareUpdateDialog* confirm_dlg = new FirmwareUpdateDialog(this->GetParent()); | ||||
|     ConfirmHintDialog* confirm_dlg = new ConfirmHintDialog(this->GetParent(), wxID_ANY, _L("Upgrade firmware")); | ||||
|     confirm_dlg->SetHint(normal_upgrade_hint); | ||||
|     confirm_dlg->Bind(EVT_UPGRADE_FIRMWARE, [this](wxCommandEvent &e) { | ||||
|     confirm_dlg->Bind(EVT_CONFIRM_HINT, [this](wxCommandEvent &e) { | ||||
|         if (m_obj){ | ||||
|             m_obj->command_upgrade_confirm(); | ||||
|         } | ||||
|  | @ -670,9 +670,9 @@ void MachineInfoPanel::on_upgrade_firmware(wxCommandEvent &event) | |||
| 
 | ||||
| void MachineInfoPanel::on_consisitency_upgrade_firmware(wxCommandEvent &event) | ||||
| { | ||||
|     FirmwareUpdateDialog* confirm_dlg = new FirmwareUpdateDialog(this->GetParent()); | ||||
|     ConfirmHintDialog* confirm_dlg = new ConfirmHintDialog(this->GetParent(), wxID_ANY, _L("Upgrade firmware")); | ||||
|     confirm_dlg->SetHint(normal_upgrade_hint); | ||||
|     confirm_dlg->Bind(EVT_UPGRADE_FIRMWARE, [this](wxCommandEvent &e) { | ||||
|     confirm_dlg->Bind(EVT_CONFIRM_HINT, [this](wxCommandEvent &e) { | ||||
|         if (m_obj){ | ||||
|             m_obj->command_consistency_upgrade_confirm(); | ||||
|         } | ||||
|  | @ -793,9 +793,9 @@ 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
 | ||||
|             FirmwareUpdateDialog* force_dlg = new FirmwareUpdateDialog(m_scrolledWindow); | ||||
|             ConfirmHintDialog* force_dlg = new ConfirmHintDialog(m_scrolledWindow, wxID_ANY, _L("Upgrade firmware")); | ||||
|             force_dlg->SetHint(force_upgrade_hint); | ||||
|             force_dlg->Bind(EVT_UPGRADE_FIRMWARE, &MachineInfoPanel::on_upgrade_firmware, m_push_upgrade_panel); | ||||
|             force_dlg->Bind(EVT_CONFIRM_HINT, &MachineInfoPanel::on_upgrade_firmware, m_push_upgrade_panel); | ||||
|             if (force_dlg->ShowModal()) | ||||
|                 delete force_dlg; | ||||
|         } | ||||
|  | @ -809,9 +809,9 @@ void UpgradePanel::update(MachineObject *obj) | |||
|     if (m_obj && m_show_consistency_hint) { | ||||
|         if (m_obj->upgrade_consistency_request) { | ||||
|             m_show_consistency_hint = false; | ||||
| 		    FirmwareUpdateDialog* consistency_dlg = new FirmwareUpdateDialog(m_scrolledWindow); | ||||
| 		    ConfirmHintDialog* consistency_dlg = new ConfirmHintDialog(m_scrolledWindow, wxID_ANY, _L("Upgrade firmware")); | ||||
|             consistency_dlg->SetHint(consistency_upgrade_hint); | ||||
|             consistency_dlg->Bind(EVT_UPGRADE_FIRMWARE, &MachineInfoPanel::on_consisitency_upgrade_firmware, m_push_upgrade_panel); | ||||
|             consistency_dlg->Bind(EVT_CONFIRM_HINT, &MachineInfoPanel::on_consisitency_upgrade_firmware, m_push_upgrade_panel); | ||||
|             if (consistency_dlg->ShowModal()) | ||||
|                 delete consistency_dlg; | ||||
| 	    } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 tao.jin
						tao.jin