Publish LumaOps source

This commit is contained in:
LumaOps release export
2026-09-03 01:18:36 +02:00
commit 7f1c0e5f71
2363 changed files with 501543 additions and 0 deletions
+168
View File
@@ -0,0 +1,168 @@
/*---------------------------------------------------------*\
| DetectorTableModel.cpp |
| |
| Table model for detector list |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "DetectorTableModel.h"
#include "SettingsManager.h"
DetectorTableModel::DetectorTableModel(QObject* parent) : QAbstractTableModel(parent)
{
detectors.clear();
/*-----------------------------------------------------*\
| Read the detector list from the settings manager |
\*-----------------------------------------------------*/
json settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Detectors");
if(settings.contains("detectors"))
{
for(json::const_iterator it = settings["detectors"].begin(); it != settings["detectors"].end(); it++)
{
DetectorTableValue new_entry;
new_entry.key = it.key();
new_entry.value = it.value();
detectors.push_back(new_entry);
}
}
/*-----------------------------------------------------*\
| If settings contains the detectors list, fill in rows |
\*-----------------------------------------------------*/
beginInsertRows(QModelIndex(), 0, (int)detectors.size());
endInsertRows();
}
int DetectorTableModel::columnCount(const QModelIndex&) const
{
/*-----------------------------------------------------*\
| The table has two columns - detector name and enable |
\*-----------------------------------------------------*/
return(2);
}
int DetectorTableModel::rowCount(const QModelIndex&) const
{
/*-----------------------------------------------------*\
| The number of rows is equal to the number of detectors|
\*-----------------------------------------------------*/
return((int)detectors.size());
}
QVariant DetectorTableModel::data(const QModelIndex& index, int role) const
{
switch(role)
{
/*-----------------------------------------------------*\
| Column 0 is the detector name, 1 is the enable flag |
\*-----------------------------------------------------*/
case Qt::DisplayRole:
switch(index.column())
{
case 0:
return(detectors[index.row()].key.c_str());
case 1:
return(detectors[index.row()].value);
}
return(QVariant());
case Qt::CheckStateRole:
switch(index.column())
{
case 1:
return(2 * detectors[index.row()].value);
}
return(QVariant());
}
return(QVariant());
}
bool DetectorTableModel::setData(const QModelIndex& index, const QVariant& value, int role)
{
/*-----------------------------------------------------*\
| Update detector value for column 1 |
\*-----------------------------------------------------*/
if(index.column() == 1 && role == Qt::CheckStateRole)
{
detectors[index.row()].value = value.toBool();
emit dataChanged(index, index);
}
return(false);
}
QVariant DetectorTableModel::headerData(int index, Qt::Orientation orientation, int role) const
{
if(role == Qt::DisplayRole)
{
switch(orientation)
{
case Qt::Vertical:
return(index + 1);
case Qt::Horizontal:
switch(index)
{
case 0:
return(tr("Name"));
case 1:
return(tr("Enabled"));
}
}
}
return(QVariant());
}
Qt::ItemFlags DetectorTableModel::flags(const QModelIndex& index) const
{
Qt::ItemFlags fl = Qt::ItemIsEnabled;
if(index.column() == 1)
{
fl |= Qt::ItemIsUserCheckable;
}
return(fl);
}
void DetectorTableModel::applySettings()
{
/*-----------------------------------------------------*\
| Read the detector list from the settings manager |
\*-----------------------------------------------------*/
json settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Detectors");
/*-----------------------------------------------------*\
| Loop through all detectors in the list and update the |
| value in the settings |
\*-----------------------------------------------------*/
if(settings.contains("detectors"))
{
for(unsigned int detector_idx = 0; detector_idx < detectors.size(); detector_idx++)
{
settings["detectors"][detectors[detector_idx].key] = detectors[detector_idx].value;
}
}
/*-----------------------------------------------------*\
| Set and save the settings |
\*-----------------------------------------------------*/
ResourceManager::get()->GetSettingsManager()->SetSettings("Detectors", settings);
ResourceManager::get()->GetSettingsManager()->SaveSettings();
}
void DetectorTableModel::toggleAll(const bool state, QSortFilterProxyModel* detectorSortModel)
{
for(unsigned int detector_idx = 0; detector_idx < detectors.size(); detector_idx++)
{
if(detectorSortModel->mapFromSource(index(detector_idx, 0)).isValid())
{
setData(index(detector_idx,1), state, Qt::CheckStateRole);
}
}
}
+41
View File
@@ -0,0 +1,41 @@
/*---------------------------------------------------------*\
| DetectorTableModel.h |
| |
| Table model for detector list |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <QSortFilterProxyModel>
#include <QAbstractTableModel>
#include "ResourceManager.h"
typedef struct
{
std::string key;
bool value;
} DetectorTableValue;
class DetectorTableModel : public QAbstractTableModel
{
Q_OBJECT
private:
std::vector<DetectorTableValue> detectors;
public:
DetectorTableModel(QObject *parent = nullptr);
int columnCount(const QModelIndex&) const override;
int rowCount(const QModelIndex&) const override;
QVariant data(const QModelIndex& index, int role) const override;
bool setData(const QModelIndex& index, const QVariant&, int role) override;
QVariant headerData(int index, Qt::Orientation orientation, int role) const override;
Qt::ItemFlags flags(const QModelIndex& index) const override;
public slots:
void applySettings();
void toggleAll(const bool state, QSortFilterProxyModel* detectorSortModel);
};
+1094
View File
File diff suppressed because it is too large Load Diff
+86
View File
@@ -0,0 +1,86 @@
/*---------------------------------------------------------*\
| DeviceView.h |
| |
| OpenRGB Device view widget for Qt |
| |
| Adam Honse (calcprogrammer1@gmail.com) |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <QWidget>
#include "RGBController.h"
typedef struct
{
float matrix_x;
float matrix_y;
float matrix_w;
float matrix_h;
} matrix_pos_size_type;
class DeviceView : public QWidget
{
Q_OBJECT
public:
explicit DeviceView(QWidget *parent = 0);
~DeviceView();
virtual QSize sizeHint () const;
virtual QSize minimumSizeHint () const;
void setController(RGBController * controller_ptr);
void setNumericalLabels(bool enable);
void setPerLED(bool per_led_mode);
protected:
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *);
void resizeEvent(QResizeEvent *event);
void paintEvent(QPaintEvent *);
private:
QSize initSize;
bool mouseDown;
bool ctrlDown;
bool mouseMoved;
int size;
int offset_x;
QRect selectionRect;
QPoint lastMousePos;
QVector<int> previousSelection;
QVector<int> selectedLeds;
QVector<bool> selectionFlags;
QVector<bool> previousFlags;
bool per_led;
std::vector<matrix_pos_size_type> zone_pos;
std::vector<matrix_pos_size_type> segment_pos;
std::vector<matrix_pos_size_type> led_pos;
std::vector<QString> led_labels;
float matrix_h;
bool numerical_labels;
RGBController* controller;
QColor posColor(const QPoint &point);
void InitDeviceView();
void updateSelection();
signals:
void selectionChanged(QVector<int>);
public slots:
bool selectLed(int);
bool selectLeds(QVector<int>);
bool selectSegment(int zone, int segment, bool add = false);
bool selectZone(int zone, bool add = false);
void clearSelection(); // Same as selecting the entire device
void setSelectionColor(RGBColor);
};
@@ -0,0 +1,27 @@
/*-----------------------------------------------------------------*\
| BaseManualDeviceEntry.cpp |
| |
| Base class to all user-defined device settings entries |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-only |
\*-----------------------------------------------------------------*/
#include "BaseManualDeviceEntry.h"
#include "ManualDevicesTypeManager.h"
void BaseManualDeviceEntry::setSettingsSection(const std::string& section)
{
settingsSection = section;
}
std::string BaseManualDeviceEntry::getSettingsSection()
{
return settingsSection;
}
ManualDeviceTypeRegistrator::ManualDeviceTypeRegistrator(const std::string& name, const std::string& settingsEntry, ManualDeviceEntrySpawnFunction entrySpawnFunction)
{
ManualDevicesTypeManager::get()->registerType(name, settingsEntry, entrySpawnFunction);
};
@@ -0,0 +1,41 @@
/*-----------------------------------------------------------------*\
| BaseManualDeviceEntry.h |
| |
| Base class to all user-defined device settings entries |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-only |
\*-----------------------------------------------------------------*/
#pragma once
#include <QWidget>
#include "nlohmann/json.hpp"
using json = nlohmann::json;
class BaseManualDeviceEntry: public QWidget
{
Q_OBJECT
public:
explicit BaseManualDeviceEntry(QWidget *parent = nullptr): QWidget(parent) {}
virtual json saveSettings() = 0;
virtual bool isDataValid() = 0;
void setSettingsSection(const std::string& section);
std::string getSettingsSection();
private:
std::string settingsSection;
};
typedef std::function<BaseManualDeviceEntry*(const json& data)> ManualDeviceEntrySpawnFunction;
class ManualDeviceTypeRegistrator
{
public:
ManualDeviceTypeRegistrator(const std::string& name, const std::string& settingsEntry, ManualDeviceEntrySpawnFunction entrySpawnFunction);
};
#define REGISTER_MANUAL_DEVICE_TYPE(name, settingsEntry, func) static ManualDeviceTypeRegistrator device_detector_obj_##func(name, settingsEntry, func)
@@ -0,0 +1,100 @@
/*---------------------------------------------------------*\
| DDPSettingsEntry.cpp |
| |
| User interface for OpenRGB DDP settings entry |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "DDPSettingsEntry.h"
#include "ui_DDPSettingsEntry.h"
#include "ManualDevicesTypeManager.h"
#include "nlohmann/json.hpp"
using json = nlohmann::json;
DDPSettingsEntry::DDPSettingsEntry(QWidget *parent) :
BaseManualDeviceEntry(parent),
ui(new Ui::DDPSettingsEntry)
{
ui->setupUi(this);
}
DDPSettingsEntry::~DDPSettingsEntry()
{
delete ui;
}
void DDPSettingsEntry::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
}
void DDPSettingsEntry::loadFromSettings(const json& data)
{
if(data.contains("name"))
{
ui->NameEdit->setText(QString::fromStdString(data["name"]));
}
if(data.contains("ip"))
{
ui->IPEdit->setText(QString::fromStdString(data["ip"]));
}
if(data.contains("port"))
{
ui->PortSpinBox->setValue(data["port"]);
}
else
{
ui->PortSpinBox->setValue(4048);
}
if(data.contains("num_leds"))
{
ui->NumLedsSpinBox->setValue(data["num_leds"]);
}
if(data.contains("keepalive_time"))
{
ui->KeepaliveTimeSpinBox->setValue(data["keepalive_time"]);
}
}
json DDPSettingsEntry::saveSettings()
{
json result;
result["name"] = ui->NameEdit->text().toStdString();
result["ip"] = ui->IPEdit->text().toStdString();
result["port"] = ui->PortSpinBox->value();
result["num_leds"] = ui->NumLedsSpinBox->value();
if(ui->KeepaliveTimeSpinBox->value() > 0)
{
result["keepalive_time"] = ui->KeepaliveTimeSpinBox->value();
}
return result;
}
bool DDPSettingsEntry::isDataValid()
{
return !ui->IPEdit->text().isEmpty() && ui->NumLedsSpinBox->value() > 0;
}
static BaseManualDeviceEntry* SpawnDDPEntry(const json& data)
{
DDPSettingsEntry* entry = new DDPSettingsEntry;
entry->loadFromSettings(data);
return entry;
}
static const char* DDPDeviceName = QT_TRANSLATE_NOOP("ManualDevice", "DDP (Distributed Display Protocol)");
REGISTER_MANUAL_DEVICE_TYPE(DDPDeviceName, "DDPDevices", SpawnDDPEntry);
@@ -0,0 +1,35 @@
/*---------------------------------------------------------*\
| DDPSettingsEntry.h |
| |
| User interface for OpenRGB DDP settings entry |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "BaseManualDeviceEntry.h"
namespace Ui
{
class DDPSettingsEntry;
}
class DDPSettingsEntry : public BaseManualDeviceEntry
{
Q_OBJECT
public:
explicit DDPSettingsEntry(QWidget *parent = nullptr);
~DDPSettingsEntry();
void loadFromSettings(const json& data);
json saveSettings() override;
bool isDataValid() override;
private:
Ui::DDPSettingsEntry *ui;
private slots:
void changeEvent(QEvent *event) override;
};
@@ -0,0 +1,127 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DDPSettingsEntry</class>
<widget class="QWidget" name="DDPSettingsEntry">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>200</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true">DDP Settings Entry</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>DDP Device</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="IPLabel">
<property name="text">
<string>IP Address:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="IPEdit">
<property name="placeholderText">
<string>192.168.1.100</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="NameLabel">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="NameEdit">
<property name="placeholderText">
<string>Device Name</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="PortLabel">
<property name="text">
<string>Port:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="PortSpinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>4048</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="NumLedsLabel">
<property name="text">
<string>Number of LEDs:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="NumLedsSpinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="value">
<number>50</number>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="KeepaliveTimeLabel">
<property name="text">
<string>Keepalive Time (ms):</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="KeepaliveTimeSpinBox">
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="value">
<number>1000</number>
</property>
<property name="specialValueText">
<string>Disabled</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,136 @@
/*---------------------------------------------------------*\
| DMXSettingsEntry.cpp |
| |
| User interface for OpenRGB DMX settings entry |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "DMXSettingsEntry.h"
#include "ui_DMXSettingsEntry.h"
#include "serial_port.h"
#include <QStandardItemModel>
DMXSettingsEntry::DMXSettingsEntry(QWidget *parent) :
BaseManualDeviceEntry(parent),
ui(new Ui::DMXSettingsEntry)
{
ui->setupUi(this);
std::vector<std::string> serialPorts = serial_port::getSerialPorts();
for(size_t i = 0; i < serialPorts.size(); ++i)
{
ui->PortComboBox->addItem(QString::fromStdString(serialPorts[i]));
}
if(serialPorts.empty())
{
/*---------------------------------------------------*\
| When no ports were found, add an unselectable entry |
| denoting this fact istead |
\*---------------------------------------------------*/
QStandardItemModel* comboBoxModel = qobject_cast<QStandardItemModel *>(ui->PortComboBox->model());
if(comboBoxModel != nullptr)
{
ui->PortComboBox->addItem(tr("No serial ports found"));
QStandardItem *item = comboBoxModel->item(0);
item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
}
}
ui->PortComboBox->clearEditText();
}
DMXSettingsEntry::~DMXSettingsEntry()
{
delete ui;
}
void DMXSettingsEntry::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
}
void DMXSettingsEntry::loadFromSettings(const json& data)
{
if(data.contains("name"))
{
ui->NameEdit->setText(QString::fromStdString(data["name"]));
}
if(data.contains("port"))
{
ui->PortComboBox->setCurrentText(QString::fromStdString(data["port"]));
}
if(data.contains("red_channel"))
{
ui->RedEdit->setText(QString::number((int)data["red_channel"]));
}
if(data.contains("green_channel"))
{
ui->GreenEdit->setText(QString::number((int)data["green_channel"]));
}
if(data.contains("blue_channel"))
{
ui->BlueEdit->setText(QString::number((int)data["blue_channel"]));
}
if(data.contains("brightness_channel"))
{
ui->BrightnessEdit->setText(QString::number((int)data["brightness_channel"]));
}
if(data.contains("keepalive_time"))
{
ui->KeepaliveTimeEdit->setText(QString::number((int)data["keepalive_time"]));
}
}
json DMXSettingsEntry::saveSettings()
{
json result;
/*-------------------------------------------------*\
| Required parameters |
\*-------------------------------------------------*/
result["name"] = ui->NameEdit->text().toStdString();
result["port"] = ui->PortComboBox->currentText().toStdString();
result["red_channel"] = ui->RedEdit->text().toUInt();
result["green_channel"] = ui->GreenEdit->text().toUInt();
result["blue_channel"] = ui->BlueEdit->text().toUInt();
/*-------------------------------------------------*\
| Optional parameters |
\*-------------------------------------------------*/
if(ui->BrightnessEdit->text() != "")
{
result["brightness_channel"] = ui->BrightnessEdit->text().toUInt();
}
if(ui->KeepaliveTimeEdit->text() != "")
{
result["keepalive_time"] = ui->KeepaliveTimeEdit->text().toUInt();
}
return result;
}
bool DMXSettingsEntry::isDataValid()
{
// stub
return true;
}
static BaseManualDeviceEntry* SpawnDMXEntry(const json& data)
{
DMXSettingsEntry* entry = new DMXSettingsEntry;
entry->loadFromSettings(data);
return entry;
}
REGISTER_MANUAL_DEVICE_TYPE("DMX", "DMXDevices", SpawnDMXEntry);
@@ -0,0 +1,35 @@
/*---------------------------------------------------------*\
| DMXSettingsEntry.h |
| |
| User interface for OpenRGB DMX settings entry |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "BaseManualDeviceEntry.h"
namespace Ui
{
class DMXSettingsEntry;
}
class DMXSettingsEntry : public BaseManualDeviceEntry
{
Q_OBJECT
public:
explicit DMXSettingsEntry(QWidget *parent = nullptr);
~DMXSettingsEntry();
void loadFromSettings(const json& data);
json saveSettings() override;
bool isDataValid() override;
private:
Ui::DMXSettingsEntry *ui;
private slots:
void changeEvent(QEvent *event) override;
};
@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DMXSettingsEntry</class>
<widget class="QWidget" name="DMXSettingsEntry">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>531</width>
<height>206</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true">DMX Settings Entry</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>DMX Device</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="4" column="4">
<widget class="QLabel" name="BrightnessLabel">
<property name="text">
<string>Brightness Channel:</string>
</property>
</widget>
</item>
<item row="4" column="5">
<widget class="QLineEdit" name="BrightnessEdit"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Blue Channel:</string>
</property>
</widget>
</item>
<item row="3" column="5">
<widget class="QLineEdit" name="GreenEdit"/>
</item>
<item row="3" column="3">
<widget class="QLineEdit" name="RedEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="NameLabel">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QLabel" name="GreenLabel">
<property name="text">
<string>Green Channel:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="RedLabel">
<property name="text">
<string>Red Channel:</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QLineEdit" name="BlueEdit"/>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="NameEdit"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="KeepaliveTimeLabel">
<property name="text">
<string>Keepalive Time:</string>
</property>
</widget>
</item>
<item row="5" column="3">
<widget class="QLineEdit" name="KeepaliveTimeEdit"/>
</item>
<item row="1" column="4">
<widget class="QLabel" name="PortLabel">
<property name="text">
<string>Port:</string>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QComboBox" name="PortComboBox">
<property name="editable">
<bool>true</bool>
</property>
<property name="insertPolicy">
<enum>QComboBox::NoInsert</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>NameEdit</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,145 @@
/*---------------------------------------------------------*\
| DebugSettingsEntry.cpp |
| |
| User interface for OpenRGB Debug settings entry |
| |
| Adam Honse <calcprogrammer1@gmail.com> 30 Jul 2025 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "DebugSettingsEntry.h"
#include "ui_DebugSettingsEntry.h"
#include "ManualDevicesTypeManager.h"
#include "nlohmann/json.hpp"
using json = nlohmann::json;
#define NUM_TYPES 6
const std::string types[] =
{
"motherboard",
"dram",
"gpu",
"keyboard",
"mouse",
"argb"
};
DebugSettingsEntry::DebugSettingsEntry(QWidget *parent) :
BaseManualDeviceEntry(parent),
ui(new Ui::DebugSettingsEntry)
{
ui->setupUi(this);
ui->TypeComboBox->addItem("motherboard");
ui->TypeComboBox->addItem("dram");
ui->TypeComboBox->addItem("gpu");
ui->TypeComboBox->addItem("keyboard");
ui->TypeComboBox->addItem("mouse");
ui->TypeComboBox->addItem("argb");
ui->LayoutComboBox->addItem("Default");
ui->LayoutComboBox->addItem("ANSI QWERTY");
ui->LayoutComboBox->addItem("ISO QWERTY");
ui->LayoutComboBox->addItem("ISO QWERTZ");
ui->LayoutComboBox->addItem("ISO AZERTY");
ui->LayoutComboBox->addItem("JIS");
}
DebugSettingsEntry::~DebugSettingsEntry()
{
delete ui;
}
void DebugSettingsEntry::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
}
void DebugSettingsEntry::loadFromSettings(const json& data)
{
if(data.contains("name"))
{
ui->NameEdit->setText(QString::fromStdString(data["name"]));
}
if(data.contains("type"))
{
for(unsigned int type_idx = 0; type_idx < NUM_TYPES; type_idx++)
{
if(data["type"] == types[type_idx])
{
ui->TypeComboBox->setCurrentIndex(type_idx);
break;
}
}
}
if(data.contains("layout"))
{
ui->LayoutComboBox->setCurrentIndex(data["layout"]);
}
if(data.contains("single"))
{
ui->SingleCheckBox->setChecked(data["single"]);
}
if(data.contains("linear"))
{
ui->LinearCheckBox->setChecked(data["linear"]);
}
if(data.contains("resizable"))
{
ui->ResizableCheckBox->setChecked(data["resizable"]);
}
if(data.contains("keyboard"))
{
ui->KeyboardCheckBox->setChecked(data["keyboard"]);
}
if(data.contains("underglow"))
{
ui->UnderglowCheckBox->setChecked(data["underglow"]);
}
}
json DebugSettingsEntry::saveSettings()
{
json result;
result["name"] = ui->NameEdit->text().toStdString();
result["type"] = types[ui->TypeComboBox->currentIndex()];
result["layout"] = ui->LayoutComboBox->currentIndex();
result["single"] = ui->SingleCheckBox->isChecked();
result["linear"] = ui->LinearCheckBox->isChecked();
result["resizable"] = ui->ResizableCheckBox->isChecked();
result["keyboard"] = ui->KeyboardCheckBox->isChecked();
result["underglow"] = ui->UnderglowCheckBox->isChecked();
return result;
}
bool DebugSettingsEntry::isDataValid()
{
return true;
}
static BaseManualDeviceEntry* SpawnDebugEntry(const json& data)
{
DebugSettingsEntry* entry = new DebugSettingsEntry;
entry->loadFromSettings(data);
return entry;
}
static const char* DebugDeviceName = QT_TRANSLATE_NOOP("ManualDevice", "Debug Device");
REGISTER_MANUAL_DEVICE_TYPE(DebugDeviceName, "DebugDevices", SpawnDebugEntry);
@@ -0,0 +1,37 @@
/*---------------------------------------------------------*\
| DebugSettingsEntry.h |
| |
| User interface for OpenRGB Debug settings entry |
| |
| Adam Honse <calcprogrammer1@gmail.com> 30 Jul 2025 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "BaseManualDeviceEntry.h"
namespace Ui
{
class DebugSettingsEntry;
}
class DebugSettingsEntry : public BaseManualDeviceEntry
{
Q_OBJECT
public:
explicit DebugSettingsEntry(QWidget *parent = nullptr);
~DebugSettingsEntry();
void loadFromSettings(const json& data);
json saveSettings() override;
bool isDataValid() override;
private:
Ui::DebugSettingsEntry *ui;
private slots:
void changeEvent(QEvent *event) override;
};
@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DebugSettingsEntry</class>
<widget class="QWidget" name="DebugSettingsEntry">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>293</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true">Debug Settings Entry</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Debug Device</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QLabel" name="TypeLabel">
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="NameEdit">
<property name="placeholderText">
<string>Device Name</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="TypeComboBox"/>
</item>
<item row="3" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_Zones">
<property name="title">
<string>Zones</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="1">
<widget class="QCheckBox" name="KeyboardCheckBox">
<property name="text">
<string>Keyboard</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="LinearCheckBox">
<property name="text">
<string>Linear</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="SingleCheckBox">
<property name="text">
<string>Single</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="ResizableCheckBox">
<property name="text">
<string>Resizable</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="UnderglowCheckBox">
<property name="text">
<string>Underglow</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="NameLabel">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="LayoutLabel">
<property name="text">
<string>Layout:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="LayoutComboBox"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,302 @@
/*---------------------------------------------------------*\
| E131SettingsEntry.cpp |
| |
| User interface for OpenRGB E1.31 settings entry |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "E131SettingsEntry.h"
#include "ui_E131SettingsEntry.h"
E131SettingsEntry::E131SettingsEntry(QWidget *parent) :
BaseManualDeviceEntry(parent),
ui(new Ui::E131SettingsEntry)
{
ui->setupUi(this);
ui->TypeComboBox->addItem(tr("Single"));
ui->TypeComboBox->addItem(tr("Linear"));
ui->TypeComboBox->addItem(tr("Matrix"));
ui->MatrixOrderComboBox->addItem(tr("Horizontal Top Left"));
ui->MatrixOrderComboBox->addItem(tr("Horizontal Top Right"));
ui->MatrixOrderComboBox->addItem(tr("Horizontal Bottom Left"));
ui->MatrixOrderComboBox->addItem(tr("Horizontal Bottom Right"));
ui->MatrixOrderComboBox->addItem(tr("Vertical Top Left"));
ui->MatrixOrderComboBox->addItem(tr("Vertical Top Right"));
ui->MatrixOrderComboBox->addItem(tr("Vertical Bottom Left"));
ui->MatrixOrderComboBox->addItem(tr("Vertical Bottom Right"));
ui->RGBOrderComboBox->addItem("RGB");
ui->RGBOrderComboBox->addItem("RBG");
ui->RGBOrderComboBox->addItem("GRB");
ui->RGBOrderComboBox->addItem("GBR");
ui->RGBOrderComboBox->addItem("BRG");
ui->RGBOrderComboBox->addItem("BGR");
HideMatrixSettings();
}
E131SettingsEntry::~E131SettingsEntry()
{
delete ui;
}
void E131SettingsEntry::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
}
void E131SettingsEntry::HideMatrixSettings()
{
ui->MatrixWidthLabel->setDisabled(true);
ui->MatrixWidthEdit->setDisabled(true);
ui->MatrixHeightLabel->setDisabled(true);
ui->MatrixHeightEdit->setDisabled(true);
ui->MatrixOrderLabel->setDisabled(true);
ui->MatrixOrderComboBox->setDisabled(true);
}
void E131SettingsEntry::ShowMatrixSettings()
{
ui->MatrixWidthLabel->setDisabled(false);
ui->MatrixWidthEdit->setDisabled(false);
ui->MatrixHeightLabel->setDisabled(false);
ui->MatrixHeightEdit->setDisabled(false);
ui->MatrixOrderLabel->setDisabled(false);
ui->MatrixOrderComboBox->setDisabled(false);
}
void E131SettingsEntry::on_TypeComboBox_currentIndexChanged(int index)
{
if(index == 2)
{
ShowMatrixSettings();
}
else
{
HideMatrixSettings();
}
}
void E131SettingsEntry::loadFromSettings(const json& data)
{
if(data.contains("name"))
{
ui->NameEdit->setText(QString::fromStdString(data["name"]));
}
if(data.contains("ip"))
{
ui->IPEdit->setText(QString::fromStdString(data["ip"]));
}
if(data.contains("start_universe"))
{
ui->StartUniverseEdit->setText(QString::number((int)data["start_universe"]));
}
if(data.contains("start_channel"))
{
ui->StartChannelEdit->setText(QString::number((int)data["start_channel"]));
}
if(data.contains("num_leds"))
{
ui->NumLEDsEdit->setText(QString::number((int)data["num_leds"]));
}
if(data.contains("type"))
{
if(data["type"].is_string())
{
std::string type_val = data["type"];
if(type_val == "SINGLE")
{
ui->TypeComboBox->setCurrentIndex(0);
}
else if(type_val == "LINEAR")
{
ui->TypeComboBox->setCurrentIndex(1);
}
else if(type_val == "MATRIX")
{
ui->TypeComboBox->setCurrentIndex(2);
}
}
else
{
ui->TypeComboBox->setCurrentIndex(data["type"]);
}
}
if(data.contains("rgb_order"))
{
if(data["rgb_order"].is_string())
{
std::string rgb_order_val = data["rgb_order"];
if(rgb_order_val == "RGB")
{
ui->RGBOrderComboBox->setCurrentIndex(0);
}
else if(rgb_order_val == "RBG")
{
ui->RGBOrderComboBox->setCurrentIndex(1);
}
else if(rgb_order_val == "GRB")
{
ui->RGBOrderComboBox->setCurrentIndex(2);
}
else if(rgb_order_val == "GBR")
{
ui->RGBOrderComboBox->setCurrentIndex(3);
}
else if(rgb_order_val == "BRG")
{
ui->RGBOrderComboBox->setCurrentIndex(4);
}
else if(rgb_order_val == "BGR")
{
ui->RGBOrderComboBox->setCurrentIndex(5);
}
}
else
{
ui->RGBOrderComboBox->setCurrentIndex(data["rgb_order"]);
}
}
if(data.contains("matrix_width"))
{
ui->MatrixWidthEdit->setText(QString::number((int)data["matrix_width"]));
}
if(data.contains("matrix_height"))
{
ui->MatrixHeightEdit->setText(QString::number((int)data["matrix_height"]));
}
if(data.contains("matrix_order"))
{
if(data["matrix_order"].is_string())
{
std::string matrix_order_val = data["matrix_order"];
if(matrix_order_val == "HORIZONTAL_TOP_LEFT")
{
ui->MatrixOrderComboBox->setCurrentIndex(0);
}
else if(matrix_order_val == "HORIZONTAL_TOP_RIGHT")
{
ui->MatrixOrderComboBox->setCurrentIndex(1);
}
else if(matrix_order_val == "HORIZONTAL_BOTTOM_LEFT")
{
ui->MatrixOrderComboBox->setCurrentIndex(2);
}
else if(matrix_order_val == "HORIZONTAL_BOTTOM_RIGHT")
{
ui->MatrixOrderComboBox->setCurrentIndex(3);
}
else if(matrix_order_val == "VERTICAL_TOP_LEFT")
{
ui->MatrixOrderComboBox->setCurrentIndex(4);
}
else if(matrix_order_val == "VERTICAL_TOP_RIGHT")
{
ui->MatrixOrderComboBox->setCurrentIndex(5);
}
else if(matrix_order_val == "VERTICAL_BOTTOM_LEFT")
{
ui->MatrixOrderComboBox->setCurrentIndex(6);
}
else if(matrix_order_val == "VERTICAL_BOTTOM_RIGHT")
{
ui->MatrixOrderComboBox->setCurrentIndex(7);
}
}
else
{
ui->MatrixOrderComboBox->setCurrentIndex(data["matrix_order"]);
}
}
if(data.contains("universe_size"))
{
ui->UniverseSizeEdit->setText(QString::number((int)data["universe_size"]));
}
if(data.contains("keepalive_time"))
{
ui->KeepaliveTimeEdit->setText(QString::number((int)data["keepalive_time"]));
}
}
json E131SettingsEntry::saveSettings()
{
json result;
/*-------------------------------------------------*\
| Required parameters |
\*-------------------------------------------------*/
result["name"] = ui->NameEdit->text().toStdString();
result["start_universe"] = ui->StartUniverseEdit->text().toUInt();
result["start_channel"] = ui->StartChannelEdit->text().toUInt();
result["num_leds"] = ui->NumLEDsEdit->text().toUInt();
result["type"] = ui->TypeComboBox->currentIndex();
result["rgb_order"] = ui->RGBOrderComboBox->currentIndex();
/*-------------------------------------------------*\
| Optional parameters |
\*-------------------------------------------------*/
if(ui->IPEdit->text() != "")
{
result["ip"] = ui->IPEdit->text().toStdString();
}
if(result["type"] == 2)
{
result["matrix_width"] = ui->MatrixWidthEdit->text().toUInt();
result["matrix_height"] = ui->MatrixHeightEdit->text().toUInt();
result["matrix_order"] = ui->MatrixOrderComboBox->currentIndex();
}
if(ui->UniverseSizeEdit->text() != "")
{
result["universe_size"] = ui->UniverseSizeEdit->text().toUInt();
}
if(ui->KeepaliveTimeEdit->text() != "")
{
result["keepalive_time"] = ui->KeepaliveTimeEdit->text().toUInt();
}
return result;
}
bool E131SettingsEntry::isDataValid()
{
// stub
return true;
}
static BaseManualDeviceEntry* SpawnE131Entry(const json& data)
{
E131SettingsEntry* entry = new E131SettingsEntry;
entry->loadFromSettings(data);
return entry;
}
static const char* E131DeviceName = QT_TRANSLATE_NOOP("ManualDevice", "E1.31 (including WLED)");
REGISTER_MANUAL_DEVICE_TYPE(E131DeviceName, "E131Devices", SpawnE131Entry);
@@ -0,0 +1,40 @@
/*---------------------------------------------------------*\
| E131SettingsEntry.h |
| |
| User interface for OpenRGB E1.31 settings entry |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "BaseManualDeviceEntry.h"
namespace Ui
{
class E131SettingsEntry;
}
class E131SettingsEntry : public BaseManualDeviceEntry
{
Q_OBJECT
public:
explicit E131SettingsEntry(QWidget *parent = nullptr);
~E131SettingsEntry();
void loadFromSettings(const json& data);
json saveSettings() override;
bool isDataValid() override;
private:
Ui::E131SettingsEntry *ui;
private:
void HideMatrixSettings();
void ShowMatrixSettings();
private slots:
void changeEvent(QEvent *event) override;
void on_TypeComboBox_currentIndexChanged(int index);
};
@@ -0,0 +1,169 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>E131SettingsEntry</class>
<widget class="QWidget" name="E131SettingsEntry">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>531</width>
<height>256</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true">E.131 Settings Entry</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>E1.31 Device</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="5">
<widget class="QLineEdit" name="StartChannelEdit"/>
</item>
<item row="5" column="3">
<widget class="QLineEdit" name="NumLEDsEdit"/>
</item>
<item row="6" column="3">
<widget class="QLineEdit" name="MatrixWidthEdit"/>
</item>
<item row="2" column="4">
<widget class="QLabel" name="StartChannelLabel">
<property name="text">
<string>Start Channel:</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="NumLEDsLabel">
<property name="text">
<string>Number of LEDs:</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLineEdit" name="StartUniverseEdit"/>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="NameEdit"/>
</item>
<item row="7" column="3">
<widget class="QComboBox" name="MatrixOrderComboBox"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="StartUniverseLabel">
<property name="text">
<string>Start Universe:</string>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QLineEdit" name="IPEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="NameLabel">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="MatrixOrderLabel">
<property name="text">
<string>Matrix Order:</string>
</property>
</widget>
</item>
<item row="5" column="5">
<widget class="QComboBox" name="TypeComboBox"/>
</item>
<item row="6" column="5">
<widget class="QLineEdit" name="MatrixHeightEdit"/>
</item>
<item row="6" column="4">
<widget class="QLabel" name="MatrixHeightLabel">
<property name="text">
<string>Matrix Height:</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="MatrixWidthLabel">
<property name="text">
<string>Matrix Width:</string>
</property>
</widget>
</item>
<item row="5" column="4">
<widget class="QLabel" name="TypeLabel">
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QLabel" name="IPLabel">
<property name="text">
<string>IP (Unicast):</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="UniverseSizeLabel">
<property name="text">
<string>Universe Size:</string>
</property>
</widget>
</item>
<item row="8" column="3">
<widget class="QLineEdit" name="UniverseSizeEdit"/>
</item>
<item row="8" column="4">
<widget class="QLabel" name="KeepaliveTimeLabel">
<property name="text">
<string>Keepalive Time:</string>
</property>
</widget>
</item>
<item row="8" column="5">
<widget class="QLineEdit" name="KeepaliveTimeEdit"/>
</item>
<item row="7" column="4">
<widget class="QLabel" name="RGBOrderLabel">
<property name="text">
<string>RGB Order:</string>
</property>
</widget>
</item>
<item row="7" column="5">
<widget class="QComboBox" name="RGBOrderComboBox"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>NameEdit</tabstop>
<tabstop>IPEdit</tabstop>
<tabstop>StartUniverseEdit</tabstop>
<tabstop>StartChannelEdit</tabstop>
<tabstop>NumLEDsEdit</tabstop>
<tabstop>TypeComboBox</tabstop>
<tabstop>MatrixWidthEdit</tabstop>
<tabstop>MatrixHeightEdit</tabstop>
<tabstop>MatrixOrderComboBox</tabstop>
<tabstop>UniverseSizeEdit</tabstop>
<tabstop>KeepaliveTimeEdit</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,62 @@
/*---------------------------------------------------------*\
| ElgatoKeyLightSettingsEntry.cpp |
| |
| User interface for OpenRGB Elgato Key Light entry |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "ElgatoKeyLightSettingsEntry.h"
#include "ui_ElgatoKeyLightSettingsEntry.h"
ElgatoKeyLightSettingsEntry::ElgatoKeyLightSettingsEntry(QWidget *parent) :
BaseManualDeviceEntry(parent),
ui(new Ui::ElgatoKeyLightSettingsEntry)
{
ui->setupUi(this);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
}
ElgatoKeyLightSettingsEntry::~ElgatoKeyLightSettingsEntry()
{
delete ui;
}
void ElgatoKeyLightSettingsEntry::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
}
void ElgatoKeyLightSettingsEntry::loadFromSettings(const json& data)
{
if(data.contains("ip"))
{
ui->IPEdit->setText(QString::fromStdString(data["ip"]));
}
}
json ElgatoKeyLightSettingsEntry::saveSettings()
{
json result;
result["ip"] = ui->IPEdit->text().toStdString();
return result;
}
bool ElgatoKeyLightSettingsEntry::isDataValid()
{
// stub
return true;
}
static BaseManualDeviceEntry* SpawnElgatoKeyLightEntry(const json& data)
{
ElgatoKeyLightSettingsEntry* entry = new ElgatoKeyLightSettingsEntry;
entry->loadFromSettings(data);
return entry;
}
REGISTER_MANUAL_DEVICE_TYPE("Elgato Key Light", "ElgatoKeyLightDevices", SpawnElgatoKeyLightEntry);
@@ -0,0 +1,35 @@
/*---------------------------------------------------------*\
| ElgatoKeyLightSettingsEntry.h |
| |
| User interface for OpenRGB Elgato Key Light entry |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "BaseManualDeviceEntry.h"
namespace Ui
{
class ElgatoKeyLightSettingsEntry;
}
class ElgatoKeyLightSettingsEntry : public BaseManualDeviceEntry
{
Q_OBJECT
public:
explicit ElgatoKeyLightSettingsEntry(QWidget *parent = nullptr);
~ElgatoKeyLightSettingsEntry();
void loadFromSettings(const json& data);
json saveSettings() override;
bool isDataValid() override;
private:
Ui::ElgatoKeyLightSettingsEntry *ui;
private slots:
void changeEvent(QEvent *event) override;
};
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ElgatoKeyLightSettingsEntry</class>
<widget class="QWidget" name="ElgatoKeyLightSettingsEntry">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>225</width>
<height>108</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Elgato Key Light Settings Entry</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Elgato Key Light</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0" rowspan="2" colspan="2">
<widget class="QLabel" name="label">
<property name="text">
<string>IP:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLineEdit" name="IPEdit"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,63 @@
/*---------------------------------------------------------*\
| ElgatoLightStripSettingsEntry.cpp |
| |
| User interface for OpenRGB Elgato Light Strips entry |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "ElgatoLightStripSettingsEntry.h"
#include "ui_ElgatoLightStripSettingsEntry.h"
ElgatoLightStripSettingsEntry::ElgatoLightStripSettingsEntry(QWidget *parent) :
BaseManualDeviceEntry(parent),
ui(new Ui::ElgatoLightStripSettingsEntry)
{
ui->setupUi(this);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
}
ElgatoLightStripSettingsEntry::~ElgatoLightStripSettingsEntry()
{
delete ui;
}
void ElgatoLightStripSettingsEntry::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
}
void ElgatoLightStripSettingsEntry::loadFromSettings(const json& data)
{
if(data.contains("ip"))
{
ui->IPEdit->setText(QString::fromStdString(data["ip"]));
}
}
json ElgatoLightStripSettingsEntry::saveSettings()
{
json result;
result["ip"] = ui->IPEdit->text().toStdString();
return result;
}
bool ElgatoLightStripSettingsEntry::isDataValid()
{
// stub
return true;
}
static BaseManualDeviceEntry* SpawnElgatoLightStripEntry(const json& data)
{
ElgatoLightStripSettingsEntry* entry = new ElgatoLightStripSettingsEntry;
entry->loadFromSettings(data);
return entry;
}
REGISTER_MANUAL_DEVICE_TYPE("Elgato Light Strip", "ElgatoLightStripDevices", SpawnElgatoLightStripEntry);
@@ -0,0 +1,35 @@
/*---------------------------------------------------------*\
| ElgatoLightStripSettingsEntry.h |
| |
| User interface for OpenRGB Elgato Light Strips entry |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "BaseManualDeviceEntry.h"
namespace Ui
{
class ElgatoLightStripSettingsEntry;
}
class ElgatoLightStripSettingsEntry : public BaseManualDeviceEntry
{
Q_OBJECT
public:
explicit ElgatoLightStripSettingsEntry(QWidget *parent = nullptr);
~ElgatoLightStripSettingsEntry();
void loadFromSettings(const json& data);
json saveSettings() override;
bool isDataValid() override;
private:
Ui::ElgatoLightStripSettingsEntry *ui;
private slots:
void changeEvent(QEvent *event) override;
};
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ElgatoLightStripSettingsEntry</class>
<widget class="QWidget" name="ElgatoLightStripSettingsEntry">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>225</width>
<height>108</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Elgato Light Strip Settings Entry</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Elgato Light Strip</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0" rowspan="2" colspan="2">
<widget class="QLabel" name="label">
<property name="text">
<string>IP:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLineEdit" name="IPEdit"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,63 @@
/*---------------------------------------------------------*\
| GoveeSettingsEntry.cpp |
| |
| User interface for OpenRGB Govee settings entry |
| |
| Adam Honse (calcprogrammer1@gmail.com) 15 May 2025 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "GoveeSettingsEntry.h"
#include "ui_GoveeSettingsEntry.h"
GoveeSettingsEntry::GoveeSettingsEntry(QWidget *parent) :
BaseManualDeviceEntry(parent),
ui(new Ui::GoveeSettingsEntry)
{
ui->setupUi(this);
}
GoveeSettingsEntry::~GoveeSettingsEntry()
{
delete ui;
}
void GoveeSettingsEntry::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
}
void GoveeSettingsEntry::loadFromSettings(const json& data)
{
if(data.contains("ip"))
{
ui->IPEdit->setText(QString::fromStdString(data["ip"]));
}
}
json GoveeSettingsEntry::saveSettings()
{
json result;
result["ip"] = ui->IPEdit->text().toStdString();
return result;
}
bool GoveeSettingsEntry::isDataValid()
{
// stub
return true;
}
static BaseManualDeviceEntry* SpawnGoveeSettingsEntry(const json& data)
{
GoveeSettingsEntry* entry = new GoveeSettingsEntry;
entry->loadFromSettings(data);
return entry;
}
REGISTER_MANUAL_DEVICE_TYPE("Govee", "GoveeDevices", SpawnGoveeSettingsEntry);
@@ -0,0 +1,37 @@
/*---------------------------------------------------------*\
| GoveeSettingsEntry.h |
| |
| User interface for OpenRGB Govee settings entry |
| |
| Adam Honse (calcprogrammer1@gmail.com) 15 May 2025 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "BaseManualDeviceEntry.h"
namespace Ui
{
class GoveeSettingsEntry;
}
class GoveeSettingsEntry : public BaseManualDeviceEntry
{
Q_OBJECT
public:
explicit GoveeSettingsEntry(QWidget *parent = nullptr);
~GoveeSettingsEntry();
void loadFromSettings(const json& data);
json saveSettings() override;
bool isDataValid() override;
private:
Ui::GoveeSettingsEntry *ui;
private slots:
void changeEvent(QEvent *event) override;
};
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GoveeSettingsEntry</class>
<widget class="QWidget" name="GoveeSettingsEntry">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>328</width>
<height>81</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true">Philips Wiz Settings Entry</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Govee Device</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="IPLabel">
<property name="text">
<string>IP:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="IPEdit"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,71 @@
/*---------------------------------------------------------*\
| KasaSmartSettingsEntry.cpp |
| |
| User interface for OpenRGB Kasa Smart settings entry |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "KasaSmartSettingsEntry.h"
#include "ui_KasaSmartSettingsEntry.h"
KasaSmartSettingsEntry::KasaSmartSettingsEntry(QWidget *parent) :
BaseManualDeviceEntry(parent),
ui(new Ui::KasaSmartSettingsEntry)
{
ui->setupUi(this);
}
KasaSmartSettingsEntry::~KasaSmartSettingsEntry()
{
delete ui;
}
void KasaSmartSettingsEntry::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
}
void KasaSmartSettingsEntry::loadFromSettings(const json& data)
{
if(data.contains("ip"))
{
ui->IPEdit->setText(QString::fromStdString(data["ip"]));
}
if(data.contains("name"))
{
ui->NameEdit->setText(QString::fromStdString(data["name"]));
}
}
json KasaSmartSettingsEntry::saveSettings()
{
json result;
result["ip"] = ui->IPEdit->text().toStdString();
result["name"] = ui->NameEdit->text().toStdString();
return result;
}
void KasaSmartSettingsEntry::setName(QString name)
{
ui->NameEdit->setText(name);
}
bool KasaSmartSettingsEntry::isDataValid()
{
// stub
return true;
}
static BaseManualDeviceEntry* SpawnKasaSmartSettingsEntry(const json& data)
{
KasaSmartSettingsEntry* entry = new KasaSmartSettingsEntry;
entry->loadFromSettings(data);
return entry;
}
REGISTER_MANUAL_DEVICE_TYPE("Kasa Smart", "KasaSmartDevices", SpawnKasaSmartSettingsEntry);
@@ -0,0 +1,37 @@
/*---------------------------------------------------------*\
| KasaSmartSettingsEntry.h |
| |
| User interface for OpenRGB Kasa Smart settings entry |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "BaseManualDeviceEntry.h"
namespace Ui
{
class KasaSmartSettingsEntry;
}
class KasaSmartSettingsEntry : public BaseManualDeviceEntry
{
Q_OBJECT
public:
explicit KasaSmartSettingsEntry(QWidget *parent = nullptr);
~KasaSmartSettingsEntry();
void loadFromSettings(const json& data);
void setName(QString name);
json saveSettings() override;
bool isDataValid() override;
private:
Ui::KasaSmartSettingsEntry *ui;
private slots:
void changeEvent(QEvent *event) override;
};
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>KasaSmartSettingsEntry</class>
<widget class="QWidget" name="KasaSmartSettingsEntry">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>216</width>
<height>89</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true">Kasa Smart Settings Entry</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Kasa Smart Device</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="5">
<widget class="QLineEdit" name="NameEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="IPLabel">
<property name="text">
<string>IP:</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="IPEdit"/>
</item>
<item row="1" column="4">
<widget class="QLabel" name="NameLabel">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>IPEdit</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,96 @@
/*---------------------------------------------------------*\
| LIFXSettingsEntry.cpp |
| |
| User interface for OpenRGB LIFX settings entry |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "LIFXSettingsEntry.h"
#include "ui_LIFXSettingsEntry.h"
LIFXSettingsEntry::LIFXSettingsEntry(QWidget *parent) :
BaseManualDeviceEntry(parent),
ui(new Ui::LIFXSettingsEntry)
{
ui->setupUi(this);
connect(ui->MultizoneCheckBox, SIGNAL(stateChanged(int)), this, SLOT(on_MultizoneCheckBox_stateChanged(int)));
}
LIFXSettingsEntry::~LIFXSettingsEntry()
{
delete ui;
}
void LIFXSettingsEntry::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
}
void LIFXSettingsEntry::loadFromSettings(const json& data)
{
if(data.contains("ip"))
{
ui->IPEdit->setText(QString::fromStdString(data["ip"]));
}
if(data.contains("name"))
{
ui->NameEdit->setText(QString::fromStdString(data["name"]));
}
if(data.contains("multizone") && data["multizone"].is_boolean())
{
ui->MultizoneCheckBox->setCheckState(data["multizone"] == true ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
}
if(data.contains("extended_multizone") && data["extended_multizone"].is_boolean())
{
ui->ExtendedMultizoneCheckBox->setCheckState(data["extended_multizone"] == true ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
}
}
json LIFXSettingsEntry::saveSettings()
{
json result;
result["ip"] = ui->IPEdit->text().toStdString();
result["name"] = ui->NameEdit->text().toStdString();
result["multizone"] = ui->MultizoneCheckBox->checkState() == Qt::Checked;
result["extended_multizone"] = ui->ExtendedMultizoneCheckBox->checkState() == Qt::Checked;
return result;
}
void LIFXSettingsEntry::setName(QString name)
{
ui->NameEdit->setText(name);
}
void LIFXSettingsEntry::on_MultizoneCheckBox_stateChanged(int checkState)
{
if (checkState == Qt::Checked)
{
ui->ExtendedMultizoneCheckBox->setEnabled(true);
}
else
{
ui->ExtendedMultizoneCheckBox->setEnabled(false);
ui->ExtendedMultizoneCheckBox->setCheckState(Qt::Unchecked);
}
}
bool LIFXSettingsEntry::isDataValid()
{
// stub
return true;
}
static BaseManualDeviceEntry* SpawnLIFXSettingsEntry(const json& data)
{
LIFXSettingsEntry* entry = new LIFXSettingsEntry;
entry->loadFromSettings(data);
return entry;
}
REGISTER_MANUAL_DEVICE_TYPE("LIFX", "LIFXDevices", SpawnLIFXSettingsEntry);
@@ -0,0 +1,36 @@
/*---------------------------------------------------------*\
| LIFXSettingsEntry.h |
| |
| User interface for OpenRGB LIFX settings entry |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "BaseManualDeviceEntry.h"
namespace Ui
{
class LIFXSettingsEntry;
}
class LIFXSettingsEntry : public BaseManualDeviceEntry
{
Q_OBJECT
public:
explicit LIFXSettingsEntry(QWidget *parent = nullptr);
~LIFXSettingsEntry();
void loadFromSettings(const json& data);
void setName(QString name);
json saveSettings() override;
bool isDataValid() override;
private:
Ui::LIFXSettingsEntry *ui;
private slots:
void changeEvent(QEvent *event) override;
void on_MultizoneCheckBox_stateChanged(int arg1);
};
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LIFXSettingsEntry</class>
<widget class="QWidget" name="LIFXSettingsEntry">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>605</width>
<height>89</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true">LIFX Settings Entry</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>LIFX Device</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="3">
<widget class="QLineEdit" name="IPEdit"/>
</item>
<item row="1" column="6">
<widget class="QCheckBox" name="MultizoneCheckBox">
<property name="text">
<string>Multizone</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="IPLabel">
<property name="text">
<string>IP:</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QLabel" name="NameLabel">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QLineEdit" name="NameEdit"/>
</item>
<item row="1" column="7">
<widget class="QCheckBox" name="ExtendedMultizoneCheckBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Extended Multizone</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>IPEdit</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,340 @@
/*---------------------------------------------------------*\
| ManualDevicesSettingsPage.cpp |
| |
| User interface for OpenRGB Manually Added Devices |
| settings page |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "ManualDevicesSettingsPage.h"
#include "ui_ManualDevicesSettingsPage.h"
#include "NanoleafSettingsEntry.h"
#include "ResourceManager.h"
#include "SettingsManager.h"
#include <QLineEdit>
static void ManualDevicesPageReloadCallback(void* this_ptr)
{
ManualDevicesSettingsPage * this_obj = (ManualDevicesSettingsPage *)this_ptr;
QMetaObject::invokeMethod(this_obj, "reloadList", Qt::QueuedConnection);
}
ManualDevicesSettingsPage::ManualDevicesSettingsPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::ManualDevicesSettingsPage)
{
ui->setupUi(this);
ResourceManager::get()->RegisterDetectionEndCallback(&ManualDevicesPageReloadCallback, this);
addDeviceMenu = new QMenu(this);
ui->addDeviceButton->setMenu(addDeviceMenu);
connect(addDeviceMenu, &QMenu::triggered, this, &ManualDevicesSettingsPage::onAddDeviceItemSelected);
QMenu* saveButtonMenu = new QMenu(this);
saveButtonMenu->addAction(ui->ActionSaveAndRescan);
saveButtonMenu->addAction(ui->ActionSaveNoRescan);
ui->saveConfigurationButton->setMenu(saveButtonMenu);
ui->saveConfigurationButton->setDefaultAction(ui->ActionSaveAndRescan);
reloadList();
}
ManualDevicesSettingsPage::~ManualDevicesSettingsPage()
{
ResourceManager::get()->UnregisterDetectionEndCallback(&ManualDevicesPageReloadCallback, this);
clearList();
delete ui;
}
void ManualDevicesSettingsPage::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
reloadMenu();
}
}
void ManualDevicesSettingsPage::on_removeDeviceButton_clicked()
{
int cur_row = ui->deviceList->currentRow();
if(cur_row < 0)
{
return;
}
QListWidgetItem* item = ui->deviceList->takeItem(cur_row);
ui->deviceList->removeItemWidget(item);
delete item;
BaseManualDeviceEntry* entry = entries[cur_row];
entries.erase(entries.begin() + cur_row);
delete entry;
setUnsavedChanges(true);
}
void ManualDevicesSettingsPage::saveSettings()
{
SettingsManager* sm = ResourceManager::get()->GetSettingsManager();
json result;
/*-----------------------------------------------------------------------------*\
| First, cache the data that will be stored as JSON |
| We wrap data into arrays by type (except Nanoleaf) |
| Nanoleaf stores it's data as an object with "location" as key for some reason |
\*-----------------------------------------------------------------------------*/
for(std::size_t idx = 0; idx < entries.size(); idx++)
{
std::string section = entries[idx]->getSettingsSection();
if(section == "NanoleafDevices")
{
NanoleafSettingsEntry* entry = dynamic_cast<NanoleafSettingsEntry*>(entries[idx]);
result[section]["devices"][entry->getLocation()] = entries[idx]->saveSettings();
}
else if(section == "PhilipsHueDevices")
{
result[section]["bridges"].push_back(entries[idx]->saveSettings());
}
else
{
result[section]["devices"].push_back(entries[idx]->saveSettings());
}
}
/*---------------------------------------------------------*\
| Transfer data from the cached object into config sections |
| Use ALL possible settings entry names, so that those with |
| all entries deleted are cleared properly |
\*---------------------------------------------------------*/
std::vector<ManualDeviceTypeBlock> blocks = ManualDevicesTypeManager::get()->getRegisteredTypes();
for(std::size_t i = 0; i < blocks.size(); i++)
{
sm->SetSettings(blocks[i].settingsSection, result[blocks[i].settingsSection]);
}
sm->SaveSettings();
setUnsavedChanges(false);
}
void ManualDevicesSettingsPage::reloadMenu()
{
std::vector<std::string> names = ManualDevicesTypeManager::get()->getRegisteredTypeNames();
addDeviceMenu->clear();
for(std::size_t i = 0; i < names.size(); i++)
{
QAction* action = addDeviceMenu->addAction(qApp->translate("ManualDevice", names[i].c_str()));
action->setData(QString::fromStdString(names[i]));
}
}
void ManualDevicesSettingsPage::reloadList()
{
clearList();
addDeviceMenu->clear();
std::vector<ManualDeviceTypeBlock> blocks = ManualDevicesTypeManager::get()->getRegisteredTypes();
for(std::size_t i = 0; i < blocks.size(); i++)
{
addEntries(blocks[i]);
/*------------------------------------------------------------*\
| While we have all the data at hand, load in the menu as well |
\*------------------------------------------------------------*/
QAction* action = addDeviceMenu->addAction(qApp->translate("ManualDevice", blocks[i].name.c_str()));
action->setData(QString::fromStdString(blocks[i].name));
}
/*---------------------------------------------------------*\
| Refresh button state |
\*---------------------------------------------------------*/
setUnsavedChanges(false);
on_deviceList_itemSelectionChanged();
}
void ManualDevicesSettingsPage::onTextEditChanged()
{
setUnsavedChanges(true);
}
void ManualDevicesSettingsPage::clearList()
{
std::vector<BaseManualDeviceEntry*> entries_copy;
entries_copy.swap(entries);
ui->deviceList->clear();
for(std::size_t i = 0; i < entries_copy.size(); i++)
{
delete entries_copy[i];
}
entries_copy.clear();
setUnsavedChanges(true);
}
void ManualDevicesSettingsPage::setUnsavedChanges(bool v)
{
unsavedChanges = v;
if(v)
{
ui->saveConfigurationButton->setStyleSheet("font: bold");
}
else
{
ui->saveConfigurationButton->setStyleSheet("");
}
}
bool ManualDevicesSettingsPage::checkValidToSave()
{
for(std::size_t i = 0; i < entries.size(); i++)
{
if(!entries[i]->isDataValid())
{
return false;
}
}
return true;
}
QListWidgetItem* ManualDevicesSettingsPage::addEntry(BaseManualDeviceEntry* entry)
{
if(!entry)
{
return nullptr;
}
/*---------------------------------------------------------*\
| Find EVERY QLineEdit in the entry and get notified if ANY |
| text in them changes - for validation |
| Validation mostly affects the "Save" button state |
\*---------------------------------------------------------*/
QList<QLineEdit*> textEditList = entry->findChildren<QLineEdit*>(QString(), Qt::FindChildrenRecursively);
for(qsizetype i = 0; i < textEditList.size(); i++)
{
connect(textEditList[i], &QLineEdit::textChanged, this, &ManualDevicesSettingsPage::onTextEditChanged);
}
QListWidgetItem* item = new QListWidgetItem;
item->setSizeHint(entry->sizeHint());
ui->deviceList->addItem(item);
ui->deviceList->setItemWidget(item, entry);
ui->deviceList->show();
entries.push_back(entry);
/*---------------------------------------------------------*\
| New entries generally indicate unsaved changes |
\*---------------------------------------------------------*/
setUnsavedChanges(true);
return item;
}
void ManualDevicesSettingsPage::addEntries(const ManualDeviceTypeBlock& block)
{
/*---------------------------------------------------------*\
| Spawn list entries for all config entries of one type |
\*---------------------------------------------------------*/
json settings = ResourceManager::get()->GetSettingsManager()->GetSettings(block.settingsSection);
const char* array_name = "devices";
if(block.settingsSection == "PhilipsHueDevices")
{
array_name = "bridges";
}
if(settings.contains(array_name))
{
json& array_ref = settings[array_name];
if(!array_ref.is_array() && !array_ref.is_object())
{
return;
}
/*-----------------------------------------------------------------*\
| Nanoleaf stores it's data as objects with location field as "key" |
| everything else is arrays |
| For uniformity, use iterators, as if it's always an object |
\*-----------------------------------------------------------------*/
for(json::const_iterator iter = array_ref.begin(); iter != array_ref.end(); ++iter)
{
if(!iter.value().empty())
{
BaseManualDeviceEntry* entry = block.spawn(iter.value());
/*---------------------------------------------------*\
| Note: spawn functions are allowed to return nullptr |
\*---------------------------------------------------*/
if(entry)
{
addEntry(entry);
}
}
}
}
}
void ManualDevicesSettingsPage::onAddDeviceItemSelected(QAction* action)
{
/*---------------------------------------------------------*\
| Spawn new entry based on name |
\*---------------------------------------------------------*/
std::string entryName = action->data().toString().toStdString();
BaseManualDeviceEntry* entry = ManualDevicesTypeManager::get()->spawnByTypeName(entryName, json());
/*---------------------------------------------------------*\
| Note: spawn functions are allowed to return nullptr |
\*---------------------------------------------------------*/
if(entry)
{
QListWidgetItem* item = addEntry(entry);
/*-----------------------------------------------------*\
| Scroll to the newly added entry (last one in the list |
\*-----------------------------------------------------*/
if(item)
{
ui->deviceList->scrollToItem(item);
}
}
}
void ManualDevicesSettingsPage::on_deviceList_itemSelectionChanged()
{
/*---------------------------------------------------------*\
| Enable Remove button if any entry is selected |
\*---------------------------------------------------------*/
int cur_row = ui->deviceList->currentRow();
bool anySelected = (cur_row >= 0);
ui->removeDeviceButton->setEnabled(anySelected);
}
void ManualDevicesSettingsPage::on_ActionSaveNoRescan_triggered()
{
saveSettings();
}
void ManualDevicesSettingsPage::on_ActionSaveAndRescan_triggered()
{
saveSettings();
/*---------------------------------------------------------*\
| Trigger rescan |
\*---------------------------------------------------------*/
ResourceManager::get()->RescanDevices();
}
@@ -0,0 +1,61 @@
/*-----------------------------------------------------------------*\
| ManualDevicesSettingsPage.h |
| |
| User interface for OpenRGB Manually Added Devices settings page |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-only |
\*-----------------------------------------------------------------*/
#pragma once
#include "BaseManualDeviceEntry.h"
#include "ManualDevicesTypeManager.h"
#include "nlohmann/json.hpp"
#include <QWidget>
#include <QMenu>
#include <QListWidgetItem>
using json = nlohmann::json;
namespace Ui
{
class ManualDevicesSettingsPage;
}
class ManualDevicesSettingsPage : public QWidget
{
Q_OBJECT
public:
explicit ManualDevicesSettingsPage(QWidget *parent = nullptr);
~ManualDevicesSettingsPage();
public slots:
void reloadList();
void reloadMenu();
private slots:
void onTextEditChanged(); // Slot connected to all text edits in all entries; for validation & marking dirty changes
void onAddDeviceItemSelected(QAction* action);
void changeEvent(QEvent *event);
void on_removeDeviceButton_clicked();
void on_deviceList_itemSelectionChanged();
void on_ActionSaveNoRescan_triggered();
void on_ActionSaveAndRescan_triggered();
private:
Ui::ManualDevicesSettingsPage* ui;
std::vector<BaseManualDeviceEntry*> entries;
QMenu* addDeviceMenu;
bool unsavedChanges;
QListWidgetItem* addEntry(BaseManualDeviceEntry* entry);
void addEntries(const ManualDeviceTypeBlock&);
void clearList();
void saveSettings();
void setUnsavedChanges(bool v);
bool checkValidToSave();
};
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ManualDevicesSettingsPage</class>
<widget class="QWidget" name="ManualDevicesSettingsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Manually Added Devices Settings Page</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListWidget" name="deviceList">
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="addDeviceButton">
<property name="text">
<string>Add Device...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeDeviceButton">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="saveConfigurationButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Save and Rescan</string>
</property>
<property name="popupMode">
<enum>QToolButton::MenuButtonPopup</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
<action name="ActionSaveAndRescan">
<property name="text">
<string>Save and Rescan</string>
</property>
</action>
<action name="ActionSaveNoRescan">
<property name="text">
<string>Save without Rescan</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,84 @@
/*---------------------------------------------------------*\
| ManualDevicesTypeManager.cpp |
| |
| OpenRGB Manual Devices Type Manager registers available |
| types of Manually Added devices and generates UI |
| elements for their settings |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "ManualDevicesTypeManager.h"
ManualDeviceTypeBlock::ManualDeviceTypeBlock(const std::string& _name, const std::string& _settingsSection, ManualDeviceEntrySpawnFunction _entrySpawnFunction)
{
name = _name;
settingsSection = _settingsSection;
entrySpawnFunction = _entrySpawnFunction;
}
BaseManualDeviceEntry* ManualDeviceTypeBlock::spawn(const json& data) const
{
BaseManualDeviceEntry* result = entrySpawnFunction(data);
if(result)
{
result->setSettingsSection(settingsSection);
}
return result;
}
ManualDevicesTypeManager* ManualDevicesTypeManager::instance;
ManualDevicesTypeManager *ManualDevicesTypeManager::get()
{
if(!instance)
{
instance = new ManualDevicesTypeManager();
}
return instance;
}
ManualDevicesTypeManager::ManualDevicesTypeManager()
{
}
void ManualDevicesTypeManager::registerType(const std::string& name, const std::string& settingsSection, ManualDeviceEntrySpawnFunction entrySpawnFunction)
{
types.push_back(ManualDeviceTypeBlock(name, settingsSection, entrySpawnFunction));
}
std::vector<ManualDeviceTypeBlock> ManualDevicesTypeManager::getRegisteredTypes()
{
return types;
}
std::vector<std::string> ManualDevicesTypeManager::getRegisteredTypeNames()
{
std::vector<std::string> result;
result.resize(types.size());
for(std::size_t i = 0; i < types.size(); i++)
{
result[i] = types[i].name;
}
return result;
}
BaseManualDeviceEntry* ManualDevicesTypeManager::spawnByTypeName(const std::string& typeName, const json& data)
{
for(std::size_t i = 0; i < types.size(); i++)
{
if(types[i].name == typeName)
{
return types[i].spawn(data);
}
}
return nullptr;
}
@@ -0,0 +1,50 @@
/*---------------------------------------------------------*\
| ManualDevicesTypeManager.h |
| |
| OpenRGB Manual Devices Type Manager registers UI |
| classes for managing Manually Added devices |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "BaseManualDeviceEntry.h"
#include <vector>
#include <string>
#include "nlohmann/json.hpp"
using json = nlohmann::json;
class ManualDeviceTypeBlock
{
public:
ManualDeviceTypeBlock(const std::string& name, const std::string& settingsSection, ManualDeviceEntrySpawnFunction entrySpawnFunction);
std::string name; // Name as listed in the drop-down list
std::string settingsSection; // Settings Section name, as listed in Config file
BaseManualDeviceEntry* spawn(const json &data) const;
private:
ManualDeviceEntrySpawnFunction entrySpawnFunction;
};
class ManualDevicesTypeManager
{
public:
static ManualDevicesTypeManager* get();
void registerType(const std::string& name, const std::string& settingsSection, ManualDeviceEntrySpawnFunction entrySpawnFunction);
std::vector<ManualDeviceTypeBlock> getRegisteredTypes();
std::vector<std::string> getRegisteredTypeNames();
BaseManualDeviceEntry* spawnByTypeName(const std::string& typeName, const json& data);
private:
static ManualDevicesTypeManager* instance;
std::vector<ManualDeviceTypeBlock> types;
ManualDevicesTypeManager();
};
@@ -0,0 +1,58 @@
/*---------------------------------------------------------*\
| NanoleafNewDeviceDialog.cpp |
| |
| User interface for OpenRGB Nanoleaf dialog |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <QCloseEvent>
#include "ResourceManager.h"
#include "NanoleafNewDeviceDialog.h"
#include "ui_NanoleafNewDeviceDialog.h"
#ifdef _WIN32
#include <QSettings>
#endif
NanoleafNewDeviceDialog::NanoleafNewDeviceDialog(QWidget *parent) :
QDialog(parent), ui(new Ui::NanoleafNewDeviceDialog)
{
ui->setupUi(this);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
ui->devicePortEdit->setText("16021");
}
NanoleafNewDeviceDialog::~NanoleafNewDeviceDialog()
{
delete ui;
}
void NanoleafNewDeviceDialog::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
}
NanoleafDevice NanoleafNewDeviceDialog::show()
{
NanoleafDevice return_device;
int result = this->exec();
if(result != QDialog::Rejected)
{
return_device.ip = ui->deviceIPEdit->text().toStdString();
return_device.port = ui->devicePortEdit->text().toInt();
}
else
{
return_device.ip = "";
return_device.port = 0;
}
return(return_device);
}
@@ -0,0 +1,38 @@
/*---------------------------------------------------------*\
| NanoleafNewDeviceDialog.h |
| |
| User interface for OpenRGB Nanoleaf dialog |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <QDialog>
struct NanoleafDevice
{
std::string ip;
unsigned int port;
};
namespace Ui
{
class NanoleafNewDeviceDialog;
}
class NanoleafNewDeviceDialog : public QDialog
{
Q_OBJECT
public:
explicit NanoleafNewDeviceDialog(QWidget *parent = nullptr);
~NanoleafNewDeviceDialog();
NanoleafDevice show();
private:
Ui::NanoleafNewDeviceDialog *ui;
private slots:
void changeEvent(QEvent *event);
};
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>NanoleafNewDeviceDialog</class>
<widget class="QDialog" name="NanoleafNewDeviceDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>184</width>
<height>186</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>New Nanoleaf device</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="deviceIPLabel">
<property name="text">
<string>IP address:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="deviceIPEdit"/>
</item>
<item>
<widget class="QLabel" name="devicePortLabel">
<property name="text">
<string>Port:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="devicePortEdit"/>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>NanoleafNewDeviceDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>NanoleafNewDeviceDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
@@ -0,0 +1,149 @@
/*---------------------------------------------------------*\
| NanoleafScanDialog.cpp |
| |
| User interface for Nanoleaf scan & pairing page |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "NanoleafScanDialog.h"
#include "ui_NanoleafScanDialog.h"
#include "NanoleafNewDeviceDialog.h"
#include "ResourceManager.h"
#include "SettingsManager.h"
#include "LogManager.h"
using json = nlohmann::json;
NanoleafScanDialog::NanoleafScanDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::NanoleafScanDialog)
{
ui->setupUi(this);
on_NanoleafDeviceList_itemSelectionChanged(); // Refresh button state
}
NanoleafScanDialog::~NanoleafScanDialog()
{
delete ui;
}
void NanoleafScanDialog::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
}
void NanoleafScanDialog::on_AddNanoleafDeviceButton_clicked()
{
/*-----------------------------------------------------*\
| Open a popup to manually add a device by setting ip |
| and port |
\*-----------------------------------------------------*/
NanoleafNewDeviceDialog dialog;
NanoleafDevice device = dialog.show();
if(!device.ip.empty())
{
LOG_TRACE("[%s] Add %s:%d", "Nanoleaf", device.ip.c_str(), device.port);
std::string location = device.ip+":"+std::to_string(device.port);
if(entries.find(location) == entries.end())
{
NanoleafSettingsEntry* entry = new NanoleafSettingsEntry(QString::fromUtf8(device.ip.c_str()), device.port);
entries[location] = entry;
QListWidgetItem* item = new QListWidgetItem;
item->setSizeHint(entry->sizeHint());
ui->NanoleafDeviceList->addItem(item);
ui->NanoleafDeviceList->setItemWidget(item, entry);
ui->NanoleafDeviceList->show();
json nanoleaf_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("NanoleafDevices");
nanoleaf_settings["devices"][location]["ip"] = device.ip;
nanoleaf_settings["devices"][location]["port"] = device.port;
ResourceManager::get()->GetSettingsManager()->SetSettings("NanoleafDevices", nanoleaf_settings);
ResourceManager::get()->GetSettingsManager()->SaveSettings();
}
}
}
void NanoleafScanDialog::on_RemoveNanoleafDeviceButton_clicked()
{
/*-------------------------------------------------*\
| Remove the selected device |
\*-------------------------------------------------*/
int cur_row = ui->NanoleafDeviceList->currentRow();
if(cur_row < 0)
{
return;
}
QListWidgetItem* item = ui->NanoleafDeviceList->item(cur_row);
NanoleafSettingsEntry* entry = (NanoleafSettingsEntry*) ui->NanoleafDeviceList->itemWidget(item);
ui->NanoleafDeviceList->removeItemWidget(item);
delete item;
std::string location = entry->getLocation();
delete entries[location];
entries.erase(location);
json nanoleaf_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("NanoleafDevices");
nanoleaf_settings["devices"].erase(location);
ResourceManager::get()->GetSettingsManager()->SetSettings("NanoleafDevices", nanoleaf_settings);
ResourceManager::get()->GetSettingsManager()->SaveSettings();
}
void NanoleafScanDialog::on_ScanForNanoleafDevicesButton_clicked()
{
/*-----------------------------------------------------*\
| Create a worker thread for the mDNS query and hookup |
| callbacks for when it finds devices |
\*-----------------------------------------------------*/
NanoleafScanningThread *scanThread = new NanoleafScanningThread;
connect(scanThread, SIGNAL(DeviceFound(QString, int)),
SLOT(on_DeviceFound(QString, int)));
connect(scanThread, SIGNAL(finished()),
scanThread, SLOT(deleteLater()));
scanThread->start();
}
void NanoleafScanDialog::on_DeviceFound(QString address, int port)
{
std::string location = address.toStdString()+":"+std::to_string(port);
if(entries.find(location) == entries.end())
{
NanoleafSettingsEntry* entry = new NanoleafSettingsEntry(address, port);
entries[location] = entry;
QListWidgetItem* item = new QListWidgetItem;
item->setSizeHint(entry->sizeHint());
ui->NanoleafDeviceList->addItem(item);
ui->NanoleafDeviceList->setItemWidget(item, entry);
ui->NanoleafDeviceList->show();
}
}
void NanoleafScanDialog::on_NanoleafDeviceList_itemSelectionChanged()
{
int cur_row = ui->NanoleafDeviceList->currentRow();
bool anySelected = (cur_row >= 0);
ui->RemoveNanoleafDeviceButton->setEnabled(anySelected);
}
@@ -0,0 +1,40 @@
/*---------------------------------------------------------*\
| NanoleafScanDialog.h |
| |
| User interface for OpenRGB Nanoleaf scan & pairing page |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <QDialog>
#include "NanoleafSettingsEntry.h"
namespace Ui
{
class NanoleafScanDialog;
}
class NanoleafScanDialog : public QDialog
{
Q_OBJECT
public:
explicit NanoleafScanDialog(QWidget *parent = nullptr);
~NanoleafScanDialog();
private slots:
void changeEvent(QEvent *event);
void on_AddNanoleafDeviceButton_clicked();
void on_RemoveNanoleafDeviceButton_clicked();
void on_ScanForNanoleafDevicesButton_clicked();
void on_DeviceFound(QString address, int port);
void on_NanoleafDeviceList_itemSelectionChanged();
private:
Ui::NanoleafScanDialog *ui;
std::map<std::string, NanoleafSettingsEntry*> entries;
};
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>NanoleafScanDialog</class>
<widget class="QDialog" name="NanoleafScanDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Nanoleaf Scan Page</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="SyncLabel">
<property name="text">
<string>To pair, hold the on-off button down for 5-7 seconds until the LED starts flashing in a pattern, a new entry should appear in the list below, then click the &quot;Pair&quot; button on the entry within 30 seconds.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="NanoleafDeviceList">
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="ScanForNanoleafDevicesButton">
<property name="text">
<string>Scan</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="AddNanoleafDeviceButton">
<property name="text">
<string>Add manually</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="RemoveNanoleafDeviceButton">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,477 @@
/*---------------------------------------------------------*\
| NanoleafScanningThread.cpp |
| |
| OpenRGB Nanoleaf scanning thread |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#ifdef _WIN32
#define _CRT_SECURE_NO_WARNINGS 1
#endif
#ifdef _WIN32
#include <winsock2.h>
#include <iphlpapi.h>
#else
#include <netdb.h>
#include <ifaddrs.h>
#include <sys/select.h>
#endif
#include "mdns.h"
#include "NanoleafScanningThread.h"
static char namebuffer[256];
static struct sockaddr_in service_address_ipv4;
static struct sockaddr_in6 service_address_ipv6;
static int has_ipv4;
static int has_ipv6;
static mdns_string_t ipv4_address_to_string(char* buffer, size_t capacity, const struct sockaddr_in* addr, size_t addrlen)
{
char host[NI_MAXHOST] = {0};
char service[NI_MAXSERV] = {0};
int ret = getnameinfo((const struct sockaddr*)addr, (socklen_t)addrlen, host, NI_MAXHOST, service, NI_MAXSERV, NI_NUMERICSERV | NI_NUMERICHOST);
int len = 0;
if(ret == 0)
{
len = snprintf(buffer, capacity, "%s", host);
}
if(len >= (int)capacity)
{
len = (int)capacity - 1;
}
mdns_string_t str;
str.str = buffer;
str.length = len;
return str;
}
static mdns_string_t ipv6_address_to_string(char* buffer, size_t capacity, const struct sockaddr_in6* addr, size_t addrlen)
{
char host[NI_MAXHOST] = {0};
char service[NI_MAXSERV] = {0};
int ret = getnameinfo((const struct sockaddr*)addr, (socklen_t)addrlen, host, NI_MAXHOST, service, NI_MAXSERV, NI_NUMERICSERV | NI_NUMERICHOST);
int len = 0;
if(ret == 0)
{
if(addr->sin6_port != 0)
{
len = snprintf(buffer, capacity, "[%s]:%s", host, service);
}
else
{
len = snprintf(buffer, capacity, "%s", host);
}
}
if(len >= (int)capacity)
{
len = (int)capacity - 1;
}
mdns_string_t str;
str.str = buffer;
str.length = len;
return str;
}
/*-----------------------------------------------------*\
| Open sockets for sending one-shot multicast queries |
| from an ephemeral port |
\*-----------------------------------------------------*/
static int open_client_sockets(int* sockets, int max_sockets, int port)
{
/*-----------------------------------------------------*\
| When sending, each socket can only send to one |
| network interface from an ephemeral port, thus we |
| need to open one socket for each interface and |
| address family |
\*-----------------------------------------------------*/
int num_sockets = 0;
#ifdef _WIN32
IP_ADAPTER_ADDRESSES* adapter_address = 0;
ULONG address_size = 8000;
unsigned int ret;
unsigned int num_retries = 4;
do
{
adapter_address = (IP_ADAPTER_ADDRESSES*)malloc(address_size);
ret = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_ANYCAST, 0, adapter_address, &address_size);
if(ret == ERROR_BUFFER_OVERFLOW)
{
free(adapter_address);
adapter_address = 0;
address_size *= 2;
}
else
{
break;
}
}
while(num_retries-- > 0);
if(!adapter_address || (ret != NO_ERROR))
{
free(adapter_address);
return num_sockets;
}
int first_ipv4 = 1;
int first_ipv6 = 1;
for(PIP_ADAPTER_ADDRESSES adapter = adapter_address; adapter; adapter = adapter->Next)
{
if(adapter->TunnelType == TUNNEL_TYPE_TEREDO)
{
continue;
}
if(adapter->OperStatus != IfOperStatusUp)
{
continue;
}
for(IP_ADAPTER_UNICAST_ADDRESS* unicast = adapter->FirstUnicastAddress; unicast; unicast = unicast->Next)
{
if(unicast->Address.lpSockaddr->sa_family == AF_INET)
{
struct sockaddr_in* saddr = (struct sockaddr_in*)unicast->Address.lpSockaddr;
if((saddr->sin_addr.S_un.S_un_b.s_b1 != 127) ||
(saddr->sin_addr.S_un.S_un_b.s_b2 != 0) ||
(saddr->sin_addr.S_un.S_un_b.s_b3 != 0) ||
(saddr->sin_addr.S_un.S_un_b.s_b4 != 1))
{
int log_addr = 0;
if(first_ipv4)
{
service_address_ipv4 = *saddr;
first_ipv4 = 0;
log_addr = 1;
}
has_ipv4 = 1;
if(num_sockets < max_sockets)
{
saddr->sin_port = htons((unsigned short)port);
int sock = mdns_socket_open_ipv4(saddr);
if(sock >= 0)
{
sockets[num_sockets++] = sock;
log_addr = 1;
}
else
{
log_addr = 0;
}
}
if(log_addr)
{
char buffer[128];
ipv4_address_to_string(buffer, sizeof(buffer), saddr, sizeof(struct sockaddr_in));
}
}
}
else if(unicast->Address.lpSockaddr->sa_family == AF_INET6)
{
struct sockaddr_in6* saddr = (struct sockaddr_in6*)unicast->Address.lpSockaddr;
static const unsigned char localhost[] = {0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1};
static const unsigned char localhost_mapped[] = {0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0xff, 0xff, 0x7f, 0, 0, 1};
if((unicast->DadState == NldsPreferred) &&
memcmp(saddr->sin6_addr.s6_addr, localhost, 16) &&
memcmp(saddr->sin6_addr.s6_addr, localhost_mapped, 16))
{
int log_addr = 0;
if(first_ipv6)
{
service_address_ipv6 = *saddr;
first_ipv6 = 0;
log_addr = 1;
}
has_ipv6 = 1;
if(num_sockets < max_sockets)
{
saddr->sin6_port = htons((unsigned short)port);
int sock = mdns_socket_open_ipv6(saddr);
if(sock >= 0)
{
sockets[num_sockets++] = sock;
log_addr = 1;
}
else
{
log_addr = 0;
}
}
if(log_addr)
{
char buffer[128];
ipv6_address_to_string(buffer, sizeof(buffer), saddr, sizeof(struct sockaddr_in6));
}
}
}
}
}
free(adapter_address);
#else
struct ifaddrs* ifaddr = 0;
struct ifaddrs* ifa = 0;
getifaddrs(&ifaddr);
int first_ipv4 = 1;
int first_ipv6 = 1;
for(ifa = ifaddr; ifa; ifa = ifa->ifa_next)
{
if(!ifa->ifa_addr)
{
continue;
}
if(ifa->ifa_addr->sa_family == AF_INET)
{
struct sockaddr_in* saddr = (struct sockaddr_in*)ifa->ifa_addr;
if(saddr->sin_addr.s_addr != htonl(INADDR_LOOPBACK))
{
int log_addr = 0;
if(first_ipv4)
{
service_address_ipv4 = *saddr;
first_ipv4 = 0;
log_addr = 1;
}
has_ipv4 = 1;
if(num_sockets < max_sockets)
{
saddr->sin_port = htons(port);
int sock = mdns_socket_open_ipv4(saddr);
if(sock >= 0)
{
sockets[num_sockets++] = sock;
log_addr = 1;
}
else
{
log_addr = 0;
}
}
if(log_addr)
{
char buffer[128];
ipv4_address_to_string(buffer, sizeof(buffer), saddr, sizeof(struct sockaddr_in));
}
}
}
else if(ifa->ifa_addr->sa_family == AF_INET6)
{
struct sockaddr_in6* saddr = (struct sockaddr_in6*)ifa->ifa_addr;
static const unsigned char localhost[] = {0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1};
static const unsigned char localhost_mapped[] = {0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0xff, 0xff, 0x7f, 0, 0, 1};
if (memcmp(saddr->sin6_addr.s6_addr, localhost, 16) &&
memcmp(saddr->sin6_addr.s6_addr, localhost_mapped, 16))
{
int log_addr = 0;
if(first_ipv6)
{
service_address_ipv6 = *saddr;
first_ipv6 = 0;
log_addr = 1;
}
has_ipv6 = 1;
if(num_sockets < max_sockets)
{
saddr->sin6_port = htons(port);
int sock = mdns_socket_open_ipv6(saddr);
if (sock >= 0)
{
sockets[num_sockets++] = sock;
log_addr = 1;
}
else
{
log_addr = 0;
}
}
if(log_addr)
{
char buffer[128];
ipv6_address_to_string(buffer, sizeof(buffer), saddr, sizeof(struct sockaddr_in6));
}
}
}
}
freeifaddrs(ifaddr);
#endif
return num_sockets;
}
/*-----------------------------------------------------*\
| Callback handling parsing answers to queries sent |
\*-----------------------------------------------------*/
static int query_callback(
int sock,
[[maybe_unused]] const struct sockaddr* from,
[[maybe_unused]] size_t addrlen,
[[maybe_unused]] mdns_entry_type_t entry,
uint16_t query_id,
uint16_t rtype,
[[maybe_unused]] uint16_t rclass,
[[maybe_unused]] uint32_t ttl,
const void* data,
size_t size,
[[maybe_unused]] size_t name_offset,
size_t name_length,
size_t record_offset,
size_t record_length,
void* user_data)
{
(void)sizeof(sock);
(void)sizeof(query_id);
(void)sizeof(name_length);
(void)sizeof(user_data);
if(rtype == MDNS_RECORDTYPE_A)
{
struct sockaddr_in address;
mdns_record_parse_a(data, size, record_offset, record_length, &address);
if(address.sin_port == 0)
{
address.sin_port = 16021; // Default Nanoleaf port.
}
mdns_string_t addrstr = ipv4_address_to_string(namebuffer, sizeof(namebuffer), &address, sizeof(address));
(static_cast<NanoleafScanningThread*>(user_data))->EmitDeviceFound(addrstr.str, address.sin_port);
}
return 0;
}
void NanoleafScanningThread::EmitDeviceFound(QString address, int port)
{
emit DeviceFound(address, port);
}
/*-----------------------------------------------------*\
| Send a mDNS query |
\*-----------------------------------------------------*/
int NanoleafScanningThread::SendMDNSQuery()
{
const char* service = "_nanoleafapi._tcp.local.";
mdns_record_type record = MDNS_RECORDTYPE_PTR;
int sockets[32];
int query_id[32];
int num_sockets = open_client_sockets(sockets, sizeof(sockets) / sizeof(sockets[0]), 0);
if (num_sockets <= 0)
{
return -1;
}
size_t capacity = 2048;
void* buffer = malloc(capacity);
size_t records;
//const char* record_name;
if(record == MDNS_RECORDTYPE_SRV)
{
//record_name = "SRV";
}
else if(record == MDNS_RECORDTYPE_A)
{
//record_name = "A";
}
else if(record == MDNS_RECORDTYPE_AAAA)
{
//record_name = "AAAA";
}
else
{
record = MDNS_RECORDTYPE_PTR;
}
for(int isock = 0; isock < num_sockets; ++isock)
{
query_id[isock] = mdns_query_send(sockets[isock], record, service, strlen(service), buffer, capacity, 0);
}
/*-----------------------------------------------------*\
| This is a simple implementation that loops for |
| 5 seconds or as long as we get replies |
\*-----------------------------------------------------*/
int res;
do
{
struct timeval timeout;
timeout.tv_sec = 5;
timeout.tv_usec = 0;
int nfds = 0;
fd_set readfs;
FD_ZERO(&readfs);
for(int isock = 0; isock < num_sockets; ++isock)
{
if(sockets[isock] >= nfds)
{
nfds = sockets[isock] + 1;
}
FD_SET(sockets[isock], &readfs);
}
records = 0;
res = select(nfds, &readfs, 0, 0, &timeout);
if(res > 0)
{
for(int isock = 0; isock < num_sockets; ++isock)
{
if(FD_ISSET(sockets[isock], &readfs))
{
records += mdns_query_recv(sockets[isock], buffer, capacity, query_callback, this, query_id[isock]);
}
FD_SET(sockets[isock], &readfs);
}
}
}
while (res > 0);
free(buffer);
for(int isock = 0; isock < num_sockets; ++isock)
{
mdns_socket_close(sockets[isock]);
}
return 0;
}
void NanoleafScanningThread::run()
{
SendMDNSQuery();
}
@@ -0,0 +1,25 @@
/*---------------------------------------------------------*\
| NanoleafScanningThread.h |
| |
| OpenRGB Nanoleaf scanning thread |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <QThread>
class NanoleafScanningThread : public QThread
{
Q_OBJECT
void run();
int SendMDNSQuery();
signals:
void DeviceFound(QString address, int port);
public:
void EmitDeviceFound(QString address, int port);
};
@@ -0,0 +1,177 @@
/*---------------------------------------------------------*\
| NanoleafSettingsEntry.cpp |
| |
| User interface for OpenRGB Nanoleaf settings entry |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "NanoleafSettingsEntry.h"
#include "ui_NanoleafSettingsEntry.h"
#include "NanoleafScanDialog.h"
#include "ResourceManager.h"
#include "SettingsManager.h"
#include "NanoleafController.h"
NanoleafSettingsEntry::NanoleafSettingsEntry(QWidget *parent) :
BaseManualDeviceEntry(parent),
ui(new Ui::NanoleafSettingsEntry),
paired(false)
{
ui->setupUi(this);
}
NanoleafSettingsEntry::NanoleafSettingsEntry(QString a_address, int a_port) :
NanoleafSettingsEntry(nullptr)
{
address = a_address;
port = a_port;
const std::string location = getLocation();
ui->IPValue->setText(address);
ui->PortValue->setText(QString::fromStdString(std::to_string(a_port)));
json nanoleaf_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("NanoleafDevices");
if(nanoleaf_settings["devices"].contains(location) &&
nanoleaf_settings["devices"][location].contains("auth_token") &&
nanoleaf_settings["devices"][location]["auth_token"].size())
{
paired = true;
auth_token = nanoleaf_settings["devices"][location]["auth_token"];
ui->AuthKeyValue->setText(QString::fromStdString(auth_token));
ui->PairButton->hide();
}
else
{
ui->UnpairButton->hide();
}
}
NanoleafSettingsEntry::~NanoleafSettingsEntry()
{
delete ui;
}
void NanoleafSettingsEntry::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
}
void NanoleafSettingsEntry::on_PairButton_clicked()
{
try
{
auth_token = NanoleafController::Pair(address.toStdString(), port);
// Save auth token.
std::string location = getLocation();
json nanoleaf_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("NanoleafDevices");
nanoleaf_settings["devices"][location]["ip"] = address.toStdString();
nanoleaf_settings["devices"][location]["port"] = port;
nanoleaf_settings["devices"][location]["auth_token"] = auth_token;
ResourceManager::get()->GetSettingsManager()->SetSettings("NanoleafDevices", nanoleaf_settings);
ResourceManager::get()->GetSettingsManager()->SaveSettings();
// Update UI.
paired = true;
ui->AuthKeyValue->setText(QString::fromStdString(auth_token));
ui->PairButton->hide();
ui->UnpairButton->show();
}
catch(const std::exception& /*e*/)
{
paired = false;
ui->AuthKeyValue->setText("PAIRING FAILED");
}
}
void NanoleafSettingsEntry::on_UnpairButton_clicked()
{
NanoleafController::Unpair(address.toStdString(), port, auth_token);
std::string location = getLocation();
json nanoleaf_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("NanoleafDevices");
nanoleaf_settings["devices"].erase(location);
ResourceManager::get()->GetSettingsManager()->SetSettings("NanoleafDevices", nanoleaf_settings);
ResourceManager::get()->GetSettingsManager()->SaveSettings();
paired = false;
ui->AuthKeyValue->setText("");
ui->PairButton->show();
ui->UnpairButton->hide();
}
void NanoleafSettingsEntry::loadFromSettings(const json& data)
{
address = QString::fromStdString(data["ip"]);
port = data["port"];
ui->IPValue->setText(address);
ui->PortValue->setText(QString::fromStdString(std::to_string(port)));
if(data.contains("auth_token") && data["auth_token"].size())
{
auth_token = data["auth_token"];
ui->AuthKeyValue->setText(QString::fromStdString(auth_token));
ui->PairButton->hide();
}
else
{
auth_token.clear();
ui->UnpairButton->hide();
}
}
json NanoleafSettingsEntry::saveSettings()
{
json result;
/*-------------------------------------------------*\
| Required parameters |
\*-------------------------------------------------*/
result["ip"] = address.toStdString();
result["port"] = port;
if(!auth_token.empty())
{
result["auth_token"] = auth_token;
}
return result;
}
std::string NanoleafSettingsEntry::getLocation()
{
return (address.toStdString() + ":" + std::to_string(port));
}
bool NanoleafSettingsEntry::isDataValid()
{
// stub
return true;
}
static BaseManualDeviceEntry* SpawnNanoleafSettingsEntry(const json& data)
{
if(data.empty())
{
// A special case: we open a new scanning dialog instead of returning a new entry
// The caller should be able to handle this
NanoleafScanDialog scanPage;
scanPage.exec();
return nullptr;
}
else
{
NanoleafSettingsEntry* entry = new NanoleafSettingsEntry;
entry->loadFromSettings(data);
return entry;
}
}
REGISTER_MANUAL_DEVICE_TYPE("Nanoleaf", "NanoleafDevices", SpawnNanoleafSettingsEntry);
@@ -0,0 +1,45 @@
/*---------------------------------------------------------*\
| NanoleafSettingsEntry.h |
| |
| User interface for OpenRGB Nanoleaf settings entry |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "BaseManualDeviceEntry.h"
#include "NanoleafScanningThread.h"
namespace Ui
{
class NanoleafSettingsEntry;
}
class NanoleafSettingsEntry : public BaseManualDeviceEntry
{
Q_OBJECT
public:
explicit NanoleafSettingsEntry(QWidget *parent = nullptr);
NanoleafSettingsEntry(QString a_address, int a_port);
~NanoleafSettingsEntry();
void loadFromSettings(const json& data);
std::string getLocation();
json saveSettings() override;
bool isDataValid() override;
private slots:
void changeEvent(QEvent *event) override;
void on_UnpairButton_clicked();
void on_PairButton_clicked();
private:
Ui::NanoleafSettingsEntry *ui;
QString address;
int port;
std::string auth_token;
bool paired;
};
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>NanoleafSettingsEntry</class>
<widget class="QWidget" name="NanoleafSettingsEntry">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>287</width>
<height>207</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true">Nanoleaf Settings Entry</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Nanoleaf Device</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QLabel" name="IPLabel">
<property name="text">
<string>IP:</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="4">
<widget class="QLabel" name="IPValue">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="PortLabel">
<property name="text">
<string>Port:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="PortValue">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="AuthKeyLabel">
<property name="text">
<string>Auth Key:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="AuthKeyValue">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="UnpairButton">
<property name="text">
<string>Unpair</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="PairButton">
<property name="text">
<string>Pair</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,109 @@
/*---------------------------------------------------------*\
| PhilipsHueSettingsEntry.cpp |
| |
| User interface for OpenRGB Philips Hue settings entry |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "PhilipsHueSettingsEntry.h"
#include "ui_PhilipsHueSettingsEntry.h"
PhilipsHueSettingsEntry::PhilipsHueSettingsEntry(QWidget *parent) :
BaseManualDeviceEntry(parent),
ui(new Ui::PhilipsHueSettingsEntry)
{
ui->setupUi(this);
}
PhilipsHueSettingsEntry::~PhilipsHueSettingsEntry()
{
delete ui;
}
void PhilipsHueSettingsEntry::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
}
void PhilipsHueSettingsEntry::on_UnpairButton_clicked()
{
ui->UsernameValue->setText("");
ui->ClientKeyValue->setText("");
}
void PhilipsHueSettingsEntry::loadFromSettings(const json& data)
{
if(data.contains("ip"))
{
ui->IPEdit->setText(QString::fromStdString(data["ip"]));
}
if(data.contains("mac"))
{
ui->MACEdit->setText(QString::fromStdString(data["mac"]));
}
if(data.contains("entertainment"))
{
ui->EntertainmentCheckBox->setChecked(data["entertainment"]);
}
if(data.contains("autoconnect"))
{
ui->AutoConnectCheckBox->setChecked(data["autoconnect"]);
}
if(data.contains("username"))
{
ui->UsernameValue->setText(QString::fromStdString(data["username"]));
}
if(data.contains("clientkey"))
{
ui->ClientKeyValue->setText(QString::fromStdString(data["clientkey"]));
}
}
json PhilipsHueSettingsEntry::saveSettings()
{
json result;
/*-------------------------------------------------*\
| Required parameters |
\*-------------------------------------------------*/
result["ip"] = ui->IPEdit->text().toStdString();
result["mac"] = ui->MACEdit->text().toStdString();
result["entertainment"] = ui->EntertainmentCheckBox->isChecked();
result["autoconnect"] = ui->AutoConnectCheckBox->isChecked();
if(ui->UsernameValue->text() != "")
{
result["username"] = ui->UsernameValue->text().toStdString();
}
if(ui->ClientKeyValue->text() != "")
{
result["clientkey"] = ui->ClientKeyValue->text().toStdString();
}
return result;
}
bool PhilipsHueSettingsEntry::isDataValid()
{
// stub
return true;
}
static BaseManualDeviceEntry* SpawnPhilipsHueSettingsEntry(const json& data)
{
PhilipsHueSettingsEntry* entry = new PhilipsHueSettingsEntry;
entry->loadFromSettings(data);
return entry;
}
REGISTER_MANUAL_DEVICE_TYPE("Philips Hue", "PhilipsHueDevices", SpawnPhilipsHueSettingsEntry);
@@ -0,0 +1,36 @@
/*---------------------------------------------------------*\
| PhilipsHueSettingsEntry.h |
| |
| User interface for OpenRGB Philips Hue settings entry |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "BaseManualDeviceEntry.h"
namespace Ui
{
class PhilipsHueSettingsEntry;
}
class PhilipsHueSettingsEntry : public BaseManualDeviceEntry
{
Q_OBJECT
public:
explicit PhilipsHueSettingsEntry(QWidget *parent = nullptr);
~PhilipsHueSettingsEntry();
void loadFromSettings(const json& data);
json saveSettings() override;
bool isDataValid() override;
private:
Ui::PhilipsHueSettingsEntry *ui;
private slots:
void changeEvent(QEvent *event) override;
void on_UnpairButton_clicked();
};
@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PhilipsHueSettingsEntry</class>
<widget class="QWidget" name="PhilipsHueSettingsEntry">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>297</width>
<height>260</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true">Philips Hue Settings Entry</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Philips Hue Bridge</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="3" column="0">
<widget class="QLabel" name="EntertainmentLabel">
<property name="text">
<string>Entertainment Mode:</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QCheckBox" name="EntertainmentCheckBox">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="AutoConnectLabel">
<property name="text">
<string>Auto Connect Group:</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QCheckBox" name="AutoConnectCheckBox">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="IPLabel">
<property name="text">
<string>IP:</string>
</property>
</widget>
</item>
<item row="6" column="3">
<widget class="QLabel" name="ClientKeyValue">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="ClientKeyLabel">
<property name="text">
<string>Client Key:</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="UsernameLabel">
<property name="text">
<string>Username:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="MACLabel">
<property name="text">
<string>MAC:</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="4">
<widget class="QPushButton" name="UnpairButton">
<property name="text">
<string>Unpair Bridge</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLineEdit" name="MACEdit"/>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="IPEdit"/>
</item>
<item row="5" column="3">
<widget class="QLabel" name="UsernameValue">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>IPEdit</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,86 @@
/*---------------------------------------------------------*\
| PhilipsWizSettingsEntry.cpp |
| |
| User interface for OpenRGB Philips Wiz settings entry |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "PhilipsWizSettingsEntry.h"
#include "ui_PhilipsWizSettingsEntry.h"
PhilipsWizSettingsEntry::PhilipsWizSettingsEntry(QWidget *parent) :
BaseManualDeviceEntry(parent),
ui(new Ui::PhilipsWizSettingsEntry)
{
ui->setupUi(this);
ui->WhiteStrategyComboBox->addItem(tr("Average"));
ui->WhiteStrategyComboBox->addItem(tr("Minimum"));
}
PhilipsWizSettingsEntry::~PhilipsWizSettingsEntry()
{
delete ui;
}
void PhilipsWizSettingsEntry::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
}
void PhilipsWizSettingsEntry::loadFromSettings(const json& data)
{
if(data.contains("ip"))
{
ui->IPEdit->setText(QString::fromStdString(data["ip"]));
}
if(data.contains("use_cool_white"))
{
ui->UseCoolWhiteCheckBox->setChecked(data["use_cool_white"]);
}
if(data.contains("use_warm_white"))
{
ui->UseWarmWhiteCheckBox->setChecked(data["use_warm_white"]);
}
if(data.contains("selected_white_strategy"))
{
ui->WhiteStrategyComboBox->setCurrentText(QString::fromStdString(data["selected_white_strategy"]));
}
}
json PhilipsWizSettingsEntry::saveSettings()
{
json result;
/*-------------------------------------------------*\
| Required parameters |
\*-------------------------------------------------*/
result["ip"] = ui->IPEdit->text().toStdString();
result["use_cool_white"] = ui->UseCoolWhiteCheckBox->isChecked();
result["use_warm_white"] = ui->UseWarmWhiteCheckBox->isChecked();
result["selected_white_strategy"] = ui->WhiteStrategyComboBox->currentText().toStdString();
return result;
}
bool PhilipsWizSettingsEntry::isDataValid()
{
// stub
return true;
}
static BaseManualDeviceEntry* SpawnPhilipsWizSettingsEntry(const json& data)
{
PhilipsWizSettingsEntry* entry = new PhilipsWizSettingsEntry;
entry->loadFromSettings(data);
return entry;
}
REGISTER_MANUAL_DEVICE_TYPE("Philips Wiz", "PhilipsWizDevices", SpawnPhilipsWizSettingsEntry);
@@ -0,0 +1,35 @@
/*---------------------------------------------------------*\
| PhilipsWizSettingsEntry.h |
| |
| User interface for OpenRGB Philips Wiz settings entry |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "BaseManualDeviceEntry.h"
namespace Ui
{
class PhilipsWizSettingsEntry;
}
class PhilipsWizSettingsEntry : public BaseManualDeviceEntry
{
Q_OBJECT
public:
explicit PhilipsWizSettingsEntry(QWidget *parent = nullptr);
~PhilipsWizSettingsEntry();
void loadFromSettings(const json& data);
json saveSettings() override;
bool isDataValid() override;
private:
Ui::PhilipsWizSettingsEntry *ui;
private slots:
void changeEvent(QEvent *event) override;
};
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PhilipsWizSettingsEntry</class>
<widget class="QWidget" name="PhilipsWizSettingsEntry">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>327</width>
<height>149</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true">Philips Wiz Settings Entry</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Philips Wiz Device</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="0">
<widget class="QCheckBox" name="UseCoolWhiteCheckBox">
<property name="text">
<string>Use Cool White</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="UseWarmWhiteCheckBox">
<property name="text">
<string>Use Warm White</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="IPEdit"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="IPLabel">
<property name="text">
<string>IP:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="WhiteStrategyComboBox"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="WhiteStrategyLabel">
<property name="text">
<string>White Strategy:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,79 @@
/*---------------------------------------------------------*\
| QMKORGBSettingsEntry.cpp |
| |
| User interface entry for OpenRGB QMK configuration |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "QMKORGBSettingsEntry.h"
#include "ui_QMKORGBSettingsEntry.h"
QMKORGBSettingsEntry::QMKORGBSettingsEntry(QWidget *parent) :
BaseManualDeviceEntry(parent),
ui(new Ui::QMKORGBSettingsEntry)
{
ui->setupUi(this);
}
QMKORGBSettingsEntry::~QMKORGBSettingsEntry()
{
delete ui;
}
void QMKORGBSettingsEntry::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
}
void QMKORGBSettingsEntry::loadFromSettings(const json& data)
{
if(data.contains("name"))
{
ui->NameEdit->setText(QString::fromStdString(data["name"]));
}
if(data.contains("usb_vid"))
{
ui->USBVIDEdit->setText(QString::fromStdString(data["usb_vid"]));
}
if(data.contains("usb_pid"))
{
ui->USBPIDEdit->setText(QString::fromStdString(data["usb_pid"]));
}
}
json QMKORGBSettingsEntry::saveSettings()
{
json result;
/*-------------------------------------------------*\
| Required parameters |
\*-------------------------------------------------*/
result["name"] = ui->NameEdit->text().toStdString();
result["usb_vid"] = ui->USBVIDEdit->text().toStdString();
result["usb_pid"] = ui->USBPIDEdit->text().toStdString();
return result;
}
bool QMKORGBSettingsEntry::isDataValid()
{
// stub
return true;
}
static BaseManualDeviceEntry* SpawnQMKORGBSettingsEntry(const json& data)
{
QMKORGBSettingsEntry* entry = new QMKORGBSettingsEntry;
entry->loadFromSettings(data);
return entry;
}
static const char* QMKDeviceName = QT_TRANSLATE_NOOP("ManualDevice", "QMK (OpenRGB Protocol)");
REGISTER_MANUAL_DEVICE_TYPE(QMKDeviceName, "QMKOpenRGBDevices", SpawnQMKORGBSettingsEntry);
@@ -0,0 +1,35 @@
/*---------------------------------------------------------*\
| QMKORGBSettingsEntry.h |
| |
| User interface entry for OpenRGB QMK configuration |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "BaseManualDeviceEntry.h"
namespace Ui
{
class QMKORGBSettingsEntry;
}
class QMKORGBSettingsEntry : public BaseManualDeviceEntry
{
Q_OBJECT
private slots:
void changeEvent(QEvent *event) override;
public:
explicit QMKORGBSettingsEntry(QWidget *parent = nullptr);
~QMKORGBSettingsEntry();
void loadFromSettings(const json& data);
json saveSettings() override;
bool isDataValid() override;
private:
Ui::QMKORGBSettingsEntry *ui;
};
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QMKORGBSettingsEntry</class>
<widget class="QWidget" name="QMKORGBSettingsEntry">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>531</width>
<height>237</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true"> QMK OpenRGB Settings Entry</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>QMK OpenRGB Device</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="5">
<widget class="QLineEdit" name="USBPIDEdit"/>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="NameEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="NameLabel">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLineEdit" name="USBVIDEdit"/>
</item>
<item row="2" column="4">
<widget class="QLabel" name="USBPIDLabel">
<property name="text">
<string>USB PID:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="USBVIDLabel">
<property name="text">
<string>USB VID:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>NameEdit</tabstop>
<tabstop>USBVIDEdit</tabstop>
<tabstop>USBPIDEdit</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,79 @@
/*---------------------------------------------------------*\
| QMKVialRGBSettingsEntry.cpp |
| |
| User interface entry for VialRGB QMK configuration |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "QMKVialRGBSettingsEntry.h"
#include "ui_QMKVialRGBSettingsEntry.h"
QMKVialRGBSettingsEntry::QMKVialRGBSettingsEntry(QWidget *parent) :
BaseManualDeviceEntry(parent),
ui(new Ui::QMKVialRGBSettingsEntry)
{
ui->setupUi(this);
}
QMKVialRGBSettingsEntry::~QMKVialRGBSettingsEntry()
{
delete ui;
}
void QMKVialRGBSettingsEntry::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
}
void QMKVialRGBSettingsEntry::loadFromSettings(const json& data)
{
if(data.contains("name"))
{
ui->NameEdit->setText(QString::fromStdString(data["name"]));
}
if(data.contains("usb_vid"))
{
ui->USBVIDEdit->setText(QString::fromStdString(data["usb_vid"]));
}
if(data.contains("usb_pid"))
{
ui->USBPIDEdit->setText(QString::fromStdString(data["usb_pid"]));
}
}
json QMKVialRGBSettingsEntry::saveSettings()
{
json result;
/*-------------------------------------------------*\
| Required parameters |
\*-------------------------------------------------*/
result["name"] = ui->NameEdit->text().toStdString();
result["usb_vid"] = ui->USBVIDEdit->text().toStdString();
result["usb_pid"] = ui->USBPIDEdit->text().toStdString();
return result;
}
bool QMKVialRGBSettingsEntry::isDataValid()
{
// stub
return true;
}
static BaseManualDeviceEntry* SpawnQMKVialRGBSettingsEntry(const json& data)
{
QMKVialRGBSettingsEntry* entry = new QMKVialRGBSettingsEntry;
entry->loadFromSettings(data);
return entry;
}
static const char* QMKDeviceName = QT_TRANSLATE_NOOP("ManualDevice", "QMK (VialRGB Protocol)");
REGISTER_MANUAL_DEVICE_TYPE(QMKDeviceName, "QMKVialRGBDevices", SpawnQMKVialRGBSettingsEntry);
@@ -0,0 +1,35 @@
/*---------------------------------------------------------*\
| QMKVialRGBSettingsEntry.h |
| |
| User interface entry for VialRGB QMK configuration |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "BaseManualDeviceEntry.h"
namespace Ui
{
class QMKVialRGBSettingsEntry;
}
class QMKVialRGBSettingsEntry : public BaseManualDeviceEntry
{
Q_OBJECT
private slots:
void changeEvent(QEvent *event) override;
public:
explicit QMKVialRGBSettingsEntry(QWidget *parent = nullptr);
~QMKVialRGBSettingsEntry();
void loadFromSettings(const json& data);
json saveSettings() override;
bool isDataValid() override;
private:
Ui::QMKVialRGBSettingsEntry *ui;
};
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QMKVialRGBSettingsEntry</class>
<widget class="QWidget" name="QMKVialRGBSettingsEntry">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>531</width>
<height>237</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true"> QMK VialRGB Settings Entry</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>QMK VialRGB Device</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="5">
<widget class="QLineEdit" name="USBPIDEdit"/>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="NameEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="NameLabel">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLineEdit" name="USBVIDEdit"/>
</item>
<item row="2" column="4">
<widget class="QLabel" name="USBPIDLabel">
<property name="text">
<string>USB PID:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="USBVIDLabel">
<property name="text">
<string>USB VID:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>NameEdit</tabstop>
<tabstop>USBVIDEdit</tabstop>
<tabstop>USBPIDEdit</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,164 @@
/*---------------------------------------------------------*\
| SerialSettingsEntry.cpp |
| |
| User interface entry for serial device configuration |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "SerialSettingsEntry.h"
#include "ui_SerialSettingsEntry.h"
#include "serial_port.h"
#include <QStandardItemModel>
SerialSettingsEntry::SerialSettingsEntry(QWidget *parent) :
BaseManualDeviceEntry(parent),
ui(new Ui::SerialSettingsEntry)
{
ui->setupUi(this);
ui->ProtocolComboBox->addItem("Keyboard Visualizer");
ui->ProtocolComboBox->addItem("Adalight");
ui->ProtocolComboBox->addItem("TPM2");
ui->ProtocolComboBox->addItem("Basic I2C");
std::vector<std::string> serialPorts = serial_port::getSerialPorts();
for(size_t i = 0; i < serialPorts.size(); ++i)
{
ui->PortComboBox->addItem(QString::fromStdString(serialPorts[i]));
}
if(serialPorts.empty())
{
/*---------------------------------------------------*\
| When no ports were found, add an unselectable entry |
| denoting this fact istead |
\*---------------------------------------------------*/
QStandardItemModel* comboBoxModel = qobject_cast<QStandardItemModel *>(ui->PortComboBox->model());
if(comboBoxModel != nullptr)
{
ui->PortComboBox->addItem(tr("No serial ports found"));
QStandardItem *item = comboBoxModel->item(0);
item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
}
}
ui->PortComboBox->clearEditText();
}
SerialSettingsEntry::~SerialSettingsEntry()
{
delete ui;
}
void SerialSettingsEntry::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
}
void SerialSettingsEntry::on_ProtocolComboBox_currentIndexChanged(int index)
{
if(index == 3)
{
ui->BaudLabel->setText("Address:");
}
else
{
ui->BaudLabel->setText("Baud:");
}
}
void SerialSettingsEntry::loadFromSettings(const json& data)
{
if(data.contains("name"))
{
ui->NameEdit->setText(QString::fromStdString(data["name"]));
}
if(data.contains("port"))
{
ui->PortComboBox->setCurrentText(QString::fromStdString(data["port"]));
}
if(data.contains("baud"))
{
ui->BaudEdit->setText(QString::number((int)data["baud"]));
}
if(data.contains("num_leds"))
{
ui->NumLEDsEdit->setText(QString::number((int)data["num_leds"]));
}
if(data.contains("protocol"))
{
std::string protocol_string = data["protocol"];
if(protocol_string == "keyboard_visualizer")
{
ui->ProtocolComboBox->setCurrentIndex(0);
}
else if(protocol_string == "adalight")
{
ui->ProtocolComboBox->setCurrentIndex(1);
}
else if(protocol_string == "tpm2")
{
ui->ProtocolComboBox->setCurrentIndex(2);
}
else if(protocol_string == "basic_i2c")
{
ui->ProtocolComboBox->setCurrentIndex(3);
}
}
}
json SerialSettingsEntry::saveSettings()
{
json result;
/*-------------------------------------------------*\
| Required parameters |
\*-------------------------------------------------*/
result["name"] = ui->NameEdit->text().toStdString();
result["port"] = ui->PortComboBox->currentText().toStdString();
result["num_leds"] = ui->NumLEDsEdit->text().toUInt();
result["baud"] = ui->BaudEdit->text().toUInt();
switch(ui->ProtocolComboBox->currentIndex())
{
case 0:
result["protocol"] = "keyboard_visualizer";
break;
case 1:
result["protocol"] = "adalight";
break;
case 2:
result["protocol"] = "tpm2";
break;
case 3:
result["protocol"] = "basic_i2c";
break;
}
return result;
}
bool SerialSettingsEntry::isDataValid()
{
// stub
return true;
}
static BaseManualDeviceEntry* SpawnSerialSettingsEntry(const json& data)
{
SerialSettingsEntry* entry = new SerialSettingsEntry;
entry->loadFromSettings(data);
return entry;
}
static const char* SerialDeviceName = QT_TRANSLATE_NOOP("ManualDevice", "Serial Device");
REGISTER_MANUAL_DEVICE_TYPE(SerialDeviceName, "LEDStripDevices", SpawnSerialSettingsEntry);
@@ -0,0 +1,37 @@
/*---------------------------------------------------------*\
| SerialSettingsEntry.h |
| |
| User interface entry for serial device configuration |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "BaseManualDeviceEntry.h"
namespace Ui
{
class SerialSettingsEntry;
}
class SerialSettingsEntry : public BaseManualDeviceEntry
{
Q_OBJECT
private slots:
void changeEvent(QEvent *event) override;
void on_ProtocolComboBox_currentIndexChanged(int index);
public:
explicit SerialSettingsEntry(QWidget *parent = nullptr);
~SerialSettingsEntry();
void loadFromSettings(const json& data);
json saveSettings() override;
bool isDataValid() override;
private:
Ui::SerialSettingsEntry *ui;
};
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SerialSettingsEntry</class>
<widget class="QWidget" name="SerialSettingsEntry">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>531</width>
<height>237</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true">Serial Settings Entry</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Serial Device</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="4">
<widget class="QLabel" name="NumLEDsLabel">
<property name="text">
<string>Number of LEDs:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="BaudLabel">
<property name="text">
<string>Baud:</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QComboBox" name="ProtocolComboBox"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="NameLabel">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="NameEdit"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="ProtocolLabel">
<property name="text">
<string>Protocol:</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLineEdit" name="BaudEdit"/>
</item>
<item row="2" column="5">
<widget class="QLineEdit" name="NumLEDsEdit"/>
</item>
<item row="1" column="4">
<widget class="QLabel" name="PortLabel">
<property name="text">
<string>Port:</string>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QComboBox" name="PortComboBox">
<property name="editable">
<bool>true</bool>
</property>
<property name="insertPolicy">
<enum>QComboBox::NoInsert</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>NameEdit</tabstop>
<tabstop>BaudEdit</tabstop>
<tabstop>NumLEDsEdit</tabstop>
<tabstop>ProtocolComboBox</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,109 @@
/*---------------------------------------------------------*\
| YeelightSettingsEntry.cpp |
| |
| User interface for Yeelight settings entry |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <QInputDialog>
#include "YeelightSettingsEntry.h"
#include "ui_YeelightSettingsEntry.h"
#include "net_port.h"
YeelightSettingsEntry::YeelightSettingsEntry(QWidget *parent) :
BaseManualDeviceEntry(parent),
ui(new Ui::YeelightSettingsEntry)
{
ui->setupUi(this);
}
YeelightSettingsEntry::~YeelightSettingsEntry()
{
delete ui;
}
void YeelightSettingsEntry::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
}
void YeelightSettingsEntry::on_HostIPChooserButton_clicked()
{
char hostname[256];
gethostname(hostname, 256);
char **in_addrs = gethostbyname(hostname)->h_addr_list;
QStringList in_addr_list;
while (*in_addrs != NULL)
{
in_addr_list << inet_ntoa(*((struct in_addr*) *in_addrs));
in_addrs++;
}
QInputDialog inp;
inp.setOptions(QInputDialog::UseListViewForComboBoxItems);
inp.setComboBoxItems(in_addr_list);
inp.setWindowTitle(tr("Choose an IP..."));
inp.setLabelText(tr("Choose the correct IP for the host"));
if(!inp.exec())
{
return;
}
ui->HostIPEdit->setText(inp.textValue());
}
void YeelightSettingsEntry::loadFromSettings(const json& data)
{
if(data.contains("ip"))
{
ui->IPEdit->setText(QString::fromStdString(data["ip"]));
}
if(data.contains("host_ip"))
{
ui->HostIPEdit->setText(QString::fromStdString(data["host_ip"]));
}
if(data.contains("music_mode"))
{
ui->MusicModeCheckBox->setChecked(data["music_mode"]);
}
}
json YeelightSettingsEntry::saveSettings()
{
json result;
/*-------------------------------------------------*\
| Required parameters |
\*-------------------------------------------------*/
result["ip"] = ui->IPEdit->text().toStdString();
result["host_ip"] = ui->HostIPEdit->text().toStdString();
result["music_mode"] = ui->MusicModeCheckBox->isChecked();
return result;
}
bool YeelightSettingsEntry::isDataValid()
{
// stub
return true;
}
static BaseManualDeviceEntry* SpawnYeelightSettingsEntry(const json& data)
{
YeelightSettingsEntry* entry = new YeelightSettingsEntry;
entry->loadFromSettings(data);
return entry;
}
REGISTER_MANUAL_DEVICE_TYPE("Yeelight", "YeelightDevices", SpawnYeelightSettingsEntry);
@@ -0,0 +1,36 @@
/*---------------------------------------------------------*\
| YeelightSettingsEntry.h |
| |
| User interface for Yeelight settings entry |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "BaseManualDeviceEntry.h"
namespace Ui
{
class YeelightSettingsEntry;
}
class YeelightSettingsEntry : public BaseManualDeviceEntry
{
Q_OBJECT
public:
explicit YeelightSettingsEntry(QWidget *parent = nullptr);
~YeelightSettingsEntry();
void loadFromSettings(const json& data);
json saveSettings() override;
bool isDataValid() override;
private:
Ui::YeelightSettingsEntry *ui;
private slots:
void changeEvent(QEvent *event) override;
void on_HostIPChooserButton_clicked();
};
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>YeelightSettingsEntry</class>
<widget class="QWidget" name="YeelightSettingsEntry">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>972</width>
<height>385</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true">Yeelight Settings Entry</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Yeelight Device</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="1">
<widget class="QCheckBox" name="MusicModeCheckBox">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="IPLabel">
<property name="text">
<string>IP:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="HostIPEdit"/>
</item>
<item row="5" column="2">
<widget class="QToolButton" name="HostIPChooserButton">
<property name="text">
<string>?</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="MusicModeLabel">
<property name="text">
<string>Music Mode:</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Override host IP:</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLineEdit" name="IPEdit"/>
</item>
<item row="6" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Left blank for auto discovering host ip</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

@@ -0,0 +1,365 @@
/*---------------------------------------------------------*\
| OpenRGBClientInfoPage.cpp |
| |
| User interface for OpenRGB client information page |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <iostream>
#include <QSignalMapper>
#include <QCheckBox>
#include "OpenRGBClientInfoPage.h"
#include "ResourceManager.h"
#include "SettingsManager.h"
#include "ui_OpenRGBClientInfoPage.h"
static void UpdateInfoCallback(void * this_ptr)
{
OpenRGBClientInfoPage * this_obj = (OpenRGBClientInfoPage *)this_ptr;
QMetaObject::invokeMethod(this_obj, "UpdateInfo", Qt::QueuedConnection);
}
class NetworkClientPointer : public QObject
{
public:
NetworkClient * net_client;
QWidget * widget;
};
OpenRGBClientInfoPage::OpenRGBClientInfoPage(QWidget *parent) :
QFrame(parent),
ui(new Ui::OpenRGBClientInfoPage)
{
/*-----------------------------------------------------*\
| Set initial values for GUI fields |
\*-----------------------------------------------------*/
ui->setupUi(this);
ui->ClientIPValue->setText("127.0.0.1");
ui->ClientPortValue->setText(QString::number(OPENRGB_SDK_PORT));
/*-----------------------------------------------------*\
| Register callbacks with resource manager |
\*-----------------------------------------------------*/
ResourceManager::get()->RegisterClientInfoChangeCallback(UpdateInfoCallback, this);
/*-----------------------------------------------------*\
| Update the information view |
\*-----------------------------------------------------*/
UpdateInfo();
}
OpenRGBClientInfoPage::~OpenRGBClientInfoPage()
{
}
void OpenRGBClientInfoPage::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
}
void OpenRGBClientInfoPage::UpdateInfo()
{
/*-----------------------------------------------------*\
| Clear the tree view before recreating its contents |
\*-----------------------------------------------------*/
ui->ClientTree->clear();
/*-----------------------------------------------------*\
| Set up the tree view header |
\*-----------------------------------------------------*/
ui->ClientTree->setColumnCount(5);
ui->ClientTree->header()->setStretchLastSection(false);
ui->ClientTree->header()->setSectionResizeMode(0, QHeaderView::Stretch);
ui->ClientTree->setColumnWidth(1, 140);
ui->ClientTree->setColumnWidth(2, 140);
ui->ClientTree->setColumnWidth(3, 140);
ui->ClientTree->setColumnWidth(4, 140);
/*-----------------------------------------------------*\
| Set up signal mappers to handle buttons |
\*-----------------------------------------------------*/
QSignalMapper* signalMapperDisconnect = new QSignalMapper(this);
QSignalMapper* signalMapperSave = new QSignalMapper(this);
QSignalMapper* signalMapperRescan = new QSignalMapper(this);
connect(signalMapperDisconnect, SIGNAL(mappedObject(QObject *)), this, SLOT(onClientDisconnectButton_clicked(QObject *)));
connect(signalMapperSave, SIGNAL(mappedObject(QObject *)), this, SLOT(onClientSaveCheckBox_clicked(QObject *)));
connect(signalMapperRescan, SIGNAL(mappedObject(QObject *)), this, SLOT(onClientRescanButton_clicked(QObject *)));
/*-------------------------------------------------*\
| Get Client settings |
\*-------------------------------------------------*/
json client_settings;
client_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Client");
/*-----------------------------------------------------*\
| Loop through all clients in list and display them |
\*-----------------------------------------------------*/
for(std::size_t client_idx = 0; client_idx < ResourceManager::get()->GetClients().size(); client_idx++)
{
/*-----------------------------------------------------*\
| Check to see if this client is in the saved clients |
| list |
\*-----------------------------------------------------*/
bool found = false;
if(client_settings.contains("clients"))
{
for(unsigned int saved_client_idx = 0; saved_client_idx < client_settings["clients"].size(); saved_client_idx++)
{
if(client_settings["clients"][saved_client_idx].contains("ip") && client_settings["clients"][saved_client_idx].contains("port"))
{
std::string saved_ip = client_settings["clients"][saved_client_idx]["ip"];
unsigned short saved_port = client_settings["clients"][saved_client_idx]["port"];
std::string client_ip = ResourceManager::get()->GetClients()[client_idx]->GetIP();
unsigned short client_port = ResourceManager::get()->GetClients()[client_idx]->GetPort();
if((client_ip == saved_ip) && (client_port == saved_port))
{
found = true;
break;
}
}
}
}
/*-----------------------------------------------------*\
| Create the top level tree widget items and display the|
| client IP addresses and protocol versions in them |
\*-----------------------------------------------------*/
QTreeWidgetItem* new_top_item = new QTreeWidgetItem(ui->ClientTree);
new_top_item->setText(0, QString::fromStdString(ResourceManager::get()->GetClients()[client_idx]->GetIP()));
new_top_item->setText(1, QString::number(ResourceManager::get()->GetClients()[client_idx]->GetProtocolVersion()));
/*-----------------------------------------------------*\
| Create the save checkbox |
\*-----------------------------------------------------*/
QCheckBox* checkbox_save = new QCheckBox( "" );
ui->ClientTree->setItemWidget(new_top_item, 2, checkbox_save);
checkbox_save->setChecked(found);
connect(checkbox_save, SIGNAL(clicked()), signalMapperSave, SLOT(map()));
NetworkClientPointer * arg_save = new NetworkClientPointer();
arg_save->net_client = ResourceManager::get()->GetClients()[client_idx];
arg_save->widget = checkbox_save;
signalMapperSave->setMapping(checkbox_save, arg_save);
/*-----------------------------------------------------*\
| Create the rescan button if protocol version is 5 or |
| greater |
\*-----------------------------------------------------*/
if(ResourceManager::get()->GetClients()[client_idx]->GetProtocolVersion() >= 5)
{
QPushButton* button_rescan = new QPushButton(tr("Rescan Devices"));
ui->ClientTree->setItemWidget(new_top_item, 3, button_rescan);
connect(button_rescan, SIGNAL(clicked()), signalMapperRescan, SLOT(map()));
NetworkClientPointer * arg_rescan = new NetworkClientPointer();
arg_rescan->net_client = ResourceManager::get()->GetClients()[client_idx];
arg_rescan->widget = button_rescan;
signalMapperRescan->setMapping(button_rescan, arg_rescan);
}
/*-----------------------------------------------------*\
| Create the disconnect button |
\*-----------------------------------------------------*/
QPushButton* button_disconnect = new QPushButton(tr("Disconnect"));
ui->ClientTree->setItemWidget(new_top_item, 4, button_disconnect);
connect(button_disconnect, SIGNAL(clicked()), signalMapperDisconnect, SLOT(map()));
NetworkClientPointer * arg_disconnect = new NetworkClientPointer();
arg_disconnect->net_client = ResourceManager::get()->GetClients()[client_idx];
arg_disconnect->widget = button_disconnect;
signalMapperDisconnect->setMapping(button_disconnect, arg_disconnect);
/*-----------------------------------------------------*\
| Add child items for each device in the client |
\*-----------------------------------------------------*/
for(std::size_t dev_idx = 0; dev_idx < ResourceManager::get()->GetClients()[client_idx]->server_controllers.size(); dev_idx++)
{
/*-----------------------------------------------------*\
| Create child tree widget items and display the device |
| names in them |
\*-----------------------------------------------------*/
QTreeWidgetItem* new_item = new QTreeWidgetItem(new_top_item);
new_item->setText(0, QString::fromStdString(ResourceManager::get()->GetClients()[client_idx]->server_controllers[dev_idx]->GetName()));
/*-----------------------------------------------------*\
| Add child items for each zone in the device |
\*-----------------------------------------------------*/
for(std::size_t zone_idx = 0; zone_idx < ResourceManager::get()->GetClients()[client_idx]->server_controllers[dev_idx]->zones.size(); zone_idx++)
{
/*-----------------------------------------------------*\
| Create child tree widget items and display the zone |
| names, number of LEDs, and types in them |
\*-----------------------------------------------------*/
QTreeWidgetItem* new_child = new QTreeWidgetItem();
std::string zone_str = ResourceManager::get()->GetClients()[client_idx]->server_controllers[dev_idx]->zones[zone_idx].name + ", ";
zone_str.append(std::to_string(ResourceManager::get()->GetClients()[client_idx]->server_controllers[dev_idx]->zones[zone_idx].leds_count));
zone_str.append(" LEDs, ");
// TODO : translate
switch(ResourceManager::get()->GetClients()[client_idx]->server_controllers[dev_idx]->zones[zone_idx].type)
{
case ZONE_TYPE_SINGLE:
zone_str.append("Single");
break;
case ZONE_TYPE_LINEAR:
zone_str.append("Linear");
break;
case ZONE_TYPE_MATRIX:
zone_str.append("Matrix");
break;
}
new_child->setText(0, QString::fromStdString(zone_str));
new_item->addChild(new_child);
}
}
}
}
void OpenRGBClientInfoPage::on_ClientConnectButton_clicked()
{
/*-----------------------------------------------------*\
| Read the new client IP and Port values from the UI |
\*-----------------------------------------------------*/
unsigned short port = std::stoi(ui->ClientPortValue->text().toStdString());
std::string ip = ui->ClientIPValue->text().toStdString();
/*-----------------------------------------------------*\
| Create a new client and set name, IP, and port values |
\*-----------------------------------------------------*/
NetworkClient * rgb_client = new NetworkClient(ResourceManager::get()->GetRGBControllers());
std::string titleString = "OpenRGB ";
titleString.append(VERSION_STRING);
rgb_client->SetIP(ip.c_str());
rgb_client->SetName(titleString.c_str());
rgb_client->SetPort(port);
rgb_client->StartClient();
/*-----------------------------------------------------*\
| Add new client to list and register update callback |
\*-----------------------------------------------------*/
ResourceManager::get()->RegisterNetworkClient(rgb_client);
rgb_client->RegisterClientInfoChangeCallback(UpdateInfoCallback, this);
}
void OpenRGBClientInfoPage::onClientDisconnectButton_clicked(QObject * arg)
{
/*-----------------------------------------------------*\
| Get the pointer to the client from args |
\*-----------------------------------------------------*/
NetworkClient * disconnect_client = ((NetworkClientPointer *)arg)->net_client;
/*-----------------------------------------------------*\
| Remove the client from the resource manager, which |
| deletes the client |
\*-----------------------------------------------------*/
ResourceManager::get()->UnregisterNetworkClient(disconnect_client);
}
void OpenRGBClientInfoPage::onClientRescanButton_clicked(QObject * arg)
{
/*-----------------------------------------------------*\
| Get the pointer to the client from args |
\*-----------------------------------------------------*/
NetworkClient * rescan_client = ((NetworkClientPointer *)arg)->net_client;
/*-----------------------------------------------------*\
| Send a rescan request to the client |
\*-----------------------------------------------------*/
rescan_client->SendRequest_RescanDevices();
}
void OpenRGBClientInfoPage::onClientSaveCheckBox_clicked(QObject * arg)
{
/*-----------------------------------------------------*\
| Get the pointer to the client from args |
\*-----------------------------------------------------*/
NetworkClient * save_client = ((NetworkClientPointer *)arg)->net_client;
QCheckBox * save_checkbox = (QCheckBox *)((NetworkClientPointer *)arg)->widget;
json client_settings;
/*-------------------------------------------------*\
| Get Client settings |
\*-------------------------------------------------*/
client_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Client");
if(save_checkbox->isChecked())
{
bool found = false;
for(unsigned int client_idx = 0; client_idx < client_settings["clients"].size(); client_idx++)
{
if(client_settings["clients"][client_idx].contains("ip") && client_settings["clients"][client_idx].contains("port"))
{
std::string client_ip = client_settings["clients"][client_idx]["ip"];
unsigned short client_port = client_settings["clients"][client_idx]["port"];
std::string save_ip = save_client->GetIP();
unsigned short save_port = save_client->GetPort();
if((client_ip == save_ip) && (client_port == save_port))
{
found = true;
break;
}
}
}
if(!found)
{
json new_client;
new_client["ip"] = save_client->GetIP();
new_client["port"] = save_client->GetPort();
client_settings["clients"].push_back(new_client);
}
}
else
{
if(client_settings.contains("clients"))
{
for(unsigned int client_idx = 0; client_idx < client_settings["clients"].size(); client_idx++)
{
if(client_settings["clients"][client_idx].contains("ip") && client_settings["clients"][client_idx].contains("port"))
{
std::string client_ip = client_settings["clients"][client_idx]["ip"];
unsigned short client_port = client_settings["clients"][client_idx]["port"];
std::string save_ip = save_client->GetIP();
unsigned short save_port = save_client->GetPort();
if((client_ip == save_ip) && (client_port == save_port))
{
client_settings["clients"].erase(client_settings["clients"].begin() + client_idx);
break;
}
}
}
}
}
ResourceManager::get()->GetSettingsManager()->SetSettings("Client", client_settings);
ResourceManager::get()->GetSettingsManager()->SaveSettings();
}
@@ -0,0 +1,41 @@
/*---------------------------------------------------------*\
| OpenRGBClientInfoPage.h |
| |
| User interface for OpenRGB client information page |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <QFrame>
#include "RGBController.h"
#include "NetworkClient.h"
namespace Ui
{
class OpenRGBClientInfoPage;
}
class OpenRGBClientInfoPage : public QFrame
{
Q_OBJECT
public:
explicit OpenRGBClientInfoPage(QWidget *parent = nullptr);
~OpenRGBClientInfoPage();
public slots:
void UpdateInfo();
private slots:
void changeEvent(QEvent *event);
void on_ClientConnectButton_clicked();
void onClientDisconnectButton_clicked(QObject * arg);
void onClientRescanButton_clicked(QObject * arg);
void onClientSaveCheckBox_clicked(QObject * arg);
private:
Ui::OpenRGBClientInfoPage *ui;
};
@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OpenRGBClientInfoPage</class>
<widget class="QFrame" name="OpenRGBClientInfoPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>664</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Client Info Page</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="6">
<widget class="QLineEdit" name="ClientPortValue">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QLabel" name="ClientPortLabel">
<property name="text">
<string>Port:</string>
</property>
</widget>
</item>
<item row="0" column="7">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="8">
<widget class="QPushButton" name="ClientConnectButton">
<property name="text">
<string>Connect</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLineEdit" name="ClientIPValue"/>
</item>
<item row="0" column="3">
<widget class="QLabel" name="ClientIPLabel">
<property name="text">
<string>IP:</string>
</property>
</widget>
</item>
<item row="1" column="3" colspan="6">
<widget class="QTreeWidget" name="ClientTree">
<property name="columnCount">
<number>5</number>
</property>
<column>
<property name="text">
<string>Connected Clients</string>
</property>
</column>
<column>
<property name="text">
<string>Protocol Version</string>
</property>
</column>
<column>
<property name="text">
<string>Save Connection</string>
</property>
</column>
<column>
<property name="text">
<string/>
</property>
</column>
<column>
<property name="text">
<string/>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>ClientIPValue</tabstop>
<tabstop>ClientPortValue</tabstop>
<tabstop>ClientConnectButton</tabstop>
<tabstop>ClientTree</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,90 @@
/*---------------------------------------------------------*\
| OpenRGBConsolePage.cpp |
| |
| User interface for OpenRGB console page |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "OpenRGBConsolePage.h"
#include "ui_OpenRGBConsolePage.h"
#include "LogManager.h"
OpenRGBConsolePage::OpenRGBConsolePage(QWidget *parent) :
QFrame(parent),
ui(new Ui::OpenRGBConsolePage)
{
ui->setupUi(this);
ui->log_level->blockSignals(true);
ui->log_level->addItems({
"Fatal",
"Error",
"Warning",
"Info",
"Verbose",
"Debug",
"Trace"
});
ui->log_level->setCurrentIndex(LogManager::get()->getLoglevel());
ui->log_level->blockSignals(false);
#ifdef _WIN32
ui->logs->setFontFamily("Courier New");
#endif
Refresh();
}
void OpenRGBConsolePage::Refresh()
{
QString log;
unsigned int current_level = LogManager::get()->getLoglevel();
for(PLogMessage& message: LogManager::get()->messages())
{
unsigned int message_level = message.get()->level;
if(message_level <= current_level || message_level == LL_DIALOG)
{
log += "[";
log += LogManager::log_codes[message_level];
log += "] ";
log += QString::fromStdString(message.get()->buffer);
log += "\n";
}
}
ui->logs->setText(log);
}
void OpenRGBConsolePage::on_log_level_currentIndexChanged(int index)
{
LogManager::get()->setLoglevel(index);
}
void OpenRGBConsolePage::on_clear_clicked()
{
LogManager::get()->clearMessages();
ui->logs->clear();
}
void OpenRGBConsolePage::on_refresh_clicked()
{
Refresh();
}
OpenRGBConsolePage::~OpenRGBConsolePage()
{
delete ui;
}
void OpenRGBConsolePage::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
}
@@ -0,0 +1,37 @@
/*---------------------------------------------------------*\
| OpenRGBConsolePage.h |
| |
| User interface for OpenRGB console page |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <QFrame>
namespace Ui
{
class OpenRGBConsolePage;
}
class OpenRGBConsolePage : public QFrame
{
Q_OBJECT
public:
explicit OpenRGBConsolePage(QWidget *parent = nullptr);
~OpenRGBConsolePage();
private slots:
void changeEvent(QEvent *event);
void on_log_level_currentIndexChanged(int);
void on_clear_clicked();
void on_refresh_clicked();
private:
Ui::OpenRGBConsolePage *ui;
void Refresh();
};
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OpenRGBConsolePage</class>
<widget class="QFrame" name="OpenRGBConsolePage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1328</width>
<height>915</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Log Console Page</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Log level</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="log_level"/>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="refresh">
<property name="text">
<string>Refresh logs</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="clear">
<property name="text">
<string>Clear log</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<widget class="QTextEdit" name="logs">
<property name="font">
<font>
<family>Monospace</family>
</font>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,85 @@
/*---------------------------------------------------------*\
| OpenRGBDeviceInfoPage.cpp |
| |
| User interface for OpenRGB device information page |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "OpenRGBDeviceInfoPage.h"
#include "ui_OpenRGBDeviceInfoPage.h"
OpenRGBDeviceInfoPage::OpenRGBDeviceInfoPage(RGBController *dev, QWidget *parent) :
QFrame(parent),
ui(new Ui::OpenRGBDeviceInfoPage)
{
controller = dev;
ui->setupUi(this);
ui->TypeValue->setText(device_type_to_str(dev->type).c_str());
ui->NameValue->setText(QString::fromStdString(dev->GetName()));
ui->VendorValue->setText(QString::fromStdString(dev->GetVendor()));
ui->DescriptionValue->setText(QString::fromStdString(dev->GetDescription()));
ui->VersionValue->setText(QString::fromStdString(dev->GetVersion()));
ui->LocationValue->setText(QString::fromStdString(dev->GetLocation()));
ui->SerialValue->setText(QString::fromStdString(dev->GetSerial()));
std::string flags_string = "";
bool need_separator = false;
if(dev->flags & CONTROLLER_FLAG_LOCAL)
{
flags_string += "Local";
need_separator = true;
}
if(dev->flags & CONTROLLER_FLAG_REMOTE)
{
if(need_separator)
{
flags_string += ", ";
}
flags_string += "Remote";
need_separator = true;
}
if(dev->flags & CONTROLLER_FLAG_VIRTUAL)
{
if(need_separator)
{
flags_string += ", ";
}
flags_string += "Virtual";
need_separator = true;
}
if(dev->flags & CONTROLLER_FLAG_RESET_BEFORE_UPDATE)
{
if(need_separator)
{
flags_string += ", ";
}
flags_string += "Reset Before Update";
need_separator = true;
}
ui->FlagsValue->setText(QString::fromStdString(flags_string));
}
OpenRGBDeviceInfoPage::~OpenRGBDeviceInfoPage()
{
delete ui;
}
void OpenRGBDeviceInfoPage::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
}
RGBController* OpenRGBDeviceInfoPage::GetController()
{
return controller;
}
@@ -0,0 +1,36 @@
/*---------------------------------------------------------*\
| OpenRGBDeviceInfoPage.h |
| |
| User interface for OpenRGB device information page |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <QFrame>
#include "RGBController.h"
namespace Ui
{
class OpenRGBDeviceInfoPage;
}
class OpenRGBDeviceInfoPage : public QFrame
{
Q_OBJECT
public:
explicit OpenRGBDeviceInfoPage(RGBController *dev, QWidget *parent = nullptr);
~OpenRGBDeviceInfoPage();
RGBController* GetController();
private:
RGBController* controller;
Ui::OpenRGBDeviceInfoPage* ui;
private slots:
void changeEvent(QEvent *event);
};
@@ -0,0 +1,194 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OpenRGBDeviceInfoPage</class>
<widget class="QFrame" name="OpenRGBDeviceInfoPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Device Info Page</string>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="frameShape">
<enum>QFrame::Shape::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Sunken</enum>
</property>
<layout class="QGridLayout" name="gridLayout" columnstretch="0">
<item row="0" column="0">
<widget class="QFrame" name="DeviceInfoFrame">
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Sunken</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,1">
<item row="4" column="1">
<widget class="QLabel" name="VersionValue">
<property name="text">
<string notr="true">Version Value</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="SerialLabel">
<property name="text">
<string>Serial:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="SerialValue">
<property name="text">
<string notr="true">Serial Value</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="NameLabel">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="NameValue">
<property name="text">
<string notr="true">Name Value</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="VendorLabel">
<property name="text">
<string>Vendor:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="VendorValue">
<property name="text">
<string notr="true">Vendor Value</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="TypeLabel">
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="TypeValue">
<property name="text">
<string notr="true">Type Value</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="DescriptionValue">
<property name="text">
<string notr="true">Description Value</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="DescriptionLabel">
<property name="text">
<string>Description:</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="VersionLabel">
<property name="text">
<string>Version:</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="LocationLabel">
<property name="text">
<string>Location:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="LocationValue">
<property name="text">
<string notr="true">Location Value</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="FlagsLabel">
<property name="text">
<string>Flags:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="FlagsValue">
<property name="text">
<string notr="true">Flags Value</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
File diff suppressed because it is too large Load Diff
+93
View File
@@ -0,0 +1,93 @@
/*---------------------------------------------------------*\
| OpenRGBDevicePage.h |
| |
| User interface for OpenRGB device page |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <QFrame>
#include "RGBController.h"
namespace Ui
{
class OpenRGBDevicePage;
}
class OpenRGBDevicePage : public QFrame
{
Q_OBJECT
public:
explicit OpenRGBDevicePage(RGBController *dev, QWidget *parent = nullptr);
~OpenRGBDevicePage();
RGBController* GetController();
void SetDevice(unsigned char red, unsigned char green, unsigned char blue); // Could be moved to private
void SetCustomMode(unsigned char red, unsigned char green, unsigned char blue);
void UpdateDevice();
void UpdateMode();
void UpdateModeUi();
void ShowDeviceView();
void HideDeviceView();
private slots:
void changeEvent(QEvent *event);
void UpdateInterface();
void on_ColorWheelBox_colorChanged(const QColor color);
void on_SwatchBox_swatchChanged(const QColor color);
void on_DirectionBox_currentIndexChanged(int index);
void on_ZoneBox_currentIndexChanged(int index);
void on_LEDBox_currentIndexChanged(int index);
void on_BrightnessSlider_valueChanged(int value);
void on_ModeBox_currentIndexChanged(int index);
void on_SpeedSlider_valueChanged(int value);
void on_RedSpinBox_valueChanged(int red);
void on_HueSpinBox_valueChanged(int hue);
void on_GreenSpinBox_valueChanged(int green);
void on_SatSpinBox_valueChanged(int sat);
void on_BlueSpinBox_valueChanged(int blue);
void on_ValSpinBox_valueChanged(int val);
void on_HexLineEdit_textChanged(const QString &arg1);
void on_DeviceViewBox_selectionChanged(QVector<int>);
void on_SetAllButton_clicked();
void on_RandomCheck_clicked();
void on_PerLEDCheck_clicked();
void on_ModeSpecificCheck_clicked();
void on_EditZoneButton_clicked();
void on_ApplyColorsButton_clicked();
void on_SelectAllLEDsButton_clicked();
void on_DeviceSaveButton_clicked();
private:
Ui::OpenRGBDevicePage *ui;
RGBController *device;
bool InvertedSpeed = false;
bool InvertedBrightness = false;
bool MultipleSelected = false;
bool DeviceViewShowing = false;
bool UpdateHex = true;
bool HexFormatRGB = true;
QColor current_color;
bool autoUpdateEnabled();
void colorChanged();
void getSelectedZone(bool * selected_all_zones, int * selected_zone, int * selected_segment);
void updateColorUi();
QString ModeDescription(const mode& m);
signals:
void SetAllDevices(unsigned char red, unsigned char green, unsigned char blue);
void SaveSizeProfile();
};
+439
View File
@@ -0,0 +1,439 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OpenRGBDevicePage</class>
<widget class="QFrame" name="OpenRGBDevicePage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>843</width>
<height>374</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Device Page</string>
</property>
<layout class="QGridLayout" name="OpenRGBDevicePageUiGridLayout" rowstretch="0,0" columnstretch="3,1">
<item row="1" column="1">
<widget class="QFrame" name="ColorFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Sunken</enum>
</property>
<layout class="QGridLayout" name="ColorGridLayout" rowstretch="10,0,0,0" columnstretch="0">
<item row="2" column="0">
<widget class="QFrame" name="ColorEntryFrame">
<property name="frameShape">
<enum>QFrame::Shape::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Raised</enum>
</property>
<layout class="QGridLayout" name="ColorEntryGridLayout" columnstretch="0,1,0,1">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="RedLabel">
<property name="text">
<string>R:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="RedSpinBox">
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="HueLabel">
<property name="text">
<string>H:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QSpinBox" name="HueSpinBox">
<property name="maximum">
<number>359</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="GreenLabel">
<property name="text">
<string>G:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="GreenSpinBox">
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="SatLabel">
<property name="text">
<string>S:</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QSpinBox" name="SatSpinBox">
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="BlueLabel">
<property name="text">
<string>B:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="BlueSpinBox">
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="ValLabel">
<property name="text">
<string>V:</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QSpinBox" name="ValSpinBox">
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="HexLabel">
<property name="text">
<string>Hex:</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="3">
<widget class="QLineEdit" name="HexLineEdit">
<property name="maxLength">
<number>8</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="ColorWheel" name="ColorWheelBox" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="Swatches" name="SwatchBox" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="DeviceSaveButton">
<property name="text">
<string>Save To Device</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QFrame" name="ControlsFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Sunken</enum>
</property>
<layout class="QGridLayout" name="ControlsGridLayout" columnstretch="0,1,1,1">
<item row="5" column="0">
<widget class="QLabel" name="SpeedLabel">
<property name="text">
<string>Speed:</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="LEDBox"/>
</item>
<item row="0" column="1" colspan="2">
<widget class="QComboBox" name="ZoneBox"/>
</item>
<item row="4" column="3">
<widget class="QRadioButton" name="RandomCheck">
<property name="text">
<string>Random</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="ModeLabel">
<property name="text">
<string>Mode:</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="DirectionLabel">
<property name="text">
<string>Dir:</string>
</property>
</widget>
</item>
<item row="5" column="1" colspan="3">
<widget class="QTooltipedSlider" name="SpeedSlider">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="ColorLabel">
<property name="text">
<string>Colors:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QRadioButton" name="PerLEDCheck">
<property name="text">
<string>Per-LED</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="ZoneLabel">
<property name="text">
<string>Zone:</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="3">
<widget class="QComboBox" name="ModeBox"/>
</item>
<item row="2" column="3">
<widget class="QPushButton" name="SetAllButton">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;justify&quot;&gt;Sets all devices to&lt;br/&gt;&lt;b&gt;Static&lt;/b&gt; mode and&lt;br/&gt;applies the selected color.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Apply All Devices</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="LEDLabel">
<property name="text">
<string>LED:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="EditZoneButton">
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QRadioButton" name="ModeSpecificCheck">
<property name="text">
<string>Mode-Specific</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QPushButton" name="ApplyColorsButton">
<property name="text">
<string>Apply Colors To Selection</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="SelectAllLEDsButton">
<property name="text">
<string>Select All</string>
</property>
</widget>
</item>
<item row="7" column="1" colspan="3">
<widget class="QTooltipedSlider" name="BrightnessSlider">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
</item>
<item row="6" column="1" colspan="3">
<widget class="QComboBox" name="DirectionBox"/>
</item>
<item row="7" column="0">
<widget class="QLabel" name="BrightnessLabel">
<property name="text">
<string>Brightness:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QFrame" name="DeviceViewBoxFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Sunken</enum>
</property>
<layout class="QGridLayout" name="DeviceViewBoxGridLayout">
<item row="0" column="0">
<widget class="DeviceView" name="DeviceViewBox" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ColorWheel</class>
<extends>QWidget</extends>
<header location="global">ColorWheel.h</header>
<container>1</container>
<slots>
<signal>colorChanged(QColor)</signal>
</slots>
</customwidget>
<customwidget>
<class>DeviceView</class>
<extends>QWidget</extends>
<header location="global">DeviceView.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>Swatches</class>
<extends>QWidget</extends>
<header location="global">swatches.h</header>
<container>1</container>
<slots>
<signal>swatchChanged(QColor)</signal>
<slot>currentColorInput(QColor)</slot>
</slots>
</customwidget>
<customwidget>
<class>QTooltipedSlider</class>
<extends>QSlider</extends>
<header location="global">QTooltipedSlider.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>ZoneBox</tabstop>
<tabstop>EditZoneButton</tabstop>
<tabstop>LEDBox</tabstop>
<tabstop>SelectAllLEDsButton</tabstop>
<tabstop>ApplyColorsButton</tabstop>
<tabstop>SetAllButton</tabstop>
<tabstop>ModeBox</tabstop>
<tabstop>PerLEDCheck</tabstop>
<tabstop>ModeSpecificCheck</tabstop>
<tabstop>RandomCheck</tabstop>
<tabstop>SpeedSlider</tabstop>
<tabstop>DirectionBox</tabstop>
<tabstop>BrightnessSlider</tabstop>
<tabstop>RedSpinBox</tabstop>
<tabstop>GreenSpinBox</tabstop>
<tabstop>BlueSpinBox</tabstop>
<tabstop>HueSpinBox</tabstop>
<tabstop>SatSpinBox</tabstop>
<tabstop>ValSpinBox</tabstop>
<tabstop>DeviceSaveButton</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
File diff suppressed because it is too large Load Diff
+171
View File
@@ -0,0 +1,171 @@
/*---------------------------------------------------------*\
| OpenRGBDialog.h |
| |
| User interface for OpenRGB main window |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <string>
#include <QMainWindow>
#include <QTimer>
#include <QSystemTrayIcon>
#include <QMenu>
#include <QSlider>
#include "OpenRGBClientInfoPage.h"
#include "OpenRGBPluginsPage/OpenRGBPluginsPage.h"
#include "OpenRGBSoftwareInfoPage.h"
#include "OpenRGBSystemInfoPage.h"
#include "OpenRGBSupportedDevicesPage.h"
#include "OpenRGBSettingsPage.h"
#include "ManualDevicesSettingsPage/ManualDevicesSettingsPage.h"
#include "PluginManager.h"
#include "SuspendResume.h"
#include "i2c_smbus.h"
#include "LogManager.h"
#include "RGBController.h"
#include "ProfileManager.h"
#include "NetworkClient.h"
#include "NetworkServer.h"
namespace Ui
{
class OpenRGBDialog;
}
class OpenRGBDialog : public QMainWindow, private SuspendResumeListener
{
Q_OBJECT
public:
explicit OpenRGBDialog(QWidget *parent = 0);
~OpenRGBDialog();
void AddClientTab();
void AddI2CToolsPage();
void AddServerTab();
void AddPlugin(OpenRGBPluginEntry* plugin);
void RemovePlugin(OpenRGBPluginEntry* plugin);
void setMode(unsigned char mode_val);
static bool IsMinimizeOnClose();
void SetDialogMessage(PLogMessage msg);
bool DontShowAgain;
signals:
void ProfileListChanged();
public slots:
void changeEvent(QEvent *event) override;
void SetTrayIcon(bool tray_icon);
void handleAboutToQuit();
protected:
void keyPressEvent(QKeyEvent *event) override;
private:
/*-----------------------------------------------------*\
| Context string |
\*-----------------------------------------------------*/
const char * context = "OpenRGBDialog";
/*-----------------------------------------------------*\
| Page pointers |
\*-----------------------------------------------------*/
OpenRGBClientInfoPage * ClientInfoPage;
OpenRGBPluginsPage * PluginsPage;
OpenRGBSystemInfoPage * SMBusToolsPage;
OpenRGBSoftwareInfoPage * SoftInfoPage;
OpenRGBSupportedDevicesPage * SupportedPage;
OpenRGBSettingsPage * SettingsPage;
ManualDevicesSettingsPage * manualDevicesPage;
PluginManager * plugin_manager = nullptr;
bool device_view_showing = false;
bool ShowI2CTools = false;
bool plugins_loaded = false;
/*-----------------------------------------------------*\
| System tray icon and menu |
\*-----------------------------------------------------*/
QSystemTrayIcon * trayIcon;
QMenu * trayIconMenu;
QMenu * profileMenu;
QAction * actionExit;
QString dialog_message;
/*-----------------------------------------------------*\
| User interface |
\*-----------------------------------------------------*/
Ui::OpenRGBDialog *ui;
void AddSoftwareInfoPage();
void AddSupportedDevicesPage();
void AddSettingsPage();
void AddPluginsPage();
void AddConsolePage();
void AddManualDevicesSettingsPage();
void ClearDevicesList();
void UpdateDevicesList();
void UpdateProfileList();
void closeEvent(QCloseEvent *event) override;
bool SelectConfigProfile(const std::string name);
void SetDetectionViewState(bool detection_showing);
void SaveProfile();
void SaveProfileAs();
void TogglePluginsVisibility(int, QTabWidget*);
void ShowLEDView();
void HideLEDView();
void OnSuspend() override;
void OnResume() override;
private slots:
void on_Exit();
void on_LightsOff();
void on_QuickRed();
void on_QuickYellow();
void on_QuickGreen();
void on_QuickCyan();
void on_QuickBlue();
void on_QuickMagenta();
void on_QuickWhite();
void onDeviceListUpdated();
void onDetectionProgressUpdated();
void onDetectionStarted();
void onDetectionEnded();
void on_SetAllDevices(unsigned char red, unsigned char green, unsigned char blue);
void on_SaveSizeProfile();
void on_ShowHide();
void onShowDialogMessage();
void on_ReShow(QSystemTrayIcon::ActivationReason reason);
void on_ProfileSelected();
void on_ButtonLoadProfile_clicked();
void on_ButtonDeleteProfile_clicked();
void on_ButtonToggleDeviceView_clicked();
void on_ButtonStopDetection_clicked();
void on_ButtonRescan_clicked();
void on_ActionSaveProfile_triggered();
void on_ActionSaveProfileAs_triggered();
void on_MainTabBar_currentChanged(int);
void on_InformationTabBar_currentChanged(int);
void on_DevicesTabBar_currentChanged(int);
void on_SettingsTabBar_currentChanged(int);
};
+206
View File
@@ -0,0 +1,206 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OpenRGBDialog</class>
<widget class="QMainWindow" name="OpenRGBDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>700</width>
<height>350</height>
</rect>
</property>
<property name="windowTitle">
<string>OpenRGB</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0" colspan="5">
<widget class="QTabWidget" name="MainTabBar">
<property name="tabShape">
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<widget class="QWidget" name="TabDevices">
<attribute name="title">
<string>Devices</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0">
<widget class="QTabWidget" name="DevicesTabBar">
<property name="tabPosition">
<enum>QTabWidget::West</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="TabInformation">
<attribute name="title">
<string>Information</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QTabWidget" name="InformationTabBar">
<property name="tabPosition">
<enum>QTabWidget::West</enum>
</property>
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="TabSettings">
<attribute name="title">
<string>Settings</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QTabWidget" name="SettingsTabBar">
<property name="tabPosition">
<enum>QTabWidget::West</enum>
</property>
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="6" column="0" colspan="5">
<layout class="QHBoxLayout" name="MainButtonsLayout">
<item>
<widget class="QFrame" name="MainButtonsFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QPushButton" name="ButtonToggleDeviceView">
<property name="text">
<string>Toggle LED View</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="ButtonRescan">
<property name="text">
<string>Rescan Devices</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="ButtonSaveProfile">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Save Profile</string>
</property>
<property name="popupMode">
<enum>QToolButton::MenuButtonPopup</enum>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="ButtonDeleteProfile">
<property name="text">
<string>Delete Profile</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="ButtonLoadProfile">
<property name="text">
<string>Load Profile</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QComboBox" name="ProfileBox"/>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item row="4" column="0" colspan="5">
<layout class="QHBoxLayout" name="DetectorLayout">
<item>
<widget class="QLabel" name="DetectionProgressLabel">
<property name="text">
<string>OpenRGB is detecting devices...</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="DetectionProgressBar">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="ButtonStopDetection">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<action name="ActionSaveProfile">
<property name="text">
<string>Save Profile</string>
</property>
<property name="toolTip">
<string>Save Profile</string>
</property>
</action>
<action name="ActionSaveProfileAs">
<property name="text">
<string>Save Profile As...</string>
</property>
<property name="toolTip">
<string>Save Profile with custom name</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>
+51
View File
@@ -0,0 +1,51 @@
/*---------------------------------------------------------*\
| OpenRGBFont.cpp |
| |
| Functionality for OpenRGB custom font icons |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <QStringList>
#include <QFontDatabase>
#include "OpenRGBFont.h"
OpenRGBFont* OpenRGBFont::instance;
OpenRGBFont::OpenRGBFont()
{
}
OpenRGBFont *OpenRGBFont::Get()
{
if(!instance)
{
instance = new OpenRGBFont();
instance->fontId = QFontDatabase::addApplicationFont(":/fonts/OpenRGB.ttf");
if(instance->fontId == -1)
{
printf("Cannot load requested font.\n");
}
else
{
QString family = QFontDatabase::applicationFontFamilies(instance->fontId).at(0);
instance->font = QFont(family);
instance->font.setStyleStrategy(QFont::PreferAntialias);
}
}
return instance;
}
QString OpenRGBFont::icon(int glyph)
{
return QChar(glyph);
}
QFont OpenRGBFont::GetFont()
{
return Get()->font;
}
+63
View File
@@ -0,0 +1,63 @@
/*---------------------------------------------------------*\
| OpenRGBFont.h |
| |
| Functionality for OpenRGB custom font icons |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <QFont>
#include <QString>
class OpenRGBFont
{
public:
static OpenRGBFont* Get();
enum Glyph
{
bulb = 0xF001,
controller = 0xF002,
cooler = 0xF003,
data = 0xF004,
dram = 0xF005,
drive = 0xF006,
extension = 0xF007,
gamepad = 0xF008,
gpu = 0xF009,
headset = 0xF00A,
headsetstand = 0xF00B,
info = 0xF00C,
keyboard = 0xF00D,
keypad = 0xF00E,
ledstrip = 0xF00F,
mainboard = 0xF010,
mic = 0xF011,
mouse = 0xF012,
mousemat = 0xF013,
music_speaker = 0xF014,
options = 0xF015,
pc_case = 0xF016,
serial = 0xF017,
terminal = 0xF018,
toolbox = 0xF019,
unknown = 0xF01A,
virtual_controller = 0xF01B,
usb = 0xF01C,
laptop = 0xF01D,
monitor = 0xF01E
};
static QString icon(int);
static QFont GetFont();
private:
OpenRGBFont();
static OpenRGBFont* instance;
int fontId = -1;
QFont font;
};
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

@@ -0,0 +1,144 @@
/*---------------------------------------------------------*\
| OpenRGBHardwareIDsDialog.cpp |
| |
| User interface for OpenRGB Hardware IDs dialog |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <QString>
#include <QClipboard>
#include <hidapi.h>
#include <libusb.h>
#include "OpenRGBHardwareIDsDialog.h"
#include "ui_OpenRGBHardwareIDsDialog.h"
#include "ResourceManager.h"
#include "StringUtils.h"
OpenRGBHardwareIDsDialog::OpenRGBHardwareIDsDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::OpenRGBHardwareIDsDialog)
{
ui->setupUi(this);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
ui->HardwareIdsList->header()->resizeSection(0 /*column index*/, 300 /*width*/);
ui->HardwareIdsList->header()->resizeSection(1 /*column index*/, 200 /*width*/);
ui->HardwareIdsList->header()->resizeSection(2 /*column index*/, 100 /*width*/);
}
OpenRGBHardwareIDsDialog::~OpenRGBHardwareIDsDialog()
{
delete ui;
}
int OpenRGBHardwareIDsDialog::show()
{
/*---------------------------------------------------------*\
| Add i2c busses infos |
\*---------------------------------------------------------*/
std::vector<i2c_smbus_interface*> i2CBusses = ResourceManager::get()->GetI2CBusses();
// The widget takes control over items after creation
QTreeWidgetItem* i2c_top = new QTreeWidgetItem(ui->HardwareIdsList, {"i2c busses"});
strings.push_back("[ i2c busses ]");
for(i2c_smbus_interface* bus : i2CBusses)
{
char line[550];
snprintf(line, 550, "%04X:%04X %04X:%04X", bus->pci_vendor, bus->pci_device, bus->pci_subsystem_vendor, bus->pci_subsystem_device);
new QTreeWidgetItem(i2c_top, {line, bus->device_name});
snprintf(line, 550, "%04X:%04X %04X:%04X - %s", bus->pci_vendor, bus->pci_device, bus->pci_subsystem_vendor, bus->pci_subsystem_device, bus->device_name);
strings.push_back(line);
}
/*---------------------------------------------------------*\
| Add HID devices infos |
\*---------------------------------------------------------*/
hid_device_info* hid_devices = NULL;
hid_devices = hid_enumerate(0,0);
hid_device_info* current_hid_device;
current_hid_device = hid_devices;
QTreeWidgetItem* hid_top = new QTreeWidgetItem(ui->HardwareIdsList, {"HID devices"});
strings.push_back("\n[ HID devices ]");
while(current_hid_device)
{
const char* manu_name = StringUtils::wchar_to_char(current_hid_device->manufacturer_string);
const char* prod_name = StringUtils::wchar_to_char(current_hid_device->product_string);
char line[550];
snprintf(line, 550, "[%04X:%04X U=%04X P=0x%04X I=%d]", current_hid_device->vendor_id, current_hid_device->product_id, current_hid_device->usage, current_hid_device->usage_page, current_hid_device->interface_number);
new QTreeWidgetItem(hid_top, {line, prod_name, manu_name});
snprintf(line, 550, "[%04X:%04X U=%04X P=0x%04X I=%d] %s - %s", current_hid_device->vendor_id, current_hid_device->product_id, current_hid_device->usage, current_hid_device->usage_page, current_hid_device->interface_number, manu_name, prod_name);
strings.push_back(line);
current_hid_device = current_hid_device->next;
}
/*---------------------------------------------------------*\
| Add LibUSB devices infos |
\*---------------------------------------------------------*/
libusb_device** devices = nullptr;
QTreeWidgetItem* libusb_top = new QTreeWidgetItem(ui->HardwareIdsList, {"LibUSB devices"});
strings.push_back("\n[ LibUSB devices ]");
int ret;
ret = libusb_init(NULL);
if(ret < 0)
{
return 0;
}
ret = libusb_get_device_list(NULL, &devices);
if(ret < 0)
{
return 0;
}
int deviceCount = ret;
for(int i = 0; i < deviceCount; i++)
{
libusb_device* device = devices[i];
libusb_device_descriptor descriptor;
ret = libusb_get_device_descriptor(device, &descriptor);
if(ret < 0)
{
continue;
}
char line[512];
snprintf(line, 512, "%04X:%04X", descriptor.idVendor, descriptor.idProduct);
new QTreeWidgetItem(libusb_top, {line});
strings.push_back(line);
}
if(devices != nullptr)
{
libusb_free_device_list(devices, 1);
}
i2c_top->setExpanded(true);
hid_top->setExpanded(true);
libusb_top->setExpanded(true);
return this->exec();
}
void OpenRGBHardwareIDsDialog::on_CopyToClipboardButton_clicked()
{
QClipboard *clipboard = QGuiApplication::clipboard();
clipboard->setText(strings.join("\n"));
}
@@ -0,0 +1,35 @@
/*---------------------------------------------------------*\
| OpenRGBHardwareIDsDialog.h |
| |
| User interface for OpenRGB Hardware IDs dialog |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <QDialog>
namespace Ui
{
class OpenRGBHardwareIDsDialog;
}
class OpenRGBHardwareIDsDialog : public QDialog
{
Q_OBJECT
public:
explicit OpenRGBHardwareIDsDialog(QWidget *parent = nullptr);
~OpenRGBHardwareIDsDialog();
int show();
private slots:
void on_CopyToClipboardButton_clicked();
private:
Ui::OpenRGBHardwareIDsDialog *ui;
QStringList strings;
};
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OpenRGBHardwareIDsDialog</class>
<widget class="QWidget" name="OpenRGBHardwareIDsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>700</width>
<height>500</height>
</rect>
</property>
<property name="windowTitle">
<string>Hardware IDs</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QPushButton" name="CopyToClipboardButton">
<property name="text">
<string>Copy to clipboard</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QTreeWidget" name="HardwareIdsList">
<column>
<property name="text">
<string>Location</string>
</property>
</column>
<column>
<property name="text">
<string>Device</string>
</property>
</column>
<column>
<property name="text">
<string>Vendor</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,50 @@
/*---------------------------------------------------------*\
| OpenRGBPluginContainer.h |
| |
| User interface entry for OpenRGB plugin container widget|
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "OpenRGBPluginContainer.h"
#include "ui_OpenRGBPluginContainer.h"
OpenRGBPluginContainer::OpenRGBPluginContainer(QWidget *plugin, QWidget *parent) :
QWidget(parent),
ui(new Ui::OpenRGBPluginContainer)
{
ui->setupUi(this);
plugin_widget = plugin;
plugin_widget->setParent(this);
ui->PluginContainerLayout->layout()->addWidget(plugin_widget);
Hide();
}
OpenRGBPluginContainer::~OpenRGBPluginContainer()
{
delete ui;
}
void OpenRGBPluginContainer::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
}
void OpenRGBPluginContainer::Hide()
{
plugin_widget->hide();
ui->PluginContainerLayout->layout()->invalidate();
}
void OpenRGBPluginContainer::Show()
{
plugin_widget->show();
ui->PluginContainerLayout->layout()->invalidate();
}
@@ -0,0 +1,36 @@
/*---------------------------------------------------------*\
| OpenRGBPluginContainer.h |
| |
| User interface entry for OpenRGB plugin container widget|
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <QWidget>
namespace Ui
{
class OpenRGBPluginContainer;
}
class OpenRGBPluginContainer : public QWidget
{
Q_OBJECT
public:
explicit OpenRGBPluginContainer(QWidget *plugin, QWidget *parent = nullptr);
~OpenRGBPluginContainer();
void Hide();
void Show();
QWidget* plugin_widget;
private:
Ui::OpenRGBPluginContainer *ui;
private slots:
void changeEvent(QEvent *event);
};
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OpenRGBPluginContainer</class>
<widget class="QWidget" name="OpenRGBPluginContainer">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>256</width>
<height>120</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true">Plugin Container</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QGridLayout" name="PluginContainerLayout"/>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,120 @@
/*---------------------------------------------------------*\
| OpenRGBPluginsEntry.cpp |
| |
| User interface entry for OpenRGB plugin entry widget |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "OpenRGBPluginsEntry.h"
#include "ui_OpenRGBPluginsEntry.h"
#include "PluginManager.h"
OpenRGBPluginsEntry::OpenRGBPluginsEntry(QWidget *parent) :
QWidget(parent),
ui(new Ui::OpenRGBPluginsEntry)
{
ui->setupUi(this);
EnableClickCallbackVal = nullptr;
EnableClickCallbackArg = nullptr;
}
OpenRGBPluginsEntry::~OpenRGBPluginsEntry()
{
delete ui;
}
void OpenRGBPluginsEntry::fillFrom(const OpenRGBPluginEntry *plugin)
{
/*---------------------------------------------------------*\
| Fill in plugin information fields |
\*---------------------------------------------------------*/
ui->NameValue->setText(QString::fromStdString(plugin->info.Name));
ui->DescriptionValue->setText(QString::fromStdString(plugin->info.Description));
ui->VersionValue->setText(QString::fromStdString(plugin->info.Version));
ui->CommitValue->setText(QString::fromStdString(plugin->info.Commit));
ui->URLValue->setText(QString::fromStdString(plugin->info.URL));
ui->APIVersionValue->setText(QString::number(plugin->api_version));
/*---------------------------------------------------------*\
| If the plugin is incompatible, highlight the API version |
| in red and disable the enable checkbox |
\*---------------------------------------------------------*/
if(plugin->incompatible)
{
ui->APIVersionValue->setStyleSheet("QLabel { color : red; }");
ui->EnabledCheckBox->setEnabled(false);
}
/*---------------------------------------------------------*\
| Fill in plugin icon |
\*---------------------------------------------------------*/
QPixmap pixmap(QPixmap::fromImage(plugin->info.Icon));
ui->IconView->setPixmap(pixmap);
ui->IconView->setScaledContents(true);
/*---------------------------------------------------------*\
| Fill in plugin path |
\*---------------------------------------------------------*/
ui->PathValue->setText(QString::fromStdString(plugin->path));
/*---------------------------------------------------------*\
| Fill in plugin enabled status |
\*---------------------------------------------------------*/
ui->EnabledCheckBox->setChecked((plugin->enabled));
is_system = plugin->is_system;
}
bool OpenRGBPluginsEntry::isSystem() const
{
return is_system;
}
bool OpenRGBPluginsEntry::isPluginEnabled() const
{
return ui->EnabledCheckBox->isChecked();
}
std::string OpenRGBPluginsEntry::getName() const
{
return ui->NameValue->text().toStdString();
}
std::string OpenRGBPluginsEntry::getDescription() const
{
return ui->DescriptionValue->text().toStdString();
}
std::string OpenRGBPluginsEntry::getPath() const
{
return ui->PathValue->text().toStdString();
}
void OpenRGBPluginsEntry::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
}
void OpenRGBPluginsEntry::RegisterEnableClickCallback(EnableClickCallback new_callback, void * new_callback_arg)
{
EnableClickCallbackVal = new_callback;
EnableClickCallbackArg = new_callback_arg;
}
void OpenRGBPluginsEntry::on_EnabledCheckBox_stateChanged(int /*checked*/)
{
/*-------------------------------------------------*\
| Call the callbacks |
\*-------------------------------------------------*/
if(EnableClickCallbackVal != nullptr)
{
EnableClickCallbackVal(EnableClickCallbackArg, this);
}
}
@@ -0,0 +1,49 @@
/*---------------------------------------------------------*\
| OpenRGBPluginsEntry.h |
| |
| User interface entry for OpenRGB plugin entry widget |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <QWidget>
namespace Ui
{
class OpenRGBPluginsEntry;
}
typedef void (*EnableClickCallback)(void *, void *);
struct OpenRGBPluginEntry;
class OpenRGBPluginsEntry : public QWidget
{
Q_OBJECT
public:
explicit OpenRGBPluginsEntry(QWidget *parent = nullptr);
~OpenRGBPluginsEntry();
void fillFrom(const OpenRGBPluginEntry* plugin);
bool isSystem() const;
bool isPluginEnabled() const;
std::string getName() const;
std::string getDescription() const;
std::string getPath() const;
void RegisterEnableClickCallback(EnableClickCallback new_callback, void * new_callback_arg);
private slots:
void changeEvent(QEvent *event);
void on_EnabledCheckBox_stateChanged(int checked);
private:
EnableClickCallback EnableClickCallbackVal;
void * EnableClickCallbackArg;
Ui::OpenRGBPluginsEntry * ui;
bool is_system;
};
@@ -0,0 +1,197 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OpenRGBPluginsEntry</class>
<widget class="QWidget" name="OpenRGBPluginsEntry">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>478</width>
<height>238</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Plugins Entry</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="5" column="1">
<widget class="QLabel" name="URLLabel">
<property name="text">
<string>URL:</string>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="8">
<widget class="QLabel" name="IconView">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="text">
<string notr="true">Icon</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLabel" name="URLValue">
<property name="text">
<string notr="true">URL Value</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="EnabledLabel">
<property name="text">
<string>Enabled</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="DescriptionLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Description:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="NameValue">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">Name Value</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="PathValue">
<property name="text">
<string notr="true">Path Value</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLabel" name="VersionValue">
<property name="text">
<string notr="true">Version Value</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QLabel" name="CommitValue">
<property name="text">
<string notr="true">Commit Value</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="NameLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="PathLabel">
<property name="text">
<string>Path:</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QCheckBox" name="EnabledCheckBox">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="VersionLabel">
<property name="text">
<string>Version:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="CommitLabel">
<property name="text">
<string>Commit:</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="DescriptionValue">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">Description Value</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="APIVersionLabel">
<property name="text">
<string>API Version:</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QLabel" name="APIVersionValue">
<property name="text">
<string>API Version Value</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,53 @@
/*---------------------------------------------------------*\
| OpenRGBPluginsList.cpp |
| |
| User interface entry for OpenRGB plugin list widget |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <QMimeData>
#include <QUrl>
#include "OpenRGBPluginsList.h"
OpenRGBPluginsList::OpenRGBPluginsList(QWidget *parent) : QListWidget (parent)
{
setAcceptDrops(true);
}
void OpenRGBPluginsList::dropEvent(QDropEvent *event)
{
const QMimeData* mimeData = event->mimeData();
if (mimeData->hasUrls())
{
std::vector<std::string> path_list;
QList<QUrl> urls = mimeData->urls();
for(const QUrl& url: urls)
{
path_list.push_back(url.toLocalFile().toStdString());
}
emit PluginsDropped(path_list);
}
}
void OpenRGBPluginsList::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData()->hasUrls())
{
event->acceptProposedAction();
}
else
{
event->ignore();
}
}
void OpenRGBPluginsList::dragMoveEvent(QDragMoveEvent *event)
{
event->acceptProposedAction();
}
@@ -0,0 +1,30 @@
/*---------------------------------------------------------*\
| OpenRGBPluginsList.h |
| |
| User interface entry for OpenRGB plugin list widget |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <QListWidget>
#include <QDropEvent>
#include <QDragEnterEvent>
class OpenRGBPluginsList : public QListWidget
{
Q_OBJECT
public:
OpenRGBPluginsList(QWidget *parent = nullptr);
signals:
void PluginsDropped(std::vector<std::string>);
protected:
void dropEvent(QDropEvent *event) override;
void dragEnterEvent(QDragEnterEvent *event) override;
void dragMoveEvent(QDragMoveEvent *event) override;
};
@@ -0,0 +1,346 @@
/*---------------------------------------------------------*\
| OpenRGBPluginsPage.cpp |
| |
| User interface entry for OpenRGB plugin settings |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <QFileDialog>
#include <QMessageBox>
#include <QGraphicsPixmapItem>
#include <QGraphicsScene>
#include "filesystem.h"
#include "LogManager.h"
#include "SettingsManager.h"
#include "OpenRGBPluginsPage.h"
#include "ui_OpenRGBPluginsPage.h"
#include "ResourceManager.h"
void EnableClickCallbackFunction(void* this_ptr, void* entry_ptr)
{
OpenRGBPluginsPage* this_page = (OpenRGBPluginsPage*)this_ptr;
this_page->on_EnableButton_clicked((OpenRGBPluginsEntry*)entry_ptr);
}
OpenRGBPluginsPage::OpenRGBPluginsPage(PluginManager* plugin_manager_ptr, QWidget *parent) :
QWidget(parent),
ui(new Ui::OpenRGBPluginsPage)
{
plugin_manager = plugin_manager_ptr;
ui->setupUi(this);
RefreshList();
}
OpenRGBPluginsPage::~OpenRGBPluginsPage()
{
delete ui;
}
void OpenRGBPluginsPage::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
}
void OpenRGBPluginsPage::RefreshList()
{
ui->PluginsList->clear();
entries.clear();
for(const OpenRGBPluginEntry& plugin: plugin_manager->ActivePlugins)
{
OpenRGBPluginsEntry* entry = new OpenRGBPluginsEntry();
/*---------------------------------------------------------*\
| Fill in plugin information fields |
\*---------------------------------------------------------*/
entry->fillFrom(&plugin);
entry->RegisterEnableClickCallback(EnableClickCallbackFunction, this);
/*---------------------------------------------------------*\
| Add the entry to the plugin list |
\*---------------------------------------------------------*/
QListWidgetItem* item = new QListWidgetItem;
item->setSizeHint(entry->sizeHint());
ui->PluginsList->addItem(item);
ui->PluginsList->setItemWidget(item, entry);
entries.push_back(entry);
}
}
void OpenRGBPluginsPage::on_InstallPluginButton_clicked()
{
/*-----------------------------------------------------*\
| Open a file selection prompt to choose the plugin file|
\*-----------------------------------------------------*/
QString install_file = QFileDialog::getOpenFileName(this, tr("Install OpenRGB Plugin"), "", tr("Plugin files (*.dll *.dylib *.so *.so.*)"));
bool installed = InstallPlugin(install_file.toStdString());
if(installed)
{
RefreshList();
}
}
bool OpenRGBPluginsPage::InstallPlugin(std::string install_file)
{
filesystem::path from_path = filesystem::u8path(install_file);
filesystem::path to_path = ResourceManager::get()->GetConfigurationDirectory() / "plugins" / from_path.filename();
bool match = false;
LOG_TRACE("[OpenRGBPluginsPage] Installing plugin %s", install_file.c_str());
/*-----------------------------------------------------*\
| Check if a plugin with this path already exists |
\*-----------------------------------------------------*/
for(unsigned int plugin_idx = 0; plugin_idx < plugin_manager->ActivePlugins.size(); plugin_idx++)
{
if(to_path == plugin_manager->ActivePlugins[plugin_idx].path)
{
match = true;
break;
}
}
/*-----------------------------------------------------*\
| If this plugin already exists, prompt to replace it |
\*-----------------------------------------------------*/
if(match == true)
{
QMessageBox::StandardButton reply;
reply = QMessageBox::question(this, tr("Replace Plugin"), tr("A plugin with this filename is already installed. Are you sure you want to replace this plugin?"), QMessageBox::Yes | QMessageBox::No);
if(reply != QMessageBox::Yes)
{
return false;
}
}
/*-----------------------------------------------------*\
| When replacing, remove the existing plugin before |
| copying the file and adding the new one |
\*-----------------------------------------------------*/
try
{
plugin_manager->RemovePlugin(to_path);
LOG_TRACE("[OpenRGBPluginsPage] Copying from %s to %s", from_path.c_str(), to_path.c_str());
filesystem::copy(from_path, to_path, filesystem::copy_options::overwrite_existing);
plugin_manager->AddPlugin(to_path, false);
return true;
}
catch(const std::exception& e)
{
LOG_ERROR("[OpenRGBPluginsPage] Failed to install plugin: %s", e.what());
}
return false;
}
void OpenRGBPluginsPage::on_RemovePluginButton_clicked()
{
QMessageBox::StandardButton reply;
/*-----------------------------------------------------*\
| Confirm plugin removal with message box |
\*-----------------------------------------------------*/
reply = QMessageBox::question(this, tr("Remove Plugin"), tr("Are you sure you want to remove this plugin?"), QMessageBox::Yes | QMessageBox::No);
if(reply != QMessageBox::Yes)
{
return;
}
/*-----------------------------------------------------*\
| Get index of selected plugin entry |
\*-----------------------------------------------------*/
int cur_row = ui->PluginsList->currentRow();
if(cur_row < 0)
{
return;
}
/*-----------------------------------------------------*\
| Don't allow removing system plugins |
\*-----------------------------------------------------*/
if(entries[cur_row]->isSystem())
{
return;
}
/*-----------------------------------------------------*\
| Open plugin settings |
\*-----------------------------------------------------*/
json plugin_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Plugins");
/*-----------------------------------------------------*\
| Find plugin's entry in settings and remove it |
\*-----------------------------------------------------*/
if(plugin_settings.contains("plugins"))
{
for(unsigned int plugin_idx = 0; plugin_idx < plugin_settings["plugins"].size(); plugin_idx++)
{
if((plugin_settings["plugins"][plugin_idx].contains("name"))
&&(plugin_settings["plugins"][plugin_idx].contains("description")))
{
if((plugin_settings["plugins"][plugin_idx]["name"] == entries[cur_row]->getName())
&&(plugin_settings["plugins"][plugin_idx]["description"] == entries[cur_row]->getDescription()))
{
/*-------------------------------------*\
| Remove plugin from settings |
\*-------------------------------------*/
plugin_settings["plugins"].erase(plugin_idx);
}
}
}
}
/*-----------------------------------------------------*\
| Mark plugin to be removed on next restart |
\*-----------------------------------------------------*/
plugin_settings["plugins_remove"][plugin_settings["plugins_remove"].size()] = entries[cur_row]->getPath();
ResourceManager::get()->GetSettingsManager()->SetSettings("Plugins", plugin_settings);
ResourceManager::get()->GetSettingsManager()->SaveSettings();
QMessageBox::information(this, tr("Restart Needed"), tr("The plugin will be fully removed after restarting OpenRGB."), QMessageBox::Ok);
}
void OpenRGBPluginsPage::on_EnableButton_clicked(OpenRGBPluginsEntry* entry)
{
/*-----------------------------------------------------*\
| Open plugin list and check if plugin is in the list |
\*-----------------------------------------------------*/
json plugin_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Plugins");
/*-----------------------------------------------------*\
| Search the settings to find the correct index |
\*-----------------------------------------------------*/
std::string name = "";
std::string description = "";
bool enabled = entry->isPluginEnabled();
bool found = false;
unsigned int plugin_ct = 0;
unsigned int plugin_idx = 0;
std::string entry_name = entry->getName();
std::string entry_desc = entry->getDescription();
std::string entry_path = entry->getPath();
if(plugin_settings.contains("plugins"))
{
plugin_ct = (unsigned int)plugin_settings["plugins"].size();
for(plugin_idx = 0; plugin_idx < (unsigned int)plugin_settings["plugins"].size(); plugin_idx++)
{
if(plugin_settings["plugins"][plugin_idx].contains("name"))
{
name = plugin_settings["plugins"][plugin_idx]["name"];
}
if(plugin_settings["plugins"][plugin_idx].contains("description"))
{
description = plugin_settings["plugins"][plugin_idx]["description"];
}
if((entry_name == name)
&&(entry_desc == description))
{
found = true;
break;
}
}
}
/*-----------------------------------------------------*\
| If the plugin was not in the list, add it to the list |
| and default it to enabled, then save the settings |
\*-----------------------------------------------------*/
if(!found)
{
plugin_settings["plugins"][plugin_ct]["name"] = entry_name;
plugin_settings["plugins"][plugin_ct]["description"] = entry_desc;
plugin_settings["plugins"][plugin_ct]["enabled"] = enabled;
ResourceManager::get()->GetSettingsManager()->SetSettings("Plugins", plugin_settings);
ResourceManager::get()->GetSettingsManager()->SaveSettings();
}
else
{
plugin_settings["plugins"][plugin_idx]["enabled"] = enabled;
ResourceManager::get()->GetSettingsManager()->SetSettings("Plugins", plugin_settings);
ResourceManager::get()->GetSettingsManager()->SaveSettings();
}
if(enabled)
{
plugin_manager->EnablePlugin(entry_path);
}
else
{
plugin_manager->DisablePlugin(entry_path);
}
}
void OpenRGBPluginsPage::on_PluginsList_itemSelectionChanged()
{
/*-----------------------------------------------------*\
| Get index of selected plugin entry |
\*-----------------------------------------------------*/
int cur_row = ui->PluginsList->currentRow();
/*-----------------------------------------------------*\
| Disable the remove button if no item selected |
\*-----------------------------------------------------*/
if(cur_row == -1)
{
ui->RemovePluginButton->setEnabled(false);
return;
}
/*-----------------------------------------------------*\
| Enable the remove button when there's a selected item |
| and the selected item is not a system plugin |
\*-----------------------------------------------------*/
if(!entries[cur_row]->isSystem())
{
ui->RemovePluginButton->setEnabled(!ui->PluginsList->selectedItems().empty());
ui->RemovePluginButton->setText("Remove Plugin");
}
else
{
ui->RemovePluginButton->setEnabled(false);
ui->RemovePluginButton->setText("System Plugin - Cannot Remove");
}
}
void OpenRGBPluginsPage::on_PluginsList_PluginsDropped(std::vector<std::string> path_list)
{
bool installed = false;
for(const std::string& file_path: path_list)
{
installed |= InstallPlugin(file_path);
}
if(installed)
{
RefreshList();
}
}
@@ -0,0 +1,48 @@
/*---------------------------------------------------------*\
| OpenRGBPluginsPage.h |
| |
| User interface entry for OpenRGB plugin settings |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <QWidget>
#include "OpenRGBPluginsEntry.h"
#include "PluginManager.h"
namespace Ui
{
class OpenRGBPluginsPage;
}
class OpenRGBPluginsPage : public QWidget
{
Q_OBJECT
public:
explicit OpenRGBPluginsPage(PluginManager* plugin_manager_ptr, QWidget *parent = nullptr);
~OpenRGBPluginsPage();
void on_EnableButton_clicked(OpenRGBPluginsEntry* entry);
void RefreshList();
private slots:
void changeEvent(QEvent *event);
void on_InstallPluginButton_clicked();
void on_RemovePluginButton_clicked();
void on_PluginsList_itemSelectionChanged();
void on_PluginsList_PluginsDropped(std::vector<std::string>);
private:
Ui::OpenRGBPluginsPage* ui;
PluginManager* plugin_manager;
std::vector<OpenRGBPluginsEntry*> entries;
bool InstallPlugin(std::string path);
};

Some files were not shown because too many files have changed in this diff Show More