diff --git a/src/AutoPilotPlugins/PX4/FlightModesComponent.qml b/src/AutoPilotPlugins/PX4/FlightModesComponent.qml index 90bd70152d31274b34d4439d815b2c135b671b08..d809205e18be67a776eeb75ab9893eb679730348 100644 --- a/src/AutoPilotPlugins/PX4/FlightModesComponent.qml +++ b/src/AutoPilotPlugins/PX4/FlightModesComponent.qml @@ -382,7 +382,7 @@ Item { QGCLabel { text: "FLIGHT MODES CONFIG" - font.pointSize: 20 * screenTools.dpiFactor; + font.pointSize: screenTools.dpiAdjustedPointSize(20); } Item { height: 20; width: 10 } // spacer @@ -873,7 +873,7 @@ Item { QGCLabel { text: "FLIGHT MODES CONFIG" - font.pointSize: 20 * screenTools.dpiFactor; + font.pointSize: screenTools.dpiAdjustedPointSize(20); } QGCLabel { diff --git a/src/AutoPilotPlugins/PX4/PowerComponent.qml b/src/AutoPilotPlugins/PX4/PowerComponent.qml index 0fc64b10882fe9ce7ace07aa839b77a359c82b98..06d242bc468c42b106804e4711e7111570eba1a1 100644 --- a/src/AutoPilotPlugins/PX4/PowerComponent.qml +++ b/src/AutoPilotPlugins/PX4/PowerComponent.qml @@ -98,13 +98,13 @@ Rectangle { QGCLabel { text: "POWER CONFIG" - font.pointSize: 20 * screenTools.dpiFactor; + font.pointSize: screenTools.dpiAdjustedPointSize(20); } QGCLabel { text: "Battery" color: palette.text - font.pointSize: 20 * screenTools.dpiFactor; + font.pointSize: screenTools.dpiAdjustedPointSize(20); } Rectangle { @@ -208,12 +208,12 @@ Rectangle { text: "Battery Max:" color: palette.text width: 80 - font.pointSize: 12 * screenTools.dpiFactor; + font.pointSize: screenTools.dpiAdjustedPointSize(12); } QGCLabel { text: (battNumCells.value * battHighVolt.value).toFixed(1) + ' V' color: palette.text - font.pointSize: 12 * screenTools.dpiFactor; + font.pointSize: screenTools.dpiAdjustedPointSize(12); } } Row { @@ -222,12 +222,12 @@ Rectangle { text: "Battery Min:" color: palette.text width: 80 - font.pointSize: 12 * screenTools.dpiFactor; + font.pointSize: screenTools.dpiAdjustedPointSize(12); } QGCLabel { text: (battNumCells.value * battLowVolt.value).toFixed(1) + ' V' color: palette.text - font.pointSize: 12 * screenTools.dpiFactor; + font.pointSize: screenTools.dpiAdjustedPointSize(12); } } } @@ -245,7 +245,7 @@ Rectangle { QGCLabel { text: "Propeller Function" color: palette.text - font.pointSize: 20 * screenTools.dpiFactor; + font.pointSize: screenTools.dpiAdjustedPointSize(20); } Rectangle { width: parent.width @@ -259,7 +259,7 @@ Rectangle { QGCLabel { text: "Magnetometer Distortion" color: palette.text - font.pointSize: 20 * screenTools.dpiFactor; + font.pointSize: screenTools.dpiAdjustedPointSize(20); } Rectangle { width: parent.width diff --git a/src/AutoPilotPlugins/PX4/SafetyComponent.qml b/src/AutoPilotPlugins/PX4/SafetyComponent.qml index a7ad9fd90b9589a5779e6750dae0d1f28220d183..ecf3e8e7a4a7f877b5cd5011294e28d33722ba2f 100644 --- a/src/AutoPilotPlugins/PX4/SafetyComponent.qml +++ b/src/AutoPilotPlugins/PX4/SafetyComponent.qml @@ -54,7 +54,7 @@ Rectangle { QGCLabel { text: "SAFETY CONFIG" - font.pointSize: 20 * screenTools.dpiFactor; + font.pointSize: screenTools.dpiAdjustedPointSize(20); } Item { height: 20; width: 10 } // spacer @@ -62,7 +62,7 @@ Rectangle { //----------------------------------------------------------------- //-- 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 @@ -121,7 +121,7 @@ Rectangle { //----------------------------------------------------------------- //-- 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 @@ -273,12 +273,12 @@ Rectangle { QGCLabel { text: "Home loiter altitude"; color: palette.text; - enabled: homeLoiterCheckbox.checked == true + enabled: homeLoiterCheckbox.checked === true } FactTextField { id: descendField; fact: Fact { name: "RTL_DESCEND_ALT" } - enabled: homeLoiterCheckbox.checked == true + enabled: homeLoiterCheckbox.checked === true showUnits: true } } @@ -291,17 +291,17 @@ Rectangle { QGCLabel { property Fact fact: Fact { name: "NAV_RCL_OBC" } 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."; - visible: fact.value != 0 + visible: fact.value !== 0 wrapMode: Text.Wrap } QGCLabel { property Fact fact: Fact { name: "NAV_DLL_OBC" } 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."; - visible: fact.value != 0 + visible: fact.value !== 0 wrapMode: Text.Wrap } } diff --git a/src/AutoPilotPlugins/PX4/SensorsComponent.qml b/src/AutoPilotPlugins/PX4/SensorsComponent.qml index 5b2bf6475d1c96bfadc9349c096e4602cfacf312..38bdb27be1b74c5d9e95183442c815a55f6bd5f6 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponent.qml +++ b/src/AutoPilotPlugins/PX4/SensorsComponent.qml @@ -87,7 +87,7 @@ Rectangle { QGCLabel { text: "SENSORS CONFIG" - font.pointSize: 20 * screenTools.dpiFactor; + font.pointSize: screenTools.dpiAdjustedPointSize(20); } Item { height: 20; width: 10 } // spacer diff --git a/src/FactSystem/FactSystemTest.qml b/src/FactSystem/FactSystemTest.qml index 9d8daed48e66594dfcd7d838c50eb0b6c21dbc84..fa7316468c14078023fea063b0eae9a392543b93 100644 --- a/src/FactSystem/FactSystemTest.qml +++ b/src/FactSystem/FactSystemTest.qml @@ -33,7 +33,7 @@ Item { Fact { id: fact; name: "RC_MAP_THROTTLE" } text: fact.value font.family: "Helvetica" - font.pointSize: 24 * screenTools.dpiFactor; + font.pointSize: screenTools.dpiAdjustedPointSize(24); color: "red" focus: true onAccepted: { fact.value = text; } diff --git a/src/QmlControls/ScreenTools.cc b/src/QmlControls/ScreenTools.cc index 90611e0437de7dbe56729800cd25795c32cc3637..dde82a1e74eacf55ad4a6291959b80c0f9899164 100644 --- a/src/QmlControls/ScreenTools.cc +++ b/src/QmlControls/ScreenTools.cc @@ -42,6 +42,11 @@ ScreenTools::ScreenTools() connect(MainWindow::instance(), &MainWindow::repaintCanvas, this, &ScreenTools::_updateCanvas); } +qreal ScreenTools::dpiAdjustedPointSize(qreal pointSize) +{ + return pointSize * _dpiFactor; +} + void ScreenTools::_updateCanvas() { emit repaintRequestedChanged(); diff --git a/src/QmlControls/ScreenTools.h b/src/QmlControls/ScreenTools.h index 39138d008e2b202a15519b436dcb3cbef419849e..8365b9313f34fc395222d724fb569aa1d4a603bf 100644 --- a/src/QmlControls/ScreenTools.h +++ b/src/QmlControls/ScreenTools.h @@ -110,6 +110,12 @@ public: */ 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 dpiFactor () { return _dpiFactor; } int mouseX () { return QCursor::pos().x(); } diff --git a/src/QmlControls/VehicleRotationCal.qml b/src/QmlControls/VehicleRotationCal.qml index b287840a6b5f45930b779b521e014dc9a6cdf6c4..847b5069aaf3bbfff10de1ee2a459c20f16f775d 100644 --- a/src/QmlControls/VehicleRotationCal.qml +++ b/src/QmlControls/VehicleRotationCal.qml @@ -68,7 +68,7 @@ Rectangle { height: parent.height horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignBottom - font.pointSize: 25 * screenTools.dpiFactor; + font.pointSize: screenTools.dpiAdjustedPointSize(25); font.bold: true color: "black" @@ -79,7 +79,7 @@ Rectangle { height: parent.height horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignBottom - font.pointSize: 25 * screenTools.dpiFactor; + font.pointSize: screenTools.dpiAdjustedPointSize(25); color: calInProgress ? "yellow" : "white" text: parent.calText diff --git a/src/VehicleSetup/FirmwareUpgrade.qml b/src/VehicleSetup/FirmwareUpgrade.qml index dfa23872e62864a50b599b9a5c1d92540a55b8a5..3315f46f631f2835dcbda12f30721b648a4fe16d 100644 --- a/src/VehicleSetup/FirmwareUpgrade.qml +++ b/src/VehicleSetup/FirmwareUpgrade.qml @@ -51,7 +51,7 @@ Rectangle { QGCLabel { text: "FIRMWARE UPDATE" - font.pointSize: 20 * screenTools.dpiFactor; + font.pointSize: screenTools.dpiAdjustedPointSize(20); } Item { diff --git a/src/VehicleSetup/VehicleSummary.qml b/src/VehicleSetup/VehicleSummary.qml index 99323e234521035478a30eb4756a7fcffff6d2ba..d760a5d3eb3b0af6fa1b59f26122ac49860eefb7 100644 --- a/src/VehicleSetup/VehicleSummary.qml +++ b/src/VehicleSetup/VehicleSummary.qml @@ -47,7 +47,7 @@ Rectangle { QGCLabel { text: "VEHICLE SUMMARY" - font.pointSize: 20 * screenTools.dpiFactor; + font.pointSize: screenTools.dpiAdjustedPointSize(20); } Item { diff --git a/src/ui/toolbar/MainToolBar.qml b/src/ui/toolbar/MainToolBar.qml index 5f39ea290190f1ae4776c0b373718ae3c97a536f..b52ac3c2de56de90540a7b0f0b3652e59d2acfbe 100644 --- a/src/ui/toolbar/MainToolBar.qml +++ b/src/ui/toolbar/MainToolBar.qml @@ -241,7 +241,7 @@ Rectangle { Text { id: messageText text: (mainToolBar.messageCount > 0) ? mainToolBar.messageCount : '' - font.pointSize: 14 * screenTools.dpiFactor + font.pointSize: screenTools.dpiAdjustedPointSize(14); font.weight: Font.DemiBold anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter @@ -329,7 +329,7 @@ Rectangle { Text { id: satelitteText text: (mainToolBar.satelliteCount > 0) ? mainToolBar.satelliteCount : '' - font.pointSize: 14 * screenTools.dpiFactor + font.pointSize: screenTools.dpiAdjustedPointSize(14); font.weight: Font.DemiBold anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right @@ -364,7 +364,7 @@ Rectangle { Text { id: batteryText text: mainToolBar.batteryVoltage.toFixed(1) + ' V'; - font.pointSize: 14 * screenTools.dpiFactor + font.pointSize: screenTools.dpiAdjustedPointSize(14); font.weight: Font.DemiBold anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right @@ -392,7 +392,7 @@ Rectangle { Text { id: armedStatusText text: (mainToolBar.systemArmed) ? qsTr("ARMED") : qsTr("DISARMED") - font.pointSize: 12 * screenTools.dpiFactor + font.pointSize: screenTools.dpiAdjustedPointSize(12); font.weight: Font.DemiBold anchors.centerIn: parent color: (mainToolBar.systemArmed) ? colorOrangeText : colorGreenText @@ -411,7 +411,7 @@ Rectangle { Text { id: stateStatusText text: mainToolBar.currentState - font.pointSize: 12 * screenTools.dpiFactor + font.pointSize: screenTools.dpiAdjustedPointSize(12); font.weight: Font.DemiBold anchors.centerIn: parent color: (mainToolBar.currentState === "STANDBY") ? colorGreenText : colorRedText @@ -432,7 +432,7 @@ Rectangle { Text { id: modeStatusText text: mainToolBar.currentMode - font.pointSize: 12 * screenTools.dpiFactor + font.pointSize: screenTools.dpiAdjustedPointSize(12); font.weight: Font.DemiBold anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter @@ -453,7 +453,7 @@ Rectangle { Text { id: connectionStatusText text: qsTr("CONNECTION LOST") - font.pointSize: 14 * screenTools.dpiFactor + font.pointSize: screenTools.dpiAdjustedPointSize(14); font.weight: Font.DemiBold anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter