Publish LumaOps source
This commit is contained in:
@@ -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>
|
||||
Reference in New Issue
Block a user