summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>2015-11-17 13:51:42 +0100
committerTor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>2015-11-19 06:06:59 +0000
commit2ab6963e9597f42609632ff25a696b14a63d2fd8 (patch)
treedb19504a02063b1983a114e45532d6ad38495d11 /src
parent7a8c61284738ecaf6632611d638f24cc7c3b37bd (diff)
iOS: Update pixel density (PPI) logic to detect new iOS devices
Since the iPhone 6(S) Plus devices have a PPI of 401, we change the logic from storing the unscaled PPI to storing the scaled PPI, and applying that to a scaled geometry when computing the physical size. Task-number: QTBUG-49467 Change-Id: I1741ff075749a301d2434cd35f642fcc9ea4b581 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/ios/qiosscreen.h2
-rw-r--r--src/plugins/platforms/ios/qiosscreen.mm25
2 files changed, 16 insertions, 11 deletions
diff --git a/src/plugins/platforms/ios/qiosscreen.h b/src/plugins/platforms/ios/qiosscreen.h
index a0aa922a31..f31be9756c 100644
--- a/src/plugins/platforms/ios/qiosscreen.h
+++ b/src/plugins/platforms/ios/qiosscreen.h
@@ -73,7 +73,7 @@ private:
QRect m_geometry;
QRect m_availableGeometry;
int m_depth;
- uint m_unscaledDpi;
+ uint m_pixelDensity;
QSizeF m_physicalSize;
QIOSOrientationListener *m_orientationListener;
};
diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm
index 3e16efcd22..5cb06d591d 100644
--- a/src/plugins/platforms/ios/qiosscreen.mm
+++ b/src/plugins/platforms/ios/qiosscreen.mm
@@ -170,23 +170,28 @@ QIOSScreen::QIOSScreen(UIScreen *screen)
if (screen == [UIScreen mainScreen]) {
QString deviceIdentifier = deviceModelIdentifier();
- if (deviceIdentifier == QLatin1String("iPhone2,1") /* iPhone 3GS */
- || deviceIdentifier == QLatin1String("iPod3,1") /* iPod touch 3G */) {
+ // Based on https://en.wikipedia.org/wiki/List_of_iOS_devices#Display
+
+ // iPhone (1st gen), 3G, 3GS, and iPod Touch (1st–3rd gen) are 18-bit devices
+ if (deviceIdentifier.contains(QRegularExpression("^(iPhone1,[12]|iPhone2,1|iPod[1-3],1)$")))
m_depth = 18;
- } else {
+ else
m_depth = 24;
- }
- if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad
- && !deviceIdentifier.contains(QRegularExpression("^iPad2,[567]$")) /* excluding iPad Mini */) {
- m_unscaledDpi = 132;
+ if (deviceIdentifier.contains(QRegularExpression("^iPhone(7,1|8,2)$"))) {
+ // iPhone 6 Plus or iPhone 6S Plus
+ m_pixelDensity = 401;
+ } else if (deviceIdentifier.contains(QRegularExpression("^iPad(1,1|2,[1-4]|3,[1-6]|4,[1-3]|5,[3-4]|6,[7-8])$"))) {
+ // All iPads except the iPad Mini series
+ m_pixelDensity = 132 * devicePixelRatio();
} else {
- m_unscaledDpi = 163; // Regular iPhone DPI
+ // All non-Plus iPhones, and iPad Minis
+ m_pixelDensity = 163 * devicePixelRatio();
}
} else {
// External display, hard to say
m_depth = 24;
- m_unscaledDpi = 96;
+ m_pixelDensity = 96;
}
for (UIWindow *existingWindow in [[UIApplication sharedApplication] windows]) {
@@ -249,7 +254,7 @@ void QIOSScreen::updateProperties()
if (m_geometry != previousGeometry) {
const qreal millimetersPerInch = 25.4;
- m_physicalSize = QSizeF(m_geometry.size()) / m_unscaledDpi * millimetersPerInch;
+ m_physicalSize = QSizeF(m_geometry.size() * devicePixelRatio()) / m_pixelDensity * millimetersPerInch;
}
// At construction time, we don't yet have an associated QScreen, but we still want