OG_CustomCtrl: Code refactoring - Use standard RichMessageDialog instead of own written
This commit is contained in:
parent
8bfa132a1b
commit
e70fc7f0da
2 changed files with 13 additions and 62 deletions
src/slic3r/GUI
|
@ -772,65 +772,30 @@ bool OG_CustomCtrl::CtrlLine::launch_browser() const
|
||||||
bool launch = true;
|
bool launch = true;
|
||||||
|
|
||||||
if (get_app_config()->get("suppress_hyperlinks").empty()) {
|
if (get_app_config()->get("suppress_hyperlinks").empty()) {
|
||||||
RememberChoiceDialog dialog(nullptr, _L("Open hyperlink in default browser?"), _L("PrusaSlicer: Open hyperlink"));
|
RichMessageDialog dialog(nullptr, _L("Open hyperlink in default browser?"), _L("PrusaSlicer: Open hyperlink"), wxYES_NO);
|
||||||
|
dialog.ShowCheckBox(_L("Remember my choice"));
|
||||||
int answer = dialog.ShowModal();
|
int answer = dialog.ShowModal();
|
||||||
launch = answer == wxID_YES;
|
|
||||||
|
|
||||||
get_app_config()->set("suppress_hyperlinks", dialog.remember_choice() ? (answer == wxID_NO ? "1" : "0") : "");
|
if (dialog.IsCheckBoxChecked()) {
|
||||||
}
|
|
||||||
if (launch)
|
|
||||||
launch = get_app_config()->get("suppress_hyperlinks") != "1";
|
|
||||||
|
|
||||||
return launch && wxLaunchDefaultBrowser(get_url(og_line.label_path));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
RememberChoiceDialog::RememberChoiceDialog(wxWindow* parent, const wxString& msg_text, const wxString& caption)
|
|
||||||
: wxDialog(parent, wxID_ANY, caption, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxICON_INFORMATION)
|
|
||||||
{
|
|
||||||
this->SetEscapeId(wxID_CLOSE);
|
|
||||||
|
|
||||||
wxBoxSizer* topSizer = new wxBoxSizer(wxVERTICAL);
|
|
||||||
|
|
||||||
m_remember_choice = new wxCheckBox(this, wxID_ANY, _L("Remember my choice"));
|
|
||||||
m_remember_choice->SetValue(false);
|
|
||||||
m_remember_choice->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent& evt)
|
|
||||||
{
|
|
||||||
if (!evt.IsChecked())
|
|
||||||
return;
|
|
||||||
wxString preferences_item = _L("Suppress to open hyperlink in browser");
|
wxString preferences_item = _L("Suppress to open hyperlink in browser");
|
||||||
wxString msg =
|
wxString msg =
|
||||||
_L("PrusaSlicer will remember your choice.") + "\n\n" +
|
_L("PrusaSlicer will remember your choice.") + "\n\n" +
|
||||||
_L("You will not be asked about it again on label hovering.") + "\n\n" +
|
_L("You will not be asked about it again on label hovering.") + "\n\n" +
|
||||||
format_wxstr(_L("Visit \"Preferences\" and check \"%1%\"\nto changes your choice."), preferences_item);
|
format_wxstr(_L("Visit \"Preferences\" and check \"%1%\"\nto changes your choice."), preferences_item);
|
||||||
|
|
||||||
//wxMessageDialog dialog(nullptr, msg, _L("PrusaSlicer: Don't ask me again"), wxOK | wxCANCEL | wxICON_INFORMATION);
|
MessageDialog msg_dlg(nullptr, msg, _L("PrusaSlicer: Don't ask me again"), wxOK | wxCANCEL | wxICON_INFORMATION);
|
||||||
MessageDialog dialog(nullptr, msg, _L("PrusaSlicer: Don't ask me again"), wxOK | wxCANCEL | wxICON_INFORMATION);
|
if (msg_dlg.ShowModal() == wxID_CANCEL)
|
||||||
if (dialog.ShowModal() == wxID_CANCEL)
|
return false;
|
||||||
m_remember_choice->SetValue(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
get_app_config()->set("suppress_hyperlinks", dialog.IsCheckBoxChecked() ? (answer == wxID_NO ? "1" : "0") : "");
|
||||||
|
}
|
||||||
|
|
||||||
// Add dialog's buttons
|
launch = answer == wxID_YES;
|
||||||
wxStdDialogButtonSizer* btns = this->CreateStdDialogButtonSizer(wxYES | wxNO);
|
}
|
||||||
wxButton* btnYES = static_cast<wxButton*>(this->FindWindowById(wxID_YES, this));
|
if (launch)
|
||||||
wxButton* btnNO = static_cast<wxButton*>(this->FindWindowById(wxID_NO, this));
|
launch = get_app_config()->get("suppress_hyperlinks") != "1";
|
||||||
btnYES->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { this->EndModal(wxID_YES); });
|
|
||||||
btnNO->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { this->EndModal(wxID_NO); });
|
|
||||||
|
|
||||||
topSizer->Add(new wxStaticText(this, wxID_ANY, msg_text), 0, wxEXPAND | wxALL, 10);
|
return launch && wxLaunchDefaultBrowser(get_url(og_line.label_path));
|
||||||
topSizer->Add(m_remember_choice, 0, wxEXPAND | wxALL, 10);
|
|
||||||
topSizer->Add(btns, 0, wxEXPAND | wxALL, 10);
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
wxGetApp().UpdateDlgDarkUI(this);
|
|
||||||
#else
|
|
||||||
this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
|
||||||
#endif
|
|
||||||
this->SetSizer(topSizer);
|
|
||||||
topSizer->SetSizeHints(this);
|
|
||||||
|
|
||||||
this->CenterOnScreen();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // GUI
|
} // GUI
|
||||||
|
|
|
@ -106,20 +106,6 @@ public:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------------
|
|
||||||
// RememberChoiceDialog
|
|
||||||
//-----------------------------------------------
|
|
||||||
|
|
||||||
class RememberChoiceDialog : public wxDialog
|
|
||||||
{
|
|
||||||
wxCheckBox* m_remember_choice;
|
|
||||||
public:
|
|
||||||
RememberChoiceDialog(wxWindow* parent, const wxString& msg_text, const wxString& caption);
|
|
||||||
~RememberChoiceDialog() {}
|
|
||||||
|
|
||||||
bool remember_choice() const { return m_remember_choice->GetValue(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
#endif /* slic3r_OG_CustomCtrl_hpp_ */
|
#endif /* slic3r_OG_CustomCtrl_hpp_ */
|
||||||
|
|
Loading…
Reference in a new issue