Skip to content

Commit 6b406c0

Browse files
committed
fixup! feat: add sound hardware setting section
1 parent f8d14c3 commit 6b406c0

File tree

4 files changed

+143
-14
lines changed

4 files changed

+143
-14
lines changed

res/qml/Settings/AudioRouter.qml

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ Rectangle {
3434
property var system: new Object()
3535
property bool hasChanges: false
3636

37+
property alias soundApi: soundApiChoice
38+
property alias multiSoundcard: multiSoundcardChoice
39+
property alias keylock: keylockChoice
40+
3741
property var inputs: {
3842
let cards = {}
3943
const hwAlsa = / (\(hw:\d+,\d+\))/;
@@ -214,7 +218,8 @@ Rectangle {
214218
ColumnLayout {
215219
visible: root.mode == AudioRouter.Mode.Advanced
216220
Layout.fillHeight: true
217-
Layout.preferredWidth: 170
221+
Layout.minimumWidth: 200
222+
Layout.maximumWidth: 220
218223
Text {
219224
Layout.alignment: Qt.AlignHCenter
220225
Layout.margins: 15
@@ -301,6 +306,33 @@ Rectangle {
301306
RowLayout {
302307
Layout.topMargin: 6
303308
Layout.bottomMargin: 3
309+
RatioChoice {
310+
id: keylockChoice
311+
normalizedWidth: false
312+
options: [
313+
"soundtouch",
314+
"rubberband R2",
315+
"rubberband R3"
316+
]
317+
tooltips: [
318+
"faster",
319+
"better",
320+
"near-hi-fi quality"
321+
]
322+
323+
onSelectedChanged: {
324+
root.hasChanges = true
325+
}
326+
327+
Mixxx.SettingParameter {
328+
label: "Keylock engine"
329+
}
330+
}
331+
Text {
332+
text: "Keylock engine"
333+
color: "#D9D9D9"
334+
font.pixelSize: 14
335+
}
304336
Item {
305337
Layout.fillWidth: true
306338
}
@@ -319,7 +351,7 @@ Rectangle {
319351
RowLayout {
320352
Layout.bottomMargin: 3
321353
RatioChoice {
322-
id: multiSoundcard
354+
id: multiSoundcardChoice
323355
normalizedWidth: false
324356
options: [
325357
"experimental",
@@ -332,6 +364,10 @@ Rectangle {
332364
"Short delay"
333365
]
334366

367+
onSelectedChanged: {
368+
root.hasChanges = true
369+
}
370+
335371
Mixxx.SettingParameter {
336372
label: "Multi-Soundcard Synchronization"
337373
}
@@ -350,9 +386,13 @@ Rectangle {
350386
font.pixelSize: 14
351387
}
352388
RatioChoice {
353-
id: soundApi
354-
options: Mixxx.SoundManager.getHostAPIList()
355-
selected: Mixxx.SoundManager.getAPI()
389+
id: soundApiChoice
390+
maxWidth: mainCanvas.width / 3
391+
options: []
392+
393+
onSelectedChanged: {
394+
root.hasChanges = true
395+
}
356396

357397
Mixxx.SettingParameter {
358398
label: "Sound API"
@@ -371,7 +411,8 @@ Rectangle {
371411
ColumnLayout {
372412
visible: root.mode != AudioRouter.Mode.Legacy
373413
Layout.fillHeight: true
374-
Layout.preferredWidth: 170
414+
Layout.minimumWidth: 200
415+
Layout.maximumWidth: 220
375416
Text {
376417
Layout.alignment: Qt.AlignHCenter
377418
Layout.margins: 15
@@ -389,7 +430,7 @@ Rectangle {
389430
clip: true
390431
reuseItems: false
391432
spacing: 15
392-
cacheBuffer: contentHeight // Disable lazy loading to make sure all item are loaded and can be bounded to connection
433+
cacheBuffer: Math.max(0, contentHeight) // Disable lazy loading to make sure all item are loaded and can be bounded to connection
393434
delegate: AudioEntity {
394435
id: entity
395436
required property var modelData

res/qml/Settings/RatioChoice.qml

Lines changed: 88 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Item {
1414
property list<var> tooltips: []
1515
property string selected: options.length ? options[0] : null
1616
property real spacing: 9
17+
property real maxWidth: 0
1718
property bool normalizedWidth: true
1819

1920
FontMetrics {
@@ -22,14 +23,15 @@ Item {
2223
font.capitalization: Font.AllUppercase
2324
}
2425

25-
implicitHeight: content.height + dropRatio.radius * 2
26-
implicitWidth: content.width + dropRatio.radius * 2
26+
implicitHeight: (contentList.visible ? contentList.height : contentSpin.height) + dropRatio.radius * 2
27+
implicitWidth: (contentList.visible ? contentList.width : contentSpin.width) + dropRatio.radius * 2
2728
readonly property real cellSize: {
2829
Math.max.apply(null, options.map((option) => fontMetrics.advanceWidth(option))) + root.spacing*2
2930
}
3031

3132
Rectangle {
32-
id: content
33+
id: contentList
34+
visible: root.maxWidth == 0 || root.maxWidth > root.cellSize * root.options.length
3335
anchors.centerIn: parent
3436
height: 24
3537
width: {
@@ -50,7 +52,7 @@ Item {
5052
required property var modelData
5153
color: root.selected == modelData ? '#2D4EA1' : 'transparent'
5254
width: root.normalizedWidth ? root.cellSize : fontMetrics.advanceWidth(modelData) + root.spacing*2
53-
height: content.height
55+
height: contentList.height
5456
radius: height / 2
5557
Text {
5658
text: modelData
@@ -80,14 +82,94 @@ Item {
8082
}
8183
}
8284
}
85+
SpinBox {
86+
id: contentSpin
87+
visible: !contentList.visible
88+
anchors.centerIn: parent
89+
from: 0
90+
spacing: root.spacing
91+
to: root.options.length - 1
92+
font: fontMetrics.font
93+
value: root.options.indexOf(root.selected)
94+
95+
property real textWidth: fontMetrics.advanceWidth(root.options.reduce((accumulator, currentValue) => accumulator.length > currentValue.length ? accumulator : currentValue, ""))
96+
97+
contentItem: Rectangle {
98+
color: '#2D4EA1'
99+
width: contentSpin.textWidth + 2 * contentSpin.spacing
100+
height: 18
101+
z: 2
102+
radius: height / 2
103+
Text {
104+
id: textLabel
105+
anchors.centerIn: parent
106+
text: contentSpin.textFromValue(contentSpin.value, contentSpin.locale)
107+
color: Theme.white
108+
font: contentSpin.font
109+
}
110+
}
111+
112+
component Indicator: Rectangle {
113+
required property string text
114+
height: implicitHeight
115+
implicitWidth: 24
116+
implicitHeight: 24
117+
radius: parent.height / 2
118+
color: '#2B2B2B'
119+
border.width: 0
120+
121+
Text {
122+
text: parent.text
123+
font.pixelSize: contentSpin.font.pixelSize * 2
124+
color: Theme.white
125+
anchors.fill: parent
126+
fontSizeMode: Text.Fit
127+
horizontalAlignment: Text.AlignHCenter
128+
verticalAlignment: Text.AlignVCenter
129+
}
130+
}
131+
132+
up.indicator: Indicator {
133+
x: contentSpin.mirrored ? 0 : parent.width - width
134+
text: ">"
135+
}
136+
137+
down.indicator: Indicator {
138+
x: contentSpin.mirrored ? parent.width - width : 0
139+
text: "<"
140+
}
141+
142+
background: Rectangle {
143+
implicitWidth: contentSpin.textWidth + 2 * contentSpin.spacing + 48
144+
radius: parent.height / 2
145+
color: '#2B2B2B'
146+
}
147+
148+
textFromValue: function(value) {
149+
return root.options[value];
150+
}
151+
152+
valueFromText: function(text) {
153+
for (var i = 0; i < root.options.length; ++i) {
154+
if (root.options[i].toLowerCase().indexOf(text.toLowerCase()) === 0)
155+
return i
156+
}
157+
return contentSpin.value
158+
}
159+
160+
onValueChanged: {
161+
root.selected = contentSpin.textFromValue(value)
162+
}
163+
}
83164
DropShadow {
84165
id: dropRatio
85-
anchors.fill: content
166+
anchors.margins: dropRatio.radius
167+
anchors.fill: root
86168
horizontalOffset: 0
87169
verticalOffset: 0
88170
radius: 4.0
89171
color: "#80000000"
90-
source: content
172+
source: contentList.visible ? contentList : contentSpin
91173
}
92174
Popup {
93175
id: popup

res/qml/Settings/SoundHardware.qml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Mixxx.SettingGroup {
5757
function save() {
5858
const manager = Mixxx.SoundManager;
5959
mainEnabled.value = mainMixEnabled.options.indexOf(mainMixEnabled.selected)
60-
monoMix.value = mainOutputMode.options.indexOf(mainOutputMode.selected)
60+
monoMix.value = !mainOutputMode.options.indexOf(mainOutputMode.selected)
6161
manager.setForceNetworkClock(soundClock.options[1] == soundClock.selected)
6262
manager.setSampleRate(parseInt(sampleRate.selected))
6363
manager.setAudioBufferSizeIndex(audioBuffer.currentIndex + 1)
@@ -122,6 +122,10 @@ Mixxx.SettingGroup {
122122
microphoneMonitorMode.currentIndex = micMonitorMode.value
123123

124124
// Router
125+
router.soundApi.options = manager.getHostAPIList()
126+
router.soundApi.selected = manager.getAPI()
127+
// router.multiSoundcardChoice.selected = manager.getAPI()
128+
// router.keylockChoice.selected = manager.getAPI()
125129
router.loadConnections()
126130

127131
//Delays
@@ -248,6 +252,7 @@ Mixxx.SettingGroup {
248252
RatioChoice {
249253
id: sampleRate
250254
Layout.minimumWidth: sampleRate.implicitWidth
255+
options: []
251256
function update() {
252257
let data = []
253258
for (let sampleRate of Mixxx.SoundManager.getSampleRates()) {

res/qml/main.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ ApplicationWindow {
253253
color: '#000000'
254254
anchors.fill: parent
255255
property real radius: 12
256+
// TODO very costly on weaker machine. Should not be used on those
256257
GaussianBlur {
257258
anchors.fill: parent
258259
source: content

0 commit comments

Comments
 (0)