Qt: Drop int for QT_SCALE_FACTOR_ROUNDING_POLICY

This commit is contained in:
Megamouse 2021-03-29 19:43:00 +02:00
parent d62983e1a2
commit a982280400

View File

@ -265,27 +265,13 @@ QCoreApplication* createApplication(int& argc, char* argv[])
const auto check_dpi_rounding_arg = [&rounding_str_cli, &rounding_val, &meta_enum](const char* val) -> bool
{
bool ok{false};
// Try to find out if the argument is a valid string representation of Qt::HighDpiScaleFactorRoundingPolicy
bool ok{false};
if (const int enum_index = meta_enum.keyToValue(val, &ok); ok)
{
rounding_str_cli = meta_enum.valueToKey(enum_index);
rounding_val = static_cast<Qt::HighDpiScaleFactorRoundingPolicy>(enum_index);
}
// Try to find out if the argument is a valid integer representation of Qt::HighDpiScaleFactorRoundingPolicy
else if (const int enum_index = QString(val).toInt(&ok); ok)
{
if (const char* key = meta_enum.valueToKey(enum_index))
{
rounding_str_cli = key;
rounding_val = static_cast<Qt::HighDpiScaleFactorRoundingPolicy>(enum_index);
}
else
{
return false;
}
}
return ok;
};