Push the Quit/Close menu logic down into common.

This commit is contained in:
Jeff Young 2019-08-02 12:36:14 -06:00
parent c258ad7e3c
commit cc82e59003
7 changed files with 30 additions and 38 deletions

View File

@ -26,6 +26,7 @@
#include <tool/conditional_menu.h> #include <tool/conditional_menu.h>
#include <tool/action_menu.h> #include <tool/action_menu.h>
#include <menus_helpers.h> #include <menus_helpers.h>
#include <kiface_i.h>
CONDITIONAL_MENU::CONDITIONAL_MENU( bool isContextMenu, TOOL_INTERACTIVE* aTool ) : 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; SELECTION g_resolveDummySelection;

View File

@ -115,16 +115,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
fileMenu->AddItem( ACTIONS::plot, EE_CONDITIONS::ShowAlways ); fileMenu->AddItem( ACTIONS::plot, EE_CONDITIONS::ShowAlways );
fileMenu->AddSeparator(); fileMenu->AddSeparator();
fileMenu->AddQuitOrClose( &Kiface() );
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(); fileMenu->Resolve();

View File

@ -139,8 +139,7 @@ void GERBVIEW_FRAME::ReCreateMenuBar()
fileMenu->AddItem( ACTIONS::print, SELECTION_CONDITIONS::ShowAlways ); fileMenu->AddItem( ACTIONS::print, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddSeparator(); fileMenu->AddSeparator();
// Don't use ACTIONS::quit; wxWidgets moves this on OSX and expects to find it via wxID_EXIT fileMenu->AddQuitOrClose( &Kiface() );
fileMenu->AddItem( wxID_EXIT, _( "Quit" ), "", exit_xpm, SELECTION_CONDITIONS::ShowAlways );
fileMenu->Resolve(); fileMenu->Resolve();

View File

@ -30,10 +30,10 @@
#include <list> #include <list>
#include <wx/wx.h> #include <wx/wx.h>
class SELECTION_TOOL; class SELECTION_TOOL;
class TOOL_ACTION; class TOOL_ACTION;
class TOOL_INTERACTIVE; class TOOL_INTERACTIVE;
class KIFACE_I;
class CONDITIONAL_MENU : public ACTION_MENU class CONDITIONAL_MENU : public ACTION_MENU
@ -100,6 +100,14 @@ public:
*/ */
void AddSeparator( int aOrder = ANY_ORDER ); 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() * Function Evaluate()
* *

View File

@ -84,8 +84,7 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar()
unzip_xpm, SELECTION_CONDITIONS::ShowAlways ); unzip_xpm, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddSeparator(); fileMenu->AddSeparator();
// Don't use ACTIONS::quit; wxWidgets moves this on OSX and expects to find it via wxID_EXIT fileMenu->AddQuitOrClose( nullptr );
fileMenu->AddItem( wxID_EXIT, _( "Quit" ), "", exit_xpm, SELECTION_CONDITIONS::ShowAlways );
fileMenu->Resolve(); fileMenu->Resolve();

View File

@ -78,18 +78,7 @@ void PL_EDITOR_FRAME::ReCreateMenuBar()
fileMenu->AddItem( ACTIONS::print, SELECTION_CONDITIONS::ShowAlways ); fileMenu->AddItem( ACTIONS::print, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddSeparator(); fileMenu->AddSeparator();
fileMenu->AddQuitOrClose( &Kiface() );
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->Resolve(); fileMenu->Resolve();

View File

@ -193,17 +193,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
fileMenu->AddMenu( submenuArchive, SELECTION_CONDITIONS::ShowAlways ); fileMenu->AddMenu( submenuArchive, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddSeparator(); fileMenu->AddSeparator();
fileMenu->AddQuitOrClose( &Kiface() );
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(); fileMenu->Resolve();