Generalize the Ctrl-Q to all frames

Rather than adding our handler to each frame separately, we initialize
the Ctrl-Q quit action at the base frame to be consistent
This commit is contained in:
Seth Hillbrand 2021-02-09 11:41:36 -08:00
parent 65c41cff42
commit 505844f68c
10 changed files with 20 additions and 24 deletions

View File

@ -118,6 +118,8 @@ EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType,
// hook wxEVT_CLOSE_WINDOW so we can call SaveSettings(). This function seems
// to be called before any other hook for wxCloseEvent, which is necessary.
Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_BASE_FRAME::windowClosing ) );
initExitKey();
}
@ -974,6 +976,15 @@ bool EDA_BASE_FRAME::IsContentModified()
}
void EDA_BASE_FRAME::initExitKey()
{
wxAcceleratorEntry entries[1];
entries[0].Set( wxACCEL_CTRL, int( 'Q' ), wxID_EXIT );
wxAcceleratorTable accel( 1, entries );
SetAcceleratorTable( accel );
}
void EDA_BASE_FRAME::ClearUndoRedoList()
{
ClearUndoORRedoList( UNDO_LIST );

View File

@ -455,15 +455,6 @@ void EDA_DRAW_FRAME::AddStandardSubMenus( TOOL_MENU& aToolMenu )
}
void EDA_DRAW_FRAME::initExitKey()
{
wxAcceleratorEntry entries[1];
entries[0].Set( wxACCEL_CTRL, int( 'Q' ), wxID_EXIT );
wxAcceleratorTable accel( 1, entries );
SetAcceleratorTable( accel );
}
void EDA_DRAW_FRAME::DisplayToolMsg( const wxString& msg )
{
SetStatusText( msg, 6 );
@ -1057,4 +1048,4 @@ void EDA_DRAW_FRAME::resolveCanvasType()
m_firstRunDialogSetting = 1;
SaveSettings( config() );
}
}
}

View File

@ -288,7 +288,6 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
p->SetSchematic( m_schematic );
}
initExitKey();
setupUnits( eeconfig() );
// Net list generator

View File

@ -147,7 +147,6 @@ SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
ReCreateHToolbar();
ReCreateVToolbar();
ReCreateOptToolbar();
initExitKey();
updateTitle();
DisplaySymbolDatasheet();

View File

@ -618,6 +618,14 @@ protected:
*/
virtual void setupUIConditions();
/**
* 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();
DECLARE_EVENT_TABLE()
private:

View File

@ -462,14 +462,6 @@ protected:
*/
bool saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType );
/**
* 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();
wxSocketServer* m_socketServer;
std::vector<wxSocketBase*> m_sockets; ///< interprocess communication

View File

@ -189,7 +189,6 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
SwitchCanvas( m_canvasType );
// Add the exit key handler
initExitKey();
setupUnits( config() );
wxPoint originCoord = ReturnCoordOriginCorner();

View File

@ -285,7 +285,6 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent,
GetToolManager()->RunAction( ACTIONS::zoomFitScreen, false );
updateTitle();
initExitKey();
setupUnits( GetSettings() );
// Default shutdown reason until a file is loaded

View File

@ -266,7 +266,6 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent
GetCanvas()->GetView()->SetScale( cfg->m_FootprintViewerZoom );
updateView();
initExitKey();
setupUnits( config() );
if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame

View File

@ -313,7 +313,6 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
resolveCanvasType();
initExitKey();
setupUnits( config() );
// Ensure the Python interpreter is up to date with its environment variables