From e9c78e4ea6862f52ca2c03cbc25babf81daadf77 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Sun, 19 Nov 2023 07:15:55 -0600 Subject: [PATCH] making sure we can show that files exist in the ui --- src/rust/songs/song_editor.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/rust/songs/song_editor.rs b/src/rust/songs/song_editor.rs index 9b721ca..3b97c66 100644 --- a/src/rust/songs/song_editor.rs +++ b/src/rust/songs/song_editor.rs @@ -1,5 +1,7 @@ #[cxx_qt::bridge] pub mod song_editor { + use std::path::PathBuf; + use tracing::{debug, debug_span, error, info, instrument}; unsafe extern "C++" { @@ -49,6 +51,10 @@ pub mod song_editor { font: QString, #[qproperty] font_size: i32, + #[qproperty] + background_exists: bool, + #[qproperty] + audio_exists: bool, // #[qproperty] // song_model: *mut CxxSongs, } @@ -69,6 +75,8 @@ pub mod song_editor { vertical_text_alignment: QString::default(), font: QString::default(), font_size: 50, + background_exists: true, + audio_exists: true, // song_model: std::ptr::null_mut(), } } @@ -95,5 +103,27 @@ pub mod song_editor { } } } + + #[qinvokable] + pub fn check_files(mut self: Pin<&mut Self>) { + let background = PathBuf::from( + self.background() + .clone() + .to_string() + .trim_start_matches("file://"), + ); + let audio = PathBuf::from( + self.audio() + .clone() + .to_string() + .trim_start_matches("file://"), + ); + debug!( + background = background.exists(), + audio = audio.exists() + ); + self.as_mut().set_background_exists(background.exists()); + self.as_mut().set_audio_exists(audio.exists()); + } } }