adding an audio picker for songs

This commit is contained in:
Chris Cochrun 2022-09-22 05:59:21 -05:00
parent 7916427442
commit a8943b86cf

View file

@ -163,7 +163,7 @@ Item {
Controls.TextField { Controls.TextField {
id: songVorderField id: songVorderField
Layout.preferredWidth: 300 /* Layout.preferredWidth: 300 */
Layout.fillWidth: true Layout.fillWidth: true
Layout.leftMargin: 20 Layout.leftMargin: 20
Layout.rightMargin: 20 Layout.rightMargin: 20
@ -177,7 +177,7 @@ Item {
Controls.ScrollView { Controls.ScrollView {
id: songLyricsField id: songLyricsField
Layout.preferredHeight: 3000 Layout.preferredHeight: 2000
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
Layout.leftMargin: 20 Layout.leftMargin: 20
@ -213,7 +213,32 @@ Item {
onEditingFinished: updateAuthor(text) onEditingFinished: updateAuthor(text)
} }
RowLayout {
Layout.fillWidth: true
Layout.preferredWidth: 300
Layout.leftMargin: 20
Layout.rightMargin: 20
Controls.TextField {
id: songAudioField
Layout.fillWidth: true
placeholderText: "Audio File..."
text: song.audio
padding: 10
onEditingFinished: showPassiveNotification(text)
} }
Controls.ToolButton {
id: audioPickerButton
Layout.fillHeight: true
text: "Audio"
icon.name: "folder-music-symbolic"
onClicked: audioFileDialog.open()
}
}
}
ColumnLayout { ColumnLayout {
Controls.SplitView.fillHeight: true Controls.SplitView.fillHeight: true
Controls.SplitView.preferredWidth: 700 Controls.SplitView.preferredWidth: 700
@ -245,6 +270,22 @@ Item {
} }
} }
FileDialog {
id: audioFileDialog
title: "Please choose an audio file"
folder: shortcuts.home
selectMultiple: false
nameFilters: ["Audio files (*.mp3 *.flac *.wav *.opus *.MP3 *.FLAC *.WAV *.OPUS)"]
onAccepted: {
updateAudioFile(audioFileDialog.fileUrls[0]);
print("audio = " + audioFileDialog.fileUrls[0]);
}
onRejected: {
print("Canceled")
}
}
FileDialog { FileDialog {
id: videoFileDialog id: videoFileDialog
title: "Please choose a background" title: "Please choose a background"
@ -328,6 +369,10 @@ Item {
songsqlmodel.updateVerseOrder(songIndex, vorder) songsqlmodel.updateVerseOrder(songIndex, vorder)
} }
function updateAudioFile(file) {
songsqlmodel.updateAudio(songIndex, file);
}
function updateBackground(background, backgroundType) { function updateBackground(background, backgroundType) {
song.backgroundType = backgroundType; song.backgroundType = backgroundType;
song.background = background; song.background = background;