KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_git_repository.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
21
22#include <memory>
23
26#include <eda_base_frame.h>
28#include <pgm_base.h>
29#include <project.h>
31#include <wx/utils.h>
32
33
36 m_dialog( aDialog ),
37 m_frame( aFrame )
38{
39 m_repoUserName->SetEditable( false );
40 m_repoUserEmail->SetEditable( false );
41 m_identityNote->SetLabel( _( "Edits apply to this repository only." ) );
42 m_saveButton->SetLabel( _( "Edit Author..." ) );
43 m_saveButton->Bind( wxEVT_BUTTON,
44 [this]( wxCommandEvent& )
45 {
47 } );
48}
49
50
52{
53 if( !m_dialog->SessionStillCurrent() )
54 return;
55
56 auto identity = std::make_shared<KIGIT::GIT_IDENTITY>();
57
58 m_configQuery.Run(
59 m_frame->Prj().GetGitCommon(),
60 [identity]( KIGIT_COMMON& aCommon )
61 {
62 *identity = KIGIT::ReadGitIdentity( aCommon );
63 },
64 [this, identity]()
65 {
66 if( !m_dialog->SessionStillCurrent() )
67 return;
68
69 GitUserConfig config =
70 KIGIT::ResolveGitIdentity( *identity, Pgm().GetCommonSettings()->m_Git, wxGetUserName() );
71 m_repoUserName->ChangeValue( config.authorName );
72 m_repoUserEmail->ChangeValue( config.authorEmail );
73 } );
74}
75
76
78{
79 if( !m_dialog->SessionStillCurrent() )
80 return;
81
82 std::shared_ptr<KIGIT_COMMON> common = m_frame->Prj().GetGitCommon();
83 auto identity = std::make_shared<KIGIT::GIT_IDENTITY>();
84 m_saveButton->Disable();
85
86 m_editQuery.Run(
87 common,
88 [identity]( KIGIT_COMMON& aCommon )
89 {
90 *identity = KIGIT::ReadGitIdentity( aCommon );
91 },
92 [this, common, identity]()
93 {
94 m_saveButton->Enable();
95
96 if( m_dialog->SessionStillCurrent() )
97 KIGIT::EditGitIdentity( this, m_frame, common, *identity );
98 } );
99}
The base frame for deriving all KiCad main window classes.
The advanced Git window: a non-modal dialog with a top bar naming the repository and branch and a sid...
The project's git session.
PANEL_GIT_REPOSITORY_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
void Populate()
Read the repository identity on a worker and update the display.
GIT_ADVANCED_DIALOG * m_dialog
PANEL_GIT_REPOSITORY(wxWindow *aParent, GIT_ADVANCED_DIALOG *aDialog, EDA_BASE_FRAME *aFrame)
#define _(s)
Base window classes and related definitions.
GIT_IDENTITY ReadGitIdentity(KIGIT_COMMON &aCommon)
Read on a worker while holding the session's action lock.
bool EditGitIdentity(wxWindow *aParent, EDA_BASE_FRAME *aFrame, const std::shared_ptr< KIGIT_COMMON > &aCommon, const GIT_IDENTITY &aIdentity)
Edit the repository's author and refresh Git views after saving.
see class PGM_BASE