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

View File

@ -23,6 +23,7 @@
#include "panel_kicad_launcher_base.h" #include "panel_kicad_launcher_base.h"
class TOOL_MANAGER; class TOOL_MANAGER;
class KICAD_MANAGER_FRAME;
class PANEL_KICAD_LAUNCHER : public PANEL_KICAD_LAUNCHER_BASE class PANEL_KICAD_LAUNCHER : public PANEL_KICAD_LAUNCHER_BASE
{ {
@ -38,6 +39,7 @@ private:
private: private:
TOOL_MANAGER* m_toolManager; 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; execFile = EESCHEMA_EXE;
else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::editOtherPCB ) ) else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::editOtherPCB ) )
execFile = PCBNEW_EXE; 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 else
wxFAIL_MSG( "Execute(): unexpected request" ); 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() void KICAD_MANAGER_CONTROL::setTransitions()
{ {
Go( &KICAD_MANAGER_CONTROL::NewProject, KICAD_MANAGER_ACTIONS::newProject.MakeEvent() ); 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() ); Go( &KICAD_MANAGER_CONTROL::Execute, KICAD_MANAGER_ACTIONS::editOtherPCB.MakeEvent() );
#ifdef PCM #ifdef PCM
Go( &KICAD_MANAGER_CONTROL::Execute, KICAD_MANAGER_ACTIONS::showPluginManager.MakeEvent() ); Go( &KICAD_MANAGER_CONTROL::ShowPluginManager, KICAD_MANAGER_ACTIONS::showPluginManager.MakeEvent() );
#endif #endif
} }

View File

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