Use alpha or released or local manual for "help on selection".

Previously this was hard coded to use the online alphamanual.
Some other help-on-errors paths were hardcoded to use the online manual, and did not use local help even if available, so these were changed too.

Also two naming changes in the code:
ShowHelpDialog() became ShowHelp() because it typically shows the help in your browser, only showing the help in a dialog under certain circumstances.
The helpURL parameter became helpPage since it is usually a page name that is then elaborated into a url.
The Link() function became InnerLink().

Some careful http -> https changes made too.
This commit is contained in:
James Crook 2017-08-25 13:54:37 +01:00
parent 4a0a7efd84
commit ce9938787c
18 changed files with 74 additions and 75 deletions

View File

@ -535,7 +535,7 @@ public:
void OnDownload(wxCommandEvent & WXUNUSED(event))
{
HelpSystem::ShowHelpDialog(this, wxT("FAQ:Installation_and_Plug-Ins#ffdown"));
HelpSystem::ShowHelp(this, wxT("FAQ:Installation_and_Plug-Ins#ffdown"));
}
wxString GetLibPath()

View File

@ -530,7 +530,7 @@ void FreqWindow::OnGetURL(wxCommandEvent & WXUNUSED(event))
{
// Original help page is back on-line (March 2016), but the manual should be more reliable.
// http://www.eramp.com/WCAG_2_audio_contrast_tool_help.htm
HelpSystem::ShowHelpDialog(this, wxT("Plot Spectrum"));
HelpSystem::ShowHelp(this, wxT("Plot Spectrum"));
}
bool FreqWindow::Show(bool show)

View File

@ -39,7 +39,7 @@ static wxString WrapText( const wxString & Text )
wxT("</body></html>");
}
static wxString Link( const wxString &Key, const wxString& Text )
static wxString InnerLink( const wxString &Key, const wxString& Text )
{
return wxString(wxT("")) +
wxT("<a href='innerlink:") +
@ -52,7 +52,7 @@ static wxString Link( const wxString &Key, const wxString& Text )
static wxString WikiLink( const wxString &Key, const wxString& Text )
{
return wxString(wxT("")) +
wxT("<a href='http://www.audacityteam.org/wiki/index.php?title=") +
wxT("<a href='https://www.audacityteam.org/wiki/index.php?title=") +
Key +
wxT("'>") +
Text +
@ -126,7 +126,7 @@ static wxString LinkExpand( const wxString & Text )
}
else
{
Replacement = Link( Key, LinkText );
Replacement = InnerLink( Key, LinkText );
}
@ -225,8 +225,8 @@ static wxString HelpTextBuiltIn( const wxString & Key )
_(" [[http://www.darkaudacity.com/video.html|Tutorials]] - for getting started with DarkAudacity.") + wxT("</li></ul>") +
wxT("<br><br>Audacity has these support methods:") + wxT("<ul><li>") +
wxT(" [[http://manual.audacityteam.org/|Manual]] - for comprehensive Audacity documentation") + wxT("</li><li>") +
wxT(" [[http://forum.audacityteam.org/|Forum]] - for large knowledge base on using Audacity.") + wxT("</li></ul>");
wxT(" [[https://manual.audacityteam.org/|Manual]] - for comprehensive Audacity documentation") + wxT("</li><li>") +
wxT(" [[https://forum.audacityteam.org/|Forum]] - for large knowledge base on using Audacity.") + wxT("</li></ul>");
#else
wxT("<center><h3>Audacity ") + AUDACITY_VERSION_STRING + wxT("</h3><h3>") +
_("How to get help") + wxT("</h3></center>") +

View File

@ -8260,14 +8260,14 @@ void AudacityProject::OnHelpWelcome()
void AudacityProject::OnQuickHelp()
{
HelpSystem::ShowHelpDialog(
HelpSystem::ShowHelp(
this,
wxT("Quick_Help"));
}
void AudacityProject::OnManual()
{
HelpSystem::ShowHelpDialog(
HelpSystem::ShowHelp(
this,
wxT("Main_Page"));
}

View File

@ -356,7 +356,7 @@ void TimerRecordDialog::OnAutoExportCheckBox_Change(wxCommandEvent& WXUNUSED(eve
void TimerRecordDialog::OnHelpButtonClick(wxCommandEvent& WXUNUSED(event))
{
HelpSystem::ShowHelpDialog(this, wxT("Timer_Record"), true);
HelpSystem::ShowHelp(this, wxT("Timer_Record"), true);
}
void TimerRecordDialog::OnOK(wxCommandEvent& WXUNUSED(event))

View File

@ -95,6 +95,7 @@ CommandManager. It holds the callback for one command.
#include "../effects/EffectManager.h"
#include "../widgets/LinkingHtmlWindow.h"
#include "../widgets/ErrorDialog.h"
#include "../widgets/HelpSystem.h"
// On wxGTK, there may be many many many plugins, but the menus don't automatically
// allow for scrolling, so we build sub-menus. If the menu gets longer than
@ -1232,7 +1233,7 @@ void CommandManager::TellUserWhyDisallowed( const wxString & Name, CommandFlag f
wxString reason = _("There was a problem with your last action. If you think\nthis is a bug, please tell us exactly where it occurred.");
// The default title string is 'Disallowed'.
wxString title = _("Disallowed");
wxString help_url ="";
wxString helpPage ="";
auto missingFlags = flagsRequired & (~flagsGot );
if( missingFlags & AudioIONotBusyFlag )
@ -1263,7 +1264,7 @@ void CommandManager::TellUserWhyDisallowed( const wxString & Name, CommandFlag f
), Name );
#endif
#endif
help_url = "http://alphamanual.audacityteam.org/man/Selecting_Audio_-_the_basics";
helpPage = "Selecting_Audio_-_the_basics";
}
else if( missingFlags & WaveTracksSelectedFlag)
reason = _("You must first select some audio to perform this action.\n(Selecting other kinds of track won't work.)");
@ -1277,30 +1278,13 @@ void CommandManager::TellUserWhyDisallowed( const wxString & Name, CommandFlag f
else if( missingFlags == TrackPanelHasFocus )
return;
#if 0
// Does not have the warning icon...
ShowErrorDialog(
NULL,
title,
reason,
help_url,
helpPage,
false);
#endif
// JKC: I tried building a custom error dialog with the warning icon, and a
// help button linking to our html (without closing).
// In the end I decided it was easier (more portable across different
// OS's) to use the stock one.
int result = ::wxMessageBox(reason, title, wxICON_WARNING | wxOK |
(help_url.IsEmpty() ? 0 : wxHELP) );
// if they click help, we fetch that help, and pop the dialog (without a
// help button) up again.
if( result == wxHELP ){
wxHtmlLinkInfo link( help_url );
OpenInDefaultBrowser(link);
::wxMessageBox(reason, title, wxICON_WARNING | wxOK );
}
}
wxString CommandManager::DescribeCommandsAndShortcuts

View File

@ -323,7 +323,7 @@ void ContrastDialog::OnGetURL(wxCommandEvent & WXUNUSED(event))
{
// Original help page is back on-line (March 2016), but the manual should be more reliable.
// http://www.eramp.com/WCAG_2_audio_contrast_tool_help.htm
HelpSystem::ShowHelpDialog(this, wxT("Contrast"));
HelpSystem::ShowHelp(this, wxT("Contrast"));
}
void ContrastDialog::OnClose(wxCommandEvent & WXUNUSED(event))

View File

@ -2625,7 +2625,7 @@ void Effect::Preview(bool dryOnly)
else {
ShowErrorDialog(FocusDialog, _("Error"),
_("Error opening sound device.\nTry changing the audio host, playback device and the project sample rate."),
wxT("http://manual.audacityteam.org/man/faq_errors.html#sound_device"), false);
wxT("faq_errors.html#sound_device"), false);
}
}
}
@ -3245,13 +3245,13 @@ void EffectUIHost::OnCancel(wxCommandEvent & evt)
void EffectUIHost::OnHelp(wxCommandEvent & WXUNUSED(event))
{
if (mEffect->GetFamily().IsSameAs(NYQUISTEFFECTS_FAMILY) && (mEffect->ManualPage().IsEmpty())) {
// Old ShowHelpDialog required when there is no on-line manual.
// Old ShowHelp required when there is no on-line manual.
// Always use default web browser to allow full-featured HTML pages.
HelpSystem::ShowHelpDialog(FindWindow(wxID_HELP), mEffect->HelpPage(), wxEmptyString, true, true);
HelpSystem::ShowHelp(FindWindow(wxID_HELP), mEffect->HelpPage(), wxEmptyString, true, true);
}
else {
// otherwise use the NEW ShowHelpDialog
HelpSystem::ShowHelpDialog(FindWindow(wxID_HELP), mEffect->ManualPage(), true);
// otherwise use the NEW ShowHelp
HelpSystem::ShowHelp(FindWindow(wxID_HELP), mEffect->ManualPage(), true);
}
}

View File

@ -3536,7 +3536,8 @@ void EditCurvesDialog::OnExport( wxCommandEvent & WXUNUSED(event))
void EditCurvesDialog::OnLibrary( wxCommandEvent & WXUNUSED(event))
{
wxLaunchDefaultBrowser(wxT("http://wiki.audacityteam.org/wiki/EQCurvesDownload"));
// full path to wiki.
wxLaunchDefaultBrowser(wxT("https://wiki.audacityteam.org/wiki/EQCurvesDownload"));
}
void EditCurvesDialog::OnDefaults( wxCommandEvent & WXUNUSED(event))

View File

@ -676,7 +676,7 @@ public:
void OnDownload(wxCommandEvent & WXUNUSED(event))
{
wxString page = wxT("http://manual.audacityteam.org/man/faq_installation_and_plug_ins.html#lame");
wxString page = wxT("faq_installation_and_plug_ins.html#lame");
::OpenInDefaultBrowser(page);
}

View File

@ -180,7 +180,7 @@ void LibraryPrefs::OnMP3FindButton(wxCommandEvent & WXUNUSED(event))
void LibraryPrefs::OnMP3DownButton(wxCommandEvent & WXUNUSED(event))
{
// Modal help dialogue required here
HelpSystem::ShowHelpDialog(this, wxT("FAQ:Installation_and_Plug-Ins#lame"), true);
HelpSystem::ShowHelp(this, wxT("FAQ:Installation_and_Plug-Ins#lame"), true);
}
void LibraryPrefs::SetFFmpegVersionText()
@ -228,7 +228,7 @@ void LibraryPrefs::OnFFmpegFindButton(wxCommandEvent & WXUNUSED(event))
void LibraryPrefs::OnFFmpegDownButton(wxCommandEvent & WXUNUSED(event))
{
HelpSystem::ShowHelpDialog(this, wxT("FAQ:Installation_and_Plug-Ins#ffdown"), true);
HelpSystem::ShowHelp(this, wxT("FAQ:Installation_and_Plug-Ins#ffdown"), true);
}
bool LibraryPrefs::Commit()

View File

@ -434,7 +434,7 @@ void PrefsDialog::OnHelp(wxCommandEvent & WXUNUSED(event))
// So we change the page name in the case of a page on its own.
if( !mCategories)
page.Replace( "Spectrograms_Preferences", "Spectrogram_Settings" );
HelpSystem::ShowHelpDialog(this, page, true);
HelpSystem::ShowHelp(this, page, true);
}
void PrefsDialog::OnTreeKeyDown(wxTreeEvent & event)

View File

@ -718,7 +718,7 @@ int ControlToolBar::PlayPlayRegion(const SelectedRegion &selectedRegion,
// Show error message if stream could not be opened
ShowErrorDialog(this, _("Error"),
_("Error opening sound device.\nTry changing the audio host, playback device and the project sample rate."),
wxT("http://manual.audacityteam.org/man/faq_errors.html#sound_device"), false);
wxT("faq_errors.html#sound_device"), false);
});
}
}
@ -1200,7 +1200,7 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
// Show error message if stream could not be opened
ShowErrorDialog(this, _("Error"),
_("Error opening sound device.\nTry changing the audio host, recording device and the project sample rate."),
wxT("http://manual.audacityteam.org/man/faq_errors.html#sound_device"), false);
wxT("faq_errors.html#sound_device"), false);
}
}
}

View File

@ -76,7 +76,7 @@ ErrorDialog::ErrorDialog(
wxWindow *parent,
const wxString & dlogTitle,
const wxString & message,
const wxString & helpURL,
const wxString & helpPage,
const bool Close, const bool modal):
wxDialogWrapper(parent, (wxWindowID)-1, dlogTitle)
{
@ -85,8 +85,8 @@ ErrorDialog::ErrorDialog(
long buttonMask;
// only add the help button if we have a URL
buttonMask = (helpURL == wxT("")) ? eOkButton : (eHelpButton | eOkButton);
dhelpURL = helpURL;
buttonMask = (helpPage == wxT("")) ? eOkButton : (eHelpButton | eOkButton);
dhelpPage = helpPage;
dClose = Close;
dModal = modal;
@ -152,17 +152,18 @@ void ErrorDialog::OnOk(wxCommandEvent & WXUNUSED(event))
void ErrorDialog::OnHelp(wxCommandEvent & WXUNUSED(event))
{
if( dhelpURL.StartsWith(wxT("innerlink:")) )
if( dhelpPage.StartsWith(wxT("innerlink:")) )
{
HelpSystem::ShowHtmlText(
this,
TitleText(dhelpURL.Mid( 10 ) ),
HelpText( dhelpURL.Mid( 10 )),
TitleText(dhelpPage.Mid( 10 ) ),
HelpText( dhelpPage.Mid( 10 )),
false,
true );
return;
}
OpenInDefaultBrowser( dhelpURL );
HelpSystem::ShowHelp( this, dhelpPage, dClose );
//OpenInDefaultBrowser( dhelpURL );
if(dClose)
EndModal(true);
}
@ -170,26 +171,31 @@ void ErrorDialog::OnHelp(wxCommandEvent & WXUNUSED(event))
void ShowErrorDialog(wxWindow *parent,
const wxString &dlogTitle,
const wxString &message,
const wxString &helpURL,
const wxString &helpPage,
const bool Close)
{
ErrorDialog dlog(parent, dlogTitle, message, helpURL, Close);
ErrorDialog dlog(parent, dlogTitle, message, helpPage, Close);
dlog.CentreOnParent();
dlog.ShowModal();
}
// unused.
void ShowModelessErrorDialog(wxWindow *parent,
const wxString &dlogTitle,
const wxString &message,
const wxString &helpURL,
const wxString &helpPage,
const bool Close)
{
// ensure it has some parent.
if( !parent )
parent = wxTheApp->GetTopWindow();
wxASSERT(parent);
ErrorDialog *dlog = safenew ErrorDialog(parent, dlogTitle, message, helpURL, Close, false);
ErrorDialog *dlog = safenew ErrorDialog(parent, dlogTitle, message, helpPage, Close, false);
dlog->CentreOnParent();
dlog->Show();
// ANSWER-ME: Vigilant Sentry flags this method as not deleting dlog, so a mem leak.
// ANSWER-ME: This is unused. Delete it or are there plans for it?
// ANSWER-ME: Vigilant Sentry flagged this method as not deleting dlog, so
// is this actually a mem leak.
// PRL: answer is that the parent window guarantees destruction of the dialog
// but in practice Destroy() in OnOK does that
}
@ -197,11 +203,11 @@ void ShowModelessErrorDialog(wxWindow *parent,
void ShowAliasMissingDialog(AudacityProject *parent,
const wxString &dlogTitle,
const wxString &message,
const wxString &helpURL,
const wxString &helpPage,
const bool Close)
{
wxASSERT(parent); // to justify safenew
ErrorDialog *dlog = safenew AliasedFileMissingDialog(parent, dlogTitle, message, helpURL, Close, false);
ErrorDialog *dlog = safenew AliasedFileMissingDialog(parent, dlogTitle, message, helpPage, Close, false);
// Don't center because in many cases (effect, export, etc) there will be a progress bar in the center that blocks this.
// instead put it just above or on the top of the project.
wxPoint point;

View File

@ -26,13 +26,13 @@ public:
ErrorDialog(wxWindow *parent,
const wxString & dlogTitle,
const wxString & message,
const wxString & helpURL,
const wxString & helpPage,
const bool Close = true, const bool modal = true);
virtual ~ErrorDialog(){}
private:
wxString dhelpURL;
wxString dhelpPage;
bool dClose;
bool dModal;
@ -67,21 +67,21 @@ public:
void ShowErrorDialog(wxWindow *parent,
const wxString &dlogTitle,
const wxString &message,
const wxString &helpURL,
const wxString &helpPage,
bool Close = true);
/// Displays a modeless error dialog with a button that offers help
void ShowModelessErrorDialog(wxWindow *parent,
const wxString &dlogTitle,
const wxString &message,
const wxString &helpURL,
const wxString &helpPage,
bool Close = true);
/// Displays a custom modeless error dialog for aliased file errors
void ShowAliasMissingDialog(AudacityProject *parent,
const wxString &dlogTitle,
const wxString &message,
const wxString &helpURL,
const wxString &helpPage,
const bool Close = true);
#endif // __AUDACITY_ERRORDIALOG__

View File

@ -197,7 +197,8 @@ void HelpSystem::ShowHtmlText(wxWindow *pParent,
return;
}
void HelpSystem::ShowHelpDialog(wxWindow *parent,
// Shows help in browser, or possibly in own dialog.
void HelpSystem::ShowHelp(wxWindow *parent,
const wxString &localFileName,
const wxString &remoteURL,
bool bModal,
@ -240,7 +241,7 @@ void HelpSystem::ShowHelpDialog(wxWindow *parent,
// Always go to remote URL. Use External browser.
OpenInDefaultBrowser( remoteURL );
}
else if( !wxFileExists( localfile ))
else if( localfile.IsEmpty() || !wxFileExists( localfile ))
{
// If you give an empty remote URL, you should have already ensured
// that the file exists!
@ -263,9 +264,9 @@ void HelpSystem::ShowHelpDialog(wxWindow *parent,
}
}
void HelpSystem::ShowHelpDialog(wxWindow *parent,
const wxString &PageName,
bool bModal)
void HelpSystem::ShowHelp(wxWindow *parent,
const wxString &PageName,
bool bModal)
{
wxString localHelpPage;
wxString webHelpPath;
@ -299,7 +300,7 @@ void HelpSystem::ShowHelpDialog(wxWindow *parent,
{
releasePageName = wxT("index") + HelpSystem::ReleaseSuffix + anchor;
localHelpPage = wxFileName(FileNames::HtmlHelpDir(), releasePageName).GetFullPath();
webHelpPath = wxT("http://")+HelpSystem::HelpHostname+HelpSystem::HelpServerHomeDir;
webHelpPath = wxT("https://")+HelpSystem::HelpHostname+HelpSystem::HelpServerHomeDir;
}
else if (releasePageName == wxT("Quick_Help"))
{
@ -311,9 +312,16 @@ void HelpSystem::ShowHelpDialog(wxWindow *parent,
#else
releasePageName = wxT("quick_help") + HelpSystem::ReleaseSuffix + anchor;
localHelpPage = wxFileName(FileNames::HtmlHelpDir(), releasePageName).GetFullPath();
webHelpPath = wxT("http://")+HelpSystem::HelpHostname+HelpSystem::HelpServerHomeDir;
webHelpPath = wxT("https://")+HelpSystem::HelpHostname+HelpSystem::HelpServerHomeDir;
#endif
}
// not a page name, but rather a full path (e.g. to wiki)
// in which case do not do any substitutions.
else if (releasePageName.StartsWith( "http" ) )
{
localHelpPage = "";
webHelpPage = releasePageName + anchor;
}
else
{
// Handle all other pages.
@ -343,7 +351,7 @@ void HelpSystem::ShowHelpDialog(wxWindow *parent,
// Other than index and quick_help, all local pages are in subdirectory 'LocalHelpManDir'.
localHelpPage = wxFileName(FileNames::HtmlHelpDir() + LocalHelpManDir, releasePageName).GetFullPath();
// Other than index and quick_help, all on-line pages are in subdirectory 'HelpServerManDir'.
webHelpPath = wxT("http://")+HelpSystem::HelpHostname+HelpSystem::HelpServerManDir;
webHelpPath = wxT("https://")+HelpSystem::HelpHostname+HelpSystem::HelpServerManDir;
}
#if IS_ALPHA
@ -359,7 +367,7 @@ void HelpSystem::ShowHelpDialog(wxWindow *parent,
wxASSERT(parent); // to justify safenew
HelpSystem::ShowHelpDialog(
HelpSystem::ShowHelp(
parent,
localHelpPage,
webHelpPage,

View File

@ -59,7 +59,7 @@ public:
/// Default is modeless dialogue
/// @param alwaysDefaultBrowser Force use of default web browser.
/// Default allows built in browser for local files.
static void ShowHelpDialog(wxWindow *parent,
static void ShowHelp(wxWindow *parent,
const wxString &localFileName,
const wxString &remoteURL,
bool bModal = false,
@ -72,7 +72,7 @@ public:
/// converted file name used for offline and released manuals.
/// @param bModal Whether the resulting dialogue should be modal or not.
/// Default is modeless dialogue
static void ShowHelpDialog(wxWindow *parent,
static void ShowHelp(wxWindow *parent,
const wxString &PageName,
bool bModal = false);

View File

@ -144,7 +144,7 @@ void LinkingHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link)
wxFileName( FileNames::HtmlHelpDir(), href.Mid( 10 ) + wxT(".htm") ).GetFullPath();
if( wxFileExists( FileName ) )
{
HelpSystem::ShowHelpDialog(this, FileName, wxT(""));
HelpSystem::ShowHelp(this, FileName, wxT(""));
return;
}
else