some changes to songs including attributes

This commit is contained in:
Chris Cochrun 2022-04-22 11:28:50 -05:00
parent 2979b40f5a
commit 5db946ef53
4 changed files with 88 additions and 43 deletions

View file

@ -4,12 +4,12 @@
:END: :END:
* Inbox * Inbox
** TODO Make toolbar functional for songeditor [1/4] [25%] ** TODO Make toolbar functional for songeditor [3/4] [75%]
[[file:~/dev/church-presenter/src/qml/presenter/SongEditor.qml::Controls.ToolBar {]] [[file:~/dev/church-presenter/src/qml/presenter/SongEditor.qml::Controls.ToolBar {]]
- [X] alignment - [X] alignment
- [ ] font - [X] font
- [ ] fontsize - [X] fontsize
- [ ] effects? - [ ] effects?
** TODO bug in changing slides with the arrows ** TODO bug in changing slides with the arrows

View file

@ -10,16 +10,7 @@ Item {
id: root id: root
property int songIndex property int songIndex
property string songTitle property var song
property string songLyrics
property string songAuthor
property string songCcli
property string songAudio
property string songVorder
property string songBackground
property string songBackgroundType
property string songHAlignment
property string songVAlignment
GridLayout { GridLayout {
id: mainLayout id: mainLayout
@ -40,7 +31,7 @@ Item {
implicitWidth: 300 implicitWidth: 300
editable: true editable: true
hoverEnabled: true hoverEnabled: true
/* onCurrentTextChanged: showPassiveNotification(currentText) */ onCurrentTextChanged: showPassiveNotification(currentText)
} }
Controls.SpinBox { Controls.SpinBox {
editable: true editable: true
@ -158,7 +149,7 @@ Item {
Layout.rightMargin: 20 Layout.rightMargin: 20
placeholderText: "Song Title..." placeholderText: "Song Title..."
text: songTitle text: song.title
padding: 10 padding: 10
onEditingFinished: updateTitle(text); onEditingFinished: updateTitle(text);
} }
@ -171,7 +162,7 @@ Item {
Layout.rightMargin: 20 Layout.rightMargin: 20
placeholderText: "verse order..." placeholderText: "verse order..."
text: songVorder text: song.vorder
padding: 10 padding: 10
onEditingFinished: updateVerseOrder(text); onEditingFinished: updateVerseOrder(text);
} }
@ -191,7 +182,7 @@ Item {
width: parent.width width: parent.width
placeholderText: "Put lyrics here..." placeholderText: "Put lyrics here..."
persistentSelection: true persistentSelection: true
text: songLyrics text: song.lyrics
textFormat: TextEdit.PlainText textFormat: TextEdit.PlainText
padding: 10 padding: 10
onEditingFinished: { onEditingFinished: {
@ -210,7 +201,7 @@ Item {
Layout.rightMargin: 20 Layout.rightMargin: 20
placeholderText: "Author..." placeholderText: "Author..."
text: songAuthor text: song.author
padding: 10 padding: 10
onEditingFinished: updateAuthor(text) onEditingFinished: updateAuthor(text)
} }
@ -277,32 +268,20 @@ Item {
} }
function changeSong(index) { function changeSong(index) {
const song = songsqlmodel.getSong(index); song = songsqlmodel.getSong(index);
songIndex = index; songIndex = index;
songTitle = song.title;
songLyrics = song.lyrics;
songAuthor = song.author;
songCcli = song.ccli;
songAudio = song.audio;
songVorder = song.vorder;
songBackground = song.background;
songBackgroundType = song.backgroundType;
songHAlignment = song.horizontalTextAlignment;
songVAlignment = song.verticalTextAlignment;
alignmentSetTimer.restart();
if (songBackgroundType == "image") { if (songBackgroundType == "image") {
slideEditor.videoBackground = ""; slideEditor.videoBackground = "";
slideEditor.imageBackground = songBackground; slideEditor.imageBackground = song.background;
} else { } else {
slideEditor.imageBackground = ""; slideEditor.imageBackground = "";
slideEditor.videoBackground = songBackground; slideEditor.videoBackground = song.background;
slideEditor.loadVideo(); slideEditor.loadVideo();
} }
changeSlideHAlignment(songHAlignment); changeSlideHAlignment(song.horizontalTextAlignment);
changeSlideVAlignment(songVAlignment); changeSlideVAlignment(song.verticalTextAlignment);
print(song); print(song);
} }

View file

@ -36,6 +36,8 @@ static void createTable()
" 'backgroundType' TEXT," " 'backgroundType' TEXT,"
" 'horizontalTextAlignment' TEXT," " 'horizontalTextAlignment' TEXT,"
" 'verticalTextAlignment' TEXT," " 'verticalTextAlignment' TEXT,"
" 'font' TEXT,"
" 'fontSize' INTEGER,"
" 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()));
@ -45,16 +47,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, horizontalTextAlignment, verticalTextAlignment) VALUES ('10,000 Reasons', '10,000 reasons " "background, backgroundType, horizontalTextAlignment, verticalTextAlignment, font, fontSize) VALUES ('10,000 Reasons', '10,000 reasons "
"for my heart to sing', 'Matt Redman', '13470183', '', '', '', '', 'center', '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, horizontalTextAlignment, verticalTextAlignment) VALUES ('River', 'Im going down to " "background, backgroundType, horizontalTextAlignment, verticalTextAlignment, font, fontSize) VALUES ('River', 'Im going down to "
"the river', 'Jordan Feliz', '13470183', '', '', '', '', 'center', '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, horizontalTextAlignment, verticalTextAlignment) VALUES ('Marvelous Light', 'Into marvelous " "background, backgroundType, horizontalTextAlignment, verticalTextAlignment, font, fontSize) VALUES ('Marvelous Light', 'Into marvelous "
"light Im running', 'Chris Tomlin', '13470183', '', '', '', '', 'center', '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");
@ -485,3 +487,55 @@ void SongSqlModel::updateVerticalTextAlignment(const int &row, const QString &ve
submitAll(); submitAll();
emit verticalTextAlignmentChanged(); emit verticalTextAlignmentChanged();
} }
QString SongSqlModel::font() const {
return m_font;
}
void SongSqlModel::setFont(const QString &font) {
if (font == m_font)
return;
m_font = font;
select();
emit fontChanged();
}
// This function is for updating the lyrics from outside the delegate
void SongSqlModel::updateFont(const int &row, const QString &font) {
qDebug() << "Row is " << row;
QSqlRecord rowdata = record(row);
qDebug() << rowdata;
rowdata.setValue("font", font);
setRecord(row, rowdata);
qDebug() << rowdata;
submitAll();
emit fontChanged();
}
int SongSqlModel::fontSize() const {
return m_fontSize;
}
void SongSqlModel::setFontSize(const QString &fontSize) {
if (fontSize == m_fontSize)
return;
m_fontSize = fontSize;
select();
emit fontSizeChanged();
}
// This function is for updating the lyrics from outside the delegate
void SongSqlModel::updateFontSize(const int &row, const QString &fontSize) {
qDebug() << "Row is " << row;
QSqlRecord rowdata = record(row);
qDebug() << rowdata;
rowdata.setValue("fontSize", fontSize);
setRecord(row, rowdata);
qDebug() << rowdata;
submitAll();
emit fontSizeChanged();
}

View file

@ -20,6 +20,8 @@ class SongSqlModel : public QSqlTableModel
Q_PROPERTY(QString backgroundType READ backgroundType WRITE setBackgroundType NOTIFY backgroundTypeChanged) Q_PROPERTY(QString backgroundType READ backgroundType WRITE setBackgroundType NOTIFY backgroundTypeChanged)
Q_PROPERTY(QString horizontalTextAlignment READ horizontalTextAlignment WRITE setHorizontalTextAlignment NOTIFY horizontalTextAlignmentChanged) Q_PROPERTY(QString horizontalTextAlignment READ horizontalTextAlignment WRITE setHorizontalTextAlignment NOTIFY horizontalTextAlignmentChanged)
Q_PROPERTY(QString verticalTextAlignment READ verticalTextAlignment WRITE setVerticalTextAlignment NOTIFY verticalTextAlignmentChanged) Q_PROPERTY(QString verticalTextAlignment READ verticalTextAlignment WRITE setVerticalTextAlignment NOTIFY verticalTextAlignmentChanged)
Q_PROPERTY(QString font READ font WRITE setFont NOTIFY fontChanged)
Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
QML_ELEMENT QML_ELEMENT
public: public:
@ -36,6 +38,8 @@ public:
QString backgroundType() const; QString backgroundType() const;
QString horizontalTextAlignment() const; QString horizontalTextAlignment() const;
QString verticalTextAlignment() const; QString verticalTextAlignment() const;
QString font() const;
int fontSize() const;
void setTitle(const QString &title); void setTitle(const QString &title);
void setLyrics(const QString &lyrics); void setLyrics(const QString &lyrics);
@ -45,8 +49,10 @@ 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 setHorizontalTextAlignment(const QString &background); void setHorizontalTextAlignment(const QString &horizontalTextAlignment);
void setVerticalTextAlignment(const QString &background); void setVerticalTextAlignment(const QString &verticalTextAlignment);
void setFont(const QString &font);
void setFontSize(const int &fontSize);
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);
@ -58,6 +64,8 @@ public:
Q_INVOKABLE void updateBackgroundType(const int &row, const QString &backgroundType); Q_INVOKABLE void updateBackgroundType(const int &row, const QString &backgroundType);
Q_INVOKABLE void updateHorizontalTextAlignment(const int &row, const QString &horizontalTextAlignment); Q_INVOKABLE void updateHorizontalTextAlignment(const int &row, const QString &horizontalTextAlignment);
Q_INVOKABLE void updateVerticalTextAlignment(const int &row, const QString &horizontalTextAlignment); Q_INVOKABLE void updateVerticalTextAlignment(const int &row, const QString &horizontalTextAlignment);
Q_INVOKABLE void updateFont(const int &row, const QString &font);
Q_INVOKABLE void updateFontSize(const int &row, const int &fontSize);
Q_INVOKABLE void newSong(); Q_INVOKABLE void newSong();
Q_INVOKABLE void deleteSong(const int &row); Q_INVOKABLE void deleteSong(const int &row);
@ -78,6 +86,8 @@ signals:
void backgroundTypeChanged(); void backgroundTypeChanged();
void horizontalTextAlignmentChanged(); void horizontalTextAlignmentChanged();
void verticalTextAlignmentChanged(); void verticalTextAlignmentChanged();
void fontChanged();
void fontSizeChanged();
private: private:
int m_id; int m_id;
@ -91,6 +101,8 @@ private:
QString m_backgroundType; QString m_backgroundType;
QString m_horizontalTextAlignment; QString m_horizontalTextAlignment;
QString m_verticalTextAlignment; QString m_verticalTextAlignment;
QString m_font;
int m_fontSize;
}; };
#endif //SONGSQLMODEL_H #endif //SONGSQLMODEL_H