diff --git a/common/tool/conditional_menu.cpp b/common/tool/conditional_menu.cpp index 6f968d6817..f55756d2eb 100644 --- a/common/tool/conditional_menu.cpp +++ b/common/tool/conditional_menu.cpp @@ -26,6 +26,7 @@ #include #include #include +#include CONDITIONAL_MENU::CONDITIONAL_MENU( bool isContextMenu, TOOL_INTERACTIVE* aTool ) : @@ -98,6 +99,21 @@ void CONDITIONAL_MENU::AddSeparator( int aOrder ) } +void CONDITIONAL_MENU::AddQuitOrClose( KIFACE_I* aKiface ) +{ + if( !aKiface || aKiface->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 + AddItem( wxID_EXIT, _( "Quit" ), "", exit_xpm, SELECTION_CONDITIONS::ShowAlways ); + } + else + { + AddItem( wxID_CLOSE, _( "Close\tCTRL+W" ), "", exit_xpm, SELECTION_CONDITIONS::ShowAlways ); + } +} + + SELECTION g_resolveDummySelection; diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index e1a557573c..03e23f48da 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -115,16 +115,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() fileMenu->AddItem( ACTIONS::plot, EE_CONDITIONS::ShowAlways ); fileMenu->AddSeparator(); - - 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->AddQuitOrClose( &Kiface() ); fileMenu->Resolve(); diff --git a/gerbview/menubar.cpp b/gerbview/menubar.cpp index f171ff83de..e072001d42 100644 --- a/gerbview/menubar.cpp +++ b/gerbview/menubar.cpp @@ -139,8 +139,7 @@ void GERBVIEW_FRAME::ReCreateMenuBar() fileMenu->AddItem( ACTIONS::print, 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->AddQuitOrClose( &Kiface() ); fileMenu->Resolve(); diff --git a/include/tool/conditional_menu.h b/include/tool/conditional_menu.h index e994d2a2c1..dc788c0371 100644 --- a/include/tool/conditional_menu.h +++ b/include/tool/conditional_menu.h @@ -30,10 +30,10 @@ #include #include - class SELECTION_TOOL; class TOOL_ACTION; class TOOL_INTERACTIVE; +class KIFACE_I; class CONDITIONAL_MENU : public ACTION_MENU @@ -100,6 +100,14 @@ public: */ void AddSeparator( int aOrder = ANY_ORDER ); + /** + * Functions AddQuitOrClose() + * + * Adds either a standard Quit or Close item to the menu (depending on whether or not the + * app was launched stand-alone). + */ + void AddQuitOrClose( KIFACE_I* aKiface ); + /** * Function Evaluate() * diff --git a/kicad/menubar.cpp b/kicad/menubar.cpp index a6a92e7403..750f3aea8a 100644 --- a/kicad/menubar.cpp +++ b/kicad/menubar.cpp @@ -84,8 +84,7 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar() unzip_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->AddQuitOrClose( nullptr ); fileMenu->Resolve(); diff --git a/pagelayout_editor/menubar.cpp b/pagelayout_editor/menubar.cpp index f1c3ec9c4e..6740be3be7 100644 --- a/pagelayout_editor/menubar.cpp +++ b/pagelayout_editor/menubar.cpp @@ -78,18 +78,7 @@ void PL_EDITOR_FRAME::ReCreateMenuBar() fileMenu->AddItem( ACTIONS::print, SELECTION_CONDITIONS::ShowAlways ); fileMenu->AddSeparator(); - - if( Kiface().IsSingle() ) - { - // 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->AddQuitOrClose( &Kiface() ); fileMenu->Resolve(); diff --git a/pcbnew/menubar_pcb_editor.cpp b/pcbnew/menubar_pcb_editor.cpp index 2063ffcfe2..c11d0428fb 100644 --- a/pcbnew/menubar_pcb_editor.cpp +++ b/pcbnew/menubar_pcb_editor.cpp @@ -193,17 +193,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() fileMenu->AddMenu( submenuArchive, SELECTION_CONDITIONS::ShowAlways ); fileMenu->AddSeparator(); - - 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->AddQuitOrClose( &Kiface() ); fileMenu->Resolve();