From eaa32c8b2beb4254252b3fbefb6f6d1f1d5df8fe Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Fri, 22 Apr 2022 16:42:07 -0500 Subject: [PATCH] implemented font and fontsize in toolbar of songeditor --- TODO.org | 7 +++++-- src/qml/presenter/SlideEditor.qml | 5 ++++- src/qml/presenter/SongEditor.qml | 29 ++++++++++++++++++++++++++++- src/songsqlmodel.cpp | 2 ++ 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/TODO.org b/TODO.org index 3240ae0..077b434 100644 --- a/TODO.org +++ b/TODO.org @@ -8,9 +8,12 @@ [[file:~/dev/church-presenter/src/qml/presenter/SongEditor.qml::Controls.ToolBar {]] - [X] alignment -- [X] font -- [X] fontsize +- [X] font - Need to finish the UI portion of it +- [X] fontsize - Need to finish the UI portion of it - [ ] effects? + For effects, I'm not 100% sure how to do this in an easy to build out way. Should I just do them the same as the other attributes or have effects be individually stored? Which effects to use? + + I'm thinking shadows for sure for readability on slides. Also, maybe I should have an effect of like glow? But maybe I'll come back to this after more of the core system is finished. ** TODO bug in changing slides with the arrows [[file:~/dev/church-presenter/src/qml/presenter/Presentation.qml::function changeSlide() {]] diff --git a/src/qml/presenter/SlideEditor.qml b/src/qml/presenter/SlideEditor.qml index b628163..ec17628 100644 --- a/src/qml/presenter/SlideEditor.qml +++ b/src/qml/presenter/SlideEditor.qml @@ -15,16 +15,19 @@ Item { property string videoBackground property var hTextAlignment property var vTextAlignment + property string font + property real fontSize Presenter.Slide { id: representation anchors.fill: parent - textSize: width / 15 editMode: true imageSource: imageBackground videoSource: videoBackground hTextAlignment: root.hTextAlignment vTextAlignment: root.vTextAlignment + chosenFont: font + textSize: fontSize preview: true } diff --git a/src/qml/presenter/SongEditor.qml b/src/qml/presenter/SongEditor.qml index 78ab926..971054b 100644 --- a/src/qml/presenter/SongEditor.qml +++ b/src/qml/presenter/SongEditor.qml @@ -33,7 +33,7 @@ Item { editable: true hoverEnabled: true flat: true - onCurrentTextChanged: showPassiveNotification(currentText) + onActivated: updateFont(currentText) } Controls.SpinBox { id: fontSizeBox @@ -41,6 +41,7 @@ Item { from: 5 to: 72 hoverEnabled: true + onValueModified: updateFontSize(value) } Controls.ComboBox { id: hAlignmentBox @@ -290,6 +291,8 @@ Item { changeSlideHAlignment(song.horizontalTextAlignment); changeSlideVAlignment(song.verticalTextAlignment); + changeSlideFont(song.font, true); + changeSlideFontSize(song.fontSize, true) print(song); } @@ -336,6 +339,16 @@ Item { songsqlmodel.updateVerticalTextAlignment(songIndex, textAlignment) } + function updateFont(font) { + changeSlideFont(font, false); + songsqlmodel.updateFont(songIndex, font); + } + + function updateFontSize(fontSize) { + changeSlideFontSize(fontSize, false); + songsqlmodel.updateFontSize(songIndex, fontSize); + } + function changeSlideHAlignment(alignment) { switch (alignment) { case "left" : @@ -373,4 +386,18 @@ Item { break; } } + + function changeSlideFont(font, updateBox) { + const fontIndex = fontBox.find(font); + print(fontIndex); + if (updateBox) + fontBox.currentIndex = fontIndex; + slideEditor.font = font; + } + + function changeSlideFontSize(fontSize, updateBox) { + if (updateBox) + fontSizeBox.value = fontSize; + slideEditor.fontSize = fontSize; + } } diff --git a/src/songsqlmodel.cpp b/src/songsqlmodel.cpp index db4651f..fcf1723 100644 --- a/src/songsqlmodel.cpp +++ b/src/songsqlmodel.cpp @@ -99,6 +99,8 @@ QHash SongSqlModel::roleNames() const names[Qt::UserRole + 8] = "backgroundType"; names[Qt::UserRole + 9] = "horizontalTextAlignment"; names[Qt::UserRole + 10] = "verticalTextAlignment"; + names[Qt::UserRole + 11] = "font"; + names[Qt::UserRole + 12] = "fontSize"; return names; }