diff options
Diffstat (limited to 'main.qml')
-rw-r--r-- | main.qml | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/main.qml b/main.qml new file mode 100644 index 0000000..693938e --- /dev/null +++ b/main.qml @@ -0,0 +1,144 @@ +// main.qml +import QtQuick 2.15 +import QtQuick.Controls 1.4 +import QtQuick.Controls 2.15 +import QtQuick.Layouts 1.1 +import QtQuick.Dialogs 1.3 +import QtMultimedia 5.15 +import BassPlayer 0.1 + +ApplicationWindow { + visible: true + width: layout.implicitWidth + height: layout.implicitHeight + + title: "Bass Player!" + + ColumnLayout { + anchors.fill: parent + anchors.margins: 10 + width: 700 + RowLayout { + TableView { + id: songTable + model: song.model + Layout.fillHeight: true + Layout.fillWidth: true + Layout.alignment: Qt.AlignTop + //Layout.minimumWidth: 300 + alternatingRowColors: true + + TableViewColumn { + role: "title" + title: "Title" + } + TableViewColumn { + role: "duration" + title: "Duration" + } + onClicked: { + song.song_selected('song') + } + } + + TableView { + id: songPartTable + model: song.part_model + Layout.fillHeight: true + Layout.fillWidth: true + Layout.alignment: Qt.AlignTop + //Layout.minimumWidth: 300 + alternatingRowColors: true + + TableViewColumn { + role: "name" + title: "Name" + } + TableViewColumn { + role: "from" + title: "From" + } + TableViewColumn { + role: "to" + title: "To" + } + } + } + FileDialog { + id: fileDialog + title: "Select a song" + folder: shortcuts.music + onAccepted: { + audioInterface.source = fileDialog.fileUrl.toString() + durationText.text = song.ms_to_time(audioInterface.duration) + song.add(fileDialog.fileUrl.toString(), audioInterface.duration, audioInterface.metaData) + + } + } + RowLayout { + Slider { + id: slider + from: 0 + to: 1 + value: 0 + Layout.fillWidth: true + } + Text { + id: durationText + text: { '--:--' } + } + } + + RowLayout { + Button { + text: "Add" + onClicked: { + fileDialog.open() + } + } + Button { + text: "Play" + onClicked: { + audioInterface.play() + timer.start() + durationText.text = song.ms_to_time(audioInterface.duration) + } + } + Button { + text: "Stop" + onClicked: { + audioInterface.stop() + timer.restart() + } + } + Button { + text: "Pause" + onClicked: { + audioInterface.pause() + timer.stop() + } + } + } + + } + + SongController { + id: song + title: titleField.text + duration: durationField.text + } + + Audio { + id: audioInterface + audioRole: MusicRole + } + + Timer { + id: timer + running: false + repeat: true + onTriggered: { + slider.value = audioInterface.position / audioInterface.duration + } + } +} |