Commit 9b6e5499 authored by dogmaphobic's avatar dogmaphobic

Added convenience function to ScreenTools to compute appropriate font point size.

parent a5bd0794
...@@ -382,7 +382,7 @@ Item { ...@@ -382,7 +382,7 @@ Item {
QGCLabel { QGCLabel {
text: "FLIGHT MODES CONFIG" text: "FLIGHT MODES CONFIG"
font.pointSize: 20 * screenTools.dpiFactor; font.pointSize: screenTools.dpiAdjustedPointSize(20);
} }
Item { height: 20; width: 10 } // spacer Item { height: 20; width: 10 } // spacer
...@@ -873,7 +873,7 @@ Item { ...@@ -873,7 +873,7 @@ Item {
QGCLabel { QGCLabel {
text: "FLIGHT MODES CONFIG" text: "FLIGHT MODES CONFIG"
font.pointSize: 20 * screenTools.dpiFactor; font.pointSize: screenTools.dpiAdjustedPointSize(20);
} }
QGCLabel { QGCLabel {
......
...@@ -98,13 +98,13 @@ Rectangle { ...@@ -98,13 +98,13 @@ Rectangle {
QGCLabel { QGCLabel {
text: "POWER CONFIG" text: "POWER CONFIG"
font.pointSize: 20 * screenTools.dpiFactor; font.pointSize: screenTools.dpiAdjustedPointSize(20);
} }
QGCLabel { QGCLabel {
text: "Battery" text: "Battery"
color: palette.text color: palette.text
font.pointSize: 20 * screenTools.dpiFactor; font.pointSize: screenTools.dpiAdjustedPointSize(20);
} }
Rectangle { Rectangle {
...@@ -208,12 +208,12 @@ Rectangle { ...@@ -208,12 +208,12 @@ Rectangle {
text: "Battery Max:" text: "Battery Max:"
color: palette.text color: palette.text
width: 80 width: 80
font.pointSize: 12 * screenTools.dpiFactor; font.pointSize: screenTools.dpiAdjustedPointSize(12);
} }
QGCLabel { QGCLabel {
text: (battNumCells.value * battHighVolt.value).toFixed(1) + ' V' text: (battNumCells.value * battHighVolt.value).toFixed(1) + ' V'
color: palette.text color: palette.text
font.pointSize: 12 * screenTools.dpiFactor; font.pointSize: screenTools.dpiAdjustedPointSize(12);
} }
} }
Row { Row {
...@@ -222,12 +222,12 @@ Rectangle { ...@@ -222,12 +222,12 @@ Rectangle {
text: "Battery Min:" text: "Battery Min:"
color: palette.text color: palette.text
width: 80 width: 80
font.pointSize: 12 * screenTools.dpiFactor; font.pointSize: screenTools.dpiAdjustedPointSize(12);
} }
QGCLabel { QGCLabel {
text: (battNumCells.value * battLowVolt.value).toFixed(1) + ' V' text: (battNumCells.value * battLowVolt.value).toFixed(1) + ' V'
color: palette.text color: palette.text
font.pointSize: 12 * screenTools.dpiFactor; font.pointSize: screenTools.dpiAdjustedPointSize(12);
} }
} }
} }
...@@ -245,7 +245,7 @@ Rectangle { ...@@ -245,7 +245,7 @@ Rectangle {
QGCLabel { QGCLabel {
text: "Propeller Function" text: "Propeller Function"
color: palette.text color: palette.text
font.pointSize: 20 * screenTools.dpiFactor; font.pointSize: screenTools.dpiAdjustedPointSize(20);
} }
Rectangle { Rectangle {
width: parent.width width: parent.width
...@@ -259,7 +259,7 @@ Rectangle { ...@@ -259,7 +259,7 @@ Rectangle {
QGCLabel { QGCLabel {
text: "Magnetometer Distortion" text: "Magnetometer Distortion"
color: palette.text color: palette.text
font.pointSize: 20 * screenTools.dpiFactor; font.pointSize: screenTools.dpiAdjustedPointSize(20);
} }
Rectangle { Rectangle {
width: parent.width width: parent.width
......
...@@ -54,7 +54,7 @@ Rectangle { ...@@ -54,7 +54,7 @@ Rectangle {
QGCLabel { QGCLabel {
text: "SAFETY CONFIG" text: "SAFETY CONFIG"
font.pointSize: 20 * screenTools.dpiFactor; font.pointSize: screenTools.dpiAdjustedPointSize(20);
} }
Item { height: 20; width: 10 } // spacer Item { height: 20; width: 10 } // spacer
...@@ -62,7 +62,7 @@ Rectangle { ...@@ -62,7 +62,7 @@ Rectangle {
//----------------------------------------------------------------- //-----------------------------------------------------------------
//-- Return Home Triggers //-- Return Home Triggers
QGCLabel { text: "Triggers For Return Home"; color: palette.text; font.pointSize: 20 * screenTools.dpiFactor; } QGCLabel { text: "Triggers For Return Home"; color: palette.text; font.pointSize: screenTools.dpiAdjustedPointSize(20); }
Item { height: 10; width: 10 } // spacer Item { height: 10; width: 10 } // spacer
...@@ -121,7 +121,7 @@ Rectangle { ...@@ -121,7 +121,7 @@ Rectangle {
//----------------------------------------------------------------- //-----------------------------------------------------------------
//-- Return Home Settings //-- Return Home Settings
QGCLabel { text: "Return Home Settings"; font.pointSize: 20 * screenTools.dpiFactor; } QGCLabel { text: "Return Home Settings"; font.pointSize: screenTools.dpiAdjustedPointSize(20); }
Item { height: 10; width: 10 } // spacer Item { height: 10; width: 10 } // spacer
...@@ -273,12 +273,12 @@ Rectangle { ...@@ -273,12 +273,12 @@ Rectangle {
QGCLabel { QGCLabel {
text: "Home loiter altitude"; text: "Home loiter altitude";
color: palette.text; color: palette.text;
enabled: homeLoiterCheckbox.checked == true enabled: homeLoiterCheckbox.checked === true
} }
FactTextField { FactTextField {
id: descendField; id: descendField;
fact: Fact { name: "RTL_DESCEND_ALT" } fact: Fact { name: "RTL_DESCEND_ALT" }
enabled: homeLoiterCheckbox.checked == true enabled: homeLoiterCheckbox.checked === true
showUnits: true showUnits: true
} }
} }
...@@ -291,17 +291,17 @@ Rectangle { ...@@ -291,17 +291,17 @@ Rectangle {
QGCLabel { QGCLabel {
property Fact fact: Fact { name: "NAV_RCL_OBC" } property Fact fact: Fact { name: "NAV_RCL_OBC" }
width: parent.width width: parent.width
font.pointSize: 14 * screenTools.dpiFactor; font.pointSize: screenTools.dpiAdjustedPointSize(14);
text: "Warning: You have an advanced safety configuration set using the NAV_RCL_OBC parameter. The above settings may not apply."; text: "Warning: You have an advanced safety configuration set using the NAV_RCL_OBC parameter. The above settings may not apply.";
visible: fact.value != 0 visible: fact.value !== 0
wrapMode: Text.Wrap wrapMode: Text.Wrap
} }
QGCLabel { QGCLabel {
property Fact fact: Fact { name: "NAV_DLL_OBC" } property Fact fact: Fact { name: "NAV_DLL_OBC" }
width: parent.width width: parent.width
font.pointSize: 14 * screenTools.dpiFactor; font.pointSize: screenTools.dpiAdjustedPointSize(14);
text: "Warning: You have an advanced safety configuration set using the NAV_DLL_OBC parameter. The above settings may not apply."; text: "Warning: You have an advanced safety configuration set using the NAV_DLL_OBC parameter. The above settings may not apply.";
visible: fact.value != 0 visible: fact.value !== 0
wrapMode: Text.Wrap wrapMode: Text.Wrap
} }
} }
......
...@@ -87,7 +87,7 @@ Rectangle { ...@@ -87,7 +87,7 @@ Rectangle {
QGCLabel { QGCLabel {
text: "SENSORS CONFIG" text: "SENSORS CONFIG"
font.pointSize: 20 * screenTools.dpiFactor; font.pointSize: screenTools.dpiAdjustedPointSize(20);
} }
Item { height: 20; width: 10 } // spacer Item { height: 20; width: 10 } // spacer
......
...@@ -33,7 +33,7 @@ Item { ...@@ -33,7 +33,7 @@ Item {
Fact { id: fact; name: "RC_MAP_THROTTLE" } Fact { id: fact; name: "RC_MAP_THROTTLE" }
text: fact.value text: fact.value
font.family: "Helvetica" font.family: "Helvetica"
font.pointSize: 24 * screenTools.dpiFactor; font.pointSize: screenTools.dpiAdjustedPointSize(24);
color: "red" color: "red"
focus: true focus: true
onAccepted: { fact.value = text; } onAccepted: { fact.value = text; }
......
...@@ -42,6 +42,11 @@ ScreenTools::ScreenTools() ...@@ -42,6 +42,11 @@ ScreenTools::ScreenTools()
connect(MainWindow::instance(), &MainWindow::repaintCanvas, this, &ScreenTools::_updateCanvas); connect(MainWindow::instance(), &MainWindow::repaintCanvas, this, &ScreenTools::_updateCanvas);
} }
qreal ScreenTools::dpiAdjustedPointSize(qreal pointSize)
{
return pointSize * _dpiFactor;
}
void ScreenTools::_updateCanvas() void ScreenTools::_updateCanvas()
{ {
emit repaintRequestedChanged(); emit repaintRequestedChanged();
......
...@@ -110,6 +110,12 @@ public: ...@@ -110,6 +110,12 @@ public:
*/ */
Q_PROPERTY(bool repaintRequested READ repaintRequested NOTIFY repaintRequestedChanged) Q_PROPERTY(bool repaintRequested READ repaintRequested NOTIFY repaintRequestedChanged)
//! Utility for adjusting font point size.
/*!
@sa dpiFactor
*/
Q_INVOKABLE qreal dpiAdjustedPointSize(qreal pointSize);
double screenDPI () { return _dotsPerInch; } double screenDPI () { return _dotsPerInch; }
double dpiFactor () { return _dpiFactor; } double dpiFactor () { return _dpiFactor; }
int mouseX () { return QCursor::pos().x(); } int mouseX () { return QCursor::pos().x(); }
......
...@@ -68,7 +68,7 @@ Rectangle { ...@@ -68,7 +68,7 @@ Rectangle {
height: parent.height height: parent.height
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignBottom verticalAlignment: Text.AlignBottom
font.pointSize: 25 * screenTools.dpiFactor; font.pointSize: screenTools.dpiAdjustedPointSize(25);
font.bold: true font.bold: true
color: "black" color: "black"
...@@ -79,7 +79,7 @@ Rectangle { ...@@ -79,7 +79,7 @@ Rectangle {
height: parent.height height: parent.height
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignBottom verticalAlignment: Text.AlignBottom
font.pointSize: 25 * screenTools.dpiFactor; font.pointSize: screenTools.dpiAdjustedPointSize(25);
color: calInProgress ? "yellow" : "white" color: calInProgress ? "yellow" : "white"
text: parent.calText text: parent.calText
......
...@@ -51,7 +51,7 @@ Rectangle { ...@@ -51,7 +51,7 @@ Rectangle {
QGCLabel { QGCLabel {
text: "FIRMWARE UPDATE" text: "FIRMWARE UPDATE"
font.pointSize: 20 * screenTools.dpiFactor; font.pointSize: screenTools.dpiAdjustedPointSize(20);
} }
Item { Item {
......
...@@ -47,7 +47,7 @@ Rectangle { ...@@ -47,7 +47,7 @@ Rectangle {
QGCLabel { QGCLabel {
text: "VEHICLE SUMMARY" text: "VEHICLE SUMMARY"
font.pointSize: 20 * screenTools.dpiFactor; font.pointSize: screenTools.dpiAdjustedPointSize(20);
} }
Item { Item {
......
...@@ -241,7 +241,7 @@ Rectangle { ...@@ -241,7 +241,7 @@ Rectangle {
Text { Text {
id: messageText id: messageText
text: (mainToolBar.messageCount > 0) ? mainToolBar.messageCount : '' text: (mainToolBar.messageCount > 0) ? mainToolBar.messageCount : ''
font.pointSize: 14 * screenTools.dpiFactor font.pointSize: screenTools.dpiAdjustedPointSize(14);
font.weight: Font.DemiBold font.weight: Font.DemiBold
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
...@@ -329,7 +329,7 @@ Rectangle { ...@@ -329,7 +329,7 @@ Rectangle {
Text { Text {
id: satelitteText id: satelitteText
text: (mainToolBar.satelliteCount > 0) ? mainToolBar.satelliteCount : '' text: (mainToolBar.satelliteCount > 0) ? mainToolBar.satelliteCount : ''
font.pointSize: 14 * screenTools.dpiFactor font.pointSize: screenTools.dpiAdjustedPointSize(14);
font.weight: Font.DemiBold font.weight: Font.DemiBold
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right anchors.right: parent.right
...@@ -364,7 +364,7 @@ Rectangle { ...@@ -364,7 +364,7 @@ Rectangle {
Text { Text {
id: batteryText id: batteryText
text: mainToolBar.batteryVoltage.toFixed(1) + ' V'; text: mainToolBar.batteryVoltage.toFixed(1) + ' V';
font.pointSize: 14 * screenTools.dpiFactor font.pointSize: screenTools.dpiAdjustedPointSize(14);
font.weight: Font.DemiBold font.weight: Font.DemiBold
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right anchors.right: parent.right
...@@ -392,7 +392,7 @@ Rectangle { ...@@ -392,7 +392,7 @@ Rectangle {
Text { Text {
id: armedStatusText id: armedStatusText
text: (mainToolBar.systemArmed) ? qsTr("ARMED") : qsTr("DISARMED") text: (mainToolBar.systemArmed) ? qsTr("ARMED") : qsTr("DISARMED")
font.pointSize: 12 * screenTools.dpiFactor font.pointSize: screenTools.dpiAdjustedPointSize(12);
font.weight: Font.DemiBold font.weight: Font.DemiBold
anchors.centerIn: parent anchors.centerIn: parent
color: (mainToolBar.systemArmed) ? colorOrangeText : colorGreenText color: (mainToolBar.systemArmed) ? colorOrangeText : colorGreenText
...@@ -411,7 +411,7 @@ Rectangle { ...@@ -411,7 +411,7 @@ Rectangle {
Text { Text {
id: stateStatusText id: stateStatusText
text: mainToolBar.currentState text: mainToolBar.currentState
font.pointSize: 12 * screenTools.dpiFactor font.pointSize: screenTools.dpiAdjustedPointSize(12);
font.weight: Font.DemiBold font.weight: Font.DemiBold
anchors.centerIn: parent anchors.centerIn: parent
color: (mainToolBar.currentState === "STANDBY") ? colorGreenText : colorRedText color: (mainToolBar.currentState === "STANDBY") ? colorGreenText : colorRedText
...@@ -432,7 +432,7 @@ Rectangle { ...@@ -432,7 +432,7 @@ Rectangle {
Text { Text {
id: modeStatusText id: modeStatusText
text: mainToolBar.currentMode text: mainToolBar.currentMode
font.pointSize: 12 * screenTools.dpiFactor font.pointSize: screenTools.dpiAdjustedPointSize(12);
font.weight: Font.DemiBold font.weight: Font.DemiBold
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
...@@ -453,7 +453,7 @@ Rectangle { ...@@ -453,7 +453,7 @@ Rectangle {
Text { Text {
id: connectionStatusText id: connectionStatusText
text: qsTr("CONNECTION LOST") text: qsTr("CONNECTION LOST")
font.pointSize: 14 * screenTools.dpiFactor font.pointSize: screenTools.dpiAdjustedPointSize(14);
font.weight: Font.DemiBold font.weight: Font.DemiBold
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
......
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