Browse Source

Remove font query from QWidget side of code

For QWidget we will just use the Qt default font sizes. This removes
the extra QQuickWidget creation which breaks boot Qml Profiling
QGC4.4
Don Gagne 10 years ago
parent
commit
c786943375
  1. 1
      qgroundcontrol.qrc
  2. 17
      resources/styles/style-dark.css
  3. 6
      src/FlightDisplay/FlightDisplayWidget.cc
  4. 11
      src/QGCApplication.cc
  5. 20
      src/QmlControls/ScreenToolsController.cc
  6. 11
      src/QmlControls/ScreenToolsController.h
  7. 9
      src/QmlControls/ScreenToolsFontQuery.qml

1
qgroundcontrol.qrc

@ -133,7 +133,6 @@
<file alias="JoystickConfig.qml">src/VehicleSetup/JoystickConfig.qml</file> <file alias="JoystickConfig.qml">src/VehicleSetup/JoystickConfig.qml</file>
<file alias="SetupParameterEditor.qml">src/VehicleSetup/SetupParameterEditor.qml</file> <file alias="SetupParameterEditor.qml">src/VehicleSetup/SetupParameterEditor.qml</file>
<file alias="ScreenToolsFontQuery.qml">src/QmlControls/ScreenToolsFontQuery.qml</file>
<file alias="CustomCommandWidget.qml">src/ViewWidgets/CustomCommandWidget.qml</file> <file alias="CustomCommandWidget.qml">src/ViewWidgets/CustomCommandWidget.qml</file>
<file alias="SafetyComponent.qml">src/AutoPilotPlugins/PX4/SafetyComponent.qml</file> <file alias="SafetyComponent.qml">src/AutoPilotPlugins/PX4/SafetyComponent.qml</file>
<file alias="RadioComponent.qml">src/AutoPilotPlugins/PX4/RadioComponent.qml</file> <file alias="RadioComponent.qml">src/AutoPilotPlugins/PX4/RadioComponent.qml</file>

17
resources/styles/style-dark.css

@ -10,8 +10,6 @@
* { * {
background-color: #222; background-color: #222;
color: #FFF; color: #FFF;
font-size: FONT_NORMAL;
font-weight: lighter;
} }
QWidget#viewModeWidget { QWidget#viewModeWidget {
@ -132,7 +130,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 FONT_SMALL; font: bold;
color: #DDD; color: #DDD;
} }
@ -152,25 +150,18 @@ QLabel:disabled {
border-color: #444; border-color: #444;
} }
QLabel#noUas {
font-size: FONT_LARGE;
}
QMessageBox { QMessageBox {
min-width: 400px; min-width: 400px;
min-height: 300px; min-height: 300px;
} }
QLabel#tabTitleLabel { QLabel#tabTitleLabel {
font-size: FONT_LARGE;
font-weight: lighter;
margin-top: 16px; margin-top: 16px;
margin-bottom: 8px; margin-bottom: 8px;
} }
QLabel#instructionLabel { QLabel#instructionLabel {
color: #FEC654; color: #FEC654;
font-size: FONT_LARGE;
} }
QLineEdit { QLineEdit {
@ -229,8 +220,6 @@ QMenuBar::item:disabled {
QPlainTextEdit { QPlainTextEdit {
border: 1px solid #777; border: 1px solid #777;
border-radius: 2px; border-radius: 2px;
font-family: "Monospace";
font: FONT_SMALL;
} }
QProgressBar { QProgressBar {
@ -535,10 +524,6 @@ UASQuickViewItem QLabel {
min-height: 1em; min-height: 1em;
} }
UASQuickViewItem QLabel#value {
font-size: FONT_LARGE;
}
UASView { UASView {
background: #444; background: #444;
border: 1px solid #AAA; border: 1px solid #AAA;

6
src/FlightDisplay/FlightDisplayWidget.cc

@ -44,10 +44,8 @@ FlightDisplayWidget::FlightDisplayWidget(const QString& title, QAction* action,
if(pl) { if(pl) {
pl->setContentsMargins(0,0,0,0); pl->setContentsMargins(0,0,0,0);
} }
#ifndef __android__ setMinimumWidth(300);
setMinimumWidth( 31 * ScreenToolsController::defaultFontPixelSize_s()); setMinimumHeight(300);
setMinimumHeight(33 * ScreenToolsController::defaultFontPixelSize_s());
#endif
setContextPropertyObject("flightDisplay", this); setContextPropertyObject("flightDisplay", this);
/* /*

11
src/QGCApplication.cc

@ -759,17 +759,6 @@ void QGCApplication::_loadCurrentStyle(void)
} }
} }
// Now that we have the styles loaded we need to adjust the font sizes.
QString fSmall = QString("%1px;").arg(ScreenToolsController::smallFontPixelSize_s());
QString fNormal = QString("%1px;").arg(ScreenToolsController::defaultFontPixelSize_s());
QString fLarge = QString("%1px;").arg(ScreenToolsController::largeFontPixelSize_s());
qDebug() << fSmall << fNormal << fLarge;
styles.replace("FONT_SMALL", fSmall);
styles.replace("FONT_NORMAL", fNormal);
styles.replace("FONT_LARGE", fLarge);
setStyleSheet(styles); setStyleSheet(styles);
if (!success) { if (!success) {

20
src/QmlControls/ScreenToolsController.cc

@ -27,8 +27,6 @@
#include "ScreenToolsController.h" #include "ScreenToolsController.h"
#include "MainWindow.h" #include "MainWindow.h"
int ScreenToolsController::_qmlDefaultFontPixelSize = -1;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
const double ScreenToolsController::_defaultFontPixelSizeRatio = 1.0; const double ScreenToolsController::_defaultFontPixelSizeRatio = 1.0;
#else #else
@ -52,21 +50,3 @@ void ScreenToolsController::_updateCanvas()
emit repaintRequested(); emit repaintRequested();
} }
double ScreenToolsController::getQmlDefaultFontPixelSize(void)
{
if (_qmlDefaultFontPixelSize == -1) {
QGCQmlWidgetHolder qmlWidgetHolder(QString(), NULL);
qmlWidgetHolder.setSource(QUrl::fromUserInput("qrc:/qml/ScreenToolsFontQuery.qml"));
}
double qmlDefaultFontPixelSize = _qmlDefaultFontPixelSize;
#ifdef QT_DEBUG
if (qgcApp()->testHighDPI()) {
qmlDefaultFontPixelSize *= 2;
}
#endif
return qmlDefaultFontPixelSize;
}

11
src/QmlControls/ScreenToolsController.h

@ -91,15 +91,6 @@ public:
Q_PROPERTY(double mediumFontPixelSizeRatio MEMBER _mediumFontPixelSizeRatio CONSTANT) Q_PROPERTY(double mediumFontPixelSizeRatio MEMBER _mediumFontPixelSizeRatio CONSTANT)
Q_PROPERTY(double largeFontPixelSizeRatio MEMBER _largeFontPixelSizeRatio CONSTANT) Q_PROPERTY(double largeFontPixelSizeRatio MEMBER _largeFontPixelSizeRatio CONSTANT)
Q_PROPERTY(double qmlDefaultFontPixelSize MEMBER _qmlDefaultFontPixelSize)
static double getQmlDefaultFontPixelSize(void);
static int defaultFontPixelSize_s() { return (int)getQmlDefaultFontPixelSize(); }
static int smallFontPixelSize_s() { return (int)((double)defaultFontPixelSize_s() * _smallFontPixelSizeRatio); }
static int mediumFontPixelSize_s() { return (int)((double)defaultFontPixelSize_s() * _mediumFontPixelSizeRatio); }
static int largeFontPixelSize_s() { return (int)((double)defaultFontPixelSize_s() * _largeFontPixelSizeRatio); }
#if defined (__android__) #if defined (__android__)
bool isAndroid () { return true; } bool isAndroid () { return true; }
bool isiOS () { return false; } bool isiOS () { return false; }
@ -131,8 +122,6 @@ private:
static const double _smallFontPixelSizeRatio; static const double _smallFontPixelSizeRatio;
static const double _mediumFontPixelSizeRatio; static const double _mediumFontPixelSizeRatio;
static const double _largeFontPixelSizeRatio; static const double _largeFontPixelSizeRatio;
static int _qmlDefaultFontPixelSize;
}; };
#endif #endif

9
src/QmlControls/ScreenToolsFontQuery.qml

@ -1,9 +0,0 @@
import QtQuick 2.2
import QtQuick.Controls 1.2
import QGroundControl.ScreenTools 1.0
import QGroundControl.ScreenToolsController 1.0
Item {
Component.onCompleted: ScreenToolsController.qmlDefaultFontPixelSize = ScreenTools.defaultFontPixelSize
}
Loading…
Cancel
Save