Skip to content

Commit 73db0ed

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

File tree

10 files changed

+567
-241
lines changed

10 files changed

+567
-241
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4057,6 +4057,10 @@ if(RUBBERBAND)
40574057
find_package(rubberband REQUIRED)
40584058
target_link_libraries(mixxx-lib PRIVATE rubberband::rubberband)
40594059
target_compile_definitions(mixxx-lib PUBLIC __RUBBERBAND__)
4060+
if(QML)
4061+
target_link_libraries(mixxx-qml-lib PRIVATE rubberband::rubberband)
4062+
target_compile_definitions(mixxx-qml-lib PUBLIC __RUBBERBAND__)
4063+
endif()
40604064
target_sources(
40614065
mixxx-lib
40624066
PRIVATE

res/qml/Settings/AudioConnection.qml

Lines changed: 57 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import "../Theme"
55
Item {
66
id: root
77

8+
enum Flags {
9+
AboutToDelete = 1,
10+
CannotConnect = 2
11+
}
12+
813
required property var source
914
required property var router
1015
property var sink: undefined
@@ -13,8 +18,29 @@ Item {
1318
property bool system: false
1419
property bool vertical: false
1520
property bool existing: false
21+
property int flags: 0
22+
23+
readonly property bool ready: !!source && !!sink
24+
25+
visible: !source || !sink || source.visible && sink.visible
26+
27+
z: 0
1628

1729
states: [
30+
State {
31+
name: "warning"
32+
when: root.flags
33+
34+
PropertyChanges {
35+
target: line
36+
strokeColor: Theme.warningColor
37+
}
38+
39+
PropertyChanges {
40+
target: root
41+
z: 50
42+
}
43+
},
1844
State {
1945
name: "system"
2046
when: root.system
@@ -25,29 +51,39 @@ Item {
2551
}
2652
},
2753
State {
28-
name: "setting"
29-
when: root.sink == undefined || root.existing
54+
name: "existing"
55+
when: root.existing
3056

3157
PropertyChanges {
3258
target: line
3359
strokeColor: Theme.midGray
3460
}
61+
62+
PropertyChanges {
63+
target: root
64+
}
3565
},
3666
State {
37-
name: "set"
38-
when: root.sink != undefined && !root.existing
67+
name: "setting"
68+
when: root.sink === undefined
3969

4070
PropertyChanges {
4171
target: line
4272
strokeColor: Theme.accentColor
4373
}
74+
75+
PropertyChanges {
76+
target: root
77+
z: 50
78+
}
4479
},
4580
State {
46-
name: "impossible"
81+
name: "set"
82+
when: root.sink != undefined && !root.existing
4783

4884
PropertyChanges {
4985
target: line
50-
strokeColor: Theme.warningColor
86+
strokeColor: Theme.accentColor
5187
}
5288
}
5389
]
@@ -72,6 +108,13 @@ Item {
72108

73109
onSinkChanged: {
74110
if (sink != null && source != null) {
111+
// swap entities if the connection was made backward
112+
if (source.type !== "source") {
113+
let swap = root.source
114+
root.source = root.sink
115+
root.sink = swap
116+
return;
117+
}
75118
target = null
76119
if (sink.connections !== undefined) {
77120
sink.connections.add(root)
@@ -87,6 +130,13 @@ Item {
87130
}
88131
onSourceChanged: {
89132
if (sink != null && source != null) {
133+
// swap entities if the connection was made backward
134+
if (source.type !== "source") {
135+
let swap = root.source
136+
root.source = root.sink
137+
root.sink = swap
138+
return;
139+
}
90140
target = null
91141
if (sink.connections !== undefined) {
92142
sink.connections.add(root)
@@ -101,8 +151,6 @@ Item {
101151
}
102152
}
103153
onTargetChanged: {
104-
if (!system)
105-
state = "setting"
106154
if (!source)
107155
return
108156
scale.xScale = sourcePosition.x > sinkPosition.x ? -1 : 1
@@ -118,7 +166,7 @@ Item {
118166
layer.textureMirroring: ShaderEffectSource.MirrorHorizontally
119167
ShapePath {
120168
id: line
121-
strokeColor: "#696968"
169+
strokeColor: Theme.midGray
122170
strokeWidth: 2
123171
fillColor: "transparent"
124172
capStyle: ShapePath.RoundCap

res/qml/Settings/AudioEntity.qml

Lines changed: 72 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,15 @@ Item {
1616
required property string name
1717
required property string group
1818
property list<var> gateways: []
19+
property bool advanced: false
1920

2021
implicitHeight: 54 + 32 * gatewayRepeater.visibleChannels
2122
width: 135
23+
z: 10
24+
25+
onGatewaysChanged: {
26+
gatewayRepeater.visibleChannels = root.gateways.length
27+
}
2228

2329
property alias handleSource: handleSourceEdge
2430
property alias handleSink: handleSinkEdge
@@ -31,6 +37,7 @@ Item {
3137
anchors.fill: parent
3238
anchors.margins: 8
3339
Column {
40+
id: gatewayColumn
3441
anchors.fill: parent
3542
padding: 0
3643
spacing: 4
@@ -63,10 +70,12 @@ Item {
6370
readonly property string label: root.gateways[index].name
6471
readonly property string address: root.gateways[index].address || root.gateways[index].name
6572
readonly property var channels: root.gateways[index].channels || [0, 1]
73+
readonly property var instances: root.gateways[index].instances || 1
6674
readonly property string type: root.gateways[index].type
75+
readonly property bool advanced: root.gateways[index].advanced || false
6776
readonly property bool required: !!root.gateways[index].required
6877

69-
model: node.channels.length/2
78+
model: node.channels.length/2 * instances
7079

7180
property list<int> channelAssignation: {
7281
return [...Array(node.channels.length/2)].map((_, i) => i);
@@ -97,7 +106,7 @@ Item {
97106
property alias edgeItem: edge
98107
property bool counted: channel.index == 0
99108

100-
visible: edgeItem.connection || index == node.connectionCount
109+
visible: (edgeItem.connection?.ready || index == node.connectionCount) && (!node.advanced || root.advanced)
101110
onVisibleChanged: {
102111
if (counted != channel.visible)
103112
gatewayRepeater.visibleChannels += channel.visible ? 1 : -1
@@ -119,7 +128,7 @@ Item {
119128
Layout.alignment: Qt.AlignVCenter
120129
Layout.preferredHeight: 28
121130
verticalAlignment: Text.AlignVCenter
122-
text: label
131+
text: node.instances == 1 ? label : `${label} #${index+1}`
123132
color: Theme.white
124133
elide: Text.ElideRight
125134
font.pixelSize: 10
@@ -131,16 +140,16 @@ Item {
131140
Skin.ComboBox {
132141
Layout.minimumWidth: implicitWidth
133142
id: channelSelector
134-
property int previousIndex: node.channelAssignation[channel.index]
135-
visible: node.count > 1
143+
property int previousIndex: node.channelAssignation[channel.index] ?? 0
144+
visible: node.count > 1 && node.channels.length > 2
136145
spacing: 2
137146
clip: true
138147

139148
font.pixelSize: 12
140149
model: {
141150
return [...Array(node.channels.length/2)].map((e, i) => `Ch ${i * 2 + node.channels[0] + 1} - ${i * 2 + node.channels[0] + 2}`);
142151
}
143-
currentIndex: node.channelAssignation[channel.index]
152+
currentIndex: node.channelAssignation[channel.index] ?? 0
144153
onActivated: (activatedIndex) => {
145154
let alreadyAssigned = node.channelAssignation.indexOf(activatedIndex)
146155
node.channelAssignation[alreadyAssigned] = previousIndex
@@ -151,6 +160,7 @@ Item {
151160
Rectangle {
152161
id: edge
153162
property var entity: root
163+
property int instance: index / (node.channels.length/2)
154164
property string type: node.type
155165
property string group: root.group
156166
property var address: node.address
@@ -160,6 +170,7 @@ Item {
160170

161171
property var connection: null
162172
property bool counted: false
173+
property bool connecting: false
163174

164175
onConnectionChanged: {
165176
if (counted != !!edge.connection)
@@ -187,29 +198,77 @@ Item {
187198
edge.updateConnectionPosition()
188199
}
189200
}
190-
color: (edge.connection && edge.connection.state == "impossible" || !edge.connection && node.required) ? '#7D3B3B' : edge.connection ? Theme.white : '#626262'
201+
202+
Connections {
203+
target: channel
204+
function onHeightChanged() {
205+
edge.updateConnectionPosition()
206+
}
207+
function onYChanged() {
208+
edge.updateConnectionPosition()
209+
}
210+
}
211+
212+
color: Theme.midGray
191213
width: 10
192-
height: 10
193-
radius: 5
214+
height: width
215+
radius: width/2
216+
z: 100
217+
218+
states: [
219+
State {
220+
name: "idle"
221+
},
222+
State {
223+
name: "warning"
224+
when: (!edge.connection && node.required) || (edge.connection && edge.connection.state == "warning")
225+
226+
PropertyChanges {
227+
target: edge
228+
width: 15
229+
color: Theme.warningColor
230+
}
231+
},
232+
State {
233+
name: "hidden"
234+
when: edge.connection && !edge.connection.visible
235+
236+
PropertyChanges {
237+
target: channel
238+
opacity: 0.5
239+
}
240+
},
241+
State {
242+
name: "setting"
243+
when: edge.connection && !edge.connection.existing || edge.connecting
244+
245+
PropertyChanges {
246+
target: edge
247+
width: 15
248+
color: Theme.accentColor
249+
}
250+
}
251+
]
194252

195253
MouseArea {
196-
hoverEnabled: edge.connection != null
254+
id: edgeMouseArea
255+
hoverEnabled: edge.connection != null && edge.connection.visible
197256
anchors.fill: parent
198257
onPressed: {
199-
if (edge.connection && edge.connection.state == "impossible") {
258+
if (edge.connection && edge.connection.flags & AudioConnection.Flags.AboutToDelete) {
200259
root.disconnect(edge.connection)
201260
} else if (edge.connection == null) {
202261
root.connect(parent)
203262
}
204263
}
205264
onEntered: {
206265
if (edge.connection) {
207-
edge.connection.state = "impossible"
266+
edge.connection.flags |= AudioConnection.Flags.AboutToDelete
208267
}
209268
}
210269
onExited: {
211270
if (edge.connection) {
212-
edge.connection.state = edge.connection.existing ? "setting" : "set"
271+
edge.connection.flags &= ~AudioConnection.Flags.AboutToDelete
213272
}
214273
}
215274
}

0 commit comments

Comments
 (0)