Kicad and PCM: fix some (minor) issues:

- do not use KICAD_MANAGER_CONTROL::Execute() to run PCM: it is not an external app.
- add a workaround to avoid keeping incorrect focus on buttons in PANEL_KICAD_LAUNCHER.
Fixes #9780
https://gitlab.com/kicad/code/kicad/issues/9780
This commit is contained in:
jean-pierre charras 2021-11-26 10:52:38 +01:00
parent bfa1f6c1a3
commit d03a13b8d8
4 changed files with 24 additions and 11 deletions

View File

@ -31,7 +31,8 @@
PANEL_KICAD_LAUNCHER::PANEL_KICAD_LAUNCHER( wxWindow* aParent ) :
PANEL_KICAD_LAUNCHER_BASE( aParent )
{
m_toolManager = static_cast<KICAD_MANAGER_FRAME*>( aParent )->GetToolManager();
m_frame = static_cast<KICAD_MANAGER_FRAME*>( aParent );
m_toolManager = m_frame->GetToolManager();
CreateLaunchers();
Bind( wxEVT_SYS_COLOUR_CHANGED,
@ -69,7 +70,7 @@ void PANEL_KICAD_LAUNCHER::CreateLaunchers()
{
// Defocus the button because leaving the large buttons
// focused after a click looks out of place in the launcher
GetParent()->SetFocus();
m_frame->SetFocus();
// Gives a slice of time to update the button state (mandatory on GTK,
// useful on MSW to avoid some cosmetic issues).
wxSafeYield();

View File

@ -23,6 +23,7 @@
#include "panel_kicad_launcher_base.h"
class TOOL_MANAGER;
class KICAD_MANAGER_FRAME;
class PANEL_KICAD_LAUNCHER : public PANEL_KICAD_LAUNCHER_BASE
{
@ -38,6 +39,7 @@ private:
private:
TOOL_MANAGER* m_toolManager;
KICAD_MANAGER_FRAME* m_frame;
};

View File

@ -780,14 +780,6 @@ int KICAD_MANAGER_CONTROL::Execute( const TOOL_EVENT& aEvent )
execFile = EESCHEMA_EXE;
else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::editOtherPCB ) )
execFile = PCBNEW_EXE;
#ifdef PCM
else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::showPluginManager ) )
{
DIALOG_PCM* pcm = new DIALOG_PCM( m_frame );
pcm->ShowModal();
pcm->Destroy();
}
#endif
else
wxFAIL_MSG( "Execute(): unexpected request" );
@ -823,6 +815,22 @@ int KICAD_MANAGER_CONTROL::Execute( const TOOL_EVENT& aEvent )
}
int KICAD_MANAGER_CONTROL::ShowPluginManager( const TOOL_EVENT& aEvent )
{
#ifdef PCM
DIALOG_PCM pcm( m_frame );
pcm.ShowModal();
// For some reason, after a double click the bitmap button calling
// PCM keeps the focus althougt the focus was not set to this button.
// This hack force removing the focus from this button
m_frame->SetFocus();
#endif
return 0;
}
void KICAD_MANAGER_CONTROL::setTransitions()
{
Go( &KICAD_MANAGER_CONTROL::NewProject, KICAD_MANAGER_ACTIONS::newProject.MakeEvent() );
@ -849,6 +857,6 @@ void KICAD_MANAGER_CONTROL::setTransitions()
Go( &KICAD_MANAGER_CONTROL::Execute, KICAD_MANAGER_ACTIONS::editOtherPCB.MakeEvent() );
#ifdef PCM
Go( &KICAD_MANAGER_CONTROL::Execute, KICAD_MANAGER_ACTIONS::showPluginManager.MakeEvent() );
Go( &KICAD_MANAGER_CONTROL::ShowPluginManager, KICAD_MANAGER_ACTIONS::showPluginManager.MakeEvent() );
#endif
}

View File

@ -57,6 +57,8 @@ public:
int ShowPlayer( const TOOL_EVENT& aEvent );
int Execute( const TOOL_EVENT& aEvent );
int ShowPluginManager( const TOOL_EVENT& aEvent );
///< Set up handlers for various events.
void setTransitions() override;