Rework show/hide to reduce the surface called from the SignalUpdate callback

This commit is contained in:
Adam Honse committed 2026-07-27 23:14:39 -05:00
1 parent 069eeccb60
commit 227fd375fb
4 files changed
+106 -3

No files matched your search

+1 -1
View File
@@ -2026,7 +2026,7 @@ void OpenRGBDevicePage::UpdateInterface(unsigned int update_reason)
case RGBCONTROLLER_UPDATE_REASON_HIDDEN:
case RGBCONTROLLER_UPDATE_REASON_UNHIDDEN:
case RGBCONTROLLER_UPDATE_REASON_CONFIGUREDEVICE:
emit RefreshList();
emit ShowHideList();
break;
case RGBCONTROLLER_UPDATE_REASON_UPDATELEDS:
+2
View File
@@ -129,5 +129,7 @@ private slots:
signals:
void RefreshList();
void ShowHideList();
void SetAllDevices(unsigned char red, unsigned char green, unsigned char blue);
};
+98 -1
View File
@@ -38,6 +38,7 @@
#include <QCheckBox>
#include <QScreen>
#include <QSpinBox>
#include <QThread>
#include <string>
#include <functional>
@@ -106,7 +107,15 @@ static void OpenRGBDialogResourceManagerCallback(void * this_ptr, unsigned int u
break;
case RESOURCEMANAGER_UPDATE_REASON_DEVICE_LIST_UPDATED:
QMetaObject::invokeMethod(this_obj, "onDeviceListUpdated", Qt::BlockingQueuedConnection);
if(QThread::currentThread() != qApp->thread())
{
printf("invoking onDeviceListUpdated\n");
QMetaObject::invokeMethod(this_obj, "onDeviceListUpdated", Qt::BlockingQueuedConnection);
}
else
{
this_obj->onDeviceListUpdated();
}
break;
}
}
@@ -960,6 +969,84 @@ void OpenRGBDialog::ClearDevicesList()
}
}
void OpenRGBDialog::UpdateDevicesListShowHide()
{
/*-----------------------------------------------------*\
| Loop through each controller in the tab list and hide |
| any controller marked as hidden. |
\*-----------------------------------------------------*/
for(int tab_idx = 0; tab_idx < ui->DevicesTabBar->count(); tab_idx++)
{
/*-------------------------------------------------*\
| Get a pointer to the page at this index in the |
| tab bar |
\*-------------------------------------------------*/
QWidget* page = ui->DevicesTabBar->widget(tab_idx);
/*-------------------------------------------------*\
| Verify this page is an OpenRGBDevicePage |
\*-------------------------------------------------*/
if(dynamic_cast<OpenRGBDevicePage*>(page) != nullptr)
{
/*---------------------------------------------*\
| If the controller for this page is hidden, |
| remove the page from the tab bar and store it |
| in the hidden pages vector |
\*---------------------------------------------*/
if(((OpenRGBDevicePage*)page)->GetController()->GetHidden())
{
hidden_pages.push_back((OpenRGBDevicePage*)page);
ui->DevicesTabBar->removeTab(tab_idx);
/*-----------------------------------------*\
| Decrement tab index to account for |
| removing tab |
\*-----------------------------------------*/
tab_idx--;
}
}
}
/*-----------------------------------------------------*\
| Loop through each controller in the hidden pages |
| vector and restore any controller marked as not |
| hidden. |
\*-----------------------------------------------------*/
for(std::size_t page_idx = 0; page_idx < hidden_pages.size(); page_idx++)
{
/*-----------------------------------------*\
| Get a pointer to the page at this index |
| in the hidden pages vector |
\*-----------------------------------------*/
OpenRGBDevicePage* page = (OpenRGBDevicePage*)hidden_pages[page_idx];
RGBController* controller = page->GetController();
/*-----------------------------------------*\
| If the current tab matches the current |
| controller, check if it is hidden |
\*-----------------------------------------*/
if(!(controller->GetHidden()))
{
ui->DevicesTabBar->addTab((QWidget*)page, "");
/*---------------------------------*\
| Create the tab label |
\*---------------------------------*/
TabLabel* NewTabLabel = new TabLabel(OpenRGBFont::GetIconIDFromDeviceType(controller->GetDeviceType()), (char *)controller->GetDisplayName().c_str(), (char *)context, false);
ui->DevicesTabBar->tabBar()->setTabButton(ui->DevicesTabBar->count() - 1, QTabBar::LeftSide, NewTabLabel);
hidden_pages.erase(hidden_pages.begin() + page_idx);
/*---------------------------------*\
| Decrement page index to account |
| for removing page |
\*---------------------------------*/
page_idx--;
}
}
}
void OpenRGBDialog::UpdateDevicesList()
{
std::vector<RGBController *> controllers = ResourceManager::get()->GetRGBControllers();
@@ -1142,6 +1229,11 @@ void OpenRGBDialog::UpdateDevicesList()
this,
SLOT(onDeviceListUpdated()));
connect(NewPage,
SIGNAL(ShowHideList()),
this,
SLOT(onDeviceListShowHide()));
if(controllers[controller_idx]->GetHidden())
{
hidden_pages.push_back(NewPage);
@@ -1475,6 +1567,11 @@ void OpenRGBDialog::onDeviceListUpdated()
UpdateDevicesList();
}
void OpenRGBDialog::onDeviceListShowHide()
{
UpdateDevicesListShowHide();
}
void OpenRGBDialog::onDetectionProgressUpdated()
{
ui->DetectionProgressBar->setValue(ResourceManager::get()->GetDetectionPercent());
+5 -1
View File
@@ -148,6 +148,7 @@ private:
void ClearDevicesList();
void UpdateDevicesList();
void UpdateDevicesListShowHide();
void closeEvent(QCloseEvent *event) override;
bool SelectConfigProfile(const std::string name);
@@ -166,6 +167,9 @@ private:
void UpdateTabs();
bool isCompactTabMode();
public slots:
void onDeviceListUpdated();
private slots:
void on_Exit();
void on_LightsOff();
@@ -176,7 +180,7 @@ private slots:
void on_QuickBlue();
void on_QuickMagenta();
void on_QuickWhite();
void onDeviceListUpdated();
void onDeviceListShowHide();
void onDetectionProgressUpdated();
void onDetectionStarted();
void onDetectionEnded();