Formatting.

This commit is contained in:
Jeff Young 2025-07-09 16:13:34 +01:00
parent 76c2a9fb8e
commit 7a91441a82
2 changed files with 65 additions and 77 deletions

View File

@ -36,8 +36,8 @@ PANEL_KICAD_LAUNCHER::PANEL_KICAD_LAUNCHER( wxWindow* aParent ) :
m_frame = static_cast<KICAD_MANAGER_FRAME*>( aParent->GetParent() );
CreateLaunchers();
Bind( wxEVT_SYS_COLOUR_CHANGED,
wxSysColourChangedEventHandler( PANEL_KICAD_LAUNCHER::onThemeChanged ), this );
Bind( wxEVT_SYS_COLOUR_CHANGED, wxSysColourChangedEventHandler( PANEL_KICAD_LAUNCHER::onThemeChanged ),
this );
}
@ -48,23 +48,22 @@ PANEL_KICAD_LAUNCHER::~PANEL_KICAD_LAUNCHER()
for( wxWindow* window : m_scrolledWindow->GetChildren() )
{
if( dynamic_cast<BITMAP_BUTTON*>( window ) != nullptr )
{
window->Unbind( wxEVT_BUTTON, &PANEL_KICAD_LAUNCHER::onLauncherButtonClick, this );
}
}
Unbind( wxEVT_SYS_COLOUR_CHANGED,
wxSysColourChangedEventHandler( PANEL_KICAD_LAUNCHER::onThemeChanged ), this );
Unbind( wxEVT_SYS_COLOUR_CHANGED, wxSysColourChangedEventHandler( PANEL_KICAD_LAUNCHER::onThemeChanged ),
this );
}
void PANEL_KICAD_LAUNCHER::onLauncherButtonClick( wxCommandEvent& aEvent )
{
// Defocus the button because leaving the large buttons
// focused after a click looks out of place in the launcher
// Defocus the button because leaving the large buttons focused after a click looks out of place in
// the launcher
m_frame->SetFocus();
// Gives a slice of time to update the button state (mandatory on GTK,
// useful on MSW to avoid some cosmetic issues).
// Gives a slice of time to update the button state (mandatory on GTK, useful on MSW to avoid some
// cosmetic issues).
wxSafeYield();
BITMAP_BUTTON* button = (BITMAP_BUTTON*) aEvent.GetEventObject();
@ -98,48 +97,48 @@ void PANEL_KICAD_LAUNCHER::CreateLaunchers()
wxFont helpFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
helpFont.SetStyle( wxFONTSTYLE_ITALIC );
auto addLauncher = [&]( const TOOL_ACTION& aAction, BITMAPS aBitmaps, const wxString& aHelpText,
bool enabled = true )
{
BITMAP_BUTTON* btn = new BITMAP_BUTTON( m_scrolledWindow, wxID_ANY );
btn->SetBitmap( KiBitmapBundle( aBitmaps ) );
btn->SetDisabledBitmap( KiDisabledBitmapBundle( aBitmaps ) );
btn->SetPadding( FromDIP( 4 ) );
btn->SetToolTip( aAction.GetTooltip() );
auto addLauncher =
[&]( const TOOL_ACTION& aAction, BITMAPS aBitmaps, const wxString& aHelpText, bool enabled = true )
{
BITMAP_BUTTON* btn = new BITMAP_BUTTON( m_scrolledWindow, wxID_ANY );
btn->SetBitmap( KiBitmapBundle( aBitmaps ) );
btn->SetDisabledBitmap( KiDisabledBitmapBundle( aBitmaps ) );
btn->SetPadding( FromDIP( 4 ) );
btn->SetToolTip( aAction.GetTooltip() );
m_scrolledWindow->SetFont( titleFont ); // Use font inheritance to avoid extra SetFont call.
wxStaticText* label =
new wxStaticText( m_scrolledWindow, wxID_ANY, aAction.GetFriendlyName() );
label->SetToolTip( aAction.GetTooltip() );
m_scrolledWindow->SetFont( titleFont ); // Use font inheritance to avoid extra SetFont call.
wxStaticText* label = new wxStaticText( m_scrolledWindow, wxID_ANY, aAction.GetFriendlyName() );
label->SetToolTip( aAction.GetTooltip() );
m_scrolledWindow->SetFont( helpFont ); // Use font inheritance to avoid extra SetFont call.
wxStaticText* help = new wxStaticText( m_scrolledWindow, wxID_ANY, aHelpText );
m_scrolledWindow->SetFont( helpFont ); // Use font inheritance to avoid extra SetFont call.
wxStaticText* help = new wxStaticText( m_scrolledWindow, wxID_ANY, aHelpText );
btn->Bind( wxEVT_BUTTON, &PANEL_KICAD_LAUNCHER::onLauncherButtonClick, this );
btn->SetClientData( (void*) &aAction );
btn->Bind( wxEVT_BUTTON, &PANEL_KICAD_LAUNCHER::onLauncherButtonClick, this );
btn->SetClientData( (void*) &aAction );
// The bug fix below makes this handler active for the entire window width. Without
// any visual feedback that's a bit odd. Disabling for now.
// label->Bind( wxEVT_LEFT_UP, handler );
// The bug fix below makes this handler active for the entire window width. Without any visual
// feedback that's a bit odd. Disabling for now.
// label->Bind( wxEVT_LEFT_UP, handler );
m_toolsSizer->Add( btn, 1, wxALIGN_CENTER_VERTICAL );
m_toolsSizer->Add( btn, 1, wxALIGN_CENTER_VERTICAL );
wxBoxSizer* textSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* textSizer = new wxBoxSizer( wxVERTICAL );
textSizer->Add( label );
textSizer->Add( help );
textSizer->Add( label );
textSizer->Add( help );
m_toolsSizer->Add( textSizer, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL );
m_toolsSizer->Add( textSizer, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL );
btn->Enable( enabled );
if( !enabled )
{
help->Disable();
label->Disable();
}
btn->Enable( enabled );
return btn;
};
if( !enabled )
{
help->Disable();
label->Disable();
}
return btn;
};
addLauncher( KICAD_MANAGER_ACTIONS::editSchematic, BITMAPS::icon_eeschema,
_( "Edit the project schematic" ) );
@ -163,14 +162,12 @@ void PANEL_KICAD_LAUNCHER::CreateLaunchers()
_( "Show tools for calculating resistance, current capacity, etc." ) );
addLauncher( KICAD_MANAGER_ACTIONS::editDrawingSheet, BITMAPS::icon_pagelayout_editor,
_( "Edit drawing sheet borders and title blocks for use in schematics and PCB "
"designs" ) );
_( "Edit drawing sheet borders and title blocks for use in schematics and PCB designs" ) );
BITMAP_BUTTON* bb =
addLauncher( KICAD_MANAGER_ACTIONS::showPluginManager, BITMAPS::icon_pcm,
_( "Manage downloadable packages from KiCad and 3rd party repositories" ),
( KIPLATFORM::POLICY::GetPolicyBool( POLICY_KEY_PCM )
!= KIPLATFORM::POLICY::PBOOL::DISABLED ) );
BITMAP_BUTTON* bb = addLauncher( KICAD_MANAGER_ACTIONS::showPluginManager, BITMAPS::icon_pcm,
_( "Manage downloadable packages from KiCad and 3rd party repositories" ),
KIPLATFORM::POLICY::GetPolicyBool( POLICY_KEY_PCM )
!= KIPLATFORM::POLICY::PBOOL::DISABLED );
m_frame->SetPcmButton( bb );

View File

@ -218,8 +218,7 @@ int KICAD_MANAGER_CONTROL::NewFromRepository( const TOOL_EVENT& aEvent )
int KICAD_MANAGER_CONTROL::NewJobsetFile( const TOOL_EVENT& aEvent )
{
wxString default_dir = wxFileName( Prj().GetProjectFullName() ).GetPathWithSep();
wxFileDialog dlg( m_frame, _( "Create New Jobset" ), default_dir, wxEmptyString,
FILEEXT::JobsetFileWildcard(),
wxFileDialog dlg( m_frame, _( "Create New Jobset" ), default_dir, wxEmptyString, FILEEXT::JobsetFileWildcard(),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() == wxID_CANCEL )
@ -258,8 +257,8 @@ int KICAD_MANAGER_CONTROL::NewFromTemplate( const TOOL_EVENT& aEvent )
titleDirMap.emplace( _( "User Templates" ), templatePath );
}
DIALOG_TEMPLATE_SELECTOR ps( m_frame, settings->m_TemplateWindowPos,
settings->m_TemplateWindowSize, titleDirMap );
DIALOG_TEMPLATE_SELECTOR ps( m_frame, settings->m_TemplateWindowPos, settings->m_TemplateWindowSize,
titleDirMap );
// Show the project template selector dialog
int result = ps.ShowModal();
@ -272,8 +271,8 @@ int KICAD_MANAGER_CONTROL::NewFromTemplate( const TOOL_EVENT& aEvent )
if( !ps.GetSelectedTemplate() )
{
wxMessageBox( _( "No project template was selected. Cannot generate new project." ),
_( "Error" ), wxOK | wxICON_ERROR, m_frame );
wxMessageBox( _( "No project template was selected. Cannot generate new project." ), _( "Error" ),
wxOK | wxICON_ERROR, m_frame );
return -1;
}
@ -355,10 +354,8 @@ int KICAD_MANAGER_CONTROL::NewFromTemplate( const TOOL_EVENT& aEvent )
for( const wxFileName& file : overwrittenFiles )
extendedMsg += "\n" + file.GetFullName();
KIDIALOG msgDlg( m_frame,
_( "Similar files already exist in the destination folder." ),
_( "Confirmation" ),
wxOK | wxCANCEL | wxICON_WARNING );
KIDIALOG msgDlg( m_frame, _( "Similar files already exist in the destination folder." ),
_( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
msgDlg.SetExtendedMessage( extendedMsg );
msgDlg.SetOKLabel( _( "Overwrite" ) );
msgDlg.DoNotShowCheckbox( __FILE__, __LINE__ );
@ -374,10 +371,8 @@ int KICAD_MANAGER_CONTROL::NewFromTemplate( const TOOL_EVENT& aEvent )
// create a project
if( !ps.GetSelectedTemplate()->CreateProject( fn, &errorMsg ) )
{
wxMessageDialog createDlg( m_frame,
_( "A problem occurred creating new project from template." ),
_( "Error" ),
wxOK | wxICON_ERROR );
wxMessageDialog createDlg( m_frame, _( "A problem occurred creating new project from template." ),
_( "Error" ), wxOK | wxICON_ERROR );
if( !errorMsg.empty() )
createDlg.SetExtendedMessage( errorMsg );
@ -438,8 +433,8 @@ int KICAD_MANAGER_CONTROL::OpenProject( const TOOL_EVENT& aEvent )
int KICAD_MANAGER_CONTROL::OpenJobsetFile( const TOOL_EVENT& aEvent )
{
wxString default_dir = wxFileName( Prj().GetProjectFullName() ).GetPathWithSep();
wxFileDialog dlg( m_frame, _( "Open Jobset" ), default_dir, wxEmptyString,
FILEEXT::JobsetFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST );
wxFileDialog dlg( m_frame, _( "Open Jobset" ), default_dir, wxEmptyString, FILEEXT::JobsetFileWildcard(),
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
if( dlg.ShowModal() == wxID_CANCEL )
return -1;
@ -473,8 +468,7 @@ int KICAD_MANAGER_CONTROL::ArchiveProject( const TOOL_EVENT& aEvent )
fileName.SetExt( FILEEXT::ArchiveFileExtension );
wxFileDialog dlg( m_frame, _( "Archive Project Files" ),
fileName.GetPath(), fileName.GetFullName(),
wxFileDialog dlg( m_frame, _( "Archive Project Files" ), fileName.GetPath(), fileName.GetFullName(),
FILEEXT::ZipFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() == wxID_CANCEL )
@ -591,7 +585,7 @@ public:
|| ext == FILEEXT::LegacySymbolDocumentFileExtension
|| ext == FILEEXT::KiCadSymbolLibFileExtension
|| ext == FILEEXT::NetlistFileExtension
|| destFile.GetName() == FILEEXT::SymbolLibraryTableFileName )
|| destFile.GetName() == FILEEXT::SymbolLibraryTableFileName )
{
KIFACE* eeschema = m_frame->Kiway().KiFACE( KIWAY::FACE_SCH );
eeschema->SaveFileAs( m_projectDirPath, m_projectName, m_newProjectDirPath,
@ -603,7 +597,7 @@ public:
|| ext == FILEEXT::KiCadFootprintFileExtension
|| ext == FILEEXT::LegacyFootprintLibPathExtension
|| ext == FILEEXT::FootprintAssignmentFileExtension
|| destFile.GetName() == FILEEXT::FootprintLibraryTableFileName )
|| destFile.GetName() == FILEEXT::FootprintLibraryTableFileName )
{
KIFACE* pcbnew = m_frame->Kiway().KiFACE( KIWAY::FACE_PCB );
pcbnew->SaveFileAs( m_projectDirPath, m_projectName, m_newProjectDirPath,
@ -736,8 +730,7 @@ int KICAD_MANAGER_CONTROL::SaveProjectAs( const TOOL_EVENT& aEvent )
default_dir = default_dir_fn.GetPath();
}
wxFileDialog dlg( m_frame, _( "Save Project To" ), default_dir, wxEmptyString, wxEmptyString,
wxFD_SAVE );
wxFileDialog dlg( m_frame, _( "Save Project To" ), default_dir, wxEmptyString, wxEmptyString, wxFD_SAVE );
if( dlg.ShowModal() == wxID_CANCEL )
return -1;
@ -776,8 +769,8 @@ int KICAD_MANAGER_CONTROL::SaveProjectAs( const TOOL_EVENT& aEvent )
const wxString& newProjectName = newProjectDir.GetDirs().Last();
wxDir currentProjectDir( currentProjectDirPath );
SAVE_AS_TRAVERSER traverser( m_frame, currentProjectDirPath, currentProjectName,
newProjectDirPath, newProjectName );
SAVE_AS_TRAVERSER traverser( m_frame, currentProjectDirPath, currentProjectName, newProjectDirPath,
newProjectName );
currentProjectDir.Traverse( traverser );
@ -823,14 +816,12 @@ int KICAD_MANAGER_CONTROL::ShowPlayer( const TOOL_EVENT& aEvent )
if( playerType == FRAME_SCH && !m_frame->IsProjectActive() )
{
DisplayInfoMessage( m_frame, _( "Create (or open) a project to edit a schematic." ),
wxEmptyString );
DisplayInfoMessage( m_frame, _( "Create (or open) a project to edit a schematic." ), wxEmptyString );
return -1;
}
else if( playerType == FRAME_PCB_EDITOR && !m_frame->IsProjectActive() )
{
DisplayInfoMessage( m_frame, _( "Create (or open) a project to edit a pcb." ),
wxEmptyString );
DisplayInfoMessage( m_frame, _( "Create (or open) a project to edit a pcb." ), wxEmptyString );
return -1;
}