From b962daa3c821b22ab3cc99ff8da679ec60b1b444 Mon Sep 17 00:00:00 2001 From: gxalpha Date: Fri, 11 Aug 2023 11:45:14 +0200 Subject: [PATCH] UI: Use static function instead of macro to set color Macros can be hard to read and are usually not very friendly to use in a debugger. Using a static function instead gives the advantage of better syntax highlighting in IDEs and better debugger support. --- UI/window-basic-settings-a11y.cpp | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/UI/window-basic-settings-a11y.cpp b/UI/window-basic-settings-a11y.cpp index 03e929004..8a10201a4 100644 --- a/UI/window-basic-settings-a11y.cpp +++ b/UI/window-basic-settings-a11y.cpp @@ -133,26 +133,25 @@ void OBSBasicSettings::SaveA11ySettings() main->RefreshVolumeColors(); } -#define SetStyle(label, colorVal) \ - color = color_from_int(colorVal); \ - color.setAlpha(255); \ - palette = QPalette(color); \ - label->setFrameStyle(QFrame::Sunken | QFrame::Panel); \ - label->setText(color.name(QColor::HexRgb)); \ - label->setPalette(palette); \ - label->setStyleSheet(QString("background-color: %1; color: %2;") \ - .arg(palette.color(QPalette::Window) \ - .name(QColor::HexRgb)) \ - .arg(palette.color(QPalette::WindowText) \ - .name(QColor::HexRgb))); \ - label->setAutoFillBackground(true); \ +static void SetStyle(QLabel *label, uint32_t colorVal) +{ + QColor color = color_from_int(colorVal); + color.setAlpha(255); + QPalette palette = QPalette(color); + label->setFrameStyle(QFrame::Sunken | QFrame::Panel); + label->setText(color.name(QColor::HexRgb)); + label->setPalette(palette); + label->setStyleSheet(QString("background-color: %1; color: %2;") + .arg(palette.color(QPalette::Window) + .name(QColor::HexRgb)) + .arg(palette.color(QPalette::WindowText) + .name(QColor::HexRgb))); + label->setAutoFillBackground(true); label->setAlignment(Qt::AlignCenter); +} void OBSBasicSettings::UpdateA11yColors() { - QPalette palette; - QColor color; - SetStyle(ui->color1, selectRed); SetStyle(ui->color2, selectGreen); SetStyle(ui->color3, selectBlue);