1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-19 17:40:15 +02:00

Help Menus

This commit is contained in:
Paul Licameli 2018-10-23 17:47:23 -04:00
parent 574fc7f2ec
commit 64b6493bec
5 changed files with 305 additions and 288 deletions

View File

@ -1595,7 +1595,7 @@ bool AudacityApp::OnInit()
// Mainly this is to tell users of ALPHAS who don't know that they have an ALPHA.
// Disabled for now, after discussion.
// project->MayCheckForUpdates();
GetMenuCommandHandler(*project).OnHelpWelcome(*project);
HelpActions::DoHelpWelcome(*project);
}
// JKC 10-Sep-2007: Enable monitoring from the start.

View File

@ -64,15 +64,12 @@ menu items.
#include "effects/EffectManager.h"
#include "AudacityApp.h"
#include "AudacityLogger.h"
#include "AudioIO.h"
#include "Dependencies.h"
#include "float_cast.h"
#include "LabelTrack.h"
#include "import/ImportRaw.h"
#include "prefs/PrefsDialog.h"
#include "prefs/PlaybackPrefs.h"
#include "ShuttleGui.h"
#include "LyricsWindow.h"
#include "MixerBoard.h"
#include "Project.h"
@ -83,7 +80,6 @@ menu items.
#ifdef USE_MIDI
#include "NoteTrack.h"
#endif // USE_MIDI
#include "AboutDialog.h"
#include "ondemand/ODManager.h"
#include "prefs/BatchPrefs.h"
@ -98,18 +94,10 @@ menu items.
#include "Experimental.h"
#include "PlatformCompatibility.h"
#include "FileNames.h"
#include "SplashDialog.h"
#include "widgets/HelpSystem.h"
#include "UndoManager.h"
#include "WaveTrack.h"
#if defined(EXPERIMENTAL_CRASH_REPORT)
#include <wx/debugrpt.h>
#endif
#include "prefs/TracksPrefs.h"
#include "widgets/ErrorDialog.h"
@ -352,9 +340,7 @@ MenuTable::BaseItemPtr WindowMenu( AudacityProject& );
MenuTable::BaseItemPtr ExtraMenu( AudacityProject& );
namespace {
MenuTable::BaseItemPtr HelpMenu( AudacityProject& );
}
// Table of menu factories.
// TODO: devise a registration system instead.
@ -374,72 +360,6 @@ static const auto menuTree = MenuTable::Items(
, HelpMenu
);
namespace {
MenuTable::BaseItemPtr HelpMenu( AudacityProject & )
{
#ifdef __WXMAC__
wxGetApp().s_macHelpMenuTitleName = _("&Help");
#endif
using namespace MenuTable;
return Menu( _("&Help"),
Command( wxT("QuickFix"), XXO("&Quick Fix..."), FN(OnQuickFix),
AlwaysEnabledFlag ),
// DA: Emphasise it is the Audacity Manual (No separate DA manual).
#ifdef EXPERIMENTAL_DA
// 'Getting Started' rather than 'Quick Help' for DarkAudacity.
// At the moment the video tutorials are aspirational (aka do not exist yet).
// Emphasise that manual is for Audacity, not DarkAudacity.
Command( wxT("QuickHelp"), XXO("&Getting Started"), FN(OnQuickHelp) ),
Command( wxT("Manual"), XXO("Audacity &Manual"), FN(OnManual) ),
#else
Command( wxT("QuickHelp"), XXO("&Quick Help..."), FN(OnQuickHelp),
AlwaysEnabledFlag ),
Command( wxT("Manual"), XXO("&Manual..."), FN(OnManual),
AlwaysEnabledFlag ),
#endif
Separator(),
Menu( _("&Diagnostics"),
Command( wxT("DeviceInfo"), XXO("Au&dio Device Info..."),
FN(OnAudioDeviceInfo),
AudioIONotBusyFlag ),
#ifdef EXPERIMENTAL_MIDI_OUT
Command( wxT("MidiDeviceInfo"), XXO("&MIDI Device Info..."),
FN(OnMidiDeviceInfo),
AudioIONotBusyFlag ),
#endif
Command( wxT("Log"), XXO("Show &Log..."), FN(OnShowLog),
AlwaysEnabledFlag ),
#if defined(EXPERIMENTAL_CRASH_REPORT)
Command( wxT("CrashReport"), XXO("&Generate Support Data..."),
FN(OnCrashReport), AlwaysEnabledFlag ),
#endif
Command( wxT("CheckDeps"), XXO("Chec&k Dependencies..."),
FN(OnCheckDependencies),
AudioIONotBusyFlag )
),
#ifndef __WXMAC__
Separator(),
#endif
// DA: Does not fully support update checking.
#ifndef EXPERIMENTAL_DA
Command( wxT("Updates"), XXO("&Check for Updates..."),
FN(OnCheckForUpdates),
AlwaysEnabledFlag ),
#endif
Command( wxT("About"), XXO("&About Audacity..."), FN(OnAbout),
AlwaysEnabledFlag )
);
}
}
void MenuCreator::CreateMenusAndCommands(AudacityProject &project)
{
CommandManager *c = project.GetCommandManager();
@ -1014,21 +934,6 @@ void MenuCommandHandler::RebuildAllMenuBars()
}
}
//
// File Menu
//
void MenuCommandHandler::OnCheckDependencies(const CommandContext &context)
{
auto &project = context.project;
::ShowDependencyDialogIfNeeded(&project, false);
}
//
// Edit Menu
//
void AudacityProject::SelectNone()
{
for (auto t : GetTracks()->Any())
@ -1137,169 +1042,3 @@ void AudacityProject::ZoomOutByFactor( double ZoomFactor )
}
//
// Help Menu
//
void MenuCommandHandler::OnAbout(const CommandContext &context)
{
#ifdef __WXMAC__
// Modeless dialog, consistent with other Mac applications
wxCommandEvent dummy;
wxGetApp().OnMenuAbout(dummy);
#else
auto &project = context.project;
// Windows and Linux still modal.
AboutDialog dlog(&project);
dlog.ShowModal();
#endif
}
void MenuCommandHandler::OnHelpWelcome(const CommandContext &context)
{
auto &project = context.project;
SplashDialog::Show2( &project );
}
void MenuCommandHandler::OnQuickHelp(const CommandContext &context)
{
auto &project = context.project;
HelpSystem::ShowHelp(
&project,
wxT("Quick_Help"));
}
void MenuCommandHandler::OnQuickFix(const CommandContext &context)
{
auto &project = context.project;
QuickFixDialog dlg( &project );
dlg.ShowModal();
}
void MenuCommandHandler::OnManual(const CommandContext &context)
{
auto &project = context.project;
HelpSystem::ShowHelp(
&project,
wxT("Main_Page"));
}
void MenuCommandHandler::OnCheckForUpdates(const CommandContext &WXUNUSED(context))
{
::OpenInDefaultBrowser( VerCheckUrl());
}
// Only does the update checks if it's an ALPHA build and not disabled by preferences.
void MenuCommandHandler::MayCheckForUpdates(AudacityProject &project)
{
#ifdef IS_ALPHA
OnCheckForUpdates(project);
#endif
}
void MenuCommandHandler::OnShowLog(const CommandContext &WXUNUSED(context) )
{
AudacityLogger *logger = wxGetApp().GetLogger();
if (logger) {
logger->Show();
}
}
#if defined(EXPERIMENTAL_CRASH_REPORT)
void MenuCommandHandler::OnCrashReport(const CommandContext &WXUNUSED(context) )
{
// Change to "1" to test a real crash
#if 0
char *p = 0;
*p = 1234;
#endif
wxGetApp().GenerateCrashReport(wxDebugReport::Context_Current);
}
#endif
void MenuCommandHandler::OnAudioDeviceInfo(const CommandContext &context)
{
auto &project = context.project;
wxString info = gAudioIO->GetDeviceInfo();
wxDialogWrapper dlg(&project, wxID_ANY, wxString(_("Audio Device Info")));
dlg.SetName(dlg.GetTitle());
ShuttleGui S(&dlg, eIsCreating);
wxTextCtrl *text;
S.StartVerticalLay();
{
S.SetStyle(wxTE_MULTILINE | wxTE_READONLY);
text = S.Id(wxID_STATIC).AddTextWindow(info);
S.AddStandardButtons(eOkButton | eCancelButton);
}
S.EndVerticalLay();
dlg.FindWindowById(wxID_OK)->SetLabel(_("&Save"));
dlg.SetSize(350, 450);
if (dlg.ShowModal() == wxID_OK)
{
wxString fName = FileNames::SelectFile(FileNames::Operation::Export,
_("Save Device Info"),
wxEmptyString,
wxT("deviceinfo.txt"),
wxT("txt"),
wxT("*.txt"),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
&project);
if (!fName.IsEmpty())
{
if (!text->SaveFile(fName))
{
AudacityMessageBox(_("Unable to save device info"), _("Save Device Info"));
}
}
}
}
#ifdef EXPERIMENTAL_MIDI_OUT
void MenuCommandHandler::OnMidiDeviceInfo(const CommandContext &context)
{
auto &project = context.project;
wxString info = gAudioIO->GetMidiDeviceInfo();
wxDialogWrapper dlg(&project, wxID_ANY, wxString(_("MIDI Device Info")));
dlg.SetName(dlg.GetTitle());
ShuttleGui S(&dlg, eIsCreating);
wxTextCtrl *text;
S.StartVerticalLay();
{
S.SetStyle(wxTE_MULTILINE | wxTE_READONLY);
text = S.Id(wxID_STATIC).AddTextWindow(info);
S.AddStandardButtons(eOkButton | eCancelButton);
}
S.EndVerticalLay();
dlg.FindWindowById(wxID_OK)->SetLabel(_("&Save"));
dlg.SetSize(350, 450);
if (dlg.ShowModal() == wxID_OK)
{
wxString fName = FileNames::SelectFile(FileNames::Operation::Export,
_("Save MIDI Device Info"),
wxEmptyString,
wxT("midideviceinfo.txt"),
wxT("txt"),
wxT("*.txt"),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
&project);
if (!fName.IsEmpty())
{
if (!text->SaveFile(fName))
{
AudacityMessageBox(_("Unable to save MIDI device info"), _("Save MIDI Device Info"));
}
}
}
}
#endif

View File

@ -49,13 +49,6 @@ struct MenuCommandHandler final
MenuCommandHandler();
~MenuCommandHandler();
// File Menu
void OnCheckDependencies(const CommandContext &context );
// Edit Menu
public:
// Effect Menu
@ -75,24 +68,6 @@ struct OnEffectFlags
static void RebuildAllMenuBars();
// Help Menu
void OnAbout(const CommandContext &context );
void OnQuickHelp(const CommandContext &context );
void OnQuickFix(const CommandContext &context );
void OnManual(const CommandContext &context );
void OnCheckForUpdates(const CommandContext &context );
void MayCheckForUpdates(AudacityProject &project);
void OnShowLog(const CommandContext &context );
void OnHelpWelcome(const CommandContext &context );
#if defined(EXPERIMENTAL_CRASH_REPORT)
void OnCrashReport(const CommandContext &context );
#endif
void OnAudioDeviceInfo(const CommandContext &context );
#ifdef EXPERIMENTAL_MIDI_OUT
void OnMidiDeviceInfo(const CommandContext &context );
#endif
public:
void UpdatePrefs() override;
};
@ -204,6 +179,11 @@ bool DoAudacityCommand(
const PluginID & ID, const CommandContext & context, unsigned flags );
}
namespace HelpActions {
void DoHelpWelcome( AudacityProject & );
void DoShowLog( AudacityProject& );
}
#endif

View File

@ -0,0 +1,298 @@
#include "../AboutDialog.h"
#include "../AudacityApp.h"
#include "../AudacityLogger.h"
#include "../AudioIO.h"
#include "../Dependencies.h"
#include "../Experimental.h"
#include "../FileNames.h"
#include "../Project.h"
#include "../ShuttleGui.h"
#include "../SplashDialog.h"
#include "../commands/CommandContext.h"
#include "../commands/CommandManager.h"
#include "../widgets/HelpSystem.h"
#if defined(EXPERIMENTAL_CRASH_REPORT)
#include <wx/debugrpt.h>
#endif
// private helper classes and functions
namespace {
}
namespace HelpActions {
// exported helper functions
void DoShowLog( AudacityProject & )
{
AudacityLogger *logger = wxGetApp().GetLogger();
if (logger) {
logger->Show();
}
}
void DoHelpWelcome( AudacityProject &project )
{
SplashDialog::Show2( &project );
}
// Menu handler functions
struct Handler : CommandHandlerObject {
void OnQuickFix(const CommandContext &context)
{
auto &project = context.project;
QuickFixDialog dlg( &project );
dlg.ShowModal();
}
void OnQuickHelp(const CommandContext &context)
{
auto &project = context.project;
HelpSystem::ShowHelp(
&project,
wxT("Quick_Help"));
}
void OnManual(const CommandContext &context)
{
auto &project = context.project;
HelpSystem::ShowHelp(
&project,
wxT("Main_Page"));
}
void OnAudioDeviceInfo(const CommandContext &context)
{
auto &project = context.project;
wxString info = gAudioIO->GetDeviceInfo();
wxDialogWrapper dlg(&project, wxID_ANY, wxString(_("Audio Device Info")));
dlg.SetName(dlg.GetTitle());
ShuttleGui S(&dlg, eIsCreating);
wxTextCtrl *text;
S.StartVerticalLay();
{
S.SetStyle(wxTE_MULTILINE | wxTE_READONLY);
text = S.Id(wxID_STATIC).AddTextWindow(info);
S.AddStandardButtons(eOkButton | eCancelButton);
}
S.EndVerticalLay();
dlg.FindWindowById(wxID_OK)->SetLabel(_("&Save"));
dlg.SetSize(350, 450);
if (dlg.ShowModal() == wxID_OK)
{
wxString fName = FileNames::SelectFile(FileNames::Operation::Export,
_("Save Device Info"),
wxEmptyString,
wxT("deviceinfo.txt"),
wxT("txt"),
wxT("*.txt"),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
&project);
if (!fName.IsEmpty())
{
if (!text->SaveFile(fName))
{
AudacityMessageBox(
_("Unable to save device info"), _("Save Device Info"));
}
}
}
}
#ifdef EXPERIMENTAL_MIDI_OUT
void OnMidiDeviceInfo(const CommandContext &context)
{
auto &project = context.project;
wxString info = gAudioIO->GetMidiDeviceInfo();
wxDialogWrapper dlg(&project, wxID_ANY, wxString(_("MIDI Device Info")));
dlg.SetName(dlg.GetTitle());
ShuttleGui S(&dlg, eIsCreating);
wxTextCtrl *text;
S.StartVerticalLay();
{
S.SetStyle(wxTE_MULTILINE | wxTE_READONLY);
text = S.Id(wxID_STATIC).AddTextWindow(info);
S.AddStandardButtons(eOkButton | eCancelButton);
}
S.EndVerticalLay();
dlg.FindWindowById(wxID_OK)->SetLabel(_("&Save"));
dlg.SetSize(350, 450);
if (dlg.ShowModal() == wxID_OK)
{
wxString fName = FileNames::SelectFile(FileNames::Operation::Export,
_("Save MIDI Device Info"),
wxEmptyString,
wxT("midideviceinfo.txt"),
wxT("txt"),
wxT("*.txt"),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
&project);
if (!fName.IsEmpty())
{
if (!text->SaveFile(fName))
{
AudacityMessageBox(
_("Unable to save MIDI device info"),
_("Save MIDI Device Info"));
}
}
}
}
#endif
void OnShowLog( const CommandContext &context )
{
DoShowLog( context.project );
}
#if defined(EXPERIMENTAL_CRASH_REPORT)
void OnCrashReport(const CommandContext &WXUNUSED(context) )
{
// Change to "1" to test a real crash
#if 0
char *p = 0;
*p = 1234;
#endif
wxGetApp().GenerateCrashReport(wxDebugReport::Context_Current);
}
#endif
void OnCheckDependencies(const CommandContext &context)
{
auto &project = context.project;
::ShowDependencyDialogIfNeeded(&project, false);
}
void OnCheckForUpdates(const CommandContext &WXUNUSED(context))
{
::OpenInDefaultBrowser( VerCheckUrl());
}
void OnAbout(const CommandContext &context)
{
#ifdef __WXMAC__
// Modeless dialog, consistent with other Mac applications
wxCommandEvent dummy;
wxGetApp().OnMenuAbout(dummy);
#else
auto &project = context.project;
// Windows and Linux still modal.
AboutDialog dlog(&project);
dlog.ShowModal();
#endif
}
#if 0
// Legacy handlers, not used as of version 2.3.0
// Only does the update checks if it's an ALPHA build and not disabled by
// preferences.
void MayCheckForUpdates(AudacityProject &project)
{
#ifdef IS_ALPHA
OnCheckForUpdates(project);
#endif
}
void OnHelpWelcome(const CommandContext &context)
{
DoHelpWelcome( context.project );
}
#endif
}; // struct Handler
} // namespace
static CommandHandlerObject &findCommandHandler(AudacityProject &) {
// Handler is not stateful. Doesn't need a factory registered with
// AudacityProject.
static HelpActions::Handler instance;
return instance;
};
// Menu definitions
#define FN(X) findCommandHandler, \
static_cast<CommandFunctorPointer>(& HelpActions::Handler :: X)
#define XXO(X) _(X), wxString{X}.Contains("...")
MenuTable::BaseItemPtr HelpMenu( AudacityProject & )
{
#ifdef __WXMAC__
wxGetApp().s_macHelpMenuTitleName = _("&Help");
#endif
using namespace MenuTable;
return Menu( _("&Help"),
Command( wxT("QuickFix"), XXO("&Quick Fix..."), FN(OnQuickFix),
AlwaysEnabledFlag ),
// DA: Emphasise it is the Audacity Manual (No separate DA manual).
#ifdef EXPERIMENTAL_DA
// 'Getting Started' rather than 'Quick Help' for DarkAudacity.
// At the moment the video tutorials are aspirational (aka do not exist
// yet). Emphasise that manual is for Audacity, not DarkAudacity.
Command( wxT("QuickHelp"), XXO("&Getting Started"), FN(OnQuickHelp) ),
Command( wxT("Manual"), XXO("Audacity &Manual"), FN(OnManual) ),
#else
Command( wxT("QuickHelp"), XXO("&Quick Help..."), FN(OnQuickHelp),
AlwaysEnabledFlag ),
Command( wxT("Manual"), XXO("&Manual..."), FN(OnManual),
AlwaysEnabledFlag ),
#endif
Separator(),
Menu( _("&Diagnostics"),
Command( wxT("DeviceInfo"), XXO("Au&dio Device Info..."),
FN(OnAudioDeviceInfo),
AudioIONotBusyFlag ),
#ifdef EXPERIMENTAL_MIDI_OUT
Command( wxT("MidiDeviceInfo"), XXO("&MIDI Device Info..."),
FN(OnMidiDeviceInfo),
AudioIONotBusyFlag ),
#endif
Command( wxT("Log"), XXO("Show &Log..."), FN(OnShowLog),
AlwaysEnabledFlag ),
#if defined(EXPERIMENTAL_CRASH_REPORT)
Command( wxT("CrashReport"), XXO("&Generate Support Data..."),
FN(OnCrashReport), AlwaysEnabledFlag ),
#endif
Command( wxT("CheckDeps"), XXO("Chec&k Dependencies..."),
FN(OnCheckDependencies),
AudioIONotBusyFlag )
),
#ifndef __WXMAC__
Separator(),
#endif
// DA: Does not fully support update checking.
#ifndef EXPERIMENTAL_DA
Command( wxT("Updates"), XXO("&Check for Updates..."),
FN(OnCheckForUpdates),
AlwaysEnabledFlag ),
#endif
Command( wxT("About"), XXO("&About Audacity..."), FN(OnAbout),
AlwaysEnabledFlag )
);
}
#undef XXO
#undef FN

View File

@ -154,7 +154,7 @@ void MultiDialog::OnOK(wxCommandEvent & WXUNUSED(event))
void MultiDialog::OnShowLog(wxCommandEvent & WXUNUSED(event))
{
auto project = GetActiveProject();
GetMenuCommandHandler(*project).OnShowLog(*project);
HelpActions::DoShowLog(*project);
}