diff options
-rw-r--r-- | src/slic3r/GUI/GUI.cpp | 4 | ||||
-rw-r--r-- | src/slic3r/GUI/GUI_App.cpp | 43 | ||||
-rw-r--r-- | src/slic3r/GUI/MsgDialog.cpp | 28 | ||||
-rw-r--r-- | src/slic3r/GUI/MsgDialog.hpp | 10 |
4 files changed, 49 insertions, 36 deletions
diff --git a/src/slic3r/GUI/GUI.cpp b/src/slic3r/GUI/GUI.cpp index 8fe951292..fb7fa00f1 100644 --- a/src/slic3r/GUI/GUI.cpp +++ b/src/slic3r/GUI/GUI.cpp @@ -352,7 +352,7 @@ void show_substitutions_info(const PresetsConfigSubstitutions& presets_config_su add_config_substitutions(substitution.substitutions, changes); } - InfoDialog msg(nullptr, _L("Configuration bundle was loaded, however some configuration values were not recognized."), substitution_message(changes)); + InfoDialog msg(nullptr, _L("Configuration bundle was loaded, however some configuration values were not recognized."), substitution_message(changes), true); msg.ShowModal(); } @@ -363,7 +363,7 @@ void show_substitutions_info(const ConfigSubstitutions& config_substitutions, co InfoDialog msg(nullptr, format_wxstr(_L("Configuration file \"%1%\" was loaded, however some configuration values were not recognized."), from_u8(filename)), - substitution_message(changes)); + substitution_message(changes), true); msg.ShowModal(); } diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 0c40000e5..2e8231cc5 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -948,24 +948,31 @@ bool GUI_App::check_older_app_config(Semver current_version, bool backup) return false; BOOST_LOG_TRIVIAL(info) << "last app config file used: " << m_older_data_dir_path; // ask about using older data folder - RichMessageDialog msg(nullptr, backup ? - wxString::Format(_L( - "Current configuration folder: %s" - "\n\n%s found another configuration for version %s." - "\nIt is found at %s." - "\n\nDo you wish to copy and use the configuration file for version %s (overwriting any file with the same name)? A backup of your current configuration will be created." - "\nIf you select no, you will continue with the configuration file for version %s (may not be fully compatible).") - , current_version.to_string(), SLIC3R_APP_NAME, last_semver.to_string(), m_older_data_dir_path, last_semver.to_string(), current_version.to_string()) - : wxString::Format(_L( - "%s found another configuration for version %s." - "\nIt is found at %s." - "\nThere is no configuration file in current configuration folder." - "\n\nDo you wish to copy and use the configuration file for version %s?" - "\nIf you select no, you will start with clean installation with configuration wizard.") - , SLIC3R_APP_NAME, last_semver.to_string(), m_older_data_dir_path, last_semver.to_string()) - , _L("PrusaSlicer") - , wxYES_NO - , wxString::Format(_L("Load configuration from version %s?"), last_semver.to_string())); + + InfoDialog msg(nullptr + , format_wxstr(_L("You are opening %1% version %2%."), SLIC3R_APP_NAME, SLIC3R_VERSION) + , backup ? + format_wxstr(_L( + "The active configuration was created by <b>%1% %2%</b>," + "\nwhile a newer configuration was found in <b>%3%</b>" + "\ncreated by <b>%1% %4%</b>." + "\n\nShall the newer configuration be imported?" + "\nIf so, your active configuration will backed up before importing the new configuration." + ) + , SLIC3R_APP_NAME, current_version.to_string(), m_older_data_dir_path, last_semver.to_string()) + : format_wxstr(_L( + "An existing configuration was found in <b>%3%</b>" + "\ncreated by <b>%1% %2%</b>." + "\n\nShall this configuration be imported?" + ) + , SLIC3R_APP_NAME, last_semver.to_string(), m_older_data_dir_path) + , true, wxYES_NO); + + if (backup) { + msg.SetButtonLabel(wxID_YES, _L("Import")); + msg.SetButtonLabel(wxID_NO, _L("Don't import")); + } + if (msg.ShowModal() == wxID_YES) { std::string snapshot_id; if (backup) { diff --git a/src/slic3r/GUI/MsgDialog.cpp b/src/slic3r/GUI/MsgDialog.cpp index 9343bb741..4e2462d4b 100644 --- a/src/slic3r/GUI/MsgDialog.cpp +++ b/src/slic3r/GUI/MsgDialog.cpp @@ -63,6 +63,15 @@ MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &he SetSizerAndFit(main_sizer); } +void MsgDialog::SetButtonLabel(wxWindowID btn_id, const wxString& label, bool set_focus/* = false*/) +{ + if (wxButton* btn = get_button(btn_id)) { + btn->SetLabel(label); + if (set_focus) + btn->SetFocus(); + } +} + wxButton* MsgDialog::add_button(wxWindowID btn_id, bool set_focus /*= false*/, const wxString& label/* = wxString()*/) { wxButton* btn = new wxButton(this, btn_id, label); @@ -98,7 +107,7 @@ void MsgDialog::finalize() // Text shown as HTML, so that mouse selection and Ctrl-V to copy will work. -static void add_msg_content(wxWindow* parent, wxBoxSizer* content_sizer, wxString msg, bool monospaced_font = false) +static void add_msg_content(wxWindow* parent, wxBoxSizer* content_sizer, wxString msg, bool monospaced_font = false, bool is_marked_msg = false) { wxHtmlWindow* html = new wxHtmlWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO); @@ -136,8 +145,7 @@ static void add_msg_content(wxWindow* parent, wxBoxSizer* content_sizer, wxStrin int em = wxGetApp().em_unit(); // if message containes the table - bool is_marked = msg.Contains("<tr>"); - if (is_marked) { + if (msg.Contains("<tr>")) { int lines = msg.Freq('\n') + 1; int pos = 0; while (pos < (int)msg.Len() && pos != wxNOT_FOUND) { @@ -155,7 +163,7 @@ static void add_msg_content(wxWindow* parent, wxBoxSizer* content_sizer, wxStrin } html->SetMinSize(page_size); - std::string msg_escaped = xml_escape(msg.ToUTF8().data(), is_marked); + std::string msg_escaped = xml_escape(msg.ToUTF8().data(), is_marked_msg); boost::replace_all(msg_escaped, "\r\n", "<br>"); boost::replace_all(msg_escaped, "\n", "<br>"); if (monospaced_font) @@ -215,10 +223,8 @@ MessageDialog::MessageDialog(wxWindow* parent, RichMessageDialog::RichMessageDialog(wxWindow* parent, const wxString& message, const wxString& caption/* = wxEmptyString*/, - long style/* = wxOK*/, - const wxString& headline/* = wxEmptyString*/ - ) - : MsgDialog(parent, caption.IsEmpty() ? wxString::Format(_L("%s info"), SLIC3R_APP_NAME) : caption, headline, style) + long style/* = wxOK*/) + : MsgDialog(parent, caption.IsEmpty() ? wxString::Format(_L("%s info"), SLIC3R_APP_NAME) : caption, wxEmptyString, style) { add_msg_content(this, content_sizer, message); @@ -245,11 +251,11 @@ int RichMessageDialog::ShowModal() // InfoDialog -InfoDialog::InfoDialog(wxWindow* parent, const wxString &title, const wxString& msg) - : MsgDialog(parent, wxString::Format(_L("%s information"), SLIC3R_APP_NAME), title, wxOK | wxICON_INFORMATION) +InfoDialog::InfoDialog(wxWindow* parent, const wxString &title, const wxString& msg, bool is_marked_msg/* = false*/, long style/* = wxOK | wxICON_INFORMATION*/) + : MsgDialog(parent, wxString::Format(_L("%s information"), SLIC3R_APP_NAME), title, style) , msg(msg) { - add_msg_content(this, content_sizer, msg); + add_msg_content(this, content_sizer, msg, false, is_marked_msg); finalize(); } diff --git a/src/slic3r/GUI/MsgDialog.hpp b/src/slic3r/GUI/MsgDialog.hpp index 50651312e..17d935495 100644 --- a/src/slic3r/GUI/MsgDialog.hpp +++ b/src/slic3r/GUI/MsgDialog.hpp @@ -30,7 +30,7 @@ struct MsgDialog : wxDialog MsgDialog &operator=(const MsgDialog &) = delete; virtual ~MsgDialog() = default; - // TODO: refactor with CreateStdDialogButtonSizer usage + void SetButtonLabel(wxWindowID btn_id, const wxString& label, bool set_focus = false); protected: enum { @@ -111,6 +111,7 @@ public: class MessageDialog : public MsgDialog { public: + // NOTE! Don't change a signature of contsrucor. It have to be tha same as for wxMessageDialog MessageDialog( wxWindow *parent, const wxString& message, const wxString& caption = wxEmptyString, @@ -130,12 +131,11 @@ class RichMessageDialog : public MsgDialog bool m_checkBoxValue{ false }; public: + // NOTE! Don't change a signature of contsrucor. It have to be tha same as for wxRichMessageDialog RichMessageDialog( wxWindow *parent, const wxString& message, const wxString& caption = wxEmptyString, - long style = wxOK, - const wxString& headline = wxEmptyString - ); + long style = wxOK); RichMessageDialog(RichMessageDialog&&) = delete; RichMessageDialog(const RichMessageDialog&) = delete; RichMessageDialog &operator=(RichMessageDialog&&) = delete; @@ -306,7 +306,7 @@ public: class InfoDialog : public MsgDialog { public: - InfoDialog(wxWindow *parent, const wxString &title, const wxString &msg); + InfoDialog(wxWindow *parent, const wxString &title, const wxString &msg, bool is_marked = false, long style = wxOK| wxICON_INFORMATION); InfoDialog(InfoDialog&&) = delete; InfoDialog(const InfoDialog&) = delete; InfoDialog&operator=(InfoDialog&&) = delete; |