Add OpenRGB client support to GUI
This commit is contained in:
parent
7d2877a8e9
commit
4c6429ae76
7 changed files with 521 additions and 88 deletions
|
|
@ -89,6 +89,7 @@ HEADERS += \
|
|||
NetworkProtocol.h \
|
||||
NetworkServer.h \
|
||||
ProfileManager.h \
|
||||
qt/OpenRGBClientInfoPage.h \
|
||||
qt/OpenRGBDeviceInfoPage.h \
|
||||
qt/OpenRGBDevicePage.h \
|
||||
qt/OpenRGBDialog.h \
|
||||
|
|
@ -194,6 +195,7 @@ SOURCES += \
|
|||
NetworkClient.cpp \
|
||||
NetworkServer.cpp \
|
||||
ProfileManager.cpp \
|
||||
qt/OpenRGBClientInfoPage.cpp \
|
||||
qt/OpenRGBDeviceInfoPage.cpp \
|
||||
qt/OpenRGBDevicePage.cpp \
|
||||
qt/OpenRGBDialog.cpp \
|
||||
|
|
@ -327,7 +329,8 @@ SOURCES += \
|
|||
RESOURCES += \
|
||||
qt/resources.qrc
|
||||
|
||||
FORMS += \
|
||||
FORMS += \
|
||||
qt/OpenRGBClientInfoPage.ui \
|
||||
qt/OpenRGBDeviceInfoPage.ui \
|
||||
qt/OpenRGBDevicePage.ui \
|
||||
qt/OpenRGBDialog.ui \
|
||||
|
|
|
|||
6
main.cpp
6
main.cpp
|
|
@ -70,7 +70,7 @@ int main(int argc, char* argv[])
|
|||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QApplication a(argc, argv);
|
||||
|
||||
Ui::OpenRGBDialog2 dlg(busses, rgb_controllers, &profile_manager, &server);
|
||||
Ui::OpenRGBDialog2 dlg(busses, rgb_controllers, &profile_manager);
|
||||
|
||||
if(ret_flags & RET_FLAG_I2C_TOOLS)
|
||||
{
|
||||
|
|
@ -80,13 +80,13 @@ int main(int argc, char* argv[])
|
|||
//TODO:
|
||||
// Determine whether or not to add server tab
|
||||
// If application is open in client mode, do not show server tab
|
||||
dlg.AddServerTab();
|
||||
dlg.AddServerTab(&server);
|
||||
|
||||
//TODO:
|
||||
// Determine whether or not to add client tab
|
||||
// Client tab should probably always show
|
||||
// Implement client tab
|
||||
//dlg.AddClientTab();
|
||||
dlg.AddClientTab();
|
||||
|
||||
if(ret_flags & RET_FLAG_START_MINIMIZED)
|
||||
{
|
||||
|
|
|
|||
219
qt/OpenRGBClientInfoPage.cpp
Normal file
219
qt/OpenRGBClientInfoPage.cpp
Normal file
|
|
@ -0,0 +1,219 @@
|
|||
#include <QSignalMapper>
|
||||
#include "OpenRGBClientInfoPage.h"
|
||||
|
||||
using namespace Ui;
|
||||
|
||||
static void UpdateInfoCallback(void * this_ptr)
|
||||
{
|
||||
OpenRGBClientInfoPage * this_obj = (OpenRGBClientInfoPage *)this_ptr;
|
||||
|
||||
QMetaObject::invokeMethod(this_obj, "UpdateInfo", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
class NetworkClientPointer : public QObject
|
||||
{
|
||||
public:
|
||||
NetworkClient * net_client;
|
||||
};
|
||||
|
||||
OpenRGBClientInfoPage::OpenRGBClientInfoPage(std::vector<RGBController *>& control, QWidget *parent) :
|
||||
QFrame(parent),
|
||||
controllers(control),
|
||||
ui(new Ui::OpenRGBClientInfoPageUi)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Set initial values for GUI fields |
|
||||
\*-----------------------------------------------------*/
|
||||
ui->setupUi(this);
|
||||
ui->ClientIPValue->setText("127.0.0.1");
|
||||
ui->ClientPortValue->setText(QString::number(OPENRGB_SDK_PORT));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Update the information view |
|
||||
\*-----------------------------------------------------*/
|
||||
UpdateInfo();
|
||||
}
|
||||
|
||||
OpenRGBClientInfoPage::~OpenRGBClientInfoPage()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OpenRGBClientInfoPage::AddClient(NetworkClient* new_client)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Add a new client to the list, register the callback, |
|
||||
| and update the information view if the pointer is |
|
||||
| valid |
|
||||
\*-----------------------------------------------------*/
|
||||
if(new_client != NULL)
|
||||
{
|
||||
rgb_clients.push_back(new_client);
|
||||
new_client->RegisterClientInfoChangeCallback(UpdateInfoCallback, this);
|
||||
|
||||
UpdateInfo();
|
||||
}
|
||||
}
|
||||
|
||||
void OpenRGBClientInfoPage::UpdateInfo()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Clear the tree view before recreating its contents |
|
||||
\*-----------------------------------------------------*/
|
||||
ui->ClientTree->clear();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up the tree view header |
|
||||
\*-----------------------------------------------------*/
|
||||
ui->ClientTree->setColumnCount(2);
|
||||
ui->ClientTree->header()->setStretchLastSection(false);
|
||||
ui->ClientTree->header()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
ui->ClientTree->setColumnWidth(1, 100);
|
||||
ui->ClientTree->setHeaderLabels(QStringList() << "Connected Clients" << "");
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up a signal mapper to handle disconnect buttons |
|
||||
\*-----------------------------------------------------*/
|
||||
QSignalMapper* signalMapper = new QSignalMapper(this);
|
||||
connect(signalMapper, SIGNAL(mapped(QObject *)), this, SLOT(on_ClientDisconnectButton_clicked(QObject *)));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Loop through all clients in list and display them |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int client_idx = 0; client_idx < rgb_clients.size(); client_idx++)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Create the top level tree widget items and display the|
|
||||
| client IP addresses in them |
|
||||
\*-----------------------------------------------------*/
|
||||
QTreeWidgetItem* new_top_item = new QTreeWidgetItem(ui->ClientTree);
|
||||
new_top_item->setText(0, QString::fromStdString(rgb_clients[client_idx]->GetIP()));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Create the disconnect buttons and connect them to the |
|
||||
| signal mapper |
|
||||
\*-----------------------------------------------------*/
|
||||
QPushButton* new_button = new QPushButton( "Disconnect" );
|
||||
ui->ClientTree->setItemWidget(new_top_item, 1, new_button);
|
||||
|
||||
connect(new_button, SIGNAL(clicked()), signalMapper, SLOT(map()));
|
||||
|
||||
NetworkClientPointer * new_arg = new NetworkClientPointer();
|
||||
new_arg->net_client = rgb_clients[client_idx];
|
||||
|
||||
signalMapper->setMapping(new_button, new_arg);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Add child items for each device in the client |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int dev_idx = 0; dev_idx < rgb_clients[client_idx]->server_controllers.size(); dev_idx++)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Create child tree widget items and display the device |
|
||||
| names in them |
|
||||
\*-----------------------------------------------------*/
|
||||
QTreeWidgetItem* new_item = new QTreeWidgetItem(new_top_item);
|
||||
new_item->setText(0, QString::fromStdString(rgb_clients[client_idx]->server_controllers[dev_idx]->name));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Add child items for each zone in the device |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int zone_idx = 0; zone_idx < rgb_clients[client_idx]->server_controllers[dev_idx]->zones.size(); zone_idx++)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Create child tree widget items and display the zone |
|
||||
| names, number of LEDs, and types in them |
|
||||
\*-----------------------------------------------------*/
|
||||
QTreeWidgetItem* new_child = new QTreeWidgetItem();
|
||||
|
||||
std::string zone_str = rgb_clients[client_idx]->server_controllers[dev_idx]->zones[zone_idx].name + ", ";
|
||||
zone_str.append(std::to_string(rgb_clients[client_idx]->server_controllers[dev_idx]->zones[zone_idx].leds_count));
|
||||
zone_str.append(" LEDs, ");
|
||||
|
||||
switch(rgb_clients[client_idx]->server_controllers[dev_idx]->zones[zone_idx].type)
|
||||
{
|
||||
case ZONE_TYPE_SINGLE:
|
||||
zone_str.append("Single");
|
||||
break;
|
||||
|
||||
case ZONE_TYPE_LINEAR:
|
||||
zone_str.append("Linear");
|
||||
break;
|
||||
|
||||
case ZONE_TYPE_MATRIX:
|
||||
zone_str.append("Matrix");
|
||||
break;
|
||||
}
|
||||
|
||||
new_child->setText(0, QString::fromStdString(zone_str));
|
||||
|
||||
new_item->addChild(new_child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Emit client information updated signal |
|
||||
\*-----------------------------------------------------*/
|
||||
emit ClientListUpdated();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBClientInfoPage::on_ClientConnectButton_clicked()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Read the new client IP and Port values from the UI |
|
||||
\*-----------------------------------------------------*/
|
||||
unsigned short port = std::stoi(ui->ClientPortValue->text().toStdString());
|
||||
std::string ip = ui->ClientIPValue->text().toStdString();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Create a new client and set name, IP, and port values |
|
||||
\*-----------------------------------------------------*/
|
||||
NetworkClient * rgb_client = new NetworkClient(controllers);
|
||||
|
||||
std::string titleString = "OpenRGB ";
|
||||
titleString.append(VERSION_STRING);
|
||||
|
||||
rgb_client->SetIP(ip.c_str());
|
||||
rgb_client->SetName(titleString.c_str());
|
||||
rgb_client->SetPort(port);
|
||||
|
||||
rgb_client->StartClient();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Add new client to list and register update callback |
|
||||
\*-----------------------------------------------------*/
|
||||
rgb_clients.push_back(rgb_client);
|
||||
|
||||
rgb_client->RegisterClientInfoChangeCallback(UpdateInfoCallback, this);
|
||||
}
|
||||
|
||||
void Ui::OpenRGBClientInfoPage::on_ClientDisconnectButton_clicked(QObject * arg)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Get the pointer to the disconnecting client from args |
|
||||
\*-----------------------------------------------------*/
|
||||
NetworkClient * disconnect_client = ((NetworkClientPointer *)arg)->net_client;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Stop the disconnecting client |
|
||||
\*-----------------------------------------------------*/
|
||||
disconnect_client->StopClient();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Remove disconnecting client from list |
|
||||
\*-----------------------------------------------------*/
|
||||
for(unsigned int client_idx = 0; client_idx < rgb_clients.size(); client_idx++)
|
||||
{
|
||||
if(disconnect_client == rgb_clients[client_idx])
|
||||
{
|
||||
rgb_clients.erase(rgb_clients.begin() + client_idx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Delete the disconnecting client |
|
||||
\*-----------------------------------------------------*/
|
||||
delete disconnect_client;
|
||||
}
|
||||
40
qt/OpenRGBClientInfoPage.h
Normal file
40
qt/OpenRGBClientInfoPage.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#ifndef OPENRGBCLIENTINFOPAGE_H
|
||||
#define OPENRGBCLIENTINFOPAGE_H
|
||||
|
||||
#include <QFrame>
|
||||
#include "RGBController.h"
|
||||
#include "ui_OpenRGBClientInfoPage.h"
|
||||
#include "NetworkClient.h"
|
||||
|
||||
namespace Ui {
|
||||
class OpenRGBClientInfoPage;
|
||||
}
|
||||
|
||||
class Ui::OpenRGBClientInfoPage : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OpenRGBClientInfoPage(std::vector<RGBController *>& control, QWidget *parent = nullptr);
|
||||
~OpenRGBClientInfoPage();
|
||||
|
||||
void AddClient(NetworkClient* new_client);
|
||||
|
||||
public slots:
|
||||
void UpdateInfo();
|
||||
|
||||
private slots:
|
||||
void on_ClientConnectButton_clicked();
|
||||
void on_ClientDisconnectButton_clicked(QObject * arg);
|
||||
|
||||
private:
|
||||
Ui::OpenRGBClientInfoPageUi *ui;
|
||||
|
||||
std::vector<RGBController *>& controllers;
|
||||
std::vector<NetworkClient*> rgb_clients;
|
||||
|
||||
signals:
|
||||
void ClientListUpdated();
|
||||
};
|
||||
|
||||
#endif // OPENRGBCLIENTINFOPAGE_H
|
||||
75
qt/OpenRGBClientInfoPage.ui
Normal file
75
qt/OpenRGBClientInfoPage.ui
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OpenRGBClientInfoPageUi</class>
|
||||
<widget class="QFrame" name="OpenRGBClientInfoPageUi">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>664</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Frame</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="6">
|
||||
<widget class="QLineEdit" name="ClientPortValue">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<widget class="QLabel" name="ClientPortLabel">
|
||||
<property name="text">
|
||||
<string>Port:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="7">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="8">
|
||||
<widget class="QPushButton" name="ClientConnectButton">
|
||||
<property name="text">
|
||||
<string>Connect</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QLineEdit" name="ClientIPValue"/>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="ClientIPLabel">
|
||||
<property name="text">
|
||||
<string>IP:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3" colspan="6">
|
||||
<widget class="QTreeWidget" name="ClientTree">
|
||||
<property name="columnCount">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
@ -2,8 +2,6 @@
|
|||
#include "OpenRGBDevicePage.h"
|
||||
#include "OpenRGBDeviceInfoPage.h"
|
||||
#include "OpenRGBServerInfoPage.h"
|
||||
#include "OpenRGBSoftwareInfoPage.h"
|
||||
#include "OpenRGBSystemInfoPage.h"
|
||||
#include "OpenRGBProfileSaveDialog.h"
|
||||
#include <QLabel>
|
||||
#include <QTabBar>
|
||||
|
|
@ -13,6 +11,10 @@ using namespace Ui;
|
|||
|
||||
static QString GetIconString(device_type type)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Return the icon filename string for the given device |
|
||||
| type value |
|
||||
\*-----------------------------------------------------*/
|
||||
switch(type)
|
||||
{
|
||||
case DEVICE_TYPE_MOTHERBOARD:
|
||||
|
|
@ -51,13 +53,23 @@ static QString GetIconString(device_type type)
|
|||
}
|
||||
}
|
||||
|
||||
OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vector<RGBController *>& control, ProfileManager* manager, NetworkServer* server, QWidget *parent) : QMainWindow(parent), busses(bus), controllers(control), profile_manager(manager), network_server(server), ui(new OpenRGBDialog2Ui)
|
||||
OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vector<RGBController *>& control, ProfileManager* manager, QWidget *parent) : QMainWindow(parent), busses(bus), controllers(control), profile_manager(manager), ui(new OpenRGBDialog2Ui)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set window icon |
|
||||
\*-----------------------------------------------------*/
|
||||
QIcon logo(":OpenRGB.png");
|
||||
setWindowIcon(logo);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Initialize page pointers |
|
||||
\*-----------------------------------------------------*/
|
||||
ClientInfoPage = NULL;
|
||||
SMBusToolsPage = NULL;
|
||||
SoftInfoPage = NULL;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up tray icon menu |
|
||||
\*-----------------------------------------------------*/
|
||||
|
|
@ -118,16 +130,134 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vec
|
|||
trayIcon->setContextMenu(trayIconMenu);
|
||||
trayIcon->show();
|
||||
|
||||
RefreshProfileList();
|
||||
/*-----------------------------------------------------*\
|
||||
| Update the profile list |
|
||||
\*-----------------------------------------------------*/
|
||||
UpdateProfileList();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Update the device list |
|
||||
\*-----------------------------------------------------*/
|
||||
UpdateDevicesList();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Create the Software Information page |
|
||||
\*-----------------------------------------------------*/
|
||||
SoftInfoPage = new OpenRGBSoftwareInfoPage();
|
||||
ui->InformationTabBar->addTab(SoftInfoPage, "");
|
||||
|
||||
QString SoftwareLabelString = "<html><table><tr><td width='30'><img src='";
|
||||
SoftwareLabelString += ":/software.png";
|
||||
SoftwareLabelString += "' height='16' width='16'></td><td>Software</td></tr></table></html>";
|
||||
|
||||
QLabel *SoftwareTabLabel = new QLabel();
|
||||
SoftwareTabLabel->setText(SoftwareLabelString);
|
||||
SoftwareTabLabel->setIndent(20);
|
||||
SoftwareTabLabel->setGeometry(0, 0, 200, 20);
|
||||
|
||||
ui->InformationTabBar->tabBar()->setTabButton(ui->InformationTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SoftwareTabLabel);
|
||||
}
|
||||
|
||||
OpenRGBDialog2::~OpenRGBDialog2()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void OpenRGBDialog2::AddI2CToolsPage()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Create the I2C Tools page if it doesn't exist yet |
|
||||
\*-----------------------------------------------------*/
|
||||
if(SMBusToolsPage == NULL)
|
||||
{
|
||||
SMBusToolsPage = new OpenRGBSystemInfoPage(busses);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Create the I2C Tools tab in the Information bar |
|
||||
\*-----------------------------------------------------*/
|
||||
ui->InformationTabBar->addTab(SMBusToolsPage, "");
|
||||
|
||||
QString SMBusToolsLabelString = "<html><table><tr><td width='30'><img src='";
|
||||
SMBusToolsLabelString += ":/tools.png";
|
||||
SMBusToolsLabelString += "' height='16' width='16'></td><td>SMBus Tools</td></tr></table></html>";
|
||||
|
||||
QLabel *SMBusToolsTabLabel = new QLabel();
|
||||
SMBusToolsTabLabel->setText(SMBusToolsLabelString);
|
||||
SMBusToolsTabLabel->setIndent(20);
|
||||
SMBusToolsTabLabel->setGeometry(0, 0, 200, 20);
|
||||
|
||||
ui->InformationTabBar->tabBar()->setTabButton(ui->InformationTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SMBusToolsTabLabel);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenRGBDialog2::AddClientTab()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Add client information tab if it doesn't exist yet |
|
||||
\*-----------------------------------------------------*/
|
||||
if(ClientInfoPage == NULL)
|
||||
{
|
||||
ClientInfoPage = new OpenRGBClientInfoPage(controllers);
|
||||
ui->MainTabBar->addTab(ClientInfoPage, "SDK Client");
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Connect the page's Set All button to the Set All slot |
|
||||
\*-----------------------------------------------------*/
|
||||
connect(ClientInfoPage,
|
||||
SIGNAL(ClientListUpdated()),
|
||||
this,
|
||||
SLOT(on_ClientListUpdated()));
|
||||
}
|
||||
}
|
||||
|
||||
void OpenRGBDialog2::AddClient(NetworkClient* new_client)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Add a client to the client information page |
|
||||
\*-----------------------------------------------------*/
|
||||
if(ClientInfoPage != NULL)
|
||||
{
|
||||
ClientInfoPage->AddClient(new_client);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenRGBDialog2::AddServerTab(NetworkServer* network_server)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Add server information tab if there is a server |
|
||||
\*-----------------------------------------------------*/
|
||||
if(network_server != NULL)
|
||||
{
|
||||
OpenRGBServerInfoPage *ServerInfoPage = new OpenRGBServerInfoPage(network_server);
|
||||
ui->MainTabBar->addTab(ServerInfoPage, "SDK Server");
|
||||
}
|
||||
}
|
||||
|
||||
void OpenRGBDialog2::ClearDevicesList()
|
||||
{
|
||||
for(int tab_idx = 0; tab_idx < ui->InformationTabBar->count(); tab_idx++)
|
||||
{
|
||||
delete ui->DevicesTabBar->widget(tab_idx);
|
||||
}
|
||||
ui->DevicesTabBar->clear();
|
||||
|
||||
for(int tab_idx = 0; tab_idx < ui->InformationTabBar->count(); tab_idx++)
|
||||
{
|
||||
delete ui->InformationTabBar->widget(tab_idx);
|
||||
}
|
||||
ui->InformationTabBar->clear();
|
||||
}
|
||||
|
||||
void OpenRGBDialog2::UpdateDevicesList()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up list of devices |
|
||||
\*-----------------------------------------------------*/
|
||||
QTabBar *DevicesTabBar = ui->DevicesTabBar->tabBar();
|
||||
|
||||
for(std::size_t dev_idx = 0; dev_idx < control.size(); dev_idx++)
|
||||
for(std::size_t dev_idx = 0; dev_idx < controllers.size(); dev_idx++)
|
||||
{
|
||||
OpenRGBDevicePage *NewPage = new OpenRGBDevicePage(control[dev_idx]);
|
||||
OpenRGBDevicePage *NewPage = new OpenRGBDevicePage(controllers[dev_idx]);
|
||||
ui->DevicesTabBar->addTab(NewPage, "");
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
|
|
@ -152,8 +282,8 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vec
|
|||
| type and append device name string. |
|
||||
\*-----------------------------------------------------*/
|
||||
QString NewLabelString = "<html><table><tr><td width='30'><img src=':/";
|
||||
NewLabelString += GetIconString(control[dev_idx]->type);
|
||||
NewLabelString += "' height='16' width='16'></td><td>" + QString::fromStdString(control[dev_idx]->name) + "</td></tr></table></html>";
|
||||
NewLabelString += GetIconString(controllers[dev_idx]->type);
|
||||
NewLabelString += "' height='16' width='16'></td><td>" + QString::fromStdString(controllers[dev_idx]->name) + "</td></tr></table></html>";
|
||||
|
||||
QLabel *NewTabLabel = new QLabel();
|
||||
NewTabLabel->setText(NewLabelString);
|
||||
|
|
@ -168,9 +298,9 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vec
|
|||
\*-----------------------------------------------------*/
|
||||
QTabBar *InformationTabBar = ui->InformationTabBar->tabBar();
|
||||
|
||||
for(std::size_t dev_idx = 0; dev_idx < control.size(); dev_idx++)
|
||||
for(std::size_t dev_idx = 0; dev_idx < controllers.size(); dev_idx++)
|
||||
{
|
||||
OpenRGBDeviceInfoPage *NewPage = new OpenRGBDeviceInfoPage(control[dev_idx]);
|
||||
OpenRGBDeviceInfoPage *NewPage = new OpenRGBDeviceInfoPage(controllers[dev_idx]);
|
||||
ui->InformationTabBar->addTab(NewPage, "");
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
|
|
@ -179,8 +309,8 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vec
|
|||
| type and append device name string. |
|
||||
\*-----------------------------------------------------*/
|
||||
QString NewLabelString = "<html><table><tr><td width='30'><img src=':/";
|
||||
NewLabelString += GetIconString(control[dev_idx]->type);
|
||||
NewLabelString += "' height='16' width='16'></td><td>" + QString::fromStdString(control[dev_idx]->name) + "</td></tr></table></html>";
|
||||
NewLabelString += GetIconString(controllers[dev_idx]->type);
|
||||
NewLabelString += "' height='16' width='16'></td><td>" + QString::fromStdString(controllers[dev_idx]->name) + "</td></tr></table></html>";
|
||||
|
||||
QLabel *NewTabLabel = new QLabel();
|
||||
NewTabLabel->setText(NewLabelString);
|
||||
|
|
@ -189,72 +319,9 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vec
|
|||
|
||||
InformationTabBar->setTabButton(dev_idx, QTabBar::LeftSide, NewTabLabel);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Create the Software Information page |
|
||||
\*-----------------------------------------------------*/
|
||||
OpenRGBSoftwareInfoPage *SoftInfoPage = new OpenRGBSoftwareInfoPage();
|
||||
ui->InformationTabBar->addTab(SoftInfoPage, "");
|
||||
|
||||
QString SoftwareLabelString = "<html><table><tr><td width='30'><img src='";
|
||||
SoftwareLabelString += ":/software.png";
|
||||
SoftwareLabelString += "' height='16' width='16'></td><td>Software</td></tr></table></html>";
|
||||
|
||||
QLabel *SoftwareTabLabel = new QLabel();
|
||||
SoftwareTabLabel->setText(SoftwareLabelString);
|
||||
SoftwareTabLabel->setIndent(20);
|
||||
SoftwareTabLabel->setGeometry(0, 0, 200, 20);
|
||||
|
||||
InformationTabBar->setTabButton(ui->InformationTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SoftwareTabLabel);
|
||||
}
|
||||
|
||||
OpenRGBDialog2::~OpenRGBDialog2()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void OpenRGBDialog2::AddI2CToolsPage()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Create the I2C Tools page |
|
||||
\*-----------------------------------------------------*/
|
||||
OpenRGBSystemInfoPage *SMBusToolsPage = new OpenRGBSystemInfoPage(busses);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Create the I2C Tools tab in the Information bar |
|
||||
\*-----------------------------------------------------*/
|
||||
ui->InformationTabBar->addTab(SMBusToolsPage, "");
|
||||
|
||||
QString SMBusToolsLabelString = "<html><table><tr><td width='30'><img src='";
|
||||
SMBusToolsLabelString += ":/tools.png";
|
||||
SMBusToolsLabelString += "' height='16' width='16'></td><td>SMBus Tools</td></tr></table></html>";
|
||||
|
||||
QLabel *SMBusToolsTabLabel = new QLabel();
|
||||
SMBusToolsTabLabel->setText(SMBusToolsLabelString);
|
||||
SMBusToolsTabLabel->setIndent(20);
|
||||
SMBusToolsTabLabel->setGeometry(0, 0, 200, 20);
|
||||
|
||||
ui->InformationTabBar->tabBar()->setTabButton(ui->InformationTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SMBusToolsTabLabel);
|
||||
}
|
||||
|
||||
void OpenRGBDialog2::AddServerTab()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Add server information tab if there is a server |
|
||||
\*-----------------------------------------------------*/
|
||||
if(network_server != NULL)
|
||||
{
|
||||
OpenRGBServerInfoPage *ServerInfoPage = new OpenRGBServerInfoPage(network_server);
|
||||
ui->MainTabBar->addTab(ServerInfoPage, "SDK Server");
|
||||
}
|
||||
}
|
||||
|
||||
void OpenRGBDialog2::show()
|
||||
{
|
||||
QMainWindow::show();
|
||||
}
|
||||
|
||||
void OpenRGBDialog2::RefreshProfileList()
|
||||
void OpenRGBDialog2::UpdateProfileList()
|
||||
{
|
||||
if(profile_manager != NULL)
|
||||
{
|
||||
|
|
@ -328,6 +395,12 @@ void OpenRGBDialog2::on_QuickWhite()
|
|||
on_SetAllDevices(0xFF, 0xFF, 0xFF);
|
||||
}
|
||||
|
||||
void OpenRGBDialog2::on_ClientListUpdated()
|
||||
{
|
||||
ClearDevicesList();
|
||||
UpdateDevicesList();
|
||||
}
|
||||
|
||||
void OpenRGBDialog2::on_SetAllDevices(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
for(int device = 0; device < ui->DevicesTabBar->count(); device++)
|
||||
|
|
@ -403,7 +476,7 @@ void Ui::OpenRGBDialog2::on_ButtonSaveProfile_clicked()
|
|||
\*---------------------------------------------------------*/
|
||||
if(profile_manager->SaveProfile(filename))
|
||||
{
|
||||
RefreshProfileList();
|
||||
UpdateProfileList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -452,7 +525,7 @@ void Ui::OpenRGBDialog2::on_ButtonDeleteProfile_clicked()
|
|||
{
|
||||
profile_manager->DeleteProfile(profile_name);
|
||||
|
||||
RefreshProfileList();
|
||||
UpdateProfileList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,15 @@
|
|||
|
||||
#include "ui_OpenRGBDialog2.h"
|
||||
|
||||
#include "OpenRGBClientInfoPage.h"
|
||||
#include "OpenRGBSoftwareInfoPage.h"
|
||||
#include "OpenRGBSystemInfoPage.h"
|
||||
|
||||
#include <vector>
|
||||
#include "i2c_smbus.h"
|
||||
#include "RGBController.h"
|
||||
#include "ProfileManager.h"
|
||||
#include "NetworkClient.h"
|
||||
#include "NetworkServer.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
|
|
@ -24,26 +29,43 @@ class Ui::OpenRGBDialog2 : public QMainWindow
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vector<RGBController *>& control, ProfileManager* manager, NetworkServer* server, QWidget *parent = 0);
|
||||
explicit OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vector<RGBController *>& control, ProfileManager* manager, QWidget *parent = 0);
|
||||
~OpenRGBDialog2();
|
||||
|
||||
void AddClient(NetworkClient* new_client);
|
||||
void AddClientTab();
|
||||
void AddI2CToolsPage();
|
||||
void AddServerTab();
|
||||
void AddServerTab(NetworkServer* network_server);
|
||||
|
||||
void show();
|
||||
void setMode(unsigned char mode_val);
|
||||
|
||||
protected:
|
||||
std::vector<i2c_smbus_interface *>& busses;
|
||||
std::vector<RGBController *>& controllers;
|
||||
ProfileManager* profile_manager;
|
||||
NetworkServer* network_server;
|
||||
|
||||
private:
|
||||
Ui::OpenRGBDialog2Ui *ui;
|
||||
/*-------------------------------------*\
|
||||
| Page pointers |
|
||||
\*-------------------------------------*/
|
||||
OpenRGBClientInfoPage *ClientInfoPage;
|
||||
OpenRGBSystemInfoPage *SMBusToolsPage;
|
||||
OpenRGBSoftwareInfoPage *SoftInfoPage;
|
||||
|
||||
/*-------------------------------------*\
|
||||
| System tray icon and menu |
|
||||
\*-------------------------------------*/
|
||||
QSystemTrayIcon* trayIcon;
|
||||
QMenu* profileMenu;
|
||||
void RefreshProfileList();
|
||||
|
||||
/*-------------------------------------*\
|
||||
| User interface |
|
||||
\*-------------------------------------*/
|
||||
Ui::OpenRGBDialog2Ui *ui;
|
||||
|
||||
void ClearDevicesList();
|
||||
void UpdateDevicesList();
|
||||
void UpdateProfileList();
|
||||
|
||||
private slots:
|
||||
void on_Exit();
|
||||
|
|
@ -55,6 +77,7 @@ private slots:
|
|||
void on_QuickBlue();
|
||||
void on_QuickMagenta();
|
||||
void on_QuickWhite();
|
||||
void on_ClientListUpdated();
|
||||
void on_SetAllDevices(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void on_SaveSizeProfile();
|
||||
void on_ShowHide();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue