a lot of setup and testing work for rust

This commit is contained in:
Chris Cochrun 2022-12-13 09:33:47 -06:00
parent 8e58dd89df
commit 8b4c348279
12 changed files with 231 additions and 32 deletions

45
src/rust/file_helper.rs Normal file
View file

@ -0,0 +1,45 @@
#[cxx_qt::bridge]
mod file_helper {
use cxx::{CxxString, CxxVector};
unsafe extern "C++" {
include!("cxx-qt-lib/qstring.h");
type QString = cxx_qt_lib::QString;
include!("cxx-qt-lib/qurl.h");
type QUrl = cxx_qt_lib::QUrl;
include!("cxx-qt-lib/qvariant.h");
type QVariant = cxx_qt_lib::QVariant;
}
#[derive(Clone)]
#[cxx_qt::qobject]
pub struct FileHelper {
#[qproperty]
name: QString,
#[qproperty]
file_path: QString,
}
impl Default for FileHelper {
fn default() -> Self {
Self {
name: QString::from(""),
file_path: QString::from(""),
}
}
}
impl qobject::FileHelper {
#[qinvokable]
pub fn save(self: Pin<&mut Self>, file: QUrl, _service_list: QVariant) -> bool {
println!("{}", file);
return true;
}
#[qinvokable]
pub fn load(self: Pin<&mut Self>, file: QUrl) -> Vec<String> {
println!("{}", file);
let vc = vec![String::new()];
return vc;
}
}
}