7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-03-30 06:56:57 +00:00

Enable/disable git tracking in user prefs

Don't require advanced config for people who want to disable
This commit is contained in:
Seth Hillbrand 2025-03-24 11:52:11 -07:00
parent 6d0a8cd346
commit f83e607e6e
13 changed files with 1097 additions and 1373 deletions

View File

@ -100,7 +100,6 @@ static const wxChar V3DRT_BevelHeight_um[] = wxT( "V3DRT_BevelHeight_um" );
static const wxChar V3DRT_BevelExtentFactor[] = wxT( "V3DRT_BevelExtentFactor" );
static const wxChar EnablePcbDesignBlocks[] = wxT( "EnablePcbDesignBlocks" );
static const wxChar EnableGenerators[] = wxT( "EnableGenerators" );
static const wxChar EnableGit[] = wxT( "EnableGit" );
static const wxChar EnableLibWithText[] = wxT( "EnableLibWithText" );
static const wxChar EnableLibDir[] = wxT( "EnableLibDir" );
static const wxChar DisambiguationTime[] = wxT( "DisambiguationTime" );
@ -127,7 +126,6 @@ static const wxChar NetInspectorBulkUpdateOptimisationThreshold[] =
wxT( "NetInspectorBulkUpdateOptimisationThreshold" );
static const wxChar ExcludeFromSimulationLineWidth[] = wxT( "ExcludeFromSimulationLineWidth" );
static const wxChar GitIconRefreshInterval[] = wxT( "GitIconRefreshInterval" );
static const wxChar GitProjectStatusRefreshInterval[] = wxT( "GitProjectStatusRefreshInterval" );
static const wxChar ConfigurableToolbars[] = wxT( "ConfigurableToolbars" );
} // namespace KEYS
@ -259,7 +257,6 @@ ADVANCED_CFG::ADVANCED_CFG()
m_ShowRepairSchematic = false;
m_EnablePcbDesignBlocks = false;
m_EnableGenerators = false;
m_EnableGit = true;
m_EnableLibWithText = false;
m_EnableLibDir = false;
@ -309,7 +306,6 @@ ADVANCED_CFG::ADVANCED_CFG()
m_ExcludeFromSimulationLineWidth = 25;
m_GitIconRefreshInterval = 10000;
m_GitProjectStatusRefreshInterval = 60000;
m_ConfigurableToolbars = false;
@ -502,9 +498,6 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::EnableAPILogging,
&m_EnableAPILogging, m_EnableAPILogging ) );
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::EnableGit,
&m_EnableGit, m_EnableGit ) );
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::EnableLibWithText,
&m_EnableLibWithText, m_EnableLibWithText ) );
@ -598,10 +591,6 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
&m_GitIconRefreshInterval,
m_GitIconRefreshInterval, 0, 100000 ) );
configParams.push_back( new PARAM_CFG_INT( true, AC_KEYS::GitProjectStatusRefreshInterval,
&m_GitProjectStatusRefreshInterval,
m_GitProjectStatusRefreshInterval, 0, 100000 ) );
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::ConfigurableToolbars,
&m_ConfigurableToolbars,
m_ConfigurableToolbars ) );

View File

@ -38,11 +38,6 @@
PANEL_GIT_REPOS::PANEL_GIT_REPOS( wxWindow* aParent ) : PANEL_GIT_REPOS_BASE( aParent)
{
m_btnAddRepo->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) );
m_btnEditRepo->SetBitmap( KiBitmapBundle( BITMAPS::small_edit ) );
m_btnDelete->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
}
PANEL_GIT_REPOS::~PANEL_GIT_REPOS()
@ -52,7 +47,6 @@ PANEL_GIT_REPOS::~PANEL_GIT_REPOS()
void PANEL_GIT_REPOS::ResetPanel()
{
m_grid->ClearGrid();
m_cbDefault->SetValue( true );
m_author->SetValue( wxEmptyString );
m_authorEmail->SetValue( wxEmptyString );
@ -103,28 +97,10 @@ static std::pair<wxString, wxString> getDefaultAuthorAndEmail()
bool PANEL_GIT_REPOS::TransferDataFromWindow()
{
COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
std::vector<COMMON_SETTINGS::GIT_REPOSITORY>& repos = settings->m_Git.repositories;
repos.clear();
for( int row = 0; row < m_grid->GetNumberRows(); row++ )
{
COMMON_SETTINGS::GIT_REPOSITORY repo;
repo.active = m_grid->GetCellValue( row, COL_ACTIVE ) == "1";
repo.name = m_grid->GetCellValue( row, COL_NAME );
repo.path = m_grid->GetCellValue( row, COL_PATH );
repo.authType = m_grid->GetCellValue( row, COL_AUTH_TYPE );
repo.username = m_grid->GetCellValue( row, COL_USERNAME );
KIPLATFORM::SECRETS::StoreSecret( repo.path, repo.username,
m_grid->GetCellValue( row, COL_PASSWORD ) );
repo.ssh_path = m_grid->GetCellValue( row, COL_SSH_PATH );
repo.checkValid = m_grid->GetCellValue( row, COL_STATUS ) == "1";
repos.push_back( repo );
}
COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
settings->m_Git.enableGit = m_enableGit->GetValue();
settings->m_Git.updatInterval = m_updateInterval->GetValue();
settings->m_Git.useDefaultAuthor = m_cbDefault->GetValue();
settings->m_Git.authorName = m_author->GetValue();
settings->m_Git.authorEmail = m_authorEmail->GetValue();
@ -132,149 +108,38 @@ bool PANEL_GIT_REPOS::TransferDataFromWindow()
return true;
}
static bool testRepositoryConnection( COMMON_SETTINGS::GIT_REPOSITORY& repository)
{
git_libgit2_init();
git_remote_callbacks callbacks;
callbacks.version = GIT_REMOTE_CALLBACKS_VERSION;
typedef struct
{
COMMON_SETTINGS::GIT_REPOSITORY* repo;
bool success;
} callbacksPayload;
callbacksPayload cb_data( { &repository, true } ); // If we don't need authentication, then,
// we are successful
callbacks.payload = &cb_data;
callbacks.credentials =
[](git_cred** out, const char* url, const char* username, unsigned int allowed_types,
void* payload) -> int
{
// If we are asking for credentials, then, we need authentication
callbacksPayload* data = static_cast<callbacksPayload*>(payload);
data->success = false;
if( allowed_types & GIT_CREDTYPE_USERNAME )
{
data->success = true;
}
else if( data->repo->authType == "ssh" && ( allowed_types & GIT_CREDTYPE_SSH_KEY ) )
{
wxString sshKeyPath = data->repo->ssh_path;
// Check if the SSH key exists and is readable
if( wxFileExists( sshKeyPath ) && wxFile::Access( sshKeyPath, wxFile::read ) )
data->success = true;
}
else if( data->repo->authType == "password" )
{
data->success = ( allowed_types & GIT_CREDTYPE_USERPASS_PLAINTEXT );
}
return 0;
};
// Create a temporary directory to initialize the Git repository
wxString tempDirPath = wxFileName::CreateTempFileName(wxT("kigit_temp"));
if( !wxFileName::Mkdir( tempDirPath, wxS_DIR_DEFAULT ) )
{
git_libgit2_shutdown();
wxLogError( "Failed to create temporary directory for Git repository (%s): %s", tempDirPath,
wxSysErrorMsg() );
return false;
}
// Initialize the Git repository
git_repository* repo = nullptr;
const char* path = tempDirPath.mb_str( wxConvUTF8 );
if( git_repository_init( &repo, path, 0 ) != 0 )
{
git_libgit2_shutdown();
wxRmdir(tempDirPath);
return false;
}
KIGIT::GitRepositoryPtr repoPtr( repo );
git_remote* remote = nullptr;
if( git_remote_create_anonymous( &remote, repo, path ) != 0 )
{
git_libgit2_shutdown();
wxRmdir(tempDirPath);
return false;
}
KIGIT::GitRemotePtr remotePtr( remote );
// We don't really care about the result of this call, the authentication callback
// will set the return values we need
git_remote_connect( remote, GIT_DIRECTION_FETCH, &callbacks, nullptr, nullptr );
git_remote_disconnect( remote );
git_libgit2_shutdown();
// Clean up the temporary directory
wxRmdir(tempDirPath);
return cb_data.success;
}
bool PANEL_GIT_REPOS::TransferDataToWindow()
{
COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
std::pair<wxString, wxString> defaultAuthor = getDefaultAuthorAndEmail();
m_grid->ClearGrid();
for( COMMON_SETTINGS::GIT_REPOSITORY& repo : settings->m_Git.repositories )
{
if( repo.name.IsEmpty() || repo.path.IsEmpty() )
continue;
int row = m_grid->GetNumberRows();
m_grid->AppendRows( 1 );
m_grid->SetCellRenderer( row, COL_ACTIVE, new wxGridCellBoolRenderer() );
m_grid->SetCellEditor( row, COL_ACTIVE, new wxGridCellBoolEditor() );
m_grid->SetCellValue( row, COL_ACTIVE, repo.active ? "1" : "0" );
m_grid->SetCellValue( row, COL_NAME, repo.name );
m_grid->SetCellValue( row, COL_PATH, repo.path );
m_grid->SetCellValue( row, COL_AUTH_TYPE, repo.authType );
m_grid->SetCellValue( row, COL_USERNAME, repo.username );
wxString password;
KIPLATFORM::SECRETS::GetSecret( repo.path, repo.username, password );
m_grid->SetCellValue( row, COL_PASSWORD, password );
m_grid->SetCellValue( row, COL_SSH_PATH, repo.ssh_path );
if( repo.active )
m_grid->SetCellValue( row, 3, testRepositoryConnection( repo ) ? "C" : "NC" );
}
m_enableGit->SetValue( settings->m_Git.enableGit );
m_updateInterval->SetValue( settings->m_Git.updatInterval );
m_cbDefault->SetValue( settings->m_Git.useDefaultAuthor );
if( settings->m_Git.useDefaultAuthor )
{
std::pair<wxString, wxString> defaultAuthor = getDefaultAuthorAndEmail();
m_author->SetValue( defaultAuthor.first );
m_authorEmail->SetValue( defaultAuthor.second );
m_author->Disable();
m_authorEmail->Disable();
}
else
{
m_author->SetValue( settings->m_Git.authorName );
m_authorEmail->SetValue( settings->m_Git.authorEmail );
if( settings->m_Git.authorName.IsEmpty() )
m_author->SetValue( defaultAuthor.first );
else
m_author->SetValue( settings->m_Git.authorName );
if( settings->m_Git.authorEmail.IsEmpty() )
m_authorEmail->SetValue( defaultAuthor.second );
else
m_authorEmail->SetValue( settings->m_Git.authorEmail );
}
wxCommandEvent event;
onDefaultClick( event );
onEnableGitClick( event );
return true;
}
@ -286,115 +151,13 @@ void PANEL_GIT_REPOS::onDefaultClick( wxCommandEvent& event )
m_authorEmailLabel->Enable( !m_cbDefault->GetValue() );
}
void PANEL_GIT_REPOS::onGridDClick( wxGridEvent& event )
void PANEL_GIT_REPOS::onEnableGitClick( wxCommandEvent& aEvent )
{
if( m_grid->GetNumberRows() <= 0 )
{
wxCommandEvent evt;
onAddClick( evt );
return;
}
int row = event.GetRow();
if( row < 0 || row >= m_grid->GetNumberRows() )
return;
DIALOG_GIT_REPOSITORY dialog( this, nullptr );
dialog.SetRepoName( m_grid->GetCellValue( row, COL_NAME ) );
dialog.SetRepoURL( m_grid->GetCellValue( row, COL_PATH ) );
dialog.SetUsername( m_grid->GetCellValue( row, COL_USERNAME ) );
dialog.SetRepoSSHPath( m_grid->GetCellValue( row, COL_SSH_PATH ) );
dialog.SetPassword( m_grid->GetCellValue( row, COL_PASSWORD ) );
wxString type = m_grid->GetCellValue( row, COL_AUTH_TYPE );
if( type == "password" )
dialog.SetRepoType( KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_HTTPS );
else if( type == "ssh" )
dialog.SetRepoType( KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_SSH );
else
dialog.SetRepoType( KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_LOCAL);
if( dialog.ShowModal() == wxID_OK )
{
m_grid->SetCellValue( row, COL_NAME, dialog.GetRepoName() );
m_grid->SetCellValue( row, COL_PATH, dialog.GetRepoURL() );
m_grid->SetCellValue( row, COL_USERNAME, dialog.GetUsername() );
m_grid->SetCellValue( row, COL_SSH_PATH, dialog.GetRepoSSHPath() );
m_grid->SetCellValue( row, COL_PASSWORD, dialog.GetPassword() );
if( dialog.GetRepoType() == KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_HTTPS )
{
m_grid->SetCellValue( row, COL_AUTH_TYPE, "password" );
}
else if( dialog.GetRepoType() == KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_SSH )
{
m_grid->SetCellValue( row, COL_AUTH_TYPE, "ssh" );
}
else
{
m_grid->SetCellValue( row, COL_AUTH_TYPE, "none" );
}
}
}
void PANEL_GIT_REPOS::onAddClick( wxCommandEvent& event )
{
DIALOG_GIT_REPOSITORY dialog( m_parent, nullptr );
if( dialog.ShowModal() == wxID_OK )
{
int row = m_grid->GetNumberRows();
m_grid->AppendRows( 1 );
m_grid->SetCellValue( row, COL_NAME, dialog.GetRepoName() );
m_grid->SetCellValue( row, COL_PATH, dialog.GetRepoURL() );
m_grid->SetCellValue( row, COL_USERNAME, dialog.GetUsername() );
m_grid->SetCellValue( row, COL_SSH_PATH, dialog.GetRepoSSHPath() );
m_grid->SetCellValue( row, COL_PASSWORD, dialog.GetPassword() );
if( dialog.GetRepoType() == KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_HTTPS )
{
m_grid->SetCellValue( row, COL_AUTH_TYPE, "password" );
}
else if( dialog.GetRepoType() == KIGIT_COMMON::GIT_CONN_TYPE::GIT_CONN_SSH )
{
m_grid->SetCellValue( row, COL_AUTH_TYPE, "ssh" );
}
else
{
m_grid->SetCellValue( row, COL_AUTH_TYPE, "none" );
}
m_grid->MakeCellVisible( row, 0 );
}
}
void PANEL_GIT_REPOS::onEditClick( wxCommandEvent& event )
{
wxGridEvent evt( m_grid->GetId(), wxEVT_GRID_CELL_LEFT_DCLICK, m_grid,
m_grid->GetGridCursorRow(), m_grid->GetGridCursorCol() );
onGridDClick( evt );
}
void PANEL_GIT_REPOS::onDeleteClick( wxCommandEvent& event )
{
if( !m_grid->CommitPendingChanges() || m_grid->GetNumberRows() <= 0 )
return;
int curRow = m_grid->GetGridCursorRow();
m_grid->DeleteRows( curRow );
curRow = std::max( 0, curRow - 1 );
m_grid->MakeCellVisible( curRow, m_grid->GetGridCursorCol() );
m_grid->SetGridCursor( curRow, m_grid->GetGridCursorCol() );
bool enable = m_enableGit->GetValue();
m_updateInterval->Enable( enable );
m_cbDefault->Enable( enable );
m_author->Enable( enable && !m_cbDefault->GetValue() );
m_authorEmail->Enable( enable && !m_cbDefault->GetValue() );
m_authorLabel->Enable( enable && !m_cbDefault->GetValue() );
m_authorEmailLabel->Enable( enable && !m_cbDefault->GetValue() );
}

View File

@ -49,10 +49,7 @@ public:
private:
void onDefaultClick( wxCommandEvent& event ) override;
void onGridDClick( wxGridEvent& event ) override;
void onAddClick( wxCommandEvent& event ) override;
void onEditClick( wxCommandEvent& event ) override;
void onDeleteClick( wxCommandEvent& event ) override;
void onEnableGitClick( wxCommandEvent& event ) override;
};

View File

@ -1,13 +1,10 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-254-gc2ef7767)
// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6a-dirty)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "widgets/std_bitmap_button.h"
#include "widgets/wx_grid.h"
#include "panel_git_repos_base.h"
///////////////////////////////////////////////////////////////////////////
@ -20,9 +17,57 @@ PANEL_GIT_REPOS_BASE::PANEL_GIT_REPOS_BASE( wxWindow* parent, wxWindowID id, con
wxBoxSizer* bLeftSizer;
bLeftSizer = new wxBoxSizer( wxVERTICAL );
m_enableGit = new wxCheckBox( this, wxID_ANY, _("Enable Git Tracking"), wxDefaultPosition, wxDefaultSize, 0 );
bLeftSizer->Add( m_enableGit, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 13 );
m_gitSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizerUpdate;
bSizerUpdate = new wxBoxSizer( wxVERTICAL );
m_staticText6 = new wxStaticText( this, wxID_ANY, _("Remote Tracking"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText6->Wrap( -1 );
bSizerUpdate->Add( m_staticText6, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 13 );
m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerUpdate->Add( m_staticline2, 0, wxEXPAND | wxALL, 5 );
wxGridBagSizer* gbUpdate;
gbUpdate = new wxGridBagSizer( 4, 5 );
gbUpdate->SetFlexibleDirection( wxBOTH );
gbUpdate->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
gbUpdate->SetEmptyCellSize( wxSize( -1,2 ) );
m_updateLabel = new wxStaticText( this, wxID_ANY, _("Update interval:"), wxDefaultPosition, wxDefaultSize, 0 );
m_updateLabel->Wrap( -1 );
gbUpdate->Add( m_updateLabel, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
m_updateInterval = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 60, 5 );
m_updateInterval->SetToolTip( _("Number of minutes between remote update checks. Zero disables automatic checks.") );
gbUpdate->Add( m_updateInterval, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
m_staticText7 = new wxStaticText( this, wxID_ANY, _("minutes"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText7->Wrap( -1 );
gbUpdate->Add( m_staticText7, wxGBPosition( 0, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
gbUpdate->AddGrowableCol( 2 );
bSizerUpdate->Add( gbUpdate, 0, wxEXPAND|wxLEFT, 13 );
m_gitSizer->Add( bSizerUpdate, 0, wxEXPAND, 5 );
wxBoxSizer* bSizerCommitData;
bSizerCommitData = new wxBoxSizer( wxVERTICAL );
m_staticText12 = new wxStaticText( this, wxID_ANY, _("Git Commit Data"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText12->Wrap( -1 );
bLeftSizer->Add( m_staticText12, 0, wxEXPAND|wxLEFT|wxTOP, 10 );
bSizerCommitData->Add( m_staticText12, 0, wxEXPAND|wxLEFT|wxTOP, 13 );
m_staticline31 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerCommitData->Add( m_staticline31, 0, wxEXPAND | wxALL, 5 );
wxFlexGridSizer* fgSizer1;
fgSizer1 = new wxFlexGridSizer( 0, 2, 0, 0 );
@ -60,84 +105,13 @@ PANEL_GIT_REPOS_BASE::PANEL_GIT_REPOS_BASE( wxWindow* parent, wxWindowID id, con
fgSizer1->Add( m_authorEmail, 0, wxALL|wxEXPAND, 5 );
bLeftSizer->Add( fgSizer1, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 13 );
m_staticline3 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bLeftSizer->Add( m_staticline3, 0, wxEXPAND|wxBOTTOM, 5 );
m_staticText20 = new wxStaticText( this, wxID_ANY, _("Git Repositories"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText20->Wrap( -1 );
bLeftSizer->Add( m_staticText20, 0, wxEXPAND|wxLEFT|wxRIGHT, 13 );
wxBoxSizer* bAntialiasingSizer;
bAntialiasingSizer = new wxBoxSizer( wxVERTICAL );
m_grid = new WX_GRID( this, wxID_ANY, wxDefaultPosition, wxSize( 820,200 ), 0 );
// Grid
m_grid->CreateGrid( 0, 10 );
m_grid->EnableEditing( false );
m_grid->EnableGridLines( true );
m_grid->EnableDragGridSize( false );
m_grid->SetMargins( 0, 0 );
// Columns
m_grid->SetColSize( 0, 60 );
m_grid->SetColSize( 1, 200 );
m_grid->SetColSize( 2, 500 );
m_grid->SetColSize( 3, 60 );
m_grid->SetColSize( 4, 0 );
m_grid->SetColSize( 5, 0 );
m_grid->SetColSize( 6, 0 );
m_grid->SetColSize( 7, 0 );
m_grid->SetColSize( 8, 0 );
m_grid->SetColSize( 9, 0 );
m_grid->EnableDragColMove( false );
m_grid->EnableDragColSize( true );
m_grid->SetColLabelValue( 0, _("Active") );
m_grid->SetColLabelValue( 1, _("Name") );
m_grid->SetColLabelValue( 2, _("Path") );
m_grid->SetColLabelValue( 3, _("Status") );
m_grid->SetColLabelSize( 22 );
m_grid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
// Rows
m_grid->EnableDragRowSize( true );
m_grid->SetRowLabelSize( 0 );
m_grid->SetRowLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
// Label Appearance
// Cell Defaults
m_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
bAntialiasingSizer->Add( m_grid, 5, wxALL|wxEXPAND, 5 );
bSizerCommitData->Add( fgSizer1, 0, wxBOTTOM|wxEXPAND|wxLEFT, 8 );
bLeftSizer->Add( bAntialiasingSizer, 0, wxEXPAND|wxLEFT|wxTOP, 5 );
wxBoxSizer* bButtonsSizer;
bButtonsSizer = new wxBoxSizer( wxHORIZONTAL );
m_btnAddRepo = new STD_BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
m_btnAddRepo->SetToolTip( _("Add new repository") );
bButtonsSizer->Add( m_btnAddRepo, 0, wxALL, 5 );
m_btnEditRepo = new STD_BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
m_btnEditRepo->SetToolTip( _("Edit repository properties") );
bButtonsSizer->Add( m_btnEditRepo, 0, wxALL, 5 );
m_gitSizer->Add( bSizerCommitData, 1, wxEXPAND, 5 );
bButtonsSizer->Add( 0, 0, 1, wxEXPAND, 5 );
m_btnDelete = new STD_BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
m_btnDelete->SetToolTip( _("Remove Git Repository") );
bButtonsSizer->Add( m_btnDelete, 0, wxBOTTOM|wxRIGHT|wxTOP, 5 );
bLeftSizer->Add( bButtonsSizer, 1, wxALL|wxEXPAND, 5 );
bLeftSizer->Add( m_gitSizer, 0, wxEXPAND, 0 );
bPanelSizer->Add( bLeftSizer, 0, wxRIGHT, 20 );
@ -148,20 +122,14 @@ PANEL_GIT_REPOS_BASE::PANEL_GIT_REPOS_BASE( wxWindow* parent, wxWindowID id, con
bPanelSizer->Fit( this );
// Connect Events
m_enableGit->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_GIT_REPOS_BASE::onEnableGitClick ), NULL, this );
m_cbDefault->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_GIT_REPOS_BASE::onDefaultClick ), NULL, this );
m_grid->Connect( wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEventHandler( PANEL_GIT_REPOS_BASE::onGridDClick ), NULL, this );
m_btnAddRepo->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_GIT_REPOS_BASE::onAddClick ), NULL, this );
m_btnEditRepo->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_GIT_REPOS_BASE::onEditClick ), NULL, this );
m_btnDelete->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_GIT_REPOS_BASE::onDeleteClick ), NULL, this );
}
PANEL_GIT_REPOS_BASE::~PANEL_GIT_REPOS_BASE()
{
// Disconnect Events
m_enableGit->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_GIT_REPOS_BASE::onEnableGitClick ), NULL, this );
m_cbDefault->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_GIT_REPOS_BASE::onDefaultClick ), NULL, this );
m_grid->Disconnect( wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEventHandler( PANEL_GIT_REPOS_BASE::onGridDClick ), NULL, this );
m_btnAddRepo->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_GIT_REPOS_BASE::onAddClick ), NULL, this );
m_btnEditRepo->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_GIT_REPOS_BASE::onEditClick ), NULL, this );
m_btnDelete->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_GIT_REPOS_BASE::onDeleteClick ), NULL, this );
}

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-254-gc2ef7767)
// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6a-dirty)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -10,26 +10,19 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class STD_BITMAP_BUTTON;
class WX_GRID;
#include "widgets/resettable_panel.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/checkbox.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/checkbox.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/stattext.h>
#include <wx/statline.h>
#include <wx/grid.h>
#include <wx/bmpbuttn.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/button.h>
#include <wx/spinctrl.h>
#include <wx/gbsizer.h>
#include <wx/sizer.h>
#include <wx/textctrl.h>
#include <wx/panel.h>
///////////////////////////////////////////////////////////////////////////
@ -42,25 +35,24 @@ class PANEL_GIT_REPOS_BASE : public RESETTABLE_PANEL
private:
protected:
wxCheckBox* m_enableGit;
wxBoxSizer* m_gitSizer;
wxStaticText* m_staticText6;
wxStaticLine* m_staticline2;
wxStaticText* m_updateLabel;
wxSpinCtrl* m_updateInterval;
wxStaticText* m_staticText7;
wxStaticText* m_staticText12;
wxStaticLine* m_staticline31;
wxCheckBox* m_cbDefault;
wxStaticText* m_authorLabel;
wxTextCtrl* m_author;
wxStaticText* m_authorEmailLabel;
wxTextCtrl* m_authorEmail;
wxStaticLine* m_staticline3;
wxStaticText* m_staticText20;
WX_GRID* m_grid;
STD_BITMAP_BUTTON* m_btnAddRepo;
STD_BITMAP_BUTTON* m_btnEditRepo;
STD_BITMAP_BUTTON* m_btnDelete;
// Virtual event handlers, override them in your derived class
virtual void onEnableGitClick( wxCommandEvent& event ) { event.Skip(); }
virtual void onDefaultClick( wxCommandEvent& event ) { event.Skip(); }
virtual void onGridDClick( wxGridEvent& event ) { event.Skip(); }
virtual void onAddClick( wxCommandEvent& event ) { event.Skip(); }
virtual void onEditClick( wxCommandEvent& event ) { event.Skip(); }
virtual void onDeleteClick( wxCommandEvent& event ) { event.Skip(); }
public:

File diff suppressed because it is too large Load Diff

View File

@ -1253,16 +1253,11 @@ void EDA_BASE_FRAME::ShowPreferences( wxString aStartPage, wxString aStartParent
book->AddPage( hotkeysPanel, _( "Hotkeys" ) );
// This currently allows pre-defined repositories that we
// don't use, so keep it disabled at the moment
if( ADVANCED_CFG::GetCfg().m_EnableGit && false )
{
book->AddLazyPage(
[]( wxWindow* aParent ) -> wxWindow*
{
return new PANEL_GIT_REPOS( aParent );
}, _( "Version Control" ) );
}
book->AddLazyPage(
[]( wxWindow* aParent ) -> wxWindow*
{
return new PANEL_GIT_REPOS( aParent );
}, _( "Version Control" ) );
#ifdef KICAD_USE_SENTRY
book->AddLazyPage(

View File

@ -419,6 +419,12 @@ COMMON_SETTINGS::COMMON_SETTINGS() :
m_params.emplace_back( new PARAM<bool>( "git.useDefaultAuthor",
&m_Git.useDefaultAuthor, true ) );
m_params.emplace_back( new PARAM<bool>( "git.enableGit",
&m_Git.enableGit, true ) );
m_params.emplace_back( new PARAM<int>( "git.updatInterval",
&m_Git.updatInterval, 5 ) );
m_params.emplace_back( new PARAM<wxString>( "api.interpreter_path",
&m_Api.python_interpreter, wxS( "" ) ) );

View File

@ -488,15 +488,6 @@ public:
*/
bool m_EnableGenerators;
/**
* Enable git integration.
*
* Setting name: "EnableGit"
* Valid values: 0 or 1
* Default value: 0
*/
bool m_EnableGit;
/**
* Enable option to load lib files with text editor.
*
@ -748,15 +739,6 @@ public:
*/
int m_GitIconRefreshInterval;
/**
* The interval in milliseconds to refresh the project status by performing
* a git fetch on the remote project. Set to 0 to disable.
*
* Setting name: "GitProjectStatusRefreshInterval"
* Default value: 60000
*/
int m_GitProjectStatusRefreshInterval;
/**
* Enable the UI to configure toolbars.
*

View File

@ -166,6 +166,8 @@ public:
struct GIT
{
std::vector<GIT_REPOSITORY> repositories;
bool enableGit;
int updatInterval;
bool useDefaultAuthor;
wxString authorName;
wxString authorEmail;

View File

@ -1014,6 +1014,8 @@ void KICAD_MANAGER_FRAME::CommonSettingsChanged( int aFlags )
onToolbarSizeChanged();
m_lastToolbarIconSize = settings->m_Appearance.toolbar_icon_size;
}
m_leftWin->ReCreateTreePrj();
}

View File

@ -76,7 +76,7 @@ void KICAD_MANAGER_FRAME::doReCreateMenuBar()
fileMenu->Add( KICAD_MANAGER_ACTIONS::newProject );
fileMenu->Add( KICAD_MANAGER_ACTIONS::newFromTemplate );
if( ADVANCED_CFG::GetCfg().m_EnableGit )
if( Pgm().GetCommonSettings()->m_Git.enableGit )
{
fileMenu->Add( KICAD_MANAGER_ACTIONS::newFromRepository );
}

View File

@ -660,7 +660,7 @@ void PROJECT_TREE_PANE::ReCreateTreePrj()
bool prjOpened = fn.FileExists();
// Bind the git repository to the project tree (if it exists)
if( ADVANCED_CFG::GetCfg().m_EnableGit )
if( Pgm().GetCommonSettings()->m_Git.enableGit )
{
m_TreeProject->SetGitRepo( get_git_repository_for_file( fn.GetPath().c_str() ) );
@ -801,7 +801,7 @@ void PROJECT_TREE_PANE::onRight( wxTreeEvent& Event )
bool vcs_can_push = vcs_can_fetch && git->HasLocalCommits();
bool vcs_can_pull = vcs_can_fetch;
bool vcs_can_switch = vcs_has_repo;
bool vcs_menu = ADVANCED_CFG::GetCfg().m_EnableGit;
bool vcs_menu = Pgm().GetCommonSettings()->m_Git.enableGit;
// Check if the libgit2 library has been successfully initialized
#if ( LIBGIT2_VER_MAJOR >= 1 ) || ( LIBGIT2_VER_MINOR >= 99 )
@ -1975,7 +1975,7 @@ void PROJECT_TREE_PANE::updateGitStatusIcons()
return;
}
if( ADVANCED_CFG::GetCfg().m_EnableGit == false || !m_TreeProject )
if( !Pgm().GetCommonSettings()->m_Git.enableGit || !m_TreeProject )
{
wxLogTrace( traceGit, wxS( "updateGitStatusIcons: Git is disabled or tree control is null" ) );
return;
@ -2068,7 +2068,7 @@ void PROJECT_TREE_PANE::updateGitStatusIconMap()
#endif
if( ADVANCED_CFG::GetCfg().m_EnableGit == false || !m_TreeProject )
if( !Pgm().GetCommonSettings()->m_Git.enableGit || !m_TreeProject )
return;
std::unique_lock<std::mutex> lock1( m_gitStatusMutex, std::try_to_lock );
@ -2662,7 +2662,9 @@ void PROJECT_TREE_PANE::onRunSelectedJobsFile(wxCommandEvent& event)
void PROJECT_TREE_PANE::onGitSyncTimer( wxTimerEvent& aEvent )
{
wxLogTrace( traceGit, "onGitSyncTimer" );
if( ADVANCED_CFG::GetCfg().m_EnableGit == false || !m_TreeProject )
COMMON_SETTINGS::GIT& gitSettings = Pgm().GetCommonSettings()->m_Git;
if( !gitSettings.enableGit || !m_TreeProject )
return;
thread_pool& tp = GetKiCadThreadPool();
@ -2686,11 +2688,11 @@ void PROJECT_TREE_PANE::onGitSyncTimer( wxTimerEvent& aEvent )
} );
} );
if( ADVANCED_CFG::GetCfg().m_GitProjectStatusRefreshInterval > 0 )
if( gitSettings.updatInterval > 0 )
{
wxLogTrace( traceGit, "onGitSyncTimer: Restarting git sync timer" );
m_gitSyncTimer.Start( ADVANCED_CFG::GetCfg().m_GitProjectStatusRefreshInterval,
wxTIMER_ONE_SHOT );
// We store the timer interval in minutes but wxTimer uses milliseconds
m_gitSyncTimer.Start( gitSettings.updatInterval * 60 * 1000, wxTIMER_ONE_SHOT );
}
}
@ -2710,7 +2712,7 @@ void PROJECT_TREE_PANE::gitStatusTimerHandler()
void PROJECT_TREE_PANE::onGitStatusTimer( wxTimerEvent& aEvent )
{
wxLogTrace( traceGit, "onGitStatusTimer" );
if( ADVANCED_CFG::GetCfg().m_EnableGit == false || !m_TreeProject )
if( !Pgm().GetCommonSettings()->m_Git.enableGit || !m_TreeProject )
return;
gitStatusTimerHandler();