Song editor is functional and library adds new songs

This commit is contained in:
Chris Cochrun 2022-02-24 15:20:56 -06:00
parent f755190e40
commit b2ea6ab22a
6 changed files with 240 additions and 29 deletions

View file

@ -103,9 +103,43 @@ Item {
}
}
header: Component {
Kirigami.ActionToolBar {
height: selectedLibrary == "songs" ? 40 : 0
width: parent.width
display: IconOnly
actions: [
Kirigami.Action {
icon.name: "document-new"
text: "New Song"
tooltip: "Add a new song"
onTriggered: songLibraryList.newSong()
},
Kirigami.Action {
displayComponent: Component {
Kirigami.SearchField {
id: searchField
width: parent.width - 40
onAccepted: showPassiveNotification(searchField.text, 3000)
}
}
}
]
Behavior on height {
NumberAnimation {
easing.type: Easing.OutCubic
duration: 300
}
}
}
}
headerPositioning: ListView.OverlayHeader
Component {
id: songDelegate
Kirigami.BasicListItem {
id: songListItem
implicitWidth: ListView.view.width
@ -114,6 +148,15 @@ Item {
label: title
subtitle: author
hoverEnabled: true
ListView.onAdd: {
showPassiveNotification(title, 3000)
songLibraryList.currentIndex = index
song = index
songTitle = title
songLyrics = lyrics
songAuthor = author
songVorder = vorder
}
Behavior on height {
NumberAnimation {
@ -124,6 +167,7 @@ Item {
MouseArea {
id: dragHandler
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
/* width: parent.width */
/* height: parent.height */
/* Layout.alignment: Qt.AlignTop */
@ -139,12 +183,17 @@ Item {
}
}
onClicked: {
showPassiveNotification(title, 3000)
songLibraryList.currentIndex = index
song = index
songTitle = title
songLyrics = lyrics
songAuthor = author
if(mouse.button == Qt.RightButton)
showPassiveNotification("Delete me!");
else{
showPassiveNotification(title, 3000)
songLibraryList.currentIndex = index
song = index
songTitle = title
songLyrics = lyrics
songAuthor = author
songVorder = vorder
}
}
}
@ -176,6 +225,12 @@ Item {
anchors.leftMargin: 10
active: hovered || pressed
}
function newSong() {
songsqlmodel.newSong();
songLibraryList.currentIndex = songsqlmodel.rowCount();
showPassiveNotification("newest song index: " + songLibraryList.currentIndex)
}
}
Rectangle {

View file

@ -17,6 +17,7 @@ Controls.Page {
property string songTitle: ""
property string songLyrics: ""
property string songAuthor: ""
property string songVorder: ""
property int blurRadius: 0
property Item slideItem
@ -145,10 +146,26 @@ Controls.Page {
}
function updateLyrics(lyrics) {
showPassiveNotification("song id " + song);
songsqlmodel.updateLyrics(song, lyrics);
}
songsqlmodel.setLyrics(song, lyrics);
function updateTitle(title) {
songsqlmodel.updateTitle(song, title)
}
showPassiveNotification("did we do it?");
function updateAuthor(author) {
songsqlmodel.updateAuthor(song, author)
}
function updateAudio(audio) {
songsqlmodel.updateAudio(song, audio)
}
function updateCcli(ccli) {
songsqlmodel.updateCcli(song, ccli)
}
function updateVerseOrder(vorder) {
songsqlmodel.updateVerseOrder(song, vorder)
}
}

View file

@ -13,6 +13,7 @@ Item {
Presenter.Slide {
id: representation
textSize: 48
editMode: true
}
}

View file

@ -113,6 +113,20 @@ Item {
placeholderText: "Song Title..."
text: songTitle
padding: 10
onEditingFinished: updateTitle(text);
}
Controls.TextField {
id: songVorderField
Layout.preferredWidth: 300
Layout.fillWidth: true
Layout.leftMargin: 20
Layout.rightMargin: 20
placeholderText: "verse order..."
text: songVorder
padding: 10
onEditingFinished: updateVerseOrder(text);
}
Controls.ScrollView {
@ -126,15 +140,18 @@ Item {
rightPadding: 20
Controls.TextArea {
id: lyricsEditor
width: parent.width
placeholderText: "Put lyrics here..."
persistentSelection: true
text: songLyrics
textFormat: TextEdit.MarkdownText
padding: 10
onEditingFinished: mainPage.updateLyrics(text)
/* onPressed: editorTimer.running = true */
onEditingFinished: {
updateLyrics(text);
editorTimer.running = false;
}
onPressed: editorTimer.running = true
}
}
Controls.TextField {
@ -148,6 +165,7 @@ Item {
placeholderText: "Author..."
text: songAuthor
padding: 10
onEditingFinished: updateAuthor(text)
}
}
@ -182,9 +200,9 @@ Item {
}
Timer {
id: editorTimer
interval: 2000
interval: 1000
repeat: true
running: false
onTriggered: showPassiveNotification("updating song...")
onTriggered: updateLyrics(lyricsEditor.text)
}
}