Hotkeys Editor has now a "reset to default" button

This commit is contained in:
unknown 2016-03-29 18:35:24 +02:00 committed by jean-pierre charras
parent 2efd31ef03
commit 0cd747668f
9 changed files with 144 additions and 4 deletions

View File

@ -84,3 +84,8 @@ void HOTKEYS_EDITOR_DIALOG::ResetClicked( wxCommandEvent& aEvent )
{ {
m_hotkeyListCtrl->TransferDataToControl(); m_hotkeyListCtrl->TransferDataToControl();
} }
void HOTKEYS_EDITOR_DIALOG::DefaultsClicked( wxCommandEvent& aEvent )
{
m_hotkeyListCtrl->TransferDefaultsToControl();
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Dec 28 2015) // C++ code generated with wxFormBuilder (version Jun 17 2015)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
@ -28,6 +28,9 @@ HOTKEYS_EDITOR_DIALOG_BASE::HOTKEYS_EDITOR_DIALOG_BASE( wxWindow* parent, wxWind
m_resetButton = new wxButton( this, wxID_RESET, _("Reset"), wxDefaultPosition, wxDefaultSize, 0 ); m_resetButton = new wxButton( this, wxID_RESET, _("Reset"), wxDefaultPosition, wxDefaultSize, 0 );
b_buttonsSizer->Add( m_resetButton, 0, wxALL|wxEXPAND, 5 ); b_buttonsSizer->Add( m_resetButton, 0, wxALL|wxEXPAND, 5 );
m_defaultButton = new wxButton( this, wxID_ANY, _("Defaults"), wxDefaultPosition, wxDefaultSize, 0 );
b_buttonsSizer->Add( m_defaultButton, 0, wxALL|wxEXPAND, 5 );
b_buttonsSizer->Add( 0, 0, 1, wxEXPAND, 5 ); b_buttonsSizer->Add( 0, 0, 1, wxEXPAND, 5 );
@ -49,11 +52,13 @@ HOTKEYS_EDITOR_DIALOG_BASE::HOTKEYS_EDITOR_DIALOG_BASE( wxWindow* parent, wxWind
// Connect Events // Connect Events
m_resetButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::ResetClicked ), NULL, this ); m_resetButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::ResetClicked ), NULL, this );
m_defaultButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::DefaultsClicked ), NULL, this );
} }
HOTKEYS_EDITOR_DIALOG_BASE::~HOTKEYS_EDITOR_DIALOG_BASE() HOTKEYS_EDITOR_DIALOG_BASE::~HOTKEYS_EDITOR_DIALOG_BASE()
{ {
// Disconnect Events // Disconnect Events
m_resetButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::ResetClicked ), NULL, this ); m_resetButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::ResetClicked ), NULL, this );
m_defaultButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( HOTKEYS_EDITOR_DIALOG_BASE::DefaultsClicked ), NULL, this );
} }

View File

@ -353,6 +353,94 @@
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Defaults</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_defaultButton</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">DefaultsClicked</event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxEXPAND</property> <property name="flag">wxEXPAND</property>

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Dec 28 2015) // C++ code generated with wxFormBuilder (version Jun 17 2015)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
@ -40,12 +40,14 @@ class HOTKEYS_EDITOR_DIALOG_BASE : public DIALOG_SHIM
wxStaticText* m_staticText1; wxStaticText* m_staticText1;
wxPanel* m_panelHotkeys; wxPanel* m_panelHotkeys;
wxButton* m_resetButton; wxButton* m_resetButton;
wxButton* m_defaultButton;
wxStdDialogButtonSizer* m_sdbSizer; wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK; wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel; wxButton* m_sdbSizerCancel;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void ResetClicked( wxCommandEvent& event ) { event.Skip(); } virtual void ResetClicked( wxCommandEvent& event ) { event.Skip(); }
virtual void DefaultsClicked( wxCommandEvent& event ) { event.Skip(); }
public: public:

View File

@ -55,7 +55,8 @@ wxString g_CommonSectionTag( wxT( "[common]" ) );
* file. * file.
*/ */
EDA_HOTKEY::EDA_HOTKEY( const wxChar* infomsg, int idcommand, int keycode, int idmenuevent ) EDA_HOTKEY::EDA_HOTKEY( const wxChar* infomsg, int idcommand, int keycode, int idmenuevent ) :
m_DefaultKeyCode( keycode ) // initialize DefaultKeyCode
{ {
m_KeyCode = keycode; // Key code (ascii value for ascii keys m_KeyCode = keycode; // Key code (ascii value for ascii keys
@ -69,7 +70,8 @@ EDA_HOTKEY::EDA_HOTKEY( const wxChar* infomsg, int idcommand, int keycode, int i
} }
EDA_HOTKEY::EDA_HOTKEY( const EDA_HOTKEY* base ) EDA_HOTKEY::EDA_HOTKEY( const EDA_HOTKEY* base ) :
m_DefaultKeyCode( base->m_DefaultKeyCode ) // initialize DefaultKeyCode
{ {
m_KeyCode = base->m_KeyCode; m_KeyCode = base->m_KeyCode;
m_InfoMsg = base->m_InfoMsg; m_InfoMsg = base->m_InfoMsg;

View File

@ -575,6 +575,26 @@ void WIDGET_HOTKEY_LIST::InstallOnPanel( wxPanel* aPanel )
} }
bool WIDGET_HOTKEY_LIST::TransferDefaultsToControl()
{
Freeze();
for( wxTreeListItem item = GetFirstItem(); item.IsOk(); item = GetNextItem( item ) )
{
WIDGET_HOTKEY_CLIENT_DATA* hkdata = GetHKClientData( item );
if( hkdata == NULL)
continue;
hkdata->GetHotkey().ResetKeyCodeToDefault();
}
UpdateFromClientData();
Thaw();
return true;
}
bool WIDGET_HOTKEY_LIST::TransferDataToControl() bool WIDGET_HOTKEY_LIST::TransferDataToControl()
{ {
Freeze(); Freeze();

View File

@ -66,6 +66,14 @@ private:
* @param aEvent is the button press event, unused * @param aEvent is the button press event, unused
*/ */
void ResetClicked( wxCommandEvent& aEvent ); void ResetClicked( wxCommandEvent& aEvent );
/**
* Function DefaultsClicked
* Set the hotkeys to the default values (values after installation)
*
* @param aEvent is the button press event, unused
*/
void DefaultsClicked( wxCommandEvent& aEvent );
}; };
/** /**

View File

@ -56,6 +56,8 @@ extern wxString g_CommonSectionTag;
*/ */
class EDA_HOTKEY class EDA_HOTKEY
{ {
private:
const int m_DefaultKeyCode; // Key code assigned upon object construction, to be used as default value
public: public:
int m_KeyCode; // Key code (ascii value for ascii keys or wxWidgets code for function key int m_KeyCode; // Key code (ascii value for ascii keys or wxWidgets code for function key
wxString m_InfoMsg; // info message. wxString m_InfoMsg; // info message.
@ -65,6 +67,7 @@ public:
public: public:
EDA_HOTKEY( const wxChar* infomsg, int idcommand, int keycode, int idmenuevent = 0 ); EDA_HOTKEY( const wxChar* infomsg, int idcommand, int keycode, int idmenuevent = 0 );
EDA_HOTKEY( const EDA_HOTKEY* base); EDA_HOTKEY( const EDA_HOTKEY* base);
void ResetKeyCodeToDefault() { m_KeyCode = m_DefaultKeyCode; }
}; };

View File

@ -177,6 +177,13 @@ public:
*/ */
void InstallOnPanel( wxPanel* aPanel ); void InstallOnPanel( wxPanel* aPanel );
/**
* Method TransferDefaultsToControl
* Set hotkeys in the control to default values.
* @return true iff the operation was successful
*/
bool TransferDefaultsToControl();
/** /**
* Method TransferDataToControl * Method TransferDataToControl
* Load the hotkey data into the control. It is safe to call this multiple times, * Load the hotkey data into the control. It is safe to call this multiple times,