* @brief Load any known file filters * @todo Preserve filter selection? How? */
| 690 | * @todo Preserve filter selection? How? |
| 691 | */ |
| 692 | void FileFilterHelper::LoadAllFileFilters() |
| 693 | { |
| 694 | // First delete existing filters |
| 695 | m_fileFilterMgr->DeleteAllFilters(); |
| 696 | |
| 697 | std::vector<String> folders; |
| 698 | auto addUnique = [&](const String& path) |
| 699 | { |
| 700 | if (path.empty()) |
| 701 | return; |
| 702 | for (const auto& f : folders) |
| 703 | { |
| 704 | if (strutils::compare_nocase(f, path) == 0) |
| 705 | return; |
| 706 | } |
| 707 | folders.push_back(path); |
| 708 | }; |
| 709 | // Program application directory |
| 710 | m_sGlobalFilterPath = paths::ConcatPath(env::GetProgPath(), _T("Filters")); |
| 711 | addUnique(m_sGlobalFilterPath); |
| 712 | addUnique(paths::ConcatPath(env::GetAppDataPath(), _T("WinMerge\\Filters"))); |
| 713 | addUnique(paths::ConcatPath(env::GetMyDocuments(), _T("WinMerge\\Filters"))); |
| 714 | if (!m_sUserSelFilterPath.empty()) |
| 715 | addUnique(m_sUserSelFilterPath); |
| 716 | |
| 717 | String pattern(_T("*")); |
| 718 | pattern += FileFilterExt; |
| 719 | |
| 720 | for (const auto& folder : folders) |
| 721 | LoadFileFilterDirPattern(folder, pattern); |
| 722 | } |
| 723 | |
| 724 | /** |
| 725 | * @brief Return path to global filters (& create if needed), or empty if cannot create |