From 8ab4d25e3331388576bd09b972fff0ed95b19063 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sat, 5 Feb 2022 22:35:42 +0100 Subject: [PATCH] ux: Only show file chooser popup when there's files in the the relevant folder --- lib/libimhex/source/ui/view.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/libimhex/source/ui/view.cpp b/lib/libimhex/source/ui/view.cpp index f6bc923a8..c9152e9fe 100644 --- a/lib/libimhex/source/ui/view.cpp +++ b/lib/libimhex/source/ui/view.cpp @@ -118,12 +118,18 @@ namespace hex { } void View::showFileChooserPopup(const std::vector &paths, const std::vector &validExtensions, const std::function &callback) { - View::s_selectableFileIndex = 0; - View::s_selectableFiles = paths; - View::s_selectableFilesValidExtensions = validExtensions; - View::s_selectableFileOpenCallback = 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_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 {