made the alignment of text persistent and editable

This commit is contained in:
Chris Cochrun 2022-04-14 06:30:12 -05:00
parent 2e46f403be
commit 672158a316
3 changed files with 16 additions and 12 deletions

View file

@ -22,8 +22,8 @@ Item {
property string chosenFont: "Quicksand" property string chosenFont: "Quicksand"
property var text: "This is demo text" property var text: "This is demo text"
property color backgroundColor property color backgroundColor
property var horizontalAlignment: Text.AlignHCenter property var hTextAlignment: Text.AlignHCenter
property var verticalAlignment: Text.AlignVCenter property var vTextAlignment: Text.AlignVCenter
//these properties are for giving video info to parents //these properties are for giving video info to parents
property int mpvPosition: mpv.position property int mpvPosition: mpv.position
@ -119,8 +119,8 @@ Item {
/* minimumPointSize: 5 */ /* minimumPointSize: 5 */
fontSizeMode: Text.Fit fontSizeMode: Text.Fit
font.family: chosenFont font.family: chosenFont
horizontalAlignment: horizontalAlignment horizontalAlignment: hTextAlignment
verticalAlignment: verticalAlignment verticalAlignment: vTextAlignment
style: Text.Raised style: Text.Raised
anchors.fill: parent anchors.fill: parent
clip: true clip: true

View file

@ -23,8 +23,8 @@ Item {
editMode: true editMode: true
imageSource: imageBackground imageSource: imageBackground
videoSource: videoBackground videoSource: videoBackground
horizontalAlignment: hTextAlignment hTextAlignment: root.hTextAlignment
verticalAlignment: vTextAlignment vTextAlignment: root.vTextAlignment
preview: true preview: true
} }
@ -56,7 +56,7 @@ Item {
function updateVAlignment(alignment) { function updateVAlignment(alignment) {
switch (alignment) { switch (alignment) {
case "top" : case "top" :
representation.verticalAlignment = Text.AlignBottom; representation.verticalAlignment = Text.AlignTop;
break; break;
case "center" : case "center" :
representation.verticalAlignment = Text.AlignVCenter; representation.verticalAlignment = Text.AlignVCenter;

View file

@ -53,14 +53,14 @@ Item {
model: ["Left", "Center", "Right", "Justify"] model: ["Left", "Center", "Right", "Justify"]
implicitWidth: 100 implicitWidth: 100
hoverEnabled: true hoverEnabled: true
onCurrentTextChanged: updateHorizontalTextAlignment(currentText.toLowerCase()); onActivated: updateHorizontalTextAlignment(currentText.toLowerCase());
} }
Controls.ComboBox { Controls.ComboBox {
id: vAlignmentBox id: vAlignmentBox
model: ["Top", "Center", "Bottom"] model: ["Top", "Center", "Bottom"]
implicitWidth: 100 implicitWidth: 100
hoverEnabled: true hoverEnabled: true
onCurrentTextChanged: updateVerticalTextAlignment(currentText.toLowerCase()); onActivated: updateVerticalTextAlignment(currentText.toLowerCase());
} }
Controls.ToolButton { Controls.ToolButton {
text: "B" text: "B"
@ -290,6 +290,8 @@ Item {
songHAlignment = song.horizontalTextAlignment; songHAlignment = song.horizontalTextAlignment;
songVAlignment = song.verticalTextAlignment; songVAlignment = song.verticalTextAlignment;
alignmentSetTimer.restart();
if (songBackgroundType == "image") { if (songBackgroundType == "image") {
slideEditor.videoBackground = ""; slideEditor.videoBackground = "";
slideEditor.imageBackground = songBackground; slideEditor.imageBackground = songBackground;
@ -338,17 +340,20 @@ Item {
function updateHorizontalTextAlignment(textAlignment) { function updateHorizontalTextAlignment(textAlignment) {
if (alignmentSetTimer.running)
return;
changeSlideHAlignment(textAlignment); changeSlideHAlignment(textAlignment);
songsqlmodel.updateHorizontalTextAlignment(songIndex, textAlignment); songsqlmodel.updateHorizontalTextAlignment(songIndex, textAlignment);
} }
function updateVerticalTextAlignment(textAlignment) { function updateVerticalTextAlignment(textAlignment) {
if (alignmentSetTimer.running)
return;
changeSlideVAlignment(textAlignment); changeSlideVAlignment(textAlignment);
songsqlmodel.updateVerticalTextAlignment(songIndex, textAlignment) songsqlmodel.updateVerticalTextAlignment(songIndex, textAlignment)
} }
function changeSlideHAlignment(alignment) { function changeSlideHAlignment(alignment) {
print("AHHHHHHHHHHH")
switch (alignment) { switch (alignment) {
case "left" : case "left" :
hAlignmentBox.currentIndex = 0; hAlignmentBox.currentIndex = 0;
@ -370,11 +375,10 @@ Item {
} }
function changeSlideVAlignment(alignment) { function changeSlideVAlignment(alignment) {
print("AHHHHHHHHHHH")
switch (alignment) { switch (alignment) {
case "top" : case "top" :
vAlignmentBox.currentIndex = 0; vAlignmentBox.currentIndex = 0;
slideEditor.vTextAlignment = Text.AlignBottom; slideEditor.vTextAlignment = Text.AlignTop;
break; break;
case "center" : case "center" :
vAlignmentBox.currentIndex = 1; vAlignmentBox.currentIndex = 1;