31#include <wx/checkbox.h>
32#include <wx/listctrl.h>
34#include <wx/stattext.h>
35#include <wx/textctrl.h>
38 const wxString& defaultAuthorName,
39 const wxString& defaultAuthorEmail,
40 const std::map<wxString, int>& filesToCommit ) :
43 wxBoxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
47 m_listCtrl =
new wxListCtrl(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
48 wxLC_REPORT | wxLC_SINGLE_SEL );
62 wxVector<wxBitmapBundle> stateImages;
63 stateImages.push_back( wxBitmapBundle() );
64 stateImages.push_back(
KiBitmapBundle( BITMAPS::git_good_check ) );
68 stateImages.push_back(
KiBitmapBundle( BITMAPS::git_out_of_date ) );
69 stateImages.push_back(
KiBitmapBundle( BITMAPS::git_changed_ahead ) );
75 wxImageList* imageList =
new wxImageList(
78 imageList->Add(
KiBitmap( BITMAPS::git_good_check ) );
79 imageList->Add(
KiBitmap( BITMAPS::git_good_check ) );
80 imageList->Add(
KiBitmap( BITMAPS::git_modified ) );
81 imageList->Add(
KiBitmap( BITMAPS::git_add ) );
82 imageList->Add(
KiBitmap( BITMAPS::git_delete ) );
83 imageList->Add(
KiBitmap( BITMAPS::git_out_of_date ) );
84 imageList->Add(
KiBitmap( BITMAPS::git_changed_ahead ) );
85 imageList->Add(
KiBitmap( BITMAPS::git_conflict ) );
88 m_listCtrl->SetImageList( imageList, wxIMAGE_LIST_SMALL );
92 for(
auto& [filename, status] : filesToCommit )
97 if( status & ( GIT_STATUS_INDEX_NEW | GIT_STATUS_WT_NEW ) )
103 if( status & ( GIT_STATUS_INDEX_NEW ) )
106 else if( status & ( GIT_STATUS_INDEX_MODIFIED | GIT_STATUS_WT_MODIFIED ) )
112 if( status & ( GIT_STATUS_INDEX_MODIFIED ) )
115 else if( status & ( GIT_STATUS_INDEX_DELETED | GIT_STATUS_WT_DELETED ) )
121 if( status & ( GIT_STATUS_INDEX_DELETED ) )
126 printf(
" Unknown status: %d\n", status );
130 sizer->Add(
m_listCtrl, 1, wxEXPAND | wxALL, 5 );
133 wxStaticText* commitMessageLabel =
new wxStaticText(
this, wxID_ANY,
_(
"Commit Message:" ) );
135 new wxTextCtrl(
this, wxID_ANY,
"", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
136 sizer->Add( commitMessageLabel, 0, wxALL, 5 );
140 wxStaticText* authorLabel =
new wxStaticText(
this, wxID_ANY,
_(
"Author:" ) );
141 wxString defaultAuthor = defaultAuthorName +
" <" + defaultAuthorEmail +
">";
143 new wxTextCtrl(
this, wxID_ANY, defaultAuthor, wxDefaultPosition, wxDefaultSize, 0 );
144 sizer->Add( authorLabel, 0, wxALL, 5 );
149 wxStdDialogButtonSizer* buttonSizer =
new wxStdDialogButtonSizer();
151 m_okButton =
new wxButton(
this, wxID_OK,
_(
"OK" ) );
152 wxButton* cancelButton =
new wxButton(
this, wxID_CANCEL,
_(
"Cancel" ) );
153 buttonSizer->Add( cancelButton, 0, wxALL, 5 );
155 buttonSizer->Realize();
157 sizer->Add( buttonSizer, 0, wxALIGN_RIGHT | wxALL, 5 );
159 SetSizerAndFit( sizer );
178 m_okButton->SetToolTip(
_(
"Commit message cannot be empty" ) );
197 size_t pos = authorText.find(
'<' );
199 if( pos != wxString::npos )
200 return authorText.substr( 0, pos ).Trim();
202 return wxEmptyString;
209 size_t startPos = authorText.find(
'<' );
210 size_t endPos = authorText.find(
'>' );
212 if( startPos != wxString::npos && endPos != wxString::npos && startPos < endPos )
213 return authorText.substr( startPos + 1, endPos - startPos - 1 ).Trim();
215 return wxEmptyString;
221 std::vector<wxString> selectedFiles;
224 while( ( item =
m_listCtrl->GetNextItem( item, wxLIST_NEXT_ALL ) )
228 selectedFiles.push_back(
m_listCtrl->GetItemText( item ) );
231 return selectedFiles;
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
wxTextCtrl * m_commitMessageTextCtrl
void OnTextChanged(wxCommandEvent &event)
wxString GetCommitMessage() const
wxTextCtrl * m_authorTextCtrl
DIALOG_GIT_COMMIT(wxWindow *parent, git_repository *repo, const wxString &defaultAuthorName, const wxString &defaultAuthorEmail, const std::map< wxString, int > &filesToCommit)
wxString GetAuthorEmail() const
std::vector< wxString > GetSelectedFiles() const
wxString m_defaultAuthorEmail
wxString GetAuthorName() const
wxString m_defaultAuthorName
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
void SetupStandardButtons(std::map< int, wxString > aLabels={})