Add action for switching to Project Manager.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15740
This commit is contained in:
Jeff Young 2023-09-26 17:25:06 +01:00
parent aab0696bb6
commit 54171ec030
7 changed files with 54 additions and 13 deletions

View File

@ -841,6 +841,13 @@ TOOL_ACTION ACTIONS::pickerSubTool( TOOL_ACTION_ARGS()
.Name( "common.InteractivePicker.pickerSubTool" )
.Scope( AS_GLOBAL ) );
TOOL_ACTION ACTIONS::showProjectManager( TOOL_ACTION_ARGS()
.Name( "common.Control.showProjectManager" )
.Scope( AS_GLOBAL )
.MenuText( _( "Switch to Project Manager" ) )
.Tooltip( _( "Show project window" ) )
.Icon( BITMAPS::icon_kicad_24 ) );
TOOL_ACTION ACTIONS::show3DViewer( TOOL_ACTION_ARGS()
.Name( "common.Control.show3DViewer" )
.Scope( AS_GLOBAL )

View File

@ -143,6 +143,28 @@ int COMMON_CONTROL::ShowLibraryTable( const TOOL_EVENT& aEvent )
}
void showFrame( EDA_BASE_FRAME* aFrame )
{
// Needed on Windows, other platforms do not use it, but it creates no issue
if( aFrame->IsIconized() )
aFrame->Iconize( false );
aFrame->Raise();
// Raising the window does not set the focus on Linux. This should work on
// any platform.
if( wxWindow::FindFocus() != aFrame )
aFrame->SetFocus();
// If the player is currently blocked, focus the user attention on the correct window
if( wxWindow* blocking_win = aFrame->Kiway().GetBlockingDialog() )
{
blocking_win->Raise();
blocking_win->SetFocus();
}
}
int COMMON_CONTROL::ShowPlayer( const TOOL_EVENT& aEvent )
{
FRAME_T playerType = aEvent.Parameter<FRAME_T>();
@ -151,22 +173,25 @@ int COMMON_CONTROL::ShowPlayer( const TOOL_EVENT& aEvent )
// editor can be null if Player() fails:
wxCHECK_MSG( editor != nullptr, 0, wxT( "Cannot open/create the editor frame" ) );
// Needed on Windows, other platforms do not use it, but it creates no issue
if( editor->IsIconized() )
editor->Iconize( false );
showFrame( editor );
editor->Raise();
return 0;
}
// Raising the window does not set the focus on Linux. This should work on
// any platform.
if( wxWindow::FindFocus() != editor )
editor->SetFocus();
// If the player is currently blocked, focus the user attention on the correct window
if( wxWindow* blocking_win = editor->Kiway().GetBlockingDialog() )
int COMMON_CONTROL::ShowProjectManager( const TOOL_EVENT& aEvent )
{
// Note: dynamic_cast doesn't work over the Kiway() on MacOS. We have to use static_cast
// here.
EDA_BASE_FRAME* top = static_cast<EDA_BASE_FRAME*>( m_frame->Kiway().GetTop() );
if( top && top->GetFrameType() == KICAD_MAIN_FRAME_T )
{
blocking_win->Raise();
blocking_win->SetFocus();
showFrame( top );
}
else
{
wxMessageDialog( m_frame, _( "Can not switch to project manager in stand-alone mode." ) );
}
return 0;
@ -313,6 +338,7 @@ void COMMON_CONTROL::setTransitions()
Go( &COMMON_CONTROL::ShowPlayer, ACTIONS::showSymbolEditor.MakeEvent() );
Go( &COMMON_CONTROL::ShowPlayer, ACTIONS::showFootprintBrowser.MakeEvent() );
Go( &COMMON_CONTROL::ShowPlayer, ACTIONS::showFootprintEditor.MakeEvent() );
Go( &COMMON_CONTROL::ShowProjectManager, ACTIONS::showProjectManager.MakeEvent() );
Go( &COMMON_CONTROL::ShowHelp, ACTIONS::gettingStarted.MakeEvent() );
Go( &COMMON_CONTROL::ShowHelp, ACTIONS::help.MakeEvent() );

View File

@ -271,6 +271,9 @@ void SCH_EDIT_FRAME::doReCreateMenuBar()
toolsMenu->Add( EE_ACTIONS::showPcbNew );
if( !Kiface().IsSingle() )
toolsMenu->Add( ACTIONS::showProjectManager );
toolsMenu->AppendSeparator();
toolsMenu->Add( ACTIONS::showSymbolEditor );
toolsMenu->Add( EE_ACTIONS::updateSymbols );

View File

@ -166,6 +166,7 @@ public:
static TOOL_ACTION pickerSubTool;
// Misc
static TOOL_ACTION showProjectManager;
static TOOL_ACTION show3DViewer;
static TOOL_ACTION showSymbolBrowser;
static TOOL_ACTION showSymbolEditor;

View File

@ -50,6 +50,7 @@ public:
int ShowLibraryTable( const TOOL_EVENT& aEvent );
int ShowPlayer( const TOOL_EVENT& aEvent );
int ShowProjectManager( const TOOL_EVENT& aEvent );
int ShowHelp( const TOOL_EVENT& aEvent );
int ListHotKeys( const TOOL_EVENT& aEvent );

View File

@ -390,6 +390,9 @@ void PCB_EDIT_FRAME::doReCreateMenuBar()
toolsMenu->Add( PCB_ACTIONS::showEeschema );
if( !Kiface().IsSingle() )
toolsMenu->Add( ACTIONS::showProjectManager );
toolsMenu->AppendSeparator();
toolsMenu->Add( ACTIONS::showFootprintEditor );
toolsMenu->Add( PCB_ACTIONS::updateFootprints );

View File

@ -1217,7 +1217,7 @@ TOOL_ACTION PCB_ACTIONS::showEeschema( TOOL_ACTION_ARGS()
.Name( "pcbnew.EditorControl.showEeschema" )
.Scope( AS_GLOBAL )
.MenuText( _( "Switch to Schematic Editor" ) )
.Tooltip( _( "Open in schematic editor" ) )
.Tooltip( _( "Open schematic in schematic editor" ) )
.Icon( BITMAPS::icon_eeschema_24 ) );