From 428386a25b4adbbe8b2eba1dff16c27cf8e09a3f Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Mon, 25 Mar 2024 18:35:58 -0500 Subject: [PATCH] fixing a lot of debug info --- src/main.cpp | 9 +++-- src/qml/presenter/SongEditor.qml | 58 ++++++++++++++++++-------------- src/rust/songs/song_model.rs | 21 ++++++------ src/rust/utils.rs | 24 ++++++++++++- 4 files changed, 72 insertions(+), 40 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 9317938..4c08404 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -124,7 +124,7 @@ int main(int argc, char *argv[]) QCoreApplication::setOrganizationName(QStringLiteral("lumina")); QCoreApplication::setOrganizationDomain(QStringLiteral("tfcconnection.org")); QCoreApplication::setApplicationName(QStringLiteral("lumina")); - // qSetMessagePattern("[%{type} %{time h:m:s ap}: %{function} in %{file}]: %{message}\n"); + qSetMessagePattern("[%{type} %{time h:m:s ap}: %{function} in %{file}]: %{message}\n"); #ifdef Q_OS_WINDOWS QIcon::setFallbackThemeName("breeze"); @@ -141,7 +141,7 @@ int main(int argc, char *argv[]) qDebug() << QApplication::platformName(); //Need to instantiate our slide - QScopedPointer utils(new Utils); + // QScopedPointer utils(new Utils); QScopedPointer slideModel(new SlideModel); QScopedPointer slideMod(new SlideModelCpp); QScopedPointer filemanager(new File); @@ -200,7 +200,9 @@ int main(int argc, char *argv[]) slideModel.get(), SLOT(activate(int))); - utils.get()->setup(); + Utils *utils = new Utils; + utils->setup(); + // qDebug() << utils.get(); if (!serviceItemModel.get()->load(settings->getLastSaveFile())) { qDebug() << "Last saved file is missing or there isn't a last saved file."; @@ -239,6 +241,7 @@ int main(int argc, char *argv[]) "ServiceItemC", serviceItemC.get()); qmlRegisterSingletonInstance("org.presenter", 1, 0, "SlideModel", slideModel.get()); qmlRegisterSingletonInstance("org.presenter", 1, 0, "SlideMod", slideMod.get()); + qmlRegisterSingletonInstance("org.presenter", 1, 0, "Utils", utils); qmlRegisterSingletonInstance("org.presenter", 1, 0, "SlideObject", slideobject.get()); qmlRegisterSingletonInstance("org.presenter", 1, 0, "FileManager", filemanager.get()); qmlRegisterSingletonInstance("org.presenter", 1, 0, "PresWindow", PresWindow); diff --git a/src/qml/presenter/SongEditor.qml b/src/qml/presenter/SongEditor.qml index 1dbf458..b264d83 100644 --- a/src/qml/presenter/SongEditor.qml +++ b/src/qml/presenter/SongEditor.qml @@ -5,6 +5,7 @@ import QtQuick.Dialogs 1.3 import QtQuick.Layouts 1.15 import org.kde.kirigami 2.13 as Kirigami import "./" as Presenter +import org.presenter 1.0 Item { id: root @@ -348,7 +349,7 @@ Item { songEditorModel.lyrics = text /* editorTimer.running = false; */ } - /* onPressed: editorTimer.running = true */ + onPressed: editorTimer.running = true background: Presenter.TextBackground { control: lyricsEditor } @@ -469,25 +470,34 @@ Item { } } - /* Timer { */ - /* id: editorTimer */ - /* interval: 1000 */ - /* repeat: true */ - /* running: false */ - /* onTriggered: { */ - /* if (lyricsEditor.text === songEditorModel.lyrics) */ - /* return; */ - /* else */ - /* songEditorModel.lyrics = lyricsEditor.text; */ - /* /\* updateLyrics(lyricsEditor.text); *\/ */ - /* } */ - /* } */ + Timer { + id: editorTimer + interval: 1000 + repeat: true + running: false + onTriggered: { + if (lyricsEditor.text === songEditorModel.lyrics) { + return; + } + else { + Utils.dbg("Changing Lyrics"); + /* songEditorModel.lyrics = lyricsEditor.text; */ + /* showPassiveNotification("Lyrics changed"); */ + songProxyModel.songModel.updateLyrics(songID, lyricsEditor.text); + clearSlides(); + changeSlideText(songID); + Utils.dbg("Lyrics changed"); + } + /* updateLyrics(lyricsEditor.text); */ + } + } function changeSong(index) { - console.log("Preparing to change song: " + index + 1 + " out of " + songProxyModel.songModel.count); + Utils.dbg("Preparing to change song: " + index + 1 + " out of " + songProxyModel.songModel.count); + editorTimer.running = false; clearSlides(); - const updatedSong = songProxyModel.getSong(index); - console.log(updatedSong.vorder + " " + updatedSong.title + " " + updatedSong.audio); + const updatedSong = songProxyModel.songModel.getItem(index); + Utils.dbg(updatedSong.vorder + " " + updatedSong.title + " " + updatedSong.audio); songEditorModel.title = updatedSong.title; songEditorModel.lyrics = updatedSong.lyrics; songEditorModel.author = updatedSong.author; @@ -502,14 +512,14 @@ Item { songEditorModel.fontSize = updatedSong.fontSize; songEditorModel.checkVerseOrder(); songEditorModel.checkFiles(); - songID = updatedSong.id; + songID = index; changeSlideHAlignment(song.horizontalTextAlignment); changeSlideVAlignment(song.verticalTextAlignment); changeSlideFont(song.font, true); changeSlideFontSize(song.fontSize, true) - changeSlideText(songProxyModel.modelIndex(index).row); - console.log("Changing to song: " + song.title + " with ID: " + songID); + changeSlideText(index); + Utils.dbg("Changing to song: " + song.title + " with ID: " + songID); footerFirstText = "Song: "; footerSecondText = song.title; songList.loadVideo(); @@ -518,10 +528,6 @@ Item { Connections { target: songEditorModel function onLyricsChanged() { - showPassiveNotification("Lyrics changed"); - songProxyModel.songModel.updateLyrics(songID, lyricsEditor.text); - clearSlides(); - changeSlideText(songID); } } @@ -568,7 +574,7 @@ Item { songEditorModel.background = file; songProxyModel.songModel.updateBackground(songID, file); songProxyModel.songModel.updateBackgroundType(songID, backgroundType); - console.log("changed background"); + Utils.dbg("changed background"); } @@ -647,7 +653,7 @@ Item { } function changeSlideText(id) { - const verses = songProxyModel.getLyricList(id); + const verses = songProxyModel.songModel.getLyricList(id); verses.forEach(songList.appendVerse); /* songList.loadVideo(); */ } diff --git a/src/rust/songs/song_model.rs b/src/rust/songs/song_model.rs index ac8aa99..e14eebf 100644 --- a/src/rust/songs/song_model.rs +++ b/src/rust/songs/song_model.rs @@ -978,8 +978,8 @@ impl song_model::SongModel { for (i, line) in raw_lyrics.split("\n").enumerate() { if keywords.contains(&line) { if i != 0 { - println!("{verse_title}"); - println!("{lyric}"); + // println!("{verse_title}"); + // println!("{lyric}"); lyric_map.insert(verse_title, lyric); lyric = String::from(""); verse_title = line.to_string(); @@ -996,25 +996,25 @@ impl song_model::SongModel { } } lyric_map.insert(verse_title, lyric); - println!("da-map: {:?}", lyric_map); + // println!("da-map: {:?}", lyric_map); for mut verse in vorder { let mut verse_name = ""; - debug!(verse = verse); + // debug!(verse = verse); for word in keywords.clone() { let end_verse = verse.get(1..2).unwrap_or_default(); let beg_verse = verse.get(0..1).unwrap_or_default(); - println!( - "verse: {:?}, beginning: {:?}, end: {:?}, word: {:?}", - verse, beg_verse, end_verse, word - ); + // println!( + // "verse: {:?}, beginning: {:?}, end: {:?}, word: {:?}", + // verse, beg_verse, end_verse, word + // ); if word.starts_with(beg_verse) && word.ends_with(end_verse) { verse_name = word; - println!("TITLE: {verse_name}"); + // println!("TITLE: {verse_name}"); continue; } } @@ -1036,7 +1036,8 @@ impl song_model::SongModel { }; } for lyric in lyric_list.iter() { - println!("da-list: {:?}", lyric); + // println!("da-list: {:?}", lyric); + debug!(lyric = ?lyric) } } QStringList::from(&lyric_list) diff --git a/src/rust/utils.rs b/src/rust/utils.rs index a75c78e..c27f7e8 100644 --- a/src/rust/utils.rs +++ b/src/rust/utils.rs @@ -2,11 +2,14 @@ use std::pin::Pin; use time::macros::format_description; use tokio::runtime::Runtime; +use tracing::{debug, info}; use tracing_subscriber::{ fmt::{self, time::LocalTime}, EnvFilter, }; +use self::utilities::QString; + mod db { use diesel::{Connection, SqliteConnection}; use dirs::data_local_dir; @@ -50,6 +53,11 @@ mod db { #[cxx_qt::bridge] mod utilities { + unsafe extern "C++" { + include!("cxx-qt-lib/qstring.h"); + type QString = cxx_qt_lib::QString; + } + unsafe extern "RustQt" { #[qobject] #[qml_element] @@ -57,6 +65,12 @@ mod utilities { #[qinvokable] fn setup(self: Pin<&mut Utils>); + + #[qinvokable] + fn dbg(self: &Utils, message: QString); + + #[qinvokable] + fn inf(self: &Utils, message: QString); } } @@ -74,9 +88,17 @@ impl Default for UtilsRust { } impl utilities::Utils { - pub fn setup(mut self: Pin<&mut Self>) { + pub fn setup(self: Pin<&mut Self>) { crate::utils::setup(); } + + pub fn dbg(self: &Self, message: QString) { + debug!(msg = ?message); + } + + pub fn inf(self: &Self, message: QString) { + info!(msg = ?message); + } } pub fn setup() {