feat: add native dialog
This commit is contained in:
26
__gui/native-dialog/src/main.rs
Normal file
26
__gui/native-dialog/src/main.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
use native_dialog::{FileDialog, MessageDialog, MessageType};
|
||||
|
||||
fn main() {
|
||||
let path = FileDialog::new()
|
||||
.set_location("~/Desktop")
|
||||
.add_filter("PNG Image", &["png"])
|
||||
.add_filter("JPEG Image", &["jpg", "jpeg"])
|
||||
.show_open_single_file()
|
||||
.unwrap();
|
||||
|
||||
let path = match path {
|
||||
Some(path) => path,
|
||||
None => return,
|
||||
};
|
||||
|
||||
let yes = MessageDialog::new()
|
||||
.set_type(MessageType::Info)
|
||||
.set_title("Do you want to open the file?")
|
||||
.set_text(&format!("{:#?}", path))
|
||||
.show_confirm()
|
||||
.unwrap();
|
||||
|
||||
if yes {
|
||||
println!("{:?}", path);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user