| 646 | } |
| 647 | |
| 648 | void saveFileDialogAsync( std::function<void( const std::filesystem::path& )> callback, const FileParameters& params /*= {} */ ) |
| 649 | { |
| 650 | assert( callback ); |
| 651 | #ifndef __EMSCRIPTEN__ |
| 652 | callback( saveFileDialog( params ) ); |
| 653 | #else |
| 654 | sDialogFilesCallback = [callback] ( const std::vector<std::filesystem::path>& paths ) |
| 655 | { |
| 656 | if ( !paths.empty() ) |
| 657 | { |
| 658 | if ( !paths[0].empty() ) |
| 659 | { |
| 660 | FileDialog::setLastUsedDir( paths[0].parent_path() ); |
| 661 | FileDialogSignals::instance().onSaveFile( paths[0] ); |
| 662 | } |
| 663 | callback( paths[0] ); |
| 664 | } |
| 665 | }; |
| 666 | auto filters = params.filters; |
| 667 | filters.erase( std::remove_if( filters.begin(), filters.end(), [] ( const auto& filter ) |
| 668 | { |
| 669 | return filter.extensions == "*.*"; |
| 670 | } ), filters.end() ); |
| 671 | std::string accumFilter = webAccumFilter( params.filters ); |
| 672 | #pragma clang diagnostic push |
| 673 | #pragma clang diagnostic ignored "-Wdollar-in-identifier-extension" |
| 674 | EM_ASM( download_file_dialog_popup( UTF8ToString( $0 ), UTF8ToString( $1 ) ), params.fileName.c_str(), accumFilter.c_str() ); |
| 675 | #pragma clang diagnostic pop |
| 676 | #endif |
| 677 | } |
| 678 | |
| 679 | FileDialogSignals& FileDialogSignals::instance() |
| 680 | { |
no test coverage detected