From 71f5f96e64f84c6916e92941c05497c982943696 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Wed, 12 Jun 2019 01:59:30 +0100 Subject: [PATCH] Remove help from F1 key and move it to an action Create a new action in pcbnew, gerbview and the footprint viewer/ editor to display the help documentation. Disconnect the wxID_HELP event from the window so that it no longer conflicts with the zoom action. Fixes: lp:1822041 * https://bugs.launchpad.net/kicad/+bug/1822041 --- gerbview/events_called_functions.cpp | 1 - gerbview/gerbview_id.h | 2 ++ gerbview/menubar.cpp | 2 +- gerbview/tools/gerbview_actions.cpp | 3 +++ gerbview/tools/gerbview_actions.h | 1 + gerbview/tools/gerbview_control.cpp | 19 +++++++++++++++++-- gerbview/tools/gerbview_control.h | 1 + pcbnew/footprint_edit_frame.cpp | 1 - pcbnew/footprint_viewer_frame.cpp | 1 - pcbnew/menubar_footprint_editor.cpp | 2 +- pcbnew/menubar_pcb_editor.cpp | 2 +- pcbnew/pcb_edit_frame.cpp | 1 - pcbnew/pcbnew_id.h | 3 +++ pcbnew/tool_footprint_viewer.cpp | 2 +- pcbnew/tools/pcb_actions.cpp | 3 +++ pcbnew/tools/pcb_actions.h | 1 + pcbnew/tools/pcbnew_control.cpp | 19 +++++++++++++++++-- pcbnew/tools/pcbnew_control.h | 1 + 18 files changed, 53 insertions(+), 12 deletions(-) diff --git a/gerbview/events_called_functions.cpp b/gerbview/events_called_functions.cpp index de7c87dc73..d55185334c 100644 --- a/gerbview/events_called_functions.cpp +++ b/gerbview/events_called_functions.cpp @@ -100,7 +100,6 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME ) EVT_MENU( ID_GERBVIEW_ERASE_CURR_LAYER, GERBVIEW_FRAME::Process_Special_Functions ) // Menu Help - EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp ) EVT_MENU( wxID_INDEX, EDA_DRAW_FRAME::GetKicadHelp ) EVT_MENU( ID_HELP_GET_INVOLVED, EDA_DRAW_FRAME::GetKicadContribute ) EVT_MENU( wxID_ABOUT, EDA_DRAW_FRAME::GetKicadAbout ) diff --git a/gerbview/gerbview_id.h b/gerbview/gerbview_id.h index 624f2df69b..096023c53c 100644 --- a/gerbview/gerbview_id.h +++ b/gerbview/gerbview_id.h @@ -93,6 +93,8 @@ enum gerbview_ids ID_GERBVIEW_ZIP_FILE1, ID_GERBVIEW_ZIP_FILEMAX = ID_GERBVIEW_ZIP_FILE + MAX_FILE_HISTORY_SIZE, + ID_GERBVIEW_SHOW_HELP, + ID_GERBER_END_LIST }; diff --git a/gerbview/menubar.cpp b/gerbview/menubar.cpp index 2c76bc3166..d289d2646a 100644 --- a/gerbview/menubar.cpp +++ b/gerbview/menubar.cpp @@ -353,7 +353,7 @@ void GERBVIEW_FRAME::ReCreateMenuBar() // Help menu wxMenu* helpMenu = new wxMenu; - AddMenuItem( helpMenu, wxID_HELP, _( "Gerbview &Manual" ), + AddMenuItem( helpMenu, ID_GERBVIEW_SHOW_HELP, _( "Gerbview &Manual" ), _( "Open the GerbView Manual" ), KiBitmap( online_help_xpm ) ); diff --git a/gerbview/tools/gerbview_actions.cpp b/gerbview/tools/gerbview_actions.cpp index 250fffb8db..0440a0cdfb 100644 --- a/gerbview/tools/gerbview_actions.cpp +++ b/gerbview/tools/gerbview_actions.cpp @@ -67,6 +67,9 @@ OPT GERBVIEW_ACTIONS::TranslateLegacyId( int aId ) case ID_HIGHLIGHT_NET_ITEMS: return GERBVIEW_ACTIONS::highlightNet.MakeEvent(); + case ID_GERBVIEW_SHOW_HELP: + return GERBVIEW_ACTIONS::showHelp.MakeEvent(); + case ID_HIGHLIGHT_APER_ATTRIBUTE_ITEMS: return GERBVIEW_ACTIONS::highlightAttribute.MakeEvent(); break; diff --git a/gerbview/tools/gerbview_actions.h b/gerbview/tools/gerbview_actions.h index ce348c3c63..f1dd990910 100644 --- a/gerbview/tools/gerbview_actions.h +++ b/gerbview/tools/gerbview_actions.h @@ -107,6 +107,7 @@ public: static TOOL_ACTION resetCoords; static TOOL_ACTION switchCursor; static TOOL_ACTION switchUnits; + static TOOL_ACTION showHotkeyList; static TOOL_ACTION showHelp; static TOOL_ACTION toBeDone; diff --git a/gerbview/tools/gerbview_control.cpp b/gerbview/tools/gerbview_control.cpp index 71661d4d30..b325d0e255 100644 --- a/gerbview/tools/gerbview_control.cpp +++ b/gerbview/tools/gerbview_control.cpp @@ -89,10 +89,14 @@ TOOL_ACTION GERBVIEW_ACTIONS::resetCoords( "gerbview.Control.resetCoords", AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_RESET_LOCAL_COORD ), "", "" ); -TOOL_ACTION GERBVIEW_ACTIONS::showHelp( "gerbview.Control.showHelp", +TOOL_ACTION GERBVIEW_ACTIONS::showHotkeyList( "gerbview.Control.showHotkeyList", AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_HELP ), "", "" ); +TOOL_ACTION GERBVIEW_ACTIONS::showHelp( "gerbview.Control.showHelp", + AS_GLOBAL, 0, + "", "" ); + GERBVIEW_CONTROL::GERBVIEW_CONTROL() : TOOL_INTERACTIVE( "gerbview.Control" ), m_frame( NULL ) { @@ -249,7 +253,7 @@ int GERBVIEW_CONTROL::SwitchUnits( const TOOL_EVENT& aEvent ) } -int GERBVIEW_CONTROL::ShowHelp( const TOOL_EVENT& aEvent ) +int GERBVIEW_CONTROL::ShowHotkeyList( const TOOL_EVENT& aEvent ) { DisplayHotkeyList( m_frame, m_frame->GetHotkeyConfig() ); @@ -257,6 +261,16 @@ int GERBVIEW_CONTROL::ShowHelp( const TOOL_EVENT& aEvent ) } +int GERBVIEW_CONTROL::ShowHelp( const TOOL_EVENT& aEvent ) +{ + wxCommandEvent dummyEvent; + dummyEvent.SetId( wxID_HELP ); + m_frame->GetKicadHelp( dummyEvent ); + + return 0; +} + + void GERBVIEW_CONTROL::setTransitions() { Go( &GERBVIEW_CONTROL::HighlightControl, GERBVIEW_ACTIONS::highlightClear.MakeEvent() ); @@ -276,4 +290,5 @@ void GERBVIEW_CONTROL::setTransitions() Go( &GERBVIEW_CONTROL::ResetCoords, GERBVIEW_ACTIONS::resetCoords.MakeEvent() ); Go( &GERBVIEW_CONTROL::SwitchUnits, GERBVIEW_ACTIONS::switchUnits.MakeEvent() ); Go( &GERBVIEW_CONTROL::ShowHelp, GERBVIEW_ACTIONS::showHelp.MakeEvent() ); + Go( &GERBVIEW_CONTROL::ShowHotkeyList, GERBVIEW_ACTIONS::showHotkeyList.MakeEvent() ); } diff --git a/gerbview/tools/gerbview_control.h b/gerbview/tools/gerbview_control.h index a34e65168a..c5b613ccee 100644 --- a/gerbview/tools/gerbview_control.h +++ b/gerbview/tools/gerbview_control.h @@ -60,6 +60,7 @@ public: int ResetCoords( const TOOL_EVENT& aEvent ); int SwitchUnits( const TOOL_EVENT& aEvent ); int ShowHelp( const TOOL_EVENT& aEvent ); + int ShowHotkeyList( const TOOL_EVENT& aEvent ); ///> Sets up handlers for various events. void setTransitions() override; diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 27e3ff1c68..1bdf915af0 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -167,7 +167,6 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME ) EVT_MENU( ID_PCB_USER_GRID_SETUP, FOOTPRINT_EDIT_FRAME::OnGridSettings ) // Menu Help - EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp ) EVT_MENU( wxID_INDEX, EDA_DRAW_FRAME::GetKicadHelp ) EVT_MENU( ID_HELP_GET_INVOLVED, EDA_DRAW_FRAME::GetKicadContribute ) EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::GetKicadAbout ) diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index 2ac57c7b14..3c7a79a61d 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -82,7 +82,6 @@ BEGIN_EVENT_TABLE( FOOTPRINT_VIEWER_FRAME, EDA_DRAW_FRAME ) EVT_MENU( ID_SET_RELATIVE_OFFSET, FOOTPRINT_VIEWER_FRAME::OnSetRelativeOffset ) // Menu Help - EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp ) EVT_MENU( wxID_INDEX, EDA_DRAW_FRAME::GetKicadHelp ) EVT_MENU( ID_HELP_GET_INVOLVED, EDA_DRAW_FRAME::GetKicadContribute ) EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::GetKicadAbout ) diff --git a/pcbnew/menubar_footprint_editor.cpp b/pcbnew/menubar_footprint_editor.cpp index 8614611de7..9cf7cfe2a9 100644 --- a/pcbnew/menubar_footprint_editor.cpp +++ b/pcbnew/menubar_footprint_editor.cpp @@ -460,7 +460,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() wxMenu* helpMenu = new wxMenu; // Contents - AddMenuItem( helpMenu, wxID_HELP, + AddMenuItem( helpMenu, ID_PCBNEW_SHOW_HELP, _( "Pcbnew &Manual" ), _( "Open the Pcbnew Manual" ), KiBitmap( online_help_xpm ) ); diff --git a/pcbnew/menubar_pcb_editor.cpp b/pcbnew/menubar_pcb_editor.cpp index 422456245e..a977e9e034 100644 --- a/pcbnew/menubar_pcb_editor.cpp +++ b/pcbnew/menubar_pcb_editor.cpp @@ -419,7 +419,7 @@ void prepareToolsMenu( wxMenu* aParentMenu ) void prepareHelpMenu( wxMenu* aParentMenu ) { - AddMenuItem( aParentMenu, wxID_HELP, + AddMenuItem( aParentMenu, ID_PCBNEW_SHOW_HELP, _( "Pcbnew &Manual" ), _( "Open Pcbnew Manual" ), KiBitmap( online_help_xpm ) ); diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index a49a9e6910..5c08cf063a 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -164,7 +164,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) EVT_MENU( ID_MENU_PCB_EDIT_TEXT_AND_GRAPHICS, PCB_EDIT_FRAME::OnEditTextAndGraphics ) // Menu Help - EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp ) EVT_MENU( wxID_INDEX, EDA_DRAW_FRAME::GetKicadHelp ) EVT_MENU( ID_HELP_GET_INVOLVED, EDA_DRAW_FRAME::GetKicadContribute ) EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::GetKicadAbout ) diff --git a/pcbnew/pcbnew_id.h b/pcbnew/pcbnew_id.h index dfe402af5a..0180a63f45 100644 --- a/pcbnew/pcbnew_id.h +++ b/pcbnew/pcbnew_id.h @@ -402,6 +402,9 @@ enum pcbnew_ids ID_EDIT_CUT, ID_EDIT_COPY, ID_EDIT_PASTE, + + ID_PCBNEW_SHOW_HELP, + ID_PCBNEW_END_LIST }; diff --git a/pcbnew/tool_footprint_viewer.cpp b/pcbnew/tool_footprint_viewer.cpp index 76053be33c..b207eeee6d 100644 --- a/pcbnew/tool_footprint_viewer.cpp +++ b/pcbnew/tool_footprint_viewer.cpp @@ -188,7 +188,7 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar() wxMenu* helpMenu = new wxMenu; // Contents - AddMenuItem( helpMenu, wxID_HELP, + AddMenuItem( helpMenu, ID_PCBNEW_SHOW_HELP, _( "Pcbnew &Manual" ), _( "Open the Pcbnew manual" ), KiBitmap( online_help_xpm ) ); diff --git a/pcbnew/tools/pcb_actions.cpp b/pcbnew/tools/pcb_actions.cpp index 29cdc3bd5b..568508de0d 100644 --- a/pcbnew/tools/pcb_actions.cpp +++ b/pcbnew/tools/pcb_actions.cpp @@ -219,6 +219,9 @@ OPT PCB_ACTIONS::TranslateLegacyId( int aId ) case ID_POPUP_PCB_AUTOPLACE_SELECTED_MODULES: return PCB_ACTIONS::autoplaceSelectedComponents.MakeEvent(); + case ID_PCBNEW_SHOW_HELP: + return PCB_ACTIONS::showHelp.MakeEvent(); + } return OPT(); diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index a70b4e89b2..8bba06c796 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -379,6 +379,7 @@ public: static TOOL_ACTION drillOrigin; static TOOL_ACTION crossProbeSchToPcb; static TOOL_ACTION appendBoard; + static TOOL_ACTION showHotkeyList; static TOOL_ACTION showHelp; static TOOL_ACTION toBeDone; diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp index 907c5aee22..7484ec05f7 100644 --- a/pcbnew/tools/pcbnew_control.cpp +++ b/pcbnew/tools/pcbnew_control.cpp @@ -195,10 +195,14 @@ TOOL_ACTION PCB_ACTIONS::deleteItemCursor( "pcbnew.Control.deleteItemCursor", AS_GLOBAL, 0, "", "" ); -TOOL_ACTION PCB_ACTIONS::showHelp( "pcbnew.Control.showHelp", +TOOL_ACTION PCB_ACTIONS::showHotkeyList( "pcbnew.Control.showHotkeyList", AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_HELP ), "", "" ); +TOOL_ACTION PCB_ACTIONS::showHelp( "pcbnew.Control.showHelp", + AS_GLOBAL, 0, + "", "" ); + TOOL_ACTION PCB_ACTIONS::toBeDone( "pcbnew.Control.toBeDone", AS_GLOBAL, 0, // dialog saying it is not implemented yet "", "" ); // so users are aware of that @@ -980,7 +984,7 @@ int PCBNEW_CONTROL::AppendBoard( PLUGIN& pi, wxString& fileName ) } -int PCBNEW_CONTROL::ShowHelp( const TOOL_EVENT& aEvent ) +int PCBNEW_CONTROL::ShowHotkeyList( const TOOL_EVENT& aEvent ) { DisplayHotkeyList( m_frame, m_frame->GetHotkeyConfig() ); @@ -988,6 +992,16 @@ int PCBNEW_CONTROL::ShowHelp( const TOOL_EVENT& aEvent ) } +int PCBNEW_CONTROL::ShowHelp( const TOOL_EVENT& aEvent ) +{ + wxCommandEvent dummyEvent; + dummyEvent.SetId( wxID_HELP ); + m_frame->GetKicadHelp( dummyEvent ); + + return 0; +} + + int PCBNEW_CONTROL::ToBeDone( const TOOL_EVENT& aEvent ) { DisplayInfoMessage( m_frame, _( "Not available in OpenGL/Cairo canvases." ) ); @@ -1038,6 +1052,7 @@ void PCBNEW_CONTROL::setTransitions() Go( &PCBNEW_CONTROL::SwitchCursor, PCB_ACTIONS::switchCursor.MakeEvent() ); Go( &PCBNEW_CONTROL::SwitchUnits, PCB_ACTIONS::switchUnits.MakeEvent() ); Go( &PCBNEW_CONTROL::DeleteItemCursor, PCB_ACTIONS::deleteItemCursor.MakeEvent() ); + Go( &PCBNEW_CONTROL::ShowHotkeyList, PCB_ACTIONS::showHotkeyList.MakeEvent() ); Go( &PCBNEW_CONTROL::ShowHelp, PCB_ACTIONS::showHelp.MakeEvent() ); Go( &PCBNEW_CONTROL::ToBeDone, PCB_ACTIONS::toBeDone.MakeEvent() ); diff --git a/pcbnew/tools/pcbnew_control.h b/pcbnew/tools/pcbnew_control.h index 90451f4a36..729add6dc3 100644 --- a/pcbnew/tools/pcbnew_control.h +++ b/pcbnew/tools/pcbnew_control.h @@ -92,6 +92,7 @@ public: int PasteItemsFromClipboard( const TOOL_EVENT& aEvent ); int AppendBoardFromFile( const TOOL_EVENT& aEvent ); int AppendBoard( PLUGIN& pi, wxString& fileName ); + int ShowHotkeyList( const TOOL_EVENT& aEvent ); int ShowHelp( const TOOL_EVENT& aEvent ); int ToBeDone( const TOOL_EVENT& aEvent );