Skip to content

Commit 6b9a97f

Browse files
Add settings page for configuring E1.31 devices
1 parent 156ebbc commit 6b9a97f

10 files changed

+752
-68
lines changed

Controllers/E131Controller/E131ControllerDetect.cpp

+77-68
Original file line numberDiff line numberDiff line change
@@ -87,39 +87,42 @@ void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers)
8787

8888
if(e131_settings["devices"][device_idx].contains("matrix_order"))
8989
{
90-
std::string matrix_order_val = e131_settings["devices"][device_idx]["matrix_order"];
91-
92-
if(matrix_order_val == "HORIZONTAL_TOP_LEFT")
93-
{
94-
dev.matrix_order = E131_MATRIX_ORDER_HORIZONTAL_TOP_LEFT;
95-
}
96-
else if(matrix_order_val == "HORIZONTAL_TOP_RIGHT")
97-
{
98-
dev.matrix_order = E131_MATRIX_ORDER_HORIZONTAL_TOP_RIGHT;
99-
}
100-
else if(matrix_order_val == "HORIZONTAL_BOTTOM_LEFT")
101-
{
102-
dev.matrix_order = E131_MATRIX_ORDER_HORIZONTAL_BOTTOM_LEFT;
103-
}
104-
else if(matrix_order_val == "HORIZONTAL_BOTTOM_RIGHT")
105-
{
106-
dev.matrix_order = E131_MATRIX_ORDER_HORIZONTAL_BOTTOM_RIGHT;
107-
}
108-
else if(matrix_order_val == "VERTICAL_TOP_LEFT")
90+
if(e131_settings["devices"][device_idx]["matrix_order"].is_string())
10991
{
110-
dev.matrix_order = E131_MATRIX_ORDER_VERTICAL_TOP_LEFT;
111-
}
112-
else if(matrix_order_val == "VERTICAL_TOP_RIGHT")
113-
{
114-
dev.matrix_order = E131_MATRIX_ORDER_VERTICAL_TOP_RIGHT;
115-
}
116-
else if(matrix_order_val == "VERTICAL_BOTTOM_LEFT")
117-
{
118-
dev.matrix_order = E131_MATRIX_ORDER_VERTICAL_BOTTOM_LEFT;
119-
}
120-
else if(matrix_order_val == "VERTICAL_BOTTOM_RIGHT")
121-
{
122-
dev.matrix_order = E131_MATRIX_ORDER_VERTICAL_BOTTOM_RIGHT;
92+
std::string matrix_order_val = e131_settings["devices"][device_idx]["matrix_order"];
93+
94+
if(matrix_order_val == "HORIZONTAL_TOP_LEFT")
95+
{
96+
dev.matrix_order = E131_MATRIX_ORDER_HORIZONTAL_TOP_LEFT;
97+
}
98+
else if(matrix_order_val == "HORIZONTAL_TOP_RIGHT")
99+
{
100+
dev.matrix_order = E131_MATRIX_ORDER_HORIZONTAL_TOP_RIGHT;
101+
}
102+
else if(matrix_order_val == "HORIZONTAL_BOTTOM_LEFT")
103+
{
104+
dev.matrix_order = E131_MATRIX_ORDER_HORIZONTAL_BOTTOM_LEFT;
105+
}
106+
else if(matrix_order_val == "HORIZONTAL_BOTTOM_RIGHT")
107+
{
108+
dev.matrix_order = E131_MATRIX_ORDER_HORIZONTAL_BOTTOM_RIGHT;
109+
}
110+
else if(matrix_order_val == "VERTICAL_TOP_LEFT")
111+
{
112+
dev.matrix_order = E131_MATRIX_ORDER_VERTICAL_TOP_LEFT;
113+
}
114+
else if(matrix_order_val == "VERTICAL_TOP_RIGHT")
115+
{
116+
dev.matrix_order = E131_MATRIX_ORDER_VERTICAL_TOP_RIGHT;
117+
}
118+
else if(matrix_order_val == "VERTICAL_BOTTOM_LEFT")
119+
{
120+
dev.matrix_order = E131_MATRIX_ORDER_VERTICAL_BOTTOM_LEFT;
121+
}
122+
else if(matrix_order_val == "VERTICAL_BOTTOM_RIGHT")
123+
{
124+
dev.matrix_order = E131_MATRIX_ORDER_VERTICAL_BOTTOM_RIGHT;
125+
}
123126
}
124127
else
125128
{
@@ -129,31 +132,34 @@ void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers)
129132

130133
if(e131_settings["devices"][device_idx].contains("rgb_order"))
131134
{
132-
std::string rgb_order_val = e131_settings["devices"][device_idx]["rgb_order"];
133-
134-
if(rgb_order_val == "RGB")
135-
{
136-
dev.rgb_order = E131_RGB_ORDER_RGB;
137-
}
138-
else if(rgb_order_val == "RBG")
139-
{
140-
dev.rgb_order = E131_RGB_ORDER_RBG;
141-
}
142-
else if(rgb_order_val == "GRB")
143-
{
144-
dev.rgb_order = E131_RGB_ORDER_GRB;
145-
}
146-
else if(rgb_order_val == "GBR")
147-
{
148-
dev.rgb_order = E131_RGB_ORDER_GBR;
149-
}
150-
else if(rgb_order_val == "BRG")
151-
{
152-
dev.rgb_order = E131_RGB_ORDER_BGR;
153-
}
154-
else if(rgb_order_val == "BGR")
135+
if(e131_settings["devices"][device_idx]["rgb_order"].is_string())
155136
{
156-
dev.rgb_order = E131_RGB_ORDER_BGR;
137+
std::string rgb_order_val = e131_settings["devices"][device_idx]["rgb_order"];
138+
139+
if(rgb_order_val == "RGB")
140+
{
141+
dev.rgb_order = E131_RGB_ORDER_RGB;
142+
}
143+
else if(rgb_order_val == "RBG")
144+
{
145+
dev.rgb_order = E131_RGB_ORDER_RBG;
146+
}
147+
else if(rgb_order_val == "GRB")
148+
{
149+
dev.rgb_order = E131_RGB_ORDER_GRB;
150+
}
151+
else if(rgb_order_val == "GBR")
152+
{
153+
dev.rgb_order = E131_RGB_ORDER_GBR;
154+
}
155+
else if(rgb_order_val == "BRG")
156+
{
157+
dev.rgb_order = E131_RGB_ORDER_BGR;
158+
}
159+
else if(rgb_order_val == "BGR")
160+
{
161+
dev.rgb_order = E131_RGB_ORDER_BGR;
162+
}
157163
}
158164
else
159165
{
@@ -178,19 +184,22 @@ void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers)
178184

179185
if(e131_settings["devices"][device_idx].contains("type"))
180186
{
181-
std::string type_val = e131_settings["devices"][device_idx]["type"];
182-
183-
if(type_val == "SINGLE")
184-
{
185-
dev.type = ZONE_TYPE_SINGLE;
186-
}
187-
else if(type_val == "LINEAR")
187+
if(e131_settings["devices"][device_idx]["type"].is_string())
188188
{
189-
dev.type = ZONE_TYPE_LINEAR;
190-
}
191-
else if(type_val == "MATRIX")
192-
{
193-
dev.type = ZONE_TYPE_MATRIX;
189+
std::string type_val = e131_settings["devices"][device_idx]["type"];
190+
191+
if(type_val == "SINGLE")
192+
{
193+
dev.type = ZONE_TYPE_SINGLE;
194+
}
195+
else if(type_val == "LINEAR")
196+
{
197+
dev.type = ZONE_TYPE_LINEAR;
198+
}
199+
else if(type_val == "MATRIX")
200+
{
201+
dev.type = ZONE_TYPE_MATRIX;
202+
}
194203
}
195204
else
196205
{

OpenRGB.pro

+6
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ HEADERS +=
164164
pci_ids/pci_ids.h \
165165
qt/DeviceView.h \
166166
qt/OpenRGBDialog2.h \
167+
qt/OpenRGBE131SettingsEntry.h \
168+
qt/OpenRGBE131SettingsPage.h \
167169
qt/OpenRGBPluginContainer.h \
168170
qt/OpenRGBProfileSaveDialog.h \
169171
qt/OpenRGBServerInfoPage.h \
@@ -460,6 +462,8 @@ SOURCES +=
460462
net_port/net_port.cpp \
461463
qt/DeviceView.cpp \
462464
qt/OpenRGBDialog2.cpp \
465+
qt/OpenRGBE131SettingsEntry.cpp \
466+
qt/OpenRGBE131SettingsPage.cpp \
463467
qt/OpenRGBPluginContainer.cpp \
464468
qt/OpenRGBProfileSaveDialog.cpp \
465469
qt/OpenRGBServerInfoPage.cpp \
@@ -778,6 +782,8 @@ FORMS +=
778782
qt/OpenRGBDevicePage.ui \
779783
qt/OpenRGBDialog.ui \
780784
qt/OpenRGBDialog2.ui \
785+
qt/OpenRGBE131SettingsEntry.ui \
786+
qt/OpenRGBE131SettingsPage.ui \
781787
qt/OpenRGBPluginContainer.ui \
782788
qt/OpenRGBProfileSaveDialog.ui \
783789
qt/OpenRGBServerInfoPage.ui \

qt/OpenRGBDialog2.cpp

+34
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,11 @@ OpenRGBDialog2::OpenRGBDialog2(QWidget *parent) : QMainWindow(parent), ui(new Op
401401
\*-----------------------------------------------------*/
402402
AddSettingsPage();
403403

404+
/*-----------------------------------------------------*\
405+
| Add the E1.31 settings page |
406+
\*-----------------------------------------------------*/
407+
AddE131SettingsPage();
408+
404409
/*-----------------------------------------------------*\
405410
| Add the SMBus Tools page if enabled |
406411
\*-----------------------------------------------------*/
@@ -564,6 +569,35 @@ void OpenRGBDialog2::AddSettingsPage()
564569
ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel);
565570
}
566571

572+
void OpenRGBDialog2::AddE131SettingsPage()
573+
{
574+
/*-----------------------------------------------------*\
575+
| Create the Settings page |
576+
\*-----------------------------------------------------*/
577+
E131SettingsPage = new OpenRGBE131SettingsPage();
578+
579+
ui->SettingsTabBar->addTab(E131SettingsPage, "");
580+
581+
QString SettingsLabelString = "<html><table><tr><td width='30'><img src='";
582+
SettingsLabelString += ":/settings";
583+
if(IsDarkTheme()) SettingsLabelString += "_dark";
584+
SettingsLabelString += ".png' height='16' width='16'></td><td>E1.31 Devices</td></tr></table></html>";
585+
586+
QLabel *SettingsTabLabel = new QLabel();
587+
SettingsTabLabel->setText(SettingsLabelString);
588+
SettingsTabLabel->setIndent(20);
589+
if(IsDarkTheme())
590+
{
591+
SettingsTabLabel->setGeometry(0, 25, 200, 50);
592+
}
593+
else
594+
{
595+
SettingsTabLabel->setGeometry(0, 0, 200, 25);
596+
}
597+
598+
ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel);
599+
}
600+
567601
void OpenRGBDialog2::AddPluginTab(PluginManager* plugin_manager, int plugin_index)
568602
{
569603
/*-----------------------------------------------------*\

qt/OpenRGBDialog2.h

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "OpenRGBSystemInfoPage.h"
99
#include "OpenRGBSupportedDevicesPage.h"
1010
#include "OpenRGBSettingsPage.h"
11+
#include "OpenRGBE131SettingsPage.h"
1112
#include "PluginManager.h"
1213

1314
#include <vector>
@@ -55,6 +56,7 @@ class Ui::OpenRGBDialog2 : public QMainWindow
5556
OpenRGBSoftwareInfoPage *SoftInfoPage;
5657
OpenRGBSupportedDevicesPage *SupportedPage;
5758
OpenRGBSettingsPage *SettingsPage;
59+
OpenRGBE131SettingsPage *E131SettingsPage;
5860

5961
bool ShowI2CTools = false;
6062

@@ -72,6 +74,7 @@ class Ui::OpenRGBDialog2 : public QMainWindow
7274
void AddSoftwareInfoPage();
7375
void AddSupportedDevicesPage();
7476
void AddSettingsPage();
77+
void AddE131SettingsPage();
7578
void AddPluginTab(PluginManager* plugin_manager,int plugin_index);
7679

7780
void ClearDevicesList();

qt/OpenRGBE131SettingsEntry.cpp

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#include "OpenRGBE131SettingsEntry.h"
2+
#include "ui_OpenRGBE131SettingsEntry.h"
3+
4+
using namespace Ui;
5+
6+
OpenRGBE131SettingsEntry::OpenRGBE131SettingsEntry(QWidget *parent) :
7+
QWidget(parent),
8+
ui(new Ui::OpenRGBE131SettingsEntryUi)
9+
{
10+
ui->setupUi(this);
11+
12+
ui->TypeComboBox->addItem("Single");
13+
ui->TypeComboBox->addItem("Linear");
14+
ui->TypeComboBox->addItem("Matrix");
15+
16+
ui->MatrixOrderComboBox->addItem("Horizontal Top Left");
17+
ui->MatrixOrderComboBox->addItem("Horizontal Top Right");
18+
ui->MatrixOrderComboBox->addItem("Horizontal Bottom Left");
19+
ui->MatrixOrderComboBox->addItem("Horizontal Bottom Right");
20+
ui->MatrixOrderComboBox->addItem("Vertical Top Left");
21+
ui->MatrixOrderComboBox->addItem("Vertical Top Right");
22+
ui->MatrixOrderComboBox->addItem("Vertical Bottom Left");
23+
ui->MatrixOrderComboBox->addItem("Vertical Bottom Right");
24+
25+
ui->RGBOrderComboBox->addItem("RGB");
26+
ui->RGBOrderComboBox->addItem("RBG");
27+
ui->RGBOrderComboBox->addItem("GRB");
28+
ui->RGBOrderComboBox->addItem("GBR");
29+
ui->RGBOrderComboBox->addItem("BRG");
30+
ui->RGBOrderComboBox->addItem("BGR");
31+
32+
HideMatrixSettings();
33+
}
34+
35+
OpenRGBE131SettingsEntry::~OpenRGBE131SettingsEntry()
36+
{
37+
delete ui;
38+
}
39+
40+
void Ui::OpenRGBE131SettingsEntry::HideMatrixSettings()
41+
{
42+
ui->MatrixWidthLabel->setDisabled(true);
43+
ui->MatrixWidthEdit->setDisabled(true);
44+
45+
ui->MatrixHeightLabel->setDisabled(true);
46+
ui->MatrixHeightEdit->setDisabled(true);
47+
48+
ui->MatrixOrderLabel->setDisabled(true);
49+
ui->MatrixOrderComboBox->setDisabled(true);
50+
}
51+
52+
void Ui::OpenRGBE131SettingsEntry::ShowMatrixSettings()
53+
{
54+
ui->MatrixWidthLabel->setDisabled(false);
55+
ui->MatrixWidthEdit->setDisabled(false);
56+
57+
ui->MatrixHeightLabel->setDisabled(false);
58+
ui->MatrixHeightEdit->setDisabled(false);
59+
60+
ui->MatrixOrderLabel->setDisabled(false);
61+
ui->MatrixOrderComboBox->setDisabled(false);
62+
}
63+
64+
void Ui::OpenRGBE131SettingsEntry::on_TypeComboBox_currentIndexChanged(int index)
65+
{
66+
if(index == 2)
67+
{
68+
ShowMatrixSettings();
69+
}
70+
else
71+
{
72+
HideMatrixSettings();
73+
}
74+
}

qt/OpenRGBE131SettingsEntry.h

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#ifndef OPENRGBE131SETTINGSENTRY_H
2+
#define OPENRGBE131SETTINGSENTRY_H
3+
4+
#include "ui_OpenRGBE131SettingsEntry.h"
5+
#include <QWidget>
6+
7+
namespace Ui {
8+
class OpenRGBE131SettingsEntry;
9+
}
10+
11+
class Ui::OpenRGBE131SettingsEntry : public QWidget
12+
{
13+
Q_OBJECT
14+
15+
public:
16+
explicit OpenRGBE131SettingsEntry(QWidget *parent = nullptr);
17+
~OpenRGBE131SettingsEntry();
18+
Ui::OpenRGBE131SettingsEntryUi *ui;
19+
20+
private:
21+
void HideMatrixSettings();
22+
void ShowMatrixSettings();
23+
24+
private slots:
25+
void on_TypeComboBox_currentIndexChanged(int index);
26+
};
27+
28+
#endif // OPENRGBE131SETTINGSENTRY_H

0 commit comments

Comments
 (0)