-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathOpenRGBBridge.qml
516 lines (507 loc) · 26.4 KB
/
OpenRGBBridge.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
Item {
anchors.fill : parent
property var selectedDevices: []
property var deviceList: []
Component.onCompleted: {
useCustomPort.checked = service.getSetting("General", "UseCustomPort") === "true"
customPortContainer.active = useCustomPort.checked
try {
selectedDevices = JSON.parse(service.getSetting("General", "SelectedDevices"));
} catch (e) {
selectedDevices = [];
}
if (useCustomPort.checked)
{
customPortContainer.item.children[0].text = service.getSetting("General", "CustomPort") || "9730"
}
sdkServerIP.text = service.getSetting("General", "SDKServerIP") || "127.0.0.1"
sdkServerPort.text = service.getSetting("General", "SDKServerPort") || "6742"
if (sdkServerIP.text !== "" && sdkServerPort.text !== "")
{
connectButton.clicked();
}
}
Connections {
target: useCustomPort
function onCheckedChanged()
{
service.saveSetting("General", "UseCustomPort", useCustomPort.checked.toString())
if (useCustomPort.checked)
{
customPortContainer.item.children[0].onTextEdited.connect(onCustomPortTextEdited)
}
}
}
function onCustomPortTextEdited()
{
if (useCustomPort.checked)
{
service.saveSetting("General", "CustomPort", customPortContainer.item.children[0].text)
}
}
Connections {
target : sdkServerIP
function onTextEdited()
{
service.saveSetting("General", "SDKServerIP", sdkServerIP.text)
}
}
Connections {
target : sdkServerPort
function onTextEdited()
{
service.saveSetting("General", "SDKServerPort", sdkServerPort.text)
}
}
Flickable {
anchors.fill: parent
contentHeight: headerColumn.height
ScrollBar.vertical: ScrollBar {
id: controllerListScrollBar
anchors.right: parent.right
width: 10
visible: true //parent.height < parent.contentHeight
policy: ScrollBar.AlwaysOn
height: parent.availableHeight
contentItem: Rectangle {
radius: parent.width / 2
color: theme.scrollBar
}
}
Column {
id : headerColumn
y : 0
width : parent.width - 20
spacing : 0
Text {
color : theme.primarytextcolor
text : "This plugin allows you to control devices that may be supported by OpenRGB but not by SignalRGB right now and sync them with your current layout and effects."
font.pixelSize : 16
font.family : "Poppins"
font.bold : false
bottomPadding : 10
width : parent.width
wrapMode : Text.WordWrap
}
Text {
color : theme.primarytextcolor
text : 'To make this plugin work make sure you have OpenRGB installed and running on your system. You can download it from the <html><a href="https://openrgb.org/">official website</a></html>. Don\'t forget to start the SDK server by goind to the SDK server tab and clicking on "Start Server". Then under The Settings tab in "General Settings" make sure to enable "Start at login", "Start Minimized" and "Start Server". And make sure the device you want to controll is supported by OpenRGB. For further led position customization you can install the OpenRGB Visual Map Plugin and use it to customize the led position in 2d space to match the real position of your leds of your devices.'
font.pixelSize : 13
font.family : "Poppins"
font.bold : false
bottomPadding : 10
width : parent.width
wrapMode : Text.WordWrap
onLinkActivated : Qt.openUrlExternally('https://openrgb.org')
}
Text {
color : theme.primarytextcolor
text : 'You also need to download an intermediate server binary <html><a href="https://github.com/Fefedu973/SignalRGB-To-OpenRGB-Bridge">here</a></html> or if you prefer install node.js and download the bare node.js file and run it using the following command: "node server.js." If you use the EXE file it will be automatically runned on windows startup the next time (you can disable this behavior by adding "--no-startup" to the filename)."'
font.pixelSize : 13
font.family : "Poppins"
font.bold : false
bottomPadding : 10
width : parent.width
wrapMode : Text.WordWrap
onLinkActivated : Qt.openUrlExternally('https://github.com/Fefedu973/SignalRGB-To-OpenRGB-Bridge')
}
Text {
color : theme.primarytextcolor
text : 'The intermediate server will be running on port 9730 by default, if you want to change the port you can do that by modifying the server.js file directly or by renameing your js/exe file by adding "--port=${THE PORT YOU WANT}" depending on what file you picked. You can also show the console window if you want by adding "--console" to the filename. And then don\'t forget to tick the "Use a custom port for the intermediate server" checkbox and enter the port you choosed in the input that will appear.'
font.pixelSize : 13
font.family : "Poppins"
font.bold : false
bottomPadding : 10
width : parent.width
wrapMode : Text.WordWrap
}
Text {
color : theme.primarytextcolor
text : 'Then after everything is up and running you can connect to the OpenRGB SDK server by entering the Ip and the Port displayed in the OpenRGB SDK server tab (it should be "127.0.0.1" and "9730" by default) and clicking on "Connect". Then you can select the devices you want to control that are not directly supported by SignalRGB. Thoses devices will be synced with your current layout and effects and will automatically be added on next signalRGB startup.'
font.pixelSize : 13
font.family : "Poppins"
font.bold : false
bottomPadding : 10
width : parent.width
wrapMode : Text.WordWrap
}
Text {
color : theme.primarytextcolor
text : 'Make sure to configure averything in OpenRGB before connecting your devices. If new devices are discovered/added or if their order is modified in OpenRGB in the future you will need to reconnect to Click on the "Delete All" button to remove all the devices and reconnect each device one by one to make them work again.'
font.pixelSize : 13
font.family : "Poppins"
font.bold : false
bottomPadding : 10
width : parent.width
wrapMode : Text.WordWrap
}
Text {
color : theme.primarytextcolor
text : 'Use a custom port for the intermediate server (default is 9730):'
font.pixelSize : 15
font.family : "Poppins"
font.bold : true
topPadding : 10
width : parent.width
wrapMode : Text.WordWrap
}
Row {
bottomPadding : 10
spacing : 5
CheckBox {
id : useCustomPort
checked : false
onCheckedChanged: {
if (checked) {
customPortContainer.active = true
} else {
customPortContainer.active = false
}
}
}
Loader {
id : customPortContainer
active : false
sourceComponent : Component {
Rectangle {
x : 0
y : 9
width : 60
height : 30
radius : 2
border.color : "#444444"
border.width : 2
color : "#141414"
id : customPort
TextField {
width : 50
leftPadding : 0
rightPadding : 10
x : 10
y : -5
color : theme.primarytextcolor
font.family : "Poppins"
font.bold : true
font.pixelSize : 16
verticalAlignment : TextInput.AlignVCenter
placeholderText : "9730"
validator : RegularExpressionValidator {
regularExpression : /^([0-9]{1,4})$/
}
background : Item {
width : parent.width
height : parent.height
Rectangle {
color : "transparent"
height : 1
width : parent.width
anchors.bottom : parent.bottom
}
}
}
}
}
}
}
Rectangle {
width : parent.width
height : 1
color : "#444444"
}
Row {
topPadding : 20
spacing : 5
Rectangle {
x : 0
y : 0
width : 200
height : 30
radius : 2
border.color : "#444444"
border.width : 2
color : "#141414"
TextField {
width : 180
leftPadding : 0
rightPadding : 10
id : sdkServerIP
x : 10
y : -5
color : theme.primarytextcolor
font.family : "Poppins"
font.bold : true
font.pixelSize : 16
verticalAlignment : TextInput.AlignVCenter
placeholderText : "SDK Server IP"
validator : RegularExpressionValidator {
regularExpression : /^((?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.){0,3}(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])$/
}
background : Item {
width : parent.width
height : parent.height
Rectangle {
color : "transparent"
height : 1
width : parent.width
anchors.bottom : parent.bottom
}
}
}
}
Rectangle {
x : 0
y : 0
width : 60
height : 30
radius : 2
border.color : "#444444"
border.width : 2
color : "#141414"
TextField {
width : 50
leftPadding : 0
rightPadding : 10
id : sdkServerPort
x : 10
y : -5
color : theme.primarytextcolor
font.family : "Poppins"
font.bold : true
font.pixelSize : 16
verticalAlignment : TextInput.AlignVCenter
placeholderText : "Port"
validator : RegularExpressionValidator {
regularExpression : /^([0-9]{1,4})$/
}
background : Item {
width : parent.width
height : parent.height
Rectangle {
color : "transparent"
height : 1
width : parent.width
anchors.bottom : parent.bottom
}
}
}
}
Item {
Rectangle {
width : 130
height : 30
color : "#009000"
radius : 2
}
width : 135
height : 30
ToolButton {
id: connectButton
height : 30
width : 130
anchors.verticalCenter : parent.verticalCenter
font.family : "Poppins"
font.bold : true
icon.source : "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAV0lEQVQ4jWP8//8/A0UAnwH///3r+P/vXwdevQQMuPv/37+7+AxgItaluMAwMIARGpIdDAwMoVjklaD0PSxyqxkYGSsodsFoNFLBABYC8qsJGcBIaXYGAFjoNxCMz3axAAAAAElFTkSuQmCC"
text : "Connect"
anchors.right : parent.center
onClicked: {
deviceList = []
deviceRepeater.model = deviceList
const xhr = new XMLHttpRequest()
const sdkhost = sdkServerIP.text
const sdkport = sdkServerPort.text
if (useCustomPort.checked)
{
const customport = customPortContainer.item.children[0].text
if (customport.length > 0)
{
xhr.open("GET", `http://localhost:${customport}/connect?host=${sdkhost}&port=${sdkport}`, true)
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200)
{
if (xhr.responseText != "[]") {
let res = JSON.parse(xhr.responseText)
deviceList = res
deviceRepeater.model = deviceList
try {
selectedDevices = JSON.parse(service.getSetting("General", "SelectedDevices"));
} catch (e) {
selectedDevices = [];
}
if (selectedDevices.length > 0)
{
for (var i = 0; i < deviceRepeater.count; i++) {
for (var j = 0; j < selectedDevices.length; j++) {
if (deviceRepeater.itemAt(i).deviceId == selectedDevices[j].deviceId)
{
deviceRepeater.itemAt(i).color = "#209e20"
}
}
}
}
service.log(selectedDevices)
discovery.connect(selectedDevices)
}
}
}
xhr.send()
return
}
}
xhr.open("GET", `http://localhost:9730/connect?host=${sdkhost}&port=${sdkport}`, true)
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200)
{
if (xhr.responseText != "[]") {
let res = JSON.parse(xhr.responseText)
deviceList = res
deviceRepeater.model = deviceList
try {
selectedDevices = JSON.parse(service.getSetting("General", "SelectedDevices"));
} catch (e) {
selectedDevices = [];
}
if (selectedDevices.length > 0)
{
for (var i = 0; i < deviceRepeater.count; i++) {
for (var j = 0; j < selectedDevices.length; j++) {
if (deviceRepeater.itemAt(i).deviceId == selectedDevices[j].deviceId)
{
deviceRepeater.itemAt(i).color = "#209e20"
}
}
}
}
service.log(selectedDevices)
discovery.connect(selectedDevices)
}
}
}
xhr.send()
}
}
}
//add a red button to delete all the
Item {
Rectangle {
width : 130
height : 30
color : "#900000"
radius : 2
}
width : 90
height : 30
ToolButton {
id: deleteAllButton
height : 30
width : 130
anchors.verticalCenter : parent.verticalCenter
font.family : "Poppins"
font.bold : true
icon.source : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAWQklEQVR4Xu1djbEctw2WKkhUgU8VJK4gzxUkriDnChJVELuCqIMoFdgd+LmC2BX4uQKrAwXw7I2f5bvjEtyPxM+3M280o9vlgh+AjyAJcF++4EUEiEBZBF6W7Tk7TgSIwAsSAI2ACBRGgARQWPnsOhEgAdAGiEBhBEgAhZXPrhMBEgBtgAg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LwyhGAdhqQQnoxRHUuzQn4/pplbs6lK+saAay4VC6V7yoJBJBPSVPXJk4g8LpTukFyTGu2KgEcXUTyscJ+s6q9OZYarzo/ynj3Go06v04Hvrk8EEQ+JU1N4kKM/L9AYSnq2gu61/uqEgCiIOiajh83g1WnhxnugHEpCahslO/Fi3KFQL+Q3oDxhH108gp8WJyKCV6uEKgyAczc4y7mR2G7253LEbanzwSvGgEgCoIy2EPlPpQrBKocAZAAKrv69b7vzuPIBF3VCACVSJLJNqr1hQRQReOTD+OoAmv0fnYXJEXvcOUpwIpU3Az2krkPu1OlM4FQdQqATAfOZB+V+lIuDbhsBKAdl2nAzGq3So4Usa8lcwCqEwB3AiK6Kkbm7gNTMGLMb7XkFGCLAHQagKgpn69FvnEEgbsFUiMNR3i2LAFsJHCSf3UqwKsmAqWdv/QU4GLv2/n3Hqr0arrgul4/yqt15f9pnQjr31w6AngO/5YboAlCGhXwyouAOr7u+V89syFvt6/3jATwES7bF2eUBPTvD/I3++SeajaI7q+O8D/Jnzq8njpEx3+GOAkAbX5snwg4RoAE4Fg5FI0IoBEgAaARZvtEwDECJADHyqFoRACNAAkAjTDbJwKOESABOFYORSMCaARIAGiE2T4RcIwACcCxcigaEUAjQAJAI8z2iYBjBEgAjpVD0YgAGgESABphtk8EHCNAAnCsHIpGBNAIkADQCLN9IuAYARKAY+VQNCKARoAEgEaY7RMBxwiQABwrh6IRATQCJAA0wmyfCDhGgATgWDkUjQigESABoBFm+0TAMQIkAMfKoWhEAI0ACQCNMNsnAo4RIAE4Vg5FIwJoBEgAaITZPhFwjAAJwLFyKBoRQCNAAkAjzPaJgGME/g/Rs6eXl7u39AAAAABJRU5ErkJggg=="
text : "Delete All"
anchors.right : parent.center
onClicked: {
//delete all the selected devices update the discovery and update the repeater
for (var i = 0; i < deviceRepeater.count; i++) {
service.log(deviceRepeater.itemAt(i).deviceId)
discovery.removedDevices(deviceRepeater.itemAt(i).deviceId)
}
selectedDevices = []
service.saveSetting("General", "SelectedDevices", JSON.stringify(selectedDevices))
deviceList = []
deviceRepeater.model = deviceList
//click the connect button to update the device list
connectButton.clicked()
}
}
}
}
Column {
width : 200
spacing : 5
topPadding : 10
Text {
id: test
color : theme.primarytextcolor
text : "Select the devices you want to control"
font.pixelSize : 16
font.family : "Poppins"
font.bold : false
bottomPadding : 10
width : 400
wrapMode : Text.WordWrap
}
Repeater {
id : deviceRepeater
model : deviceList
Rectangle {
width : 400
height : 30
color : "#212d3a"
radius : 2
property var deviceId: modelData.deviceId
Text {
anchors.centerIn : parent
rightPadding : 10
leftPadding : 10
color : "white"
text : modelData.name
font.pixelSize : 16
font.family : "Poppins"
font.bold : true
width : parent.width
elide : Text.ElideRight
}
MouseArea {
anchors.fill : parent
cursorShape : Qt.PointingHandCursor
hoverEnabled : true
onEntered: {
if (parent.color == "#212d3a")
{
parent.color = "#2e3f4f"
}
}
onExited: {
if (parent.color == "#2e3f4f")
{
parent.color = "#212d3a"
}
}
onClicked: {
try {
selectedDevices = JSON.parse(service.getSetting("General", "SelectedDevices"));
} catch (e) {
selectedDevices = [];
}
if (selectedDevices.length == 0)
{
selectedDevices.push(modelData)
parent.color = "#209e20"
service.saveSetting("General", "SelectedDevices", JSON.stringify(selectedDevices))
} else {
for (var i = 0; i < selectedDevices.length; i++) {
if (selectedDevices[i].deviceId === modelData.deviceId)
{
let deviceIdToRemove = modelData.deviceId
parent.color = "#212d3a";
selectedDevices.splice(i, 1);
service.saveSetting("General", "SelectedDevices", JSON.stringify(selectedDevices))
discovery.removedDevices(deviceIdToRemove);
return
}
}
selectedDevices.push(modelData)
parent.color = "#209e20"
service.saveSetting("General", "SelectedDevices", JSON.stringify(selectedDevices))
}
discovery.connect(selectedDevices);
}
}
}
}
}
}
}
}