adding settings.rs

This commit is contained in:
Chris Cochrun 2023-01-27 15:46:35 -06:00
parent f1def0bce9
commit 58fb8625f4
4 changed files with 19 additions and 340 deletions

View file

@ -1,34 +1,39 @@
#[cxx_qt::bridge]
mod settings {
use configparser::ini::Ini;
use std::error::Error;
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")]
#[cxx_qt::qobject]
pub struct Settings {
#[qproperty]
name: QString,
screen: QString,
#[qproperty]
kind: QString,
sound_effect: QString,
}
impl Default for Settings {
fn default() -> Self {
Self {
name: QString::from(""),
kind: QString::from(""),
screen: QString::from(""),
sound_effect: QString::from(""),
}
}
}
impl qobject::Settings {
#[qinvokable]
pub fn activate(self: Pin<&mut Self>) {
println!("{}", self.name());
pub fn print_sound(self: Pin<&mut Self>) {
let mut config = Ini::new();
let map = config.load("~/.config/librepresenter/Libre Presenter.conf");
println!("{}", self.sound_effect());
}
}
}