fn save_camera_controls_state(rec_dest_path: &str, program_data: &ProgramData) {
    let parent_dir = match Path::new(rec_dest_path).parent() {
        Some(p) => p.to_str().unwrap().to_string(),
        None => "".to_string()
    };
    let dest_fpath = Path::new(&parent_dir).join(
        Path::new(rec_dest_path).file_stem().unwrap().to_str().unwrap().to_string() + "_settings.txt"
    );
    let mut file = std::fs::OpenOptions::new()
        .read(false)
        .write(true)
        .create(true)
        .truncate(true)
        .open(dest_fpath)
        .unwrap();

    writeln!(file, "Recorded with Vidoxide\n").unwrap(); //TODO: print Vidoxide version
    writeln!(
        file,
        "{} ({} UTC)",
        chrono::Local::now().format("%Y-%m-%d %H:%M:%S"),
        chrono::Utc::now().format("%Y-%m-%d %H:%M:%S")
    ).unwrap();
    writeln!(file, "{}\n", program_data.camera.as_ref().unwrap().name()).unwrap();

    for ctrl_widgets in &program_data.gui.as_ref().unwrap().control_widgets {
        if !(ctrl_widgets.1).0.h_box.get_visible() {
            continue;
        }

        write!(file, "{}: ", (ctrl_widgets.1).0.name).unwrap();

        if let Some(auto) = &(ctrl_widgets.1).0.auto {
            if auto.is_active() { write!(file, "auto, ").unwrap(); }
        }

        if let Some(on_off) = &(ctrl_widgets.1).0.on_off {
            write!(file, "{}, ", if on_off.is_active() { "on" } else { "off" }).unwrap();
        }

        match &(ctrl_widgets.1).1 {
            ControlWidgetBundle::ListControl(list_ctrl) =>
                write!(file, "{}", list_ctrl.combo.active_text().unwrap()).unwrap(),

            ControlWidgetBundle::NumberControl(num_ctrl) => write!(file, "{:.6}", num_ctrl.slider.value()).unwrap(),

            ControlWidgetBundle::BooleanControl(bool_ctrl) =>
                write!(file, "{}", if bool_ctrl.state_checkbox.is_active() { "true" } else { "false" }).unwrap()
        }

        write!(file, "\n").unwrap();
    }

}
/// Saves current data & time, camera name and camera controls' state to a text file
/// at the same directory as `rec_dest_path`.
Saves current data & time, camera name and camera controls' state to a text file
at the same directory as `rec_dest_path`.
Saves current data & time camera name and camera controls ' state to a text file at the same directory as ` rec_dest_path ` .
fn save_camera_controls_state(rec_dest_path: &str, program_data: &ProgramData) {
    let parent_dir = match Path::new(rec_dest_path).parent() {
        Some(p) => p.to_str().unwrap().to_string(),
        None => "".to_string()
    };
    let dest_fpath = Path::new(&parent_dir).join(
        Path::new(rec_dest_path).file_stem().unwrap().to_str().unwrap().to_string() + "_settings.txt"
    );
    let mut file = std::fs::OpenOptions::new()
        .read(false)
        .write(true)
        .create(true)
        .truncate(true)
        .open(dest_fpath)
        .unwrap();
    writeln!(file, "Recorded with Vidoxide\n").unwrap(); //TODO: print Vidoxide version
    writeln!(
        file,
        "{} ({} UTC)",
        chrono::Local::now().format("%Y-%m-%d %H:%M:%S"),
        chrono::Utc::now().format("%Y-%m-%d %H:%M:%S")
    ).unwrap();
    writeln!(file, "{}\n", program_data.camera.as_ref().unwrap().name()).unwrap();
    for ctrl_widgets in &program_data.gui.as_ref().unwrap().control_widgets {
        if !(ctrl_widgets.1).0.h_box.get_visible() {
            continue;
        }
        write!(file, "{}: ", (ctrl_widgets.1).0.name).unwrap();
        if let Some(auto) = &(ctrl_widgets.1).0.auto {
            if auto.is_active() { write!(file, "auto, ").unwrap(); }
        }
        if let Some(on_off) = &(ctrl_widgets.1).0.on_off {
            write!(file, "{}, ", if on_off.is_active() { "on" } else { "off" }).unwrap();
        }
        match &(ctrl_widgets.1).1 {
            ControlWidgetBundle::ListControl(list_ctrl) =>
                write!(file, "{}", list_ctrl.combo.active_text().unwrap()).unwrap(),
            ControlWidgetBundle::NumberControl(num_ctrl) => write!(file, "{:.6}", num_ctrl.slider.value()).unwrap(),
            ControlWidgetBundle::BooleanControl(bool_ctrl) =>
                write!(file, "{}", if bool_ctrl.state_checkbox.is_active() { "true" } else { "false" }).unwrap()
        }
        write!(file, "\n").unwrap();
    }
}
fn save_camera_controls_state ( rec_dest_path : & str , program_data : & ProgramData ) { let parent_dir = match Path :: new ( rec_dest_path ) . parent ( ) { Some ( p ) => p . to_str ( ) . unwrap ( ) . to_string ( ) , None => " " . to_string ( ) } ; let dest_fpath = Path :: new ( & parent_dir ) . join ( Path :: new ( rec_dest_path ) . file_stem ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) . to_string ( ) + " " ) ; let mut file = std :: fs :: OpenOptions :: new ( ) . read ( false ) . write ( true ) . create ( true ) . truncate ( true ) . open ( dest_fpath ) . unwrap ( ) ; writeln ! ( file " \n " ) . unwrap ( ) ; //TODO: print Vidoxide version writeln ! ( file " " chrono Local now ( ) format ( " " ) chrono Utc now ( ) format ( " " ) ) . unwrap ( ) ; writeln ! ( file " \n " program_data camera as_ref ( ) unwrap ( ) name ( ) ) . unwrap ( ) ; for ctrl_widgets in & program_data . gui . as_ref ( ) . unwrap ( ) . control_widgets { if ! ( ctrl_widgets . 1 ) . 0 . h_box . get_visible ( ) { continue ; } write ! ( file " " ( ctrl_widgets 1 ) 0 name ) . unwrap ( ) ; if let Some ( auto ) = & ( ctrl_widgets . 1 ) . 0 . auto { if auto . is_active ( ) { write ! ( file " " ) . unwrap ( ) ; } } if let Some ( on_off ) = & ( ctrl_widgets . 1 ) . 0 . on_off { write ! ( file " " if on_off is_active ( ) { " " } else { " " } ) . unwrap ( ) ; } match & ( ctrl_widgets . 1 ) . 1 { ControlWidgetBundle :: ListControl ( list_ctrl ) => write ! ( file " " list_ctrl combo active_text ( ) unwrap ( ) ) . unwrap ( ) , ControlWidgetBundle :: NumberControl ( num_ctrl ) => write ! ( file " " num_ctrl slider value ( ) ) . unwrap ( ) , ControlWidgetBundle :: BooleanControl ( bool_ctrl ) => write ! ( file " " if bool_ctrl state_checkbox is_active ( ) { " " } else { " " } ) . unwrap ( ) } write ! ( file " \n " ) . unwrap ( ) ; } }
Saves current data & time, camera name and camera controls' state to a text file
at the same directory as `rec_dest_path`.
Saves current data & time camera name and camera controls ' state to a text file at the same directory as ` rec_dest_path ` .
rec_dest_path
&str
program_data
&ProgramData
rec_dest_path
&str
program_data
&ProgramData