1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-16 01:21:25 +01:00

Reduce number of shortcuts provided by default.

The full list of shortcuts, the maxList, is still available, and can be set in KeyboardPreferences.
This commit is contained in:
James Crook
2017-06-28 23:00:02 +01:00
parent 17b705f2d8
commit a9cbebcb0f
4 changed files with 106 additions and 11 deletions

View File

@@ -425,6 +425,9 @@ CommandManager::CommandManager():
bMakingOccultCommands( false )
{
mbSeparatorAllowed = false;
SetMaxList();
}
///
@@ -436,6 +439,75 @@ CommandManager::~CommandManager()
PurgeData();
}
// CommandManager needs to know which defaults are standard and which are in the
// full (max) list.
void CommandManager::SetMaxList()
{
// This list is a DUPLICATE of the list in
// KeyConfigPrefs::OnImportDefaults(wxCommandEvent & event)
// TODO: At a later date get rid of the maxList entirely and
// instead use flags in the menu entrys to indicate whether the default
// shortcut is standard or full.
mMaxListOnly.Clear();
// These short cuts are for the max list only....
//mMaxListOnly.Add( "Ctrl+I" );
mMaxListOnly.Add( "Ctrl+Alt+I" );
mMaxListOnly.Add( "Ctrl+J" );
mMaxListOnly.Add( "Ctrl+Alt+J" );
mMaxListOnly.Add( "Ctrl+Alt+V" );
mMaxListOnly.Add( "Alt+X" );
mMaxListOnly.Add( "Alt+K" );
mMaxListOnly.Add( "Shift+Alt+X" );
mMaxListOnly.Add( "Shift+Alt+K" );
mMaxListOnly.Add( "Alt+L" );
mMaxListOnly.Add( "Shift+Alt+C" );
mMaxListOnly.Add( "Alt+I" );
mMaxListOnly.Add( "Alt+J" );
mMaxListOnly.Add( "Shift+Alt+J" );
mMaxListOnly.Add( "Ctrl+Shift+A" );
mMaxListOnly.Add( "Q" );
mMaxListOnly.Add( "Shift+J" );
mMaxListOnly.Add( "Shift+K" );
//mMaxListOnly.Add( "Shift+Home" );
//mMaxListOnly.Add( "Shift+End" );
mMaxListOnly.Add( "Ctrl+[" );
mMaxListOnly.Add( "Ctrl+]" );
mMaxListOnly.Add( "1" );
mMaxListOnly.Add( "Shift+F5" );
mMaxListOnly.Add( "Shift+F6" );
mMaxListOnly.Add( "Shift+F7" );
mMaxListOnly.Add( "Shift+F8" );
mMaxListOnly.Add( "Ctrl+Shift+F5" );
mMaxListOnly.Add( "Ctrl+Shift+F7" );
mMaxListOnly.Add( "Ctrl+Shift+N" );
mMaxListOnly.Add( "Ctrl+Shift+M" );
mMaxListOnly.Add( "Ctrl+Home" );
mMaxListOnly.Add( "Ctrl+End" );
mMaxListOnly.Add( "Shift+C" );
mMaxListOnly.Add( "Alt+Shift+Up" );
mMaxListOnly.Add( "Alt+Shift+Down" );
mMaxListOnly.Add( "Shift+P" );
mMaxListOnly.Add( "Alt+Shift+Left" );
mMaxListOnly.Add( "Alt+Shift+Right" );
mMaxListOnly.Add( "Ctrl+Shift+T" );
//mMaxListOnly.Add( "Command+M" );
//mMaxListOnly.Add( "Option+Command+M" );
mMaxListOnly.Add( "Shift+H" );
mMaxListOnly.Add( "Shift+O" );
mMaxListOnly.Add( "Shift+I" );
mMaxListOnly.Add( "Shift+N" );
mMaxListOnly.Add( "D" );
mMaxListOnly.Add( "A" );
mMaxListOnly.Add( "Alt+Shift+F6" );
mMaxListOnly.Add( "Alt+F6" );
mMaxListOnly.Sort();
}
void CommandManager::PurgeData()
{
// mCommandList contains pointers to CommandListEntrys
@@ -908,6 +980,14 @@ CommandListEntry *CommandManager::NewIdentifier(const wxString & name,
entry->isGlobal = false;
entry->isOccult = bMakingOccultCommands;
// Exclude accelerators that are in the MaxList.
// Note that the default is unaffected, intentionally so.
// There are effectively two levels of default, the full (max) list
// and the normal reduced list.
if( mMaxListOnly.Index( entry->key ) !=-1)
entry->key = wxT("");
// For key bindings for commands with a list, such as effects,
// the name in prefs is the category name plus the effect name.
if (multi) {

View File

@@ -105,6 +105,7 @@ class AUDACITY_DLL_API CommandManager final : public XMLTagHandler
CommandManager(const CommandManager&) PROHIBITED;
CommandManager &operator= (const CommandManager&) PROHIBITED;
void SetMaxList();
void PurgeData();
//
@@ -316,6 +317,9 @@ protected:
XMLTagHandler *HandleXMLChild(const wxChar *tag) override;
private:
// mMaxList only holds shortcuts that should not be added (by default).
wxSortedArrayString mMaxListOnly;
MenuBarList mMenuBarList;
SubMenuList mSubMenuList;
CommandList mCommandList;

View File

@@ -305,6 +305,7 @@ void KeyConfigPrefs::RefreshBindings(bool bSort)
mNames.Clear();
mKeys.Clear();
mDefaultKeys.Clear();
mStandardDefaultKeys.Clear();
mManager->GetAllCommandData(
mNames,
mKeys,
@@ -314,6 +315,9 @@ void KeyConfigPrefs::RefreshBindings(bool bSort)
Prefixes,
true); // True to include effects (list items), false otherwise.
mStandardDefaultKeys = mDefaultKeys;
FilterKeys( mStandardDefaultKeys );
mView->RefreshBindings(mNames,
Categories,
Prefixes,
@@ -401,10 +405,8 @@ void KeyConfigPrefs::OnDefaults(wxCommandEvent & event)
PopupMenu(&Menu);//, wxPoint(0, 0));
}
void KeyConfigPrefs::OnImportDefaults(wxCommandEvent & event)
void KeyConfigPrefs::FilterKeys( wxArrayString & arr )
{
int id = event.GetId();
mNewKeys = mDefaultKeys;
wxSortedArrayString MaxListOnly;
// These short cuts are for the max list only....
@@ -460,14 +462,21 @@ void KeyConfigPrefs::OnImportDefaults(wxCommandEvent & event)
MaxListOnly.Add( "Alt+F6" );
MaxListOnly.Sort();
// Remove items that are in MaxList.
for (size_t i = 0; i < arr.GetCount(); i++) {
if( MaxListOnly.Index( arr[i] ) != wxNOT_FOUND )
arr[i]= wxT("");
}
}
void KeyConfigPrefs::OnImportDefaults(wxCommandEvent & event)
{
mNewKeys = mDefaultKeys;
if( event.GetId() == 0 )
FilterKeys( mNewKeys );
for (size_t i = 0; i < mNewKeys.GetCount(); i++) {
// Proof of concept for idea for freeing up some unwanted bindings.
// There will be neater code idioms we can use.
bool bDeleteBinding = false;
if( id == 0 )
bDeleteBinding |= ( MaxListOnly.Index( mNewKeys[i] ) != wxNOT_FOUND );
mManager->SetKeyFromIndex(i, bDeleteBinding ? "" : mNewKeys[i]);
mManager->SetKeyFromIndex(i, mNewKeys[i]);
}
RefreshBindings(true);
@@ -703,7 +712,7 @@ bool KeyConfigPrefs::Commit()
PopulateOrExchange(S);
for (size_t i = 0; i < mNames.GetCount(); i++) {
wxString dkey = KeyStringNormalize(mDefaultKeys[i]);
wxString dkey = KeyStringNormalize(mStandardDefaultKeys[i]);
wxString name = wxT("/NewKeys/") + mNames[i];
wxString key = KeyStringNormalize(mNewKeys[i]);

View File

@@ -47,6 +47,7 @@ private:
void Populate();
void PopulateOrExchange(ShuttleGui & S);
void RefreshBindings(bool bSort);
void FilterKeys( wxArrayString & arr );
wxString NameFromKey(const wxString & key);
void SetKeyForSelected(const wxString & key);
@@ -86,7 +87,8 @@ private:
int mCommandSelected;
wxArrayString mNames;
wxArrayString mDefaultKeys;
wxArrayString mDefaultKeys; // The full set.
wxArrayString mStandardDefaultKeys; // The reduced set.
wxArrayString mKeys;
wxArrayString mNewKeys; // Used for work in progress.