summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qhighdpiscaling.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-01-26 14:38:54 +0100
committerMarc Mutz <marc.mutz@kdab.com>2016-02-11 19:25:47 +0000
commitbcd7d223f066f2830501c2be79f1e7e4f6dd8f50 (patch)
tree2731bb0009263cb2c8d6365a0fedaf2ae63ab8db /src/gui/kernel/qhighdpiscaling.cpp
parent276d6cf239bdb0a39ae589e13f60b2a31a2efb60 (diff)
QtGui: eradicate Q_FOREACH loops [rvalues]
... by replacing them with C++11 range-for loops. This is the simplest of the patch series: Q_FOREACH took a copy, so we do, too. Except we don't, since we're just catching the return value that comes out of the function (RVO). We can't feed the rvalues into range-for, because they are non-const and would thus detach. Change-Id: I457942159015ff153bdfc6d5f031a3f0a0f6e9ac Reviewed-by: Gunnar Sletta <gunnar@sletta.org> Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/gui/kernel/qhighdpiscaling.cpp')
-rw-r--r--src/gui/kernel/qhighdpiscaling.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp
index eed4c301ef..4cc9e95e81 100644
--- a/src/gui/kernel/qhighdpiscaling.cpp
+++ b/src/gui/kernel/qhighdpiscaling.cpp
@@ -267,7 +267,8 @@ void QHighDpiScaling::updateHighDpiScaling()
return;
if (m_usePixelDensity && !m_pixelDensityScalingActive) {
- Q_FOREACH (QScreen *screen, QGuiApplication::screens()) {
+ const auto screens = QGuiApplication::screens();
+ for (QScreen *screen : screens) {
if (!qFuzzyCompare(screenSubfactor(screen->handle()), qreal(1))) {
m_pixelDensityScalingActive = true;
break;
@@ -276,7 +277,8 @@ void QHighDpiScaling::updateHighDpiScaling()
}
if (qEnvironmentVariableIsSet(screenFactorsEnvVar)) {
int i = 0;
- Q_FOREACH (const QByteArray &spec, qgetenv(screenFactorsEnvVar).split(';')) {
+ const auto specs = qgetenv(screenFactorsEnvVar).split(';');
+ for (const QByteArray &spec : specs) {
QScreen *screen = 0;
int equalsPos = spec.lastIndexOf('=');
double factor = 0;
@@ -287,7 +289,8 @@ void QHighDpiScaling::updateHighDpiScaling()
bool ok;
factor = f.toDouble(&ok);
if (ok) {
- Q_FOREACH (QScreen *s, QGuiApplication::screens()) {
+ const auto screens = QGuiApplication::screens();
+ for (QScreen *s : screens) {
if (s->name() == QString::fromLocal8Bit(name)) {
screen = s;
break;
@@ -327,7 +330,8 @@ void QHighDpiScaling::setGlobalFactor(qreal factor)
m_globalScalingActive = !qFuzzyCompare(factor, qreal(1));
m_factor = m_globalScalingActive ? factor : qreal(1);
m_active = m_globalScalingActive || m_screenFactorSet || m_pixelDensityScalingActive;
- Q_FOREACH (QScreen *screen, QGuiApplication::screens())
+ const auto screens = QGuiApplication::screens();
+ for (QScreen *screen : screens)
screen->d_func()->updateHighDpi();
}