Unverified Commit c4b864aa authored by Gus Grubba's avatar Gus Grubba Committed by GitHub

Merge pull request #8256 from mavlink/pr-ui-scaling

UI Scaling
parents 0b5aba44 da62ead1
...@@ -21,6 +21,8 @@ T.ComboBox { ...@@ -21,6 +21,8 @@ T.ComboBox {
id: control id: control
padding: ScreenTools.comboBoxPadding padding: ScreenTools.comboBoxPadding
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
font.pointSize: ScreenTools.defaultFontPointSize
font.family: ScreenTools.normalFontFamily
implicitWidth: Math.max(background ? background.implicitWidth : 0, implicitWidth: Math.max(background ? background.implicitWidth : 0,
contentItem.implicitWidth + leftPadding + rightPadding + padding) contentItem.implicitWidth + leftPadding + rightPadding + padding)
implicitHeight: Math.max(background ? background.implicitHeight : 0, implicitHeight: Math.max(background ? background.implicitHeight : 0,
...@@ -37,13 +39,13 @@ T.ComboBox { ...@@ -37,13 +39,13 @@ T.ComboBox {
property real _popupWidth: sizeToContents ? _largestTextWidth + leftPadding + rightPadding : control.width property real _popupWidth: sizeToContents ? _largestTextWidth + leftPadding + rightPadding : control.width
TextMetrics { TextMetrics {
id: textMetrics id: textMetrics
font: control.font
} }
onModelChanged: { onModelChanged: {
if (sizeToContents) { if (sizeToContents) {
_largestTextWidth = 0 _largestTextWidth = 0
textMetrics.font = control.font
for (var i = 0; i < model.length; i++){ for (var i = 0; i < model.length; i++){
textMetrics.text = model[i] textMetrics.text = model[i]
_largestTextWidth = Math.max(textMetrics.width, _largestTextWidth) _largestTextWidth = Math.max(textMetrics.width, _largestTextWidth)
...@@ -59,8 +61,9 @@ T.ComboBox { ...@@ -59,8 +61,9 @@ T.ComboBox {
property string _text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] : model[control.textRole]) : modelData property string _text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] : model[control.textRole]) : modelData
TextMetrics { TextMetrics {
id: popupItemMetrics id: popupItemMetrics
text: _text font: control.font
text: _text
} }
contentItem: Text { contentItem: Text {
......
...@@ -31,6 +31,7 @@ Item { ...@@ -31,6 +31,7 @@ Item {
//-- The point and pixel font size values are computed at runtime //-- The point and pixel font size values are computed at runtime
property real defaultFontPointSize: 10 property real defaultFontPointSize: 10
property real platformFontPointSize: 10
/// You can use this property to position ui elements in a screen resolution independent manner. Using fixed positioning values should not /// You can use this property to position ui elements in a screen resolution independent manner. Using fixed positioning values should not
/// be done. All positioning should be done using anchors or a ratio of the defaultFontPixelHeight and defaultFontPixelWidth values. This way /// be done. All positioning should be done using anchors or a ratio of the defaultFontPixelHeight and defaultFontPixelWidth values. This way
...@@ -105,8 +106,7 @@ Item { ...@@ -105,8 +106,7 @@ Item {
Connections { Connections {
target: QGroundControl.settingsManager.appSettings.appFontPointSize target: QGroundControl.settingsManager.appSettings.appFontPointSize
onValueChanged: { onValueChanged: {
if(ScreenToolsController.isDebug) _setBasePointSize(QGroundControl.settingsManager.appSettings.appFontPointSize.value)
_setBasePointSize(QGroundControl.settingsManager.appSettings.appFontPointSize.value)
} }
} }
...@@ -158,40 +158,36 @@ Item { ...@@ -158,40 +158,36 @@ Item {
property real fontWidth: contentWidth property real fontWidth: contentWidth
property real fontHeight: contentHeight property real fontHeight: contentHeight
Component.onCompleted: { Component.onCompleted: {
var _appFontPointSizeFact = QGroundControl.settingsManager.appSettings.appFontPointSize //-- First, compute platform, default size
var baseSize = _appFontPointSizeFact.value if(ScreenToolsController.isMobile) {
//-- If this is the first time (not saved in settings) //-- Check iOS really tiny screens (iPhone 4s/5/5s)
if(baseSize < _appFontPointSizeFact.min || baseSize > _appFontPointSizeFact.max) { if(ScreenToolsController.isiOS) {
//-- Init base size base on the platform if(ScreenToolsController.isiOS && Screen.width < 570) {
if(ScreenToolsController.isMobile) { // For iPhone 4s size we don't fit with additional tweaks to fit screen,
//-- Check iOS really tiny screens (iPhone 4s/5/5s) // we will just drop point size to make things fit. Correct size not yet determined.
if(ScreenToolsController.isiOS) { platformFontPointSize = 12; // This will be lowered in a future pull
if(ScreenToolsController.isiOS && Screen.width < 570) {
// For iPhone 4s size we don't fit with additional tweaks to fit screen,
// we will just drop point size to make things fit. Correct size not yet determined.
baseSize = 12; // This will be lowered in a future pull
} else {
baseSize = 14;
}
} else if((Screen.width / realPixelDensity) < 120) {
baseSize = 11;
// Other Android
} else { } else {
baseSize = 14; platformFontPointSize = 14;
} }
} else if((Screen.width / realPixelDensity) < 120) {
platformFontPointSize = 11;
// Other Android
} else { } else {
baseSize = _defaultFont.font.pointSize; platformFontPointSize = 14;
} }
_appFontPointSizeFact._setIgnoreQGCRebootRequired(true)
_appFontPointSizeFact.value = baseSize
_appFontPointSizeFact._setIgnoreQGCRebootRequired(false)
//-- Release build doesn't get signal
if(!ScreenToolsController.isDebug)
_screenTools._setBasePointSize(baseSize);
} else { } else {
//-- Set size saved in settings platformFontPointSize = _defaultFont.font.pointSize;
_screenTools._setBasePointSize(baseSize); }
//-- See if we are using a custom size
var _appFontPointSizeFact = QGroundControl.settingsManager.appSettings.appFontPointSize
var baseSize = _appFontPointSizeFact.value
//-- Sanity check
if(baseSize < _appFontPointSizeFact.min || baseSize > _appFontPointSizeFact.max) {
baseSize = platformFontPointSize;
_appFontPointSizeFact.value = baseSize
} }
//-- Set size saved in settings
_screenTools._setBasePointSize(baseSize);
} }
} }
} }
...@@ -146,8 +146,7 @@ ...@@ -146,8 +146,7 @@
"units": "pt", "units": "pt",
"min": 6, "min": 6,
"max": 48, "max": 48,
"defaultValue": 0, "defaultValue": 0
"qgcRebootRequired": true
}, },
{ {
"name": "indoorPalette", "name": "indoorPalette",
......
...@@ -36,7 +36,7 @@ Rectangle { ...@@ -36,7 +36,7 @@ Rectangle {
property Fact _userBrandImageIndoor: QGroundControl.settingsManager.brandImageSettings.userBrandImageIndoor property Fact _userBrandImageIndoor: QGroundControl.settingsManager.brandImageSettings.userBrandImageIndoor
property Fact _userBrandImageOutdoor: QGroundControl.settingsManager.brandImageSettings.userBrandImageOutdoor property Fact _userBrandImageOutdoor: QGroundControl.settingsManager.brandImageSettings.userBrandImageOutdoor
property real _labelWidth: ScreenTools.defaultFontPixelWidth * 20 property real _labelWidth: ScreenTools.defaultFontPixelWidth * 20
property real _comboFieldWidth: ScreenTools.defaultFontPixelWidth * 28 property real _comboFieldWidth: ScreenTools.defaultFontPixelWidth * 30
property real _valueFieldWidth: ScreenTools.defaultFontPixelWidth * 10 property real _valueFieldWidth: ScreenTools.defaultFontPixelWidth * 10
property string _mapProvider: QGroundControl.settingsManager.flightMapSettings.mapProvider.value property string _mapProvider: QGroundControl.settingsManager.flightMapSettings.mapProvider.value
property string _mapType: QGroundControl.settingsManager.flightMapSettings.mapType.value property string _mapType: QGroundControl.settingsManager.flightMapSettings.mapType.value
...@@ -197,8 +197,8 @@ Rectangle { ...@@ -197,8 +197,8 @@ Rectangle {
} }
QGCLabel { QGCLabel {
text: qsTr("Stream GCS Position") text: qsTr("Stream GCS Position")
visible: _followTarget.visible visible: _followTarget.visible
} }
FactComboBox { FactComboBox {
Layout.preferredWidth: _comboFieldWidth Layout.preferredWidth: _comboFieldWidth
...@@ -206,6 +206,54 @@ Rectangle { ...@@ -206,6 +206,54 @@ Rectangle {
indexModel: false indexModel: false
visible: _followTarget.visible visible: _followTarget.visible
} }
QGCLabel {
text: qsTr("UI Scaling")
visible: _appFontPointSize.visible
Layout.alignment: Qt.AlignVCenter
}
Item {
width: _comboFieldWidth
height: baseFontEdit.height * 1.5
visible: _appFontPointSize.visible
Layout.alignment: Qt.AlignVCenter
Row {
spacing: ScreenTools.defaultFontPixelWidth
anchors.verticalCenter: parent.verticalCenter
QGCButton {
width: height
height: baseFontEdit.height * 1.5
text: "-"
anchors.verticalCenter: parent.verticalCenter
onClicked: {
if (_appFontPointSize.value > _appFontPointSize.min) {
_appFontPointSize.value = _appFontPointSize.value - 1
}
}
}
QGCLabel {
id: baseFontEdit
width: ScreenTools.defaultFontPixelWidth * 6
text: (QGroundControl.settingsManager.appSettings.appFontPointSize.value / ScreenTools.platformFontPointSize * 100).toFixed(0) + "%"
horizontalAlignment: Text.AlignHCenter
anchors.verticalCenter: parent.verticalCenter
}
Text {
}
QGCButton {
width: height
height: baseFontEdit.height * 1.5
text: "+"
anchors.verticalCenter: parent.verticalCenter
onClicked: {
if (_appFontPointSize.value < _appFontPointSize.max) {
_appFontPointSize.value = _appFontPointSize.value + 1
}
}
}
}
}
} }
} }
...@@ -215,6 +263,7 @@ Rectangle { ...@@ -215,6 +263,7 @@ Rectangle {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: comboGridItem.bottom anchors.top: comboGridItem.bottom
anchors.topMargin: ScreenTools.defaultFontPixelHeight
height: miscCol.height height: miscCol.height
ColumnLayout { ColumnLayout {
...@@ -222,41 +271,6 @@ Rectangle { ...@@ -222,41 +271,6 @@ Rectangle {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
spacing: _margins spacing: _margins
RowLayout {
Layout.fillWidth: false
Layout.alignment: Qt.AlignHCenter
visible: _appFontPointSize.visible
QGCLabel {
text: qsTr("Font Size:")
}
QGCButton {
Layout.preferredWidth: height
Layout.preferredHeight: baseFontEdit.height
text: "-"
onClicked: {
if (_appFontPointSize.value > _appFontPointSize.min) {
_appFontPointSize.value = _appFontPointSize.value - 1
}
}
}
FactTextField {
id: baseFontEdit
Layout.preferredWidth: _valueFieldWidth
fact: QGroundControl.settingsManager.appSettings.appFontPointSize
}
QGCButton {
Layout.preferredWidth: height
Layout.preferredHeight: baseFontEdit.height
text: "+"
onClicked: {
if (_appFontPointSize.value < _appFontPointSize.max) {
_appFontPointSize.value = _appFontPointSize.value + 1
}
}
}
}
FactCheckBox { FactCheckBox {
text: qsTr("Use Vehicle Pairing") text: qsTr("Use Vehicle Pairing")
fact: _usePairing fact: _usePairing
......
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