Files
Graphite/desktop/src/dialogs.rs
Timon 96a1b12a05 Desktop: Unify save file handling and add file dialog for export (#3008)
* Prepare save file unification

* Desktop add save file dialog
2025-08-06 16:07:53 +00:00

27 lines
748 B
Rust

use std::path::PathBuf;
use rfd::AsyncFileDialog;
pub(crate) async fn dialog_open_graphite_file() -> Option<PathBuf> {
AsyncFileDialog::new()
.add_filter("Graphite", &["graphite"])
.set_title("Open Graphite Document")
.pick_file()
.await
.map(|f| f.path().to_path_buf())
}
pub(crate) async fn dialog_save_graphite_file(name: String) -> Option<PathBuf> {
AsyncFileDialog::new()
.add_filter("Graphite", &["graphite"])
.set_title("Save Graphite Document")
.set_file_name(name)
.save_file()
.await
.map(|f| f.path().to_path_buf())
}
pub(crate) async fn dialog_save_file(name: String) -> Option<PathBuf> {
AsyncFileDialog::new().set_title("Save File").set_file_name(name).save_file().await.map(|f| f.path().to_path_buf())
}