From 4c6429ae76a1c44b2aba93dbe6887f8caf2ad30d Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Sun, 28 Jun 2020 16:27:08 -0500 Subject: [PATCH] Add OpenRGB client support to GUI --- OpenRGB.pro | 5 +- main.cpp | 6 +- qt/OpenRGBClientInfoPage.cpp | 219 +++++++++++++++++++++++++++++++++ qt/OpenRGBClientInfoPage.h | 40 ++++++ qt/OpenRGBClientInfoPage.ui | 75 ++++++++++++ qt/OpenRGBDialog2.cpp | 229 +++++++++++++++++++++++------------ qt/OpenRGBDialog2.h | 35 +++++- 7 files changed, 521 insertions(+), 88 deletions(-) create mode 100644 qt/OpenRGBClientInfoPage.cpp create mode 100644 qt/OpenRGBClientInfoPage.h create mode 100644 qt/OpenRGBClientInfoPage.ui diff --git a/OpenRGB.pro b/OpenRGB.pro index e75264ae..0796e1e4 100644 --- a/OpenRGB.pro +++ b/OpenRGB.pro @@ -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 \ diff --git a/main.cpp b/main.cpp index 735627ce..533b619b 100644 --- a/main.cpp +++ b/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) { diff --git a/qt/OpenRGBClientInfoPage.cpp b/qt/OpenRGBClientInfoPage.cpp new file mode 100644 index 00000000..e84defc6 --- /dev/null +++ b/qt/OpenRGBClientInfoPage.cpp @@ -0,0 +1,219 @@ +#include +#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& 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; +} diff --git a/qt/OpenRGBClientInfoPage.h b/qt/OpenRGBClientInfoPage.h new file mode 100644 index 00000000..15321cb0 --- /dev/null +++ b/qt/OpenRGBClientInfoPage.h @@ -0,0 +1,40 @@ +#ifndef OPENRGBCLIENTINFOPAGE_H +#define OPENRGBCLIENTINFOPAGE_H + +#include +#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& 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& controllers; + std::vector rgb_clients; + +signals: + void ClientListUpdated(); +}; + +#endif // OPENRGBCLIENTINFOPAGE_H diff --git a/qt/OpenRGBClientInfoPage.ui b/qt/OpenRGBClientInfoPage.ui new file mode 100644 index 00000000..f79f59ab --- /dev/null +++ b/qt/OpenRGBClientInfoPage.ui @@ -0,0 +1,75 @@ + + + OpenRGBClientInfoPageUi + + + + 0 + 0 + 664 + 300 + + + + Frame + + + + + + + 0 + 0 + + + + + + + + Port: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Connect + + + + + + + + + + IP: + + + + + + + 0 + + + + + + + + diff --git a/qt/OpenRGBDialog2.cpp b/qt/OpenRGBDialog2.cpp index 46353f0f..cc149e14 100644 --- a/qt/OpenRGBDialog2.cpp +++ b/qt/OpenRGBDialog2.cpp @@ -2,8 +2,6 @@ #include "OpenRGBDevicePage.h" #include "OpenRGBDeviceInfoPage.h" #include "OpenRGBServerInfoPage.h" -#include "OpenRGBSoftwareInfoPage.h" -#include "OpenRGBSystemInfoPage.h" #include "OpenRGBProfileSaveDialog.h" #include #include @@ -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& bus, std::vector& 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& bus, std::vector& 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& 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 = "
Software
"; + + 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 = "
SMBus Tools
"; + + 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& bus, std::vec | type and append device name string. | \*-----------------------------------------------------*/ QString NewLabelString = "
" + QString::fromStdString(control[dev_idx]->name) + "
"; + NewLabelString += GetIconString(controllers[dev_idx]->type); + NewLabelString += "' height='16' width='16'>" + QString::fromStdString(controllers[dev_idx]->name) + ""; QLabel *NewTabLabel = new QLabel(); NewTabLabel->setText(NewLabelString); @@ -168,9 +298,9 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector& 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& bus, std::vec | type and append device name string. | \*-----------------------------------------------------*/ QString NewLabelString = "
" + QString::fromStdString(control[dev_idx]->name) + "
"; + NewLabelString += GetIconString(controllers[dev_idx]->type); + NewLabelString += "' height='16' width='16'>" + QString::fromStdString(controllers[dev_idx]->name) + ""; QLabel *NewTabLabel = new QLabel(); NewTabLabel->setText(NewLabelString); @@ -189,72 +319,9 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector& 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 = "
Software
"; - - 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 = "
SMBus Tools
"; - - 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(); } } } diff --git a/qt/OpenRGBDialog2.h b/qt/OpenRGBDialog2.h index 8c9bf0ce..b9742ae3 100644 --- a/qt/OpenRGBDialog2.h +++ b/qt/OpenRGBDialog2.h @@ -3,10 +3,15 @@ #include "ui_OpenRGBDialog2.h" +#include "OpenRGBClientInfoPage.h" +#include "OpenRGBSoftwareInfoPage.h" +#include "OpenRGBSystemInfoPage.h" + #include #include "i2c_smbus.h" #include "RGBController.h" #include "ProfileManager.h" +#include "NetworkClient.h" #include "NetworkServer.h" #include @@ -24,26 +29,43 @@ class Ui::OpenRGBDialog2 : public QMainWindow Q_OBJECT public: - explicit OpenRGBDialog2(std::vector& bus, std::vector& control, ProfileManager* manager, NetworkServer* server, QWidget *parent = 0); + explicit OpenRGBDialog2(std::vector& bus, std::vector& 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& busses; std::vector& 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();