From 672158a31690ebb3b469a4d6d95b1fa3fa168a3f Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Thu, 14 Apr 2022 06:30:12 -0500 Subject: [PATCH] made the alignment of text persistent and editable --- src/qml/presenter/Slide.qml | 8 ++++---- src/qml/presenter/SlideEditor.qml | 6 +++--- src/qml/presenter/SongEditor.qml | 14 +++++++++----- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/qml/presenter/Slide.qml b/src/qml/presenter/Slide.qml index f4420f4..ddc1244 100644 --- a/src/qml/presenter/Slide.qml +++ b/src/qml/presenter/Slide.qml @@ -22,8 +22,8 @@ Item { property string chosenFont: "Quicksand" property var text: "This is demo text" property color backgroundColor - property var horizontalAlignment: Text.AlignHCenter - property var verticalAlignment: Text.AlignVCenter + property var hTextAlignment: Text.AlignHCenter + property var vTextAlignment: Text.AlignVCenter //these properties are for giving video info to parents property int mpvPosition: mpv.position @@ -119,8 +119,8 @@ Item { /* minimumPointSize: 5 */ fontSizeMode: Text.Fit font.family: chosenFont - horizontalAlignment: horizontalAlignment - verticalAlignment: verticalAlignment + horizontalAlignment: hTextAlignment + verticalAlignment: vTextAlignment style: Text.Raised anchors.fill: parent clip: true diff --git a/src/qml/presenter/SlideEditor.qml b/src/qml/presenter/SlideEditor.qml index f4d171e..b628163 100644 --- a/src/qml/presenter/SlideEditor.qml +++ b/src/qml/presenter/SlideEditor.qml @@ -23,8 +23,8 @@ Item { editMode: true imageSource: imageBackground videoSource: videoBackground - horizontalAlignment: hTextAlignment - verticalAlignment: vTextAlignment + hTextAlignment: root.hTextAlignment + vTextAlignment: root.vTextAlignment preview: true } @@ -56,7 +56,7 @@ Item { function updateVAlignment(alignment) { switch (alignment) { case "top" : - representation.verticalAlignment = Text.AlignBottom; + representation.verticalAlignment = Text.AlignTop; break; case "center" : representation.verticalAlignment = Text.AlignVCenter; diff --git a/src/qml/presenter/SongEditor.qml b/src/qml/presenter/SongEditor.qml index a2fe3de..6fb6b1c 100644 --- a/src/qml/presenter/SongEditor.qml +++ b/src/qml/presenter/SongEditor.qml @@ -53,14 +53,14 @@ Item { model: ["Left", "Center", "Right", "Justify"] implicitWidth: 100 hoverEnabled: true - onCurrentTextChanged: updateHorizontalTextAlignment(currentText.toLowerCase()); + onActivated: updateHorizontalTextAlignment(currentText.toLowerCase()); } Controls.ComboBox { id: vAlignmentBox model: ["Top", "Center", "Bottom"] implicitWidth: 100 hoverEnabled: true - onCurrentTextChanged: updateVerticalTextAlignment(currentText.toLowerCase()); + onActivated: updateVerticalTextAlignment(currentText.toLowerCase()); } Controls.ToolButton { text: "B" @@ -290,6 +290,8 @@ Item { songHAlignment = song.horizontalTextAlignment; songVAlignment = song.verticalTextAlignment; + alignmentSetTimer.restart(); + if (songBackgroundType == "image") { slideEditor.videoBackground = ""; slideEditor.imageBackground = songBackground; @@ -338,17 +340,20 @@ Item { function updateHorizontalTextAlignment(textAlignment) { + if (alignmentSetTimer.running) + return; changeSlideHAlignment(textAlignment); songsqlmodel.updateHorizontalTextAlignment(songIndex, textAlignment); } function updateVerticalTextAlignment(textAlignment) { + if (alignmentSetTimer.running) + return; changeSlideVAlignment(textAlignment); songsqlmodel.updateVerticalTextAlignment(songIndex, textAlignment) } function changeSlideHAlignment(alignment) { - print("AHHHHHHHHHHH") switch (alignment) { case "left" : hAlignmentBox.currentIndex = 0; @@ -370,11 +375,10 @@ Item { } function changeSlideVAlignment(alignment) { - print("AHHHHHHHHHHH") switch (alignment) { case "top" : vAlignmentBox.currentIndex = 0; - slideEditor.vTextAlignment = Text.AlignBottom; + slideEditor.vTextAlignment = Text.AlignTop; break; case "center" : vAlignmentBox.currentIndex = 1;