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();
}
#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);