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>2022-01-06 15:55:16 +0300
committerYuSanka <yusanka@gmail.com>2022-01-06 15:55:40 +0300
commit2b66a81ee168f8a2b1020677001360cf9301a872 (patch)
treebf8592ab2b16217f0500e81193c6ca7b1354819c /src/slic3r/GUI
parente031001f0a1b7d6cf9f7bc806cc8159ffe8ef78d (diff)
Preferences: Changed tooltip for the "Suppress to open hyperlink in browser"
+ Show "PrusaSlicer: Don't ask me again" dialog when "Remember my choice" is checked in "PrusaSlicer: Open hyperlink" dialog + Ignore suppress of hyperlink for menu items + Code refactoring for OptionsGroup::launch_browser() => use common wxGetApp().open_browser_with_warning_dialog().
Diffstat (limited to 'src/slic3r/GUI')
-rw-r--r--src/slic3r/GUI/GUI_App.cpp41
-rw-r--r--src/slic3r/GUI/GUI_App.hpp3
-rw-r--r--src/slic3r/GUI/MainFrame.cpp4
-rw-r--r--src/slic3r/GUI/OptionsGroup.cpp31
-rw-r--r--src/slic3r/GUI/Preferences.cpp5
5 files changed, 39 insertions, 45 deletions
diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp
index 5a28abedd..1858044ae 100644
--- a/src/slic3r/GUI/GUI_App.cpp
+++ b/src/slic3r/GUI/GUI_App.cpp
@@ -2795,7 +2795,7 @@ wxString GUI_App::current_language_code_safe() const
void GUI_App::open_web_page_localized(const std::string &http_address)
{
- open_browser_with_warning_dialog(http_address + "&lng=" + this->current_language_code_safe());
+ open_browser_with_warning_dialog(http_address + "&lng=" + this->current_language_code_safe(), nullptr, false);
}
// If we are switching from the FFF-preset to the SLA, we should to control the printed objects if they have a part(s).
@@ -2999,19 +2999,40 @@ void GUI_App::check_updates(const bool verbose)
}
}
-bool GUI_App::open_browser_with_warning_dialog(const wxString& url, int flags/* = 0*/)
+bool GUI_App::open_browser_with_warning_dialog(const wxString& url, wxWindow* parent/* = nullptr*/, bool force_remember_choice /*= true*/, int flags/* = 0*/)
{
bool launch = true;
- if (get_app_config()->get("suppress_hyperlinks").empty()) {
- RichMessageDialog dialog(nullptr, _L("Open hyperlink in default browser?"), _L("PrusaSlicer: Open hyperlink"), wxICON_QUESTION | wxYES_NO);
- dialog.ShowCheckBox(_L("Remember my choice"));
- int answer = dialog.ShowModal();
- launch = answer == wxID_YES;
- get_app_config()->set("suppress_hyperlinks", dialog.IsCheckBoxChecked() ? (answer == wxID_NO ? "1" : "0") : "");
+ // warning dialog containes a "Remember my choice" checkbox
+ std::string option_key = "suppress_hyperlinks";
+ if (force_remember_choice || app_config->get(option_key).empty()) {
+ if (app_config->get(option_key).empty()) {
+ RichMessageDialog dialog(parent, _L("Open hyperlink in default browser?"), _L("PrusaSlicer: Open hyperlink"), wxICON_QUESTION | wxYES_NO);
+ dialog.ShowCheckBox(_L("Remember my choice"));
+ auto answer = dialog.ShowModal();
+ launch = answer == wxID_YES;
+ if (dialog.IsCheckBoxChecked()) {
+ wxString preferences_item = _L("Suppress to open hyperlink in browser");
+ wxString msg =
+ _L("PrusaSlicer will remember your choice.") + "\n\n" +
+ _L("You will not be asked about it again on hyperlinks hovering.") + "\n\n" +
+ format_wxstr(_L("Visit \"Preferences\" and check \"%1%\"\nto changes your choice."), preferences_item);
+
+ MessageDialog msg_dlg(parent, msg, _L("PrusaSlicer: Don't ask me again"), wxOK | wxCANCEL | wxICON_INFORMATION);
+ if (msg_dlg.ShowModal() == wxID_CANCEL)
+ return false;
+ app_config->set(option_key, answer == wxID_NO ? "1" : "0");
+ }
+ }
+ if (launch)
+ launch = app_config->get(option_key) != "1";
+ }
+ // warning dialog doesn't containe a "Remember my choice" checkbox
+ // and will be shown only when "Suppress to open hyperlink in browser" is ON.
+ else if (app_config->get(option_key) == "1") {
+ MessageDialog dialog(parent, _L("Open hyperlink in default browser?"), _L("PrusaSlicer: Open hyperlink"), wxICON_QUESTION | wxYES_NO);
+ launch = dialog.ShowModal() == wxID_YES;
}
- if (launch)
- launch = get_app_config()->get("suppress_hyperlinks") != "1";
return launch && wxLaunchDefaultBrowser(url, flags);
}
diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp
index 9c65bc024..6e310e491 100644
--- a/src/slic3r/GUI/GUI_App.hpp
+++ b/src/slic3r/GUI/GUI_App.hpp
@@ -268,7 +268,8 @@ public:
virtual bool OnExceptionInMainLoop() override;
// Calls wxLaunchDefaultBrowser if user confirms in dialog.
- bool open_browser_with_warning_dialog(const wxString& url, int flags = 0);
+ // Add "Rememeber my choice" checkbox to question dialog, when it is forced or a "suppress_hyperlinks" option has empty value
+ bool open_browser_with_warning_dialog(const wxString& url, wxWindow* parent = nullptr, bool force_remember_choice = true, int flags = 0);
#ifdef __APPLE__
void OSXStoreOpenFiles(const wxArrayString &files) override;
// wxWidgets override to get an event on open files.
diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp
index 1e589e432..fe96136e6 100644
--- a/src/slic3r/GUI/MainFrame.cpp
+++ b/src/slic3r/GUI/MainFrame.cpp
@@ -1070,7 +1070,7 @@ static wxMenu* generate_help_menu()
append_menu_item(helpMenu, wxID_ANY, _L("Prusa 3D &Drivers"), _L("Open the Prusa3D drivers download page in your browser"),
[](wxCommandEvent&) { wxGetApp().open_web_page_localized("https://www.prusa3d.com/downloads"); });
append_menu_item(helpMenu, wxID_ANY, _L("Software &Releases"), _L("Open the software releases page in your browser"),
- [](wxCommandEvent&) { wxGetApp().open_browser_with_warning_dialog("https://github.com/prusa3d/PrusaSlicer/releases"); });
+ [](wxCommandEvent&) { wxGetApp().open_browser_with_warning_dialog("https://github.com/prusa3d/PrusaSlicer/releases", nullptr, false); });
//# my $versioncheck = $self->_append_menu_item($helpMenu, "Check for &Updates...", "Check for new Slic3r versions", sub{
//# wxTheApp->check_version(1);
//# });
@@ -1087,7 +1087,7 @@ static wxMenu* generate_help_menu()
append_menu_item(helpMenu, wxID_ANY, _L("Show &Configuration Folder"), _L("Show user configuration folder (datadir)"),
[](wxCommandEvent&) { Slic3r::GUI::desktop_open_datadir_folder(); });
append_menu_item(helpMenu, wxID_ANY, _L("Report an I&ssue"), wxString::Format(_L("Report an issue on %s"), SLIC3R_APP_NAME),
- [](wxCommandEvent&) { wxGetApp().open_browser_with_warning_dialog("https://github.com/prusa3d/slic3r/issues/new"); });
+ [](wxCommandEvent&) { wxGetApp().open_browser_with_warning_dialog("https://github.com/prusa3d/slic3r/issues/new", nullptr, false); });
if (wxGetApp().is_editor())
append_menu_item(helpMenu, wxID_ANY, wxString::Format(_L("&About %s"), SLIC3R_APP_NAME), _L("Show about dialog"),
[](wxCommandEvent&) { Slic3r::GUI::about(); });
diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp
index 64fc4b8c8..3238b0650 100644
--- a/src/slic3r/GUI/OptionsGroup.cpp
+++ b/src/slic3r/GUI/OptionsGroup.cpp
@@ -977,36 +977,7 @@ wxString OptionsGroup::get_url(const std::string& path_end)
bool OptionsGroup::launch_browser(const std::string& path_end)
{
- bool launch = true;
-
- if (get_app_config()->get("suppress_hyperlinks").empty()) {
- wxWindow* parent = wxGetApp().mainframe->m_tabpanel;
- RichMessageDialog dialog(parent, _L("Open hyperlink in default browser?"), _L("PrusaSlicer: Open hyperlink"), wxYES_NO);
- dialog.ShowCheckBox(_L("Remember my choice"));
- int answer = dialog.ShowModal();
- if (answer == wxID_CANCEL)
- return false;
-
- if (dialog.IsCheckBoxChecked()) {
- wxString preferences_item = _L("Suppress to open hyperlink in browser");
- wxString msg =
- _L("PrusaSlicer will remember your choice.") + "\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);
-
- MessageDialog msg_dlg(parent, msg, _L("PrusaSlicer: Don't ask me again"), wxOK | wxCANCEL | wxICON_INFORMATION);
- if (msg_dlg.ShowModal() == wxID_CANCEL)
- return false;
-
- get_app_config()->set("suppress_hyperlinks", dialog.IsCheckBoxChecked() ? (answer == wxID_NO ? "1" : "0") : "");
- }
-
- launch = answer == wxID_YES;
- }
- if (launch)
- launch = get_app_config()->get("suppress_hyperlinks") != "1";
-
- return launch && wxLaunchDefaultBrowser(OptionsGroup::get_url(path_end));
+ return wxGetApp().open_browser_with_warning_dialog(OptionsGroup::get_url(path_end), wxGetApp().mainframe->m_tabpanel);
}
diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp
index 1d98dfd5d..7668ec360 100644
--- a/src/slic3r/GUI/Preferences.cpp
+++ b/src/slic3r/GUI/Preferences.cpp
@@ -374,8 +374,9 @@ void PreferencesDialog::build(size_t selected_tab)
def.label = L("Suppress to open hyperlink in browser");
def.type = coBool;
- def.tooltip = L("If enabled, the descriptions of configuration parameters in settings tabs wouldn't work as hyperlinks. "
- "If disabled, the descriptions of configuration parameters in settings tabs will work as hyperlinks.");
+ def.tooltip = L("If enabled, PrusaSlicer will not open a hyperlinks in your browser.");
+ //def.tooltip = ("If enabled, the descriptions of configuration parameters in settings tabs wouldn't work as hyperlinks. "
+ // "If disabled, the descriptions of configuration parameters in settings tabs will work as hyperlinks.");
def.set_default_value(new ConfigOptionBool{ app_config->get("suppress_hyperlinks") == "1" });
option = Option(def, "suppress_hyperlinks");
m_optgroup_gui->append_single_option_line(option);