Make extensions case insensitive on linux
This commit is contained in:
parent
644e99c295
commit
4f3dc85bb4
|
|
@ -1,4 +1,5 @@
|
|||
use std::{
|
||||
fmt::Write as _,
|
||||
path::PathBuf,
|
||||
sync::{Arc, Weak},
|
||||
};
|
||||
|
|
@ -49,6 +50,23 @@ pub struct FileDialogBuilder {
|
|||
|
||||
impl FileDialogBuilder {
|
||||
pub fn add_filter(self, name: impl Into<String>, extensions: &[impl ToString]) -> Self {
|
||||
#[cfg(target_os = "linux")]
|
||||
let exts = extensions
|
||||
.iter()
|
||||
.map(|ext| {
|
||||
let mut normalized = String::new();
|
||||
for char in ext.to_string().chars() {
|
||||
if char.is_ascii_lowercase() {
|
||||
let _ = write!(&mut normalized, "[{char}{}]", char.to_ascii_uppercase());
|
||||
} else {
|
||||
normalized.push(char);
|
||||
}
|
||||
}
|
||||
normalized
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
#[cfg(target_os = "linux")]
|
||||
let extensions = &exts;
|
||||
Self {
|
||||
dialog: self.dialog.add_filter(name, extensions),
|
||||
..self
|
||||
|
|
|
|||
Loading…
Reference in New Issue