From a25f3ef2fcbe70b458642f66ab21ebb39174abb6 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Sun, 28 Jun 2020 03:00:35 -0500 Subject: [PATCH] GUI rework to provide more control over optional tabs to main.cpp, add TODO comments for client mode --- main.cpp | 17 ++++++++--- qt/OpenRGBDialog2.cpp | 71 +++++++++++++++++++++---------------------- qt/OpenRGBDialog2.h | 5 ++- 3 files changed, 52 insertions(+), 41 deletions(-) diff --git a/main.cpp b/main.cpp index 8efc9c29..735627ce 100644 --- a/main.cpp +++ b/main.cpp @@ -70,14 +70,23 @@ int main(int argc, char* argv[]) QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication a(argc, argv); - bool show_i2c_tools = false; + Ui::OpenRGBDialog2 dlg(busses, rgb_controllers, &profile_manager, &server); + if(ret_flags & RET_FLAG_I2C_TOOLS) { - //I2C Tools is enabled - show_i2c_tools = true; + dlg.AddI2CToolsPage(); } - Ui::OpenRGBDialog2 dlg(busses, rgb_controllers, &profile_manager, &server, show_i2c_tools); + //TODO: + // Determine whether or not to add server tab + // If application is open in client mode, do not show server tab + dlg.AddServerTab(); + + //TODO: + // Determine whether or not to add client tab + // Client tab should probably always show + // Implement client tab + //dlg.AddClientTab(); if(ret_flags & RET_FLAG_START_MINIMIZED) { diff --git a/qt/OpenRGBDialog2.cpp b/qt/OpenRGBDialog2.cpp index 56bb1f9f..46353f0f 100644 --- a/qt/OpenRGBDialog2.cpp +++ b/qt/OpenRGBDialog2.cpp @@ -51,7 +51,7 @@ static QString GetIconString(device_type type) } } -OpenRGBDialog2::OpenRGBDialog2(std::vector& bus, std::vector& control, ProfileManager* manager, NetworkServer* server, bool show_i2c_tools, 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, NetworkServer* server, QWidget *parent) : QMainWindow(parent), busses(bus), controllers(control), profile_manager(manager), network_server(server), ui(new OpenRGBDialog2Ui) { ui->setupUi(this); @@ -191,27 +191,7 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector& bus, std::vec } /*-----------------------------------------------------*\ - | Show the I2C Tools page only if enabled | - \*-----------------------------------------------------*/ - if(show_i2c_tools) - { - OpenRGBSystemInfoPage *SMBusToolsPage = new OpenRGBSystemInfoPage(bus); - ui->InformationTabBar->addTab(SMBusToolsPage, ""); - - QString SMBusToolsLabelString = "
SMBus Tools
"; - - QLabel *SMBusToolsTabLabel = new QLabel(); - SMBusToolsTabLabel->setText(SMBusToolsLabelString); - SMBusToolsTabLabel->setIndent(20); - SMBusToolsTabLabel->setGeometry(0, 0, 200, 20); - - InformationTabBar->setTabButton(control.size(), QTabBar::LeftSide, SMBusToolsTabLabel); - } - - /*-----------------------------------------------------*\ - | Always show the software information page | + | Create the Software Information page | \*-----------------------------------------------------*/ OpenRGBSoftwareInfoPage *SoftInfoPage = new OpenRGBSoftwareInfoPage(); ui->InformationTabBar->addTab(SoftInfoPage, ""); @@ -225,31 +205,50 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector& bus, std::vec SoftwareTabLabel->setIndent(20); SoftwareTabLabel->setGeometry(0, 0, 200, 20); - if(show_i2c_tools) - { - InformationTabBar->setTabButton(control.size() + 1, QTabBar::LeftSide, SoftwareTabLabel); - } - else - { - InformationTabBar->setTabButton(control.size(), QTabBar::LeftSide, SoftwareTabLabel); - } + 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"); } } -OpenRGBDialog2::~OpenRGBDialog2() -{ - delete ui; -} - void OpenRGBDialog2::show() { QMainWindow::show(); diff --git a/qt/OpenRGBDialog2.h b/qt/OpenRGBDialog2.h index 1fd62347..8c9bf0ce 100644 --- a/qt/OpenRGBDialog2.h +++ b/qt/OpenRGBDialog2.h @@ -24,9 +24,12 @@ class Ui::OpenRGBDialog2 : public QMainWindow Q_OBJECT public: - explicit OpenRGBDialog2(std::vector& bus, std::vector& control, ProfileManager* manager, NetworkServer* server, bool show_i2c_tools, QWidget *parent = 0); + explicit OpenRGBDialog2(std::vector& bus, std::vector& control, ProfileManager* manager, NetworkServer* server, QWidget *parent = 0); ~OpenRGBDialog2(); + void AddI2CToolsPage(); + void AddServerTab(); + void show(); void setMode(unsigned char mode_val);