diff --git a/3d-viewer/3d_viewer/3d_menubar.cpp b/3d-viewer/3d_viewer/3d_menubar.cpp index 465b295296..1ddf966b35 100644 --- a/3d-viewer/3d_viewer/3d_menubar.cpp +++ b/3d-viewer/3d_viewer/3d_menubar.cpp @@ -56,8 +56,7 @@ void EDA_3D_VIEWER::CreateMenuBar() export_xpm, SELECTION_CONDITIONS::ShowAlways ); fileMenu->AddSeparator(); - // Don't use ACTIONS::quit; wxWidgets moves this on OSX and expects to find it via wxID_EXIT - fileMenu->AddItem( wxID_EXIT, _( "Quit" ), "", exit_xpm, SELECTION_CONDITIONS::ShowAlways ); + fileMenu->AddItem( wxID_CLOSE, _( "Close" ), "", exit_xpm, SELECTION_CONDITIONS::ShowAlways ); fileMenu->Resolve(); diff --git a/3d-viewer/3d_viewer/eda_3d_viewer.cpp b/3d-viewer/3d_viewer/eda_3d_viewer.cpp index 68b3f46e6a..f2b6435a59 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer.cpp +++ b/3d-viewer/3d_viewer/eda_3d_viewer.cpp @@ -131,7 +131,7 @@ BEGIN_EVENT_TABLE( EDA_3D_VIEWER, EDA_BASE_FRAME ) EVT_TOOL( ID_TOOL_SET_VISIBLE_ITEMS, EDA_3D_VIEWER::Install3DViewOptionDialog ) - EVT_MENU( wxID_EXIT, EDA_3D_VIEWER::Exit3DFrame ) + EVT_MENU( wxID_CLOSE, EDA_3D_VIEWER::Exit3DFrame ) EVT_MENU( ID_RENDER_CURRENT_VIEW, EDA_3D_VIEWER::OnRenderEngineSelection ) EVT_MENU( ID_DISABLE_RAY_TRACING, EDA_3D_VIEWER::OnDisableRayTracing ) diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index f806ed3ca4..ff442c133f 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -305,6 +305,15 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event ) } +void EDA_DRAW_FRAME::InitExitKey() +{ + wxAcceleratorEntry entries[1]; + entries[0].Set( wxACCEL_CTRL, int( 'Q' ), wxID_EXIT ); + wxAcceleratorTable accel( 1, entries ); + SetAcceleratorTable( accel ); +} + + /* * Respond to selections in the toolbar zoom popup */ diff --git a/common/kiway.cpp b/common/kiway.cpp index cfcdab42c6..15efde30cb 100644 --- a/common/kiway.cpp +++ b/common/kiway.cpp @@ -499,6 +499,21 @@ bool KIWAY::ProcessEvent( wxEvent& aEvent ) } +void KIWAY::OnKiCadExit() +{ + if( m_ctl & KFCTL_CPP_PROJECT_SUITE ) + { + // A dynamic_cast could be better, but creates link issues + // (some basic_frame functions not found) on some platforms, + // so a static_cast is used. + EDA_BASE_FRAME* top = static_cast( m_top ); + + if( top ) + top->Close( false ); + } +} + + void KIWAY::OnKiwayEnd() { for( KIFACE* i : m_kiface ) diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index d25233be29..f2e891397f 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -90,7 +90,8 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_TOOL( ID_LIBEDIT_EXPORT_BODY_BUTT, LIB_EDIT_FRAME::OnExportBody ) // menubar commands - EVT_MENU( wxID_EXIT, LIB_EDIT_FRAME::CloseWindow ) + EVT_MENU( wxID_EXIT, LIB_EDIT_FRAME::OnExitKiCad ) + EVT_MENU( wxID_CLOSE, LIB_EDIT_FRAME::CloseWindow ) EVT_MENU( ID_GRID_SETTINGS, SCH_BASE_FRAME::OnGridSettings ) // Update user interface elements. @@ -152,6 +153,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : ReCreateHToolbar(); ReCreateVToolbar(); ReCreateOptToolbar(); + InitExitKey(); updateTitle(); DisplayCmpDoc(); @@ -331,6 +333,12 @@ void LIB_EDIT_FRAME::ThawSearchTree() } +void LIB_EDIT_FRAME::OnExitKiCad( wxCommandEvent& event ) +{ + Kiway().OnKiCadExit(); +} + + void LIB_EDIT_FRAME::OnUpdatePartNumber( wxUpdateUIEvent& event ) { if( !m_unitSelectBox ) diff --git a/eeschema/libedit/lib_edit_frame.h b/eeschema/libedit/lib_edit_frame.h index 5d27375d13..5dd41c1b80 100644 --- a/eeschema/libedit/lib_edit_frame.h +++ b/eeschema/libedit/lib_edit_frame.h @@ -239,6 +239,7 @@ public: void RebuildSymbolUnitsList(); void OnCloseWindow( wxCloseEvent& Event ); + void OnExitKiCad( wxCommandEvent& event ); void ReCreateHToolbar() override; void ReCreateVToolbar() override; void ReCreateOptToolbar(); diff --git a/eeschema/libedit/menubar_libedit.cpp b/eeschema/libedit/menubar_libedit.cpp index dbd5036bcd..911bac537b 100644 --- a/eeschema/libedit/menubar_libedit.cpp +++ b/eeschema/libedit/menubar_libedit.cpp @@ -82,8 +82,7 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() fileMenu->AddMenu( submenuExport, EE_CONDITIONS::ShowAlways ); fileMenu->AddSeparator(); - // Don't use ACTIONS::quit; wxWidgets moves this on OSX and expects to find it via wxID_EXIT - fileMenu->AddItem( wxID_EXIT, _( "Quit" ), "", exit_xpm, EE_CONDITIONS::ShowAlways ); + fileMenu->AddItem( wxID_CLOSE, _( "Close" ), "", exit_xpm, EE_CONDITIONS::ShowAlways ); fileMenu->Resolve(); diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index 007496bcda..84c4177f05 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -115,8 +115,16 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() fileMenu->AddItem( ACTIONS::plot, EE_CONDITIONS::ShowAlways ); fileMenu->AddSeparator(); - // Don't use ACTIONS::quit; wxWidgets moves this on OSX and expects to find it via wxID_EXIT - fileMenu->AddItem( wxID_EXIT, _( "Quit" ), "", exit_xpm, EE_CONDITIONS::ShowAlways ); + + if( Kiface().IsSingle() ) // not when under a project mgr + { + // Don't use ACTIONS::quit; wxWidgets moves this on OSX and expects to find it via wxID_EXIT + fileMenu->AddItem( wxID_EXIT, _( "Quit" ), "", exit_xpm, EE_CONDITIONS::ShowAlways ); + } + else + { + fileMenu->AddItem( wxID_CLOSE, _( "Close" ), "", exit_xpm, EE_CONDITIONS::ShowAlways ); + } fileMenu->Resolve(); diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 37d1368bff..b7e969f640 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -22,19 +22,20 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include -#include -#include -#include -#include -#include -#include #include -#include -#include -#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include #include #include @@ -222,6 +223,7 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_MENU( ID_IMPORT_NON_KICAD_SCH, SCH_EDIT_FRAME::OnImportProject ) EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit ) + EVT_MENU( wxID_CLOSE, SCH_EDIT_FRAME::OnExit ) EVT_TOOL( ID_RESCUE_CACHED, SCH_EDIT_FRAME::OnRescueProject ) EVT_MENU( ID_REMAP_SYMBOLS, SCH_EDIT_FRAME::OnRemapSymbols ) @@ -300,6 +302,8 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ): if( GetCanvas() ) GetCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() ); + InitExitKey(); + // Net list generator DefaultExecFlags(); @@ -899,7 +903,11 @@ void SCH_EDIT_FRAME::OnRemapSymbols( wxCommandEvent& event ) void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event ) { - Close( false ); + if( event.GetId() == wxID_EXIT ) + Kiway().OnKiCadExit(); + + if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() ) + Close( false ); } diff --git a/eeschema/toolbars_viewlib.cpp b/eeschema/toolbars_viewlib.cpp index 3e594ef5c6..e9af694fb3 100644 --- a/eeschema/toolbars_viewlib.cpp +++ b/eeschema/toolbars_viewlib.cpp @@ -102,8 +102,8 @@ void LIB_VIEW_FRAME::ReCreateMenuBar() // CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, libControl ); - fileMenu->AddItem( wxID_EXIT, _( "Close" ), _( "Close footprint viewer" ), - exit_xpm, EE_CONDITIONS::ShowAlways ); + fileMenu->AddItem( wxID_CLOSE, _( "Close" ), _( "Close footprint viewer" ), exit_xpm, + EE_CONDITIONS::ShowAlways ); fileMenu->Resolve(); diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index 2eaf2f3805..0aef7f9c5d 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -77,7 +77,7 @@ BEGIN_EVENT_TABLE( LIB_VIEW_FRAME, EDA_DRAW_FRAME ) EVT_LISTBOX_DCLICK( ID_LIBVIEW_CMP_LIST, LIB_VIEW_FRAME::DClickOnCmpList ) // Menu (and/or hotkey) events - EVT_MENU( wxID_EXIT, LIB_VIEW_FRAME::CloseLibraryViewer ) + EVT_MENU( wxID_CLOSE, LIB_VIEW_FRAME::CloseLibraryViewer ) EVT_MENU( ID_GRID_SETTINGS, SCH_BASE_FRAME::OnGridSettings ) EVT_UPDATE_UI( ID_LIBVIEW_SELECT_PART_NUMBER, LIB_VIEW_FRAME::onUpdateUnitChoice ) diff --git a/include/eda_draw_frame.h b/include/eda_draw_frame.h index a1346564c7..496a97a0b1 100644 --- a/include/eda_draw_frame.h +++ b/include/eda_draw_frame.h @@ -148,6 +148,13 @@ protected: void CommonSettingsChanged() override; + /** + * Sets the common key-pair for exiting the application (Ctrl-Q) and ties it + * to the wxID_EXIT event id. This is useful in sub-applications to pass the event + * up to a non-owning window + */ + void InitExitKey(); + /** * @param doOpen if true runs an Open Library browser, otherwise New Library * @param aFilename for New may contain a default name; in both cases return the chosen diff --git a/include/kiway.h b/include/kiway.h index df3ff6b6bb..44521fb79b 100644 --- a/include/kiway.h +++ b/include/kiway.h @@ -379,6 +379,8 @@ public: */ void SetTop( wxFrame* aTop ); + void OnKiCadExit(); + void OnKiwayEnd(); bool ProcessEvent( wxEvent& aEvent ) override; diff --git a/kicad/kicad_manager_frame.cpp b/kicad/kicad_manager_frame.cpp index 87a60619ac..8c2736c5e4 100644 --- a/kicad/kicad_manager_frame.cpp +++ b/kicad/kicad_manager_frame.cpp @@ -23,22 +23,23 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "kicad_id.h" +#include "pgm_kicad.h" +#include "tree_project_frame.h" +#include +#include +#include #include #include +#include #include -#include -#include -#include -#include -#include "pgm_kicad.h" #include -#include "tree_project_frame.h" -#include "kicad_id.h" -#include #include #include +#include #include #include +#include #ifdef __WXMAC__ #include diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index ec9d48fd32..112cc00f1f 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -75,7 +75,8 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME ) EVT_CLOSE( FOOTPRINT_EDIT_FRAME::OnCloseWindow ) - EVT_MENU( wxID_EXIT, FOOTPRINT_EDIT_FRAME::CloseModuleEditor ) + EVT_MENU( wxID_CLOSE, FOOTPRINT_EDIT_FRAME::CloseModuleEditor ) + EVT_MENU( wxID_EXIT, FOOTPRINT_EDIT_FRAME::OnExitKiCad ) EVT_SIZE( FOOTPRINT_EDIT_FRAME::OnSize ) @@ -219,6 +220,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, GetToolManager()->RunAction( ACTIONS::gridPreset, true, m_LastGridSizeId ); GetToolManager()->RunAction( ACTIONS::zoomFitScreen, false ); updateTitle(); + InitExitKey(); Raise(); // On some window managers, this is needed Show( true ); @@ -477,6 +479,12 @@ void FOOTPRINT_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event ) } +void FOOTPRINT_EDIT_FRAME::OnExitKiCad( wxCommandEvent& event ) +{ + Kiway().OnKiCadExit(); +} + + void FOOTPRINT_EDIT_FRAME::CloseModuleEditor( wxCommandEvent& Event ) { Close(); diff --git a/pcbnew/footprint_edit_frame.h b/pcbnew/footprint_edit_frame.h index 0dee7cc28e..634759627b 100644 --- a/pcbnew/footprint_edit_frame.h +++ b/pcbnew/footprint_edit_frame.h @@ -89,6 +89,7 @@ public: void OnCloseWindow( wxCloseEvent& Event ) override; void CloseModuleEditor( wxCommandEvent& Event ); + void OnExitKiCad( wxCommandEvent& aEvent ); /** * switches currently used canvas (Cairo / OpenGL). diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index 38d7d57b33..33c68884f2 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -70,7 +70,8 @@ BEGIN_EVENT_TABLE( FOOTPRINT_VIEWER_FRAME, EDA_DRAW_FRAME ) EVT_SIZE( FOOTPRINT_VIEWER_FRAME::OnSize ) EVT_ACTIVATE( FOOTPRINT_VIEWER_FRAME::OnActivate ) - EVT_MENU( wxID_EXIT, FOOTPRINT_VIEWER_FRAME::CloseFootprintViewer ) + EVT_MENU( wxID_EXIT, FOOTPRINT_VIEWER_FRAME::OnExitKiCad ) + EVT_MENU( wxID_CLOSE, FOOTPRINT_VIEWER_FRAME::CloseFootprintViewer ) // Toolbar events EVT_TOOL( ID_MODVIEW_SELECT_PART, FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint ) @@ -228,6 +229,7 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent GetCanvas()->GetView()->SetScale( m_lastZoom ); updateView(); + InitExitKey(); if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame { @@ -772,7 +774,13 @@ void FOOTPRINT_VIEWER_FRAME::updateView() } +void FOOTPRINT_VIEWER_FRAME::OnExitKiCad( wxCommandEvent& event ) +{ + Kiway().OnKiCadExit(); +} + + void FOOTPRINT_VIEWER_FRAME::CloseFootprintViewer( wxCommandEvent& event ) { - Close(); + Close( false ); } diff --git a/pcbnew/footprint_viewer_frame.h b/pcbnew/footprint_viewer_frame.h index 66af1b35ff..ef52578b77 100644 --- a/pcbnew/footprint_viewer_frame.h +++ b/pcbnew/footprint_viewer_frame.h @@ -109,6 +109,7 @@ private: void OnCloseWindow( wxCloseEvent& Event ) override; void CloseFootprintViewer( wxCommandEvent& event ); + void OnExitKiCad( wxCommandEvent& event ); void ReCreateHToolbar() override; void ReCreateVToolbar() override; diff --git a/pcbnew/menubar_footprint_editor.cpp b/pcbnew/menubar_footprint_editor.cpp index 6e615ee530..a3e4ac1e6b 100644 --- a/pcbnew/menubar_footprint_editor.cpp +++ b/pcbnew/menubar_footprint_editor.cpp @@ -105,8 +105,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() fileMenu->AddItem( ACTIONS::print, haveFootprintCondition ); fileMenu->AddSeparator(); - // Don't use ACTIONS::quit; wxWidgets moves this on OSX and expects to find it via wxID_EXIT - fileMenu->AddItem( wxID_EXIT, _( "Quit" ), "", exit_xpm, SELECTION_CONDITIONS::ShowAlways ); + fileMenu->AddItem( wxID_CLOSE, _( "Close" ), "", exit_xpm, SELECTION_CONDITIONS::ShowAlways ); fileMenu->Resolve(); diff --git a/pcbnew/menubar_pcb_editor.cpp b/pcbnew/menubar_pcb_editor.cpp index 0b475b1c5a..7ceef6914c 100644 --- a/pcbnew/menubar_pcb_editor.cpp +++ b/pcbnew/menubar_pcb_editor.cpp @@ -193,8 +193,17 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() fileMenu->AddMenu( submenuArchive, SELECTION_CONDITIONS::ShowAlways ); fileMenu->AddSeparator(); - // Don't use ACTIONS::quit; wxWidgets moves this on OSX and expects to find it via wxID_EXIT - fileMenu->AddItem( wxID_EXIT, _( "Quit" ), "", exit_xpm, SELECTION_CONDITIONS::ShowAlways ); + + if( Kiface().IsSingle() ) // not when under a project mgr + { + // Don't use ACTIONS::quit; wxWidgets moves this on OSX and expects to find it via wxID_EXIT + fileMenu->AddItem( wxID_EXIT, _( "Quit" ), "", exit_xpm, SELECTION_CONDITIONS::ShowAlways ); + } + else + { + fileMenu->AddItem( + wxID_CLOSE, _( "Close" ), "", exit_xpm, SELECTION_CONDITIONS::ShowAlways ); + } fileMenu->Resolve(); diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 03b891b16f..d8337fc5a7 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -137,6 +137,7 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) EVT_MENU( ID_MENU_CREATE_LIBRARY_AND_ARCHIVE_MODULES, PCB_EDIT_FRAME::Process_Special_Functions ) EVT_MENU( wxID_EXIT, PCB_EDIT_FRAME::OnQuit ) + EVT_MENU( wxID_CLOSE, PCB_EDIT_FRAME::OnQuit ) // menu Config EVT_MENU( ID_PCB_3DSHAPELIB_WIZARD, PCB_EDIT_FRAME::On3DShapeLibWizard ) @@ -311,6 +312,8 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : SaveSettings( config() ); } + InitExitKey(); + GetCanvas()->SwitchBackend( m_canvasType ); GetCanvas()->GetGAL()->SetGridSize( VECTOR2D( GetScreen()->GetGridSize() ) ); GetCanvas()->GetView()->SetScale( GetZoomLevelCoeff() / GetScreen()->GetZoom() ); @@ -455,7 +458,11 @@ void PCB_EDIT_FRAME::ReFillLayerWidget() void PCB_EDIT_FRAME::OnQuit( wxCommandEvent& event ) { - Close( false ); + if( event.GetId() == wxID_EXIT ) + Kiway().OnKiCadExit(); + + if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() ) + Close( false ); } diff --git a/pcbnew/toolbars_footprint_viewer.cpp b/pcbnew/toolbars_footprint_viewer.cpp index b4d09295a0..c1f9c37cfc 100644 --- a/pcbnew/toolbars_footprint_viewer.cpp +++ b/pcbnew/toolbars_footprint_viewer.cpp @@ -123,9 +123,9 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar() // CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool ); - fileMenu->AddItem( wxID_EXIT, _( "Close" ), _( "Close footprint viewer" ), - exit_xpm, SELECTION_CONDITIONS::ShowAlways ); - + fileMenu->AddItem( wxID_CLOSE, _( "Close" ), _( "Close footprint viewer" ), exit_xpm, + SELECTION_CONDITIONS::ShowAlways ); + fileMenu->Resolve(); //----- View menu -----------------------------------------------------------