| 2381 | } |
| 2382 | |
| 2383 | void ImageViewer::openImageDialog() { |
| 2384 | if (mFileDialogThread) { |
| 2385 | tlog::warning("File dialog already running."); |
| 2386 | return; |
| 2387 | } |
| 2388 | |
| 2389 | const auto runDialog = [this]() { |
| 2390 | const auto threadGuard = ScopeGuard{[this]() { |
| 2391 | scheduleToUiThread([this]() { |
| 2392 | focusWindow(); |
| 2393 | if (mFileDialogThread && mFileDialogThread->joinable()) { |
| 2394 | mFileDialogThread->join(); |
| 2395 | } |
| 2396 | |
| 2397 | mFileDialogThread = nullptr; |
| 2398 | }); |
| 2399 | }}; |
| 2400 | |
| 2401 | try { |
| 2402 | vector<pair<string, string>> filters = { |
| 2403 | {"acr,dcm,dicom", "DICOM image" }, |
| 2404 | {"apng", "Animated PNG image" }, |
| 2405 | #ifdef TEV_SUPPORT_AVIF |
| 2406 | {"avif", "AV1 Image File" }, |
| 2407 | #endif |
| 2408 | {"bmp", "Bitmap image" }, |
| 2409 | {"cur", "Microsoft cursor image" }, |
| 2410 | #ifdef _WIN32 |
| 2411 | {"dds", "DirectDraw Surface image" }, |
| 2412 | #endif |
| 2413 | {"dng", "Digital Negative image" }, |
| 2414 | {"exr", "OpenEXR image" }, |
| 2415 | {"fit,fits", "FITS image" }, |
| 2416 | {"gif", "Graphics Interchange Format image"}, |
| 2417 | {"hdr", "HDR image" }, |
| 2418 | #ifdef TEV_SUPPORT_HEIC |
| 2419 | {"heic", "High Efficiency Image Container" }, |
| 2420 | #endif |
| 2421 | {"ico", "Microsoft icon image" }, |
| 2422 | {"jpeg,jpg", "JPEG image" }, |
| 2423 | {"jxl", "JPEG XL image" }, |
| 2424 | {"jxr,hdp,wdp", "JPEG XR image" }, |
| 2425 | {"pam,pbm,pfm,pgm,pnm,ppm", "Portable *Map image" }, |
| 2426 | {"pic", "PIC image" }, |
| 2427 | {"png", "Portable Network Graphics image" }, |
| 2428 | {"psd", "PSD image" }, |
| 2429 | {"qoi", "Quite OK Image format" }, |
| 2430 | {"tga", "Truevision TGA image" }, |
| 2431 | {"tiff,tif", "Tag Image File Format image" }, |
| 2432 | {"webp", "WebP image" }, |
| 2433 | }; |
| 2434 | |
| 2435 | vector<string_view> allImages; |
| 2436 | for (const auto& filter : filters) { |
| 2437 | allImages.push_back(filter.first); |
| 2438 | } |
| 2439 | |
| 2440 | filters.emplace(filters.begin(), pair{join(allImages, ","), "All images"}); |