summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qhighdpiscaling.cpp
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@theqtcompany.com>2015-06-23 17:05:32 +0200
committerPaul Olav Tvete <paul.tvete@theqtcompany.com>2015-06-30 12:38:45 +0000
commit7809e77f2e6163de892afb99cb3a4a8f259f4709 (patch)
treeb5d7d2068fbb47476659268c2ba1e05a881b0417 /src/gui/kernel/qhighdpiscaling.cpp
parent76550ed353cdcaf8be8c867bef9c112c7d198fc5 (diff)
Add environment variable to set per-screen scaling
Change-Id: I0fce05998ba6092c4dd1d64790c56c0668383477 Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
Diffstat (limited to 'src/gui/kernel/qhighdpiscaling.cpp')
-rw-r--r--src/gui/kernel/qhighdpiscaling.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp
index 8dd6c6687d..e574a79370 100644
--- a/src/gui/kernel/qhighdpiscaling.cpp
+++ b/src/gui/kernel/qhighdpiscaling.cpp
@@ -54,6 +54,7 @@ Q_LOGGING_CATEGORY(lcScaling, "qt.scaling");
static const char legacyDevicePixelEnvVar[] = "QT_DEVICE_PIXEL_RATIO";
static const char scaleFactorEnvVar[] = "QT_SCALE_FACTOR";
static const char autoScreenEnvVar[] = "QT_AUTO_SCREEN_SCALE_FACTOR";
+static const char screenFactorsEnvVar[] = "QT_SCREEN_SCALE_FACTORS";
static inline qreal initialScaleFactor()
{
@@ -113,6 +114,11 @@ static inline qreal initialScaleFactor()
Setting this to a true-ish value will make QHighDpiScaling
call QPlatformScreen::pixelDensity()
- QHighDpiScaling::setScreenFactor(screen, factor);
+ - QT_SCREEN_SCALE_FACTORS (environment variable)
+ Set this to a semicolon-separated list of scale factors
+ (matching the order of QGuiApplications::screens()),
+ or to a list of name=value pairs (where name matches
+ QScreen::name()).
All scale factors are of type qreal.
@@ -159,6 +165,38 @@ void QHighDpiScaling::updateHighDpiScaling()
}
}
}
+ if (qEnvironmentVariableIsSet(screenFactorsEnvVar)) {
+ int i = 0;
+ Q_FOREACH (QByteArray spec, qgetenv(screenFactorsEnvVar).split(';')) {
+ QScreen *screen = 0;
+ int equalsPos = spec.lastIndexOf('=');
+ double factor = 0;
+ if (equalsPos > 0) {
+ // support "name=factor"
+ QByteArray name = spec.mid(0, equalsPos);
+ QByteArray f = spec.mid(equalsPos + 1);
+ bool ok;
+ factor = f.toDouble(&ok);
+ if (ok) {
+ Q_FOREACH (QScreen *s, QGuiApplication::screens()) {
+ if (s->name() == QString::fromLocal8Bit(name)) {
+ screen = s;
+ break;
+ }
+ }
+ }
+ } else {
+ // listing screens in order
+ bool ok;
+ factor = spec.toDouble(&ok);
+ if (ok && i < QGuiApplication::screens().count())
+ screen = QGuiApplication::screens().at(i);
+ }
+ if (screen)
+ setScreenFactor(screen, factor);
+ ++i;
+ }
+ }
m_active = m_globalScalingActive || m_screenFactorSet || m_pixelDensityScalingActive;
QPlatformScreen *primaryScreen = QGuiApplication::primaryScreen()->handle();