Commit a028a2c5 authored by Adam Honse's avatar Adam Honse

Add box to enter IP and port of OpenRGB SDK server

parent b0156292
......@@ -261,8 +261,6 @@ void Visualizer::Initialize()
ChangeAudioDevice();
SetNormalization(nrml_ofst, nrml_scl);
rgb_client = new NetworkClient(rgb_controllers);
}
void Visualizer::InitClient(char * clientstring)
......@@ -674,7 +672,6 @@ void Visualizer::StartThread()
VisThread = new std::thread(&Visualizer::VisThreadFunction, this);
NetConnectThread = new std::thread(&Visualizer::NetConnectThreadFunction, this);
NetUpdateThread = new std::thread(&Visualizer::NetUpdateThreadFunction, this);
LEDUpdateThread = new std::thread(&Visualizer::LEDUpdateThreadFunction, this);
}
void Visualizer::Shutdown()
......@@ -1351,6 +1348,18 @@ void Visualizer::VisThreadFunction()
}
}
void Visualizer::OpenRGBConnect(const char * ip, unsigned short port)
{
rgb_client = new NetworkClient(rgb_controllers);
rgb_client->SetIP(ip);
rgb_client->SetPort(port);
rgb_client->StartClient();
LEDUpdateThread = new std::thread(&Visualizer::LEDUpdateThreadFunction, this);
}
void Visualizer::LEDUpdateThreadFunction()
{
while(1)
......
......@@ -88,6 +88,9 @@ public:
void NetUpdateThreadFunction();
void VisThreadFunction();
//Connect to OpenRGB
void OpenRGBConnect(const char *ip, unsigned short port);
//Called when settings changed
void OnSettingsChanged();
......
......@@ -31,6 +31,9 @@ KeyboardVisDlg::KeyboardVisDlg(QWidget *parent) : QMainWindow(parent), ui(new Ke
trayIcon->setToolTip("Keyboard Visualizer");
trayIcon->setContextMenu(myTrayIconMenu);
trayIcon->show();
ui->lineEdit_IP->setText("127.0.0.1");
ui->lineEdit_Port->setText("1337");
}
void KeyboardVisDlg::show()
......@@ -195,40 +198,6 @@ void KeyboardVisDlg::SetVisualizer(Visualizer* v)
image = new QImage(256, 64, QImage::Format_RGB32);
scene = new QGraphicsScene(this);
ui->graphicsView_Visualization_Preview->setScene(scene);
//OpenRGB device list
ui->tree_Devices->setColumnCount(3);
ui->tree_Devices->setHeaderLabels(QStringList() << "Device Zones" << "LEDs" << "Type");
for(int dev_idx = 0; dev_idx < vis_ptr->rgb_controllers.size(); dev_idx++)
{
QTreeWidgetItem* new_item = new QTreeWidgetItem(ui->tree_Devices);
new_item->setText(0, QString::fromStdString(vis_ptr->rgb_controllers[dev_idx]->name));
for(int zone_idx = 0; zone_idx < vis_ptr->rgb_controllers[dev_idx]->zones.size(); zone_idx++)
{
QTreeWidgetItem* new_child = new QTreeWidgetItem();
new_child->setText(0, QString::fromStdString(vis_ptr->rgb_controllers[dev_idx]->zones[zone_idx].name));
new_child->setText(1, QString::fromStdString(std::to_string((vis_ptr->rgb_controllers[dev_idx]->zones[zone_idx].leds_count))));
switch(vis_ptr->rgb_controllers[dev_idx]->zones[zone_idx].type)
{
case ZONE_TYPE_SINGLE:
new_child->setText(2, "Single");
break;
case ZONE_TYPE_LINEAR:
new_child->setText(2, "Linear");
break;
case ZONE_TYPE_MATRIX:
new_child->setText(2, "Matrix");
break;
}
new_item->addChild(new_child);
}
}
}
void KeyboardVisDlg::StartMinimized(boolean startmin)
......@@ -380,3 +349,45 @@ void Ui::KeyboardVisDlg::on_lineEdit_Background_Timeout_textChanged(const QStrin
vis_ptr->OnSettingsChanged();
}
void Ui::KeyboardVisDlg::on_button_Connect_clicked()
{
unsigned short port = std::stoi(ui->lineEdit_Port->text().toStdString());
const char * ip = ui->lineEdit_IP->text().toStdString().c_str();
vis_ptr->OpenRGBConnect(ip, port);
//OpenRGB device list
ui->tree_Devices->setColumnCount(3);
ui->tree_Devices->setHeaderLabels(QStringList() << "Device Zones" << "LEDs" << "Type");
for(int dev_idx = 0; dev_idx < vis_ptr->rgb_controllers.size(); dev_idx++)
{
QTreeWidgetItem* new_item = new QTreeWidgetItem(ui->tree_Devices);
new_item->setText(0, QString::fromStdString(vis_ptr->rgb_controllers[dev_idx]->name));
for(int zone_idx = 0; zone_idx < vis_ptr->rgb_controllers[dev_idx]->zones.size(); zone_idx++)
{
QTreeWidgetItem* new_child = new QTreeWidgetItem();
new_child->setText(0, QString::fromStdString(vis_ptr->rgb_controllers[dev_idx]->zones[zone_idx].name));
new_child->setText(1, QString::fromStdString(std::to_string((vis_ptr->rgb_controllers[dev_idx]->zones[zone_idx].leds_count))));
switch(vis_ptr->rgb_controllers[dev_idx]->zones[zone_idx].type)
{
case ZONE_TYPE_SINGLE:
new_child->setText(2, "Single");
break;
case ZONE_TYPE_LINEAR:
new_child->setText(2, "Linear");
break;
case ZONE_TYPE_MATRIX:
new_child->setText(2, "Matrix");
break;
}
new_item->addChild(new_child);
}
}
}
......@@ -69,6 +69,8 @@ private slots:
void on_lineEdit_Background_Timeout_textChanged(const QString &arg1);
void on_button_Connect_clicked();
private:
Ui::KeyboardVisualizerDlg *ui;
QSystemTrayIcon* trayIcon;
......
......@@ -15,30 +15,14 @@
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout">
<item row="9" column="0">
<widget class="QLabel" name="label_Visualization_Preview">
<property name="text">
<string>Visualization Preview</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QComboBox" name="comboBox_FFT_Window_Mode">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
<widget class="QLabel" name="label_FFT_Window_Mode">
<property name="text">
<string>FFT Window Mode</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="lineEdit_Filter_Constant"/>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_Amplitude"/>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_Background_Brightness"/>
</item>
<item row="9" column="1" colspan="2">
<item row="9" column="2" colspan="2">
<widget class="QGraphicsView" name="graphicsView_Visualization_Preview">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
......@@ -69,93 +53,108 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_Background_Brightness">
<property name="text">
<string>Background Brightness</string>
</property>
</widget>
<item row="0" column="2">
<widget class="QLineEdit" name="lineEdit_Amplitude"/>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_Background_Timeout">
<property name="text">
<string>Background Timeout</string>
</property>
</widget>
<item row="4" column="2">
<widget class="QLineEdit" name="lineEdit_Delay"/>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label_Foreground_Mode">
<property name="text">
<string>Foreground Mode</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit_Average_Size"/>
</item>
<item row="5" column="3">
<widget class="QComboBox" name="comboBox_Audio_Device">
<item row="1" column="4">
<widget class="QComboBox" name="comboBox_Background_Mode">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QLabel" name="label_Reactive_Background">
<item row="9" column="0">
<widget class="QLabel" name="label_Visualization_Preview">
<property name="text">
<string>Reactive Background</string>
<string>Visualization Preview</string>
</property>
</widget>
</item>
<item row="8" column="3">
<item row="8" column="4">
<widget class="QCheckBox" name="checkBox_Silent_Background">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_Delay">
<item row="5" column="0">
<widget class="QLabel" name="label_Normalization_Offset">
<property name="text">
<string>Delay (ms)</string>
<string>Normalization Offset</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEdit_Delay"/>
<item row="7" column="2">
<widget class="QLineEdit" name="lineEdit_Filter_Constant"/>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_FFT_Window_Mode">
<item row="2" column="0">
<widget class="QLabel" name="label_Average_Size">
<property name="text">
<string>FFT Window Mode</string>
<string>Average Size</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QComboBox" name="comboBox_Single_Color_Mode">
<item row="12" column="0" colspan="5">
<widget class="QTreeWidget" name="tree_Devices">
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
<item row="9" column="4">
<widget class="QPushButton" name="pushButton_Save_Settings">
<property name="text">
<string>Save Settings</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QComboBox" name="comboBox_Foreground_Mode">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
</property>
</widget>
</item>
<item row="7" column="3">
<item row="6" column="0">
<widget class="QLabel" name="label_Normalization_Scale">
<property name="text">
<string>Normalization Scale</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_Delay">
<property name="text">
<string>Delay (ms)</string>
</property>
</widget>
</item>
<item row="7" column="4">
<widget class="QCheckBox" name="checkBox_Reactive_Background">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_Average_Size">
<item row="1" column="0">
<widget class="QLabel" name="label_Background_Brightness">
<property name="text">
<string>Average Size</string>
<string>Background Brightness</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QComboBox" name="comboBox_Foreground_Mode">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
<item row="1" column="3">
<widget class="QLabel" name="label_Background_Mode">
<property name="text">
<string>Background Mode</string>
</property>
</widget>
</item>
......@@ -166,31 +165,58 @@
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_Normalization_Offset">
<item row="8" column="2">
<widget class="QLineEdit" name="lineEdit_Background_Timeout"/>
</item>
<item row="8" column="3">
<widget class="QLabel" name="label_Silent_Background">
<property name="text">
<string>Normalization Offset</string>
<string>Silent Background</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QLabel" name="label_Animation_Speed">
<widget class="QLineEdit" name="lineEdit_Normalization_Scale"/>
</item>
<item row="7" column="3">
<widget class="QLabel" name="label_Reactive_Background">
<property name="text">
<string>Animation Speed</string>
<string>Reactive Background</string>
</property>
</widget>
</item>
<item row="10" column="0" colspan="4">
<widget class="QLabel" name="label_GitHub_URL">
<item row="5" column="4">
<widget class="QComboBox" name="comboBox_Audio_Device">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
</property>
</widget>
</item>
<item row="5" column="3">
<widget class="QLabel" name="label_Audio_Device">
<property name="text">
<string>https://gitlab.com/CalcProgrammer1/KeyboardVisualizer</string>
<string>Audio Device</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_Amplitude">
<item row="0" column="4">
<widget class="QComboBox" name="comboBox_FFT_Window_Mode">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QComboBox" name="comboBox_Single_Color_Mode">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_Background_Timeout">
<property name="text">
<string>Amplitude (%)</string>
<string>Background Timeout</string>
</property>
</widget>
</item>
......@@ -201,90 +227,91 @@
</property>
</widget>
</item>
<item row="6" column="3">
<widget class="QLineEdit" name="lineEdit_Animation_Speed"/>
</item>
<item row="8" column="1">
<widget class="QLineEdit" name="lineEdit_Background_Timeout"/>
<item row="1" column="2">
<widget class="QLineEdit" name="lineEdit_Background_Brightness"/>
</item>
<item row="5" column="2">
<widget class="QLabel" name="label_Audio_Device">
<item row="4" column="3">
<widget class="QLabel" name="label_Average_Mode">
<property name="text">
<string>Audio Device</string>
<string>Average Mode</string>
</property>
</widget>
</item>
<item row="4" column="3">
<item row="5" column="2">
<widget class="QLineEdit" name="lineEdit_Normalization_Offset"/>
</item>
<item row="4" column="4">
<widget class="QComboBox" name="comboBox_Average_Mode">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLabel" name="label_Single_Color_Mode">
<item row="10" column="0">
<widget class="QLabel" name="label_IP">
<property name="text">
<string>Single Color Mode</string>
<string>IP:</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QComboBox" name="comboBox_Background_Mode">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
<item row="0" column="0">
<widget class="QLabel" name="label_Amplitude">
<property name="text">
<string>Amplitude (%)</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QLabel" name="label_Average_Mode">
<item row="3" column="3">
<widget class="QLabel" name="label_Single_Color_Mode">
<property name="text">
<string>Average Mode</string>
<string>Single Color Mode</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_Background_Mode">
<item row="6" column="3">
<widget class="QLabel" name="label_Animation_Speed">
<property name="text">
<string>Background Mode</string>
<string>Animation Speed</string>
</property>
</widget>
</item>
<item row="11" column="0" colspan="4">
<widget class="QTreeWidget" name="tree_Devices">
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
<item row="6" column="4">
<widget class="QLineEdit" name="lineEdit_Animation_Speed"/>
</item>
<item row="8" column="2">
<widget class="QLabel" name="label_Silent_Background">
<item row="3" column="2">
<widget class="QLineEdit" name="lineEdit_Decay"/>
</item>
<item row="10" column="2">
<widget class="QLineEdit" name="lineEdit_IP"/>
</item>
<item row="2" column="3">
<widget class="QLabel" name="label_Foreground_Mode">
<property name="text">
<string>Silent Background</string>
<string>Foreground Mode</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="lineEdit_Normalization_Scale"/>
<item row="10" column="4">
<widget class="QLineEdit" name="lineEdit_Port"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_Normalization_Scale">
<item row="10" column="3">
<widget class="QLabel" name="label_Port">
<property name="text">
<string>Normalization Scale</string>
<string>Port</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="lineEdit_Normalization_Offset"/>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEdit_Decay"/>
<item row="11" column="4">
<widget class="QPushButton" name="button_Connect">
<property name="text">
<string>Connect</string>
</property>
</widget>
</item>
<item row="9" column="3">
<widget class="QPushButton" name="pushButton_Save_Settings">
<item row="11" column="0" colspan="4">
<widget class="QLabel" name="label_GitLab">
<property name="text">
<string>Save Settings</string>
<string>https://gitlab.com/CalcProgrammer1/KeyboardVisualizer</string>
</property>
</widget>
</item>
......
Subproject commit 330fdcd339f58d260fd03768a9fec9a587b15adf
Subproject commit a41a22d5d6e4100b85963dfb6caa4366fb19793d
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment