mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-16 18:12:10 +00:00
ENH: add a prompt dialog box to prompt
for synchronization of machine information when opening a file jira:none Change-Id: I7b3419bb3489a5b6a37a99b5021c7e69ac35a009 (cherry picked from commit 6437437fe0c83f7c14f7ee5b339475d6db559a56)
This commit is contained in:
@@ -23,7 +23,7 @@ namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
|
||||
TipsDialog::TipsDialog(wxWindow *parent, const wxString &title, const wxString &description, std::string app_key)
|
||||
TipsDialog::TipsDialog(wxWindow *parent, const wxString &title, const wxString &description, std::string app_key, long style)
|
||||
: DPIDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX),
|
||||
m_app_key(app_key)
|
||||
{
|
||||
@@ -58,18 +58,22 @@ TipsDialog::TipsDialog(wxWindow *parent, const wxString &title, const wxString &
|
||||
|
||||
wxBoxSizer *m_sizer_right = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
m_confirm = new Button(this, _L("OK"));
|
||||
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(0, 137, 123), StateColor::Pressed), std::pair<wxColour, int>(wxColour(38, 166, 154), StateColor::Hovered),
|
||||
std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal));
|
||||
|
||||
m_confirm->SetBackgroundColor(btn_bg_green);
|
||||
m_confirm->SetBorderColor(wxColour(0, 150, 136));
|
||||
m_confirm->SetTextColor(wxColour(255, 255, 255));
|
||||
m_confirm->SetSize(TIPS_DIALOG_BUTTON_SIZE);
|
||||
m_confirm->SetMinSize(TIPS_DIALOG_BUTTON_SIZE);
|
||||
m_confirm->SetCornerRadius(FromDIP(12));
|
||||
m_confirm->Bind(wxEVT_LEFT_DOWN, &TipsDialog::on_ok, this);
|
||||
m_sizer_right->Add(m_confirm, 0, wxALL, FromDIP(5));
|
||||
if (style & wxOK) {
|
||||
Button* btn = add_button(wxID_OK, _L("OK"), true);
|
||||
m_sizer_right->Add(btn, 0, wxALL, FromDIP(5));
|
||||
}
|
||||
if (style & wxYES) {
|
||||
Button *btn = add_button(wxID_YES, _L("Yes"), true);
|
||||
m_sizer_right->Add(btn, 0, wxALL, FromDIP(5));
|
||||
}
|
||||
if (style & wxNO) {
|
||||
Button *btn = add_button(wxID_NO, _L("No"), false);
|
||||
m_sizer_right->Add(btn, 0, wxALL, FromDIP(5));
|
||||
}
|
||||
if (style & wxCANCEL) {
|
||||
Button *btn = add_button(wxID_CANCEL, _L("Cancel"), false);
|
||||
m_sizer_right->Add(btn, 0, wxALL, FromDIP(5));
|
||||
}
|
||||
|
||||
m_sizer_bottom->Add(m_sizer_right, 0, wxEXPAND, FromDIP(5));
|
||||
m_sizer_main->Add(m_sizer_bottom, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(40));
|
||||
@@ -99,7 +103,7 @@ wxBoxSizer *TipsDialog::create_item_checkbox(wxString title, wxWindow *parent, w
|
||||
checkbox_title->Wrap(-1);
|
||||
m_sizer_checkbox->Add(checkbox_title, 0, wxALIGN_CENTER | wxALL, 3);
|
||||
|
||||
m_show_again = wxGetApp().app_config->get(param) == "true" ? true : false;
|
||||
m_show_again = wxGetApp().app_config->has(param);
|
||||
checkbox->SetValue(m_show_again);
|
||||
|
||||
checkbox->Bind(wxEVT_TOGGLEBUTTON, [this, checkbox, param](wxCommandEvent &e) {
|
||||
@@ -110,6 +114,62 @@ wxBoxSizer *TipsDialog::create_item_checkbox(wxString title, wxWindow *parent, w
|
||||
return m_sizer_checkbox;
|
||||
}
|
||||
|
||||
Button *TipsDialog::add_button(wxWindowID btn_id, const wxString &label, bool set_focus /*= false*/)
|
||||
{
|
||||
Button* btn = new Button(this, label, "", 0, 0, btn_id);
|
||||
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(0, 137, 123), StateColor::Pressed),
|
||||
std::pair<wxColour, int>(wxColour(38, 166, 154), StateColor::Hovered),
|
||||
std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal));
|
||||
|
||||
StateColor btn_bd_green(std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal));
|
||||
|
||||
StateColor btn_text_green(std::pair<wxColour, int>(wxColour(255, 255, 254), 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>(wxColour(255, 255, 255), StateColor::Normal)
|
||||
);
|
||||
|
||||
StateColor btn_bd_white(std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Normal));
|
||||
|
||||
StateColor btn_text_white(std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Normal));
|
||||
|
||||
if (btn_id == wxID_OK || btn_id == wxID_YES) {
|
||||
btn->SetBackgroundColor(btn_bg_green);
|
||||
btn->SetBorderColor(btn_bd_green);
|
||||
btn->SetTextColor(btn_text_green);
|
||||
}
|
||||
|
||||
if (btn_id == wxID_CANCEL || btn_id == wxID_NO) {
|
||||
btn->SetBackgroundColor(btn_bg_white);
|
||||
btn->SetBorderColor(btn_bd_white);
|
||||
btn->SetTextColor(btn_text_white);
|
||||
}
|
||||
|
||||
if (set_focus)
|
||||
btn->SetFocus();
|
||||
|
||||
btn->SetSize(TIPS_DIALOG_BUTTON_SIZE);
|
||||
btn->SetMinSize(TIPS_DIALOG_BUTTON_SIZE);
|
||||
btn->SetCornerRadius(FromDIP(12));
|
||||
btn->Bind(wxEVT_BUTTON, [this, btn_id](wxCommandEvent &) {
|
||||
if (m_show_again) {
|
||||
if (!m_app_key.empty()) {
|
||||
if (btn_id == wxID_OK || btn_id == wxID_YES) {
|
||||
wxGetApp().app_config->set_bool(m_app_key, true);
|
||||
}
|
||||
|
||||
if (btn_id == wxID_NO) {
|
||||
wxGetApp().app_config->set_bool(m_app_key, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
EndModal(btn_id);
|
||||
});
|
||||
return btn;
|
||||
}
|
||||
|
||||
void TipsDialog::on_dpi_changed(const wxRect &suggested_rect)
|
||||
{
|
||||
if (m_confirm) m_confirm->SetMinSize(TIPS_DIALOG_BUTTON_SIZE);
|
||||
|
||||
Reference in New Issue
Block a user