Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuSanka <yusanka@gmail.com>2021-12-10 17:34:28 +0300
committerYuSanka <yusanka@gmail.com>2021-12-10 17:35:04 +0300
commit102ef9a02446f883ec0307af8b754db2fc366b30 (patch)
treef86d985d8b1040aa76bf9dfa270f67d39e2cbed4
parentc21950c07bbc1ae7784580cd95229ca500e970a1 (diff)
Follow-up https://github.com/prusa3d/PrusaSlicer/commit/ea796aaa68a2948058d02711cc25a0a0fcfcee30
* Fixed builds for non-MSW platforms (We can't change the signature of the RichMessageDialog. It have to be completely the same as for wxRichMessageDialog) * Texts of the message dialog are changed. Use InfoDialog instead of a RichMessageDialog. * MsgDialog: Added SetButtonLabel() function * InfoDialog: For constructor added is_marked_message and style parameter to allow to use marked text in the Dialog and set different style
-rw-r--r--src/slic3r/GUI/GUI.cpp4
-rw-r--r--src/slic3r/GUI/GUI_App.cpp43
-rw-r--r--src/slic3r/GUI/MsgDialog.cpp28
-rw-r--r--src/slic3r/GUI/MsgDialog.hpp10
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;