Add settings tab for QMK OpenRGB protocol devices
This commit is contained in:
parent
bfe8e7a997
commit
dc142f40d3
9 changed files with 351 additions and 0 deletions
|
|
@ -175,6 +175,8 @@ HEADERS +=
|
|||
qt/OpenRGBZoneResizeDialog.h \
|
||||
qt/OpenRGBE131SettingsPage/OpenRGBE131SettingsEntry.h \
|
||||
qt/OpenRGBE131SettingsPage/OpenRGBE131SettingsPage.h \
|
||||
qt/OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsEntry.h \
|
||||
qt/OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsPage.h \
|
||||
qt/OpenRGBSerialSettingsPage/OpenRGBSerialSettingsEntry.h \
|
||||
qt/OpenRGBSerialSettingsPage/OpenRGBSerialSettingsPage.h \
|
||||
serial_port/find_usb_serial_port.h \
|
||||
|
|
@ -484,6 +486,8 @@ SOURCES +=
|
|||
qt/hsv.cpp \
|
||||
qt/OpenRGBE131SettingsPage/OpenRGBE131SettingsEntry.cpp \
|
||||
qt/OpenRGBE131SettingsPage/OpenRGBE131SettingsPage.cpp \
|
||||
qt/OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsEntry.cpp \
|
||||
qt/OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsPage.cpp \
|
||||
qt/OpenRGBSerialSettingsPage/OpenRGBSerialSettingsEntry.cpp \
|
||||
qt/OpenRGBSerialSettingsPage/OpenRGBSerialSettingsPage.cpp \
|
||||
serial_port/serial_port.cpp \
|
||||
|
|
@ -813,6 +817,8 @@ FORMS +=
|
|||
qt/OpenRGBZoneResizeDialog.ui \
|
||||
qt/OpenRGBE131SettingsPage/OpenRGBE131SettingsEntry.ui \
|
||||
qt/OpenRGBE131SettingsPage/OpenRGBE131SettingsPage.ui \
|
||||
qt/OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsEntry.ui \
|
||||
qt/OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsPage.ui \
|
||||
qt/OpenRGBSerialSettingsPage/OpenRGBSerialSettingsEntry.ui \
|
||||
qt/OpenRGBSerialSettingsPage/OpenRGBSerialSettingsPage.ui \
|
||||
|
||||
|
|
|
|||
|
|
@ -412,6 +412,11 @@ OpenRGBDialog2::OpenRGBDialog2(QWidget *parent) : QMainWindow(parent), ui(new Op
|
|||
\*-----------------------------------------------------*/
|
||||
AddSerialSettingsPage();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Add the QMK OpenRGB Protocol settings page |
|
||||
\*-----------------------------------------------------*/
|
||||
AddQMKORGBSettingsPage();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Add the SMBus Tools page if enabled |
|
||||
\*-----------------------------------------------------*/
|
||||
|
|
@ -604,6 +609,35 @@ void OpenRGBDialog2::AddE131SettingsPage()
|
|||
ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel);
|
||||
}
|
||||
|
||||
void OpenRGBDialog2::AddQMKORGBSettingsPage()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Create the Settings page |
|
||||
\*-----------------------------------------------------*/
|
||||
QMKORGBSettingsPage = new OpenRGBQMKORGBSettingsPage();
|
||||
|
||||
ui->SettingsTabBar->addTab(QMKORGBSettingsPage, "");
|
||||
|
||||
QString SettingsLabelString = "<html><table><tr><td width='30'><img src='";
|
||||
SettingsLabelString += ":/keyboard";
|
||||
if(IsDarkTheme()) SettingsLabelString += "_dark";
|
||||
SettingsLabelString += ".png' height='16' width='16'></td><td>QMK OpenRGB Protocol</td></tr></table></html>";
|
||||
|
||||
QLabel *SettingsTabLabel = new QLabel();
|
||||
SettingsTabLabel->setText(SettingsLabelString);
|
||||
SettingsTabLabel->setIndent(20);
|
||||
if(IsDarkTheme())
|
||||
{
|
||||
SettingsTabLabel->setGeometry(0, 25, 200, 50);
|
||||
}
|
||||
else
|
||||
{
|
||||
SettingsTabLabel->setGeometry(0, 0, 200, 25);
|
||||
}
|
||||
|
||||
ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel);
|
||||
}
|
||||
|
||||
void OpenRGBDialog2::AddSerialSettingsPage()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include "OpenRGBSupportedDevicesPage.h"
|
||||
#include "OpenRGBSettingsPage.h"
|
||||
#include "OpenRGBE131SettingsPage/OpenRGBE131SettingsPage.h"
|
||||
#include "OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsPage.h"
|
||||
#include "OpenRGBSerialSettingsPage/OpenRGBSerialSettingsPage.h"
|
||||
#include "PluginManager.h"
|
||||
|
||||
|
|
@ -58,6 +59,7 @@ private:
|
|||
OpenRGBSupportedDevicesPage *SupportedPage;
|
||||
OpenRGBSettingsPage *SettingsPage;
|
||||
OpenRGBE131SettingsPage *E131SettingsPage;
|
||||
OpenRGBQMKORGBSettingsPage *QMKORGBSettingsPage;
|
||||
OpenRGBSerialSettingsPage *SerialSettingsPage;
|
||||
|
||||
bool ShowI2CTools = false;
|
||||
|
|
@ -77,6 +79,7 @@ private:
|
|||
void AddSupportedDevicesPage();
|
||||
void AddSettingsPage();
|
||||
void AddE131SettingsPage();
|
||||
void AddQMKORGBSettingsPage();
|
||||
void AddSerialSettingsPage();
|
||||
void AddPluginTab(PluginManager* plugin_manager,int plugin_index);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
#include "OpenRGBQMKORGBSettingsEntry.h"
|
||||
#include "ui_OpenRGBQMKORGBSettingsEntry.h"
|
||||
|
||||
using namespace Ui;
|
||||
|
||||
OpenRGBQMKORGBSettingsEntry::OpenRGBQMKORGBSettingsEntry(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::OpenRGBQMKORGBSettingsEntryUi)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
OpenRGBQMKORGBSettingsEntry::~OpenRGBQMKORGBSettingsEntry()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
21
qt/OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsEntry.h
Normal file
21
qt/OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsEntry.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef OPENRGBQMKORGBSETTINGSENTRY_H
|
||||
#define OPENRGBQMKORGBSETTINGSENTRY_H
|
||||
|
||||
#include "ui_OpenRGBQMKORGBSettingsEntry.h"
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class OpenRGBQMKORGBSettingsEntry;
|
||||
}
|
||||
|
||||
class Ui::OpenRGBQMKORGBSettingsEntry : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OpenRGBQMKORGBSettingsEntry(QWidget *parent = nullptr);
|
||||
~OpenRGBQMKORGBSettingsEntry();
|
||||
Ui::OpenRGBQMKORGBSettingsEntryUi *ui;
|
||||
};
|
||||
|
||||
#endif // OPENRGBQMKORGBSETTINGSENTRY_H
|
||||
71
qt/OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsEntry.ui
Normal file
71
qt/OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsEntry.ui
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OpenRGBQMKORGBSettingsEntryUi</class>
|
||||
<widget class="QWidget" name="OpenRGBQMKORGBSettingsEntryUi">
|
||||
<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>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="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>
|
||||
117
qt/OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsPage.cpp
Normal file
117
qt/OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsPage.cpp
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
#include "OpenRGBQMKORGBSettingsPage.h"
|
||||
#include "ui_OpenRGBQMKORGBSettingsPage.h"
|
||||
#include "ResourceManager.h"
|
||||
|
||||
using namespace Ui;
|
||||
|
||||
OpenRGBQMKORGBSettingsPage::OpenRGBQMKORGBSettingsPage(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::OpenRGBQMKORGBSettingsPageUi)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
json qmk_settings;
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Get QMKOpenRGB settings |
|
||||
\*-------------------------------------------------*/
|
||||
qmk_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("QMKOpenRGBDevices");
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| If the LEDStrip settings contains devices, process|
|
||||
\*-------------------------------------------------*/
|
||||
if(qmk_settings.contains("devices"))
|
||||
{
|
||||
for(unsigned int device_idx = 0; device_idx < qmk_settings["devices"].size(); device_idx++)
|
||||
{
|
||||
OpenRGBQMKORGBSettingsEntry* entry = new OpenRGBQMKORGBSettingsEntry;
|
||||
|
||||
if(qmk_settings["devices"][device_idx].contains("name"))
|
||||
{
|
||||
entry->ui->NameEdit->setText(QString::fromStdString(qmk_settings["devices"][device_idx]["name"]));
|
||||
}
|
||||
|
||||
if(qmk_settings["devices"][device_idx].contains("usb_vid"))
|
||||
{
|
||||
entry->ui->USBVIDEdit->setText(QString::fromStdString(qmk_settings["devices"][device_idx]["usb_vid"]));
|
||||
}
|
||||
|
||||
if(qmk_settings["devices"][device_idx].contains("usb_pid"))
|
||||
{
|
||||
entry->ui->USBPIDEdit->setText(QString::fromStdString(qmk_settings["devices"][device_idx]["usb_pid"]));
|
||||
}
|
||||
|
||||
entries.push_back(entry);
|
||||
|
||||
QListWidgetItem* item = new QListWidgetItem;
|
||||
|
||||
item->setSizeHint(entry->sizeHint());
|
||||
|
||||
ui->QMKORGBDeviceList->addItem(item);
|
||||
ui->QMKORGBDeviceList->setItemWidget(item, entry);
|
||||
ui->QMKORGBDeviceList->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OpenRGBQMKORGBSettingsPage::~OpenRGBQMKORGBSettingsPage()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void Ui::OpenRGBQMKORGBSettingsPage::on_AddQMKORGBDeviceButton_clicked()
|
||||
{
|
||||
OpenRGBQMKORGBSettingsEntry* entry = new OpenRGBQMKORGBSettingsEntry;
|
||||
entries.push_back(entry);
|
||||
|
||||
QListWidgetItem* item = new QListWidgetItem;
|
||||
|
||||
item->setSizeHint(entry->sizeHint());
|
||||
|
||||
ui->QMKORGBDeviceList->addItem(item);
|
||||
ui->QMKORGBDeviceList->setItemWidget(item, entry);
|
||||
ui->QMKORGBDeviceList->show();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBQMKORGBSettingsPage::on_RemoveQMKORGBDeviceButton_clicked()
|
||||
{
|
||||
int cur_row = ui->QMKORGBDeviceList->currentRow();
|
||||
|
||||
if(cur_row < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QListWidgetItem* item = ui->QMKORGBDeviceList->takeItem(cur_row);
|
||||
|
||||
ui->QMKORGBDeviceList->removeItemWidget(item);
|
||||
delete item;
|
||||
|
||||
delete entries[cur_row];
|
||||
entries.erase(entries.begin() + cur_row);
|
||||
}
|
||||
|
||||
void Ui::OpenRGBQMKORGBSettingsPage::on_SaveQMKORGBConfigurationButton_clicked()
|
||||
{
|
||||
json qmk_settings;
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Get QMKOpenRGB settings |
|
||||
\*-------------------------------------------------*/
|
||||
qmk_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("QMKOpenRGBDevices");
|
||||
|
||||
qmk_settings["devices"].clear();
|
||||
|
||||
for(unsigned int device_idx = 0; device_idx < entries.size(); device_idx++)
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Required parameters |
|
||||
\*-------------------------------------------------*/
|
||||
qmk_settings["devices"][device_idx]["name"] = entries[device_idx]->ui->NameEdit->text().toStdString();
|
||||
qmk_settings["devices"][device_idx]["usb_vid"] = entries[device_idx]->ui->USBVIDEdit->text().toStdString();
|
||||
qmk_settings["devices"][device_idx]["usb_pid"] = entries[device_idx]->ui->USBPIDEdit->text().toStdString();
|
||||
}
|
||||
|
||||
ResourceManager::get()->GetSettingsManager()->SetSettings("QMKOpenRGBDevices", qmk_settings);
|
||||
ResourceManager::get()->GetSettingsManager()->SaveSettings();
|
||||
}
|
||||
34
qt/OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsPage.h
Normal file
34
qt/OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsPage.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef OPENRGBQMKORGBSETTINGSPAGE_H
|
||||
#define OPENRGBQMKORGBSETTINGSPAGE_H
|
||||
|
||||
#include "ui_OpenRGBQMKORGBSettingsPage.h"
|
||||
#include <QWidget>
|
||||
|
||||
#include "OpenRGBQMKORGBSettingsEntry.h"
|
||||
|
||||
namespace Ui {
|
||||
class OpenRGBQMKORGBSettingsPage;
|
||||
}
|
||||
|
||||
class Ui::OpenRGBQMKORGBSettingsPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OpenRGBQMKORGBSettingsPage(QWidget *parent = nullptr);
|
||||
~OpenRGBQMKORGBSettingsPage();
|
||||
|
||||
private slots:
|
||||
void on_AddQMKORGBDeviceButton_clicked();
|
||||
|
||||
void on_RemoveQMKORGBDeviceButton_clicked();
|
||||
|
||||
void on_SaveQMKORGBConfigurationButton_clicked();
|
||||
|
||||
private:
|
||||
Ui::OpenRGBQMKORGBSettingsPageUi *ui;
|
||||
std::vector<OpenRGBQMKORGBSettingsEntry*> entries;
|
||||
|
||||
};
|
||||
|
||||
#endif // OPENRGBQMKORGBSETTINGSPAGE_H
|
||||
49
qt/OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsPage.ui
Normal file
49
qt/OpenRGBQMKORGBSettingsPage/OpenRGBQMKORGBSettingsPage.ui
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OpenRGBQMKORGBSettingsPageUi</class>
|
||||
<widget class="QWidget" name="OpenRGBQMKORGBSettingsPageUi">
|
||||
<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="1" column="0">
|
||||
<widget class="QPushButton" name="AddQMKORGBDeviceButton">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="RemoveQMKORGBDeviceButton">
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="SaveQMKORGBConfigurationButton">
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QListWidget" name="QMKORGBDeviceList">
|
||||
<property name="verticalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Loading…
Add table
Add a link
Reference in a new issue