|
|
@ -53,20 +53,24 @@ Item { |
|
|
|
readonly property real mediumFontPointRatio: 1.25 |
|
|
|
readonly property real mediumFontPointRatio: 1.25 |
|
|
|
readonly property real largeFontPointRatio: 1.5 |
|
|
|
readonly property real largeFontPointRatio: 1.5 |
|
|
|
|
|
|
|
|
|
|
|
property real realPixelDensity: QGroundControl.corePlugin.options.devicePixelDensity != 0 ? QGroundControl.corePlugin.options.devicePixelDensity : Screen.pixelDensity |
|
|
|
property real realPixelDensity: { |
|
|
|
|
|
|
|
|
|
|
|
property real realPixelRatio: { |
|
|
|
|
|
|
|
//-- If a plugin defines it, just use what it tells us |
|
|
|
//-- If a plugin defines it, just use what it tells us |
|
|
|
if (QGroundControl.corePlugin.options.devicePixelRatio != 0) |
|
|
|
if(QGroundControl.corePlugin.options.devicePixelDensity != 0) { |
|
|
|
return QGroundControl.corePlugin.options.devicePixelRatio |
|
|
|
return QGroundControl.corePlugin.options.devicePixelDensity |
|
|
|
//-- Mobile is rather unreliable. They all return 1 for Screen.devicePixelRatio. |
|
|
|
} |
|
|
|
|
|
|
|
//-- Apple returns proper values |
|
|
|
|
|
|
|
if(isiOS || isMac) { |
|
|
|
|
|
|
|
return Screen.pixelDensity |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//-- Mobile is rather unreliable |
|
|
|
if(isMobile) { |
|
|
|
if(isMobile) { |
|
|
|
// Lets assume it's unlikely you have a tablet over 300mm wide |
|
|
|
// Lets assume it's unlikely you have a tablet over 300mm wide |
|
|
|
if((Screen.width / Screen.pixelDensity * Screen.devicePixelRatio) > 300) |
|
|
|
if((Screen.width / Screen.pixelDensity) > 300) { |
|
|
|
return 2 |
|
|
|
return Screen.pixelDensity * 2 |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//-- Use whatever the system tells us |
|
|
|
//-- Still needs logical pixel density on Windows |
|
|
|
return Screen.devicePixelRatio |
|
|
|
return Screen.pixelDensity |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
property bool isAndroid: ScreenToolsController.isAndroid |
|
|
|
property bool isAndroid: ScreenToolsController.isAndroid |
|
|
@ -74,9 +78,10 @@ Item { |
|
|
|
property bool isMobile: ScreenToolsController.isMobile |
|
|
|
property bool isMobile: ScreenToolsController.isMobile |
|
|
|
property bool isWindows: ScreenToolsController.isWindows |
|
|
|
property bool isWindows: ScreenToolsController.isWindows |
|
|
|
property bool isDebug: ScreenToolsController.isDebug |
|
|
|
property bool isDebug: ScreenToolsController.isDebug |
|
|
|
|
|
|
|
property bool isMac: ScreenToolsController.isMacOS |
|
|
|
property bool isTinyScreen: (Screen.width / realPixelDensity) < 120 // 120mm |
|
|
|
property bool isTinyScreen: (Screen.width / realPixelDensity) < 120 // 120mm |
|
|
|
property bool isShortScreen: ScreenToolsController.isMobile && ((Screen.height / Screen.width) < 0.6) // Nexus 7 for example |
|
|
|
property bool isShortScreen: ScreenToolsController.isMobile && ((Screen.height / Screen.width) < 0.6) // Nexus 7 for example |
|
|
|
property bool isHugeScreen: Screen.width >= 1920*2 |
|
|
|
property bool isHugeScreen: (Screen.width / realPixelDensity) >= (23.5 * 25.4) // 27" monitor |
|
|
|
|
|
|
|
|
|
|
|
readonly property real minTouchMillimeters: 10 ///< Minimum touch size in millimeters |
|
|
|
readonly property real minTouchMillimeters: 10 ///< Minimum touch size in millimeters |
|
|
|
property real minTouchPixels: 0 ///< Minimum touch size in pixels |
|
|
|
property real minTouchPixels: 0 ///< Minimum touch size in pixels |
|
|
@ -111,10 +116,6 @@ Item { |
|
|
|
_setBasePointSize(defaultFontPointSize) |
|
|
|
_setBasePointSize(defaultFontPointSize) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onRealPixelRatioChanged: { |
|
|
|
|
|
|
|
_setBasePointSize(defaultFontPointSize) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function printScreenStats() { |
|
|
|
function printScreenStats() { |
|
|
|
console.log('ScreenTools: Screen.width: ' + Screen.width + ' Screen.height: ' + Screen.height + ' Screen.pixelDensity: ' + Screen.pixelDensity) |
|
|
|
console.log('ScreenTools: Screen.width: ' + Screen.width + ' Screen.height: ' + Screen.height + ' Screen.pixelDensity: ' + Screen.pixelDensity) |
|
|
|
} |
|
|
|
} |
|
|
@ -138,7 +139,7 @@ Item { |
|
|
|
smallFontPointSize = defaultFontPointSize * _screenTools.smallFontPointRatio |
|
|
|
smallFontPointSize = defaultFontPointSize * _screenTools.smallFontPointRatio |
|
|
|
mediumFontPointSize = defaultFontPointSize * _screenTools.mediumFontPointRatio |
|
|
|
mediumFontPointSize = defaultFontPointSize * _screenTools.mediumFontPointRatio |
|
|
|
largeFontPointSize = defaultFontPointSize * _screenTools.largeFontPointRatio |
|
|
|
largeFontPointSize = defaultFontPointSize * _screenTools.largeFontPointRatio |
|
|
|
minTouchPixels = Math.round(minTouchMillimeters * realPixelDensity * realPixelRatio) |
|
|
|
minTouchPixels = Math.round(minTouchMillimeters * realPixelDensity) |
|
|
|
if (minTouchPixels / Screen.height > 0.15) { |
|
|
|
if (minTouchPixels / Screen.height > 0.15) { |
|
|
|
// If using physical sizing takes up too much of the vertical real estate fall back to font based sizing |
|
|
|
// If using physical sizing takes up too much of the vertical real estate fall back to font based sizing |
|
|
|
minTouchPixels = defaultFontPixelHeight * 3 |
|
|
|
minTouchPixels = defaultFontPixelHeight * 3 |
|
|
|