making songeditor align text
This commit is contained in:
parent
86a5bbf93c
commit
e22ac445c5
6 changed files with 145 additions and 38 deletions
|
@ -160,7 +160,7 @@ Item {
|
||||||
} else if (textIndex <= root.text.length) {
|
} else if (textIndex <= root.text.length) {
|
||||||
previewSlide.text = root.text[textIndex];
|
previewSlide.text = root.text[textIndex];
|
||||||
print(root.text[textIndex]);
|
print(root.text[textIndex]);
|
||||||
--textIndex
|
--textIndex;
|
||||||
}
|
}
|
||||||
} else if (itemType === "video") {
|
} else if (itemType === "video") {
|
||||||
clearText();
|
clearText();
|
||||||
|
|
|
@ -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
|
property var horizontalAlignment: Text.AlignHCenter
|
||||||
property var verticalAlignment
|
property var verticalAlignment: 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: Text.AlignHCenter
|
horizontalAlignment: horizontalAlignment
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: verticalAlignment
|
||||||
style: Text.Raised
|
style: Text.Raised
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
clip: true
|
clip: true
|
||||||
|
|
|
@ -13,7 +13,8 @@ Item {
|
||||||
|
|
||||||
property string imageBackground
|
property string imageBackground
|
||||||
property string videoBackground
|
property string videoBackground
|
||||||
property string textAlignment
|
property var hTextAlignment
|
||||||
|
property var vTextAlignment
|
||||||
|
|
||||||
Presenter.Slide {
|
Presenter.Slide {
|
||||||
id: representation
|
id: representation
|
||||||
|
@ -22,14 +23,17 @@ Item {
|
||||||
editMode: true
|
editMode: true
|
||||||
imageSource: imageBackground
|
imageSource: imageBackground
|
||||||
videoSource: videoBackground
|
videoSource: videoBackground
|
||||||
|
horizontalAlignment: hTextAlignment
|
||||||
|
verticalAlignment: vTextAlignment
|
||||||
preview: true
|
preview: true
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: updateHAlignment(textAlignment)
|
Component.onCompleted: {
|
||||||
|
}
|
||||||
|
|
||||||
function loadVideo() {
|
function loadVideo() {
|
||||||
representation.loadVideo();
|
representation.loadVideo();
|
||||||
representation.pause();
|
representation.pauseVideo();
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateHAlignment(alignment) {
|
function updateHAlignment(alignment) {
|
||||||
|
@ -48,4 +52,18 @@ Item {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateVAlignment(alignment) {
|
||||||
|
switch (alignment) {
|
||||||
|
case "top" :
|
||||||
|
representation.verticalAlignment = Text.AlignBottom;
|
||||||
|
break;
|
||||||
|
case "center" :
|
||||||
|
representation.verticalAlignment = Text.AlignVCenter;
|
||||||
|
break;
|
||||||
|
case "bottom" :
|
||||||
|
representation.verticalAlignment = Text.AlignBottom;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ Item {
|
||||||
property string songBackground
|
property string songBackground
|
||||||
property string songBackgroundType
|
property string songBackgroundType
|
||||||
property string songHAlignment
|
property string songHAlignment
|
||||||
|
property string songVAlignment
|
||||||
|
|
||||||
GridLayout {
|
GridLayout {
|
||||||
id: mainLayout
|
id: mainLayout
|
||||||
|
@ -48,16 +49,18 @@ Item {
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
}
|
}
|
||||||
Controls.ComboBox {
|
Controls.ComboBox {
|
||||||
|
id: hAlignmentBox
|
||||||
model: ["Left", "Center", "Right", "Justify"]
|
model: ["Left", "Center", "Right", "Justify"]
|
||||||
implicitWidth: 100
|
implicitWidth: 100
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
onCurrentTextChanged: updateTextAlignment(currentText.toLowerCase());
|
onCurrentTextChanged: updateHorizontalTextAlignment(currentText.toLowerCase());
|
||||||
}
|
}
|
||||||
Controls.ComboBox {
|
Controls.ComboBox {
|
||||||
|
id: vAlignmentBox
|
||||||
model: ["Top", "Center", "Bottom"]
|
model: ["Top", "Center", "Bottom"]
|
||||||
implicitWidth: 100
|
implicitWidth: 100
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
onCurrentTextChanged: print(currentText.toLowerCase());
|
onCurrentTextChanged: updateVerticalTextAlignment(currentText.toLowerCase());
|
||||||
}
|
}
|
||||||
Controls.ToolButton {
|
Controls.ToolButton {
|
||||||
text: "B"
|
text: "B"
|
||||||
|
@ -226,7 +229,6 @@ Item {
|
||||||
Layout.bottomMargin: 30
|
Layout.bottomMargin: 30
|
||||||
Layout.rightMargin: 20
|
Layout.rightMargin: 20
|
||||||
Layout.leftMargin: 20
|
Layout.leftMargin: 20
|
||||||
textAlignment: songHAlignment
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -285,7 +287,9 @@ Item {
|
||||||
songVorder = song.vorder;
|
songVorder = song.vorder;
|
||||||
songBackground = song.background;
|
songBackground = song.background;
|
||||||
songBackgroundType = song.backgroundType;
|
songBackgroundType = song.backgroundType;
|
||||||
songHAlignment = song.textAlignment;
|
songHAlignment = song.horizontalTextAlignment;
|
||||||
|
songVAlignment = song.verticalTextAlignment;
|
||||||
|
|
||||||
if (songBackgroundType == "image") {
|
if (songBackgroundType == "image") {
|
||||||
slideEditor.videoBackground = "";
|
slideEditor.videoBackground = "";
|
||||||
slideEditor.imageBackground = songBackground;
|
slideEditor.imageBackground = songBackground;
|
||||||
|
@ -294,6 +298,10 @@ Item {
|
||||||
slideEditor.videoBackground = songBackground;
|
slideEditor.videoBackground = songBackground;
|
||||||
slideEditor.loadVideo();
|
slideEditor.loadVideo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
changeSlideHAlignment(songHAlignment);
|
||||||
|
changeSlideVAlignment(songVAlignment);
|
||||||
|
|
||||||
print(song);
|
print(song);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,7 +336,54 @@ Item {
|
||||||
print("changed background");
|
print("changed background");
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTextAlignment(textAlignment) {
|
|
||||||
songsqlmodel.updateTextAlignment(songIndex, textAlignment)
|
function updateHorizontalTextAlignment(textAlignment) {
|
||||||
|
changeSlideHAlignment(textAlignment);
|
||||||
|
songsqlmodel.updateHorizontalTextAlignment(songIndex, textAlignment);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateVerticalTextAlignment(textAlignment) {
|
||||||
|
changeSlideVAlignment(textAlignment);
|
||||||
|
songsqlmodel.updateVerticalTextAlignment(songIndex, textAlignment)
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeSlideHAlignment(alignment) {
|
||||||
|
print("AHHHHHHHHHHH")
|
||||||
|
switch (alignment) {
|
||||||
|
case "left" :
|
||||||
|
hAlignmentBox.currentIndex = 0;
|
||||||
|
slideEditor.hTextAlignment = Text.AlignLeft;
|
||||||
|
break;
|
||||||
|
case "center" :
|
||||||
|
hAlignmentBox.currentIndex = 1;
|
||||||
|
slideEditor.hTextAlignment = Text.AlignHCenter;
|
||||||
|
break;
|
||||||
|
case "right" :
|
||||||
|
hAlignmentBox.currentIndex = 2;
|
||||||
|
slideEditor.hTextAlignment = Text.AlignRight;
|
||||||
|
break;
|
||||||
|
case "justify" :
|
||||||
|
hAlignmentBox.currentIndex = 3;
|
||||||
|
slideEditor.hTextAlignment = Text.AlignJustify;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeSlideVAlignment(alignment) {
|
||||||
|
print("AHHHHHHHHHHH")
|
||||||
|
switch (alignment) {
|
||||||
|
case "top" :
|
||||||
|
vAlignmentBox.currentIndex = 0;
|
||||||
|
slideEditor.vTextAlignment = Text.AlignBottom;
|
||||||
|
break;
|
||||||
|
case "center" :
|
||||||
|
vAlignmentBox.currentIndex = 1;
|
||||||
|
slideEditor.vTextAlignment = Text.AlignVCenter;
|
||||||
|
break;
|
||||||
|
case "bottom" :
|
||||||
|
vAlignmentBox.currentIndex = 2;
|
||||||
|
slideEditor.vTextAlignment = Text.AlignBottom;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,8 @@ static void createTable()
|
||||||
" 'vorder' TEXT,"
|
" 'vorder' TEXT,"
|
||||||
" 'background' TEXT,"
|
" 'background' TEXT,"
|
||||||
" 'backgroundType' TEXT,"
|
" 'backgroundType' TEXT,"
|
||||||
" 'textAlignment' TEXT,"
|
" 'horizontalTextAlignment' TEXT,"
|
||||||
|
" 'verticalTextAlignment' TEXT,"
|
||||||
" PRIMARY KEY(id))")) {
|
" PRIMARY KEY(id))")) {
|
||||||
qFatal("Failed to query database: %s",
|
qFatal("Failed to query database: %s",
|
||||||
qPrintable(query.lastError().text()));
|
qPrintable(query.lastError().text()));
|
||||||
|
@ -44,16 +45,16 @@ static void createTable()
|
||||||
|
|
||||||
query.exec(
|
query.exec(
|
||||||
"INSERT INTO songs (title, lyrics, author, ccli, audio, vorder, "
|
"INSERT INTO songs (title, lyrics, author, ccli, audio, vorder, "
|
||||||
"background, backgroundType, textAlignment) VALUES ('10,000 Reasons', '10,000 reasons "
|
"background, backgroundType, horizontalTextAlignment, verticalTextAlignment) VALUES ('10,000 Reasons', '10,000 reasons "
|
||||||
"for my heart to sing', 'Matt Redman', '13470183', '', '', '', '', 'center')");
|
"for my heart to sing', 'Matt Redman', '13470183', '', '', '', '', 'center', 'center')");
|
||||||
// qDebug() << query.lastQuery();
|
// qDebug() << query.lastQuery();
|
||||||
query.exec("INSERT INTO songs (title, lyrics, author, ccli, audio, vorder, "
|
query.exec("INSERT INTO songs (title, lyrics, author, ccli, audio, vorder, "
|
||||||
"background, backgroundType, textAlignment) VALUES ('River', 'Im going down to "
|
"background, backgroundType, horizontalTextAlignment, verticalTextAlignment) VALUES ('River', 'Im going down to "
|
||||||
"the river', 'Jordan Feliz', '13470183', '', '', '', '', 'center')");
|
"the river', 'Jordan Feliz', '13470183', '', '', '', '', 'center', 'center')");
|
||||||
query.exec(
|
query.exec(
|
||||||
"INSERT INTO songs (title, lyrics, author, ccli, audio, vorder, "
|
"INSERT INTO songs (title, lyrics, author, ccli, audio, vorder, "
|
||||||
"background, backgroundType, textAlignment) VALUES ('Marvelous Light', 'Into marvelous "
|
"background, backgroundType, horizontalTextAlignment, verticalTextAlignment) VALUES ('Marvelous Light', 'Into marvelous "
|
||||||
"light Im running', 'Chris Tomlin', '13470183', '', '', '', '', 'center')");
|
"light Im running', 'Chris Tomlin', '13470183', '', '', '', '', 'center', 'center')");
|
||||||
|
|
||||||
// qDebug() << query.lastQuery();
|
// qDebug() << query.lastQuery();
|
||||||
query.exec("select * from songs");
|
query.exec("select * from songs");
|
||||||
|
@ -94,7 +95,8 @@ QHash<int, QByteArray> SongSqlModel::roleNames() const
|
||||||
names[Qt::UserRole + 6] = "vorder";
|
names[Qt::UserRole + 6] = "vorder";
|
||||||
names[Qt::UserRole + 7] = "background";
|
names[Qt::UserRole + 7] = "background";
|
||||||
names[Qt::UserRole + 8] = "backgroundType";
|
names[Qt::UserRole + 8] = "backgroundType";
|
||||||
names[Qt::UserRole + 9] = "textAlignment";
|
names[Qt::UserRole + 9] = "horizontalTextAlignment";
|
||||||
|
names[Qt::UserRole + 10] = "verticalTextAlignment";
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +142,7 @@ QVariantMap SongSqlModel::getSong(const int &row) {
|
||||||
// song.append(recordData.value("vorder"));
|
// song.append(recordData.value("vorder"));
|
||||||
// song.append(recordData.value("background"));
|
// song.append(recordData.value("background"));
|
||||||
// song.append(recordData.value("backgroundType"));
|
// song.append(recordData.value("backgroundType"));
|
||||||
// song.append(recordData.value("textAlignment"));
|
// song.append(recordData.value("horizontalTextAlignment"));
|
||||||
|
|
||||||
// return song;
|
// return song;
|
||||||
|
|
||||||
|
@ -432,28 +434,54 @@ void SongSqlModel::updateBackgroundType(const int &row, const QString &backgroun
|
||||||
emit backgroundTypeChanged();
|
emit backgroundTypeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SongSqlModel::textAlignment() const {
|
QString SongSqlModel::horizontalTextAlignment() const {
|
||||||
return m_textAlignment;
|
return m_horizontalTextAlignment;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SongSqlModel::setTextAlignment(const QString &textAlignment) {
|
void SongSqlModel::setHorizontalTextAlignment(const QString &horizontalTextAlignment) {
|
||||||
if (textAlignment == m_textAlignment)
|
if (horizontalTextAlignment == m_horizontalTextAlignment)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_textAlignment = textAlignment;
|
m_horizontalTextAlignment = horizontalTextAlignment;
|
||||||
|
|
||||||
select();
|
select();
|
||||||
emit textAlignmentChanged();
|
emit horizontalTextAlignmentChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is for updating the lyrics from outside the delegate
|
// This function is for updating the lyrics from outside the delegate
|
||||||
void SongSqlModel::updateTextAlignment(const int &row, const QString &textAlignment) {
|
void SongSqlModel::updateHorizontalTextAlignment(const int &row, const QString &horizontalTextAlignment) {
|
||||||
qDebug() << "Row is " << row;
|
qDebug() << "Row is " << row;
|
||||||
QSqlRecord rowdata = record(row);
|
QSqlRecord rowdata = record(row);
|
||||||
qDebug() << rowdata;
|
qDebug() << rowdata;
|
||||||
rowdata.setValue("textAlignment", textAlignment);
|
rowdata.setValue("horizontalTextAlignment", horizontalTextAlignment);
|
||||||
setRecord(row, rowdata);
|
setRecord(row, rowdata);
|
||||||
qDebug() << rowdata;
|
qDebug() << rowdata;
|
||||||
submitAll();
|
submitAll();
|
||||||
emit textAlignmentChanged();
|
emit horizontalTextAlignmentChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SongSqlModel::verticalTextAlignment() const {
|
||||||
|
return m_verticalTextAlignment;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SongSqlModel::setVerticalTextAlignment(const QString &verticalTextAlignment) {
|
||||||
|
if (verticalTextAlignment == m_verticalTextAlignment)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_verticalTextAlignment = verticalTextAlignment;
|
||||||
|
|
||||||
|
select();
|
||||||
|
emit verticalTextAlignmentChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
// This function is for updating the lyrics from outside the delegate
|
||||||
|
void SongSqlModel::updateVerticalTextAlignment(const int &row, const QString &verticalTextAlignment) {
|
||||||
|
qDebug() << "Row is " << row;
|
||||||
|
QSqlRecord rowdata = record(row);
|
||||||
|
qDebug() << rowdata;
|
||||||
|
rowdata.setValue("verticalTextAlignment", verticalTextAlignment);
|
||||||
|
setRecord(row, rowdata);
|
||||||
|
qDebug() << rowdata;
|
||||||
|
submitAll();
|
||||||
|
emit verticalTextAlignmentChanged();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,8 @@ class SongSqlModel : public QSqlTableModel
|
||||||
Q_PROPERTY(QString vorder READ vorder WRITE setVerseOrder NOTIFY vorderChanged)
|
Q_PROPERTY(QString vorder READ vorder WRITE setVerseOrder NOTIFY vorderChanged)
|
||||||
Q_PROPERTY(QString background READ background WRITE setBackground NOTIFY backgroundChanged)
|
Q_PROPERTY(QString background READ background WRITE setBackground NOTIFY backgroundChanged)
|
||||||
Q_PROPERTY(QString backgroundType READ backgroundType WRITE setBackgroundType NOTIFY backgroundTypeChanged)
|
Q_PROPERTY(QString backgroundType READ backgroundType WRITE setBackgroundType NOTIFY backgroundTypeChanged)
|
||||||
Q_PROPERTY(QString textAlignment READ textAlignment WRITE setTextAlignment NOTIFY textAlignmentChanged)
|
Q_PROPERTY(QString horizontalTextAlignment READ horizontalTextAlignment WRITE setHorizontalTextAlignment NOTIFY horizontalTextAlignmentChanged)
|
||||||
|
Q_PROPERTY(QString verticalTextAlignment READ verticalTextAlignment WRITE setVerticalTextAlignment NOTIFY verticalTextAlignmentChanged)
|
||||||
QML_ELEMENT
|
QML_ELEMENT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -33,7 +34,8 @@ public:
|
||||||
QString vorder() const;
|
QString vorder() const;
|
||||||
QString background() const;
|
QString background() const;
|
||||||
QString backgroundType() const;
|
QString backgroundType() const;
|
||||||
QString textAlignment() const;
|
QString horizontalTextAlignment() const;
|
||||||
|
QString verticalTextAlignment() const;
|
||||||
|
|
||||||
void setTitle(const QString &title);
|
void setTitle(const QString &title);
|
||||||
void setLyrics(const QString &lyrics);
|
void setLyrics(const QString &lyrics);
|
||||||
|
@ -43,7 +45,8 @@ public:
|
||||||
void setVerseOrder(const QString &vorder);
|
void setVerseOrder(const QString &vorder);
|
||||||
void setBackground(const QString &background);
|
void setBackground(const QString &background);
|
||||||
void setBackgroundType(const QString &backgroundType);
|
void setBackgroundType(const QString &backgroundType);
|
||||||
void setTextAlignment(const QString &background);
|
void setHorizontalTextAlignment(const QString &background);
|
||||||
|
void setVerticalTextAlignment(const QString &background);
|
||||||
|
|
||||||
Q_INVOKABLE void updateTitle(const int &row, const QString &title);
|
Q_INVOKABLE void updateTitle(const int &row, const QString &title);
|
||||||
Q_INVOKABLE void updateLyrics(const int &row, const QString &lyrics);
|
Q_INVOKABLE void updateLyrics(const int &row, const QString &lyrics);
|
||||||
|
@ -53,7 +56,8 @@ public:
|
||||||
Q_INVOKABLE void updateVerseOrder(const int &row, const QString &vorder);
|
Q_INVOKABLE void updateVerseOrder(const int &row, const QString &vorder);
|
||||||
Q_INVOKABLE void updateBackground(const int &row, const QString &background);
|
Q_INVOKABLE void updateBackground(const int &row, const QString &background);
|
||||||
Q_INVOKABLE void updateBackgroundType(const int &row, const QString &backgroundType);
|
Q_INVOKABLE void updateBackgroundType(const int &row, const QString &backgroundType);
|
||||||
Q_INVOKABLE void updateTextAlignment(const int &row, const QString &textAlignment);
|
Q_INVOKABLE void updateHorizontalTextAlignment(const int &row, const QString &horizontalTextAlignment);
|
||||||
|
Q_INVOKABLE void updateVerticalTextAlignment(const int &row, const QString &horizontalTextAlignment);
|
||||||
|
|
||||||
Q_INVOKABLE void newSong();
|
Q_INVOKABLE void newSong();
|
||||||
Q_INVOKABLE void deleteSong(const int &row);
|
Q_INVOKABLE void deleteSong(const int &row);
|
||||||
|
@ -72,7 +76,8 @@ signals:
|
||||||
void vorderChanged();
|
void vorderChanged();
|
||||||
void backgroundChanged();
|
void backgroundChanged();
|
||||||
void backgroundTypeChanged();
|
void backgroundTypeChanged();
|
||||||
void textAlignmentChanged();
|
void horizontalTextAlignmentChanged();
|
||||||
|
void verticalTextAlignmentChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_id;
|
int m_id;
|
||||||
|
@ -84,7 +89,8 @@ private:
|
||||||
QString m_vorder;
|
QString m_vorder;
|
||||||
QString m_background;
|
QString m_background;
|
||||||
QString m_backgroundType;
|
QString m_backgroundType;
|
||||||
QString m_textAlignment;
|
QString m_horizontalTextAlignment;
|
||||||
|
QString m_verticalTextAlignment;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //SONGSQLMODEL_H
|
#endif //SONGSQLMODEL_H
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue