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,6 +118,11 @@ 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) {
if (paths.empty()) {
hex::openFileBrowser("hex.builtin.common.open"_lang, DialogMode::Open, validExtensions, [callback](const auto &path) {
callback(path);
});
} else {
View::s_selectableFileIndex = 0; View::s_selectableFileIndex = 0;
View::s_selectableFiles = paths; View::s_selectableFiles = paths;
View::s_selectableFilesValidExtensions = validExtensions; View::s_selectableFilesValidExtensions = validExtensions;
@ -125,6 +130,7 @@ namespace hex {
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 {
return true; return true;