From 7327644d263e526e83c695f333a4c82ab2a72c8c Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Tue, 17 Aug 2021 19:44:20 -0500 Subject: [PATCH] Use TabLabel for all tab labels and adjust the TabLabel widget layout so that it aligns with the previous HTML label layout. Height is slightly increased for two-line labels. --- qt/OpenRGBDialog2.cpp | 169 +++++++++++++++++------------------------- qt/TabLabel.cpp | 1 + qt/TabLabel.ui | 48 ++++++++++-- 3 files changed, 114 insertions(+), 104 deletions(-) diff --git a/qt/OpenRGBDialog2.cpp b/qt/OpenRGBDialog2.cpp index 0730b56f8..7d00fff23 100644 --- a/qt/OpenRGBDialog2.cpp +++ b/qt/OpenRGBDialog2.cpp @@ -501,23 +501,22 @@ void OpenRGBDialog2::AddSoftwareInfoPage() ui->InformationTabBar->addTab(SoftInfoPage, ""); - QString SoftwareLabelString = "
Software
"; + QString SoftwareLabelString; - QLabel *SoftwareTabLabel = new QLabel(); - SoftwareTabLabel->setText(SoftwareLabelString); - SoftwareTabLabel->setIndent(20); if(IsDarkTheme()) { - SoftwareTabLabel->setGeometry(0, 25, 200, 50); + SoftwareLabelString = "software_dark.png"; } else { - SoftwareTabLabel->setGeometry(0, 0, 200, 25); + SoftwareLabelString = "software.png"; } + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* SoftwareTabLabel = new TabLabel(SoftwareLabelString, "Software"); + ui->InformationTabBar->tabBar()->setTabButton(ui->InformationTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SoftwareTabLabel); } @@ -530,23 +529,22 @@ void OpenRGBDialog2::AddSupportedDevicesPage() ui->SettingsTabBar->addTab(SupportedPage, ""); - QString SupportedLabelString = "
Supported Devices
"; + QString SettingsLabelString; - QLabel *SupportedTabLabel = new QLabel(); - SupportedTabLabel->setText(SupportedLabelString); - SupportedTabLabel->setIndent(20); if(IsDarkTheme()) { - SupportedTabLabel->setGeometry(0, 25, 200, 50); + SettingsLabelString = "software_dark.png"; } else { - SupportedTabLabel->setGeometry(0, 0, 200, 25); + SettingsLabelString = "software.png"; } + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* SupportedTabLabel = new TabLabel(SettingsLabelString, "Supported Devices"); + ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SupportedTabLabel); } @@ -560,23 +558,22 @@ void OpenRGBDialog2::AddSettingsPage() ui->SettingsTabBar->addTab(SettingsPage, ""); - QString SettingsLabelString = "
Settings
"; + QString SettingsLabelString; - QLabel *SettingsTabLabel = new QLabel(); - SettingsTabLabel->setText(SettingsLabelString); - SettingsTabLabel->setIndent(20); if(IsDarkTheme()) { - SettingsTabLabel->setGeometry(0, 25, 200, 50); + SettingsLabelString = "settings_dark.png"; } else { - SettingsTabLabel->setGeometry(0, 0, 200, 25); + SettingsLabelString = "settings.png"; } + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* SettingsTabLabel = new TabLabel(SettingsLabelString, "Settings"); + ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); } @@ -589,23 +586,22 @@ void OpenRGBDialog2::AddE131SettingsPage() ui->SettingsTabBar->addTab(E131SettingsPage, ""); - QString SettingsLabelString = "
E1.31 Devices
"; + QString SettingsLabelString; - QLabel *SettingsTabLabel = new QLabel(); - SettingsTabLabel->setText(SettingsLabelString); - SettingsTabLabel->setIndent(20); if(IsDarkTheme()) { - SettingsTabLabel->setGeometry(0, 25, 200, 50); + SettingsLabelString = "wireless_dark.png"; } else { - SettingsTabLabel->setGeometry(0, 0, 200, 25); + SettingsLabelString = "wireless.png"; } + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* SettingsTabLabel = new TabLabel(SettingsLabelString, "E1.31 Devices"); + ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); } @@ -618,23 +614,22 @@ void OpenRGBDialog2::AddQMKORGBSettingsPage() ui->SettingsTabBar->addTab(QMKORGBSettingsPage, ""); - QString SettingsLabelString = "
QMK OpenRGB Protocol
"; + QString SettingsLabelString; - QLabel *SettingsTabLabel = new QLabel(); - SettingsTabLabel->setText(SettingsLabelString); - SettingsTabLabel->setIndent(20); if(IsDarkTheme()) { - SettingsTabLabel->setGeometry(0, 25, 200, 50); + SettingsLabelString = "keyboard_dark.png"; } else { - SettingsTabLabel->setGeometry(0, 0, 200, 25); + SettingsLabelString = "keyboard.png"; } + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* SettingsTabLabel = new TabLabel(SettingsLabelString, "OpenRGB QMK Protocol"); + ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); } @@ -647,23 +642,22 @@ void OpenRGBDialog2::AddSerialSettingsPage() ui->SettingsTabBar->addTab(SerialSettingsPage, ""); - QString SettingsLabelString = "
Serial Devices
"; + QString SettingsLabelString; - QLabel *SettingsTabLabel = new QLabel(); - SettingsTabLabel->setText(SettingsLabelString); - SettingsTabLabel->setIndent(20); if(IsDarkTheme()) { - SettingsTabLabel->setGeometry(0, 25, 200, 50); + SettingsLabelString = "serial_dark.png"; } else { - SettingsTabLabel->setGeometry(0, 0, 200, 25); + SettingsLabelString = "serial.png"; } + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* SettingsTabLabel = new TabLabel(SettingsLabelString, "Serial Devices"); + ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel); } @@ -685,23 +679,21 @@ void OpenRGBDialog2::AddPluginTab(PluginManager* plugin_manager, int plugin_inde else { QLabel *TabLabelText = plugin_manager->ActivePlugins[plugin_index]->info.PluginLabel; + QString PluginLabelString; - QString NewTabLabelText = TabLabelText->text(); - QString PluginLabelString = "
" + NewTabLabelText + "
"; - PluginTabLabel->setText(PluginLabelString); - - PluginTabLabel->setIndent(20); if(IsDarkTheme()) { - PluginTabLabel->setGeometry(0, 25, 200, 50); + PluginLabelString = "plugin_dark.png"; } else { - PluginTabLabel->setGeometry(0, 0, 200, 25); + PluginLabelString = "plugin.png"; } + + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + PluginTabLabel = (QLabel*)new TabLabel(PluginLabelString, TabLabelText->text()); } /*-----------------------------------------------------*\ @@ -783,22 +775,22 @@ void OpenRGBDialog2::AddI2CToolsPage() \*-----------------------------------------------------*/ ui->InformationTabBar->addTab(SMBusToolsPage, ""); - QString SMBusToolsLabelString = "
SMBus Tools
"; + QString SMBusToolsLabelString; - QLabel *SMBusToolsTabLabel = new QLabel(); - SMBusToolsTabLabel->setText(SMBusToolsLabelString); - SMBusToolsTabLabel->setIndent(20); if(IsDarkTheme()) { - SMBusToolsTabLabel->setGeometry(0, 25, 200, 50); + SMBusToolsLabelString = "tools_dark.png"; } else { - SMBusToolsTabLabel->setGeometry(0, 0, 200, 25); + SMBusToolsLabelString = "tools.png"; } + + /*-----------------------------------------------------*\ + | Create the tab label | + \*-----------------------------------------------------*/ + TabLabel* SMBusToolsTabLabel = new TabLabel(SMBusToolsLabelString, "SMBus Tools"); + ui->InformationTabBar->tabBar()->setTabButton(ui->InformationTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SMBusToolsTabLabel); } @@ -914,16 +906,11 @@ void OpenRGBDialog2::UpdateDevicesList() SLOT(on_SaveSizeProfile())); /*-----------------------------------------------------*\ - | Use Qt's HTML capabilities to display both icon and | - | text in the tab label. Choose icon based on device | - | type and append device name string. | + | Create the tab label | \*-----------------------------------------------------*/ - TabLabel* device_tab_header = new TabLabel( - GetIconString(controllers[controller_idx]->type, IsDarkTheme()), - QString::fromStdString(controllers[controller_idx]->name) - ); + TabLabel* NewTabLabel = new TabLabel(GetIconString(controllers[controller_idx]->type, IsDarkTheme()), QString::fromStdString(controllers[controller_idx]->name)); - ui->DevicesTabBar->tabBar()->setTabButton(ui->DevicesTabBar->count() - 1, QTabBar::LeftSide, device_tab_header); + ui->DevicesTabBar->tabBar()->setTabButton(ui->DevicesTabBar->count() - 1, QTabBar::LeftSide, NewTabLabel); ui->DevicesTabBar->tabBar()->setTabToolTip(ui->DevicesTabBar->count() - 1, QString::fromStdString(controllers[controller_idx]->name)); /*-----------------------------------------------------*\ @@ -970,25 +957,9 @@ void OpenRGBDialog2::UpdateDevicesList() ui->InformationTabBar->addTab(NewPage, ""); /*-----------------------------------------------------*\ - | Use Qt's HTML capabilities to display both icon and | - | text in the tab label. Choose icon based on device | - | type and append device name string. | + | Create the tab label | \*-----------------------------------------------------*/ - QString NewLabelString = "
" + QString::fromStdString(controllers[controller_idx]->name) + "
"; - - QLabel *NewTabLabel = new QLabel(); - NewTabLabel->setText(NewLabelString); - NewTabLabel->setIndent(20); - if(IsDarkTheme()) - { - NewTabLabel->setGeometry(0, 25, 200, 50); - } - else - { - NewTabLabel->setGeometry(0, 0, 200, 25); - } + TabLabel* NewTabLabel = new TabLabel(GetIconString(controllers[controller_idx]->type, IsDarkTheme()), QString::fromStdString(controllers[controller_idx]->name)); ui->InformationTabBar->tabBar()->setTabButton(ui->InformationTabBar->count() - 1, QTabBar::LeftSide, NewTabLabel); ui->InformationTabBar->tabBar()->setTabToolTip(ui->InformationTabBar->count() - 1, QString::fromStdString(controllers[controller_idx]->name)); diff --git a/qt/TabLabel.cpp b/qt/TabLabel.cpp index f243725b5..7fd450c85 100644 --- a/qt/TabLabel.cpp +++ b/qt/TabLabel.cpp @@ -7,6 +7,7 @@ Ui::TabLabel::TabLabel(QString icon, QString name) : ui->setupUi(this); ui->icon->setText(""); ui->name->setText(name); + setMinimumHeight(ui->name->height()); } Ui::TabLabel::~TabLabel() diff --git a/qt/TabLabel.ui b/qt/TabLabel.ui index 2a8251478..ad17b89ae 100644 --- a/qt/TabLabel.ui +++ b/qt/TabLabel.ui @@ -6,21 +6,43 @@ 0 0 - 224 - 43 + 200 + 25 + + + 0 + 0 + + Form - + 0 0 - + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 0 + + + + + @@ -39,7 +61,23 @@ - + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 0 + + + + +