-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.qml
141 lines (128 loc) · 4.12 KB
/
main.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import QtQuick.Dialogs 1.2
import QtQuick.Controls.Material 2.2
import Jewel.MusicController 1.0
ApplicationWindow {
id: appWindow
visible: true
width: 640
height: 480
title: qsTr("Jewel Tracker Player")
Material.theme: Material.Dark
Material.accent: Material.Purple
Material.primary: Material.Purple
header: ToolBar {
RowLayout {
Layout.alignment: Qt.AlignTop
Layout.fillHeight: false
ToolButton {
anchors.leftMargin: 50
id: openButton
text: "Open"
onClicked: fileDialog.open()
}
Label {
text: "Currently playing:"
}
Label {
id: songName
color: Material.accent
}
}
}
footer: ToolBar {
background: Rectangle {
implicitHeight: 40
color: Material.background
}
RowLayout {
Layout.alignment: Qt.AlignBottom
Layout.fillHeight: false
Label {
text: "Select subsong: "
}
SpinBox {
id: subsongSpinBox
editable: true
}
Label {
text: "Tempo factor: "
}
SpinBox {
id: tempoSpinbox
editable: true
from: 1
value: 100
to: 400
stepSize: 10
property int decimals: 2
property real realValue: value / 100
validator: DoubleValidator {
bottom: Math.min(tempoSpinbox.from, tempoSpinbox.to)
top: Math.max(tempoSpinbox.from, tempoSpinbox.to)
}
textFromValue: function(value, locale) {
return Number(value / 100).toLocaleString(locale, 'f', tempoSpinbox.decimals)
}
valueFromText: function(text, locale) {
return Number.fromLocaleString(locale, text) * 100
}
}
}
}
MusicController {
id: musicController
}
FileDialog {
id: fileDialog
title: "Choose tracker to play"
onAccepted: {
console.log(fileDialog.fileUrl);
musicController.openFile(fileDialog.fileUrl);
songName.text = fileDialog.fileUrl;
subsongSpinBox.value = 0;
subsongSpinBox.to = musicController.getNumSubsongs() - 1;
subsongSpinBox.valueModified.connect(function() {
musicController.selectSubsong(subsongSpinBox.value);
});
tempoSpinbox.value = 100;
tempoSpinbox.valueModified.connect(function () {
musicController.setTempoFactor(tempoSpinbox.value);
});
trackerVisualizer.channelCount = musicController.getNumChannels();
appWindow.width = trackerVisualizer.channelCount * 40;
close();
}
}
ColumnLayout {
id: layout
anchors.fill: parent
RowLayout {
RoundButton {
id: playButton
anchors.left: parent.left
text: musicController.isPlaying ? "Pause" : "Play"
onClicked: musicController.isPlaying ? musicController.pause() : musicController.play()
}
Slider {
id: progressSlider
Layout.fillWidth: true
value: musicController.songPosition
to: musicController.songDuration
onMoved: musicController.setPositionSeconds(value)
}
}
RowLayout {
TrackerVisualizer {
id: trackerVisualizer
Layout.alignment: Layout.Center
model: musicController.currentPatternData
index: musicController.currentRow
onToggleChannel: musicController.toggleChannel(index, isActive);
}
}
}
}