Commit ae7becb5 authored by Don Gagne's avatar Don Gagne

Add --test-high-dpi command line option

This allows for testing issues found on high dpi screen without needing
a high dpi screen. it does this by doubling the font sizes.
parent cd2d960a
......@@ -154,6 +154,9 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
, _styleIsDark(true)
, _fakeMobile(false)
, _useNewMissionEditor(false)
#ifdef QT_DEBUG
, _testHighDPI(false)
#endif
{
Q_ASSERT(_app == NULL);
_app = this;
......@@ -172,6 +175,9 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
{ "--clear-settings", &fClearSettingsOptions, QString() },
{ "--full-logging", &fullLogging, QString() },
{ "--fake-mobile", &_fakeMobile, QString() },
#ifdef QT_DEBUG
{ "--test-high-dpi", &_testHighDPI, QString() },
#endif
// Add additional command line option flags here
};
......
......@@ -109,6 +109,10 @@ public:
bool useNewMissionEditor(void) { return _useNewMissionEditor; }
void setUseNewMissionEditor(bool use);
#ifdef QT_DEBUG
bool testHighDPI(void) { return _testHighDPI; }
#endif
public slots:
/// You can connect to this slot to show an information message box from a different thread.
void informationMessageBoxOnMainThread(const QString& title, const QString& msg);
......@@ -180,6 +184,10 @@ private:
bool _useNewMissionEditor; ///< true: Use new Mission Editor
#ifdef QT_DEBUG
bool _testHighDPI; ///< true: double fonts sizes for simulating high dpi devices
#endif
/// Unit Test have access to creating and destroying singletons
friend class UnitTest;
};
......
......@@ -8,9 +8,9 @@ import QGroundControl.ScreenToolsController 1.0
Item {
signal repaintRequested
readonly property real defaultFontPixelSize: _textMeasure.contentHeight * ScreenToolsController.defaultFontPixelSizeRatio
readonly property real defaultFontPixelSize: _textMeasure.fontHeight * ScreenToolsController.defaultFontPixelSizeRatio
readonly property real defaultFontPixelHeight: defaultFontPixelSize
readonly property real defaultFontPixelWidth: _textMeasure.contentWidth
readonly property real defaultFontPixelWidth: _textMeasure.fontWidth
readonly property real smallFontPixelSize: defaultFontPixelSize * ScreenToolsController.smallFontPixelSizeRatio
readonly property real mediumFontPixelSize: defaultFontPixelSize * ScreenToolsController.mediumFontPixelSizeRatio
readonly property real largeFontPixelSize: defaultFontPixelSize * ScreenToolsController.largeFontPixelSizeRatio
......@@ -30,6 +30,9 @@ Item {
Text {
id: _textMeasure
text: "X"
property real fontWidth: contentWidth * (ScreenToolsController.testHighDPI ? 2 : 1)
property real fontHeight: contentHeight * (ScreenToolsController.testHighDPI ? 2 : 1)
}
Connections {
......
......@@ -60,5 +60,13 @@ double ScreenToolsController::getQmlDefaultFontPixelSize(void)
qmlWidgetHolder.setSource(QUrl::fromUserInput("qrc:/qml/ScreenToolsFontQuery.qml"));
}
return _qmlDefaultFontPixelSize;
double qmlDefaultFontPixelSize = _qmlDefaultFontPixelSize;
#ifdef QT_DEBUG
if (qgcApp()->testHighDPI()) {
qmlDefaultFontPixelSize *= 2;
}
#endif
return qmlDefaultFontPixelSize;
}
......@@ -50,6 +50,7 @@ public:
Q_PROPERTY(bool isAndroid READ isAndroid CONSTANT)
Q_PROPERTY(bool isiOS READ isiOS CONSTANT)
Q_PROPERTY(bool isMobile READ isMobile CONSTANT)
Q_PROPERTY(bool testHighDPI READ testHighDPI CONSTANT)
//! Used to trigger a \c Canvas element repaint.
/*!
......@@ -113,6 +114,12 @@ public:
bool isMobile () { return qgcApp()->fakeMobile(); }
#endif
#ifdef QT_DEBUG
bool testHighDPI(void) { return qgcApp()->testHighDPI(); }
#else
bool testHighDPI(void) { return false; }
#endif
signals:
void repaintRequested(void);
......
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