A type distinction for strings that are URLs, and some Doxygen

This commit is contained in:
Paul Licameli 2021-06-06 14:30:59 -04:00
parent 6fe7a7dfa1
commit 3c50935484
4 changed files with 28 additions and 16 deletions

View File

@ -387,12 +387,13 @@ const wxString VerCheckArgs(){
}
// Text of hyperlink to check versions.
const wxString VerCheckHtml(){
const wxString VerCheckHtml()
{
wxStringOutputStream o;
wxTextOutputStream s(o);
s
<< "<center>[["
<< VerCheckUrl()
<< VerCheckUrl().GET()
<< "|"
<< XO("Check Online")
<< "]]</center>\n";
@ -400,7 +401,8 @@ const wxString VerCheckHtml(){
}
// Url with Version check args attached.
const wxString VerCheckUrl(){
const URLString VerCheckUrl()
{
//The version we intend to use for live Audacity.
#define VER_CHECK_URL "https://www.audacityteam.org/download/?"
//For testing of our scriptlet.

View File

@ -13,12 +13,17 @@
class TranslatableString;
class wxString;
#include "Identifier.h"
struct URLStringTag;
//! Distinct type for URLs
using URLString = TaggedIdentifier< URLStringTag >;
AUDACITY_DLL_API wxString HelpText( const wxString & Key );
AUDACITY_DLL_API TranslatableString TitleText( const wxString & Key );
extern AUDACITY_DLL_API const wxString VerCheckArgs();
extern AUDACITY_DLL_API const wxString VerCheckUrl();
extern AUDACITY_DLL_API const URLString VerCheckUrl();
extern AUDACITY_DLL_API const wxString VerCheckHtml();
extern AUDACITY_DLL_API wxString FormatHtmlText( const wxString & Text );

View File

@ -236,8 +236,8 @@ void HelpSystem::ShowHtmlText(wxWindow *pParent,
// Shows help in browser, or possibly in own dialog.
void HelpSystem::ShowHelp(wxWindow *parent,
const wxString &localFileName,
const wxString &remoteURL,
const FilePath &localFileName,
const URLString &remoteURL,
bool bModal,
bool alwaysDefaultBrowser)
{
@ -289,7 +289,7 @@ void HelpSystem::ShowHelp(wxWindow *parent,
// I can't find it'.
// Use Built-in browser to suggest you use the remote url.
wxString Text = HelpText( wxT("remotehelp") );
Text.Replace( wxT("*URL*"), remoteURL );
Text.Replace( wxT("*URL*"), remoteURL.GET() );
// Always make the 'help on the internet' dialog modal.
// Fixes Bug 1411.
ShowHtmlText( parent, XO("Help on the Internet"), Text, false, true );
@ -297,7 +297,7 @@ void HelpSystem::ShowHelp(wxWindow *parent,
else if( HelpMode == wxT("Local") || alwaysDefaultBrowser)
{
// Local file, External browser
OpenInDefaultBrowser( wxString(wxT("file:"))+localFileName );
OpenInDefaultBrowser( L"file:" + localFileName );
}
else
{
@ -310,7 +310,7 @@ void HelpSystem::ShowHelp(wxWindow *parent,
const wxString &PageName,
bool bModal)
{
wxString localHelpPage;
FilePath localHelpPage;
wxString webHelpPath;
wxString webHelpPage;
wxString releasePageName;
@ -515,9 +515,9 @@ void BrowserDialog::UpdateButtons()
}
}
void OpenInDefaultBrowser(const wxHtmlLinkInfo& link)
void OpenInDefaultBrowser(const URLString& link)
{
wxURI uri(link.GetHref());
wxURI uri(link.GET());
wxLaunchDefaultBrowser(uri.BuildURI());
}
@ -555,7 +555,7 @@ void LinkingHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link)
}
else if( href.StartsWith(wxT("mailto:")) || href.StartsWith(wxT("file:")) )
{
OpenInDefaultBrowser( link );
OpenInDefaultBrowser( link.GetHref() );
return;
}
else if( !href.StartsWith( wxT("http:")) && !href.StartsWith( wxT("https:")) )
@ -564,7 +564,7 @@ void LinkingHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link)
}
else
{
OpenInDefaultBrowser(link);
OpenInDefaultBrowser(link.GetHref());
return;
}
wxFrame * pFrame = GetRelatedFrame();

View File

@ -25,6 +25,7 @@
#include <wx/defs.h>
#include "wxPanelWrapper.h" // to inherit
#include "../HelpText.h"
class AudacityProject;
@ -62,21 +63,25 @@ public:
/// OR else links to the internet. Generally using this outside this class
/// is depreciated in favour of the "smarter" overload below, unless there
/// is a good reason for using this form.
/// @param parent Parent window for the dialog
/// @param localFileName Name and path of the file on the local machine
/// file system to be opened. file.name#anchor syntax is allowed, and therefore
/// file names containing a '#' are not (on any platform).
/// @param remoteURL use instead of file if nonempty, and user preferences specify remote,
/// or localFileName is invalid
/// @param bModal Whether the resulting dialogue should be modal or not.
/// Default is modeless dialogue
/// @param alwaysDefaultBrowser Force use of default web browser.
/// Default allows built in browser for local files.
static void ShowHelp(wxWindow *parent,
const wxString &localFileName,
const wxString &remoteURL,
const FilePath &localFileName,
const URLString &remoteURL,
bool bModal = false,
bool alwaysDefaultBrowser = false);
/// Displays a page from the Audacity manual in your browser, if
/// it's available locally, OR else links to the internet.
/// @param parent Parent window for the dialog
/// @param PageName The name of the manual page to display as it is in
/// _development version_ of the manual (i.e. in MediaWiki), _not_ the
/// converted file name used for offline and released manuals.
@ -115,7 +120,7 @@ class ShuttleGui;
#include "HtmlWindow.h" // to inherit
AUDACITY_DLL_API void OpenInDefaultBrowser(const wxHtmlLinkInfo& link);
AUDACITY_DLL_API void OpenInDefaultBrowser(const URLString& link);
/// \brief An HtmlWindow that handles linked clicked - usually the