From cd6880171022b945e2e9c5ccb39b68dce5ddb709 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Tue, 5 Jun 2018 22:14:23 +0300 Subject: [PATCH] [Manager] Add HTML TOU support to Wizard Add function to open links in default browser from Wizard TOU. Signed-off-by: Vitalii Koshura --- clientgui/TermsOfUsePage.cpp | 15 ++++++++++++++- clientgui/TermsOfUsePage.h | 3 +++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/clientgui/TermsOfUsePage.cpp b/clientgui/TermsOfUsePage.cpp index 5e779fd9f9..81eb54f696 100644 --- a/clientgui/TermsOfUsePage.cpp +++ b/clientgui/TermsOfUsePage.cpp @@ -54,6 +54,7 @@ BEGIN_EVENT_TABLE( CTermsOfUsePage, wxWizardPageEx ) EVT_WIZARDEX_CANCEL( -1, CTermsOfUsePage::OnCancel ) EVT_RADIOBUTTON( ID_TERMSOFUSEAGREECTRL, CTermsOfUsePage::OnTermsOfUseStatusChange ) EVT_RADIOBUTTON( ID_TERMSOFUSEDISAGREECTRL, CTermsOfUsePage::OnTermsOfUseStatusChange ) + EVT_HTML_LINK_CLICKED(ID_TERMSOFUSECTRL, CTermsOfUsePage::OnLinkClicked) ////@end CTermsOfUsePage event table entries END_EVENT_TABLE() @@ -138,7 +139,19 @@ void CTermsOfUsePage::CreateControls() ////@end CTermsOfUsePage content construction } - + + +void CTermsOfUsePage::OnLinkClicked( wxHtmlLinkEvent& event ) { + wxString url = event.GetLinkInfo().GetHref(); + if (url.StartsWith(wxT("http://")) || url.StartsWith(wxT("https://"))) { + // wxHtmlLinkEvent doesn't have Veto(), but only loads the page if you + // call Skip(). + wxLaunchDefaultBrowser(url); + } else { + event.Skip(); + } + } + /*! * Gets the previous page. */ diff --git a/clientgui/TermsOfUsePage.h b/clientgui/TermsOfUsePage.h index 43a97f84f2..614d2c175c 100644 --- a/clientgui/TermsOfUsePage.h +++ b/clientgui/TermsOfUsePage.h @@ -42,6 +42,9 @@ public: /// Creates the controls and sizers void CreateControls(); + + /// Handles clicks on links + void OnLinkClicked( wxHtmlLinkEvent & event ); ////@begin CTermsOfUsePage event handler declarations