Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify the "File Filters" dialog. #2118

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 28 additions & 11 deletions Src/FileFiltersDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ BOOL FileFiltersDlg::OnInitDialog()
}
}

SetButtonState();

return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
Expand Down Expand Up @@ -282,25 +284,18 @@ bool FileFiltersDlg::IsFilterItemNone(int item) const
/**
* @brief Called when item state is changed.
*
* Disable Edit-button when "None" filter is selected.
* Disable the "Test", "Edit" and "Remove" buttons when no item is selected or "None" filter is selected.
* @param [in] pNMHDR Listview item data.
* @param [out] pResult Result of the action is returned in here.
*/
void FileFiltersDlg::OnLvnItemchangedFilterfileList(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);

// If item got selected
if (pNMLV->uNewState & LVIS_SELECTED)
// If item got selected or deselected
if ((pNMLV->uNewState & LVIS_SELECTED) || (pNMLV->uOldState & LVIS_SELECTED))
{
String txtNone = _("<None>");
String txt = m_listFilters.GetItemText(pNMLV->iItem, 0);

bool isNone = strutils::compare_nocase(txt, txtNone) == 0;

EnableDlgItem(IDC_FILTERFILE_TEST_BTN, !isNone);
EnableDlgItem(IDC_FILTERFILE_EDITBTN, !isNone);
EnableDlgItem(IDC_FILTERFILE_DELETEBTN, !isNone);
SetButtonState();
}
*pResult = 0;
}
Expand Down Expand Up @@ -525,6 +520,7 @@ void FileFiltersDlg::OnBnClickedFilterfileDelete()
}
}
}
SetButtonState();
}

/**
Expand Down Expand Up @@ -609,3 +605,24 @@ void FileFiltersDlg::OnBnClickedFilterfileInstall()
}
}
}

/**
* @brief Disable the "Test", "Edit" and "Remove" buttons when no item is selected or "None" filter is selected.
*/
void FileFiltersDlg::SetButtonState()
{
bool isNone = true;

int sel = -1;
sel = m_listFilters.GetNextItem(sel, LVNI_SELECTED);
if (sel != -1)
{
String txtNone = _("<None>");
String txt = m_listFilters.GetItemText(sel, 0);
isNone = strutils::compare_nocase(txt, txtNone) == 0;
}

EnableDlgItem(IDC_FILTERFILE_TEST_BTN, !isNone);
EnableDlgItem(IDC_FILTERFILE_EDITBTN, !isNone);
EnableDlgItem(IDC_FILTERFILE_DELETEBTN, !isNone);
}
3 changes: 3 additions & 0 deletions Src/FileFiltersDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,7 @@ class FileFiltersDlg : public CTrPropertyPage
afx_msg void OnBnClickedFilterfileInstall();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()

private:
void SetButtonState();
};
Loading