Commit 890ea6ab authored by Don Gagne's avatar Don Gagne

Merge pull request #1657 from dogmaphobic/fontToPixels

Font to pixels
parents 0ac8e637 99eb55f1
...@@ -2,12 +2,16 @@ ...@@ -2,12 +2,16 @@
This is the master style sheet as well as the dark style. This style sheet should contain both This is the master style sheet as well as the dark style. This style sheet should contain both
color and size/positioning information for all styled controls. This sheet is always loaded first color and size/positioning information for all styled controls. This sheet is always loaded first
Then the user specified style sheet is loaded after it to override and color settings. Then the user specified style sheet is loaded after it to override and color settings.
Font sizes are defined with tokens, which are parsed and replaced at run time.
*/ */
* { * {
background-color: #222; background-color: #222;
color: #FFF; color: #FFF;
font-size: 12pt; font-size: FONT_NORMAL;
font-weight: lighter;
} }
QWidget#viewModeWidget { QWidget#viewModeWidget {
...@@ -128,7 +132,7 @@ QGroupBox::title { ...@@ -128,7 +132,7 @@ QGroupBox::title {
subcontrol-position: top center; subcontrol-position: top center;
margin: 0 3px 0 3px; margin: 0 3px 0 3px;
padding: 0 3px 0 0; padding: 0 3px 0 0;
font: bold 8px; font: bold FONT_SMALL;
color: #DDD; color: #DDD;
} }
...@@ -149,7 +153,7 @@ QLabel:disabled { ...@@ -149,7 +153,7 @@ QLabel:disabled {
} }
QLabel#noUas { QLabel#noUas {
font-size: 30pt; font-size: FONT_LARGE;
} }
QMessageBox { QMessageBox {
...@@ -158,7 +162,7 @@ QMessageBox { ...@@ -158,7 +162,7 @@ QMessageBox {
} }
QLabel#tabTitleLabel { QLabel#tabTitleLabel {
font-size: 28pt; font-size: FONT_LARGE;
font-weight: lighter; font-weight: lighter;
margin-top: 16px; margin-top: 16px;
margin-bottom: 8px; margin-bottom: 8px;
...@@ -166,7 +170,7 @@ QLabel#tabTitleLabel { ...@@ -166,7 +170,7 @@ QLabel#tabTitleLabel {
QLabel#instructionLabel { QLabel#instructionLabel {
color: #FEC654; color: #FEC654;
font-size: 26pt; font-size: FONT_LARGE;
} }
QLineEdit { QLineEdit {
...@@ -226,7 +230,7 @@ QPlainTextEdit { ...@@ -226,7 +230,7 @@ QPlainTextEdit {
border: 1px solid #777; border: 1px solid #777;
border-radius: 2px; border-radius: 2px;
font-family: "Monospace"; font-family: "Monospace";
font: large; font: FONT_SMALL;
} }
QProgressBar { QProgressBar {
...@@ -529,11 +533,10 @@ UASQuickViewItem QLabel { ...@@ -529,11 +533,10 @@ UASQuickViewItem QLabel {
padding: 0; padding: 0;
margin: 0; margin: 0;
min-height: 1em; min-height: 1em;
font-weight: bold;
} }
UASQuickViewItem QLabel#value { UASQuickViewItem QLabel#value {
font-size: 20pt; font-size: FONT_LARGE;
} }
UASView { UASView {
......
...@@ -97,7 +97,7 @@ QGCView { ...@@ -97,7 +97,7 @@ QGCView {
QGCLabel { QGCLabel {
id: header id: header
width: parent.width width: parent.width
font.pointSize: ScreenTools.largeFontPointSize font.pixelSize: ScreenTools.largeFontPixelSize
text: "AIRFRAME CONFIG" text: "AIRFRAME CONFIG"
} }
...@@ -225,4 +225,4 @@ QGCView { ...@@ -225,4 +225,4 @@ QGCView {
} // Flow - summary boxes } // Flow - summary boxes
} // Scroll View - summary boxes } // Scroll View - summary boxes
} // QGCViewPanel } // QGCViewPanel
} // QGCView } // QGCView
\ No newline at end of file
...@@ -384,7 +384,7 @@ Item { ...@@ -384,7 +384,7 @@ Item {
QGCLabel { QGCLabel {
text: "FLIGHT MODES CONFIG" text: "FLIGHT MODES CONFIG"
font.pointSize: ScreenTools.largeFontPointSize font.pixelSize: ScreenTools.largeFontPixelSize
} }
Item { height: 20; width: 10 } // spacer Item { height: 20; width: 10 } // spacer
...@@ -973,7 +973,7 @@ Item { ...@@ -973,7 +973,7 @@ Item {
QGCLabel { QGCLabel {
text: "FLIGHT MODES CONFIG" text: "FLIGHT MODES CONFIG"
font.pointSize: ScreenTools.fontPointFactor * (20); font.pixelSize: ScreenTools.font20;
} }
QGCLabel { QGCLabel {
......
...@@ -115,12 +115,12 @@ QGCView { ...@@ -115,12 +115,12 @@ QGCView {
QGCLabel { QGCLabel {
text: "POWER CONFIG" text: "POWER CONFIG"
font.pointSize: ScreenTools.largeFontPointSize font.pixelSize: ScreenTools.largeFontPixelSize
} }
QGCLabel { QGCLabel {
text: "Battery" text: "Battery"
font.pointSize: ScreenTools.mediumFontPointSize font.pixelSize: ScreenTools.mediumFontPixelSize
} }
Rectangle { Rectangle {
...@@ -234,7 +234,7 @@ QGCView { ...@@ -234,7 +234,7 @@ QGCView {
QGCLabel { QGCLabel {
text: "ESC Calibration" text: "ESC Calibration"
font.pointSize: ScreenTools.mediumFontPointSize font.pixelSize: ScreenTools.mediumFontPixelSize
} }
Rectangle { Rectangle {
...@@ -269,7 +269,7 @@ QGCView { ...@@ -269,7 +269,7 @@ QGCView {
width: (parent.width / 2) - 5 width: (parent.width / 2) - 5
QGCLabel { QGCLabel {
text: "Propeller Function" text: "Propeller Function"
font.pointSize: ScreenTools.fontPointFactor * (20); font.pixelSize: ScreenTools.font20;
} }
Rectangle { Rectangle {
width: parent.width width: parent.width
...@@ -282,7 +282,7 @@ QGCView { ...@@ -282,7 +282,7 @@ QGCView {
width: (parent.width / 2) - 5 width: (parent.width / 2) - 5
QGCLabel { QGCLabel {
text: "Magnetometer Distortion" text: "Magnetometer Distortion"
font.pointSize: ScreenTools.fontPointFactor * (20); font.pixelSize: ScreenTools.font20;
} }
Rectangle { Rectangle {
width: parent.width width: parent.width
...@@ -301,7 +301,7 @@ QGCView { ...@@ -301,7 +301,7 @@ QGCView {
} }
QGCLabel { QGCLabel {
text: "Advanced Power Settings" text: "Advanced Power Settings"
font.pointSize: ScreenTools.fontPointFactor * (20); font.pixelSize: ScreenTools.font20;
visible: showAdvanced.checked visible: showAdvanced.checked
} }
Rectangle { Rectangle {
......
...@@ -258,7 +258,7 @@ QGCView { ...@@ -258,7 +258,7 @@ QGCView {
QGCLabel { QGCLabel {
id: header id: header
font.pointSize: ScreenTools.largeFontPointSize font.pixelSize: ScreenTools.largeFontPixelSize
text: "RADIO CONFIG" text: "RADIO CONFIG"
} }
......
...@@ -52,7 +52,7 @@ FactPanel { ...@@ -52,7 +52,7 @@ FactPanel {
QGCLabel { QGCLabel {
text: "SAFETY CONFIG" text: "SAFETY CONFIG"
font.pointSize: ScreenTools.largeFontPointSize font.pixelSize: ScreenTools.largeFontPixelSize
} }
Item { height: 20; width: 10 } // spacer Item { height: 20; width: 10 } // spacer
...@@ -60,7 +60,7 @@ FactPanel { ...@@ -60,7 +60,7 @@ FactPanel {
//----------------------------------------------------------------- //-----------------------------------------------------------------
//-- Return Home Triggers //-- Return Home Triggers
QGCLabel { text: "Triggers For Return Home"; font.pointSize: ScreenTools.mediumFontPointSize; } QGCLabel { text: "Triggers For Return Home"; font.pixelSize: ScreenTools.mediumFontPixelSize; }
Item { height: 10; width: 10 } // spacer Item { height: 10; width: 10 } // spacer
...@@ -119,7 +119,7 @@ FactPanel { ...@@ -119,7 +119,7 @@ FactPanel {
//----------------------------------------------------------------- //-----------------------------------------------------------------
//-- Return Home Settings //-- Return Home Settings
QGCLabel { text: "Return Home Settings"; font.pointSize: ScreenTools.mediumFontPointSize; } QGCLabel { text: "Return Home Settings"; font.pixelSize: ScreenTools.mediumFontPixelSize; }
Item { height: 10; width: 10 } // spacer Item { height: 10; width: 10 } // spacer
...@@ -290,7 +290,7 @@ FactPanel { ...@@ -290,7 +290,7 @@ FactPanel {
QGCLabel { QGCLabel {
width: parent.width width: parent.width
font.pointSize: ScreenTools.mediumFontPointSize font.pixelSize: ScreenTools.mediumFontPixelSize
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
...@@ -300,7 +300,7 @@ FactPanel { ...@@ -300,7 +300,7 @@ FactPanel {
QGCLabel { QGCLabel {
width: parent.width width: parent.width
font.pointSize: ScreenTools.mediumFontPointSize font.pixelSize: ScreenTools.mediumFontPixelSize
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
......
...@@ -57,8 +57,8 @@ QGCView { ...@@ -57,8 +57,8 @@ QGCView {
// Used to pass help text to the preCalibrationDialog dialog // Used to pass help text to the preCalibrationDialog dialog
property string preCalibrationDialogHelp property string preCalibrationDialogHelp
readonly property int sideBarH1PointSize: (ScreenTools.defaultFontPointSize * 1.3 + 0.5) readonly property int sideBarH1PointSize: ScreenTools.mediumFontPixelSize
readonly property int mainTextH1PointSize: (ScreenTools.defaultFontPointSize * 1.5 + 0.5) readonly property int mainTextH1PointSize: ScreenTools.mediumFontPixelSize // Seems to be unused
readonly property int rotationColumnWidth: 250 readonly property int rotationColumnWidth: 250
readonly property var rotations: [ readonly property var rotations: [
...@@ -213,7 +213,7 @@ QGCView { ...@@ -213,7 +213,7 @@ QGCView {
id: compass0ComponentLabel id: compass0ComponentLabel
QGCLabel { QGCLabel {
font.pointSize: sideBarH1PointSize font.pixelSize: sideBarH1PointSize
text: "External Compass Orientation" text: "External Compass Orientation"
} }
...@@ -280,7 +280,7 @@ QGCView { ...@@ -280,7 +280,7 @@ QGCView {
QGCLabel { QGCLabel {
text: "SENSORS CONFIG" text: "SENSORS CONFIG"
font.pointSize: ScreenTools.largeFontPointSize font.pixelSize: ScreenTools.largeFontPixelSize
} }
Item { height: 20; width: 10 } // spacer Item { height: 20; width: 10 } // spacer
...@@ -408,7 +408,7 @@ QGCView { ...@@ -408,7 +408,7 @@ QGCView {
id: orientationCalAreaHelpText id: orientationCalAreaHelpText
width: parent.width width: parent.width
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
font.pointSize: ScreenTools.fontPointFactor * (22); font.pixelSize: ScreenTools.font22;
anchors.top: orientationCalArea.top anchors.top: orientationCalArea.top
anchors.left: orientationCalArea.left anchors.left: orientationCalArea.left
anchors.topMargin: 15 anchors.topMargin: 15
...@@ -480,7 +480,7 @@ QGCView { ...@@ -480,7 +480,7 @@ QGCView {
spacing: 5 spacing: 5
QGCLabel { QGCLabel {
font.pointSize: sideBarH1PointSize font.pixelSize: sideBarH1PointSize
text: "Autopilot Orientation" text: "Autopilot Orientation"
} }
...@@ -506,7 +506,7 @@ QGCView { ...@@ -506,7 +506,7 @@ QGCView {
id: compass0ComponentLabel2 id: compass0ComponentLabel2
QGCLabel { QGCLabel {
font.pointSize: sideBarH1PointSize font.pixelSize: sideBarH1PointSize
text: "External Compass Orientation" text: "External Compass Orientation"
} }
} }
...@@ -531,7 +531,7 @@ QGCView { ...@@ -531,7 +531,7 @@ QGCView {
id: compass1ComponentLabel2 id: compass1ComponentLabel2
QGCLabel { QGCLabel {
font.pointSize: sideBarH1PointSize font.pixelSize: sideBarH1PointSize
text: "External Compass 1 Orientation" text: "External Compass 1 Orientation"
} }
} }
...@@ -556,7 +556,7 @@ QGCView { ...@@ -556,7 +556,7 @@ QGCView {
id: compass2ComponentLabel2 id: compass2ComponentLabel2
QGCLabel { QGCLabel {
font.pointSize: sidebarH1PointSize font.pixelSize: sidebarH1PointSize
text: "Compass 2 Orientation" text: "Compass 2 Orientation"
} }
} }
......
...@@ -655,33 +655,16 @@ void QGCApplication::_loadCurrentStyle(void) ...@@ -655,33 +655,16 @@ void QGCApplication::_loadCurrentStyle(void)
} }
} }
// Now that we have the styles loaded we need to dpi adjust the font point sizes // Now that we have the styles loaded we need to adjust the font sizes.
QString dpiAdjustedStyles;
if (success) {
QTextStream styleStream(&styles, QIODevice::ReadOnly);
QRegularExpression regex("font-size:.+(\\d\\d)pt;");
while (!styleStream.atEnd()) {
QString adjustedLine;
QString line = styleStream.readLine();
QRegularExpressionMatch match = regex.match(line);
if (match.hasMatch()) {
//qDebug() << "found:" << line << match.captured(1);
adjustedLine = QString("font-size: %1pt;").arg(ScreenTools::adjustFontPointSize_s(match.captured(1).toDouble()));
//qDebug() << "adjusted:" << adjustedLine;
} else {
adjustedLine = line;
}
dpiAdjustedStyles += adjustedLine;
}
}
if (!dpiAdjustedStyles.isEmpty()) { QString fSmall = QString("%1px;").arg(ScreenTools::font10_s());
setStyleSheet(dpiAdjustedStyles); QString fNormal = QString("%1px;").arg(ScreenTools::defaultFontPizelSize_s());
} QString fLarge = QString("%1px;").arg(ScreenTools::largeFontPixelSize_s());
styles.replace("FONT_SMALL", fSmall);
styles.replace("FONT_NORMAL", fNormal);
styles.replace("FONT_LARGE", fLarge);
setStyleSheet(styles);
if (!success) { if (!success) {
// Fall back to plastique if we can't load our own // Fall back to plastique if we can't load our own
......
...@@ -66,7 +66,7 @@ QGCView { ...@@ -66,7 +66,7 @@ QGCView {
height: defaultTextHeight + (ScreenTools.pixelSizeFactor * (9)) height: defaultTextHeight + (ScreenTools.pixelSizeFactor * (9))
text: group text: group
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
font.pointSize: ScreenTools.fontPointFactor * (16); font.pixelSize: ScreenTools.font16;
} }
Rectangle { Rectangle {
...@@ -142,7 +142,7 @@ QGCView { ...@@ -142,7 +142,7 @@ QGCView {
height: firstButton.height height: firstButton.height
QGCLabel { QGCLabel {
font.pointSize: ScreenTools.fontPointFactor * (20) font.pixelSize: ScreenTools.font20;
visible: fullMode visible: fullMode
text: "PARAMETER EDITOR" text: "PARAMETER EDITOR"
} }
...@@ -202,7 +202,7 @@ QGCView { ...@@ -202,7 +202,7 @@ QGCView {
height: contentHeight + (ScreenTools.pixelSizeFactor * (9)) height: contentHeight + (ScreenTools.pixelSizeFactor * (9))
text: "Component #: " + componentId.toString() text: "Component #: " + componentId.toString()
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
font.pointSize: ScreenTools.fontPointFactor * (16); font.pixelSize: ScreenTools.font16;
} }
Repeater { Repeater {
...@@ -357,4 +357,4 @@ QGCView { ...@@ -357,4 +357,4 @@ QGCView {
} }
} // Rectangle - editorDialog } // Rectangle - editorDialog
} // Component - Editor Dialog } // Component - Editor Dialog
} // QGCView } // QGCView
\ No newline at end of file
...@@ -104,7 +104,7 @@ Button { ...@@ -104,7 +104,7 @@ Button {
id: text id: text
antialiasing: true antialiasing: true
text: control.text text: control.text
font.pointSize: ScreenTools.defaultFontPointSize font.pixelSize: ScreenTools.defaultFontPizelSize
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
......
...@@ -29,7 +29,7 @@ CheckBox { ...@@ -29,7 +29,7 @@ CheckBox {
id: text id: text
text: control.text text: control.text
antialiasing: true antialiasing: true
font.pointSize: ScreenTools.defaultFontPointSize font.pixelSize: ScreenTools.defaultFontPizelSize
anchors.centerIn: parent anchors.centerIn: parent
......
...@@ -11,7 +11,7 @@ ComboBox { ...@@ -11,7 +11,7 @@ ComboBox {
property bool __showHighlight: pressed | hovered property bool __showHighlight: pressed | hovered
style: ComboBoxStyle { style: ComboBoxStyle {
font.pointSize: ScreenTools.defaultFontPointSize font.pixelSize: ScreenTools.defaultFontPizelSize
textColor: __showHighlight ? textColor: __showHighlight ?
control.__qgcPal.buttonHighlightText : control.__qgcPal.buttonHighlightText :
control.__qgcPal.buttonText control.__qgcPal.buttonText
......
...@@ -10,7 +10,7 @@ Text { ...@@ -10,7 +10,7 @@ Text {
property bool enabled: true property bool enabled: true
font.pointSize: ScreenTools.defaultFontPointSize font.pixelSize: ScreenTools.defaultFontPizelSize
color: __qgcPal.text color: __qgcPal.text
antialiasing: true antialiasing: true
} }
...@@ -28,7 +28,7 @@ RadioButton { ...@@ -28,7 +28,7 @@ RadioButton {
Text { Text {
id: text id: text
text: control.text text: control.text
font.pointSize: ScreenTools.defaultFontPointSize font.pixelSize: ScreenTools.defaultFontPizelSize
antialiasing: true antialiasing: true
anchors.centerIn: parent anchors.centerIn: parent
......
...@@ -50,7 +50,7 @@ TextField { ...@@ -50,7 +50,7 @@ TextField {
width: unitsLabelWidthGenerator.width width: unitsLabelWidthGenerator.width
text: control.unitsLabel text: control.unitsLabel
font.pointSize: ScreenTools.defaultFontPointSize font.pixelSize: ScreenTools.defaultFontPizelSize
antialiasing: true antialiasing: true
color: control.textColor color: control.textColor
......
...@@ -27,35 +27,55 @@ ...@@ -27,35 +27,55 @@
#include "ScreenTools.h" #include "ScreenTools.h"
#include "MainWindow.h" #include "MainWindow.h"
#include <QFont> // Pixel size, instead of a physical thing is actually a philosophical question when
#include <QFontMetrics> // it comes to Qt.
// The values below came from actually measuring the elements on the screen on these
const double ScreenTools::_defaultFontPointSize = 13; // devices. I have yet to find a constant from Qt so these things can be properly
const double ScreenTools::_mediumFontPointSize = 16; // computed at runtime.
const double ScreenTools::_largeFontPointSize = 20;
#if defined(Q_OS_OSX)
double ScreenTools::_pixelFactor = 1.0;
#elif defined(__ios__)
double ScreenTools::_pixelFactor = 0.75;
#elif defined(Q_OS_WIN)
double ScreenTools::_pixelFactor = 0.86;
#elif defined(__android__)
double ScreenTools::_pixelFactor = 2.5;
#elif defined(Q_OS_LINUX)
double ScreenTools::_pixelFactor = 1.0;
#endif
#if defined(__android__)
#define FONT_FACTOR 2
#else
#define FONT_FACTOR 1
#endif
int ScreenTools::_font8 = 8 * FONT_FACTOR;
int ScreenTools::_font9 = 9 * FONT_FACTOR;
int ScreenTools::_font10 = 10 * FONT_FACTOR;
int ScreenTools::_font11 = 11 * FONT_FACTOR;
int ScreenTools::_font12 = 12 * FONT_FACTOR;
int ScreenTools::_font13 = 13 * FONT_FACTOR;
int ScreenTools::_font14 = 14 * FONT_FACTOR;
int ScreenTools::_font15 = 15 * FONT_FACTOR;
int ScreenTools::_font16 = 16 * FONT_FACTOR;
int ScreenTools::_font17 = 17 * FONT_FACTOR;
int ScreenTools::_font18 = 18 * FONT_FACTOR;
int ScreenTools::_font19 = 19 * FONT_FACTOR;
int ScreenTools::_font20 = 20 * FONT_FACTOR;
int ScreenTools::_font21 = 21 * FONT_FACTOR;
int ScreenTools::_font22 = 22 * FONT_FACTOR;
ScreenTools::ScreenTools() ScreenTools::ScreenTools()
{ {
MainWindow* mainWindow = MainWindow::instance(); MainWindow* mainWindow = MainWindow::instance();
// Unit tests can run Qml without MainWindow // Unit tests can run Qml without MainWindow
if (mainWindow) { if (mainWindow) {
connect(mainWindow, &MainWindow::repaintCanvas, this, &ScreenTools::_updateCanvas); connect(mainWindow, &MainWindow::repaintCanvas, this, &ScreenTools::_updateCanvas);
connect(mainWindow, &MainWindow::pixelSizeChanged, this, &ScreenTools::_updatePixelSize);
connect(mainWindow, &MainWindow::fontSizeChanged, this, &ScreenTools::_updateFontSize);
} }
} }
qreal ScreenTools::adjustFontPointSize(qreal pointSize)
{
return adjustFontPointSize_s(pointSize);
}
qreal ScreenTools::adjustFontPointSize_s(qreal pointSize)
{
return pointSize * MainWindow::fontPointFactor();
}
qreal ScreenTools::adjustPixelSize(qreal pixelSize) qreal ScreenTools::adjustPixelSize(qreal pixelSize)
{ {
return adjustPixelSize_s(pixelSize); return adjustPixelSize_s(pixelSize);
...@@ -63,66 +83,10 @@ qreal ScreenTools::adjustPixelSize(qreal pixelSize) ...@@ -63,66 +83,10 @@ qreal ScreenTools::adjustPixelSize(qreal pixelSize)
qreal ScreenTools::adjustPixelSize_s(qreal pixelSize) qreal ScreenTools::adjustPixelSize_s(qreal pixelSize)
{ {
return pixelSize * MainWindow::pixelSizeFactor(); return pixelSize * _pixelFactor;
}
void ScreenTools::increasePixelSize()
{
MainWindow::instance()->setPixelSizeFactor(MainWindow::pixelSizeFactor() + 0.025);
}
void ScreenTools::decreasePixelSize()
{
MainWindow::instance()->setPixelSizeFactor(MainWindow::pixelSizeFactor() - 0.025);
}
void ScreenTools::increaseFontSize()
{
MainWindow::instance()->setFontSizeFactor(MainWindow::fontPointFactor() + 0.025);
}
void ScreenTools::decreaseFontSize()
{
MainWindow::instance()->setFontSizeFactor(MainWindow::fontPointFactor() - 0.025);
} }
void ScreenTools::_updateCanvas() void ScreenTools::_updateCanvas()
{ {
emit repaintRequestedChanged(); emit repaintRequestedChanged();
} }
void ScreenTools::_updatePixelSize()
{
emit pixelSizeFactorChanged();
}
void ScreenTools::_updateFontSize()
{
emit fontPointFactorChanged();
emit fontSizesChanged();
}
double ScreenTools::fontPointFactor()
{
return MainWindow::fontPointFactor();
}
double ScreenTools::pixelSizeFactor()
{
return MainWindow::pixelSizeFactor();
}
double ScreenTools::defaultFontPointSize(void)
{
return _defaultFontPointSize * MainWindow::fontPointFactor();
}
double ScreenTools::mediumFontPointSize(void)
{
return _mediumFontPointSize * MainWindow::fontPointFactor();
}
double ScreenTools::largeFontPointSize(void)
{
return _largeFontPointSize * MainWindow::fontPointFactor();
}
...@@ -80,46 +80,87 @@ public: ...@@ -80,46 +80,87 @@ public:
@endcode @endcode
*/ */
Q_PROPERTY(bool repaintRequested READ repaintRequested NOTIFY repaintRequestedChanged) //! Font sizes
//! Returns the font point size factor Q_PROPERTY(int font22 READ font22 CONSTANT)
Q_PROPERTY(double fontPointFactor READ fontPointFactor NOTIFY fontPointFactorChanged) Q_PROPERTY(int font21 READ font21 CONSTANT)
//! Returns the pixel size factor Q_PROPERTY(int font20 READ font20 CONSTANT)
Q_PROPERTY(double pixelSizeFactor READ pixelSizeFactor NOTIFY pixelSizeFactorChanged) Q_PROPERTY(int font19 READ font19 CONSTANT)
Q_PROPERTY(int font18 READ font18 CONSTANT)
Q_PROPERTY(int font17 READ font17 CONSTANT)
Q_PROPERTY(int font16 READ font16 CONSTANT)
Q_PROPERTY(int font15 READ font15 CONSTANT)
Q_PROPERTY(int font14 READ font14 CONSTANT)
Q_PROPERTY(int font13 READ font13 CONSTANT)
Q_PROPERTY(int font12 READ font12 CONSTANT)
Q_PROPERTY(int font11 READ font11 CONSTANT)
Q_PROPERTY(int font10 READ font10 CONSTANT)
Q_PROPERTY(int font9 READ font9 CONSTANT)
Q_PROPERTY(int font8 READ font8 CONSTANT)
//! Returns the system wide default font point size (properly scaled) //! Returns the system wide default font point size (properly scaled)
Q_PROPERTY(double defaultFontPointSize READ defaultFontPointSize NOTIFY fontSizesChanged) Q_PROPERTY(int defaultFontPizelSize READ defaultFontPizelSize CONSTANT)
//! Returns the system wide default font point size (properly scaled) //! Returns the system wide default font point size (properly scaled)
Q_PROPERTY(double mediumFontPointSize READ mediumFontPointSize NOTIFY fontSizesChanged) Q_PROPERTY(int mediumFontPixelSize READ mediumFontPixelSize CONSTANT)
//! Returns the system wide default font point size (properly scaled) //! Returns the system wide default font point size (properly scaled)
Q_PROPERTY(double largeFontPointSize READ largeFontPointSize NOTIFY fontSizesChanged) Q_PROPERTY(int largeFontPixelSize READ largeFontPixelSize CONSTANT)
//! Utility for adjusting font point size. Not dynamic (no signals) Q_PROPERTY(bool repaintRequested READ repaintRequested NOTIFY repaintRequestedChanged)
Q_INVOKABLE qreal adjustFontPointSize(qreal pointSize); //! Returns the pixel size factor
Q_PROPERTY(double pixelSizeFactor READ pixelSizeFactor CONSTANT)
//! Utility for adjusting pixel size. Not dynamic (no signals) //! Utility for adjusting pixel size. Not dynamic (no signals)
Q_INVOKABLE qreal adjustPixelSize(qreal pixelSize); Q_INVOKABLE qreal adjustPixelSize(qreal pixelSize);
//! Utility for increasing pixel size.
Q_INVOKABLE void increasePixelSize();
//! Utility for decreasing pixel size.
Q_INVOKABLE void decreasePixelSize();
//! Utility for increasing font size.
Q_INVOKABLE void increaseFontSize();
//! Utility for decreasing font size.
Q_INVOKABLE void decreaseFontSize();
/// Static version of adjustFontPointSize of use in C++ code
static qreal adjustFontPointSize_s(qreal pointSize);
/// Static version of adjustPixelSize of use in C++ code /// Static version of adjustPixelSize of use in C++ code
static qreal adjustPixelSize_s(qreal pixelSize); static qreal adjustPixelSize_s(qreal pixelSize);
int mouseX () { return QCursor::pos().x(); } int mouseX () { return QCursor::pos().x(); }
int mouseY () { return QCursor::pos().y(); } int mouseY () { return QCursor::pos().y(); }
bool repaintRequested () { return true; } bool repaintRequested () { return true; }
double fontPointFactor (); double pixelSizeFactor () { return _pixelFactor; }
double pixelSizeFactor ();
double defaultFontPointSize(void); int font22 () { return _font22; }
double mediumFontPointSize(void); int font21 () { return _font21; }
double largeFontPointSize(void); int font20 () { return _font20; }
int font19 () { return _font19; }
int font18 () { return _font18; }
int font17 () { return _font17; }
int font16 () { return _font16; }
int font15 () { return _font15; }
int font14 () { return _font14; }
int font13 () { return _font13; }
int font12 () { return _font12; }
int font11 () { return _font11; }
int font10 () { return _font10; }
int font9 () { return _font9; }
int font8 () { return _font8; }
int defaultFontPizelSize () { return _font12; }
int mediumFontPixelSize () { return _font16; }
int largeFontPixelSize () { return _font20; }
/// Static version for use in C++ code
static int font22_s () { return _font22; }
static int font21_s () { return _font21; }
static int font20_s () { return _font20; }
static int font19_s () { return _font19; }
static int font18_s () { return _font18; }
static int font17_s () { return _font17; }
static int font16_s () { return _font16; }
static int font15_s () { return _font15; }
static int font14_s () { return _font14; }
static int font13_s () { return _font13; }
static int font12_s () { return _font12; }
static int font11_s () { return _font11; }
static int font10_s () { return _font10; }
static int font9_s () { return _font9; }
static int font8_s () { return _font8; }
static int defaultFontPizelSize_s () { return _font12; }
static int mediumFontPixelSize_s () { return _font16; }
static int largeFontPixelSize_s () { return _font20; }
static double pixelSizeFactor_s () { return _pixelFactor; }
#if defined (__android__) #if defined (__android__)
bool isAndroid () { return true; } bool isAndroid () { return true; }
...@@ -137,19 +178,29 @@ public: ...@@ -137,19 +178,29 @@ public:
signals: signals:
void repaintRequestedChanged(); void repaintRequestedChanged();
void pixelSizeFactorChanged();
void fontPointFactorChanged();
void fontSizesChanged();
private slots: private slots:
void _updateCanvas(); void _updateCanvas();
void _updatePixelSize();
void _updateFontSize();
private: private:
static const double _defaultFontPointSize; // Font Sizes
static const double _mediumFontPointSize; static int _font8;
static const double _largeFontPointSize; static int _font9;
static int _font10;
static int _font11;
static int _font12;
static int _font13;
static int _font14;
static int _font15;
static int _font16;
static int _font17;
static int _font18;
static int _font19;
static int _font20;
static int _font21;
static int _font22;
// UI Dimension Factors
static double _pixelFactor;
}; };
#endif #endif
...@@ -40,7 +40,7 @@ Button { ...@@ -40,7 +40,7 @@ Button {
horizontalAlignment: TextEdit.AlignHCenter horizontalAlignment: TextEdit.AlignHCenter
text: control.text text: control.text
font.pointSize: ScreenTools.defaultFontPointSize font.pixelSize: ScreenTools.defaultFontPizelSize
antialiasing: true antialiasing: true
color: __showHighlight ? __qgcPal.buttonHighlightText : __qgcPal.buttonText color: __showHighlight ? __qgcPal.buttonHighlightText : __qgcPal.buttonText
......
...@@ -70,10 +70,9 @@ Rectangle { ...@@ -70,10 +70,9 @@ Rectangle {
height: parent.height height: parent.height
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignBottom verticalAlignment: Text.AlignBottom
font.pointSize: ScreenTools.fontPointFactor * (25); font.pixelSize: ScreenTools.font22;
font.bold: true font.bold: true
color: "black" color: "black"
text: parent.calText text: parent.calText
} }
QGCLabel { QGCLabel {
...@@ -81,9 +80,8 @@ Rectangle { ...@@ -81,9 +80,8 @@ Rectangle {
height: parent.height height: parent.height
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignBottom verticalAlignment: Text.AlignBottom
font.pointSize: ScreenTools.fontPointFactor * (25); font.pixelSize: ScreenTools.font22;
color: calInProgress ? "yellow" : "white" color: calInProgress ? "yellow" : "white"
text: parent.calText text: parent.calText
} }
} }
......
...@@ -74,7 +74,7 @@ QGCView { ...@@ -74,7 +74,7 @@ QGCView {
QGCLabel { QGCLabel {
text: "FIRMWARE UPDATE" text: "FIRMWARE UPDATE"
font.pointSize: ScreenTools.fontPointFactor * (20); font.pixelSize: ScreenTools.font20;
} }
Item { Item {
...@@ -177,7 +177,7 @@ QGCView { ...@@ -177,7 +177,7 @@ QGCView {
height: 300 height: 300
readOnly: true readOnly: true
frameVisible: false frameVisible: false
font.pointSize: ScreenTools.defaultFontPointSize font.pixelSize: ScreenTools.defaultFontPizelSize
text: qsTr("Please disconnect all vehicles from QGroundControl before selecting Upgrade.") text: qsTr("Please disconnect all vehicles from QGroundControl before selecting Upgrade.")
...@@ -188,4 +188,4 @@ QGCView { ...@@ -188,4 +188,4 @@ QGCView {
} }
} // Column } // Column
} // QGCViewPanel } // QGCViewPanel
} // QGCView } // QGCView
\ No newline at end of file
...@@ -114,7 +114,7 @@ Rectangle { ...@@ -114,7 +114,7 @@ Rectangle {
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
font.pointSize: ScreenTools.mediumFontPointSize font.pixelSize: ScreenTools.mediumFontPixelSize
text: "Welcome to QGroundControl. " + text: "Welcome to QGroundControl. " +
"QGroundControl supports any <font color=\"orange\"><a href=\"http://www.qgroundcontrol.org/mavlink/start\">mavlink</a></font> enabled vehicle. " + "QGroundControl supports any <font color=\"orange\"><a href=\"http://www.qgroundcontrol.org/mavlink/start\">mavlink</a></font> enabled vehicle. " +
"If you are using the <font color=\"orange\"><a href=\"https://pixhawk.org/choice\">PX4 Flight Stack</a></font>, you also get full support for setting up and calibrating your vehicle. "+ "If you are using the <font color=\"orange\"><a href=\"https://pixhawk.org/choice\">PX4 Flight Stack</a></font>, you also get full support for setting up and calibrating your vehicle. "+
...@@ -136,7 +136,7 @@ Rectangle { ...@@ -136,7 +136,7 @@ Rectangle {
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
font.pointSize: ScreenTools.mediumFontPointSize font.pixelSize: ScreenTools.mediumFontPixelSize
text: messagePanelText text: messagePanelText
} }
} }
......
...@@ -46,7 +46,7 @@ Rectangle { ...@@ -46,7 +46,7 @@ Rectangle {
QGCLabel { QGCLabel {
text: "VEHICLE SUMMARY" text: "VEHICLE SUMMARY"
font.pointSize: ScreenTools.fontPointFactor * (20); font.pixelSize: ScreenTools.font20;
} }
Item { Item {
...@@ -59,7 +59,7 @@ Rectangle { ...@@ -59,7 +59,7 @@ Rectangle {
width: parent.width width: parent.width
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
color: setupComplete ? qgcPal.text : "red" color: setupComplete ? qgcPal.text : "red"
font.pointSize: setupComplete ? ScreenTools.defaultFontPointSize : ScreenTools.fontPointFactor * (20) font.pixelSize: setupComplete ? ScreenTools.defaultFontPizelSize : ScreenTools.font20
text: setupComplete ? text: setupComplete ?
"Below you will find a summary of the settings for your vehicle. To the left are the setup menus for each component." : "Below you will find a summary of the settings for your vehicle. To the left are the setup menus for each component." :
"WARNING: Your vehicle requires setup prior to flight. Please resolve the items marked in red using the menu on the left." "WARNING: Your vehicle requires setup prior to flight. Please resolve the items marked in red using the menu on the left."
......
...@@ -83,29 +83,6 @@ This file is part of the QGROUNDCONTROL project ...@@ -83,29 +83,6 @@ This file is part of the QGROUNDCONTROL project
#include "LogCompressor.h" #include "LogCompressor.h"
// Pixel size, instead of a physical thing is actually a philosophical question when
// it comes to Qt. Fonts are that and some heavy Kabalistic Voodoo added to the mix.
// The values below came from actually measuring the elements on the screen on these
// devices. I have yet to find a constant from Qt so these things can be properly
// computed at runtime.
#if defined(Q_OS_OSX)
double MainWindow::_pixelFactor = 1.0;
double MainWindow::_fontFactor = 1.0;
#elif defined(__ios__)
double MainWindow::_pixelFactor = 1.0;
double MainWindow::_fontFactor = 1.0;
#elif defined(Q_OS_WIN)
double MainWindow::_pixelFactor = 0.86;
double MainWindow::_fontFactor = 0.63;
#elif defined(__android__)
double MainWindow::_pixelFactor = 2.0;
double MainWindow::_fontFactor = 1.23;
#elif defined(Q_OS_LINUX)
double MainWindow::_pixelFactor = 1.0;
double MainWindow::_fontFactor = 0.85;
#endif
/// The key under which the Main Window settings are saved /// The key under which the Main Window settings are saved
const char* MAIN_SETTINGS_GROUP = "QGC_MAINWINDOW"; const char* MAIN_SETTINGS_GROUP = "QGC_MAINWINDOW";
...@@ -689,8 +666,6 @@ void MainWindow::loadSettings() ...@@ -689,8 +666,6 @@ void MainWindow::loadSettings()
_autoReconnect = settings.value("AUTO_RECONNECT", _autoReconnect).toBool(); _autoReconnect = settings.value("AUTO_RECONNECT", _autoReconnect).toBool();
_lowPowerMode = settings.value("LOW_POWER_MODE", _lowPowerMode).toBool(); _lowPowerMode = settings.value("LOW_POWER_MODE", _lowPowerMode).toBool();
_showStatusBar = settings.value("SHOW_STATUSBAR", _showStatusBar).toBool(); _showStatusBar = settings.value("SHOW_STATUSBAR", _showStatusBar).toBool();
_fontFactor = settings.value("FONT_SIZE_FACTOR", _fontFactor).toDouble();
_pixelFactor = settings.value("PIXEL_SIZE_FACTOR", _pixelFactor).toDouble();
settings.endGroup(); settings.endGroup();
} }
...@@ -701,8 +676,6 @@ void MainWindow::storeSettings() ...@@ -701,8 +676,6 @@ void MainWindow::storeSettings()
settings.setValue("AUTO_RECONNECT", _autoReconnect); settings.setValue("AUTO_RECONNECT", _autoReconnect);
settings.setValue("LOW_POWER_MODE", _lowPowerMode); settings.setValue("LOW_POWER_MODE", _lowPowerMode);
settings.setValue("SHOW_STATUSBAR", _showStatusBar); settings.setValue("SHOW_STATUSBAR", _showStatusBar);
settings.setValue("FONT_SIZE_FACTOR", _fontFactor);
settings.setValue("PIXEL_SIZE_FACTOR", _pixelFactor);
settings.endGroup(); settings.endGroup();
settings.setValue(_getWindowGeometryKey(), saveGeometry()); settings.setValue(_getWindowGeometryKey(), saveGeometry());
...@@ -1199,22 +1172,6 @@ void MainWindow::_linkStateChange(LinkInterface*) ...@@ -1199,22 +1172,6 @@ void MainWindow::_linkStateChange(LinkInterface*)
emit repaintCanvas(); emit repaintCanvas();
} }
void MainWindow::setPixelSizeFactor(double size) {
if(size < 0.1) {
size = 0.1;
}
_pixelFactor = size;
emit pixelSizeChanged();
}
void MainWindow::setFontSizeFactor(double size) {
if(size < 0.1) {
size = 0.1;
}
_fontFactor = size;
emit fontSizeChanged();
}
#ifdef QGC_MOUSE_ENABLED_LINUX #ifdef QGC_MOUSE_ENABLED_LINUX
bool MainWindow::x11Event(XEvent *event) bool MainWindow::x11Event(XEvent *event)
{ {
......
...@@ -130,15 +130,6 @@ public: ...@@ -130,15 +130,6 @@ public:
QWidget* getCurrentViewWidget(void) { return _currentViewWidget; } QWidget* getCurrentViewWidget(void) { return _currentViewWidget; }
//! Returns the font point size factor
static double fontPointFactor() { return _fontFactor; }
//! Returns the pixel size factor
static double pixelSizeFactor() { return _pixelFactor; }
//! Sets pixel size factor
void setPixelSizeFactor(double size);
//! Sets font size factor
void setFontSizeFactor(double size);
public slots: public slots:
/** @brief Show the application settings */ /** @brief Show the application settings */
void showSettings(); void showSettings();
...@@ -209,10 +200,6 @@ signals: ...@@ -209,10 +200,6 @@ signals:
void valueChanged(const int uasId, const QString& name, const QString& unit, const QVariant& value, const quint64 msec); void valueChanged(const int uasId, const QString& name, const QString& unit, const QVariant& value, const quint64 msec);
/** Emitted when any the Canvas elements within QML wudgets need updating */ /** Emitted when any the Canvas elements within QML wudgets need updating */
void repaintCanvas(); void repaintCanvas();
/** Emitted when pixel size factor changes */
void pixelSizeChanged();
/** Emitted when pixel size factor changes */
void fontSizeChanged();
#ifdef QGC_MOUSE_ENABLED_LINUX #ifdef QGC_MOUSE_ENABLED_LINUX
/** @brief Forward X11Event to catch 3DMouse inputs */ /** @brief Forward X11Event to catch 3DMouse inputs */
...@@ -373,10 +360,6 @@ private: ...@@ -373,10 +360,6 @@ private:
QString _getWindowStateKey(); QString _getWindowStateKey();
QString _getWindowGeometryKey(); QString _getWindowGeometryKey();
// UI Dimension Factors
static double _pixelFactor;
static double _fontFactor;
}; };
#endif /* _MAINWINDOW_H_ */ #endif /* _MAINWINDOW_H_ */
...@@ -31,7 +31,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -31,7 +31,7 @@ This file is part of the QGROUNDCONTROL project
#include <QQmlEngine> #include <QQmlEngine>
#include <QSettings> #include <QSettings>
#include "MainWindow.h" #include "ScreenTools.h"
#include "FlightDisplay.h" #include "FlightDisplay.h"
#include "UASManager.h" #include "UASManager.h"
...@@ -48,8 +48,8 @@ FlightDisplay::FlightDisplay(QWidget *parent) ...@@ -48,8 +48,8 @@ FlightDisplay::FlightDisplay(QWidget *parent)
pl->setContentsMargins(0,0,0,0); pl->setContentsMargins(0,0,0,0);
} }
#ifndef __android__ #ifndef __android__
setMinimumWidth( 380 * MainWindow::pixelSizeFactor()); setMinimumWidth( 380 * ScreenTools::pixelSizeFactor_s());
setMinimumHeight(400 * MainWindow::pixelSizeFactor()); setMinimumHeight(400 * ScreenTools::pixelSizeFactor_s());
#endif #endif
setContextPropertyObject("flightDisplay", this); setContextPropertyObject("flightDisplay", this);
setSource(QUrl::fromUserInput("qrc:/qml/FlightDisplay.qml")); setSource(QUrl::fromUserInput("qrc:/qml/FlightDisplay.qml"));
......
...@@ -230,63 +230,6 @@ Item { ...@@ -230,63 +230,6 @@ Item {
} }
} }
} }
//-- Hack tool to find optimal scale factor
Column {
id: fudgeColumn
anchors.horizontalCenter: parent.horizontalCenter
spacing: ScreenTools.adjustPixelSize(4)
width: parent.width
QGCLabel {
text: "Adjust Pixel Size Factor"
anchors.horizontalCenter: parent.horizontalCenter
}
Row {
spacing: ScreenTools.adjustPixelSize(4)
anchors.horizontalCenter: parent.horizontalCenter
Button {
text: 'Inc'
onClicked: {
ScreenTools.increasePixelSize()
}
}
Label {
text: ScreenTools.pixelSizeFactor.toFixed(2)
color: __qgcPal.text
anchors.verticalCenter: parent.verticalCenter
}
Button {
text: 'Dec'
onClicked: {
ScreenTools.decreasePixelSize()
}
}
}
QGCLabel {
text: "Adjust Font Size Factor"
anchors.horizontalCenter: parent.horizontalCenter
}
Row {
spacing: ScreenTools.adjustPixelSize(4)
anchors.horizontalCenter: parent.horizontalCenter
Button {
text: 'Inc'
onClicked: {
ScreenTools.increaseFontSize()
}
}
Label {
text: ScreenTools.fontPointFactor.toFixed(2)
color: __qgcPal.text
anchors.verticalCenter: parent.verticalCenter
}
Button {
text: 'Dec'
onClicked: {
ScreenTools.decreaseFontSize()
}
}
}
}
} }
} }
} }
......
...@@ -31,7 +31,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -31,7 +31,7 @@ This file is part of the QGROUNDCONTROL project
#include <QQmlEngine> #include <QQmlEngine>
#include <QSettings> #include <QSettings>
#include "MainWindow.h" #include "ScreenTools.h"
#include "QGCMapDisplay.h" #include "QGCMapDisplay.h"
#include "UASManager.h" #include "UASManager.h"
...@@ -48,8 +48,8 @@ QGCMapDisplay::QGCMapDisplay(QWidget *parent) ...@@ -48,8 +48,8 @@ QGCMapDisplay::QGCMapDisplay(QWidget *parent)
pl->setContentsMargins(0,0,0,0); pl->setContentsMargins(0,0,0,0);
} }
#ifndef __android__ #ifndef __android__
setMinimumWidth( 380 * MainWindow::pixelSizeFactor()); setMinimumWidth( 380 * ScreenTools::pixelSizeFactor_s());
setMinimumHeight(400 * MainWindow::pixelSizeFactor()); setMinimumHeight(400 * ScreenTools::pixelSizeFactor_s());
#endif #endif
setContextPropertyObject("mapEngine", this); setContextPropertyObject("mapEngine", this);
setSource(QUrl::fromUserInput("qrc:/qml/MapDisplay.qml")); setSource(QUrl::fromUserInput("qrc:/qml/MapDisplay.qml"));
......
...@@ -35,7 +35,7 @@ QGCMovableItem { ...@@ -35,7 +35,7 @@ QGCMovableItem {
id: root id: root
property real heading: 0 property real heading: 0
property real size: ScreenTools.pixelSizeFactor * (120) property real size: ScreenTools.pixelSizeFactor * (120)
property real _fontSize: ScreenTools.fontPointFactor * (12) property int _fontSize: ScreenTools.font12
width: size width: size
height: size height: size
Rectangle { Rectangle {
...@@ -72,7 +72,7 @@ QGCMovableItem { ...@@ -72,7 +72,7 @@ QGCMovableItem {
QGCLabel { QGCLabel {
text: heading.toFixed(0) text: heading.toFixed(0)
font.weight: Font.DemiBold font.weight: Font.DemiBold
font.pointSize: _fontSize < 1 ? 1 : _fontSize; font.pixelSize: _fontSize < 1 ? 1 : _fontSize;
color: "white" color: "white"
anchors.centerIn: parent anchors.centerIn: parent
} }
......
...@@ -40,7 +40,7 @@ Rectangle { ...@@ -40,7 +40,7 @@ Rectangle {
property real _reticleSlot: _reticleSpacing + _reticleHeight property real _reticleSlot: _reticleSpacing + _reticleHeight
property real _longDash: size * 0.40 property real _longDash: size * 0.40
property real _shortDash: size * 0.25 property real _shortDash: size * 0.25
property real _fontSize: ScreenTools.fontPointFactor * (11); property real _fontSize: ScreenTools.font11
height: size * 0.9 height: size * 0.9
width: size width: size
radius: ScreenTools.pixelSizeFactor * (8) radius: ScreenTools.pixelSizeFactor * (8)
...@@ -70,7 +70,7 @@ Rectangle { ...@@ -70,7 +70,7 @@ Rectangle {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
smooth: true smooth: true
font.weight: Font.DemiBold font.weight: Font.DemiBold
font.pointSize: _fontSize < 1 ? 1 : _fontSize; font.pixelSize: _fontSize < 1 ? 1 : _fontSize;
text: _pitch text: _pitch
color: "white" color: "white"
visible: (_pitch != 0) && ((_pitch % 10) === 0) visible: (_pitch != 0) && ((_pitch % 10) === 0)
...@@ -81,7 +81,7 @@ Rectangle { ...@@ -81,7 +81,7 @@ Rectangle {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
smooth: true smooth: true
font.weight: Font.DemiBold font.weight: Font.DemiBold
font.pointSize: _fontSize < 1 ? 1 : _fontSize; font.pixelSize: _fontSize < 1 ? 1 : _fontSize;
text: _pitch text: _pitch
color: "white" color: "white"
visible: (_pitch != 0) && ((_pitch % 10) === 0) visible: (_pitch != 0) && ((_pitch % 10) === 0)
......
...@@ -83,7 +83,7 @@ Item { ...@@ -83,7 +83,7 @@ Item {
id: label id: label
color: "black" color: "black"
text: slider.value.toFixed(2) text: slider.value.toFixed(2)
width: font.pointSize * 3.5 width: font.pixelSize * 3.5
anchors.horizontalCenter: labelRect.horizontalCenter anchors.horizontalCenter: labelRect.horizontalCenter
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
anchors.verticalCenter: labelRect.verticalCenter anchors.verticalCenter: labelRect.verticalCenter
......
...@@ -45,7 +45,7 @@ MapQuickItem { ...@@ -45,7 +45,7 @@ MapQuickItem {
Text { Text {
id: number id: number
anchors.centerIn: parent anchors.centerIn: parent
font.pointSize: 11 font.pixelSize: 11
font.weight: Font.DemiBold font.weight: Font.DemiBold
color: "white" color: "white"
text: marker.waypointID text: marker.waypointID
......
...@@ -31,6 +31,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -31,6 +31,7 @@ This file is part of the QGROUNDCONTROL project
#include <QQmlEngine> #include <QQmlEngine>
#include "MainToolBar.h" #include "MainToolBar.h"
#include "ScreenTools.h"
#include "MainWindow.h" #include "MainWindow.h"
#include "UASMessageView.h" #include "UASMessageView.h"
#include "UASMessageHandler.h" #include "UASMessageHandler.h"
...@@ -57,13 +58,14 @@ MainToolBar::MainToolBar(QWidget* parent) ...@@ -57,13 +58,14 @@ MainToolBar::MainToolBar(QWidget* parent)
{ {
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
setObjectName("MainToolBar"); setObjectName("MainToolBar");
_updatePixelSize();
setMinimumWidth(MainWindow::instance()->minimumWidth()); setMinimumWidth(MainWindow::instance()->minimumWidth());
// Get rid of layout default margins // Get rid of layout default margins
QLayout* pl = layout(); QLayout* pl = layout();
if(pl) { if(pl) {
pl->setContentsMargins(0,0,0,0); pl->setContentsMargins(0,0,0,0);
} }
setMinimumHeight(40 * ScreenTools::pixelSizeFactor_s());
setMaximumHeight(40 * ScreenTools::pixelSizeFactor_s());
// Tool Bar Preferences // Tool Bar Preferences
QSettings settings; QSettings settings;
settings.beginGroup(TOOL_BAR_SETTINGS_GROUP); settings.beginGroup(TOOL_BAR_SETTINGS_GROUP);
...@@ -83,7 +85,6 @@ MainToolBar::MainToolBar(QWidget* parent) ...@@ -83,7 +85,6 @@ MainToolBar::MainToolBar(QWidget* parent)
connect(LinkManager::instance(), &LinkManager::linkConfigurationChanged, this, &MainToolBar::_updateConfigurations); connect(LinkManager::instance(), &LinkManager::linkConfigurationChanged, this, &MainToolBar::_updateConfigurations);
connect(LinkManager::instance(), &LinkManager::linkConnected, this, &MainToolBar::_linkConnected); connect(LinkManager::instance(), &LinkManager::linkConnected, this, &MainToolBar::_linkConnected);
connect(LinkManager::instance(), &LinkManager::linkDisconnected, this, &MainToolBar::_linkDisconnected); connect(LinkManager::instance(), &LinkManager::linkDisconnected, this, &MainToolBar::_linkDisconnected);
connect(MainWindow::instance(), &MainWindow::pixelSizeChanged, this, &MainToolBar::_updatePixelSize);
// RSSI (didn't like standard connection) // RSSI (didn't like standard connection)
connect(MAVLinkProtocol::instance(), connect(MAVLinkProtocol::instance(),
SIGNAL(radioStatusChanged(LinkInterface*, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned)), this, SIGNAL(radioStatusChanged(LinkInterface*, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned)), this,
...@@ -388,9 +389,3 @@ void MainToolBar::_setProgressBarValue(float value) ...@@ -388,9 +389,3 @@ void MainToolBar::_setProgressBarValue(float value)
_progressBarValue = value; _progressBarValue = value;
emit progressBarValueChanged(value); emit progressBarValueChanged(value);
} }
void MainToolBar::_updatePixelSize()
{
setMinimumHeight(40 * MainWindow::pixelSizeFactor());
setMaximumHeight(40 * MainWindow::pixelSizeFactor());
}
...@@ -113,7 +113,6 @@ private slots: ...@@ -113,7 +113,6 @@ private slots:
void _linkDisconnected (LinkInterface* link); void _linkDisconnected (LinkInterface* link);
void _leaveMessageView (); void _leaveMessageView ();
void _setProgressBarValue (float value); void _setProgressBarValue (float value);
void _updatePixelSize ();
void _remoteControlRSSIChanged (uint8_t rssi); void _remoteControlRSSIChanged (uint8_t rssi);
void _telemetryChanged (LinkInterface* link, unsigned rxerrors, unsigned fixed, unsigned rssi, unsigned remrssi, unsigned txbuf, unsigned noise, unsigned remnoise); void _telemetryChanged (LinkInterface* link, unsigned rxerrors, unsigned fixed, unsigned rssi, unsigned remrssi, unsigned txbuf, unsigned noise, unsigned remnoise);
......
...@@ -338,7 +338,7 @@ Rectangle { ...@@ -338,7 +338,7 @@ Rectangle {
QGCLabel { QGCLabel {
id: messageText id: messageText
text: (MavManager.messageCount > 0) ? MavManager.messageCount : '' text: (MavManager.messageCount > 0) ? MavManager.messageCount : ''
font.pointSize: ScreenTools.fontPointFactor * (14); font.pixelSize: ScreenTools.font14
font.weight: Font.DemiBold font.weight: Font.DemiBold
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
...@@ -424,7 +424,7 @@ Rectangle { ...@@ -424,7 +424,7 @@ Rectangle {
QGCLabel { QGCLabel {
id: satelitteText id: satelitteText
text: MavManager.satelliteCount >= 0 ? MavManager.satelliteCount : 'NA' text: MavManager.satelliteCount >= 0 ? MavManager.satelliteCount : 'NA'
font.pointSize: MavManager.satelliteCount >= 0 ? ScreenTools.fontPointFactor * (14) : ScreenTools.fontPointFactor * (10) font.pixelSize: MavManager.satelliteCount >= 0 ? ScreenTools.font14 : ScreenTools.font10
font.weight: Font.DemiBold font.weight: Font.DemiBold
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right anchors.right: parent.right
...@@ -459,7 +459,7 @@ Rectangle { ...@@ -459,7 +459,7 @@ Rectangle {
anchors.rightMargin: getProportionalDimmension(6) anchors.rightMargin: getProportionalDimmension(6)
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
font.pointSize: ScreenTools.fontPointFactor * (12); font.pixelSize: ScreenTools.font12
font.weight: Font.DemiBold font.weight: Font.DemiBold
color: colorWhite color: colorWhite
} }
...@@ -492,7 +492,7 @@ Rectangle { ...@@ -492,7 +492,7 @@ Rectangle {
anchors.right: parent.right anchors.right: parent.right
QGCLabel { QGCLabel {
text: 'R ' text: 'R '
font.pointSize: ScreenTools.fontPointFactor * (11); font.pixelSize: ScreenTools.font11
font.weight: Font.DemiBold font.weight: Font.DemiBold
color: colorWhite color: colorWhite
} }
...@@ -500,7 +500,7 @@ Rectangle { ...@@ -500,7 +500,7 @@ Rectangle {
text: mainToolBar.telemetryRRSSI + 'dB' text: mainToolBar.telemetryRRSSI + 'dB'
width: getProportionalDimmension(30) width: getProportionalDimmension(30)
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
font.pointSize: ScreenTools.fontPointFactor * (11); font.pixelSize: ScreenTools.font11
font.weight: Font.DemiBold font.weight: Font.DemiBold
color: colorWhite color: colorWhite
} }
...@@ -509,7 +509,7 @@ Rectangle { ...@@ -509,7 +509,7 @@ Rectangle {
anchors.right: parent.right anchors.right: parent.right
QGCLabel { QGCLabel {
text: 'L ' text: 'L '
font.pointSize: ScreenTools.fontPointFactor * (11); font.pixelSize: ScreenTools.font11
font.weight: Font.DemiBold font.weight: Font.DemiBold
color: colorWhite color: colorWhite
} }
...@@ -517,7 +517,7 @@ Rectangle { ...@@ -517,7 +517,7 @@ Rectangle {
text: mainToolBar.telemetryLRSSI + 'dB' text: mainToolBar.telemetryLRSSI + 'dB'
width: getProportionalDimmension(30) width: getProportionalDimmension(30)
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
font.pointSize: ScreenTools.fontPointFactor * (11); font.pixelSize: ScreenTools.font11
font.weight: Font.DemiBold font.weight: Font.DemiBold
color: colorWhite color: colorWhite
} }
...@@ -548,7 +548,7 @@ Rectangle { ...@@ -548,7 +548,7 @@ Rectangle {
QGCLabel { QGCLabel {
visible: batteryStatus.visible && MavManager.batteryConsumed < 0.0 visible: batteryStatus.visible && MavManager.batteryConsumed < 0.0
text: MavManager.batteryVoltage.toFixed(1) + 'V'; text: MavManager.batteryVoltage.toFixed(1) + 'V';
font.pointSize: ScreenTools.fontPointFactor * (11); font.pixelSize: ScreenTools.font11
font.weight: Font.DemiBold font.weight: Font.DemiBold
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: getProportionalDimmension(6) anchors.rightMargin: getProportionalDimmension(6)
...@@ -566,7 +566,7 @@ Rectangle { ...@@ -566,7 +566,7 @@ Rectangle {
text: MavManager.batteryVoltage.toFixed(1) + 'V'; text: MavManager.batteryVoltage.toFixed(1) + 'V';
width: getProportionalDimmension(30) width: getProportionalDimmension(30)
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
font.pointSize: ScreenTools.fontPointFactor * (11); font.pixelSize: ScreenTools.font11
font.weight: Font.DemiBold font.weight: Font.DemiBold
color: colorWhite color: colorWhite
} }
...@@ -574,7 +574,7 @@ Rectangle { ...@@ -574,7 +574,7 @@ Rectangle {
text: MavManager.batteryConsumed.toFixed(0) + 'mA'; text: MavManager.batteryConsumed.toFixed(0) + 'mA';
width: getProportionalDimmension(30) width: getProportionalDimmension(30)
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
font.pointSize: ScreenTools.fontPointFactor * (11); font.pixelSize: ScreenTools.font11
font.weight: Font.DemiBold font.weight: Font.DemiBold
color: colorWhite color: colorWhite
} }
...@@ -599,7 +599,7 @@ Rectangle { ...@@ -599,7 +599,7 @@ Rectangle {
QGCLabel { QGCLabel {
id: armedStatusText id: armedStatusText
text: (MavManager.systemArmed) ? qsTr("ARMED") : qsTr("DISARMED") text: (MavManager.systemArmed) ? qsTr("ARMED") : qsTr("DISARMED")
font.pointSize: ScreenTools.fontPointFactor * (12); font.pixelSize: ScreenTools.font12
font.weight: Font.DemiBold font.weight: Font.DemiBold
anchors.centerIn: parent anchors.centerIn: parent
color: (MavManager.systemArmed) ? colorOrangeText : colorGreenText color: (MavManager.systemArmed) ? colorOrangeText : colorGreenText
...@@ -618,7 +618,7 @@ Rectangle { ...@@ -618,7 +618,7 @@ Rectangle {
QGCLabel { QGCLabel {
id: stateStatusText id: stateStatusText
text: MavManager.currentState text: MavManager.currentState
font.pointSize: ScreenTools.fontPointFactor * (12); font.pixelSize: ScreenTools.font12
font.weight: Font.DemiBold font.weight: Font.DemiBold
anchors.centerIn: parent anchors.centerIn: parent
color: (MavManager.currentState === "STANDBY") ? colorGreenText : colorRedText color: (MavManager.currentState === "STANDBY") ? colorGreenText : colorRedText
...@@ -639,7 +639,7 @@ Rectangle { ...@@ -639,7 +639,7 @@ Rectangle {
QGCLabel { QGCLabel {
id: modeStatusText id: modeStatusText
text: MavManager.currentMode text: MavManager.currentMode
font.pointSize: ScreenTools.fontPointFactor * (12); font.pixelSize: ScreenTools.font12
font.weight: Font.DemiBold font.weight: Font.DemiBold
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
...@@ -660,7 +660,7 @@ Rectangle { ...@@ -660,7 +660,7 @@ Rectangle {
QGCLabel { QGCLabel {
id: connectionStatusText id: connectionStatusText
text: qsTr("CONNECTION LOST") text: qsTr("CONNECTION LOST")
font.pointSize: ScreenTools.fontPointFactor * (14); font.pixelSize: ScreenTools.font14
font.weight: Font.DemiBold font.weight: Font.DemiBold
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
......
...@@ -63,7 +63,8 @@ UASQuickView::~UASQuickView() ...@@ -63,7 +63,8 @@ UASQuickView::~UASQuickView()
void UASQuickView::columnActionTriggered() void UASQuickView::columnActionTriggered()
{ {
bool ok = false; bool ok = false;
int newcolumns = QInputDialog::getInt(this,"Columns","Enter number of columns",1,0,100,1,&ok); int newcolumns = QInputDialog::getInt(
this,"Columns","Enter number of columns", m_columnCount, 1, 10, 1, &ok);
if (!ok) if (!ok)
{ {
return; return;
...@@ -110,7 +111,7 @@ void UASQuickView::loadSettings() ...@@ -110,7 +111,7 @@ void UASQuickView::loadSettings()
QSettings settings; QSettings settings;
m_columnCount = settings.value("UAS_QUICK_VIEW_COLUMNS",1).toInt(); m_columnCount = settings.value("UAS_QUICK_VIEW_COLUMNS",1).toInt();
int size = settings.beginReadArray("UAS_QUICK_VIEW_ITEMS"); int size = settings.beginReadArray("UAS_QUICK_VIEW_ITEMS");
for (int i=0;i<size;i++) for (int i = 0; i < size; i++)
{ {
settings.setArrayIndex(i); settings.setArrayIndex(i);
QString nameval = settings.value("name").toString(); QString nameval = settings.value("name").toString();
...@@ -158,16 +159,16 @@ void UASQuickView::sortItems(int columncount) ...@@ -158,16 +159,16 @@ void UASQuickView::sortItems(int columncount)
m_PropertyToLayoutIndexMap.remove(i.key()); m_PropertyToLayoutIndexMap.remove(i.key());
itemlist.append(i.value()); itemlist.append(i.value());
} }
//Item list has all the widgets availble, now re-add them to the layouts. // Item list has all the widgets availble, now re-add them to the layouts.
for (int i=0;i<m_verticalLayoutList.size();i++) for (int i = 0; i < m_verticalLayoutList.size(); i++)
{ {
ui.horizontalLayout->removeItem(m_verticalLayoutList[i]); ui.horizontalLayout->removeItem(m_verticalLayoutList[i]);
m_verticalLayoutList[i]->deleteLater(); //removeItem de-parents the item. m_verticalLayoutList[i]->deleteLater(); //removeItem de-parents the item.
} }
m_verticalLayoutList.clear(); m_verticalLayoutList.clear();
//Create a vertical layout for every intended column // Create a vertical layout for every intended column
for (int i=0;i<columncount;i++) for (int i = 0; i < columncount; i++)
{ {
QVBoxLayout *layout = new QVBoxLayout(); QVBoxLayout *layout = new QVBoxLayout();
ui.horizontalLayout->addItem(layout); ui.horizontalLayout->addItem(layout);
...@@ -177,7 +178,7 @@ void UASQuickView::sortItems(int columncount) ...@@ -177,7 +178,7 @@ void UASQuickView::sortItems(int columncount)
//Cycle through all items and add them to the layout //Cycle through all items and add them to the layout
int currcol = 0; int currcol = 0;
for (int i=0;i<itemlist.size();i++) for (int i = 0; i < itemlist.size(); i++)
{ {
m_verticalLayoutList[currcol]->addWidget(itemlist[i]); m_verticalLayoutList[currcol]->addWidget(itemlist[i]);
currcol++; currcol++;
...@@ -206,6 +207,8 @@ void UASQuickView::recalculateItemTextSizing() ...@@ -206,6 +207,8 @@ void UASQuickView::recalculateItemTextSizing()
minpixelsize = tempmin; minpixelsize = tempmin;
} }
} }
if(minpixelsize < 6)
minpixelsize = 6;
for (QMap<QString,UASQuickViewItem*>::const_iterator i = uasPropertyToLabelMap.constBegin();i!=uasPropertyToLabelMap.constEnd();i++) for (QMap<QString,UASQuickViewItem*>::const_iterator i = uasPropertyToLabelMap.constBegin();i!=uasPropertyToLabelMap.constEnd();i++)
{ {
i.value()->setValuePixelSize(minpixelsize); i.value()->setValuePixelSize(minpixelsize);
......
...@@ -10,27 +10,27 @@ UASQuickViewTextItem::UASQuickViewTextItem(QWidget *parent) : UASQuickViewItem(p ...@@ -10,27 +10,27 @@ UASQuickViewTextItem::UASQuickViewTextItem(QWidget *parent) : UASQuickViewItem(p
// Create the title label. Scale the font based on available size. // Create the title label. Scale the font based on available size.
titleLabel = new QLabel(this); titleLabel = new QLabel(this);
titleLabel->setAlignment(Qt::AlignHCenter); titleLabel->setAlignment(Qt::AlignHCenter);
titleLabel->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Minimum); titleLabel->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Minimum);
titleLabel->setObjectName(QString::fromUtf8("title")); titleLabel->setObjectName(QString::fromUtf8("title"));
QFont titlefont = titleLabel->font(); QFont titlefont = titleLabel->font();
titlefont.setPixelSize(this->height() / 4.0); titlefont.setPixelSize(this->height() / 4.0);
titleLabel->setFont(titlefont); titleLabel->setFont(titlefont);
layout->addWidget(titleLabel); layout->addWidget(titleLabel);
// Create the value label. Scale the font based on available size. // Create the value label. Scale the font based on available size.
valueLabel = new QLabel(this); valueLabel = new QLabel(this);
valueLabel->setAlignment(Qt::AlignHCenter); valueLabel->setAlignment(Qt::AlignHCenter);
valueLabel->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Minimum); valueLabel->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Minimum);
valueLabel->setObjectName(QString::fromUtf8("value")); valueLabel->setObjectName(QString::fromUtf8("value"));
valueLabel->setText("0.00"); valueLabel->setText("0.00");
QFont valuefont = valueLabel->font(); QFont valuefont = valueLabel->font();
valuefont.setPixelSize(this->height() / 2.0); valuefont.setPixelSize(this->height() / 2.0);
valueLabel->setFont(valuefont); valueLabel->setFont(valuefont);
layout->addWidget(valueLabel); layout->addWidget(valueLabel);
// And make sure the items are evenly spaced in the UASQuickView. // And make sure the items are evenly spaced in the UASQuickView.
layout->addSpacerItem(new QSpacerItem(20, 0, QSizePolicy::Minimum, QSizePolicy::Expanding)); layout->addSpacerItem(new QSpacerItem(10, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
this->setLayout(layout); this->setLayout(layout);
} }
void UASQuickViewTextItem::setValue(double value) void UASQuickViewTextItem::setValue(double value)
...@@ -61,7 +61,7 @@ void UASQuickViewTextItem::setTitle(QString title) ...@@ -61,7 +61,7 @@ void UASQuickViewTextItem::setTitle(QString title)
{ {
if (title.indexOf(".") != -1 && title.indexOf(":") != -1) if (title.indexOf(".") != -1 && title.indexOf(":") != -1)
{ {
titleLabel->setText(title.mid(title.indexOf(".")+1)); titleLabel->setText(title.mid(title.indexOf(".") + 1));
} }
else else
{ {
...@@ -73,7 +73,7 @@ int UASQuickViewTextItem::minValuePixelSize() ...@@ -73,7 +73,7 @@ int UASQuickViewTextItem::minValuePixelSize()
QFont valuefont = valueLabel->font(); QFont valuefont = valueLabel->font();
QFont titlefont = titleLabel->font(); QFont titlefont = titleLabel->font();
valuefont.setPixelSize(this->height()); valuefont.setPixelSize(this->height());
titlefont.setPixelSize(valuefont.pixelSize() / 2.0); titlefont.setPixelSize(valuefont.pixelSize() * 0.75);
//spacerItem->setGeometry(QRect(0,0,20,this->height()/10.0)); //spacerItem->setGeometry(QRect(0,0,20,this->height()/10.0));
QFontMetrics metrics(valuefont); QFontMetrics metrics(valuefont);
...@@ -87,18 +87,18 @@ int UASQuickViewTextItem::minValuePixelSize() ...@@ -87,18 +87,18 @@ int UASQuickViewTextItem::minValuePixelSize()
//QFontMetrics titlefm( titlefont ); //QFontMetrics titlefm( titlefont );
//QRect titlebound = titlefm.boundingRect(0,0, titleLabel->width(), titleLabel->height(), Qt::TextWordWrap | Qt::AlignLeft, titleLabel->text()); //QRect titlebound = titlefm.boundingRect(0,0, titleLabel->width(), titleLabel->height(), Qt::TextWordWrap | Qt::AlignLeft, titleLabel->text());
if ((valbound.width() <= valueLabel->width() && valbound.height() <= valueLabel->height()))// && (titlebound.width() <= titleLabel->width() && titlebound.height() <= titleLabel->height())) if ((valbound.width() <= valueLabel->width() && valbound.height() <= valueLabel->height())) // && (titlebound.width() <= titleLabel->width() && titlebound.height() <= titleLabel->height()))
fit = true; fit = true;
else else
{ {
if (valuefont.pixelSize()-5 <= 0) if (valuefont.pixelSize() - 1 <= 6)
{ {
fit = true; fit = true;
valuefont.setPixelSize(5); valuefont.setPixelSize(6);
} }
else else
{ {
valuefont.setPixelSize(valuefont.pixelSize() - 5); valuefont.setPixelSize(valuefont.pixelSize() - 1);
} }
//titlefont.setPixelSize(valuefont.pixelSize() / 2.0); //titlefont.setPixelSize(valuefont.pixelSize() / 2.0);
//qDebug() << "Point size:" << valuefont.pixelSize() << valueLabel->width() << valueLabel->height(); //qDebug() << "Point size:" << valuefont.pixelSize() << valueLabel->width() << valueLabel->height();
...@@ -111,7 +111,7 @@ void UASQuickViewTextItem::setValuePixelSize(int size) ...@@ -111,7 +111,7 @@ void UASQuickViewTextItem::setValuePixelSize(int size)
QFont valuefont = valueLabel->font(); QFont valuefont = valueLabel->font();
QFont titlefont = titleLabel->font(); QFont titlefont = titleLabel->font();
valuefont.setPixelSize(size); valuefont.setPixelSize(size);
titlefont.setPixelSize(valuefont.pixelSize() / 2.0); titlefont.setPixelSize(valuefont.pixelSize() * 0.75);
valueLabel->setFont(valuefont); valueLabel->setFont(valuefont);
titleLabel->setFont(titlefont); titleLabel->setFont(titlefont);
update(); update();
......
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