adjusting settings and slide_model.rs
These are trying to get more code written in Rust rather than c++. Not there yet, but I need to sync these to another machine.
This commit is contained in:
parent
ec95ba0d89
commit
236503e877
10 changed files with 387 additions and 108 deletions
|
@ -2,7 +2,7 @@
|
|||
mod settings {
|
||||
|
||||
use configparser::ini::Ini;
|
||||
// use std::error::Error;
|
||||
use dirs;
|
||||
|
||||
unsafe extern "C++" {
|
||||
include!("cxx-qt-lib/qstring.h");
|
||||
|
@ -16,6 +16,8 @@ mod settings {
|
|||
screen: QString,
|
||||
#[qproperty]
|
||||
sound_effect: QString,
|
||||
#[qproperty]
|
||||
last_save_file: QString,
|
||||
}
|
||||
|
||||
impl Default for Settings {
|
||||
|
@ -23,6 +25,7 @@ mod settings {
|
|||
Self {
|
||||
screen: QString::from(""),
|
||||
sound_effect: QString::from(""),
|
||||
last_save_file: QString::from(""),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,5 +38,30 @@ mod settings {
|
|||
|
||||
println!("{}", self.sound_effect());
|
||||
}
|
||||
|
||||
#[qinvokable]
|
||||
pub fn setup(self: Pin<&mut Self>) {
|
||||
let mut config = Ini::new();
|
||||
let home = dirs::config_dir();
|
||||
println!("{:?}", home);
|
||||
if let Some(mut conf) = home {
|
||||
conf.push("librepresenter");
|
||||
conf.push("Libre Presenter.conf");
|
||||
let _map = config.load(conf);
|
||||
|
||||
println!("{:?}", config);
|
||||
println!("{:?}", _map);
|
||||
let sf = config.get("General", "lastSaveFile");
|
||||
println!("{:?}", sf);
|
||||
if let Some(s) = sf {
|
||||
self.set_last_save_file(QString::from(&s));
|
||||
println!("{s}");
|
||||
} else {
|
||||
println!("error loading last save file");
|
||||
}
|
||||
} else {
|
||||
println!("Couldn't find home directory");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue