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