Add Philips Hue settings page
This commit is contained in:
parent
ea00ca8977
commit
b8246b6140
9 changed files with 429 additions and 0 deletions
|
|
@ -187,6 +187,8 @@ HEADERS +=
|
|||
qt/OpenRGBZoneResizeDialog.h \
|
||||
qt/OpenRGBE131SettingsPage/OpenRGBE131SettingsEntry.h \
|
||||
qt/OpenRGBE131SettingsPage/OpenRGBE131SettingsPage.h \
|
||||
qt/OpenRGBPhilipsHueSettingsPage/OpenRGBPhilipsHueSettingsEntry.h \
|
||||
qt/OpenRGBPhilipsHueSettingsPage/OpenRGBPhilipsHueSettingsPage.h \
|
||||
qt/OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsEntry.h \
|
||||
qt/OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsPage.h \
|
||||
qt/OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsEntry.h \
|
||||
|
|
@ -523,6 +525,8 @@ SOURCES +=
|
|||
qt/hsv.cpp \
|
||||
qt/OpenRGBE131SettingsPage/OpenRGBE131SettingsEntry.cpp \
|
||||
qt/OpenRGBE131SettingsPage/OpenRGBE131SettingsPage.cpp \
|
||||
qt/OpenRGBPhilipsHueSettingsPage/OpenRGBPhilipsHueSettingsEntry.cpp \
|
||||
qt/OpenRGBPhilipsHueSettingsPage/OpenRGBPhilipsHueSettingsPage.cpp \
|
||||
qt/OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsEntry.cpp \
|
||||
qt/OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsPage.cpp \
|
||||
qt/OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsEntry.cpp \
|
||||
|
|
@ -874,6 +878,8 @@ FORMS +=
|
|||
qt/OpenRGBZoneResizeDialog.ui \
|
||||
qt/OpenRGBE131SettingsPage/OpenRGBE131SettingsEntry.ui \
|
||||
qt/OpenRGBE131SettingsPage/OpenRGBE131SettingsPage.ui \
|
||||
qt/OpenRGBPhilipsHueSettingsPage/OpenRGBPhilipsHueSettingsEntry.ui \
|
||||
qt/OpenRGBPhilipsHueSettingsPage/OpenRGBPhilipsHueSettingsPage.ui \
|
||||
qt/OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsEntry.ui \
|
||||
qt/OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsPage.ui \
|
||||
qt/OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsEntry.ui \
|
||||
|
|
|
|||
|
|
@ -453,6 +453,11 @@ OpenRGBDialog2::OpenRGBDialog2(QWidget *parent) : QMainWindow(parent), ui(new Op
|
|||
\*-----------------------------------------------------*/
|
||||
AddQMKORGBSettingsPage();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Add the Philips Hue settings page |
|
||||
\*-----------------------------------------------------*/
|
||||
AddPhilipsHueSettingsPage();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Add the Philips Wiz settings page |
|
||||
\*-----------------------------------------------------*/
|
||||
|
|
@ -661,6 +666,34 @@ void OpenRGBDialog2::AddE131SettingsPage()
|
|||
ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel);
|
||||
}
|
||||
|
||||
void OpenRGBDialog2::AddPhilipsHueSettingsPage()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Create the Settings page |
|
||||
\*-----------------------------------------------------*/
|
||||
PhilipsHueSettingsPage = new OpenRGBPhilipsHueSettingsPage();
|
||||
|
||||
ui->SettingsTabBar->addTab(PhilipsHueSettingsPage, "");
|
||||
|
||||
QString SettingsLabelString;
|
||||
|
||||
if(IsDarkTheme())
|
||||
{
|
||||
SettingsLabelString = "light_dark.png";
|
||||
}
|
||||
else
|
||||
{
|
||||
SettingsLabelString = "light.png";
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Create the tab label |
|
||||
\*-----------------------------------------------------*/
|
||||
TabLabel* SettingsTabLabel = new TabLabel(SettingsLabelString, "Philips Hue Devices");
|
||||
|
||||
ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel);
|
||||
}
|
||||
|
||||
void OpenRGBDialog2::AddPhilipsWizSettingsPage()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include "OpenRGBSupportedDevicesPage.h"
|
||||
#include "OpenRGBSettingsPage.h"
|
||||
#include "OpenRGBE131SettingsPage/OpenRGBE131SettingsPage.h"
|
||||
#include "OpenRGBPhilipsHueSettingsPage/OpenRGBPhilipsHueSettingsPage.h"
|
||||
#include "OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsPage.h"
|
||||
#include "OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsPage.h"
|
||||
#include "OpenRGBSerialSettingsPage/OpenRGBSerialSettingsPage.h"
|
||||
|
|
@ -66,6 +67,7 @@ private:
|
|||
OpenRGBSupportedDevicesPage *SupportedPage;
|
||||
OpenRGBSettingsPage *SettingsPage;
|
||||
OpenRGBE131SettingsPage *E131SettingsPage;
|
||||
OpenRGBPhilipsHueSettingsPage *PhilipsHueSettingsPage;
|
||||
OpenRGBPhilipsWizSettingsPage *PhilipsWizSettingsPage;
|
||||
OpenRGBQMKORGBSettingsPage *QMKORGBSettingsPage;
|
||||
OpenRGBSerialSettingsPage *SerialSettingsPage;
|
||||
|
|
@ -89,6 +91,7 @@ private:
|
|||
void AddSupportedDevicesPage();
|
||||
void AddSettingsPage();
|
||||
void AddE131SettingsPage();
|
||||
void AddPhilipsHueSettingsPage();
|
||||
void AddPhilipsWizSettingsPage();
|
||||
void AddQMKORGBSettingsPage();
|
||||
void AddSerialSettingsPage();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
#include "OpenRGBPhilipsHueSettingsEntry.h"
|
||||
#include "ui_OpenRGBPhilipsHueSettingsEntry.h"
|
||||
|
||||
using namespace Ui;
|
||||
|
||||
OpenRGBPhilipsHueSettingsEntry::OpenRGBPhilipsHueSettingsEntry(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::OpenRGBPhilipsHueSettingsEntryUi)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
OpenRGBPhilipsHueSettingsEntry::~OpenRGBPhilipsHueSettingsEntry()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void Ui::OpenRGBPhilipsHueSettingsEntry::on_UnpairButton_clicked()
|
||||
{
|
||||
ui->UsernameValue->setText("");
|
||||
ui->ClientKeyValue->setText("");
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
#ifndef OPENRGBPHILIPSHUESETTINGSENTRY_H
|
||||
#define OPENRGBPHILIPSHUESETTINGSENTRY_H
|
||||
|
||||
#include "ui_OpenRGBPhilipsHueSettingsEntry.h"
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class OpenRGBPhilipsHueSettingsEntry;
|
||||
}
|
||||
|
||||
class Ui::OpenRGBPhilipsHueSettingsEntry : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OpenRGBPhilipsHueSettingsEntry(QWidget *parent = nullptr);
|
||||
~OpenRGBPhilipsHueSettingsEntry();
|
||||
Ui::OpenRGBPhilipsHueSettingsEntryUi *ui;
|
||||
private slots:
|
||||
void on_UnpairButton_clicked();
|
||||
};
|
||||
|
||||
#endif // OPENRGBPHILIPSHUESETTINGSENTRY_H
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OpenRGBPhilipsHueSettingsEntryUi</class>
|
||||
<widget class="QWidget" name="OpenRGBPhilipsHueSettingsEntryUi">
|
||||
<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>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<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="3" column="0">
|
||||
<widget class="QLabel" name="EntertainmentLabel">
|
||||
<property name="text">
|
||||
<string>Entertainment Mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="UsernameLabel">
|
||||
<property name="text">
|
||||
<string>Username:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<widget class="QLabel" name="UsernameValue">
|
||||
<property name="text">
|
||||
<string>Username Value</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QLineEdit" name="MACEdit"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="ClientKeyLabel">
|
||||
<property name="text">
|
||||
<string>Client Key:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QCheckBox" name="EntertainmentCheckBox">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLineEdit" name="IPEdit"/>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="4">
|
||||
<widget class="QPushButton" name="UnpairButton">
|
||||
<property name="text">
|
||||
<string>Unpair Bridge</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="5" column="3">
|
||||
<widget class="QLabel" name="ClientKeyValue">
|
||||
<property name="text">
|
||||
<string>Client Key Value</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>IPEdit</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
#include "OpenRGBPhilipsHueSettingsPage.h"
|
||||
#include "ui_OpenRGBPhilipsHueSettingsPage.h"
|
||||
#include "ResourceManager.h"
|
||||
|
||||
using namespace Ui;
|
||||
|
||||
OpenRGBPhilipsHueSettingsPage::OpenRGBPhilipsHueSettingsPage(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::OpenRGBPhilipsHueSettingsPageUi)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
json hue_settings;
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Get Philips Hue settings |
|
||||
\*-------------------------------------------------*/
|
||||
hue_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("PhilipsHueDevices");
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| If the Hue settings contains bridges, process |
|
||||
\*-------------------------------------------------*/
|
||||
if(hue_settings.contains("bridges"))
|
||||
{
|
||||
for(unsigned int device_idx = 0; device_idx < hue_settings["bridges"].size(); device_idx++)
|
||||
{
|
||||
OpenRGBPhilipsHueSettingsEntry* entry = new OpenRGBPhilipsHueSettingsEntry;
|
||||
|
||||
if(hue_settings["bridges"][device_idx].contains("ip"))
|
||||
{
|
||||
entry->ui->IPEdit->setText(QString::fromStdString(hue_settings["bridges"][device_idx]["ip"]));
|
||||
}
|
||||
|
||||
if(hue_settings["bridges"][device_idx].contains("mac"))
|
||||
{
|
||||
entry->ui->MACEdit->setText(QString::fromStdString(hue_settings["bridges"][device_idx]["mac"]));
|
||||
}
|
||||
|
||||
if(hue_settings["bridges"][device_idx].contains("entertainment"))
|
||||
{
|
||||
entry->ui->EntertainmentCheckBox->setChecked(hue_settings["bridges"][device_idx]["entertainment"]);
|
||||
}
|
||||
|
||||
if(hue_settings["bridges"][device_idx].contains("username"))
|
||||
{
|
||||
entry->ui->UsernameValue->setText(QString::fromStdString(hue_settings["bridges"][device_idx]["username"]));
|
||||
}
|
||||
|
||||
if(hue_settings["bridges"][device_idx].contains("clientkey"))
|
||||
{
|
||||
entry->ui->ClientKeyValue->setText(QString::fromStdString(hue_settings["bridges"][device_idx]["clientkey"]));
|
||||
}
|
||||
|
||||
entries.push_back(entry);
|
||||
|
||||
QListWidgetItem* item = new QListWidgetItem;
|
||||
|
||||
item->setSizeHint(entry->sizeHint());
|
||||
|
||||
ui->PhilipsHueDeviceList->addItem(item);
|
||||
ui->PhilipsHueDeviceList->setItemWidget(item, entry);
|
||||
ui->PhilipsHueDeviceList->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OpenRGBPhilipsHueSettingsPage::~OpenRGBPhilipsHueSettingsPage()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void Ui::OpenRGBPhilipsHueSettingsPage::on_AddPhilipsHueDeviceButton_clicked()
|
||||
{
|
||||
OpenRGBPhilipsHueSettingsEntry* entry = new OpenRGBPhilipsHueSettingsEntry;
|
||||
entries.push_back(entry);
|
||||
|
||||
QListWidgetItem* item = new QListWidgetItem;
|
||||
|
||||
item->setSizeHint(entry->sizeHint());
|
||||
|
||||
ui->PhilipsHueDeviceList->addItem(item);
|
||||
ui->PhilipsHueDeviceList->setItemWidget(item, entry);
|
||||
ui->PhilipsHueDeviceList->show();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBPhilipsHueSettingsPage::on_RemovePhilipsHueDeviceButton_clicked()
|
||||
{
|
||||
int cur_row = ui->PhilipsHueDeviceList->currentRow();
|
||||
|
||||
if(cur_row < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QListWidgetItem* item = ui->PhilipsHueDeviceList->takeItem(cur_row);
|
||||
|
||||
ui->PhilipsHueDeviceList->removeItemWidget(item);
|
||||
delete item;
|
||||
|
||||
delete entries[cur_row];
|
||||
entries.erase(entries.begin() + cur_row);
|
||||
}
|
||||
|
||||
void Ui::OpenRGBPhilipsHueSettingsPage::on_SavePhilipsHueConfigurationButton_clicked()
|
||||
{
|
||||
json hue_settings;
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Get Philips Hue settings |
|
||||
\*-------------------------------------------------*/
|
||||
hue_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("PhilipsHueDevices");
|
||||
|
||||
hue_settings["bridges"].clear();
|
||||
|
||||
for(unsigned int device_idx = 0; device_idx < entries.size(); device_idx++)
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Required parameters |
|
||||
\*-------------------------------------------------*/
|
||||
hue_settings["bridges"][device_idx]["ip"] = entries[device_idx]->ui->IPEdit->text().toStdString();
|
||||
hue_settings["bridges"][device_idx]["mac"] = entries[device_idx]->ui->MACEdit->text().toStdString();
|
||||
hue_settings["bridges"][device_idx]["entertainment"] = entries[device_idx]->ui->EntertainmentCheckBox->isChecked();
|
||||
|
||||
if(entries[device_idx]->ui->UsernameValue->text() != "")
|
||||
{
|
||||
hue_settings["bridges"][device_idx]["username"] = entries[device_idx]->ui->UsernameValue->text().toStdString();
|
||||
}
|
||||
|
||||
if(entries[device_idx]->ui->ClientKeyValue->text() != "")
|
||||
{
|
||||
hue_settings["bridges"][device_idx]["clientkey"] = entries[device_idx]->ui->ClientKeyValue->text().toStdString();
|
||||
}
|
||||
}
|
||||
|
||||
ResourceManager::get()->GetSettingsManager()->SetSettings("PhilipsHueDevices", hue_settings);
|
||||
ResourceManager::get()->GetSettingsManager()->SaveSettings();
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef OPENRGBPHILIPSHUESETTINGSPAGE_H
|
||||
#define OPENRGBPHILIPSHUESETTINGSPAGE_H
|
||||
|
||||
#include "ui_OpenRGBPhilipsHueSettingsPage.h"
|
||||
#include <QWidget>
|
||||
|
||||
#include "OpenRGBPhilipsHueSettingsEntry.h"
|
||||
|
||||
namespace Ui {
|
||||
class OpenRGBPhilipsHueSettingsPage;
|
||||
}
|
||||
|
||||
class Ui::OpenRGBPhilipsHueSettingsPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OpenRGBPhilipsHueSettingsPage(QWidget *parent = nullptr);
|
||||
~OpenRGBPhilipsHueSettingsPage();
|
||||
|
||||
private slots:
|
||||
void on_AddPhilipsHueDeviceButton_clicked();
|
||||
|
||||
void on_RemovePhilipsHueDeviceButton_clicked();
|
||||
|
||||
void on_SavePhilipsHueConfigurationButton_clicked();
|
||||
|
||||
private:
|
||||
Ui::OpenRGBPhilipsHueSettingsPageUi *ui;
|
||||
std::vector<OpenRGBPhilipsHueSettingsEntry*> entries;
|
||||
|
||||
};
|
||||
|
||||
#endif // OPENRGBPHILIPSHUESETTINGSPAGE_H
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OpenRGBPhilipsHueSettingsPageUi</class>
|
||||
<widget class="QWidget" name="OpenRGBPhilipsHueSettingsPageUi">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="RemovePhilipsHueDeviceButton">
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="AddPhilipsHueDeviceButton">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<widget class="QListWidget" name="PhilipsHueDeviceList">
|
||||
<property name="verticalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="SavePhilipsHueConfigurationButton">
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QLabel" name="SyncLabel">
|
||||
<property name="text">
|
||||
<string>After adding a Hue entry and saving, restart OpenRGB and press the Sync button on your Hue bridge to pair it.</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Loading…
Add table
Add a link
Reference in a new issue