-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace qMin
,qMax
,qBound
,qRound
,qAbs
with standard funcs
#2236
base: master
Are you sure you want to change the base?
Conversation
@@ -77,7 +79,7 @@ CustomButton::~CustomButton() = default; | |||
void CustomButton::wheelEvent(QWheelEvent *event) | |||
{ | |||
QPoint anglePoint = event->angleDelta(); | |||
bool horizontal(qAbs(event->angleDelta().x()) > qAbs(anglePoint.y())); | |||
bool horizontal(std::abs(event->angleDelta().x()) > std::abs(anglePoint.y())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs cmath
.
@@ -86,7 +88,7 @@ void LXQtNetworkMonitorConfiguration::loadSettings() | |||
ui->interfaceCB->addItem(QLatin1String(stats[ix].interface_name)); | |||
|
|||
QString interface = settings().value(QStringLiteral("interface")).toString(); | |||
ui->interfaceCB->setCurrentIndex(qMax(qMin(0, count - 1), ui->interfaceCB->findText(interface))); | |||
ui->interfaceCB->setCurrentIndex(std::clamp(count - 1, ui->interfaceCB->findText(interface), 0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QComboBox::findText
can be > 0, in which case, clamp
will be undefined. So, min
and max
should be used.
@@ -47,8 +49,8 @@ int AudioEngine::volumeBounded(int volume, AudioDevice* device) const | |||
{ | |||
int maximum = volumeMax(device); | |||
double v = ((double) volume / 100.0) * maximum; | |||
double bounded = qBound<double>(0, v, maximum); | |||
return qRound((bounded / maximum) * 100); | |||
double bounded = std::clamp<double>(v, 0.0, maximum); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope maximum >= 0
; it seems to be the case; doesn't it?
@@ -215,7 +215,7 @@ void LXQtVolume::handleSinkListChanged() | |||
{ | |||
if (m_engine->sinks().count() > 0) | |||
{ | |||
m_defaultSink = m_engine->sinks().at(qBound(0, m_defaultSinkIndex, m_engine->sinks().count()-1)); | |||
m_defaultSink = m_engine->sinks().at(std::clamp<qsizetype>(m_defaultSinkIndex, 0, m_engine->sinks().count()-1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if m_engine->sinks().count()
is 0? Is it possible here?
No description provided.