[DolphinWX] Prevent hotkeys from being assigned to more than one button/function.

Prior to this commit it was possible to assign the same keycode to more than one button.

ie. Say I assigned Open with the hotkey Ctrl+O; well, it was possible to also add it to another function as well, which leads to hotkey clashing.

Now, say I assign Open with Ctrl+O, but then assign that same hotkey to Refresh List; it will unbind the hotkey from Open and then assign it to refresh list.
This commit is contained in:
Lioncash 2014-01-22 18:28:08 -05:00
parent eb29177c5a
commit 391d26d3bf

View File

@ -72,6 +72,26 @@ void HotkeyConfigDialog::OnKeyDown(wxKeyEvent& event)
}
else
{
// Check if the hotkey combination was already applied to another button
// and unapply it if necessary.
for (wxButton* btn : m_Button_Hotkeys)
{
// We compare against this to see if we have a duplicate bind attempt.
wxString existingHotkey = btn->GetLabel();
wxString tentativeModKey = InputCommon::WXKeymodToString(g_Modkey);
wxString tentativePressedKey = InputCommon::WXKeyToString(g_Pressed);
wxString tentativeHotkey(tentativeModKey + tentativePressedKey);
// Found a button that already has this binding. Unbind it.
if (tentativeHotkey == existingHotkey)
{
SaveButtonMapping(btn->GetId(), -1, 0);
SetButtonText(btn->GetId(), wxString());
}
}
// Proceed to apply the binding to the selected button.
SetButtonText(ClickedButton->GetId(),
InputCommon::WXKeyToString(g_Pressed),
InputCommon::WXKeymodToString(g_Modkey));