mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-03 09:09:47 +02:00
Fix: Same hot-key configurable to multiple commands. (Bug 229)
This commit is contained in:
parent
0ab9f7cd41
commit
01c8c239d0
@ -361,36 +361,34 @@ void KeyConfigPrefs::OnCaptureChar(wxKeyEvent & e)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Given a hotkey combination, returns the name (description) of the
|
||||||
|
// corresponding command, or the empty string if none is found.
|
||||||
|
wxString KeyConfigPrefs::NameFromKey( const wxString & Key )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
i=mKeys.Index( Key );
|
||||||
|
if( i== wxNOT_FOUND )
|
||||||
|
return wxT("");
|
||||||
|
return mNames[i];
|
||||||
|
}
|
||||||
|
|
||||||
void KeyConfigPrefs::OnSet(wxCommandEvent & e)
|
void KeyConfigPrefs::OnSet(wxCommandEvent & e)
|
||||||
{
|
{
|
||||||
if (mCommandSelected < 0 || mCommandSelected >= mNames.GetCount()) {
|
if (mCommandSelected < 0 || mCommandSelected >= mNames.GetCount())
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
wxString newKey = mKey->GetValue();
|
wxString newKey = mKey->GetValue();
|
||||||
|
wxString alreadyAssignedName = NameFromKey( newKey );
|
||||||
|
|
||||||
// Check if shortcut has already been assigned
|
// Prevent same hotkey combination being used twice.
|
||||||
for (int i = 0; i < mList->GetItemCount(); i++) {
|
if( !alreadyAssignedName.IsEmpty() ) {
|
||||||
wxListItem item;
|
wxMessageBox(
|
||||||
|
wxString::Format(
|
||||||
item.SetColumn(KeyComboColumn);
|
_("The keyboard shortcut '%s' is already assigned to:\n\n'%s'"),
|
||||||
item.SetMask(wxLIST_MASK_TEXT);
|
newKey.c_str(),
|
||||||
item.SetId(i);
|
alreadyAssignedName.c_str()),
|
||||||
mList->GetItem(item);
|
_("Error"), wxICON_STOP | wxCENTRE, this);
|
||||||
|
return;
|
||||||
if (item.GetText() == newKey) {
|
|
||||||
item.SetColumn(CommandColumn);
|
|
||||||
mList->GetItem(item);
|
|
||||||
|
|
||||||
wxString prompt;
|
|
||||||
prompt = wxString::Format(_("The keyboard shortcut '%s' is already assigned to:\n\n'%s'"),
|
|
||||||
newKey.c_str(),
|
|
||||||
item.GetText().c_str());
|
|
||||||
|
|
||||||
wxMessageBox(prompt, _("Error"), wxICON_STOP | wxCENTRE, this);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mList->SetItem(mCommandSelected, KeyComboColumn, newKey);
|
mList->SetItem(mCommandSelected, KeyComboColumn, newKey);
|
||||||
|
@ -35,6 +35,7 @@ class KeyConfigPrefs:public PrefsPanel
|
|||||||
void PopulateOrExchange(ShuttleGui & S);
|
void PopulateOrExchange(ShuttleGui & S);
|
||||||
void CreateList();
|
void CreateList();
|
||||||
void RepopulateBindingsList();
|
void RepopulateBindingsList();
|
||||||
|
wxString NameFromKey( const wxString & Key );
|
||||||
|
|
||||||
void OnDefaults(wxCommandEvent & e);
|
void OnDefaults(wxCommandEvent & e);
|
||||||
void OnLoad(wxCommandEvent & e);
|
void OnLoad(wxCommandEvent & e);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user