GUI rework to provide more control over optional tabs to main.cpp, add TODO comments for client mode

This commit is contained in:
Adam Honse
2020-06-28 03:00:35 -05:00
parent 15ace9d094
commit a25f3ef2fc
3 changed files with 52 additions and 41 deletions

View File

@@ -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)
{

View File

@@ -51,7 +51,7 @@ static QString GetIconString(device_type type)
}
}
OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vector<RGBController *>& 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<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)
{
ui->setupUi(this);
@@ -191,27 +191,7 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& 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 = "<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);
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<i2c_smbus_interface *>& 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 = "<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");
}
}
OpenRGBDialog2::~OpenRGBDialog2()
{
delete ui;
}
void OpenRGBDialog2::show()
{
QMainWindow::show();

View File

@@ -24,9 +24,12 @@ class Ui::OpenRGBDialog2 : public QMainWindow
Q_OBJECT
public:
explicit OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vector<RGBController *>& control, ProfileManager* manager, NetworkServer* server, bool show_i2c_tools, QWidget *parent = 0);
explicit OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vector<RGBController *>& control, ProfileManager* manager, NetworkServer* server, QWidget *parent = 0);
~OpenRGBDialog2();
void AddI2CToolsPage();
void AddServerTab();
void show();
void setMode(unsigned char mode_val);