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 else if( status & ( GIT_STATUS_INDEX_MODIFIED | GIT_STATUS_WT_MODIFIED ) )
109 else if( status & ( GIT_STATUS_INDEX_DELETED | GIT_STATUS_WT_DELETED ) )
117 printf(
" Unknown status: %d\n", status );
121 sizer->Add(
m_listCtrl, 1, wxEXPAND | wxALL, 5 );
124 wxStaticText* commitMessageLabel =
new wxStaticText(
this, wxID_ANY,
_(
"Commit Message:" ) );
126 new wxTextCtrl(
this, wxID_ANY,
"", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
127 sizer->Add( commitMessageLabel, 0, wxALL, 5 );
131 wxStaticText* authorLabel =
new wxStaticText(
this, wxID_ANY,
_(
"Author:" ) );
132 wxString defaultAuthor = defaultAuthorName +
" <" + defaultAuthorEmail +
">";
134 new wxTextCtrl(
this, wxID_ANY, defaultAuthor, wxDefaultPosition, wxDefaultSize, 0 );
135 sizer->Add( authorLabel, 0, wxALL, 5 );
140 wxStdDialogButtonSizer* buttonSizer =
new wxStdDialogButtonSizer();
142 m_okButton =
new wxButton(
this, wxID_OK,
_(
"OK" ) );
143 wxButton* cancelButton =
new wxButton(
this, wxID_CANCEL,
_(
"Cancel" ) );
144 buttonSizer->Add( cancelButton, 0, wxALL, 5 );
146 buttonSizer->Realize();
148 sizer->Add( buttonSizer, 0, wxALIGN_RIGHT | wxALL, 5 );
150 SetSizerAndFit( sizer );
169 m_okButton->SetToolTip(
_(
"Commit message cannot be empty" ) );
188 size_t pos = authorText.find(
'<' );
190 if( pos != wxString::npos )
191 return authorText.substr( 0, pos ).Trim();
193 return wxEmptyString;
200 size_t startPos = authorText.find(
'<' );
201 size_t endPos = authorText.find(
'>' );
203 if( startPos != wxString::npos && endPos != wxString::npos && startPos < endPos )
204 return authorText.substr( startPos + 1, endPos - startPos - 1 ).Trim();
206 return wxEmptyString;
212 std::vector<wxString> selectedFiles;
215 while( ( item =
m_listCtrl->GetNextItem( item, wxLIST_NEXT_ALL ) )
219 selectedFiles.push_back(
m_listCtrl->GetItemText( item ) );
222 return selectedFiles;
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
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={})