Commit 80547955 authored by Gus Grubba's avatar Gus Grubba

Deal with unreliable Device Pixel Ratio on mobile platforms.

parent bac7281f
......@@ -54,7 +54,20 @@ Item {
readonly property real largeFontPointRatio: 1.5
property real realPixelDensity: QGroundControl.corePlugin.options.devicePixelDensity != 0 ? QGroundControl.corePlugin.options.devicePixelDensity : Screen.pixelDensity
property real realPixelRatio: QGroundControl.corePlugin.options.devicePixelRatio != 0 ? QGroundControl.corePlugin.options.devicePixelRatio : (isMobile ? 1 : Screen.devicePixelRatio)
property real realPixelRatio: {
//-- If a plugin defines it, just use what it tells us
if (QGroundControl.corePlugin.options.devicePixelRatio != 0)
return QGroundControl.corePlugin.options.devicePixelRatio
//-- Mobile is rather unreliable. They all return 1 for Screen.devicePixelRatio.
if(isMobile) {
// Lets assume it's unlikely you have a tablet over 300mm wide
if((Screen.width / Screen.pixelDensity * Screen.devicePixelRatio) > 300)
return 2
}
//-- Use whatever the system tells us
return Screen.devicePixelRatio
}
property bool isAndroid: ScreenToolsController.isAndroid
property bool isiOS: ScreenToolsController.isiOS
......
......@@ -160,13 +160,13 @@ QGCView {
font.family: ScreenTools.normalFontFamily
}
Text {
text: Screen.pixelDensity.toFixed(4)
color: qgcPal.text
text: Screen.pixelDensity.toFixed(4)
color: qgcPal.text
font.family: ScreenTools.normalFontFamily
}
Text {
text: qsTr("Font Point Size 13.5")
color: qgcPal.text
text: qsTr("Font Point Size 13.5")
color: qgcPal.text
font.pointSize: 13.5
font.family: ScreenTools.normalFontFamily
}
......@@ -218,6 +218,38 @@ QGCView {
font.pointSize: 15
font.family: ScreenTools.normalFontFamily
}
Text {
text: qsTr("Computed Screen Height:")
color: qgcPal.text
font.family: ScreenTools.normalFontFamily
}
Text {
text: (Screen.height / Screen.pixelDensity * Screen.devicePixelRatio).toFixed(0)
color: qgcPal.text
font.family: ScreenTools.normalFontFamily
}
Text {
text: qsTr("Font Point Size 15.5")
color: qgcPal.text
font.pointSize: 15.5
font.family: ScreenTools.normalFontFamily
}
Text {
text: qsTr("Computed Screen Width:")
color: qgcPal.text
font.family: ScreenTools.normalFontFamily
}
Text {
text: (Screen.width / Screen.pixelDensity * Screen.devicePixelRatio).toFixed(0)
color: qgcPal.text
font.family: ScreenTools.normalFontFamily
}
Text {
text: qsTr("Font Point Size 16")
color: qgcPal.text
font.pointSize: 16
font.family: ScreenTools.normalFontFamily
}
}
Rectangle {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment