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