ManualPageID is a new type; rewrite HelpSystem::ShowHelp and its uses

This commit is contained in:
Paul Licameli 2021-06-06 15:40:11 -04:00
parent cfbdd2d22e
commit 132f04d272
20 changed files with 48 additions and 45 deletions

View File

@ -232,7 +232,8 @@ struct CommandIdTag;
using CommandID = TaggedIdentifier< CommandIdTag, false >;
using CommandIDs = std::vector<CommandID>;
using ManualPageID = wxString;
struct ManualPageIDTag;
using ManualPageID = TaggedIdentifier< ManualPageIDTag >;
#endif

View File

@ -538,7 +538,7 @@ public:
void OnDownload(wxCommandEvent & WXUNUSED(event))
{
HelpSystem::ShowHelp(this, wxT("FAQ:Installing_the_FFmpeg_Import_Export_Library"));
HelpSystem::ShowHelp(this, L"FAQ:Installing_the_FFmpeg_Import_Export_Library");
}
wxString GetLibPath()

View File

@ -550,7 +550,7 @@ void FrequencyPlotDialog::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::ShowHelp(this, wxT("Plot Spectrum"));
HelpSystem::ShowHelp(this, L"Plot Spectrum");
}
bool FrequencyPlotDialog::Show(bool show)

View File

@ -313,7 +313,7 @@ void HistoryDialog::OnCompact(wxCommandEvent & WXUNUSED(event))
void HistoryDialog::OnGetURL(wxCommandEvent & WXUNUSED(event))
{
HelpSystem::ShowHelp(this, wxT("Undo,_Redo_and_History"));
HelpSystem::ShowHelp(this, L"Undo,_Redo_and_History");
}
void HistoryDialog::OnItemSelected(wxListEvent &event)

View File

@ -1362,7 +1362,7 @@ public:
void OnGetURL(wxCommandEvent &WXUNUSED(evt))
{
HelpSystem::ShowHelp(this, wxT("File_Menu:_Compact_Project"), true);
HelpSystem::ShowHelp(this, L"File_Menu:_Compact_Project", true);
}
};
}

View File

@ -559,7 +559,7 @@ void ScreenshotBigDialog::OnClose(wxCommandEvent & WXUNUSED(event))
void ScreenshotBigDialog::OnGetURL(wxCommandEvent & WXUNUSED(event))
{
HelpSystem::ShowHelp(this, wxT("Screenshot"));
HelpSystem::ShowHelp(this, L"Screenshot");
}
void ScreenshotBigDialog::OnUIUpdate(wxUpdateUIEvent & WXUNUSED(event))

View File

@ -972,7 +972,7 @@ void TagsEditorDialog::OnDontShow( wxCommandEvent & Evt )
void TagsEditorDialog::OnHelp(wxCommandEvent& WXUNUSED(event))
{
HelpSystem::ShowHelp(this, wxT("Metadata_Editor"), true);
HelpSystem::ShowHelp(this, L"Metadata_Editor", true);
}
bool TagsEditorDialog::TransferDataFromWindow()

View File

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

View File

@ -361,7 +361,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::ShowHelp(this, wxT("Contrast"));
HelpSystem::ShowHelp(this, L"Contrast");
}
void ContrastDialog::OnClose(wxCommandEvent & WXUNUSED(event))

View File

@ -190,7 +190,8 @@ void EffectManager::GetCommandDefinition(const PluginID & ID, const CommandConte
S.EndArray();
S.EndField();
}
S.AddItem( GetCommandUrl( ID ), "url" );
// use GET() to expose some details to macro programming users
S.AddItem( GetCommandUrl( ID ).GET(), "url" );
// The tip is a translated string!
S.AddItem( GetCommandTip( ID ).Translation(), "tip" );
S.EndStruct();

View File

@ -367,7 +367,7 @@ void Exporter::OnExtensionChanged(wxCommandEvent &evt)
void Exporter::OnHelp(wxCommandEvent& WXUNUSED(evt))
{
wxWindow * pWin = FindProjectFrame( mProject );
HelpSystem::ShowHelp(pWin, wxT("File_Export_Dialog"), true);
HelpSystem::ShowHelp(pWin, L"File_Export_Dialog", true);
}
void Exporter::SetFileDialogTitle( const TranslatableString & DialogTitle )
@ -1494,7 +1494,7 @@ void ExportMixerDialog::OnCancel(wxCommandEvent & WXUNUSED(event))
void ExportMixerDialog::OnMixerPanelHelp(wxCommandEvent & WXUNUSED(event))
{
HelpSystem::ShowHelp(this, wxT("Advanced_Mixing_Options"), true);
HelpSystem::ShowHelp(this, L"Advanced_Mixing_Options", true);
}

View File

@ -2562,7 +2562,7 @@ void ExportFFmpegOptions::OnOK(wxCommandEvent& WXUNUSED(event))
void ExportFFmpegOptions::OnGetURL(wxCommandEvent & WXUNUSED(event))
{
HelpSystem::ShowHelp(this, wxT("Custom_FFmpeg_Export_Options"));
HelpSystem::ShowHelp(this, L"Custom_FFmpeg_Export_Options");
}

View File

@ -674,7 +674,7 @@ public:
void OnDownload(wxCommandEvent & WXUNUSED(event))
{
HelpSystem::ShowHelp(this, wxT("FAQ:Installing_the_LAME_MP3_Encoder"));
HelpSystem::ShowHelp(this, L"FAQ:Installing_the_LAME_MP3_Encoder");
}
wxString GetLibPath()

View File

@ -574,7 +574,7 @@ void ExportMultipleDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
void ExportMultipleDialog::OnHelp(wxCommandEvent& WXUNUSED(event))
{
HelpSystem::ShowHelp(this, wxT("Export_Multiple"), true);
HelpSystem::ShowHelp(this, L"Export_Multiple", true);
}
void ExportMultipleDialog::OnExport(wxCommandEvent& WXUNUSED(event))

View File

@ -309,7 +309,7 @@ void OnQuickHelp(const CommandContext &context)
auto &project = context.project;
HelpSystem::ShowHelp(
&GetProjectFrame( project ),
wxT("Quick_Help"));
L"Quick_Help");
}
void OnManual(const CommandContext &context)
@ -317,7 +317,7 @@ void OnManual(const CommandContext &context)
auto &project = context.project;
HelpSystem::ShowHelp(
&GetProjectFrame( project ),
wxT("Main_Page"));
L"Main_Page");
}
void OnAudioDeviceInfo(const CommandContext &context)

View File

@ -168,7 +168,7 @@ void LibraryPrefs::OnMP3FindButton(wxCommandEvent & WXUNUSED(event))
void LibraryPrefs::OnMP3DownButton(wxCommandEvent & WXUNUSED(event))
{
// Modal help dialogue required here
HelpSystem::ShowHelp(this, wxT("FAQ:Installing_the_LAME_MP3_Encoder"), true);
HelpSystem::ShowHelp(this, L"FAQ:Installing_the_LAME_MP3_Encoder", true);
}
void LibraryPrefs::SetFFmpegVersionText()
@ -217,7 +217,7 @@ void LibraryPrefs::OnFFmpegFindButton(wxCommandEvent & WXUNUSED(event))
void LibraryPrefs::OnFFmpegDownButton(wxCommandEvent & WXUNUSED(event))
{
HelpSystem::ShowHelp(this, wxT("FAQ:Installing_the_FFmpeg_Import_Export_Library"), true);
HelpSystem::ShowHelp(this, L"FAQ:Installing_the_FFmpeg_Import_Export_Library", true);
}
bool LibraryPrefs::Commit()

View File

@ -133,12 +133,13 @@ void ErrorDialog::OnOk(wxCommandEvent & WXUNUSED(event))
void ErrorDialog::OnHelp(wxCommandEvent & WXUNUSED(event))
{
if( dhelpPage.StartsWith(wxT("innerlink:")) )
const auto &str = dhelpPage.GET();
if( str.StartsWith(wxT("innerlink:")) )
{
HelpSystem::ShowHtmlText(
this,
TitleText(dhelpPage.Mid( 10 ) ),
HelpText( dhelpPage.Mid( 10 )),
TitleText(str.Mid( 10 ) ),
HelpText( str.Mid( 10 )),
false,
true );
return;

View File

@ -57,7 +57,6 @@ const wxString HelpSystem::HelpServerHomeDir = wxT("/");
const wxString HelpSystem::HelpServerManDir = wxT("/man/");
#endif
const wxString HelpSystem::LocalHelpManDir = wxT("/man/");
const wxString HelpSystem::ReleaseSuffix = wxT(".html");
namespace {
@ -310,19 +309,24 @@ void HelpSystem::ShowHelp(wxWindow *parent,
const ManualPageID &PageName,
bool bModal)
{
/// The string which is appended to the development manual page name in order
/// obtain the file name in the local and release web copies of the manual
const wxString ReleaseSuffix = L".html";
FilePath localHelpPage;
wxString webHelpPath;
wxString webHelpPage;
wxString releasePageName;
wxString anchor; // optional part of URL after (and including) the '#'
if (PageName.Find('#', true) != wxNOT_FOUND)
const auto &PageNameStr = PageName.GET();
if (PageNameStr.Find('#', true) != wxNOT_FOUND)
{ // need to split anchor off into separate variable
releasePageName= PageName.BeforeLast('#');
anchor = wxT("#") + PageName.AfterLast('#');
releasePageName = PageNameStr.BeforeLast('#');
anchor = wxT("#") + PageNameStr.AfterLast('#');
}
else
{
releasePageName = PageName;
releasePageName = PageName.GET();
anchor = wxT("");
}
// The wiki pages are transformed to static HTML by
@ -338,23 +342,23 @@ void HelpSystem::ShowHelp(wxWindow *parent,
//
// The front page and 'quick_help' are treated as special cases and placed in
// the root of the help directory rather than the "/man/" sub-directory.
if (releasePageName == wxT("Main_Page"))
if (releasePageName == L"Main_Page")
{
releasePageName = wxT("index") + HelpSystem::ReleaseSuffix + anchor;
releasePageName = L"index" + ReleaseSuffix + anchor;
localHelpPage = wxFileName(FileNames::HtmlHelpDir(), releasePageName).GetFullPath();
webHelpPath = wxT("https://")+HelpSystem::HelpHostname+HelpSystem::HelpServerHomeDir;
webHelpPath = L"https://" + HelpSystem::HelpHostname + HelpSystem::HelpServerHomeDir;
}
else if (releasePageName == wxT("Quick_Help"))
else if (releasePageName == L"Quick_Help")
{
// DA: No bundled help, by default, and different quick-help URL.
#ifdef EXPERIMENTAL_DA
releasePageName = wxT("video") + HelpSystem::ReleaseSuffix + anchor;
releasePageName = L"video" + ReleaseSuffix + anchor;
localHelpPage = wxFileName(FileNames::HtmlHelpDir(), releasePageName).GetFullPath();
webHelpPath = wxT("http://www.darkaudacity.com/");
webHelpPath = L"http://www.darkaudacity.com/";
#else
releasePageName = wxT("quick_help") + HelpSystem::ReleaseSuffix + anchor;
releasePageName = L"quick_help" + ReleaseSuffix + anchor;
localHelpPage = wxFileName(FileNames::HtmlHelpDir(), releasePageName).GetFullPath();
webHelpPath = wxT("https://")+HelpSystem::HelpHostname+HelpSystem::HelpServerHomeDir;
webHelpPath = L"https://" + HelpSystem::HelpHostname + HelpSystem::HelpServerHomeDir;
#endif
}
// not a page name, but rather a full path (e.g. to wiki)
@ -390,21 +394,21 @@ void HelpSystem::ShowHelp(wxWindow *parent,
// Replace "_." with "."
releasePageName.Replace(wxT("_."), wxT("."), true);
// Concatenate file name with file extension and anchor.
releasePageName = releasePageName + HelpSystem::ReleaseSuffix + anchor;
releasePageName = releasePageName + ReleaseSuffix + anchor;
// 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("https://")+HelpSystem::HelpHostname+HelpSystem::HelpServerManDir;
webHelpPath = L"https://" + HelpSystem::HelpHostname + HelpSystem::HelpServerManDir;
}
#ifdef USE_ALPHA_MANUAL
webHelpPage = webHelpPath + PageName;
webHelpPage = webHelpPath + PageName.GET();
#else
webHelpPage = webHelpPath + releasePageName;
#endif
wxLogMessage(wxT("Help button pressed: PageName %s, releasePageName %s"),
PageName, releasePageName);
PageName.GET(), releasePageName);
wxLogMessage(wxT("webHelpPage %s, localHelpPage %s"),
webHelpPage, localHelpPage);
@ -535,7 +539,7 @@ void LinkingHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link)
if( href.StartsWith( wxT("innerlink:help:")))
{
HelpSystem::ShowHelp(this, href.Mid( 15 ), true );
HelpSystem::ShowHelp(this, ManualPageID{ href.Mid( 15 ) }, true );
return;
}
else if( href.StartsWith(wxT("innerlink:")) )

View File

@ -110,10 +110,6 @@ public:
/// Must both start and end with '/' characters.
static const wxString LocalHelpManDir;
/// The string which is appended to the development manual page name in order
/// obtain the file name in the local and release web copies of the manual
static const wxString ReleaseSuffix;
};
class ShuttleGui;

View File

@ -145,7 +145,7 @@ MultiDialog::MultiDialog(wxWindow * pParent,
auto pButton = S.Id(wxID_OK)
.AddButton(XXO("OK"), wxALIGN_CENTER, !log);
if (!mHelpPage.IsEmpty()) {
if (!mHelpPage.empty()) {
auto pHelpBtn = S.Id(wxID_HELP)
.AddBitmapButton(theTheme.Bitmap(bmpHelpIcon), wxALIGN_CENTER, false);
pHelpBtn->SetToolTip(XO("Help").Translation());