qBound -> std::clamp

This commit is contained in:
Xaver Hugl 2022-11-12 15:37:11 +01:00
parent d265535f9b
commit 704d1d639a
10 changed files with 18 additions and 18 deletions

View file

@ -412,7 +412,7 @@ void Device::setPointerAcceleration(qreal acceleration)
if (!m_supportsPointerAcceleration) {
return;
}
acceleration = qBound(-1.0, acceleration, 1.0);
acceleration = std::clamp(acceleration, -1.0, 1.0);
if (libinput_device_config_accel_set_speed(m_device, acceleration) == LIBINPUT_CONFIG_STATUS_SUCCESS) {
if (m_pointerAcceleration != acceleration) {
m_pointerAcceleration = acceleration;

View file

@ -219,7 +219,7 @@ int DesktopGridEffect::gridRows() const
case DesktopLayoutMode::LayoutAutomatic:
return ceil(sqrt(effects->numberOfDesktops()));
case DesktopLayoutMode::LayoutCustom:
return qBound(1, customLayoutRows(), effects->numberOfDesktops());
return std::clamp(customLayoutRows(), 1, effects->numberOfDesktops());
case DesktopLayoutMode::LayoutPager:
default:
return effects->desktopGridSize().height();

View file

@ -327,7 +327,7 @@ qreal WindowPaintData::crossFadeProgress() const
void WindowPaintData::setCrossFadeProgress(qreal factor)
{
d->crossFadeProgress = qBound(qreal(0.0), factor, qreal(1.0));
d->crossFadeProgress = std::clamp(factor, 0.0, 1.0);
}
qreal WindowPaintData::multiplyOpacity(qreal factor)

View file

@ -861,7 +861,7 @@ void Options::reloadCompositingSettings(bool force)
// Compositing settings
KConfigGroup config(m_settings->config(), "Compositing");
setGlSmoothScale(qBound(-1, config.readEntry("GLTextureFilter", Options::defaultGlSmoothScale()), 2));
setGlSmoothScale(std::clamp(config.readEntry("GLTextureFilter", Options::defaultGlSmoothScale()), -1, 2));
setGlStrictBindingFollowsDriver(!config.hasKey("GLStrictBinding"));
if (!isGlStrictBindingFollowsDriver()) {
setGlStrictBinding(config.readEntry("GLStrictBinding", Options::defaultGlStrictBinding()));

View file

@ -233,9 +233,9 @@ void AuroraeTheme::borders(int &left, int &top, int &right, int &bottom, bool ma
maxMargin = 0;
}
left = qBound(minMargin, d->themeConfig.borderLeft(), maxMargin);
right = qBound(minMargin, d->themeConfig.borderRight(), maxMargin);
bottom = qBound(minMargin, d->themeConfig.borderBottom(), maxMargin);
left = std::clamp(d->themeConfig.borderLeft(), minMargin, maxMargin);
right = std::clamp(d->themeConfig.borderRight(), minMargin, maxMargin);
bottom = std::clamp(d->themeConfig.borderBottom(), minMargin, maxMargin);
if (d->borderSize == KDecoration2::BorderSize::None) {
left = 0;

View file

@ -258,8 +258,8 @@ void NightColorManager::readConfig()
break;
}
m_dayTargetTemp = qBound(MIN_TEMPERATURE, s->dayTemperature(), DEFAULT_DAY_TEMPERATURE);
m_nightTargetTemp = qBound(MIN_TEMPERATURE, s->nightTemperature(), DEFAULT_DAY_TEMPERATURE);
m_dayTargetTemp = std::clamp(s->dayTemperature(), MIN_TEMPERATURE, DEFAULT_DAY_TEMPERATURE);
m_nightTargetTemp = std::clamp(s->nightTemperature(), MIN_TEMPERATURE, DEFAULT_DAY_TEMPERATURE);
double lat, lng;
auto correctReadin = [&lat, &lng]() {

View file

@ -63,8 +63,8 @@ static bool screenContainsPos(const QPointF &pos)
static QPointF confineToBoundingBox(const QPointF &pos, const QRectF &boundingBox)
{
return QPointF(
qBound(boundingBox.left(), pos.x(), boundingBox.right() - 1.0),
qBound(boundingBox.top(), pos.y(), boundingBox.bottom() - 1.0));
std::clamp(pos.x(), boundingBox.left(), boundingBox.right() - 1.0),
std::clamp(pos.y(), boundingBox.top(), boundingBox.bottom() - 1.0));
}
PointerInputRedirection::PointerInputRedirection(InputRedirection *parent)

View file

@ -430,7 +430,7 @@ VirtualDesktop *VirtualDesktopManager::createVirtualDesktop(uint position, const
return nullptr;
}
position = qBound(0u, position, static_cast<uint>(m_desktops.count()));
position = std::clamp(position, 0u, static_cast<uint>(m_desktops.count()));
QString desktopName = name;
if (desktopName.isEmpty()) {
@ -545,7 +545,7 @@ bool VirtualDesktopManager::setCurrent(VirtualDesktop *newDesktop)
void VirtualDesktopManager::setCount(uint count)
{
count = qBound<uint>(1, count, VirtualDesktopManager::maximum());
count = std::clamp<uint>(count, 1, VirtualDesktopManager::maximum());
if (count == uint(m_desktops.count())) {
// nothing to change
return;
@ -704,7 +704,7 @@ void VirtualDesktopManager::load()
}
int rows = group.readEntry<int>("Rows", 2);
m_rows = qBound(1, rows, n);
m_rows = std::clamp(rows, 1, n);
s_loadingDesktopSettings = false;
}

View file

@ -84,7 +84,7 @@ void PlasmaVirtualDesktopManagementInterfacePrivate::org_kde_plasma_virtual_desk
const QString &name,
uint32_t position)
{
Q_EMIT q->desktopCreateRequested(name, qBound<quint32>(0, position, (quint32)desktops.count()));
Q_EMIT q->desktopCreateRequested(name, std::clamp<quint32>(position, 0, desktops.size()));
}
void PlasmaVirtualDesktopManagementInterfacePrivate::org_kde_plasma_virtual_desktop_management_request_remove_virtual_desktop(Resource *resource,

View file

@ -323,7 +323,7 @@ qreal Window::opacity() const
void Window::setOpacity(qreal opacity)
{
opacity = qBound(0.0, opacity, 1.0);
opacity = std::clamp(opacity, 0.0, 1.0);
if (m_opacity == opacity) {
return;
}
@ -4204,8 +4204,8 @@ QSizeF Window::constrainClientSize(const QSizeF &size, SizeMode mode) const
const QSizeF minimumSize = minSize();
const QSizeF maximumSize = maxSize();
width = qBound(minimumSize.width(), width, maximumSize.width());
height = qBound(minimumSize.height(), height, maximumSize.height());
width = std::clamp(width, minimumSize.width(), maximumSize.width());
height = std::clamp(height, minimumSize.height(), maximumSize.height());
return QSizeF(width, height);
}