Skip to content

Commit

Permalink
Add ignore files button
Browse files Browse the repository at this point in the history
  • Loading branch information
Blake-Madden committed Sep 4, 2024
1 parent c8f985f commit 54a4a5e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
50 changes: 46 additions & 4 deletions src/gui/projectdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ NewProjectDialog::NewProjectDialog(
NewProjectDialog::ID_FOLDER_BROWSE_BUTTON);
Bind(wxEVT_BUTTON, &NewProjectDialog::OnExcludedFolderButtonClick, this,
NewProjectDialog::ID_EXCLUDED_FOLDERS_BROWSE_BUTTON);
Bind(wxEVT_BUTTON, &NewProjectDialog::OnExcludedFileButtonClick, this,
NewProjectDialog::ID_EXCLUDED_FILES_BROWSE_BUTTON);
Bind(wxEVT_BUTTON, &NewProjectDialog::OnOK, this, wxID_OK);
}

Expand Down Expand Up @@ -176,7 +178,7 @@ void NewProjectDialog::OnOK([[maybe_unused]] wxCommandEvent&)
void NewProjectDialog::OnFolderButtonClick([[maybe_unused]] wxCommandEvent&)
{
TransferDataFromWindow();
wxDirDialog dirDlg(this);
wxDirDialog dirDlg(this, _(L"Select Folder to Analyze"));
dirDlg.SetPath(m_filePath);
if (dirDlg.ShowModal() != wxID_OK)
{
Expand All @@ -191,7 +193,7 @@ void NewProjectDialog::OnFolderButtonClick([[maybe_unused]] wxCommandEvent&)
void NewProjectDialog::OnExcludedFolderButtonClick([[maybe_unused]] wxCommandEvent&)
{
TransferDataFromWindow();
wxDirDialog dirDlg(this);
wxDirDialog dirDlg(this, _(L"Select Subfolders to Ignore"));
if (dirDlg.ShowModal() != wxID_OK)
{
return;
Expand All @@ -208,6 +210,41 @@ void NewProjectDialog::OnExcludedFolderButtonClick([[maybe_unused]] wxCommandEve
SetFocus();
}

//-------------------------------------------------------------
void NewProjectDialog::OnExcludedFileButtonClick([[maybe_unused]] wxCommandEvent&)
{
TransferDataFromWindow();
wxFileDialog dialog(this, _(L"Select Files to Ignore"), wxString{}, wxString{},
_(L"All Files (*.*)|*.*"),
wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST | wxFD_PREVIEW);
if (dialog.ShowModal() != wxID_OK)
{
return;
}

wxArrayString paths;
dialog.GetPaths(paths);
wxString allPaths;
for (const auto& path : paths)
{
allPaths += L"; " + path;
}
if (m_excludedPaths.empty())
{
if (allPaths.length() > 2)
{
allPaths.erase(0, 2);
}
m_excludedPaths = allPaths;
}
else
{
m_excludedPaths += allPaths;
}
TransferDataToWindow();
SetFocus();
}

//-------------------------------------------------------------
void NewProjectDialog::CreateControls()
{
Expand Down Expand Up @@ -245,13 +282,13 @@ void NewProjectDialog::CreateControls()

{
wxStaticBoxSizer* fileBrowseBoxSizer =
new wxStaticBoxSizer(wxHORIZONTAL, generalSettingsPage, _(L"Subfolders to ignore"));
new wxStaticBoxSizer(wxHORIZONTAL, generalSettingsPage, _(L"Subfolders/files to ignore"));

mainSizer->Add(fileBrowseBoxSizer, wxSizerFlags{ 1 }.Expand().Border());

wxTextCtrl* filePathEdit =
new wxTextCtrl(fileBrowseBoxSizer->GetStaticBox(), wxID_ANY, wxString{},
wxDefaultPosition, wxSize(FromDIP(500), FromDIP(40)),
wxDefaultPosition, wxSize(FromDIP(500), FromDIP(60)),
wxTE_RICH2 | wxTE_MULTILINE | wxBORDER_THEME | wxTE_BESTWRAP,
wxGenericValidator(&m_excludedPaths));
filePathEdit->AutoCompleteFileNames();
Expand All @@ -262,6 +299,11 @@ void NewProjectDialog::CreateControls()
fileBrowseBoxSizer->GetStaticBox(), ID_EXCLUDED_FOLDERS_BROWSE_BUTTON,
wxArtProvider::GetBitmapBundle(wxART_FOLDER_OPEN, wxART_BUTTON));
fileBrowseBoxSizer->Add(folderBrowseButton, wxSizerFlags{}.CenterVertical());

wxBitmapButton* fileBrowseButton = new wxBitmapButton(
fileBrowseBoxSizer->GetStaticBox(), ID_EXCLUDED_FILES_BROWSE_BUTTON,
wxArtProvider::GetBitmapBundle(wxART_FILE_OPEN, wxART_BUTTON));
fileBrowseBoxSizer->Add(fileBrowseButton, wxSizerFlags{}.CenterVertical());
}

mainSizer->Add(
Expand Down
2 changes: 2 additions & 0 deletions src/gui/projectdlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,12 @@ class NewProjectDialog final : public wxDialog
void CreateControls();
void OnFolderButtonClick([[maybe_unused]] wxCommandEvent&);
void OnExcludedFolderButtonClick([[maybe_unused]] wxCommandEvent&);
void OnExcludedFileButtonClick([[maybe_unused]] wxCommandEvent&);
void OnOK([[maybe_unused]] wxCommandEvent&);

constexpr static int ID_FOLDER_BROWSE_BUTTON = wxID_HIGHEST;
constexpr static int ID_EXCLUDED_FOLDERS_BROWSE_BUTTON = ID_FOLDER_BROWSE_BUTTON + 1;
constexpr static int ID_EXCLUDED_FILES_BROWSE_BUTTON = ID_EXCLUDED_FOLDERS_BROWSE_BUTTON + 1;
wxString m_filePath;
wxString m_excludedPaths;
// options for all file types
Expand Down

0 comments on commit 54a4a5e

Please sign in to comment.