frontend: Round all output theme values

This commit is contained in:
Warchamp7
2026-02-09 14:37:48 -05:00
committed by Ryan Foster
parent 49c9c868ec
commit b4ff360139
+9 -6
View File
@@ -705,12 +705,6 @@ static QString PrepareQSS(const QHash<QString, OBSThemeVariable> &vars, const QS
} else if (var.type == OBSThemeVariable::Size || var.type == OBSThemeVariable::Number) {
double val = value.toDouble();
// Round any values with a px suffix. Qt does this anyway for some properties,
// but then will flat out break with decimals for others.
if (var.suffix == "px") {
val = std::roundf(val);
}
bool isInteger = ceill(val) == val;
replace = QString::number(val, 'f', isInteger ? 0 : -1);
@@ -720,6 +714,15 @@ static QString PrepareQSS(const QHash<QString, OBSThemeVariable> &vars, const QS
replace = value.toString();
}
// Round any values with a px suffix. Qt does this anyway for some properties,
// but then will flat out break with decimals for others.
if (replace.right(2) == "px") {
QString replaceValue = replace.sliced(0, replace.length() - 2);
int val = (int)std::roundf(replaceValue.toDouble());
replace = QString::number(val) + "px";
}
stylesheet = stylesheet.replace(needle, replace);
}