trying to wrap qsettings in rust

This commit is contained in:
Chris Cochrun 2023-01-27 09:58:16 -06:00
parent 137ba3d4f6
commit f1def0bce9
2 changed files with 58 additions and 0 deletions

34
src/rust/settings.rs Normal file
View file

@ -0,0 +1,34 @@
#[cxx_qt::bridge]
mod settings {
unsafe extern "C++" {
include!("qsettingscxx.h");
include!("cxx-qt-lib/qstring.h");
type QString = cxx_qt_lib::QString;
}
#[derive(Clone)]
#[cxx_qt::qobject(base = "QSettingsCXX")]
pub struct Settings {
#[qproperty]
name: QString,
#[qproperty]
kind: QString,
}
impl Default for Settings {
fn default() -> Self {
Self {
name: QString::from(""),
kind: QString::from(""),
}
}
}
impl qobject::Settings {
#[qinvokable]
pub fn activate(self: Pin<&mut Self>) {
println!("{}", self.name());
}
}
}