Formatting.

This commit is contained in:
Jeff Young 2020-12-10 22:26:35 +00:00
parent a1f9b68e3c
commit fc57860caf
2 changed files with 25 additions and 27 deletions

View File

@ -113,7 +113,8 @@ void PANEL_HOTKEYS_EDITOR::installButtons( wxSizer* aSizer )
wxID_RESET, wxID_RESET,
_( "Undo All Changes" ), _( "Undo All Changes" ),
_( "Undo all changes made so far in this dialog" ), _( "Undo all changes made so far in this dialog" ),
[this]( wxCommandEvent& ){ [this]( wxCommandEvent& )
{
m_hotkeyListCtrl->ResetAllHotkeys( false ); m_hotkeyListCtrl->ResetAllHotkeys( false );
} }
}, },
@ -121,7 +122,8 @@ void PANEL_HOTKEYS_EDITOR::installButtons( wxSizer* aSizer )
wxID_ANY, wxID_ANY,
_( "Import Hotkeys..." ), _( "Import Hotkeys..." ),
_( "Import hotkey definitions from an external file, replacing the current values" ), _( "Import hotkey definitions from an external file, replacing the current values" ),
[this]( wxCommandEvent& ){ [this]( wxCommandEvent& )
{
ImportHotKeys(); ImportHotKeys();
} }
} }

View File

@ -55,8 +55,8 @@ class WIDGET_HOTKEY_CLIENT_DATA : public wxClientData
HOTKEY& m_changed_hotkey; HOTKEY& m_changed_hotkey;
public: public:
WIDGET_HOTKEY_CLIENT_DATA( HOTKEY& aChangedHotkey ) WIDGET_HOTKEY_CLIENT_DATA( HOTKEY& aChangedHotkey ) :
: m_changed_hotkey( aChangedHotkey ) m_changed_hotkey( aChangedHotkey )
{} {}
HOTKEY& GetChangedHotkey() { return m_changed_hotkey; } HOTKEY& GetChangedHotkey() { return m_changed_hotkey; }
@ -72,8 +72,8 @@ class HK_PROMPT_DIALOG : public DIALOG_SHIM
public: public:
HK_PROMPT_DIALOG( wxWindow* aParent, wxWindowID aId, const wxString& aTitle, HK_PROMPT_DIALOG( wxWindow* aParent, wxWindowID aId, const wxString& aTitle,
const wxString& aName, const wxString& aCurrentKey ) const wxString& aName, const wxString& aCurrentKey ) :
: DIALOG_SHIM( aParent, aId, aTitle, wxDefaultPosition, wxDefaultSize ) DIALOG_SHIM( aParent, aId, aTitle, wxDefaultPosition, wxDefaultSize )
{ {
wxPanel* panel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize ); wxPanel* panel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize );
wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
@ -89,7 +89,8 @@ public:
*/ */
wxStaticText* inst_label = new wxStaticText( panel, wxID_ANY, wxEmptyString, wxStaticText* inst_label = new wxStaticText( panel, wxID_ANY, wxEmptyString,
wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL ); wxDefaultPosition, wxDefaultSize,
wxALIGN_CENTRE_HORIZONTAL );
inst_label->SetLabelText( _( "Press a new hotkey, or press Esc to cancel..." ) ); inst_label->SetLabelText( _( "Press a new hotkey, or press Esc to cancel..." ) );
sizer->Add( inst_label, 0, wxALL, 5 ); sizer->Add( inst_label, 0, wxALL, 5 );
@ -127,14 +128,12 @@ public:
SetMinClientSize( GetClientSize() ); SetMinClientSize( GetClientSize() );
// Binding both EVT_CHAR and EVT_CHAR_HOOK ensures that all key events, // Binding both EVT_CHAR and EVT_CHAR_HOOK ensures that all key events, including
// including specials like Tab and Return, are received, particularly // specials like Tab and Return, are received, particularly on MSW.
// on MSW.
panel->Bind( wxEVT_CHAR, &HK_PROMPT_DIALOG::OnChar, this ); panel->Bind( wxEVT_CHAR, &HK_PROMPT_DIALOG::OnChar, this );
panel->Bind( wxEVT_CHAR_HOOK, &HK_PROMPT_DIALOG::OnCharHook, this ); panel->Bind( wxEVT_CHAR_HOOK, &HK_PROMPT_DIALOG::OnCharHook, this );
} }
/** /**
* End the dialog whether modal or quasimodal * End the dialog whether modal or quasimodal
*/ */
@ -146,9 +145,8 @@ public:
EndModal( aRtnCode ); EndModal( aRtnCode );
} }
static wxKeyEvent PromptForKey( wxWindow* aParent, const wxString& aName, static wxKeyEvent PromptForKey( wxWindow* aParent, const wxString& aName,
const wxString& aCurrentKey ) const wxString& aCurrentKey )
{ {
HK_PROMPT_DIALOG dialog( aParent, wxID_ANY, _( "Set Hotkey" ), aName, aCurrentKey ); HK_PROMPT_DIALOG dialog( aParent, wxID_ANY, _( "Set Hotkey" ), aName, aCurrentKey );
@ -158,22 +156,20 @@ public:
return wxKeyEvent(); return wxKeyEvent();
} }
protected: protected:
void OnCharHook( wxKeyEvent& aEvent ) override void OnCharHook( wxKeyEvent& aEvent ) override
{ {
// On certain platforms, EVT_CHAR_HOOK is the only handler that receives // On certain platforms, EVT_CHAR_HOOK is the only handler that receives certain
// certain "special" keys. However, it doesn't always receive "normal" // "special" keys. However, it doesn't always receive "normal" keys correctly. For
// keys correctly. For example, with a US keyboard, it sees ? as shift+/. // example, with a US keyboard, it sees ? as shift+/.
// //
// Untangling these incorrect keys would be too much trouble, so we bind // Untangling these incorrect keys would be too much trouble, so we bind both events,
// both events, and simply skip the EVT_CHAR_HOOK if it receives a // and simply skip the EVT_CHAR_HOOK if it receives a "normal" key.
// "normal" key.
const enum wxKeyCode skipped_keys[] = const enum wxKeyCode skipped_keys[] =
{ {
WXK_NONE, WXK_SHIFT, WXK_ALT, WXK_CONTROL, WXK_CAPITAL, WXK_NONE, WXK_SHIFT, WXK_ALT, WXK_CONTROL, WXK_CAPITAL, WXK_NUMLOCK, WXK_SCROLL,
WXK_NUMLOCK, WXK_SCROLL, WXK_RAW_CONTROL WXK_RAW_CONTROL
}; };
int key = aEvent.GetKeyCode(); int key = aEvent.GetKeyCode();
@ -202,7 +198,6 @@ protected:
} }
} }
void OnChar( wxKeyEvent& aEvent ) void OnChar( wxKeyEvent& aEvent )
{ {
m_event = aEvent; m_event = aEvent;
@ -235,10 +230,12 @@ public:
// Match in the (translated) filter string // Match in the (translated) filter string
const auto normedInfo = wxGetTranslation( aHotkey.m_Actions[ 0 ]->GetLabel() ).Upper(); const auto normedInfo = wxGetTranslation( aHotkey.m_Actions[ 0 ]->GetLabel() ).Upper();
if( normedInfo.Contains( m_normalised_filter_str ) ) if( normedInfo.Contains( m_normalised_filter_str ) )
return true; return true;
const wxString keyName = KeyNameFromKeyCode( aHotkey.m_EditKeycode ); const wxString keyName = KeyNameFromKeyCode( aHotkey.m_EditKeycode );
if( keyName.Upper().Contains( m_normalised_filter_str ) ) if( keyName.Upper().Contains( m_normalised_filter_str ) )
return true; return true;
@ -246,8 +243,7 @@ public:
} }
private: private:
bool m_valid;
bool m_valid;
wxString m_normalised_filter_str; wxString m_normalised_filter_str;
}; };
@ -441,8 +437,8 @@ bool WIDGET_HOTKEY_LIST::ResolveKeyConflicts( TOOL_ACTION* aAction, long aKey )
WIDGET_HOTKEY_LIST::WIDGET_HOTKEY_LIST( wxWindow* aParent, HOTKEY_STORE& aHotkeyStore, WIDGET_HOTKEY_LIST::WIDGET_HOTKEY_LIST( wxWindow* aParent, HOTKEY_STORE& aHotkeyStore,
bool aReadOnly ) bool aReadOnly ) :
: wxTreeListCtrl( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTL_SINGLE ), wxTreeListCtrl( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTL_SINGLE ),
m_hk_store( aHotkeyStore ), m_hk_store( aHotkeyStore ),
m_readOnly( aReadOnly ) m_readOnly( aReadOnly )
{ {