From a17a694604eb872a6b857810054da555648fd3ad Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 6 Jan 2023 09:12:57 +0100 Subject: [PATCH] Linux specific: Follow-up https://github.com/Prusa-Development/PrusaSlicerPrivate/commit/fdc4ee7542a9a5516dfd6d0c502b5f01ae03c439 - Fix to "Post processigs..." line works like a link --- src/slic3r/GUI/OptionsGroup.cpp | 44 +++++++++++++++++++++++++++------ src/slic3r/GUI/Tab.cpp | 2 -- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp index 3659a08ccf..688570f904 100644 --- a/src/slic3r/GUI/OptionsGroup.cpp +++ b/src/slic3r/GUI/OptionsGroup.cpp @@ -1038,25 +1038,50 @@ void ogStaticText::SetText(const wxString& value, bool wrap/* = true*/) void ogStaticText::SetPathEnd(const std::string& link) { +#ifndef __linux__ + + Bind(wxEVT_ENTER_WINDOW, [this, link](wxMouseEvent& event) { + SetToolTip(OptionsGroup::get_url(get_app_config()->get("suppress_hyperlinks") != "1" ? link : std::string())); + FocusText(true); + event.Skip(); + }); + Bind(wxEVT_LEAVE_WINDOW, [this](wxMouseEvent& event) { FocusText(false); event.Skip(); }); + Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& event) { if (HasCapture()) return; this->CaptureMouse(); event.Skip(); - } ); + }); Bind(wxEVT_LEFT_UP, [link, this](wxMouseEvent& event) { if (!HasCapture()) return; ReleaseMouse(); OptionsGroup::launch_browser(link); event.Skip(); - } ); - Bind(wxEVT_ENTER_WINDOW, [this, link](wxMouseEvent& event) { - SetToolTip(OptionsGroup::get_url(!get_app_config()->get_bool("suppress_hyperlinks") ? link : std::string())); - FocusText(true); - event.Skip(); }); - Bind(wxEVT_LEAVE_WINDOW, [this](wxMouseEvent& event) { FocusText(false); event.Skip(); }); + +#else + + // Workaround: On Linux wxStaticText doesn't receive wxEVT_ENTER(LEAVE)_WINDOW events, + // so implement this behaviour trough wxEVT_MOTION events for this control and it's parent + Bind(wxEVT_MOTION, [link, this](wxMouseEvent& event) { + SetToolTip(OptionsGroup::get_url(!get_app_config()->get_bool("suppress_hyperlinks") ? link : std::string())); + FocusText(true); + event.Skip(); + }); + GetParent()->Bind(wxEVT_MOTION, [this](wxMouseEvent& event) { + FocusText(false); + event.Skip(); + }); + + // On Linux a mouse capturing causes a totally application freeze + Bind(wxEVT_LEFT_UP, [link, this](wxMouseEvent& event) { + OptionsGroup::launch_browser(link); + event.Skip(); + }); + +#endif } void ogStaticText::FocusText(bool focus) @@ -1065,7 +1090,10 @@ void ogStaticText::FocusText(bool focus) return; SetFont(focus ? Slic3r::GUI::wxGetApp().link_font() : - Slic3r::GUI::wxGetApp().normal_font()); + Slic3r::GUI::wxGetApp().normal_font()); +#ifdef __linux__ + this->GetContainingSizer()->Layout(); +#endif Refresh(); } diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 9932c6f459..2642cd0042 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1732,9 +1732,7 @@ void TabPrint::update_description_lines() if (m_post_process_explanation) { m_post_process_explanation->SetText( _L("Post processing scripts shall modify G-code file in place.")); -#ifndef __linux__ m_post_process_explanation->SetPathEnd("post-processing-scripts_283913"); -#endif // __linux__ } // upadte G-code substitutions from the current configuration {