From 0bee82cee54a4df3dc665d0f7b6029d74c3e8a23 Mon Sep 17 00:00:00 2001 From: yw4z Date: Sat, 3 Jan 2026 18:06:57 +0300 Subject: [PATCH] Hyperlink class (#9947) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### FIXES • 3mf file version check dialog opens bambu releases page instead Orca ### CODE COMPARISON Screenshot-20251128125737 **wxHyperlinkCtrl** • System decides what colors to use. so blue color is visible even with colors set • No need to use SetCursor() ``` auto wiki_url = "https://github.com/OrcaSlicer/OrcaSlicer/wiki/Built-in-placeholders-variables"; wxHyperlinkCtrl* wiki = new wxHyperlinkCtrl(this, wxID_ANY, _L("Wiki Guide"), wiki_url); wiki->SetToolTip(wiki_url); // required to showing navigation point to user wiki->SetFont(Label::Body_14); // not works properly wiki->SetVisitedColour(wxColour("#009687")); // not works properly wiki->SetHoverColour( wxColour("#26A69A")); // not works properly wiki->SetNormalColour( wxColour("#009687")); // not works properly ``` Screenshot-20251128125847 **wxStaticText** • Works reliably on colors and fonts • All event has to defined manually ``` wxStaticText* wiki = new wxStaticText(this, wxID_ANY, _L("Wiki Guide")); auto wiki_url = "https://github.com/OrcaSlicer/OrcaSlicer/wiki/Built-in-placeholders-variables"; wiki->SetToolTip(wiki_url); // required to showing navigation point to user wiki->SetForegroundColour(wxColour("#009687")); wiki->SetCursor(wxCURSOR_HAND); wxFont font = Label::Body_14; font.SetUnderlined(true); wiki->SetFont(font); wiki->Bind(wxEVT_LEFT_DOWN ,[this, wiki_url](wxMouseEvent e) {wxLaunchDefaultBrowser(wiki_url);}); wiki->Bind(wxEVT_ENTER_WINDOW,[this, wiki ](wxMouseEvent e) {SetForegroundColour(wxColour("#26A69A"));}); wiki->Bind(wxEVT_LEAVE_WINDOW,[this, wiki ](wxMouseEvent e) {SetForegroundColour(wxColour("#009687"));}); ``` Screenshot-20251128125847 **HyperLink** • Fully automated and single line solution • Colors can be controllable from one place • Works reliably on colors and fonts • Reduces duplicate code ``` HyperLink* wiki = new HyperLink(this, _L("Wiki Guide"), "https://github.com/OrcaSlicer/OrcaSlicer/wiki/Built-in-placeholders-variables"); wiki->SetFont(Label::Body_14) // OPTIONAL default is Label::Body_14; ``` ### CHANGES • Unifies all hyperlinks with same style and makes them controllable from one place • Replaces all wxHyperlink with simple custom class. Problem with wxHyperlink it mostly rendered as blue even color set • Reduces duplicate code • Adds wiki links for calibration dialogs • Probably will add "Wiki Guide" to more dialogs overtime Screenshot-20251127212007 Screenshot-20251127212021 Screenshot-20251127212046 Screenshot-20250824171339 Screenshot-20251127212403 Screenshot-20251127212515 Screenshot-20251127212541 Screenshot-20251127213243 --- src/slic3r/CMakeLists.txt | 2 + src/slic3r/GUI/AMSMaterialsSetting.cpp | 6 +- src/slic3r/GUI/AMSMaterialsSetting.hpp | 4 +- src/slic3r/GUI/BindDialog.cpp | 41 ++------ src/slic3r/GUI/BindDialog.hpp | 8 +- src/slic3r/GUI/CalibrationWizardPage.cpp | 15 +-- src/slic3r/GUI/CalibrationWizardPage.hpp | 3 +- src/slic3r/GUI/CreatePresetsDialog.cpp | 5 +- src/slic3r/GUI/DownloadProgressDialog.cpp | 8 +- src/slic3r/GUI/FilamentGroupPopup.cpp | 9 +- src/slic3r/GUI/GUI_App.cpp | 10 +- src/slic3r/GUI/GUI_App.hpp | 4 +- src/slic3r/GUI/MsgDialog.cpp | 15 ++- src/slic3r/GUI/MsgDialog.hpp | 5 +- src/slic3r/GUI/NotificationManager.hpp | 2 +- src/slic3r/GUI/ObjColorDialog.cpp | 9 +- src/slic3r/GUI/PrintOptionsDialog.cpp | 10 +- src/slic3r/GUI/PrintOptionsDialog.hpp | 5 +- src/slic3r/GUI/ReleaseNote.cpp | 3 +- src/slic3r/GUI/ReleaseNote.hpp | 2 +- src/slic3r/GUI/SelectMachine.cpp | 7 +- src/slic3r/GUI/SelectMachine.hpp | 3 +- src/slic3r/GUI/SelectMachinePop.cpp | 5 +- src/slic3r/GUI/SelectMachinePop.hpp | 2 +- src/slic3r/GUI/SendToPrinter.cpp | 6 +- src/slic3r/GUI/SendToPrinter.hpp | 2 +- src/slic3r/GUI/StepMeshDialog.cpp | 13 +-- src/slic3r/GUI/WebUserLoginDialog.cpp | 8 +- src/slic3r/GUI/Widgets/HyperLink.cpp | 49 ++++++++++ src/slic3r/GUI/Widgets/HyperLink.hpp | 26 +++++ src/slic3r/GUI/Widgets/SideTools.cpp | 11 +-- src/slic3r/GUI/Widgets/SideTools.hpp | 6 +- src/slic3r/GUI/calib_dlg.cpp | 114 +++++++++++----------- 33 files changed, 222 insertions(+), 196 deletions(-) create mode 100644 src/slic3r/GUI/Widgets/HyperLink.cpp create mode 100644 src/slic3r/GUI/Widgets/HyperLink.hpp diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index ca4f9c4123..69875f4ca6 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -492,6 +492,8 @@ set(SLIC3R_GUI_SOURCES GUI/Widgets/ErrorMsgStaticText.hpp GUI/Widgets/FanControl.cpp GUI/Widgets/FanControl.hpp + GUI/Widgets/HyperLink.cpp + GUI/Widgets/HyperLink.hpp GUI/Widgets/ImageSwitchButton.cpp GUI/Widgets/ImageSwitchButton.hpp GUI/Widgets/Label.cpp diff --git a/src/slic3r/GUI/AMSMaterialsSetting.cpp b/src/slic3r/GUI/AMSMaterialsSetting.cpp index a649f6b833..19a32c2d21 100644 --- a/src/slic3r/GUI/AMSMaterialsSetting.cpp +++ b/src/slic3r/GUI/AMSMaterialsSetting.cpp @@ -298,11 +298,7 @@ void AMSMaterialsSetting::create_panel_kn(wxWindow* parent) if (language.find("zh") == 0) region = "zh"; wxString link_url = wxString::Format("https://wiki.bambulab.com/%s/software/bambu-studio/calibration_pa", region); - m_wiki_ctrl = new wxHyperlinkCtrl(parent, wxID_ANY, "Wiki", link_url); - m_wiki_ctrl->SetNormalColour(*wxBLUE); - m_wiki_ctrl->SetHoverColour(wxColour(0, 0, 200)); - m_wiki_ctrl->SetVisitedColour(*wxBLUE); - m_wiki_ctrl->SetFont(Label::Head_14); + m_wiki_ctrl = new HyperLink(parent, "Wiki Guide", link_url); cali_title_sizer->Add(m_ratio_text, 0, wxALIGN_CENTER_VERTICAL); cali_title_sizer->Add(m_wiki_ctrl, 0, wxALIGN_CENTER_VERTICAL); diff --git a/src/slic3r/GUI/AMSMaterialsSetting.hpp b/src/slic3r/GUI/AMSMaterialsSetting.hpp index c678ec0717..84688896e6 100644 --- a/src/slic3r/GUI/AMSMaterialsSetting.hpp +++ b/src/slic3r/GUI/AMSMaterialsSetting.hpp @@ -14,8 +14,8 @@ #include "Widgets/CheckBox.hpp" #include "Widgets/ComboBox.hpp" #include "Widgets/TextInput.hpp" +#include "Widgets/HyperLink.hpp" #include "slic3r/Utils/CalibUtils.hpp" -#include #define AMS_MATERIALS_SETTING_DEF_COLOUR wxColour(255, 255, 255) #define AMS_MATERIALS_SETTING_GREY900 wxColour(38, 46, 48) @@ -174,7 +174,7 @@ protected: wxPanel * m_panel_kn; wxStaticText* m_ratio_text; - wxHyperlinkCtrl * m_wiki_ctrl; + HyperLink * m_wiki_ctrl; wxStaticText* m_k_param; TextInput* m_input_k_val; wxStaticText* m_n_param; diff --git a/src/slic3r/GUI/BindDialog.cpp b/src/slic3r/GUI/BindDialog.cpp index 7610fbe820..3847f8f2f1 100644 --- a/src/slic3r/GUI/BindDialog.cpp +++ b/src/slic3r/GUI/BindDialog.cpp @@ -98,18 +98,8 @@ PingCodeBindDialog::PingCodeBindDialog(Plater* plater /*= nullptr*/) m_status_text->Wrap(FromDIP(440)); m_status_text->SetForegroundColour(wxColour(38, 46, 48)); - m_link_show_ping_code_wiki = new wxStaticText(request_bind_panel, wxID_ANY, _L("Can't find Pin Code?")); - m_link_show_ping_code_wiki->SetFont(Label::Body_14); - m_link_show_ping_code_wiki->SetBackgroundColour(*wxWHITE); - m_link_show_ping_code_wiki->SetForegroundColour(wxColour(31, 142, 234)); - - m_link_show_ping_code_wiki->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_HAND); }); - m_link_show_ping_code_wiki->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_ARROW); }); - - m_link_show_ping_code_wiki->Bind(wxEVT_LEFT_DOWN, [this](auto& e) { - m_ping_code_wiki = "https://wiki.bambulab.com/en/bambu-studio/manual/pin-code"; - wxLaunchDefaultBrowser(m_ping_code_wiki); - }); + // ORCA standardized HyperLink + m_link_show_ping_code_wiki = new HyperLink(request_bind_panel, _L("Can't find Pin Code?"), "https://wiki.bambulab.com/en/bambu-studio/manual/pin-code"); m_text_input_title = new wxStaticText(request_bind_panel, wxID_ANY, _L("Pin Code")); m_text_input_title->SetFont(Label::Body_14); @@ -453,11 +443,11 @@ PingCodeBindDialog::~PingCodeBindDialog() { m_st_privacy_title->SetFont(Label::Body_13); m_st_privacy_title->SetForegroundColour(wxColour(38, 46, 48)); - auto m_link_Terms_title = new Label(m_panel_agreement, _L("Terms and Conditions")); + // ORCA standardized HyperLink + auto m_link_Terms_title = new HyperLink(m_panel_agreement, _L("Terms and Conditions")); m_link_Terms_title->SetFont(Label::Head_13); m_link_Terms_title->SetMaxSize(wxSize(FromDIP(450), -1)); m_link_Terms_title->Wrap(FromDIP(450)); - m_link_Terms_title->SetForegroundColour(wxColour("#009688")); m_link_Terms_title->Bind(wxEVT_LEFT_DOWN, [this](auto& e) { wxString txt = _L("Thank you for purchasing a Bambu Lab device. Before using your Bambu Lab device, please read the terms and conditions. " "By clicking to agree to use your Bambu Lab device, you agree to abide by the Privacy Policy and Terms of Use (collectively, the \"Terms\"). " @@ -467,18 +457,16 @@ PingCodeBindDialog::~PingCodeBindDialog() { confirm_dlg.CenterOnParent(); confirm_dlg.on_show(); }); - m_link_Terms_title->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_HAND); }); - m_link_Terms_title->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_ARROW); }); auto m_st_and_title = new Label(m_panel_agreement, _L("and")); m_st_and_title->SetFont(Label::Body_13); m_st_and_title->SetForegroundColour(wxColour(38, 46, 48)); - auto m_link_privacy_title = new Label(m_panel_agreement, _L("Privacy Policy")); + // ORCA standardized HyperLink + auto m_link_privacy_title = new HyperLink(m_panel_agreement, _L("Privacy Policy")); m_link_privacy_title->SetFont(Label::Head_13); m_link_privacy_title->SetMaxSize(wxSize(FromDIP(450), -1)); m_link_privacy_title->Wrap(FromDIP(450)); - m_link_privacy_title->SetForegroundColour(wxColour("#009688")); m_link_privacy_title->Bind(wxEVT_LEFT_DOWN, [this](auto& e) { std::string url; std::string country_code = Slic3r::GUI::wxGetApp().app_config->get_country_code(); @@ -491,8 +479,6 @@ PingCodeBindDialog::~PingCodeBindDialog() { } wxLaunchDefaultBrowser(url); }); - m_link_privacy_title->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_HAND);}); - m_link_privacy_title->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_ARROW);}); sizere_notice_agreement->Add(0, 0, 0, wxTOP, FromDIP(4)); sizer_privacy_agreement->Add(m_st_privacy_title, 0, wxALIGN_CENTER, 0); @@ -514,13 +500,11 @@ PingCodeBindDialog::~PingCodeBindDialog() { m_st_notice_title->SetFont(Label::Body_13); m_st_notice_title->SetForegroundColour(wxColour(38, 46, 48)); - auto m_link_notice_title = new Label(m_panel_agreement, notice_link_title); + // ORCA standardized HyperLink + auto m_link_notice_title = new HyperLink(m_panel_agreement, notice_link_title); m_link_notice_title->SetFont(Label::Head_13); m_link_notice_title->SetMaxSize(wxSize(FromDIP(450), -1)); m_link_notice_title->Wrap(FromDIP(450)); - m_link_notice_title->SetForegroundColour(wxColour("#009688")); - m_link_notice_title->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_HAND); }); - m_link_notice_title->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_ARROW); }); m_link_notice_title->Bind(wxEVT_LEFT_DOWN, [this](auto& e) { wxString txt = _L("In the 3D Printing community, we learn from each other's successes and failures to adjust " "our own slicing parameters and settings. %s follows the same principle and uses machine " @@ -580,13 +564,8 @@ PingCodeBindDialog::~PingCodeBindDialog() { wxBoxSizer* m_sizer_bind_failed_info = new wxBoxSizer(wxVERTICAL); m_sw_bind_failed_info->SetSizer( m_sizer_bind_failed_info ); - m_link_network_state = new wxHyperlinkCtrl(m_sw_bind_failed_info, wxID_ANY,_L("Check the status of current system services"),""); - m_link_network_state->SetFont(::Label::Body_12); - m_link_network_state->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {wxGetApp().link_to_network_check(); }); - m_link_network_state->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {m_link_network_state->SetCursor(wxCURSOR_HAND); }); - m_link_network_state->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {m_link_network_state->SetCursor(wxCURSOR_ARROW); }); - - + // ORCA standardized HyperLink + m_link_network_state = new HyperLink(m_sw_bind_failed_info, _L("Check the status of current system services"), wxGetApp().link_to_network_check()); wxBoxSizer* sizer_error_code = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* sizer_error_desc = new wxBoxSizer(wxHORIZONTAL); diff --git a/src/slic3r/GUI/BindDialog.hpp b/src/slic3r/GUI/BindDialog.hpp index a4ffd8fbff..b809bc523b 100644 --- a/src/slic3r/GUI/BindDialog.hpp +++ b/src/slic3r/GUI/BindDialog.hpp @@ -17,13 +17,13 @@ #include #include #include -#include #include "wxExtensions.hpp" #include "Widgets/StepCtrl.hpp" #include "Widgets/ProgressDialog.hpp" #include "Widgets/Button.hpp" #include "Widgets/ProgressBar.hpp" #include "Widgets/RoundedRectangle.hpp" +#include "Widgets/HyperLink.hpp" #include "Jobs/BindJob.hpp" #include "BBLStatusBar.hpp" #include "BBLStatusBarBind.hpp" @@ -56,7 +56,7 @@ private: Label* m_status_text; wxStaticText* m_text_input_title; - wxStaticText* m_link_show_ping_code_wiki; + HyperLink* m_link_show_ping_code_wiki; // ORCA TextInput* m_text_input_single_code[PING_CODE_LENGTH]; Button* m_button_bind; Button* m_button_cancel; @@ -70,7 +70,7 @@ private: Label* m_st_txt_error_code{ nullptr }; Label* m_st_txt_error_desc{ nullptr }; Label* m_st_txt_extra_info{ nullptr }; - wxHyperlinkCtrl* m_link_network_state{ nullptr }; + HyperLink* m_link_network_state{ nullptr }; wxString m_result_info; wxString m_result_extra; wxString m_ping_code_wiki; @@ -114,7 +114,7 @@ private: Label* m_st_txt_error_code{ nullptr }; Label* m_st_txt_error_desc{ nullptr }; Label* m_st_txt_extra_info{ nullptr }; - wxHyperlinkCtrl* m_link_network_state{ nullptr }; + HyperLink* m_link_network_state{ nullptr }; wxString m_result_info; wxString m_result_extra; bool m_show_error_info_state = true; diff --git a/src/slic3r/GUI/CalibrationWizardPage.cpp b/src/slic3r/GUI/CalibrationWizardPage.cpp index 3da543e79d..13e7023190 100644 --- a/src/slic3r/GUI/CalibrationWizardPage.cpp +++ b/src/slic3r/GUI/CalibrationWizardPage.cpp @@ -466,21 +466,12 @@ void CaliPageCaption::init_bitmaps() { void CaliPageCaption::create_wiki(wxWindow* parent) { - m_wiki_text = new Label(parent, _L("Wiki")); - m_wiki_text->SetFont(Label::Head_14); - m_wiki_text->SetForegroundColour({ 0, 88, 220 }); - m_wiki_text->Bind(wxEVT_ENTER_WINDOW, [this](wxMouseEvent& e) { - e.Skip(); - SetCursor(wxCURSOR_HAND); - }); - m_wiki_text->Bind(wxEVT_LEAVE_WINDOW, [this](wxMouseEvent& e) { - e.Skip(); - SetCursor(wxCURSOR_ARROW); - }); + // ORCA standardized HyperLink + m_wiki_text = new HyperLink(parent, _L("Wiki Guide")); m_wiki_text->Bind(wxEVT_LEFT_UP, [this](wxMouseEvent& e) { if (!m_wiki_url.empty()) wxLaunchDefaultBrowser(m_wiki_url); - }); + }); } void CaliPageCaption::show_prev_btn(bool show) diff --git a/src/slic3r/GUI/CalibrationWizardPage.hpp b/src/slic3r/GUI/CalibrationWizardPage.hpp index d03979cd55..524b1a6029 100644 --- a/src/slic3r/GUI/CalibrationWizardPage.hpp +++ b/src/slic3r/GUI/CalibrationWizardPage.hpp @@ -7,6 +7,7 @@ #include "Widgets/TextInput.hpp" #include "Widgets/AMSControl.hpp" #include "Widgets/ProgressBar.hpp" +#include "Widgets/HyperLink.hpp" #include "wxExtensions.hpp" #include "PresetComboBoxes.hpp" @@ -140,7 +141,7 @@ private: void init_bitmaps(); void create_wiki(wxWindow* parent); - Label* m_wiki_text; + HyperLink* m_wiki_text; // ORCA wxString m_wiki_url; ScalableBitmap m_prev_bmp_normal; ScalableBitmap m_prev_bmp_hover; diff --git a/src/slic3r/GUI/CreatePresetsDialog.cpp b/src/slic3r/GUI/CreatePresetsDialog.cpp index 7eb3beda82..269cd6ed12 100644 --- a/src/slic3r/GUI/CreatePresetsDialog.cpp +++ b/src/slic3r/GUI/CreatePresetsDialog.cpp @@ -17,6 +17,7 @@ #include "Tab.hpp" #include "MainFrame.hpp" #include "libslic3r_version.h" +#include "Widgets/HyperLink.hpp" // ORCA #define NAME_OPTION_COMBOBOX_SIZE wxSize(FromDIP(200), FromDIP(24)) #define FILAMENT_PRESET_COMBOBOX_SIZE wxSize(FromDIP(300), FromDIP(24)) @@ -5027,8 +5028,8 @@ wxPanel *PresetTree::get_child_item(wxPanel *parent, std::shared_ptr pre bool base_id_error = false; if (preset->inherits() == "" && preset->base_id != "") base_id_error = true; if (base_id_error) { - std::string wiki_url = "https://wiki.bambulab.com/en/software/bambu-studio/custom-filament-issue"; - wxHyperlinkCtrl *m_download_hyperlink = new wxHyperlinkCtrl(panel, wxID_ANY, _L("[Delete Required]"), wiki_url, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE); + // ORCA standardized HyperLink + HyperLink *m_download_hyperlink = new HyperLink(panel, _L("[Delete Required]"), "https://wiki.bambulab.com/en/software/bambu-studio/custom-filament-issue"); m_download_hyperlink->SetFont(Label::Body_10); sizer->Add(m_download_hyperlink, 0, wxEXPAND | wxALL, 5); } diff --git a/src/slic3r/GUI/DownloadProgressDialog.cpp b/src/slic3r/GUI/DownloadProgressDialog.cpp index 1c4f7a9bfb..5f3624c469 100644 --- a/src/slic3r/GUI/DownloadProgressDialog.cpp +++ b/src/slic3r/GUI/DownloadProgressDialog.cpp @@ -23,6 +23,8 @@ #include "Jobs/BoostThreadWorker.hpp" #include "Jobs/PlaterWorker.hpp" +#include "Widgets/HyperLink.hpp" // ORCA + #define DESIGN_INPUT_SIZE wxSize(FromDIP(100), -1) namespace Slic3r { @@ -72,7 +74,8 @@ DownloadProgressDialog::DownloadProgressDialog(wxString title) sizer_download_failed->Add(m_statictext_download_failed, 0, wxALIGN_CENTER | wxALL, 5); - auto m_download_hyperlink = new wxHyperlinkCtrl(m_panel_download_failed, wxID_ANY, _L("click here to see more info"), download_failed_url, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE); + // ORCA standardized HyperLink + auto m_download_hyperlink = new HyperLink(m_panel_download_failed, _L("click here to see more info"), download_failed_url); sizer_download_failed->Add(m_download_hyperlink, 0, wxALIGN_CENTER | wxALL, 5); @@ -93,7 +96,8 @@ DownloadProgressDialog::DownloadProgressDialog(wxString title) sizer_install_failed->Add(m_statictext_install_failed, 0, wxALIGN_CENTER | wxALL, 5); - auto m_install_hyperlink = new wxHyperlinkCtrl(m_panel_install_failed, wxID_ANY, _L("click here to see more info"), install_failed_url, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE); + // ORCA standardized HyperLink + auto m_install_hyperlink = new HyperLink(m_panel_install_failed, _L("click here to see more info"), install_failed_url); sizer_install_failed->Add(m_install_hyperlink, 0, wxALIGN_CENTER | wxALL, 5); diff --git a/src/slic3r/GUI/FilamentGroupPopup.cpp b/src/slic3r/GUI/FilamentGroupPopup.cpp index 89c9dbd8de..df78e69a80 100644 --- a/src/slic3r/GUI/FilamentGroupPopup.cpp +++ b/src/slic3r/GUI/FilamentGroupPopup.cpp @@ -147,15 +147,10 @@ FilamentGroupPopup::FilamentGroupPopup(wxWindow *parent) : PopupWindow(parent, w { wxBoxSizer *button_sizer = new wxBoxSizer(wxHORIZONTAL); - const std::string wiki_path = Slic3r::resources_dir() + "/wiki/filament_group_wiki_zh.html"; + const std::string wiki_path = Slic3r::resources_dir() + "/wiki/filament_group_wiki_zh.html"; // NEEDFIX this link is broken auto* wiki_sizer = new wxBoxSizer(wxHORIZONTAL); - wiki_link = new wxStaticText(this, wxID_ANY, _L("Learn more")); - wiki_link->SetBackgroundColour(BackGroundColor); - wiki_link->SetForegroundColour(GreenColor); - wiki_link->SetFont(Label::Body_12.Underlined()); - wiki_link->SetCursor(wxCursor(wxCURSOR_HAND)); - wiki_link->Bind(wxEVT_LEFT_DOWN, [wiki_path](wxMouseEvent &) { wxLaunchDefaultBrowser(wxString(wiki_path.c_str())); }); + wiki_link = new HyperLink(this, _L("Wiki Guide"), wxString(wiki_path.c_str())); // ORCA wiki_sizer->Add(wiki_link, 0, wxALIGN_CENTER | wxALL, FromDIP(3)); button_sizer->Add(wiki_sizer, 0, wxLEFT, horizontal_margin); diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 27816e2b67..2fd25bd520 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -3414,7 +3414,7 @@ void GUI_App::set_side_menu_popup_status(bool status) m_side_popup_status = status; } -void GUI_App::link_to_network_check() +std::string GUI_App::link_to_network_check() { std::string url; std::string country_code = app_config->get_country_code(); @@ -3429,10 +3429,11 @@ void GUI_App::link_to_network_check() else { url = "https://status.bambulab.com"; } - wxLaunchDefaultBrowser(url); + //wxLaunchDefaultBrowser(url); + return url; // ORCA } -void GUI_App::link_to_lan_only_wiki() +std::string GUI_App::link_to_lan_only_wiki() { std::string url; std::string country_code = app_config->get_country_code(); @@ -3446,7 +3447,8 @@ void GUI_App::link_to_lan_only_wiki() else { url = "https://wiki.bambulab.com/en/knowledge-sharing/enable-lan-mode"; } - wxLaunchDefaultBrowser(url); + //wxLaunchDefaultBrowser(url); + return url; // ORCA } bool GUI_App::tabs_as_menu() const diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index fbf61a5084..e8b696f7d3 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -406,8 +406,8 @@ public: //update side popup status bool get_side_menu_popup_status(); void set_side_menu_popup_status(bool status); - void link_to_network_check(); - void link_to_lan_only_wiki(); + std::string link_to_network_check(); // ORCA + std::string link_to_lan_only_wiki(); // ORCA const wxColour& get_label_clr_modified() { return m_color_label_modified; } const wxColour& get_label_clr_sys() { return m_color_label_sys; } diff --git a/src/slic3r/GUI/MsgDialog.cpp b/src/slic3r/GUI/MsgDialog.cpp index 0e6e1a324d..049a6b00f2 100644 --- a/src/slic3r/GUI/MsgDialog.cpp +++ b/src/slic3r/GUI/MsgDialog.cpp @@ -586,7 +586,8 @@ wxBoxSizer *Newer3mfVersionDialog::get_msg_sizer() if (file_version_newer) { text1 = new wxStaticText(this, wxID_ANY, _L("The 3MF file version is in Beta and it is newer than the current OrcaSlicer version.")); wxStaticText * text2 = new wxStaticText(this, wxID_ANY, _L("If you would like to try Orca Slicer Beta, you may click to")); - wxHyperlinkCtrl *github_link = new wxHyperlinkCtrl(this, wxID_ANY, _L("Download Beta Version"), "https://github.com/bambulab/BambuStudio/releases"); + // ORCA standardized HyperLink + HyperLink * github_link = new HyperLink(this, _L("Download Beta Version"), "https://github.com/SoftFever/OrcaSlicer/releases"); horizontal_sizer->Add(text2, 0, wxEXPAND, 0); horizontal_sizer->Add(github_link, 0, wxEXPAND | wxLEFT, 5); @@ -672,11 +673,9 @@ NetworkErrorDialog::NetworkErrorDialog(wxWindow* parent) wxBoxSizer* sizer_link = new wxBoxSizer(wxVERTICAL); - m_link_server_state = new wxHyperlinkCtrl(this, wxID_ANY, _L("Check the status of current system services"), ""); + // ORCA standardized HyperLink + m_link_server_state = new HyperLink(this, _L("Check the status of current system services"), wxGetApp().link_to_network_check()); m_link_server_state->SetFont(::Label::Body_13); - m_link_server_state->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {wxGetApp().link_to_network_check(); }); - m_link_server_state->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_HAND); }); - m_link_server_state->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_ARROW); }); sizer_link->Add(m_link_server_state, 0, wxALL, 0); @@ -690,11 +689,9 @@ NetworkErrorDialog::NetworkErrorDialog(wxWindow* parent) m_text_proposal->SetFont(::Label::Body_14); m_text_proposal->SetForegroundColour(0x323A3C); - m_text_wiki = new wxHyperlinkCtrl(this, wxID_ANY, _L("How to use LAN only mode"), ""); + // ORCA standardized HyperLink + m_text_wiki = new HyperLink(this, _L("How to use LAN only mode"), wxGetApp().link_to_lan_only_wiki()); m_text_wiki->SetFont(::Label::Body_13); - m_text_wiki->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {wxGetApp().link_to_lan_only_wiki(); }); - m_text_wiki->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_HAND); }); - m_text_wiki->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_ARROW); }); sizer_help->Add(m_text_proposal, 0, wxEXPAND, 0); sizer_help->Add(m_text_wiki, 0, wxALL, 0); diff --git a/src/slic3r/GUI/MsgDialog.hpp b/src/slic3r/GUI/MsgDialog.hpp index 7b4eb71612..bb3abde75c 100644 --- a/src/slic3r/GUI/MsgDialog.hpp +++ b/src/slic3r/GUI/MsgDialog.hpp @@ -14,6 +14,7 @@ #include "Widgets/Button.hpp" #include "Widgets/CheckBox.hpp" #include "Widgets/TextInput.hpp" +#include "Widgets/HyperLink.hpp" #include "BBLStatusBar.hpp" #include "BBLStatusBarSend.hpp" #include "libslic3r/Semver.hpp" @@ -424,9 +425,9 @@ public: private: Label* m_text_basic; - wxHyperlinkCtrl* m_link_server_state; + HyperLink* m_link_server_state; // ORCA Label* m_text_proposal; - wxHyperlinkCtrl* m_text_wiki; + HyperLink* m_text_wiki; // ORCA Button * m_button_confirm; public: diff --git a/src/slic3r/GUI/NotificationManager.hpp b/src/slic3r/GUI/NotificationManager.hpp index 9abf49323a..c9bb132f68 100644 --- a/src/slic3r/GUI/NotificationManager.hpp +++ b/src/slic3r/GUI/NotificationManager.hpp @@ -980,7 +980,7 @@ private: NotificationData{NotificationType::BBLUserPresetExceedLimit, NotificationLevel::WarningNotificationLevel, BBL_NOTICE_MAX_INTERVAL, _u8L("The number of user presets cached in the cloud has exceeded the upper limit, newly created user presets can only be used locally."), - _u8L("Wiki"), + _u8L("Wiki Guide"), [](wxEvtHandler* evnthndlr) { wxLaunchDefaultBrowser("https://wiki.bambulab.com/en/software/bambu-studio/3rd-party-printer-profile#cloud-user-presets-limit"); return false; diff --git a/src/slic3r/GUI/ObjColorDialog.cpp b/src/slic3r/GUI/ObjColorDialog.cpp index 6d3b277c03..7575777507 100644 --- a/src/slic3r/GUI/ObjColorDialog.cpp +++ b/src/slic3r/GUI/ObjColorDialog.cpp @@ -47,14 +47,7 @@ wxBoxSizer* ObjColorDialog::create_btn_sizer(long flags,bool exist_error) auto btn_sizer = new wxBoxSizer(wxHORIZONTAL); if (!exist_error) { btn_sizer->AddSpacer(FromDIP(25)); - wxStaticText *tips = new wxStaticText(this, wxID_ANY, _L("Open Wiki for more information >")); - /* wxFont font(10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false); - font.SetUnderlined(true); - tips->SetFont(font);*/ - auto font = tips->GetFont(); - font.SetUnderlined(true); - tips->SetFont(font); - tips->SetForegroundColour(wxColour("#009687")); + auto *tips = new HyperLink(this, _L("Wiki Guide")); // ORCA tips->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { bool is_zh = wxGetApp().app_config->get("language") == "zh_CN"; if (is_zh) { diff --git a/src/slic3r/GUI/PrintOptionsDialog.cpp b/src/slic3r/GUI/PrintOptionsDialog.cpp index 02329a36b7..56cc764356 100644 --- a/src/slic3r/GUI/PrintOptionsDialog.cpp +++ b/src/slic3r/GUI/PrintOptionsDialog.cpp @@ -1153,11 +1153,8 @@ PrinterPartsDialog::PrinterPartsDialog(wxWindow* parent) change_nozzle_tips->SetFont(Label::Body_13); change_nozzle_tips->SetForegroundColour(STATIC_TEXT_CAPTION_COL); - m_wiki_link = new Label(single_panel, _L("View wiki")); + m_wiki_link = new HyperLink(single_panel, _L("Wiki Guide")); // ORCA m_wiki_link->SetFont(Label::Body_13); - m_wiki_link->SetForegroundColour(wxColour("#009688")); - m_wiki_link->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) { SetCursor(wxCURSOR_HAND); }); - m_wiki_link->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) { SetCursor(wxCURSOR_ARROW); }); m_wiki_link->Bind(wxEVT_LEFT_DOWN, &PrinterPartsDialog::OnWikiClicked, this); h_tips_sizer->Add(change_nozzle_tips, 0, wxLEFT); @@ -1267,11 +1264,8 @@ PrinterPartsDialog::PrinterPartsDialog(wxWindow* parent) multiple_change_nozzle_tips->SetFont(Label::Body_13); multiple_change_nozzle_tips->SetForegroundColour(STATIC_TEXT_CAPTION_COL); - multiple_wiki_link = new Label(multiple_panel, _L("View wiki")); + multiple_wiki_link = new HyperLink(multiple_panel, _L("Wiki Guide")); // ORCA multiple_wiki_link->SetFont(Label::Body_13); - multiple_wiki_link->SetForegroundColour(wxColour("#009688")); - multiple_wiki_link->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) { SetCursor(wxCURSOR_HAND); }); - multiple_wiki_link->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) { SetCursor(wxCURSOR_ARROW); }); multiple_wiki_link->Bind(wxEVT_LEFT_DOWN, &PrinterPartsDialog::OnWikiClicked, this); wxSizer* multiple_change_tips_sizer = new wxBoxSizer(wxHORIZONTAL); diff --git a/src/slic3r/GUI/PrintOptionsDialog.hpp b/src/slic3r/GUI/PrintOptionsDialog.hpp index d555c8237b..9918cfb80e 100644 --- a/src/slic3r/GUI/PrintOptionsDialog.hpp +++ b/src/slic3r/GUI/PrintOptionsDialog.hpp @@ -16,6 +16,7 @@ #include "Widgets/CheckBox.hpp" #include "Widgets/StaticLine.hpp" #include "Widgets/ComboBox.hpp" +#include "Widgets/HyperLink.hpp" // Previous definitions class SwitchBoard; @@ -33,7 +34,7 @@ protected: Label* nozzle_flow_type_label; ComboBox* nozzle_flow_type_checkbox; Label *change_nozzle_tips; - Label* m_wiki_link; + HyperLink* m_wiki_link; Button* m_single_update_nozzle_button; Button* m_multiple_update_nozzle_button; @@ -46,7 +47,7 @@ protected: ComboBox *multiple_right_nozzle_flow_checkbox; Label *multiple_change_nozzle_tips; - Label* multiple_wiki_link; + HyperLink* multiple_wiki_link; wxPanel *single_panel; wxPanel *multiple_panel; diff --git a/src/slic3r/GUI/ReleaseNote.cpp b/src/slic3r/GUI/ReleaseNote.cpp index 2dd0a7baf2..9b156c5228 100644 --- a/src/slic3r/GUI/ReleaseNote.cpp +++ b/src/slic3r/GUI/ReleaseNote.cpp @@ -1510,7 +1510,8 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow *parent) m_tip4->SetMinSize(wxSize(FromDIP(355), -1)); m_tip4->SetMaxSize(wxSize(FromDIP(355), -1)); - m_trouble_shoot = new wxHyperlinkCtrl(this, wxID_ANY, "How to trouble shooting", ""); + // ORCA standardized HyperLink + m_trouble_shoot = new HyperLink(this, "How to trouble shooting"); m_img_help = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("input_access_code_x1_en", this, 198), wxDefaultPosition, wxSize(FromDIP(355), -1), 0); diff --git a/src/slic3r/GUI/ReleaseNote.hpp b/src/slic3r/GUI/ReleaseNote.hpp index 838df0efd5..37b7c58935 100644 --- a/src/slic3r/GUI/ReleaseNote.hpp +++ b/src/slic3r/GUI/ReleaseNote.hpp @@ -326,7 +326,7 @@ public: wxStaticBitmap* m_img_step1{ nullptr }; wxStaticBitmap* m_img_step2{ nullptr }; wxStaticBitmap* m_img_step3{ nullptr }; - wxHyperlinkCtrl* m_trouble_shoot{ nullptr }; + HyperLink* m_trouble_shoot{ nullptr }; // ORCA wxTimer* closeTimer{ nullptr }; int closeCount{3}; bool m_show_access_code{ false }; diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index 56ecd56ce2..eeb472e98a 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -688,12 +688,9 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater) sizer_extra_info->Add(st_title_extra_info_doc, 0, wxALL, 0); sizer_extra_info->Add(m_st_txt_extra_info, 0, wxALL, 0); - - m_link_network_state = new wxHyperlinkCtrl(m_sw_print_failed_info, wxID_ANY,_L("Check the status of current system services"),""); + // ORCA standardized HyperLink + m_link_network_state = new HyperLink(m_sw_print_failed_info, _L("Check the status of current system services"), wxGetApp().link_to_network_check()); m_link_network_state->SetFont(::Label::Body_12); - m_link_network_state->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {wxGetApp().link_to_network_check();}); - m_link_network_state->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {m_link_network_state->SetCursor(wxCURSOR_HAND);}); - m_link_network_state->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {m_link_network_state->SetCursor(wxCURSOR_ARROW);}); sizer_print_failed_info->Add(m_link_network_state, 0, wxLEFT, 5); sizer_print_failed_info->Add(sizer_error_code, 0, wxLEFT, 5); diff --git a/src/slic3r/GUI/SelectMachine.hpp b/src/slic3r/GUI/SelectMachine.hpp index 42bf251b7c..302b37b553 100644 --- a/src/slic3r/GUI/SelectMachine.hpp +++ b/src/slic3r/GUI/SelectMachine.hpp @@ -42,6 +42,7 @@ #include "Widgets/ComboBox.hpp" #include "Widgets/ScrolledWindow.hpp" #include "Widgets/PopupWindow.hpp" +#include "Widgets/HyperLink.hpp" // ORCA #include #include @@ -371,7 +372,7 @@ protected: Label* m_st_txt_error_desc{nullptr}; Label* m_st_txt_extra_info{nullptr}; Label* m_ams_backup_tip{nullptr}; - wxHyperlinkCtrl* m_link_network_state{ nullptr }; + HyperLink* m_link_network_state{ nullptr }; // ORCA wxSimplebook* m_rename_switch_panel{nullptr}; wxSimplebook* m_simplebook{nullptr}; wxStaticText* m_rename_text{nullptr}; diff --git a/src/slic3r/GUI/SelectMachinePop.cpp b/src/slic3r/GUI/SelectMachinePop.cpp index aef994d067..ddca6df8a7 100644 --- a/src/slic3r/GUI/SelectMachinePop.cpp +++ b/src/slic3r/GUI/SelectMachinePop.cpp @@ -596,8 +596,9 @@ void SelectMachinePopup::update_other_devices() m_placeholder_panel = new wxWindow(m_scrolledWindow, wxID_ANY, wxDefaultPosition, wxSize(-1,FromDIP(26))); wxBoxSizer* placeholder_sizer = new wxBoxSizer(wxVERTICAL); - m_hyperlink = new wxHyperlinkCtrl(m_placeholder_panel, wxID_ANY, _L("Can't find my devices?"), wxT("https://wiki.bambulab.com/en/software/bambu-studio/failed-to-connect-printer"), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE); - m_hyperlink->SetNormalColour(StateColor::darkModeColorFor("#009789")); + // ORCA standardized HyperLink + m_hyperlink = new HyperLink(m_placeholder_panel, _L("Can't find my devices?"), wxT("https://wiki.bambulab.com/en/software/bambu-studio/failed-to-connect-printer")); + m_hyperlink->SetFont(::Label::Body_12); placeholder_sizer->Add(m_hyperlink, 0, wxALIGN_CENTER | wxALL, 5); diff --git a/src/slic3r/GUI/SelectMachinePop.hpp b/src/slic3r/GUI/SelectMachinePop.hpp index d1a34f9b3a..757cb08ed5 100644 --- a/src/slic3r/GUI/SelectMachinePop.hpp +++ b/src/slic3r/GUI/SelectMachinePop.hpp @@ -180,7 +180,7 @@ private: PinCodePanel* m_panel_ping_code{nullptr}; PinCodePanel* m_panel_direct_connection{nullptr}; wxWindow* m_placeholder_panel{nullptr}; - wxHyperlinkCtrl* m_hyperlink{nullptr}; + HyperLink* m_hyperlink{nullptr}; // ORCA Label* m_ping_code_text{nullptr}; wxStaticBitmap* m_img_ping_code{nullptr}; wxBoxSizer * m_sizer_body{nullptr}; diff --git a/src/slic3r/GUI/SendToPrinter.cpp b/src/slic3r/GUI/SendToPrinter.cpp index 5f5cf9925e..670a8bcad4 100644 --- a/src/slic3r/GUI/SendToPrinter.cpp +++ b/src/slic3r/GUI/SendToPrinter.cpp @@ -446,11 +446,9 @@ SendToPrinterDialog::SendToPrinterDialog(Plater *plater) sizer_extra_info->Add(st_title_extra_info_doc, 0, wxALL, 0); sizer_extra_info->Add(m_st_txt_extra_info, 0, wxALL, 0); - m_link_network_state = new wxHyperlinkCtrl(m_sw_print_failed_info, wxID_ANY,_L("Check the status of current system services"),""); + // ORCA standardized HyperLink + m_link_network_state = new HyperLink(m_sw_print_failed_info, _L("Check the status of current system services"), wxGetApp().link_to_network_check()); m_link_network_state->SetFont(::Label::Body_12); - m_link_network_state->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {wxGetApp().link_to_network_check(); }); - m_link_network_state->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {m_link_network_state->SetCursor(wxCURSOR_HAND); }); - m_link_network_state->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {m_link_network_state->SetCursor(wxCURSOR_ARROW); }); sizer_print_failed_info->Add(m_link_network_state, 0, wxLEFT, 5); sizer_print_failed_info->Add(sizer_error_code, 0, wxLEFT, 5); diff --git a/src/slic3r/GUI/SendToPrinter.hpp b/src/slic3r/GUI/SendToPrinter.hpp index de284e31d6..14493a1f20 100644 --- a/src/slic3r/GUI/SendToPrinter.hpp +++ b/src/slic3r/GUI/SendToPrinter.hpp @@ -110,7 +110,7 @@ private: Label* m_st_txt_error_code{ nullptr }; Label* m_st_txt_error_desc{ nullptr }; Label* m_st_txt_extra_info{ nullptr }; - wxHyperlinkCtrl* m_link_network_state{ nullptr }; + HyperLink* m_link_network_state{ nullptr }; StateColor btn_bg_enable; wxBoxSizer* rename_sizer_v{ nullptr }; wxBoxSizer* rename_sizer_h{ nullptr }; diff --git a/src/slic3r/GUI/StepMeshDialog.cpp b/src/slic3r/GUI/StepMeshDialog.cpp index b1b8041cd2..196c0ff8e0 100644 --- a/src/slic3r/GUI/StepMeshDialog.cpp +++ b/src/slic3r/GUI/StepMeshDialog.cpp @@ -117,14 +117,11 @@ StepMeshDialog::StepMeshDialog(wxWindow* parent, Slic3r::Step& file, double line wxBoxSizer* tips_sizer = new wxBoxSizer(wxVERTICAL); wxStaticText* info = new wxStaticText(this, wxID_ANY, _L("Smaller linear and angular deflections result in higher-quality transformations but increase the processing time.")); info->SetForegroundColour(StateColor::darkModeColorFor(FONT_COLOR)); - wxStaticText *tips = new wxStaticText(this, wxID_ANY, _L("View Wiki for more information")); - wxFont font(10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false); - font.SetUnderlined(true); - tips->SetForegroundColour(StateColor::darkModeColorFor(wxColour(0, 151, 137))); - tips->SetFont(font); - tips->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) { - wxLaunchDefaultBrowser("https://www.orcaslicer.com/wiki/stl-transformation"); - }); + + // ORCA standardized HyperLink + HyperLink *tips = new HyperLink(this, _L("Wiki Guide"), "https://www.orcaslicer.com/wiki/stl-transformation"); + tips->SetFont(::Label::Body_12); + info->Wrap(FromDIP(400)); tips_sizer->Add(info, 0, wxALIGN_LEFT); tips_sizer->Add(tips, 0, wxALIGN_LEFT); diff --git a/src/slic3r/GUI/WebUserLoginDialog.cpp b/src/slic3r/GUI/WebUserLoginDialog.cpp index fba6547f65..2522efbf4f 100644 --- a/src/slic3r/GUI/WebUserLoginDialog.cpp +++ b/src/slic3r/GUI/WebUserLoginDialog.cpp @@ -25,6 +25,7 @@ #include #include +#include // ORCA using namespace std; using namespace nlohmann; @@ -57,11 +58,12 @@ ZUserLogin::ZUserLogin() : wxDialog((wxWindow *) (wxGetApp().mainframe), wxID_AN m_message->SetForegroundColour(*wxBLACK); m_message->Wrap(FromDIP(360)); - auto m_download_hyperlink = new wxHyperlinkCtrl(this, wxID_ANY, _L("Click here to download it."), wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE); - m_download_hyperlink->Bind(wxEVT_HYPERLINK, [this](wxCommandEvent& event) { + // ORCA standardized HyperLink + auto m_download_hyperlink = new HyperLink(this, _L("Click here to download it.")); + m_download_hyperlink->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& event) { this->Close(); wxGetApp().ShowDownNetPluginDlg(); - }); + }); m_sizer_main->Add(m_message, 0, wxALIGN_CENTER | wxALL, FromDIP(15)); m_sizer_main->Add(m_download_hyperlink, 0, wxALIGN_CENTER | wxALL, FromDIP(10)); m_sizer_main->Add(0, 0, 1, wxBOTTOM, 10); diff --git a/src/slic3r/GUI/Widgets/HyperLink.cpp b/src/slic3r/GUI/Widgets/HyperLink.cpp new file mode 100644 index 0000000000..7fdb236199 --- /dev/null +++ b/src/slic3r/GUI/Widgets/HyperLink.cpp @@ -0,0 +1,49 @@ +#include "HyperLink.hpp" +#include "Label.hpp" + +namespace Slic3r { namespace GUI { + +HyperLink::HyperLink(wxWindow* parent, const wxString& label, const wxString& url, long style) + : wxStaticText(parent, wxID_ANY, label) + , m_url(url) + , m_normalColor(wxColour("#009687")) // used slightly different color otherwise automatically uses ColorForDark that not visible enough + , m_hoverColor(wxColour("#26A69A")) +{ + SetForegroundColour(m_normalColor); + HyperLink::SetFont(Label::Head_14); + SetCursor(wxCursor(wxCURSOR_HAND)); + + if (!m_url.IsEmpty()) + SetToolTip(m_url); + + Bind(wxEVT_LEFT_DOWN, ([this](wxMouseEvent& e) { + if (!m_url.IsEmpty()) + wxLaunchDefaultBrowser(m_url); + })); + + Bind(wxEVT_ENTER_WINDOW, ([this](wxMouseEvent& e) { + SetForegroundColour(m_hoverColor); + Refresh(); + })); + Bind(wxEVT_LEAVE_WINDOW, ([this](wxMouseEvent& e) { + SetForegroundColour(m_normalColor); + Refresh(); + })); +} + +bool HyperLink::SetFont(const wxFont& font) +{ // ensure it stays underlined + wxFont f = font; + f.SetUnderlined(true); + return wxStaticText::SetFont(f); +} + +void HyperLink::SetURL(const wxString& url) +{ + m_url = url; + SetToolTip(m_url); +} + +wxString HyperLink::GetURL() const { return m_url; } + +}} // namespace Slic3r::GUI diff --git a/src/slic3r/GUI/Widgets/HyperLink.hpp b/src/slic3r/GUI/Widgets/HyperLink.hpp new file mode 100644 index 0000000000..48e2245e3b --- /dev/null +++ b/src/slic3r/GUI/Widgets/HyperLink.hpp @@ -0,0 +1,26 @@ +#ifndef slic3r_GUI_HyperLink_hpp_ +#define slic3r_GUI_HyperLink_hpp_ + +#include +#include + +namespace Slic3r { namespace GUI { + +class HyperLink : public wxStaticText +{ +public: + HyperLink(wxWindow* parent, const wxString& label = wxEmptyString, const wxString& url = wxEmptyString, const long style = 0); + + void SetURL(const wxString& url); + wxString GetURL() const; + + bool SetFont(const wxFont& font); + +private: + wxString m_url; + wxColour m_normalColor; + wxColour m_hoverColor; +}; + +}} // namespace Slic3r::GUI +#endif // !slic3r_GUI_HyperLink_hpp_ diff --git a/src/slic3r/GUI/Widgets/SideTools.cpp b/src/slic3r/GUI/Widgets/SideTools.cpp index 4288647e53..377253e707 100644 --- a/src/slic3r/GUI/Widgets/SideTools.cpp +++ b/src/slic3r/GUI/Widgets/SideTools.cpp @@ -274,8 +274,8 @@ SideTools::SideTools(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxBoxSizer* connection_sizer_V = new wxBoxSizer(wxVERTICAL); wxBoxSizer* connection_sizer_H = new wxBoxSizer(wxHORIZONTAL); - m_hyperlink = new wxHyperlinkCtrl(m_connection_info, wxID_ANY, _L("Failed to connect to the server"), wxT("https://wiki.bambulab.com/en/software/bambu-studio/failed-to-connect-printer"), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE); - m_hyperlink->SetBackgroundColour(wxColour(255, 111, 0)); + // ORCA standardized HyperLink + m_hyperlink = new HyperLink(m_connection_info, _L("Failed to connect to the server"), wxT("https://wiki.bambulab.com/en/software/bambu-studio/failed-to-connect-printer")); m_more_err_open = ScalableBitmap(this, "monitir_err_open", 16); m_more_err_close = ScalableBitmap(this, "monitir_err_close", 16); @@ -328,13 +328,10 @@ SideTools::SideTools(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxBoxSizer* sizer_error_desc = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* sizer_extra_info = new wxBoxSizer(wxHORIZONTAL); - m_link_network_state = new wxHyperlinkCtrl(m_side_error_panel, wxID_ANY,_L("Check the status of current system services"),"",wxDefaultPosition,wxDefaultSize, wxHL_ALIGN_CENTRE |wxST_ELLIPSIZE_END); - m_link_network_state->SetMinSize(wxSize(FromDIP(220), -1)); + // ORCA standardized HyperLink + m_link_network_state = new HyperLink(m_side_error_panel, _L("Check the status of current system services"), wxGetApp().link_to_network_check(), wxST_ELLIPSIZE_END); m_link_network_state->SetMaxSize(wxSize(FromDIP(220), -1)); m_link_network_state->SetFont(::Label::Body_12); - m_link_network_state->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {wxGetApp().link_to_network_check(); }); - m_link_network_state->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {m_link_network_state->SetCursor(wxCURSOR_HAND); }); - m_link_network_state->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {m_link_network_state->SetCursor(wxCURSOR_ARROW); }); auto st_title_error_code = new wxStaticText(m_side_error_panel, wxID_ANY, _L("code"), wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END); auto st_title_error_code_doc = new wxStaticText(m_side_error_panel, wxID_ANY, ": "); diff --git a/src/slic3r/GUI/Widgets/SideTools.hpp b/src/slic3r/GUI/Widgets/SideTools.hpp index 4f1cf7c667..24cbae4fd2 100644 --- a/src/slic3r/GUI/Widgets/SideTools.hpp +++ b/src/slic3r/GUI/Widgets/SideTools.hpp @@ -4,9 +4,9 @@ #include #include #include -#include #include "Button.hpp" #include "Label.hpp" +#include "HyperLink.hpp" // ORCA #include "../GUI/Tabbook.hpp" #include "../DeviceManager.hpp" #include "../wxExtensions.hpp" @@ -99,13 +99,13 @@ public: private: SideToolsPanel* m_side_tools{ nullptr }; Tabbook* m_tabpanel{ nullptr }; - wxHyperlinkCtrl* m_link_network_state{ nullptr }; + HyperLink* m_link_network_state{ nullptr }; // ORCA Label* m_st_txt_error_code{ nullptr }; Label* m_st_txt_error_desc{ nullptr }; Label* m_st_txt_extra_info{ nullptr }; wxWindow* m_side_error_panel{ nullptr }; Button* m_connection_info{ nullptr }; - wxHyperlinkCtrl* m_hyperlink{ nullptr }; + HyperLink* m_hyperlink{ nullptr }; // ORCA ScalableButton* m_more_button{ nullptr }; ScalableBitmap m_more_err_open; ScalableBitmap m_more_err_close; diff --git a/src/slic3r/GUI/calib_dlg.cpp b/src/slic3r/GUI/calib_dlg.cpp index ffd995a89b..79735f6901 100644 --- a/src/slic3r/GUI/calib_dlg.cpp +++ b/src/slic3r/GUI/calib_dlg.cpp @@ -5,6 +5,7 @@ #include #include "MainFrame.hpp" #include "Widgets/DialogButtons.hpp" +#include "Widgets/HyperLink.hpp" #include #include #include "libslic3r/PrintConfig.hpp" @@ -173,22 +174,14 @@ PA_Calibration_Dlg::PA_Calibration_Dlg(wxWindow* parent, wxWindowID id, Plater* v_sizer->Add(settings_sizer, 0, wxTOP | wxRIGHT | wxLEFT | wxEXPAND, FromDIP(10)); v_sizer->AddSpacer(FromDIP(5)); - // Help links - auto help_sizer = new wxBoxSizer(wxVERTICAL); - auto help_link_pa = new wxHyperlinkCtrl(this, wxID_ANY, _L("Pressure Advance Guide"), - "https://www.orcaslicer.com/wiki/pressure-advance-calib"); - help_link_pa->SetForegroundColour(wxColour("#1890FF")); - help_sizer->Add(help_link_pa, 0, wxALL, FromDIP(5)); - - auto help_link_apa = new wxHyperlinkCtrl(this, wxID_ANY, _L("Adaptive Pressure Advance Guide"), - "https://www.orcaslicer.com/wiki/adaptive-pressure-advance-calib"); - help_link_apa->SetForegroundColour(wxColour("#1890FF")); - help_sizer->Add(help_link_apa, 0, wxALL, FromDIP(5)); - - v_sizer->Add(help_sizer, 0, wxALL, FromDIP(10)); - auto dlg_btns = new DialogButtons(this, {"OK"}); - v_sizer->Add(dlg_btns , 0, wxEXPAND); + + auto bottom_sizer = new wxBoxSizer(wxHORIZONTAL); + auto wiki = new HyperLink(this, _L("Wiki Guide"), "https://www.orcaslicer.com/wiki/pressure-advance-calib"); + bottom_sizer->Add(wiki, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(20)); + bottom_sizer->AddStretchSpacer(); + bottom_sizer->Add(dlg_btns, 0, wxEXPAND); + v_sizer->Add(bottom_sizer, 0, wxEXPAND); dlg_btns->GetOK()->Bind(wxEVT_BUTTON, &PA_Calibration_Dlg::on_start, this); @@ -399,13 +392,14 @@ Temp_Calibration_Dlg::Temp_Calibration_Dlg(wxWindow* parent, wxWindowID id, Plat v_sizer->Add(settings_sizer, 0, wxTOP | wxRIGHT | wxLEFT | wxEXPAND, FromDIP(10)); v_sizer->AddSpacer(FromDIP(5)); - auto help_link = new wxHyperlinkCtrl(this, wxID_ANY, _L("Wiki Guide: Temperature Calibration"), - "https://www.orcaslicer.com/wiki/temp-calib"); - help_link->SetForegroundColour(wxColour("#1890FF")); - v_sizer->Add(help_link, 0, wxALL, FromDIP(10)); - auto dlg_btns = new DialogButtons(this, {"OK"}); - v_sizer->Add(dlg_btns , 0, wxEXPAND); + + auto bottom_sizer = new wxBoxSizer(wxHORIZONTAL); + auto wiki = new HyperLink(this, _L("Wiki Guide"), "https://www.orcaslicer.com/wiki/temp-calib"); + bottom_sizer->Add(wiki, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(20)); + bottom_sizer->AddStretchSpacer(); + bottom_sizer->Add(dlg_btns, 0, wxEXPAND); + v_sizer->Add(bottom_sizer, 0, wxEXPAND); dlg_btns->GetOK()->Bind(wxEVT_BUTTON, &Temp_Calibration_Dlg::on_start, this); @@ -578,13 +572,14 @@ MaxVolumetricSpeed_Test_Dlg::MaxVolumetricSpeed_Test_Dlg(wxWindow* parent, wxWin v_sizer->Add(settings_sizer, 0, wxTOP | wxRIGHT | wxLEFT | wxEXPAND, FromDIP(10)); v_sizer->AddSpacer(FromDIP(5)); - auto help_link = new wxHyperlinkCtrl(this, wxID_ANY, _L("Wiki Guide: Volumetric Speed Calibration"), - "https://www.orcaslicer.com/wiki/volumetric-speed-calib"); - help_link->SetForegroundColour(wxColour("#1890FF")); - v_sizer->Add(help_link, 0, wxALL, FromDIP(10)); - auto dlg_btns = new DialogButtons(this, {"OK"}); - v_sizer->Add(dlg_btns , 0, wxEXPAND); + + auto bottom_sizer = new wxBoxSizer(wxHORIZONTAL); + auto wiki = new HyperLink(this, _L("Wiki Guide"), "https://www.orcaslicer.com/wiki/volumetric-speed-calib"); + bottom_sizer->Add(wiki, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(20)); + bottom_sizer->AddStretchSpacer(); + bottom_sizer->Add(dlg_btns, 0, wxEXPAND); + v_sizer->Add(bottom_sizer, 0, wxEXPAND); dlg_btns->GetOK()->Bind(wxEVT_BUTTON, &MaxVolumetricSpeed_Test_Dlg::on_start, this); @@ -684,13 +679,14 @@ VFA_Test_Dlg::VFA_Test_Dlg(wxWindow* parent, wxWindowID id, Plater* plater) v_sizer->Add(settings_sizer, 0, wxTOP | wxRIGHT | wxLEFT | wxEXPAND, FromDIP(10)); v_sizer->AddSpacer(FromDIP(5)); - auto help_link = new wxHyperlinkCtrl(this, wxID_ANY, _L("Wiki Guide: VFA"), - "https://www.orcaslicer.com/wiki/vfa-calib"); - help_link->SetForegroundColour(wxColour("#1890FF")); - v_sizer->Add(help_link, 0, wxALL, FromDIP(10)); - auto dlg_btns = new DialogButtons(this, {"OK"}); - v_sizer->Add(dlg_btns , 0, wxEXPAND); + + auto bottom_sizer = new wxBoxSizer(wxHORIZONTAL); + auto wiki = new HyperLink(this, _L("Wiki Guide"), "https://www.orcaslicer.com/wiki/vfa-calib"); + bottom_sizer->Add(wiki, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(20)); + bottom_sizer->AddStretchSpacer(); + bottom_sizer->Add(dlg_btns, 0, wxEXPAND); + v_sizer->Add(bottom_sizer, 0, wxEXPAND); dlg_btns->GetOK()->Bind(wxEVT_BUTTON, &VFA_Test_Dlg::on_start, this); @@ -791,13 +787,14 @@ Retraction_Test_Dlg::Retraction_Test_Dlg(wxWindow* parent, wxWindowID id, Plater v_sizer->Add(settings_sizer, 0, wxTOP | wxRIGHT | wxLEFT | wxEXPAND, FromDIP(10)); v_sizer->AddSpacer(FromDIP(5)); - auto help_link = new wxHyperlinkCtrl(this, wxID_ANY, _L("Wiki Guide: Retraction Calibration"), - "https://www.orcaslicer.com/wiki/retraction-calib"); - help_link->SetForegroundColour(wxColour("#1890FF")); - v_sizer->Add(help_link, 0, wxALL, FromDIP(10)); - auto dlg_btns = new DialogButtons(this, {"OK"}); - v_sizer->Add(dlg_btns , 0, wxEXPAND); + + auto bottom_sizer = new wxBoxSizer(wxHORIZONTAL); + auto wiki = new HyperLink(this, _L("Wiki Guide"), "https://www.orcaslicer.com/wiki/retraction-calib"); + bottom_sizer->Add(wiki, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(20)); + bottom_sizer->AddStretchSpacer(); + bottom_sizer->Add(dlg_btns, 0, wxEXPAND); + v_sizer->Add(bottom_sizer, 0, wxEXPAND); dlg_btns->GetOK()->Bind(wxEVT_BUTTON, &Retraction_Test_Dlg::on_start, this); @@ -968,13 +965,14 @@ Input_Shaping_Freq_Test_Dlg::Input_Shaping_Freq_Test_Dlg(wxWindow* parent, wxWin v_sizer->Add(settings_sizer, 0, wxTOP | wxRIGHT | wxLEFT | wxEXPAND, FromDIP(10)); v_sizer->AddSpacer(FromDIP(5)); - auto help_link = new wxHyperlinkCtrl(this, wxID_ANY, _L("Wiki Guide: Input Shaping Calibration"), - "https://www.orcaslicer.com/wiki/input-shaping-calib"); - help_link->SetForegroundColour(wxColour("#1890FF")); - v_sizer->Add(help_link, 0, wxALL, FromDIP(10)); - auto dlg_btns = new DialogButtons(this, {"OK"}); - v_sizer->Add(dlg_btns , 0, wxEXPAND); + + auto bottom_sizer = new wxBoxSizer(wxHORIZONTAL); + auto wiki = new HyperLink(this, _L("Wiki Guide"), "https://www.orcaslicer.com/wiki/input-shaping-calib"); + bottom_sizer->Add(wiki, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(20)); + bottom_sizer->AddStretchSpacer(); + bottom_sizer->Add(dlg_btns, 0, wxEXPAND); + v_sizer->Add(bottom_sizer, 0, wxEXPAND); dlg_btns->GetOK()->Bind(wxEVT_BUTTON, &Input_Shaping_Freq_Test_Dlg::on_start, this); @@ -1165,13 +1163,14 @@ Input_Shaping_Damp_Test_Dlg::Input_Shaping_Damp_Test_Dlg(wxWindow* parent, wxWin v_sizer->Add(settings_sizer, 0, wxTOP | wxRIGHT | wxLEFT | wxEXPAND, FromDIP(10)); v_sizer->AddSpacer(FromDIP(5)); - auto help_link = new wxHyperlinkCtrl(this, wxID_ANY, _L("Wiki Guide: Input Shaping Calibration"), - "https://www.orcaslicer.com/wiki/input-shaping-calib"); - help_link->SetForegroundColour(wxColour("#1890FF")); - v_sizer->Add(help_link, 0, wxALL, FromDIP(10)); - auto dlg_btns = new DialogButtons(this, {"OK"}); - v_sizer->Add(dlg_btns , 0, wxEXPAND); + + auto bottom_sizer = new wxBoxSizer(wxHORIZONTAL); + auto wiki = new HyperLink(this, _L("Wiki Guide"), "https://www.orcaslicer.com/wiki/input-shaping-calib"); + bottom_sizer->Add(wiki, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(20)); + bottom_sizer->AddStretchSpacer(); + bottom_sizer->Add(dlg_btns, 0, wxEXPAND); + v_sizer->Add(bottom_sizer, 0, wxEXPAND); dlg_btns->GetOK()->Bind(wxEVT_BUTTON, &Input_Shaping_Damp_Test_Dlg::on_start, this); @@ -1356,13 +1355,14 @@ Cornering_Test_Dlg::Cornering_Test_Dlg(wxWindow* parent, wxWindowID id, Plater* v_sizer->Add(settings_sizer, 0, wxTOP | wxRIGHT | wxLEFT | wxEXPAND, FromDIP(10)); v_sizer->AddSpacer(FromDIP(5)); - auto help_link = new wxHyperlinkCtrl(this, wxID_ANY, _L("Wiki Guide: Cornering Calibration"), - "https://www.orcaslicer.com/wiki/cornering-calib"); - help_link->SetForegroundColour(wxColour("#1890FF")); - v_sizer->Add(help_link, 0, wxALL, FromDIP(10)); - auto dlg_btns = new DialogButtons(this, {"OK"}); - v_sizer->Add(dlg_btns , 0, wxEXPAND); + + auto bottom_sizer = new wxBoxSizer(wxHORIZONTAL); + auto wiki = new HyperLink(this, _L("Wiki Guide"), "https://www.orcaslicer.com/wiki/cornering-calib"); + bottom_sizer->Add(wiki, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(20)); + bottom_sizer->AddStretchSpacer(); + bottom_sizer->Add(dlg_btns, 0, wxEXPAND); + v_sizer->Add(bottom_sizer, 0, wxEXPAND); dlg_btns->GetOK()->Bind(wxEVT_BUTTON, &Cornering_Test_Dlg::on_start, this);