From b2700a8ac69bf3f07af384c8466d5872fec66f31 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 30 Oct 2020 12:24:33 +0100 Subject: [PATCH] Custom control : Bug fixing * OG_CustomCtrl is inherited from the wxPanel instead of the wxControl now. As a result, Tab-key is working now for the fields inside the custom control * Open localized web-page if any exist for labels + Fixed update of icons inside the PresetComboBoxes after switching between Dark/Light modes --- src/slic3r/GUI/OG_CustomCtrl.cpp | 20 ++++++++++++-------- src/slic3r/GUI/OG_CustomCtrl.hpp | 2 +- src/slic3r/GUI/PresetComboBoxes.cpp | 4 ++++ src/slic3r/GUI/Tab.cpp | 1 + 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/slic3r/GUI/OG_CustomCtrl.cpp b/src/slic3r/GUI/OG_CustomCtrl.cpp index f0fd4975e..05a7714d9 100644 --- a/src/slic3r/GUI/OG_CustomCtrl.cpp +++ b/src/slic3r/GUI/OG_CustomCtrl.cpp @@ -2,6 +2,7 @@ #include "OptionsGroup.hpp" #include "Plater.hpp" #include "GUI_App.hpp" +#include "libslic3r/AppConfig.hpp" #include #include @@ -25,11 +26,16 @@ static wxSize get_bitmap_size(const wxBitmap& bmp) #endif } -static wxString get_url(const wxString& path_end) +static wxString get_url(const wxString& path_end, bool get_default = false) { if (path_end.IsEmpty()) return wxEmptyString; - return wxString("https://help.prusa3d.com/") + "en" + "/article/" + path_end; + + wxString language = wxGetApp().app_config->get("translation_language"); + if (language.IsEmpty()) + return wxEmptyString; + + return wxString("https://help.prusa3d.com/") + language.BeforeFirst('_') + "/article/" + path_end; } OG_CustomCtrl::OG_CustomCtrl( wxWindow* parent, @@ -38,7 +44,7 @@ OG_CustomCtrl::OG_CustomCtrl( wxWindow* parent, const wxSize& size/* = wxDefaultSize*/, const wxValidator& val /* = wxDefaultValidator*/, const wxString& name/* = wxEmptyString*/) : - wxControl(parent, wxID_ANY, pos, size, wxWANTS_CHARS | wxBORDER_NONE), + wxPanel(parent, wxID_ANY, pos, size, /*wxWANTS_CHARS |*/ wxBORDER_NONE | wxTAB_TRAVERSAL), opt_group(og) { if (!wxOSX) @@ -210,6 +216,8 @@ void OG_CustomCtrl::OnMotion(wxMouseEvent& event) const wxPoint pos = event.GetLogicalPosition(wxClientDC(this)); wxString tooltip; + wxString language = wxGetApp().app_config->get("translation_language"); + for (CtrlLine& line : ctrl_lines) { line.is_focused = is_point_in_rect(pos, line.rect_label); if (line.is_focused) { @@ -631,11 +639,7 @@ wxCoord OG_CustomCtrl::CtrlLine::draw_act_bmps(wxDC& dc, wxPoint pos, const wxBi bool OG_CustomCtrl::CtrlLine::launch_browser() const { - if (is_focused && !og_line.label_path.IsEmpty()) { - wxLaunchDefaultBrowser(get_url(og_line.label_path)); - return true; - } - return false; + return is_focused && !og_line.label_path.IsEmpty() && wxLaunchDefaultBrowser(get_url(og_line.label_path)); } diff --git a/src/slic3r/GUI/OG_CustomCtrl.hpp b/src/slic3r/GUI/OG_CustomCtrl.hpp index 47b85fcef..e5e5e8eeb 100644 --- a/src/slic3r/GUI/OG_CustomCtrl.hpp +++ b/src/slic3r/GUI/OG_CustomCtrl.hpp @@ -25,7 +25,7 @@ namespace Slic3r { namespace GUI { // Static text shown among the options. -class OG_CustomCtrl :public wxControl +class OG_CustomCtrl :public wxPanel { wxFont m_font; int m_v_gap; diff --git a/src/slic3r/GUI/PresetComboBoxes.cpp b/src/slic3r/GUI/PresetComboBoxes.cpp index f71cbd17b..d82a32ed3 100644 --- a/src/slic3r/GUI/PresetComboBoxes.cpp +++ b/src/slic3r/GUI/PresetComboBoxes.cpp @@ -349,6 +349,8 @@ wxBitmap* PresetComboBox::get_bmp( std::string bitmap_key, bool wide_icons, con bitmap_key += is_system ? ",syst" : ",nsyst"; bitmap_key += ",h" + std::to_string(icon_height); + if (wxGetApp().dark_mode()) + bitmap_key += ",dark"; wxBitmap* bmp = bitmap_cache().find(bitmap_key); if (bmp == nullptr) { @@ -393,6 +395,8 @@ wxBitmap* PresetComboBox::get_bmp( std::string bitmap_key, const std::string& m bitmap_key += is_compatible ? ",cmpt" : ",ncmpt"; bitmap_key += is_system ? ",syst" : ",nsyst"; bitmap_key += ",h" + std::to_string(icon_height); + if (wxGetApp().dark_mode()) + bitmap_key += ",dark"; wxBitmap* bmp = bitmap_cache().find(bitmap_key); if (bmp == nullptr) { diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index c44f7b9d0..020fbbfc4 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1010,6 +1010,7 @@ void Tab::msw_rescale() void Tab::sys_color_changed() { update_tab_ui(); + m_presets_choice->msw_rescale(); // update buttons and cached bitmaps for (const auto btn : m_scaled_buttons)