ux: Only show file chooser popup when there's files in the the relevant folder

This commit is contained in:
WerWolv 2022-02-05 22:35:42 +01:00
parent eade95dff7
commit 8ab4d25e33
1 changed files with 11 additions and 5 deletions

View File

@ -118,12 +118,18 @@ namespace hex {
} }
void View::showFileChooserPopup(const std::vector<fs::path> &paths, const std::vector<nfdfilteritem_t> &validExtensions, const std::function<void(fs::path)> &callback) { void View::showFileChooserPopup(const std::vector<fs::path> &paths, const std::vector<nfdfilteritem_t> &validExtensions, const std::function<void(fs::path)> &callback) {
View::s_selectableFileIndex = 0; if (paths.empty()) {
View::s_selectableFiles = paths; hex::openFileBrowser("hex.builtin.common.open"_lang, DialogMode::Open, validExtensions, [callback](const auto &path) {
View::s_selectableFilesValidExtensions = validExtensions; callback(path);
View::s_selectableFileOpenCallback = callback; });
} else {
View::s_selectableFileIndex = 0;
View::s_selectableFiles = paths;
View::s_selectableFilesValidExtensions = validExtensions;
View::s_selectableFileOpenCallback = callback;
ImHexApi::Tasks::doLater([] { ImGui::OpenPopup("hex.builtin.common.choose_file"_lang); }); ImHexApi::Tasks::doLater([] { ImGui::OpenPopup("hex.builtin.common.choose_file"_lang); });
}
} }
bool View::hasViewMenuItemEntry() const { bool View::hasViewMenuItemEntry() const {