mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	ENH: refine confirm dialog when sending a print job
Change-Id: Id65afa8c5181a4b31e60a0b298bc945fbb77ade0 Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
		
							parent
							
								
									b829419c54
								
							
						
					
					
						commit
						6635e57c36
					
				
					 3 changed files with 146 additions and 8 deletions
				
			
		|  | @ -334,6 +334,128 @@ void UpdateVersionDialog::update_version_info(wxString release_note, wxString ve | |||
|         m_scrollwindows_release_note->SetSizer(sizer_text_release_note); | ||||
|         m_scrollwindows_release_note->Layout(); | ||||
|     }   | ||||
| } | ||||
| 
 | ||||
| SecondaryCheckDialog::SecondaryCheckDialog(wxWindow* parent) | ||||
|     :DPIDialog(parent, wxID_ANY, _L("Confirm"), 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(FromDIP(480), 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(5)); | ||||
| 
 | ||||
|     wxBoxSizer* m_sizer_right = new wxBoxSizer(wxVERTICAL); | ||||
| 
 | ||||
|     m_sizer_right->Add(0, 0, 1, wxTOP, FromDIP(15)); | ||||
| 
 | ||||
|     m_vebview_release_note = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL); | ||||
|     m_vebview_release_note->SetScrollRate(0, 5); | ||||
|     m_vebview_release_note->SetBackgroundColour(wxColour(0xF8, 0xF8, 0xF8)); | ||||
|     m_vebview_release_note->SetSize(wxSize(FromDIP(280), FromDIP(280))); | ||||
|     m_vebview_release_note->SetMinSize(wxSize(FromDIP(280), FromDIP(280))); | ||||
|     m_vebview_release_note->SetMaxSize(wxSize(FromDIP(280), FromDIP(280))); | ||||
| 
 | ||||
| 
 | ||||
|     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)); | ||||
| 
 | ||||
|     m_button_ok = new Button(this, _L("OK")); | ||||
|     m_button_ok->SetBackgroundColor(btn_bg_green); | ||||
|     m_button_ok->SetBorderColor(*wxWHITE); | ||||
|     m_button_ok->SetTextColor(*wxWHITE); | ||||
|     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_YES); | ||||
|         }); | ||||
| 
 | ||||
|     m_button_cancel = new Button(this, _L("Cancel")); | ||||
|     m_button_cancel->SetBackgroundColor(*wxWHITE); | ||||
|     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_vebview_release_note, 0, wxEXPAND | wxRIGHT | wxLEFT, FromDIP(20)); | ||||
|     m_sizer_right->Add(sizer_button, 0, wxEXPAND | wxRIGHT | wxLEFT, FromDIP(20)); | ||||
| 
 | ||||
| 
 | ||||
|     SetSizer(m_sizer_right); | ||||
|     Layout(); | ||||
|     m_sizer_main->Fit(this); | ||||
| 
 | ||||
|     CenterOnParent(); | ||||
| } | ||||
| 
 | ||||
| void SecondaryCheckDialog::update_text(wxString text) | ||||
| { | ||||
|     wxBoxSizer* sizer_text_release_note = new wxBoxSizer(wxVERTICAL); | ||||
|     auto        m_staticText_release_note = new wxStaticText(m_vebview_release_note, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0); | ||||
|     m_staticText_release_note->SetSize(wxSize(FromDIP(260), -1)); | ||||
|     m_staticText_release_note->SetMaxSize(wxSize(FromDIP(260), -1)); | ||||
|     m_staticText_release_note->SetMinSize(wxSize(FromDIP(260), -1)); | ||||
| 
 | ||||
|     text = format_text(m_staticText_release_note, text, FromDIP(240)); | ||||
| 
 | ||||
|     m_staticText_release_note->SetLabelText(text); | ||||
|     m_staticText_release_note->Wrap(FromDIP(240)); | ||||
|     sizer_text_release_note->Add(m_staticText_release_note, 0, wxALIGN_CENTER, 5); | ||||
|     m_vebview_release_note->SetSizer(sizer_text_release_note); | ||||
|     m_vebview_release_note->Layout(); | ||||
|     //Fit();
 | ||||
| } | ||||
| 
 | ||||
| wxString SecondaryCheckDialog::format_text(wxStaticText* st, wxString str, int warp) | ||||
| { | ||||
|     if (wxGetApp().app_config->get("language") != "zh_CN") { return str; } | ||||
| 
 | ||||
|     wxString out_txt = str; | ||||
|     wxString count_txt = ""; | ||||
|     int      new_line_pos = 0; | ||||
| 
 | ||||
|     for (int i = 0; i < str.length(); i++) { | ||||
|         auto text_size = st->GetTextExtent(count_txt); | ||||
|         if (text_size.x < warp) { | ||||
|             count_txt += str[i]; | ||||
|         } | ||||
|         else { | ||||
|             out_txt.insert(i - 1, '\n'); | ||||
|             count_txt = ""; | ||||
|         } | ||||
|     } | ||||
|     return out_txt; | ||||
| } | ||||
| 
 | ||||
| SecondaryCheckDialog::~SecondaryCheckDialog() | ||||
| { | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| void SecondaryCheckDialog::on_dpi_changed(const wxRect& suggested_rect) | ||||
| { | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
|  }} // namespace Slic3r::GUI
 | ||||
|  |  | |||
|  | @ -78,6 +78,20 @@ public: | |||
|     Button*           m_button_cancel; | ||||
| }; | ||||
| 
 | ||||
| class SecondaryCheckDialog : public DPIDialog | ||||
| { | ||||
| public: | ||||
|     SecondaryCheckDialog(wxWindow* parent); | ||||
|     void update_text(wxString text); | ||||
|     wxString format_text(wxStaticText* st, wxString str, int warp); | ||||
|     ~SecondaryCheckDialog(); | ||||
|     void on_dpi_changed(const wxRect& suggested_rect) override; | ||||
| 
 | ||||
|     wxScrolledWindow *m_vebview_release_note {nullptr}; | ||||
|     Button* m_button_ok; | ||||
|     Button* m_button_cancel; | ||||
| }; | ||||
| 
 | ||||
| }} // namespace Slic3r::GUI
 | ||||
| 
 | ||||
| #endif | ||||
|  |  | |||
|  | @ -22,6 +22,7 @@ | |||
| #include "BitmapCache.hpp" | ||||
| #include "BindDialog.hpp" | ||||
| #include "ConfirmHintDialog.hpp" | ||||
| #include "ReleaseNote.hpp" | ||||
| 
 | ||||
| namespace Slic3r { namespace GUI { | ||||
| 
 | ||||
|  | @ -39,7 +40,7 @@ wxDEFINE_EVENT(EVT_EDIT_PRINT_NAME, wxCommandEvent); | |||
| #define LIST_REFRESH_INTERVAL 200 | ||||
| #define MACHINE_LIST_REFRESH_INTERVAL 2000 | ||||
| 
 | ||||
| #define WRAP_GAP FromDIP(30) | ||||
| #define WRAP_GAP FromDIP(10) | ||||
| 
 | ||||
| static wxString task_canceled_text = _L("Task canceled"); | ||||
| 
 | ||||
|  | @ -1228,10 +1229,12 @@ wxWindow *SelectMachineDialog::create_item_checkbox(wxString title, wxWindow *pa | |||
|     sizer_checkbox->Add(sizer_check, 0, wxEXPAND, FromDIP(5)); | ||||
|     sizer_checkbox->Add(0, 0, 0, wxEXPAND | wxLEFT, FromDIP(11)); | ||||
| 
 | ||||
|     auto text = new wxStaticText(checkbox, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, 0); | ||||
|     auto text = new wxStaticText(checkbox, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END); | ||||
|     text->SetFont(::Label::Body_13); | ||||
|     text->SetForegroundColour(wxColour(107, 107, 107)); | ||||
|     text->Wrap(-1); | ||||
|     text->SetMinSize(wxSize(FromDIP(120), -1)); | ||||
|     text->SetMaxSize(wxSize(FromDIP(120), -1)); | ||||
|     sizer_checkbox->Add(text, 0, wxBOTTOM | wxEXPAND | wxTOP, FromDIP(5)); | ||||
| 
 | ||||
|     checkbox->SetSizer(sizer_checkbox); | ||||
|  | @ -1795,12 +1798,11 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event) | |||
|         || has_slice_warnings | ||||
|         ) { | ||||
|         wxString confirm_title = _L("Confirm"); | ||||
|         ConfirmHintDialog confirm_dlg(this, wxID_ANY, confirm_title); | ||||
|         confirm_dlg.SetHint(confirm_text); | ||||
|         confirm_dlg.Bind(EVT_CONFIRM_HINT, [this](wxCommandEvent& e) { | ||||
|         SecondaryCheckDialog confirm_dlg(this); | ||||
|         confirm_dlg.update_text(confirm_text); | ||||
|         if (confirm_dlg.ShowModal() == wxID_YES) { | ||||
|             this->on_ok(); | ||||
|         }); | ||||
|         confirm_dlg.ShowModal(); | ||||
|         } | ||||
|     } else { | ||||
|         this->on_ok(); | ||||
|     } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Stone Li
						Stone Li