mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-21 23:00:06 +02:00
Hotkeys for effects. (uses numbers for effect names)
This commit is contained in:
parent
b0446f3216
commit
d1afc6e8c5
@ -1212,7 +1212,7 @@ void AudacityProject::CreateMenusAndCommands()
|
||||
mSel1save = 0;
|
||||
|
||||
#if defined(__WXDEBUG__)
|
||||
c->CheckDups();
|
||||
// c->CheckDups();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -665,7 +665,10 @@ int CommandManager::NewIdentifier(wxString name, wxString label, wxMenu *menu,
|
||||
#endif
|
||||
|
||||
tmpEntry->defaultKey = tmpEntry->key;
|
||||
if( multi )
|
||||
name= name + wxString::Format(wxT("%d"),index );
|
||||
tmpEntry->name = name;
|
||||
|
||||
tmpEntry->label = label;
|
||||
tmpEntry->labelPrefix = labelPrefix;
|
||||
tmpEntry->labelTop = wxMenuItem::GetLabelFromText(mCurrentMenuName);
|
||||
@ -840,6 +843,13 @@ void CommandManager::SetKeyFromName(wxString name, wxString key)
|
||||
}
|
||||
}
|
||||
|
||||
void CommandManager::SetKeyFromIndex(int i, wxString key)
|
||||
{
|
||||
CommandListEntry *entry = mCommandList[i];
|
||||
entry->key = KeyStringNormalize(key);
|
||||
}
|
||||
|
||||
|
||||
void CommandManager::HandleMenuOpen(wxMenuEvent &evt)
|
||||
{
|
||||
// Ensure we have a menu and that it's a top-level menu.
|
||||
@ -1098,11 +1108,51 @@ void CommandManager::GetAllCommandNames(wxArrayString &names,
|
||||
unsigned int i;
|
||||
|
||||
for(i=0; i<mCommandList.GetCount(); i++) {
|
||||
if (includeMultis || !mCommandList[i]->multi)
|
||||
if (!mCommandList[i]->multi)
|
||||
names.Add(mCommandList[i]->name);
|
||||
else if( includeMultis )
|
||||
names.Add(mCommandList[i]->name + wxT(":")/*+ mCommandList[i]->label*/);
|
||||
}
|
||||
}
|
||||
|
||||
void CommandManager::GetAllCommandLabels(wxArrayString &names,
|
||||
bool includeMultis)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for(i=0; i<mCommandList.GetCount(); i++) {
|
||||
if (!mCommandList[i]->multi)
|
||||
names.Add(mCommandList[i]->label);
|
||||
else if( includeMultis )
|
||||
names.Add(mCommandList[i]->label);
|
||||
}
|
||||
}
|
||||
|
||||
void CommandManager::GetAllCommandData(
|
||||
wxArrayString &names, wxArrayString &keys, wxArrayString &default_keys, wxArrayString &labels, wxArrayString & categories,
|
||||
bool includeMultis)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for(i=0; i<mCommandList.GetCount(); i++) {
|
||||
if (!mCommandList[i]->multi)
|
||||
{
|
||||
names.Add(mCommandList[i]->name);
|
||||
keys.Add(mCommandList[i]->key);
|
||||
default_keys.Add( mCommandList[i]->defaultKey);
|
||||
labels.Add(mCommandList[i]->label);
|
||||
categories.Add(mCommandList[i]->labelTop);
|
||||
}
|
||||
else if( includeMultis )
|
||||
{
|
||||
names.Add(mCommandList[i]->name);
|
||||
keys.Add(mCommandList[i]->key);
|
||||
default_keys.Add( mCommandList[i]->defaultKey);
|
||||
labels.Add(mCommandList[i]->label);
|
||||
categories.Add(mCommandList[i]->labelTop);
|
||||
}
|
||||
}
|
||||
}
|
||||
wxString CommandManager::GetLabelFromName(wxString name)
|
||||
{
|
||||
CommandListEntry *entry = mCommandNameHash[name];
|
||||
|
@ -169,6 +169,7 @@ class AUDACITY_DLL_API CommandManager: public XMLTagHandler
|
||||
// Modifying accelerators
|
||||
//
|
||||
void SetKeyFromName(wxString name, wxString key);
|
||||
void SetKeyFromIndex(int i, wxString key);
|
||||
|
||||
//
|
||||
// Displaying menus
|
||||
@ -191,6 +192,11 @@ class AUDACITY_DLL_API CommandManager: public XMLTagHandler
|
||||
|
||||
void GetCategories(wxArrayString &cats);
|
||||
void GetAllCommandNames(wxArrayString &names, bool includeMultis);
|
||||
void GetAllCommandLabels(wxArrayString &labels, bool includeMultis);
|
||||
void CommandManager::GetAllCommandData(
|
||||
wxArrayString &names, wxArrayString &keys, wxArrayString &default_keys,
|
||||
wxArrayString &labels, wxArrayString & categories,
|
||||
bool includeMultis);
|
||||
|
||||
wxString GetLabelFromName(wxString name);
|
||||
wxString GetPrefixedLabelFromName(wxString name);
|
||||
|
@ -212,14 +212,24 @@ void KeyConfigPrefs::RepopulateBindingsList()
|
||||
|
||||
mList->DeleteAllItems(); // Delete contents, but not the column headers.
|
||||
mNames.Clear();
|
||||
mManager->GetAllCommandNames(mNames, false);
|
||||
mDefaultKeys.Clear();
|
||||
wxArrayString Keys,Labels,Categories;
|
||||
|
||||
mManager->GetAllCommandData(
|
||||
mNames,
|
||||
Keys,
|
||||
mDefaultKeys,
|
||||
Labels,
|
||||
Categories,
|
||||
true ); // JKC change to true to include effects (list items).
|
||||
|
||||
bool save = (mKeys.GetCount() == 0);
|
||||
|
||||
size_t ndx = 0;
|
||||
int color = 0;
|
||||
for (size_t i = 0; i < mNames.GetCount(); i++) {
|
||||
wxString name = mNames[i];
|
||||
wxString key = KeyStringDisplay(mManager->GetKeyFromName(name));
|
||||
wxString key = KeyStringDisplay(Keys[i]);
|
||||
|
||||
// Save the original key value to support canceling
|
||||
if (save) {
|
||||
@ -228,10 +238,10 @@ void KeyConfigPrefs::RepopulateBindingsList()
|
||||
mNewKeys.Add(key);
|
||||
}
|
||||
|
||||
if (cat != _("All") && mManager->GetCategoryFromName(name) != cat) {
|
||||
// if (cat != _("All") && ! Categories[i].StartsWith(cat)) {
|
||||
if (cat != _("All") && ! (Categories[i]== cat)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
wxString label;
|
||||
|
||||
// Labels for undo and redo change according to the last command
|
||||
@ -244,7 +254,7 @@ void KeyConfigPrefs::RepopulateBindingsList()
|
||||
label = _("Redo");
|
||||
}
|
||||
else {
|
||||
label = mManager->GetPrefixedLabelFromName(name);
|
||||
label = Labels[i];//mManager->GetPrefixedLabelFromName(name);
|
||||
}
|
||||
|
||||
label = wxMenuItem::GetLabelFromText(label.BeforeFirst(wxT('\t')));
|
||||
@ -334,8 +344,7 @@ void KeyConfigPrefs::OnSave(wxCommandEvent & e)
|
||||
void KeyConfigPrefs::OnDefaults(wxCommandEvent & e)
|
||||
{
|
||||
for (size_t i = 0; i < mNames.GetCount(); i++) {
|
||||
mManager->SetKeyFromName(mNames[i],
|
||||
mManager->GetDefaultKeyFromName(mNames[i]));
|
||||
mManager->SetKeyFromIndex(i,mDefaultKeys[i]);
|
||||
}
|
||||
RepopulateBindingsList();
|
||||
}
|
||||
@ -379,14 +388,20 @@ wxString KeyConfigPrefs::NameFromKey( const wxString & key )
|
||||
// This is not yet a committed change, which will happen on a save.
|
||||
void KeyConfigPrefs::SetKeyForSelected( const wxString & key )
|
||||
{
|
||||
wxString name = mNames[mList->GetItemData(mCommandSelected)];
|
||||
int i = mList->GetItemData(mCommandSelected);
|
||||
wxString name = mNames[i];
|
||||
|
||||
mList->SetItem(mCommandSelected, KeyComboColumn, key);
|
||||
mManager->SetKeyFromName(name, key);
|
||||
mManager->SetKeyFromIndex(i, key);
|
||||
|
||||
#if 0
|
||||
int i=mNames.Index( name );
|
||||
if( i!=wxNOT_FOUND )
|
||||
mNewKeys[i]=key;
|
||||
#endif
|
||||
|
||||
mNewKeys[i]=key;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -521,9 +536,11 @@ void KeyConfigPrefs::OnItemSelected(wxListEvent & e)
|
||||
bool KeyConfigPrefs::Apply()
|
||||
{
|
||||
for (size_t i = 0; i < mNames.GetCount(); i++) {
|
||||
wxString dkey = KeyStringNormalize(mManager->GetDefaultKeyFromName(mNames[i]));
|
||||
// wxString dkey = KeyStringNormalize(mManager->GetDefaultKeyFromName(mNames[i]));
|
||||
wxString dkey = KeyStringNormalize(mDefaultKeys[i]);
|
||||
wxString name = wxT("/NewKeys/") + mNames[i];
|
||||
wxString key = KeyStringNormalize(mManager->GetKeyFromName(mNames[i]));
|
||||
// wxString key = KeyStringNormalize(mManager->GetKeyFromName(mNames[i]));
|
||||
wxString key = KeyStringNormalize(mNewKeys[i]);
|
||||
|
||||
if (gPrefs->HasEntry(name)) {
|
||||
if (key != KeyStringNormalize(gPrefs->Read(name, key))) {
|
||||
@ -547,7 +564,7 @@ void KeyConfigPrefs::Cancel()
|
||||
{
|
||||
// Restore original key values
|
||||
for (size_t i = 0; i < mNames.GetCount(); i++) {
|
||||
mManager->SetKeyFromName(mNames[i], mKeys[i]);
|
||||
mManager->SetKeyFromIndex(i, mKeys[i]);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -59,6 +59,7 @@ class KeyConfigPrefs:public PrefsPanel
|
||||
|
||||
wxArrayString mCats;
|
||||
wxArrayString mNames;
|
||||
wxArrayString mDefaultKeys;
|
||||
wxArrayString mKeys;
|
||||
wxArrayString mNewKeys; // Used for work in progress.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user