mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-08 16:37:44 +02:00
Use a hook to implement the shift-click shortcut to keyboard prefs...
This frees EIGHTEEN files from the big strongly connected component!! They are: Dependencies Export ExportCL ExportFFmpeg ExportFFmpegDialogs ExportFLAC EportMP2 ExportMP3 ExportOGG ExportPCM ExtImportPrefs Import ImportRaw KeyConfigPrefs KeyView LibraryPrefs PrefsDialog SpectrumPrefs ... and that includes all of the remaining *Prefs files. It does still leave the nine Export* files in a smaller s.c.c, which could be broken with a registration system, as was done for import at commit e2cf1d9
This commit is contained in:
parent
d69a76dc6f
commit
7b09225bf7
@ -108,6 +108,10 @@ It handles initialization and termination by subclassing wxApp.
|
||||
#include "tracks/ui/Scrubbing.h"
|
||||
#include "widgets/FileHistory.h"
|
||||
|
||||
#ifdef EXPERIMENTAL_EASY_CHANGE_KEY_BINDINGS
|
||||
#include "../prefs/KeyConfigPrefs.h"
|
||||
#endif
|
||||
|
||||
//temporarily commented out till it is added to all projects
|
||||
//#include "Profiler.h"
|
||||
|
||||
@ -1593,6 +1597,23 @@ bool AudacityApp::OnInit()
|
||||
mTimer.SetOwner(this, kAudacityAppTimerID);
|
||||
mTimer.Start(200);
|
||||
|
||||
#ifdef EXPERIMENTAL_EASY_CHANGE_KEY_BINDINGS
|
||||
CommandManager::SetMenuHook( [](const CommandID &id){
|
||||
if (::wxGetMouseState().ShiftDown()) {
|
||||
// Only want one page of the preferences
|
||||
PrefsDialog::Factories factories;
|
||||
factories.push_back(KeyConfigPrefsFactory( id ));
|
||||
auto pWindow = FindProjectFrame( GetActiveProject() );
|
||||
GlobalPrefsDialog dialog( pWindow, factories );
|
||||
dialog.ShowModal();
|
||||
MenuCreator::RebuildAllMenuBars();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
} );
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -170,6 +170,20 @@ const CommandManager &CommandManager::Get( const AudacityProject &project )
|
||||
return Get( const_cast< AudacityProject & >( project ) );
|
||||
}
|
||||
|
||||
static CommandManager::MenuHook &sMenuHook()
|
||||
{
|
||||
static CommandManager::MenuHook theHook;
|
||||
return theHook;
|
||||
}
|
||||
|
||||
auto CommandManager::SetMenuHook( const MenuHook &hook ) -> MenuHook
|
||||
{
|
||||
auto &theHook = sMenuHook();
|
||||
auto result = theHook;
|
||||
theHook = hook;
|
||||
return result;
|
||||
}
|
||||
|
||||
///
|
||||
/// Standard Constructor
|
||||
///
|
||||
@ -1272,24 +1286,13 @@ bool CommandManager::HandleCommandEntry(const CommandListEntry * entry,
|
||||
///CommandManagerListener function. If you pass any flags,
|
||||
///the command won't be executed unless the flags are compatible
|
||||
///with the command's flags.
|
||||
#include "../prefs/PrefsDialog.h"
|
||||
#include "../prefs/KeyConfigPrefs.h"
|
||||
bool CommandManager::HandleMenuID(int id, CommandFlag flags, CommandMask mask)
|
||||
{
|
||||
CommandListEntry *entry = mCommandNumericIDHash[id];
|
||||
|
||||
#ifdef EXPERIMENTAL_EASY_CHANGE_KEY_BINDINGS
|
||||
if (::wxGetMouseState().ShiftDown()) {
|
||||
// Only want one page of the preferences
|
||||
PrefsDialog::Factories factories;
|
||||
factories.push_back(KeyConfigPrefsFactory( entry->name ));
|
||||
auto pWindow = FindProjectFrame( GetActiveProject() );
|
||||
GlobalPrefsDialog dialog( pWindow, factories );
|
||||
dialog.ShowModal();
|
||||
MenuCreator::RebuildAllMenuBars();
|
||||
auto hook = sMenuHook();
|
||||
if (hook && hook(entry->name))
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return HandleCommandEntry( entry, flags, mask );
|
||||
}
|
||||
|
@ -108,6 +108,13 @@ class AUDACITY_DLL_API CommandManager final
|
||||
static CommandManager &Get( AudacityProject &project );
|
||||
static const CommandManager &Get( const AudacityProject &project );
|
||||
|
||||
// Type of a function that can intercept menu item handling.
|
||||
// If it returns true, bypass the usual dipatch of commands.
|
||||
using MenuHook = std::function< bool(const CommandID&) >;
|
||||
|
||||
// install a menu hook, returning the previously installed one
|
||||
static MenuHook SetMenuHook( const MenuHook &hook );
|
||||
|
||||
//
|
||||
// Constructor / Destructor
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user