0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 13:08:50 +02:00

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.
This commit is contained in:
gxalpha 2023-08-11 11:45:14 +02:00 committed by Ryan Foster
parent e02f782bc6
commit b962daa3c8

View File

@ -133,26 +133,25 @@ void OBSBasicSettings::SaveA11ySettings()
main->RefreshVolumeColors(); main->RefreshVolumeColors();
} }
#define SetStyle(label, colorVal) \ static void SetStyle(QLabel *label, uint32_t colorVal)
color = color_from_int(colorVal); \ {
color.setAlpha(255); \ QColor color = color_from_int(colorVal);
palette = QPalette(color); \ color.setAlpha(255);
label->setFrameStyle(QFrame::Sunken | QFrame::Panel); \ QPalette palette = QPalette(color);
label->setText(color.name(QColor::HexRgb)); \ label->setFrameStyle(QFrame::Sunken | QFrame::Panel);
label->setPalette(palette); \ label->setText(color.name(QColor::HexRgb));
label->setStyleSheet(QString("background-color: %1; color: %2;") \ label->setPalette(palette);
.arg(palette.color(QPalette::Window) \ label->setStyleSheet(QString("background-color: %1; color: %2;")
.name(QColor::HexRgb)) \ .arg(palette.color(QPalette::Window)
.arg(palette.color(QPalette::WindowText) \ .name(QColor::HexRgb))
.name(QColor::HexRgb))); \ .arg(palette.color(QPalette::WindowText)
label->setAutoFillBackground(true); \ .name(QColor::HexRgb)));
label->setAutoFillBackground(true);
label->setAlignment(Qt::AlignCenter); label->setAlignment(Qt::AlignCenter);
}
void OBSBasicSettings::UpdateA11yColors() void OBSBasicSettings::UpdateA11yColors()
{ {
QPalette palette;
QColor color;
SetStyle(ui->color1, selectRed); SetStyle(ui->color1, selectRed);
SetStyle(ui->color2, selectGreen); SetStyle(ui->color2, selectGreen);
SetStyle(ui->color3, selectBlue); SetStyle(ui->color3, selectBlue);