First Commit
This commit is contained in:
+32
@@ -0,0 +1,32 @@
|
||||
#![windows_subsystem = "windows"]
|
||||
use std::fs::File;
|
||||
|
||||
use image::Luma;
|
||||
use native_dialog::{FileDialog, MessageDialog, MessageType};
|
||||
use qrcode::QrCode;
|
||||
slint::slint!();
|
||||
slint::include_modules!();
|
||||
|
||||
fn main() {
|
||||
let app: MainWindow = MainWindow::new().unwrap();
|
||||
let _weak = app.as_weak();
|
||||
app.on_convert({
|
||||
let handle: slint::Weak<MainWindow> = app.as_weak();
|
||||
move || {
|
||||
let weak: MainWindow = handle.unwrap();
|
||||
let binding = weak.get_website();
|
||||
let websitetext = binding.as_str();
|
||||
let result = FileDialog::new()
|
||||
.set_location("~/Downloads")
|
||||
.show_save_single_file()
|
||||
.expect("Unknown File Path")
|
||||
.unwrap();
|
||||
let mut savelocation = result.into_os_string().into_string().unwrap();
|
||||
let qrcode = QrCode::new(websitetext.as_bytes()).unwrap();
|
||||
let image = qrcode.render::<Luma<u8>>().build();
|
||||
savelocation.push_str(".png");
|
||||
image.save(savelocation);
|
||||
}
|
||||
});
|
||||
app.run().unwrap();
|
||||
}
|
||||
Reference in New Issue
Block a user