diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 575b191d2dec5700ec47cb12070141a2c5cd26e4..13c465a06380aae4789a5b33b36fbc0d85e5f08f 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -112,40 +112,41 @@ src/ui/flightdisplay/FlightDisplay.qml src/ui/mapdisplay/MapDisplay.qml - src/ui/qmlcommon/qmldir src/ui/qmlcommon/QGCAltitudeWidget.qml - src/ui/qmlcommon/QGCAttitudeWidget.qml + src/ui/qmlcommon/QGCArtificialHorizon.qml src/ui/qmlcommon/QGCAttitudeInstrument.qml + src/ui/qmlcommon/QGCAttitudeWidget.qml src/ui/qmlcommon/QGCCompass.qml src/ui/qmlcommon/QGCCompassInstrument.qml src/ui/qmlcommon/QGCCurrentAltitude.qml src/ui/qmlcommon/QGCCurrentSpeed.qml + src/ui/qmlcommon/QGCHudMessage.qml src/ui/qmlcommon/QGCMapBackground.qml + src/ui/qmlcommon/QGCMapToolButton.qml src/ui/qmlcommon/QGCPitchWidget.qml - src/ui/qmlcommon/QGCSpeedWidget.qml src/ui/qmlcommon/QGCSlider.qml + src/ui/qmlcommon/QGCSpeedWidget.qml src/ui/qmlcommon/QGCWaypointEditor.qml - src/ui/qmlcommon/QGCMapToolButton.qml - src/ui/qmlcommon/QGCArtificialHorizon.qml + src/ui/qmlcommon/qmldir src/ui/qmlcommon/QGCWaypoint.qml + src/ui/qmlcommon/attitudeDial.svg + src/ui/qmlcommon/attitudeInstrument.svg + src/ui/qmlcommon/attitudePointer.svg + src/ui/qmlcommon/buttonHome.svg + src/ui/qmlcommon/buttonLeft.svg + src/ui/qmlcommon/buttonMore.svg + src/ui/qmlcommon/buttonRight.svg src/ui/qmlcommon/compass.svg + src/ui/qmlcommon/compassInstrumentAirplane.svg + src/ui/qmlcommon/compassInstrumentDial.svg src/ui/qmlcommon/compassNeedle.svg src/ui/qmlcommon/crossHair.svg src/ui/qmlcommon/rollDialWhite.svg src/ui/qmlcommon/rollPointerWhite.svg src/ui/qmlcommon/scale.png src/ui/qmlcommon/scale_end.png - src/ui/qmlcommon/buttonLeft.svg - src/ui/qmlcommon/buttonRight.svg - src/ui/qmlcommon/buttonHome.svg - src/ui/qmlcommon/buttonMore.svg - src/ui/qmlcommon/attitudeInstrument.svg - src/ui/qmlcommon/attitudeDial.svg - src/ui/qmlcommon/attitudePointer.svg - src/ui/qmlcommon/compassInstrumentAirplane.svg - src/ui/qmlcommon/compassInstrumentDial.svg diff --git a/resources/styles/style-dark.css b/resources/styles/style-dark.css index ae439e8a87b052056efcd11328949d856be477b9..ac426b45c93d5abeb79187029a67493ac98d3c78 100644 --- a/resources/styles/style-dark.css +++ b/resources/styles/style-dark.css @@ -2,12 +2,16 @@ 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 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; color: #FFF; - font-size: 12pt; + font-size: FONT_NORMAL; + font-weight: lighter; } QWidget#viewModeWidget { @@ -128,7 +132,7 @@ QGroupBox::title { subcontrol-position: top center; margin: 0 3px 0 3px; padding: 0 3px 0 0; - font: bold 8px; + font: bold FONT_SMALL; color: #DDD; } @@ -149,7 +153,7 @@ QLabel:disabled { } QLabel#noUas { - font-size: 30pt; + font-size: FONT_LARGE; } QMessageBox { @@ -158,7 +162,7 @@ QMessageBox { } QLabel#tabTitleLabel { - font-size: 28pt; + font-size: FONT_LARGE; font-weight: lighter; margin-top: 16px; margin-bottom: 8px; @@ -166,7 +170,7 @@ QLabel#tabTitleLabel { QLabel#instructionLabel { color: #FEC654; - font-size: 26pt; + font-size: FONT_LARGE; } QLineEdit { @@ -226,7 +230,7 @@ QPlainTextEdit { border: 1px solid #777; border-radius: 2px; font-family: "Monospace"; - font: large; + font: FONT_SMALL; } QProgressBar { @@ -529,11 +533,10 @@ UASQuickViewItem QLabel { padding: 0; margin: 0; min-height: 1em; - font-weight: bold; } UASQuickViewItem QLabel#value { - font-size: 20pt; + font-size: FONT_LARGE; } UASView { diff --git a/src/AutoPilotPlugins/AutoPilotPluginManager.cc b/src/AutoPilotPlugins/AutoPilotPluginManager.cc index a18cb4eb96965d62b4af305a0f0a1a988887a20d..086400fe242e711f6784fd9ffa5c1fd5748cd444 100644 --- a/src/AutoPilotPlugins/AutoPilotPluginManager.cc +++ b/src/AutoPilotPlugins/AutoPilotPluginManager.cc @@ -40,7 +40,7 @@ AutoPilotPluginManager::AutoPilotPluginManager(QObject* parent) : // We need to track uas coming and going so that we can instantiate plugins for each uas connect(uasMgr, &UASManagerInterface::UASCreated, this, &AutoPilotPluginManager::_uasCreated); - connect(uasMgr, &UASManagerInterface::UASDeleted, this, &AutoPilotPluginManager::_uasDeleted); + connect(uasMgr, SIGNAL(UASDeleted(UASInterface*)), this, SLOT(_uasDeleted(UASInterface*))); } AutoPilotPluginManager::~AutoPilotPluginManager() diff --git a/src/AutoPilotPlugins/PX4/AirframeComponent.qml b/src/AutoPilotPlugins/PX4/AirframeComponent.qml index d27718bec968ab1d38ab9b364425daa29fee0141..43ff21671da388f93d41ef10f91ababbedd745cf 100644 --- a/src/AutoPilotPlugins/PX4/AirframeComponent.qml +++ b/src/AutoPilotPlugins/PX4/AirframeComponent.qml @@ -97,7 +97,7 @@ QGCView { QGCLabel { id: header width: parent.width - font.pointSize: ScreenTools.largeFontPointSize + font.pixelSize: ScreenTools.largeFontPixelSize text: "AIRFRAME CONFIG" } @@ -225,4 +225,4 @@ QGCView { } // Flow - summary boxes } // Scroll View - summary boxes } // QGCViewPanel -} // QGCView \ No newline at end of file +} // QGCView diff --git a/src/AutoPilotPlugins/PX4/AirframeComponentController.cc b/src/AutoPilotPlugins/PX4/AirframeComponentController.cc index 62674d32c9ccb190f48524d29134a5d2a869dffe..09cf480823eb8887721f1f84bb23b73214da25de 100644 --- a/src/AutoPilotPlugins/PX4/AirframeComponentController.cc +++ b/src/AutoPilotPlugins/PX4/AirframeComponentController.cc @@ -102,9 +102,10 @@ void AirframeComponentController::changeAutostart(void) getParameterFact(-1, "SYS_AUTOSTART")->setValue(_autostartId); getParameterFact(-1, "SYS_AUTOCONFIG")->setValue(1); - // Wait for the parameters to flow through system + // FactSystem doesn't currently have a mechanism to wait for the parameters to come backf from the board. + // So instead we wait for enough time for the parameters to hoepfully make it to the board. qgcApp()->processEvents(QEventLoop::ExcludeUserInputEvents); - QGC::SLEEP::sleep(1); + QGC::SLEEP::sleep(3); qgcApp()->processEvents(QEventLoop::ExcludeUserInputEvents); // Reboot board diff --git a/src/AutoPilotPlugins/PX4/FlightModesComponent.qml b/src/AutoPilotPlugins/PX4/FlightModesComponent.qml index 2cef7ff5dda0613279a021d82a9bf5cb4856cf61..e0e4909b877ac5c488a91f72c21902ad68887ed7 100644 --- a/src/AutoPilotPlugins/PX4/FlightModesComponent.qml +++ b/src/AutoPilotPlugins/PX4/FlightModesComponent.qml @@ -384,7 +384,7 @@ Item { QGCLabel { text: "FLIGHT MODES CONFIG" - font.pointSize: ScreenTools.largeFontPointSize + font.pixelSize: ScreenTools.largeFontPixelSize } Item { height: 20; width: 10 } // spacer @@ -973,7 +973,7 @@ Item { QGCLabel { text: "FLIGHT MODES CONFIG" - font.pointSize: ScreenTools.fontPointFactor * (20); + font.pixelSize: ScreenTools.font20; } QGCLabel { diff --git a/src/AutoPilotPlugins/PX4/PowerComponent.qml b/src/AutoPilotPlugins/PX4/PowerComponent.qml index 8dfff3a1d009ee48c9e5370cdde4423689cbf611..12f1279379a192b71a831e9e1a912d0e44076ac7 100644 --- a/src/AutoPilotPlugins/PX4/PowerComponent.qml +++ b/src/AutoPilotPlugins/PX4/PowerComponent.qml @@ -115,12 +115,12 @@ QGCView { QGCLabel { text: "POWER CONFIG" - font.pointSize: ScreenTools.largeFontPointSize + font.pixelSize: ScreenTools.largeFontPixelSize } QGCLabel { text: "Battery" - font.pointSize: ScreenTools.mediumFontPointSize + font.pixelSize: ScreenTools.mediumFontPixelSize } Rectangle { @@ -234,7 +234,7 @@ QGCView { QGCLabel { text: "ESC Calibration" - font.pointSize: ScreenTools.mediumFontPointSize + font.pixelSize: ScreenTools.mediumFontPixelSize } Rectangle { @@ -269,7 +269,7 @@ QGCView { width: (parent.width / 2) - 5 QGCLabel { text: "Propeller Function" - font.pointSize: ScreenTools.fontPointFactor * (20); + font.pixelSize: ScreenTools.font20; } Rectangle { width: parent.width @@ -282,7 +282,7 @@ QGCView { width: (parent.width / 2) - 5 QGCLabel { text: "Magnetometer Distortion" - font.pointSize: ScreenTools.fontPointFactor * (20); + font.pixelSize: ScreenTools.font20; } Rectangle { width: parent.width @@ -301,7 +301,7 @@ QGCView { } QGCLabel { text: "Advanced Power Settings" - font.pointSize: ScreenTools.fontPointFactor * (20); + font.pixelSize: ScreenTools.font20; visible: showAdvanced.checked } Rectangle { diff --git a/src/AutoPilotPlugins/PX4/RadioComponent.qml b/src/AutoPilotPlugins/PX4/RadioComponent.qml index 273d3fd8dadaf5176d7a6551dc71bba601c49179..1f9e233f36155a97ca06198efc11ea50e778b112 100644 --- a/src/AutoPilotPlugins/PX4/RadioComponent.qml +++ b/src/AutoPilotPlugins/PX4/RadioComponent.qml @@ -42,6 +42,7 @@ QGCView { QGCPalette { id: qgcPal; colorGroupEnabled: panel.enabled } + readonly property string dialogTitle: "Radio Config" readonly property real labelToMonitorMargin: defaultTextWidth * 3 property bool controllerCompleted: false property bool controllerAndViewReady: false @@ -49,11 +50,15 @@ QGCView { function updateChannelCount() { if (controllerAndViewReady) { +/* + FIXME: Turned off for now, since it prevents binding. Need to restructure to + allow binding and still check channel count if (controller.channelCount < controller.minChannelCount) { - showDialog(channelCountDialogComponent, "Radio Config", 50, 0) + showDialog(channelCountDialogComponent, dialogTitle, 50, 0) } else { hideDialog() } +*/ } } @@ -89,6 +94,32 @@ QGCView { id: panel anchors.fill: parent + Component { + id: copyTrimsDialogComponent + + QGCViewMessage { + message: "Center your sticks and move throttle all the way down, then press Ok to copy trims. After pressing Ok, reset the trims on your radio back to zero." + + function accept() { + hideDialog() + controller.copyTrims() + } + } + } + + Component { + id: zeroTrimsDialogComponent + + QGCViewMessage { + message: "Before calibrating you should zero all your trims and subtrims. Click Ok to start Calibration." + + function accept() { + hideDialog() + controller.nextButtonClicked() + } + } + } + Component { id: channelCountDialogComponent @@ -205,6 +236,8 @@ QGCView { duration: 1500 } + /* + // FIXME: Bar animation is turned off for now to figure out better usbaility onRcValueChanged: { if (Math.abs(rcValue - __lastRcValue) > __rcValueMaxJitter) { __lastRcValue = rcValue @@ -212,7 +245,6 @@ QGCView { } } - /* // rcValue debugger QGCLabel { anchors.fill: parent @@ -226,7 +258,7 @@ QGCView { QGCLabel { id: header - font.pointSize: ScreenTools.largeFontPointSize + font.pixelSize: ScreenTools.largeFontPixelSize text: "RADIO CONFIG" } @@ -245,22 +277,6 @@ QGCView { anchors.right: columnSpacer.left spacing: 10 - Row { - spacing: 10 - - QGCLabel { - anchors.baseline: bindButton.baseline - text: "Place Spektrum satellite receiver in bind mode:" - } - - QGCButton { - id: bindButton - text: "Spektrum Bind" - - onClicked: showDialog(spektrumBindDialogComponent, "Radio Config", 50, StandardButton.Ok | StandardButton.Cancel) - } - } - // Attitude Controls Column { width: parent.width @@ -412,7 +428,13 @@ QGCView { primary: true text: "Calibrate" - onClicked: controller.nextButtonClicked() + onClicked: { + if (text == "Calibrate") { + showDialog(zeroTrimsDialogComponent, dialogTitle, 50, StandardButton.Ok | StandardButton.Cancel) + } else { + controller.nextButtonClicked() + } + } } } // Row - Buttons @@ -422,6 +444,42 @@ QGCView { width: parent.width wrapMode: Text.WordWrap } + + Item { + width: 10 + height: defaultTextHeight * 4 + } + + Rectangle { + width: parent.width + height: 1 + border.color: qgcPal.text + border.width: 1 + } + + QGCLabel { text: "Additional Radio setup:" } + + Row { + spacing: 10 + + QGCLabel { + anchors.baseline: bindButton.baseline + text: "Place Spektrum satellite receiver in bind mode:" + } + + QGCButton { + id: bindButton + text: "Spektrum Bind" + + onClicked: showDialog(spektrumBindDialogComponent, dialogTitle, 50, StandardButton.Ok | StandardButton.Cancel) + } + } + + QGCButton { + text: "Copy Trims" + onClicked: showDialog(copyTrimsDialogComponent, dialogTitle, 50, StandardButton.Ok | StandardButton.Cancel) + } + } // Column - Left Column Item { diff --git a/src/AutoPilotPlugins/PX4/RadioComponentController.cc b/src/AutoPilotPlugins/PX4/RadioComponentController.cc index e642f84cc25796478fe3f49faeeb5a4d152def9d..1117d4460b63ebb33c10be6dc52c65e42e3466ba 100644 --- a/src/AutoPilotPlugins/PX4/RadioComponentController.cc +++ b/src/AutoPilotPlugins/PX4/RadioComponentController.cc @@ -1050,3 +1050,8 @@ void RadioComponentController::_signalAllAttiudeValueChanges(void) emit yawChannelReversedChanged(yawChannelReversed()); emit throttleChannelReversedChanged(throttleChannelReversed()); } + +void RadioComponentController::copyTrims(void) +{ + _uas->startCalibration(UASInterface::StartCalibrationCopyTrims); +} diff --git a/src/AutoPilotPlugins/PX4/RadioComponentController.h b/src/AutoPilotPlugins/PX4/RadioComponentController.h index 6325da86b85b730684e309080dc9a8fe288239ae..6c48a96fe9ee4feac407e595c566a045b715c3ca 100644 --- a/src/AutoPilotPlugins/PX4/RadioComponentController.h +++ b/src/AutoPilotPlugins/PX4/RadioComponentController.h @@ -93,6 +93,7 @@ public: Q_INVOKABLE void skipButtonClicked(void); Q_INVOKABLE void nextButtonClicked(void); Q_INVOKABLE void start(void); + Q_INVOKABLE void copyTrims(void); int rollChannelRCValue(void); int pitchChannelRCValue(void); diff --git a/src/AutoPilotPlugins/PX4/SafetyComponent.qml b/src/AutoPilotPlugins/PX4/SafetyComponent.qml index 6ba1dfbc9e5f61bab8c912ae44eefb9e3af4c780..01d10f215b3801c5a851a226f5cee0fb90b358b4 100644 --- a/src/AutoPilotPlugins/PX4/SafetyComponent.qml +++ b/src/AutoPilotPlugins/PX4/SafetyComponent.qml @@ -52,7 +52,7 @@ FactPanel { QGCLabel { text: "SAFETY CONFIG" - font.pointSize: ScreenTools.largeFontPointSize + font.pixelSize: ScreenTools.largeFontPixelSize } Item { height: 20; width: 10 } // spacer @@ -60,7 +60,7 @@ FactPanel { //----------------------------------------------------------------- //-- 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 @@ -119,7 +119,7 @@ FactPanel { //----------------------------------------------------------------- //-- 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 @@ -290,7 +290,7 @@ FactPanel { QGCLabel { 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."; visible: fact.value !== 0 wrapMode: Text.Wrap @@ -300,7 +300,7 @@ FactPanel { QGCLabel { 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."; visible: fact.value !== 0 wrapMode: Text.Wrap diff --git a/src/AutoPilotPlugins/PX4/SensorsComponent.qml b/src/AutoPilotPlugins/PX4/SensorsComponent.qml index fee71c2bee346cf45f386382be4e90b59b9efee9..3b3dccac13da4d691d27a5568f9746f600c71932 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponent.qml +++ b/src/AutoPilotPlugins/PX4/SensorsComponent.qml @@ -57,8 +57,8 @@ QGCView { // Used to pass help text to the preCalibrationDialog dialog property string preCalibrationDialogHelp - readonly property int sideBarH1PointSize: (ScreenTools.defaultFontPointSize * 1.3 + 0.5) - readonly property int mainTextH1PointSize: (ScreenTools.defaultFontPointSize * 1.5 + 0.5) + readonly property int sideBarH1PointSize: ScreenTools.mediumFontPixelSize + readonly property int mainTextH1PointSize: ScreenTools.mediumFontPixelSize // Seems to be unused readonly property int rotationColumnWidth: 250 readonly property var rotations: [ @@ -213,7 +213,7 @@ QGCView { id: compass0ComponentLabel QGCLabel { - font.pointSize: sideBarH1PointSize + font.pixelSize: sideBarH1PointSize text: "External Compass Orientation" } @@ -280,7 +280,7 @@ QGCView { QGCLabel { text: "SENSORS CONFIG" - font.pointSize: ScreenTools.largeFontPointSize + font.pixelSize: ScreenTools.largeFontPixelSize } Item { height: 20; width: 10 } // spacer @@ -408,7 +408,7 @@ QGCView { id: orientationCalAreaHelpText width: parent.width wrapMode: Text.WordWrap - font.pointSize: ScreenTools.fontPointFactor * (22); + font.pixelSize: ScreenTools.font22; anchors.top: orientationCalArea.top anchors.left: orientationCalArea.left anchors.topMargin: 15 @@ -480,7 +480,7 @@ QGCView { spacing: 5 QGCLabel { - font.pointSize: sideBarH1PointSize + font.pixelSize: sideBarH1PointSize text: "Autopilot Orientation" } @@ -506,7 +506,7 @@ QGCView { id: compass0ComponentLabel2 QGCLabel { - font.pointSize: sideBarH1PointSize + font.pixelSize: sideBarH1PointSize text: "External Compass Orientation" } } @@ -531,7 +531,7 @@ QGCView { id: compass1ComponentLabel2 QGCLabel { - font.pointSize: sideBarH1PointSize + font.pixelSize: sideBarH1PointSize text: "External Compass 1 Orientation" } } @@ -556,7 +556,7 @@ QGCView { id: compass2ComponentLabel2 QGCLabel { - font.pointSize: sidebarH1PointSize + font.pixelSize: sidebarH1PointSize text: "Compass 2 Orientation" } } diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index 6759af22026d582d90e02f162168b611a0845df4..e79ded5fc0f58e6d955e11e20f67a9cda6918811 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -119,6 +119,7 @@ static QObject* screenToolsSingletonFactory(QQmlEngine*, QJSEngine*) static QObject* mavManagerSingletonFactory(QQmlEngine*, QJSEngine*) { MavManager* mavManager = new MavManager; + qgcApp()->setMavManager(mavManager); return mavManager; } @@ -133,10 +134,11 @@ static QObject* mavManagerSingletonFactory(QQmlEngine*, QJSEngine*) **/ -QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) : - QApplication(argc, argv), - _runningUnitTests(unitTesting), - _styleIsDark(true) +QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) + : QApplication(argc, argv) + , _runningUnitTests(unitTesting) + , _styleIsDark(true) + , _pMavManager(NULL) { Q_ASSERT(_app == NULL); _app = this; @@ -145,46 +147,61 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) : #ifndef __android__ setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); #endif + + // Parse command line options + + bool fClearSettingsOptions = false; // Clear stored settings + bool fullLogging = false; // Turn on all logging + + CmdLineOpt_t rgCmdLineOptions[] = { + { "--clear-settings", &fClearSettingsOptions, QString() }, + { "--full-logging", &fullLogging, QString() }, + // Add additional command line option flags here + }; + + ParseCmdLineOptions(argc, argv, rgCmdLineOptions, sizeof(rgCmdLineOptions)/sizeof(rgCmdLineOptions[0]), false); #ifdef __mobile__ QLoggingCategory::setFilterRules(QStringLiteral("*Log.debug=false")); -#endif - -#ifndef __mobile__ - // First thing we want to do is set up the qtlogging.ini file. If it doesn't already exist we copy - // it to the correct location. This way default debug builds will have logging turned off. +#else + if (fullLogging) { + QLoggingCategory::setFilterRules(QStringLiteral("*Log=true")); + } else { + // First thing we want to do is set up the qtlogging.ini file. If it doesn't already exist we copy + // it to the correct location. This way default debug builds will have logging turned off. - static const char* qtProjectDir = "QtProject"; - static const char* qtLoggingFile = "qtlogging.ini"; - bool loggingDirectoryOk = false; + static const char* qtProjectDir = "QtProject"; + static const char* qtLoggingFile = "qtlogging.ini"; + bool loggingDirectoryOk = false; - QDir iniFileLocation(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation)); - if (!iniFileLocation.cd(qtProjectDir)) { - if (!iniFileLocation.mkdir(qtProjectDir)) { - qDebug() << "Unable to create qtlogging.ini directory" << iniFileLocation.filePath(qtProjectDir); - } else { - if (!iniFileLocation.cd(qtProjectDir)) { - qDebug() << "Unable to access qtlogging.ini directory" << iniFileLocation.filePath(qtProjectDir);; + QDir iniFileLocation(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation)); + if (!iniFileLocation.cd(qtProjectDir)) { + if (!iniFileLocation.mkdir(qtProjectDir)) { + qDebug() << "Unable to create qtlogging.ini directory" << iniFileLocation.filePath(qtProjectDir); + } else { + if (!iniFileLocation.cd(qtProjectDir)) { + qDebug() << "Unable to access qtlogging.ini directory" << iniFileLocation.filePath(qtProjectDir);; + } + loggingDirectoryOk = true; } + } else { loggingDirectoryOk = true; } - } else { - loggingDirectoryOk = true; - } - if (loggingDirectoryOk) { - qDebug () << iniFileLocation; - if (!iniFileLocation.exists(qtLoggingFile)) { - QFile loggingFile(iniFileLocation.filePath(qtLoggingFile)); - if (loggingFile.open(QIODevice::WriteOnly | QIODevice::Text)) { - QTextStream out(&loggingFile); - out << "[Rules]\n"; - out << "*Log.debug=false\n"; - foreach(QString category, QGCLoggingCategoryRegister::instance()->registeredCategories()) { - out << category << ".debug=false\n"; + if (loggingDirectoryOk) { + qDebug () << iniFileLocation; + if (!iniFileLocation.exists(qtLoggingFile)) { + QFile loggingFile(iniFileLocation.filePath(qtLoggingFile)); + if (loggingFile.open(QIODevice::WriteOnly | QIODevice::Text)) { + QTextStream out(&loggingFile); + out << "[Rules]\n"; + out << "*Log.debug=false\n"; + foreach(QString category, QGCLoggingCategoryRegister::instance()->registeredCategories()) { + out << category << ".debug=false\n"; + } + } else { + qDebug() << "Unable to create logging file" << QString(qtLoggingFile) << "in" << iniFileLocation; } - } else { - qDebug() << "Unable to create logging file" << QString(qtLoggingFile) << "in" << iniFileLocation; } } } @@ -215,17 +232,6 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) : // Set settings format QSettings::setDefaultFormat(QSettings::IniFormat); - // Parse command line options - - bool fClearSettingsOptions = false; // Clear stored settings - - CmdLineOpt_t rgCmdLineOptions[] = { - { "--clear-settings", &fClearSettingsOptions, QString() }, - // Add additional command line option flags here - }; - - ParseCmdLineOptions(argc, argv, rgCmdLineOptions, sizeof(rgCmdLineOptions)/sizeof(rgCmdLineOptions[0]), false); - QSettings settings; #ifdef UNITTEST_BUILD qDebug() << "Settings location" << settings.fileName(); @@ -341,7 +347,7 @@ void QGCApplication::_initCommon(void) //-- Create QML Singleton Interfaces qmlRegisterSingletonType("QGroundControl.ScreenTools", 1, 0, "ScreenTools", screenToolsSingletonFactory); qmlRegisterSingletonType("QGroundControl.MavManager", 1, 0, "MavManager", mavManagerSingletonFactory); - + //-- Register Waypoint Interface qmlRegisterInterface("Waypoint"); } @@ -649,33 +655,16 @@ void QGCApplication::_loadCurrentStyle(void) } } - // Now that we have the styles loaded we need to dpi adjust the font point 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; - } - } + // Now that we have the styles loaded we need to adjust the font sizes. - if (!dpiAdjustedStyles.isEmpty()) { - setStyleSheet(dpiAdjustedStyles); - } + QString fSmall = QString("%1px;").arg(ScreenTools::font10_s()); + 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) { // Fall back to plastique if we can't load our own @@ -709,7 +698,19 @@ void QGCApplication::_missingParamsDisplay(void) } _missingParams.clear(); - QGCMessageBox::critical("Missing Parameters", - QString("Parameters missing from firmware: %1.\n\n" - "You should quit QGroundControl immediately and update your firmware.").arg(params)); + QGCMessageBox::critical( + "Missing Parameters", + QString("Parameters missing from firmware: %1.\n\n" + "You should quit QGroundControl immediately and update your firmware.").arg(params)); +} + +void QGCApplication::setMavManager(MavManager* pMgr) +{ + if(!_pMavManager) + _pMavManager = pMgr; +} + +MavManager* QGCApplication::getMavManager() +{ + return _pMavManager; } diff --git a/src/QGCApplication.h b/src/QGCApplication.h index 0e86dc6a0f3ec08e4f18b6b0066e31973ccf6f46..8b01ce266f9653bd605f24822753a3635b226cc6 100644 --- a/src/QGCApplication.h +++ b/src/QGCApplication.h @@ -44,6 +44,7 @@ // Work around circular header includes class QGCSingleton; class MainWindow; +class MavManager; /** * @brief The main application and management class. @@ -99,6 +100,12 @@ public: /// Used to report a missing Parameter. Warning will be displayed to user. Method may be called /// multiple times. void reportMissingParameter(int componentId, const QString& name); + + /// When the singleton is created, it sets a pointer for subsequent use + void setMavManager(MavManager* pMgr); + + /// MavManager accessor + MavManager* getMavManager(); public slots: /// You can connect to this slot to show an information message box from a different thread. @@ -166,7 +173,8 @@ private: static const int _missingParamsDelayedDisplayTimerTimeout = 1000; ///< Timeout to wait for next missing fact to come in before display QTimer _missingParamsDelayedDisplayTimer; ///< Timer use to delay missing fact display QStringList _missingParams; ///< List of missing facts to be displayed - + MavManager* _pMavManager; + /// Unit Test have access to creating and destroying singletons friend class UnitTest; }; diff --git a/src/QGCConfig.h b/src/QGCConfig.h index bf6f0e7a0f322c4d89bc8bb08caebec76d04fb9f..f617a3bbce72a6377cc351a590dfaafa7d8978ef 100644 --- a/src/QGCConfig.h +++ b/src/QGCConfig.h @@ -32,7 +32,7 @@ #endif #ifndef QGC_APPLICATION_VERSION_BUILDTYPE -#define QGC_APPLICATION_VERSION_BUILDTYPE "(Development)" +#define QGC_APPLICATION_VERSION_BUILDTYPE "(Stable)" #endif #endif // QGC_CONFIGURATION_H diff --git a/src/QmlControls/MavManager.cc b/src/QmlControls/MavManager.cc index 5b2ab4e0586ccca41f4b22be30eb9b067d83e246..7c042cafa34772119ea4fc2803abdc5cdecd4b72 100644 --- a/src/QmlControls/MavManager.cc +++ b/src/QmlControls/MavManager.cc @@ -32,6 +32,7 @@ This file is part of the QGROUNDCONTROL project #include "UASManager.h" #include "Waypoint.h" #include "MavManager.h" +#include "UASMessageHandler.h" #define UPDATE_TIMER 50 #define DEFAULT_LAT 38.965767f @@ -40,6 +41,12 @@ This file is part of the QGROUNDCONTROL project MavManager::MavManager(QObject *parent) : QObject(parent) , _mav(NULL) + , _currentMessageCount(0) + , _messageCount(0) + , _currentErrorCount(0) + , _currentWarningCount(0) + , _currentNormalCount(0) + , _currentMessageType(MessageNone) , _roll(0.0f) , _pitch(0.0f) , _heading(0.0f) @@ -99,6 +106,8 @@ QString MavManager::loadSetting(const QString &name, const QString& defaultValue void MavManager::_forgetUAS(UASInterface* uas) { if (_mav != NULL && _mav == uas) { + // Stop listening for system messages + disconnect(UASMessageHandler::instance(), &UASMessageHandler::textMessageCountChanged, this, &MavManager::_handleTextMessage); // Disconnect any previously connected active MAV disconnect(_mav, SIGNAL(attitudeChanged (UASInterface*, double,double,double,quint64)), this, SLOT(_updateAttitude(UASInterface*, double, double, double, quint64))); disconnect(_mav, SIGNAL(attitudeChanged (UASInterface*, int,double,double,double,quint64)), this, SLOT(_updateAttitude(UASInterface*,int,double, double, double, quint64))); @@ -149,6 +158,8 @@ void MavManager::_setActiveUAS(UASInterface* uas) emit heartbeatTimeoutChanged(); // Set new UAS _mav = uas; + // Listen for system messages + connect(UASMessageHandler::instance(), &UASMessageHandler::textMessageCountChanged, this, &MavManager::_handleTextMessage); // Now connect the new UAS connect(_mav, SIGNAL(attitudeChanged (UASInterface*,double,double,double,quint64)), this, SLOT(_updateAttitude(UASInterface*, double, double, double, quint64))); connect(_mav, SIGNAL(attitudeChanged (UASInterface*,int,double,double,double,quint64)), this, SLOT(_updateAttitude(UASInterface*,int,double, double, double, quint64))); @@ -637,3 +648,87 @@ void MavManager::_waypointViewOnlyListChanged() */ } } + +void MavManager::_handleTextMessage(int newCount) +{ + // Reset? + if(!newCount) { + _currentMessageCount = 0; + _currentNormalCount = 0; + _currentWarningCount = 0; + _currentErrorCount = 0; + _messageCount = 0; + _currentMessageType = MessageNone; + emit newMessageCountChanged(); + emit messageTypeChanged(); + emit messageCountChanged(); + return; + } + + UASMessageHandler* pMh = UASMessageHandler::instance(); + Q_ASSERT(pMh); + MessageType_t type = newCount ? _currentMessageType : MessageNone; + int errorCount = _currentErrorCount; + int warnCount = _currentWarningCount; + int normalCount = _currentNormalCount; + //-- Add current message counts + errorCount += pMh->getErrorCount(); + warnCount += pMh->getWarningCount(); + normalCount += pMh->getNormalCount(); + //-- See if we have a higher level + if(errorCount != _currentErrorCount) { + _currentErrorCount = errorCount; + type = MessageError; + } + if(warnCount != _currentWarningCount) { + _currentWarningCount = warnCount; + if(_currentMessageType != MessageError) { + type = MessageWarning; + } + } + if(normalCount != _currentNormalCount) { + _currentNormalCount = normalCount; + if(_currentMessageType != MessageError && _currentMessageType != MessageWarning) { + type = MessageNormal; + } + } + int count = _currentErrorCount + _currentWarningCount + _currentNormalCount; + if(count != _currentMessageCount) { + _currentMessageCount = count; + // Display current total new messages count + emit newMessageCountChanged(); + } + if(type != _currentMessageType) { + _currentMessageType = type; + // Update message level + emit messageTypeChanged(); + } + // Update message count (all messages) + if(newCount != _messageCount) { + _messageCount = newCount; + emit messageCountChanged(); + } + QString errMsg = pMh->getLatestError(); + if(errMsg != _latestError) { + _latestError = errMsg; + emit latestErrorChanged(); + } +} + +void MavManager::resetMessages() +{ + // Reset Counts + int count = _currentMessageCount; + MessageType_t type = _currentMessageType; + _currentErrorCount = 0; + _currentWarningCount = 0; + _currentNormalCount = 0; + _currentMessageCount = 0; + _currentMessageType = MessageNone; + if(count != _currentMessageCount) { + emit newMessageCountChanged(); + } + if(type != _currentMessageType) { + emit messageTypeChanged(); + } +} diff --git a/src/QmlControls/MavManager.h b/src/QmlControls/MavManager.h index 46b329a9b57040e87613174b1d67191019cd6341..87e6e1b26a16e6f0e5af4f3713ccfd3d6a41565f 100644 --- a/src/QmlControls/MavManager.h +++ b/src/QmlControls/MavManager.h @@ -46,6 +46,13 @@ public: explicit MavManager(QObject *parent = 0); ~MavManager(); + typedef enum { + MessageNone, + MessageNormal, + MessageWarning, + MessageError + } MessageType_t; + enum { ROLL_CHANGED, PITCH_CHANGED, @@ -58,10 +65,19 @@ public: ALTITUDEAMSL_CHANGED }; + // Called when the message drop-down is invoked to clear current count + void resetMessages(); + Q_INVOKABLE QString getMavIconColor(); Q_INVOKABLE void saveSetting (const QString &key, const QString& value); Q_INVOKABLE QString loadSetting (const QString &key, const QString& defaultValue); + //-- System Messages + Q_PROPERTY(MessageType_t messageType READ messageType NOTIFY messageTypeChanged) + Q_PROPERTY(int newMessageCount READ newMessageCount NOTIFY newMessageCountChanged) + Q_PROPERTY(int messageCount READ messageCount NOTIFY messageCountChanged) + Q_PROPERTY(QString latestError READ latestError NOTIFY latestErrorChanged) + //-- UAV Stats Q_PROPERTY(float roll READ roll NOTIFY rollChanged) Q_PROPERTY(float pitch READ pitch NOTIFY pitchChanged) Q_PROPERTY(float heading READ heading NOTIFY headingChanged) @@ -87,8 +103,13 @@ public: Q_PROPERTY(double waypointDistance READ waypointDistance NOTIFY waypointDistanceChanged) Q_PROPERTY(uint16_t currentWaypoint READ currentWaypoint NOTIFY currentWaypointChanged) Q_PROPERTY(unsigned int heartbeatTimeout READ heartbeatTimeout NOTIFY heartbeatTimeoutChanged) + //-- Waypoint management Q_PROPERTY(QQmlListProperty waypoints READ waypoints NOTIFY waypointsChanged) + MessageType_t messageType () { return _currentMessageType; } + int newMessageCount () { return _currentMessageCount; } + int messageCount () { return _messageCount; } + QString latestError () { return _latestError; } float roll () { return _roll; } float pitch () { return _pitch; } float heading () { return _heading; } @@ -118,6 +139,10 @@ public: QQmlListProperty waypoints() {return QQmlListProperty(this, _waypoints); } signals: + void messageTypeChanged (); + void newMessageCountChanged (); + void messageCountChanged (); + void latestErrorChanged (); void rollChanged (); void pitchChanged (); void headingChanged (); @@ -147,6 +172,7 @@ signals: void waypointsChanged (); private slots: + void _handleTextMessage (int newCount); /** @brief Attitude from main autopilot / system state */ void _updateAttitude (UASInterface* uas, double roll, double pitch, double yaw, quint64 timestamp); /** @brief Attitude from one specific component / redundant autopilot */ @@ -182,6 +208,13 @@ private: private: UASInterface* _mav; + int _currentMessageCount; + int _messageCount; + int _currentErrorCount; + int _currentWarningCount; + int _currentNormalCount; + MessageType_t _currentMessageType; + QString _latestError; float _roll; float _pitch; float _heading; diff --git a/src/QmlControls/ParameterEditor.qml b/src/QmlControls/ParameterEditor.qml index 43e319044caafecb795ad6f2cf88d9b72bd604fa..0250b87fe6c22bb63c0c50565052cba64639a8e0 100644 --- a/src/QmlControls/ParameterEditor.qml +++ b/src/QmlControls/ParameterEditor.qml @@ -66,7 +66,7 @@ QGCView { height: defaultTextHeight + (ScreenTools.pixelSizeFactor * (9)) text: group verticalAlignment: Text.AlignVCenter - font.pointSize: ScreenTools.fontPointFactor * (16); + font.pixelSize: ScreenTools.font16; } Rectangle { @@ -142,7 +142,7 @@ QGCView { height: firstButton.height QGCLabel { - font.pointSize: ScreenTools.fontPointFactor * (20) + font.pixelSize: ScreenTools.font20; visible: fullMode text: "PARAMETER EDITOR" } @@ -202,7 +202,7 @@ QGCView { height: contentHeight + (ScreenTools.pixelSizeFactor * (9)) text: "Component #: " + componentId.toString() verticalAlignment: Text.AlignVCenter - font.pointSize: ScreenTools.fontPointFactor * (16); + font.pixelSize: ScreenTools.font16; } Repeater { @@ -357,4 +357,4 @@ QGCView { } } // Rectangle - editorDialog } // Component - Editor Dialog -} // QGCView \ No newline at end of file +} // QGCView diff --git a/src/QmlControls/QGCButton.qml b/src/QmlControls/QGCButton.qml index 716549a3c4a9ac0f5f041d9cee0d08c8c8477d9c..02ba38d3765f75edad40daaa4696631a2fc40890 100644 --- a/src/QmlControls/QGCButton.qml +++ b/src/QmlControls/QGCButton.qml @@ -104,7 +104,7 @@ Button { id: text antialiasing: true text: control.text - font.pointSize: ScreenTools.defaultFontPointSize + font.pixelSize: ScreenTools.defaultFontPizelSize anchors.verticalCenter: parent.verticalCenter diff --git a/src/QmlControls/QGCCheckBox.qml b/src/QmlControls/QGCCheckBox.qml index 6403ccdf7b5092470919d8a451829b167e7ead4a..84f990bae54b121314d29915f26a3bca75dba0f5 100644 --- a/src/QmlControls/QGCCheckBox.qml +++ b/src/QmlControls/QGCCheckBox.qml @@ -29,7 +29,7 @@ CheckBox { id: text text: control.text antialiasing: true - font.pointSize: ScreenTools.defaultFontPointSize + font.pixelSize: ScreenTools.defaultFontPizelSize anchors.centerIn: parent diff --git a/src/QmlControls/QGCComboBox.qml b/src/QmlControls/QGCComboBox.qml index efdc83cc140b0e04f52c841fee9e5858606fd599..e9849ec6529ff2f7fe3481b42d8599d3805f74d9 100644 --- a/src/QmlControls/QGCComboBox.qml +++ b/src/QmlControls/QGCComboBox.qml @@ -11,7 +11,7 @@ ComboBox { property bool __showHighlight: pressed | hovered style: ComboBoxStyle { - font.pointSize: ScreenTools.defaultFontPointSize + font.pixelSize: ScreenTools.defaultFontPizelSize textColor: __showHighlight ? control.__qgcPal.buttonHighlightText : control.__qgcPal.buttonText diff --git a/src/QmlControls/QGCLabel.qml b/src/QmlControls/QGCLabel.qml index ab9261d8716a51cceec324381992a1a104df003d..0b3eafdd509bfcf757e4aa549c496089f0ff24f5 100644 --- a/src/QmlControls/QGCLabel.qml +++ b/src/QmlControls/QGCLabel.qml @@ -10,7 +10,7 @@ Text { property bool enabled: true - font.pointSize: ScreenTools.defaultFontPointSize + font.pixelSize: ScreenTools.defaultFontPizelSize color: __qgcPal.text antialiasing: true } diff --git a/src/QmlControls/QGCRadioButton.qml b/src/QmlControls/QGCRadioButton.qml index 3f2bad99a58e4e2c81e2acaaabacdc6eaea99019..099038fb65810f108cacac2c75392bb90533e0bb 100644 --- a/src/QmlControls/QGCRadioButton.qml +++ b/src/QmlControls/QGCRadioButton.qml @@ -28,7 +28,7 @@ RadioButton { Text { id: text text: control.text - font.pointSize: ScreenTools.defaultFontPointSize + font.pixelSize: ScreenTools.defaultFontPizelSize antialiasing: true anchors.centerIn: parent diff --git a/src/QmlControls/QGCTextField.qml b/src/QmlControls/QGCTextField.qml index 96a6caa95212064859d6fdd4b20f25563222c3ec..a5c2d1c1613ad8072cd697f7910dcd0f40412284 100644 --- a/src/QmlControls/QGCTextField.qml +++ b/src/QmlControls/QGCTextField.qml @@ -50,7 +50,7 @@ TextField { width: unitsLabelWidthGenerator.width text: control.unitsLabel - font.pointSize: ScreenTools.defaultFontPointSize + font.pixelSize: ScreenTools.defaultFontPizelSize antialiasing: true color: control.textColor diff --git a/src/QmlControls/ScreenTools.cc b/src/QmlControls/ScreenTools.cc index c7d59f4cf69aec041a01f7cc06c899ba2b556744..70326f967bf7875c866b69c4859d6b459e6d9f6d 100644 --- a/src/QmlControls/ScreenTools.cc +++ b/src/QmlControls/ScreenTools.cc @@ -27,35 +27,55 @@ #include "ScreenTools.h" #include "MainWindow.h" -#include -#include - -const double ScreenTools::_defaultFontPointSize = 13; -const double ScreenTools::_mediumFontPointSize = 16; -const double ScreenTools::_largeFontPointSize = 20; +// Pixel size, instead of a physical thing is actually a philosophical question when +// it comes to Qt. +// 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 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() { MainWindow* mainWindow = MainWindow::instance(); - // Unit tests can run Qml without MainWindow if (mainWindow) { - connect(mainWindow, &MainWindow::repaintCanvas, this, &ScreenTools::_updateCanvas); - connect(mainWindow, &MainWindow::pixelSizeChanged, this, &ScreenTools::_updatePixelSize); - connect(mainWindow, &MainWindow::fontSizeChanged, this, &ScreenTools::_updateFontSize); + connect(mainWindow, &MainWindow::repaintCanvas, this, &ScreenTools::_updateCanvas); } } -qreal ScreenTools::adjustFontPointSize(qreal pointSize) -{ - return adjustFontPointSize_s(pointSize); -} - -qreal ScreenTools::adjustFontPointSize_s(qreal pointSize) -{ - return pointSize * MainWindow::fontPointFactor(); -} - qreal ScreenTools::adjustPixelSize(qreal pixelSize) { return adjustPixelSize_s(pixelSize); @@ -63,66 +83,10 @@ qreal ScreenTools::adjustPixelSize(qreal pixelSize) qreal ScreenTools::adjustPixelSize_s(qreal pixelSize) { - return pixelSize * MainWindow::pixelSizeFactor(); -} - -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); + return pixelSize * _pixelFactor; } void ScreenTools::_updateCanvas() { 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(); -} diff --git a/src/QmlControls/ScreenTools.h b/src/QmlControls/ScreenTools.h index 6c1f9cabb77bfdc5ba24a4e9d52193819c11561e..2f73ae8f7c3f316362a84bf0c13ae4dde701c2d4 100644 --- a/src/QmlControls/ScreenTools.h +++ b/src/QmlControls/ScreenTools.h @@ -80,46 +80,87 @@ public: @endcode */ - Q_PROPERTY(bool repaintRequested READ repaintRequested NOTIFY repaintRequestedChanged) - //! Returns the font point size factor - Q_PROPERTY(double fontPointFactor READ fontPointFactor NOTIFY fontPointFactorChanged) - //! Returns the pixel size factor - Q_PROPERTY(double pixelSizeFactor READ pixelSizeFactor NOTIFY pixelSizeFactorChanged) - + //! Font sizes + Q_PROPERTY(int font22 READ font22 CONSTANT) + Q_PROPERTY(int font21 READ font21 CONSTANT) + Q_PROPERTY(int font20 READ font20 CONSTANT) + 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) - 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) - 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) - 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_INVOKABLE qreal adjustFontPointSize(qreal pointSize); + Q_PROPERTY(bool repaintRequested READ repaintRequested NOTIFY repaintRequestedChanged) + //! Returns the pixel size factor + Q_PROPERTY(double pixelSizeFactor READ pixelSizeFactor CONSTANT) + //! Utility for adjusting pixel size. Not dynamic (no signals) 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 qreal adjustPixelSize_s(qreal pixelSize); int mouseX () { return QCursor::pos().x(); } int mouseY () { return QCursor::pos().y(); } bool repaintRequested () { return true; } - double fontPointFactor (); - double pixelSizeFactor (); - double defaultFontPointSize(void); - double mediumFontPointSize(void); - double largeFontPointSize(void); + double pixelSizeFactor () { return _pixelFactor; } + + int font22 () { return _font22; } + int font21 () { return _font21; } + 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__) bool isAndroid () { return true; } @@ -137,19 +178,29 @@ public: signals: void repaintRequestedChanged(); - void pixelSizeFactorChanged(); - void fontPointFactorChanged(); - void fontSizesChanged(); private slots: void _updateCanvas(); - void _updatePixelSize(); - void _updateFontSize(); private: - static const double _defaultFontPointSize; - static const double _mediumFontPointSize; - static const double _largeFontPointSize; + // Font Sizes + static int _font8; + 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 diff --git a/src/QmlControls/SubMenuButton.qml b/src/QmlControls/SubMenuButton.qml index 845a4715c60d27fcc15b587907f49cdfc9cdf7f6..97e2a476283805763f2425f21ab955cbba657170 100644 --- a/src/QmlControls/SubMenuButton.qml +++ b/src/QmlControls/SubMenuButton.qml @@ -40,7 +40,7 @@ Button { horizontalAlignment: TextEdit.AlignHCenter text: control.text - font.pointSize: ScreenTools.defaultFontPointSize + font.pixelSize: ScreenTools.defaultFontPizelSize antialiasing: true color: __showHighlight ? __qgcPal.buttonHighlightText : __qgcPal.buttonText diff --git a/src/QmlControls/VehicleRotationCal.qml b/src/QmlControls/VehicleRotationCal.qml index d1e2e3e06025cdbb905c6b8ef12cc6b5f1dd94de..e70ead7f1acee07fc4859d7953599e217e693908 100644 --- a/src/QmlControls/VehicleRotationCal.qml +++ b/src/QmlControls/VehicleRotationCal.qml @@ -70,10 +70,9 @@ Rectangle { height: parent.height horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignBottom - font.pointSize: ScreenTools.fontPointFactor * (25); + font.pixelSize: ScreenTools.font22; font.bold: true color: "black" - text: parent.calText } QGCLabel { @@ -81,9 +80,8 @@ Rectangle { height: parent.height horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignBottom - font.pointSize: ScreenTools.fontPointFactor * (25); + font.pixelSize: ScreenTools.font22; color: calInProgress ? "yellow" : "white" - text: parent.calText } } diff --git a/src/VehicleSetup/FirmwareUpgrade.qml b/src/VehicleSetup/FirmwareUpgrade.qml index 00167b2368190c3f39f43f2d6854899876e2be3f..c726ea4953190566a09dd32361c92c7ccbc062f9 100644 --- a/src/VehicleSetup/FirmwareUpgrade.qml +++ b/src/VehicleSetup/FirmwareUpgrade.qml @@ -74,7 +74,7 @@ QGCView { QGCLabel { text: "FIRMWARE UPDATE" - font.pointSize: ScreenTools.fontPointFactor * (20); + font.pixelSize: ScreenTools.font20; } Item { @@ -177,7 +177,7 @@ QGCView { height: 300 readOnly: true frameVisible: false - font.pointSize: ScreenTools.defaultFontPointSize + font.pixelSize: ScreenTools.defaultFontPizelSize text: qsTr("Please disconnect all vehicles from QGroundControl before selecting Upgrade.") @@ -188,4 +188,4 @@ QGCView { } } // Column } // QGCViewPanel -} // QGCView \ No newline at end of file +} // QGCView diff --git a/src/VehicleSetup/SetupView.qml b/src/VehicleSetup/SetupView.qml index 5eb099515734e0ea9b187afc387f61d869db2721..6f45b679a0474c3f4ea44510c68eeaa17f5b6365 100644 --- a/src/VehicleSetup/SetupView.qml +++ b/src/VehicleSetup/SetupView.qml @@ -114,7 +114,7 @@ Rectangle { verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter wrapMode: Text.WordWrap - font.pointSize: ScreenTools.mediumFontPointSize + font.pixelSize: ScreenTools.mediumFontPixelSize text: "Welcome to QGroundControl. " + "QGroundControl supports any mavlink enabled vehicle. " + "If you are using the PX4 Flight Stack, you also get full support for setting up and calibrating your vehicle. "+ @@ -136,7 +136,7 @@ Rectangle { verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter wrapMode: Text.WordWrap - font.pointSize: ScreenTools.mediumFontPointSize + font.pixelSize: ScreenTools.mediumFontPixelSize text: messagePanelText } } diff --git a/src/VehicleSetup/VehicleSummary.qml b/src/VehicleSetup/VehicleSummary.qml index 21657f06ded14283a7dab04310e46c67b8db76d3..339c671068f585cda79c01bc80032fae13cc8ab0 100644 --- a/src/VehicleSetup/VehicleSummary.qml +++ b/src/VehicleSetup/VehicleSummary.qml @@ -46,7 +46,7 @@ Rectangle { QGCLabel { text: "VEHICLE SUMMARY" - font.pointSize: ScreenTools.fontPointFactor * (20); + font.pixelSize: ScreenTools.font20; } Item { @@ -59,7 +59,7 @@ Rectangle { width: parent.width wrapMode: Text.WordWrap color: setupComplete ? qgcPal.text : "red" - font.pointSize: setupComplete ? ScreenTools.defaultFontPointSize : ScreenTools.fontPointFactor * (20) + font.pixelSize: setupComplete ? ScreenTools.defaultFontPizelSize : ScreenTools.font20 text: setupComplete ? "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." diff --git a/src/ViewWidgets/CustomCommandWidget.qml b/src/ViewWidgets/CustomCommandWidget.qml index 5f353f065774bb76a8a0d0240836d39803a54002..d95543648343b4fdbb7a6e482333d0e89fa7332f 100644 --- a/src/ViewWidgets/CustomCommandWidget.qml +++ b/src/ViewWidgets/CustomCommandWidget.qml @@ -37,8 +37,11 @@ ViewWidget { id: commandComponenet Item { + id: bogusFactPanel - CustomCommandWidgetController { id: controller } + // We aren't really using the controller in a FactPanel for this usage so we + // pass in a bogus item to keep it from getting upset. + CustomCommandWidgetController { id: controller; factPanel: bogusFactPanel } Item { anchors.top: parent.top diff --git a/src/audio/QGCAudioWorker.cpp b/src/audio/QGCAudioWorker.cpp index 4425a7908725de69f00159264cb6106cbe5405d3..4fa827cd51c05cb537b7b6906da20c63770e9e77 100644 --- a/src/audio/QGCAudioWorker.cpp +++ b/src/audio/QGCAudioWorker.cpp @@ -191,14 +191,28 @@ QString QGCAudioWorker::_fixTextMessageForAudio(const QString& string) { QString match; QString newNumber; QString result = string; - //-- Look for modes + //-- Look for codified terms + if(result.contains("ERR ", Qt::CaseInsensitive)) { + result.replace("ERR ", "error ", Qt::CaseInsensitive); + } + if(result.contains("ERR:", Qt::CaseInsensitive)) { + result.replace("ERR:", "error.", Qt::CaseInsensitive); + } if(result.contains("POSCTL", Qt::CaseInsensitive)) { result.replace("POSCTL", "Position Control", Qt::CaseInsensitive); - } else if(result.contains("ALTCTL", Qt::CaseInsensitive)) { + } + if(result.contains("ALTCTL", Qt::CaseInsensitive)) { result.replace("ALTCTL", "Altitude Control", Qt::CaseInsensitive); - } else if(result.contains("RTL", Qt::CaseInsensitive)) { + } + if(result.contains("RTL", Qt::CaseInsensitive)) { result.replace("RTL", "Return To Land", Qt::CaseInsensitive); } + if(result.contains("ACCEL ", Qt::CaseInsensitive)) { + result.replace("ACCEL ", "accelerometer ", Qt::CaseInsensitive); + } + if(result.contains("RC_MAP_MODE_SW", Qt::CaseInsensitive)) { + result.replace("RC_MAP_MODE_SW", "RC mode switch", Qt::CaseInsensitive); + } int number; if(_getMillisecondString(string, match, number) && number > 1000) { if(number < 60000) { diff --git a/src/comm/LinkManager.cc b/src/comm/LinkManager.cc index 879bfdc65183181563935c72db304b5e0ed4bc92..eb4dabf44103f272b804ed663c59dcece4b2a2ae 100644 --- a/src/comm/LinkManager.cc +++ b/src/comm/LinkManager.cc @@ -459,6 +459,8 @@ void LinkManager::_updateConfigurationList(void) QList portList = QSerialPortInfo::availablePorts(); // Iterate Comm Ports foreach (QSerialPortInfo portInfo, portList) { +#if 0 + // Too noisy for most logging, so turn on as needed qCDebug(LinkManagerLog) << "-----------------------------------------------------"; qCDebug(LinkManagerLog) << "portName: " << portInfo.portName(); qCDebug(LinkManagerLog) << "systemLocation: " << portInfo.systemLocation(); @@ -466,6 +468,7 @@ void LinkManager::_updateConfigurationList(void) qCDebug(LinkManagerLog) << "manufacturer: " << portInfo.manufacturer(); qCDebug(LinkManagerLog) << "serialNumber: " << portInfo.serialNumber(); qCDebug(LinkManagerLog) << "vendorIdentifier: " << portInfo.vendorIdentifier(); +#endif // Save port name currentPorts << portInfo.systemLocation(); // Is this a PX4 and NOT in bootloader mode? diff --git a/src/comm/QGCXPlaneLink.cc b/src/comm/QGCXPlaneLink.cc index e680b641e467f57eaa8d545ff950cd2fc2d8cb55..98e7f63d999030193084c5c6754fc4666f7a0413 100644 --- a/src/comm/QGCXPlaneLink.cc +++ b/src/comm/QGCXPlaneLink.cc @@ -237,15 +237,16 @@ void QGCXPlaneLink::run() QGC::SLEEP::msleep(5); } - if (mav) + uas = dynamic_cast(mav); + if (uas) { - disconnect(mav, SIGNAL(hilControlsChanged(quint64, float, float, float, float, quint8, quint8)), this, SLOT(updateControls(quint64,float,float,float,float,quint8,quint8))); - disconnect(mav, SIGNAL(hilActuatorsChanged(quint64, float, float, float, float, float, float, float, float)), this, SLOT(updateActuators(quint64,float,float,float,float,float,float,float,float))); + disconnect(uas, SIGNAL(hilControlsChanged(quint64, float, float, float, float, quint8, quint8)), this, SLOT(updateControls(quint64,float,float,float,float,quint8,quint8))); + disconnect(uas, SIGNAL(hilActuatorsChanged(quint64, float, float, float, float, float, float, float, float)), this, SLOT(updateActuators(quint64,float,float,float,float,float,float,float,float))); - disconnect(this, SIGNAL(hilGroundTruthChanged(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float)), mav, SLOT(sendHilGroundTruth(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float))); - disconnect(this, SIGNAL(hilStateChanged(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float)), mav, SLOT(sendHilState(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float))); - disconnect(this, SIGNAL(sensorHilGpsChanged(quint64,double,double,double,int,float,float,float,float,float,float,float,int)), mav, SLOT(sendHilGps(quint64,double,double,double,int,float,float,float,float,float,float,float,int))); - disconnect(this, SIGNAL(sensorHilRawImuChanged(quint64,float,float,float,float,float,float,float,float,float,float,float,float,float,quint32)), mav, SLOT(sendHilSensors(quint64,float,float,float,float,float,float,float,float,float,float,float,float,float,quint32))); + disconnect(this, SIGNAL(hilGroundTruthChanged(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float)), uas, SLOT(sendHilGroundTruth(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float))); + disconnect(this, SIGNAL(hilStateChanged(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float)), uas, SLOT(sendHilState(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float))); + disconnect(this, SIGNAL(sensorHilGpsChanged(quint64,double,double,double,int,float,float,float,float,float,float,float,int)), uas, SLOT(sendHilGps(quint64,double,double,double,int,float,float,float,float,float,float,float,int))); + disconnect(this, SIGNAL(sensorHilRawImuChanged(quint64,float,float,float,float,float,float,float,float,float,float,float,float,float,quint32)), uas, SLOT(sendHilSensors(quint64,float,float,float,float,float,float,float,float,float,float,float,float,float,quint32))); // Do not toggle HIL state on the UAS - this is not the job of this link, but of the // UAS object diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index 6cb37da585e215e3a8b7fa6c611f0fcd951da50a..957bc5004b36f562c6c45fbc46f544f5350bedbe 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -1473,6 +1473,9 @@ void UAS::startCalibration(UASInterface::StartCalibrationType calType) case StartCalibrationRadio: radioCal = 1; break; + case StartCalibrationCopyTrims: + radioCal = 2; + break; case StartCalibrationAccel: accelCal = 1; break; diff --git a/src/uas/UASInterface.h b/src/uas/UASInterface.h index ce6e9291f60f3b31f0ced00c8b2fc74d82a2a140..f535abba8225054b7c45a55fb954833bb751ae13 100644 --- a/src/uas/UASInterface.h +++ b/src/uas/UASInterface.h @@ -245,7 +245,8 @@ public: StartCalibrationAirspeed, StartCalibrationAccel, StartCalibrationLevel, - StartCalibrationEsc + StartCalibrationEsc, + StartCalibrationCopyTrims }; /// Starts the specified calibration diff --git a/src/uas/UASManager.cc b/src/uas/UASManager.cc index 5e015709f997cd749f5c26c2df00f8a4c6a36acf..23ccb3a64d95dce30a630ebfd73c1f37db138657 100644 --- a/src/uas/UASManager.cc +++ b/src/uas/UASManager.cc @@ -340,6 +340,7 @@ void UASManager::removeUAS(UASInterface* uas) // Notify other UI elements that a UAS is being deleted before finally deleting it. qDebug() << "Deleting UAS object: " << uas->getUASName(); emit UASDeleted(uas); + emit UASDeleted(uas->getUASID()); uas->deleteLater(); } } diff --git a/src/uas/UASManagerInterface.h b/src/uas/UASManagerInterface.h index c96c32655bef43cbca91c4d01d0e1555033604f6..cadf92bb827affdc155023ded5a01bbcb1658642 100644 --- a/src/uas/UASManagerInterface.h +++ b/src/uas/UASManagerInterface.h @@ -98,6 +98,8 @@ signals: void UASCreated(UASInterface* UAS); /** A system was deleted */ void UASDeleted(UASInterface* UAS); + /** A system was deleted */ + void UASDeleted(int systemId); /** @brief The UAS currently under main operator control changed */ void activeUASSet(UASInterface* UAS); /** @brief The UAS currently under main operator control changed */ diff --git a/src/uas/UASMessageHandler.cc b/src/uas/UASMessageHandler.cc index 0db804144841667ec62459ebfd13d64708415c85..db2b1be6391b9662b08e1ad67812aac6b3482006 100644 --- a/src/uas/UASMessageHandler.cc +++ b/src/uas/UASMessageHandler.cc @@ -163,6 +163,17 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString message->_setFormatedText(QString("

[%2 - COMP:%3]%4 %5

").arg(style).arg(dateString).arg(compId).arg(severityText).arg(text)); _messages.append(message); int count = _messages.count(); + switch (severity) + { + case MAV_SEVERITY_EMERGENCY: + case MAV_SEVERITY_ALERT: + case MAV_SEVERITY_CRITICAL: + case MAV_SEVERITY_ERROR: + _latestError = severityText + " " + text; + break; + default: + break; + } _mutex.unlock(); emit textMessageReceived(message); emit textMessageCountChanged(count); diff --git a/src/uas/UASMessageHandler.h b/src/uas/UASMessageHandler.h index 616ff3f2100395c33b844227d0c4b07f024db897..da1d2b40dfa1c8aa00d543e0069117900929112c 100644 --- a/src/uas/UASMessageHandler.h +++ b/src/uas/UASMessageHandler.h @@ -107,6 +107,10 @@ public: * @brief Get normal message count (Resets count once read) */ int getNormalCount(); + /** + * @brief Get latest error message + */ + QString getLatestError() { return _latestError; } public slots: /** * @brief Set currently active UAS @@ -140,6 +144,7 @@ private: int _errorCount; int _warningCount; int _normalCount; + QString _latestError; }; #endif // QGCMESSAGEHANDLER_H diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index 57b97d5b136161cac1874a7ec842bdc7bca777d4..13fd3147556c3d3959e557ea6429d1826a2252d9 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -83,29 +83,6 @@ This file is part of the QGROUNDCONTROL project #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 const char* MAIN_SETTINGS_GROUP = "QGC_MAINWINDOW"; @@ -689,8 +666,6 @@ void MainWindow::loadSettings() _autoReconnect = settings.value("AUTO_RECONNECT", _autoReconnect).toBool(); _lowPowerMode = settings.value("LOW_POWER_MODE", _lowPowerMode).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(); } @@ -701,8 +676,6 @@ void MainWindow::storeSettings() settings.setValue("AUTO_RECONNECT", _autoReconnect); settings.setValue("LOW_POWER_MODE", _lowPowerMode); settings.setValue("SHOW_STATUSBAR", _showStatusBar); - settings.setValue("FONT_SIZE_FACTOR", _fontFactor); - settings.setValue("PIXEL_SIZE_FACTOR", _pixelFactor); settings.endGroup(); settings.setValue(_getWindowGeometryKey(), saveGeometry()); @@ -796,6 +769,7 @@ void MainWindow::connectCommonActions() // Connect internal actions connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(UASCreated(UASInterface*))); + connect(UASManager::instance(), SIGNAL(UASDeleted(int)), this, SLOT(UASDeleted(int))); // Unmanned System controls connect(_ui.actionLiftoff, SIGNAL(triggered()), UASManager::instance(), SLOT(launchActiveUAS())); @@ -909,6 +883,14 @@ void MainWindow::UASCreated(UASInterface* uas) } } +void MainWindow::UASDeleted(int uasId) +{ + if (_mapUasId2HilDockWidget.contains(uasId)) { + _mapUasId2HilDockWidget[uasId]->deleteLater(); + _mapUasId2HilDockWidget.remove(uasId); + } +} + /// Stores the state of the toolbar, status bar and widgets associated with the current view void MainWindow::_storeCurrentViewState(void) { @@ -1190,22 +1172,6 @@ void MainWindow::_linkStateChange(LinkInterface*) 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 bool MainWindow::x11Event(XEvent *event) { diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 4ba330997b9fb836823129135b38e8de725179ff..c2923fccb7af9ddca581faeb2192f1c942ed2667 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -130,15 +130,6 @@ public: 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: /** @brief Show the application settings */ void showSettings(); @@ -146,6 +137,9 @@ public slots: /** @brief Add a new UAS */ void UASCreated(UASInterface* uas); + /** @brief Remove an old UAS */ + void UASDeleted(int uasID); + void handleMisconfiguration(UASInterface* uas); /** @brief Load configuration views */ void loadSetupView(); @@ -206,10 +200,6 @@ signals: 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 */ void repaintCanvas(); - /** Emitted when pixel size factor changes */ - void pixelSizeChanged(); - /** Emitted when pixel size factor changes */ - void fontSizeChanged(); #ifdef QGC_MOUSE_ENABLED_LINUX /** @brief Forward X11Event to catch 3DMouse inputs */ @@ -370,10 +360,6 @@ private: QString _getWindowStateKey(); QString _getWindowGeometryKey(); - // UI Dimension Factors - static double _pixelFactor; - static double _fontFactor; - }; #endif /* _MAINWINDOW_H_ */ diff --git a/src/ui/QGCHilConfiguration.cc b/src/ui/QGCHilConfiguration.cc index 61bed1ac64386d330067c61905c3a4a5d022ed54..58bca7e14ae9730446f8b6661885c71849026116 100644 --- a/src/ui/QGCHilConfiguration.cc +++ b/src/ui/QGCHilConfiguration.cc @@ -29,6 +29,8 @@ QGCHilConfiguration::QGCHilConfiguration(UAS *mav, QWidget *parent) : } settings.endGroup(); + + connect(mav, SIGNAL(destroyed()), this, SLOT(deleteLater())); } void QGCHilConfiguration::receiveStatusMessage(const QString& message) diff --git a/src/ui/QGCHilXPlaneConfiguration.cc b/src/ui/QGCHilXPlaneConfiguration.cc index 6ba50eda41f33ebfe44154a1c7c73322a73c56a6..9e1e015dfafa971d60906ebaf471586d9efbe202 100644 --- a/src/ui/QGCHilXPlaneConfiguration.cc +++ b/src/ui/QGCHilXPlaneConfiguration.cc @@ -26,10 +26,10 @@ QGCHilXPlaneConfiguration::QGCHilXPlaneConfiguration(QGCHilLink* link, QWidget * // connect(ui->randomAttitudeButton, SIGNAL(clicked()), link, SLOT(setRandomAttitude())); // connect(ui->randomPositionButton, SIGNAL(clicked()), link, SLOT(setRandomPosition())); - ui->airframeComboBox->setCurrentIndex(link->getAirFrameIndex()); - connect(ui->airframeComboBox, SIGNAL(activated(QString)), link, SLOT(selectAirframe(QString))); + //ui->airframeComboBox->setCurrentIndex(link->getAirFrameIndex()); + //connect(ui->airframeComboBox, SIGNAL(activated(QString)), link, SLOT(selectAirframe(QString))); // XXX not implemented yet - ui->airframeComboBox->hide(); + //ui->airframeComboBox->hide(); ui->sensorHilCheckBox->setChecked(xplane->sensorHilEnabled()); connect(xplane, SIGNAL(sensorHilChanged(bool)), ui->sensorHilCheckBox, SLOT(setChecked(bool))); connect(ui->sensorHilCheckBox, SIGNAL(clicked(bool)), xplane, SLOT(enableSensorHIL(bool))); diff --git a/src/ui/QGCHilXPlaneConfiguration.ui b/src/ui/QGCHilXPlaneConfiguration.ui index 278f35eb25701eaf1d5495d0af9466b6b5fb8c90..1f5007d7ff4b24d56987604aa3d6f8dadaa3dd4f 100644 --- a/src/ui/QGCHilXPlaneConfiguration.ui +++ b/src/ui/QGCHilXPlaneConfiguration.ui @@ -6,89 +6,27 @@ 0 0 - 570 - 238 + 226 + 150 Form - - + + 0 - - - - Start - - - - - - - true - - - - X-Plane default - - - - - QRO_X/MK - - - - - QRO_X/Ardrone - - - - - QRO_X/PWM - - - - - Unlimited - - - - - Twinjet - - - - - Early Bird - - - - - Reno Racer - - - - - Slowstick - - - - - Tiny - - - - - - - - Set HOME - - - - + + 0 + + + 0 + + + 0 + + true @@ -100,28 +38,21 @@ - + Host - - - - Airframe - - - - + Enable sensor level HIL - + Qt::Vertical @@ -134,6 +65,13 @@ + + + + Start + + + diff --git a/src/ui/flightdisplay/FlightDisplay.cc b/src/ui/flightdisplay/FlightDisplay.cc index 7ba501f2966be1aca526adc7f76c88a7b5580308..076255dd0517422a5526ca9142796c643af5a60b 100644 --- a/src/ui/flightdisplay/FlightDisplay.cc +++ b/src/ui/flightdisplay/FlightDisplay.cc @@ -31,7 +31,7 @@ This file is part of the QGROUNDCONTROL project #include #include -#include "MainWindow.h" +#include "ScreenTools.h" #include "FlightDisplay.h" #include "UASManager.h" @@ -48,8 +48,8 @@ FlightDisplay::FlightDisplay(QWidget *parent) pl->setContentsMargins(0,0,0,0); } #ifndef __android__ - setMinimumWidth( 380 * MainWindow::pixelSizeFactor()); - setMinimumHeight(400 * MainWindow::pixelSizeFactor()); + setMinimumWidth( 380 * ScreenTools::pixelSizeFactor_s()); + setMinimumHeight(400 * ScreenTools::pixelSizeFactor_s()); #endif setContextPropertyObject("flightDisplay", this); setSource(QUrl::fromUserInput("qrc:/qml/FlightDisplay.qml")); diff --git a/src/ui/flightdisplay/FlightDisplay.qml b/src/ui/flightdisplay/FlightDisplay.qml index 074f9a253031523fbb0dddb98fec8653f840465a..2a3f28a8986e2c80565594c0164e7cbcb64ea157 100644 --- a/src/ui/flightdisplay/FlightDisplay.qml +++ b/src/ui/flightdisplay/FlightDisplay.qml @@ -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() - } - } - } - } } } } @@ -487,6 +430,15 @@ Item { z: 10 } + QGCHudMessage { + id: hudMessage + y: ScreenTools.pixelSizeFactor * (5) + width: (parent.width - 520 > 200) ? parent.width - 520 : 200 + height: ScreenTools.pixelSizeFactor * (30) + anchors.horizontalCenter: parent.horizontalCenter + z: mapBackground.z + 1 + } + QGCCompassInstrument { id: compassInstrument y: ScreenTools.pixelSizeFactor * (5) @@ -494,7 +446,7 @@ Item { size: ScreenTools.pixelSizeFactor * (160) heading: isNaN(MavManager.heading) ? 0 : MavManager.heading visible: mapBackground.visible && showCompass - z: mapBackground.z + 1 + z: mapBackground.z + 2 onResetRequested: { y = ScreenTools.pixelSizeFactor * (5) x = ScreenTools.pixelSizeFactor * (85) @@ -514,7 +466,7 @@ Item { visible: mapBackground.visible && showAttitudeIndicator anchors.right: root.right anchors.rightMargin: ScreenTools.pixelSizeFactor * (85) - z: mapBackground.z + 1 + z: mapBackground.z + 2 onResetRequested: { y = ScreenTools.pixelSizeFactor * (5) anchors.right = root.right @@ -531,7 +483,6 @@ Item { rollAngle: roll pitchAngle: pitch visible: !mapBackground.visible - z: 10 } QGCAttitudeWidget { diff --git a/src/ui/mapdisplay/QGCMapDisplay.cc b/src/ui/mapdisplay/QGCMapDisplay.cc index a76ff737a6f8d107f1be4117f3e06266ebb879e6..23e63aa6e3925cf07ac04ce1a2ed30634d65f7d6 100644 --- a/src/ui/mapdisplay/QGCMapDisplay.cc +++ b/src/ui/mapdisplay/QGCMapDisplay.cc @@ -31,7 +31,7 @@ This file is part of the QGROUNDCONTROL project #include #include -#include "MainWindow.h" +#include "ScreenTools.h" #include "QGCMapDisplay.h" #include "UASManager.h" @@ -48,8 +48,8 @@ QGCMapDisplay::QGCMapDisplay(QWidget *parent) pl->setContentsMargins(0,0,0,0); } #ifndef __android__ - setMinimumWidth( 380 * MainWindow::pixelSizeFactor()); - setMinimumHeight(400 * MainWindow::pixelSizeFactor()); + setMinimumWidth( 380 * ScreenTools::pixelSizeFactor_s()); + setMinimumHeight(400 * ScreenTools::pixelSizeFactor_s()); #endif setContextPropertyObject("mapEngine", this); setSource(QUrl::fromUserInput("qrc:/qml/MapDisplay.qml")); diff --git a/src/ui/qmlcommon/QGCCompassInstrument.qml b/src/ui/qmlcommon/QGCCompassInstrument.qml index 73abbf98ee5f0c82470c28c2dca3d097682d5e16..0a4c973739548a25e381869c1258983a9db51d90 100644 --- a/src/ui/qmlcommon/QGCCompassInstrument.qml +++ b/src/ui/qmlcommon/QGCCompassInstrument.qml @@ -35,7 +35,7 @@ QGCMovableItem { id: root property real heading: 0 property real size: ScreenTools.pixelSizeFactor * (120) - property real _fontSize: ScreenTools.fontPointFactor * (12) + property int _fontSize: ScreenTools.font12 width: size height: size Rectangle { @@ -72,7 +72,7 @@ QGCMovableItem { QGCLabel { text: heading.toFixed(0) font.weight: Font.DemiBold - font.pointSize: _fontSize < 1 ? 1 : _fontSize; + font.pixelSize: _fontSize < 1 ? 1 : _fontSize; color: "white" anchors.centerIn: parent } diff --git a/src/ui/qmlcommon/QGCHudMessage.qml b/src/ui/qmlcommon/QGCHudMessage.qml new file mode 100644 index 0000000000000000000000000000000000000000..5b3d396dd35b9119e5cef2ec048156061716d231 --- /dev/null +++ b/src/ui/qmlcommon/QGCHudMessage.qml @@ -0,0 +1,93 @@ +/*===================================================================== + +QGroundControl Open Source Ground Control Station + +(c) 2009, 2015 QGROUNDCONTROL PROJECT + +This file is part of the QGROUNDCONTROL project + + QGROUNDCONTROL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + QGROUNDCONTROL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QGROUNDCONTROL. If not, see . + +======================================================================*/ + +/** + * @file + * @brief QGC HUD Message + * @author Gus Grubba + */ + +import QtQuick 2.4 +import QtQuick.Controls 1.3 + +import QGroundControl.Controls 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.MavManager 1.0 + +Item { + id: root + visible: MavManager.latestError !== '' + Rectangle { + anchors.fill: parent + color: Qt.rgba(0,0,0,0.75) + border.color: Qt.rgba(1,1,1,0.75) + radius: 4 + QGCLabel { + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + antialiasing: true + font.weight: Font.DemiBold + text: MavManager.latestError + color: "#f84444" + } + OpacityAnimator { + id: vanish + target: root; + from: 1; + to: 0; + duration: 2000 + running: false + } + } + Timer { + id: vanishTimer + interval: 30000 + running: false + repeat: false + onTriggered: { + vanish.start(); + } + } + MouseArea { + anchors.fill: parent + z: 1000 + acceptedButtons: Qt.LeftButton + onClicked: { + if (mouse.button == Qt.LeftButton) + { + vanishTimer.stop(); + vanish.stop(); + root.opacity = 0; + } + } + } + Connections { + target: MavManager + onLatestErrorChanged: { + vanishTimer.stop(); + vanish.stop(); + vanishTimer.start(); + root.opacity = 1; + } + } +} diff --git a/src/ui/qmlcommon/QGCPitchWidget.qml b/src/ui/qmlcommon/QGCPitchWidget.qml index 610d48ebb06abb53d322ee1220eba8c0cbdd0ced..e0ae9420602c3d08d31b05ca094464bafa23b04c 100644 --- a/src/ui/qmlcommon/QGCPitchWidget.qml +++ b/src/ui/qmlcommon/QGCPitchWidget.qml @@ -40,7 +40,7 @@ Rectangle { property real _reticleSlot: _reticleSpacing + _reticleHeight property real _longDash: size * 0.40 property real _shortDash: size * 0.25 - property real _fontSize: ScreenTools.fontPointFactor * (11); + property real _fontSize: ScreenTools.font11 height: size * 0.9 width: size radius: ScreenTools.pixelSizeFactor * (8) @@ -70,7 +70,7 @@ Rectangle { anchors.verticalCenter: parent.verticalCenter smooth: true font.weight: Font.DemiBold - font.pointSize: _fontSize < 1 ? 1 : _fontSize; + font.pixelSize: _fontSize < 1 ? 1 : _fontSize; text: _pitch color: "white" visible: (_pitch != 0) && ((_pitch % 10) === 0) @@ -81,7 +81,7 @@ Rectangle { anchors.verticalCenter: parent.verticalCenter smooth: true font.weight: Font.DemiBold - font.pointSize: _fontSize < 1 ? 1 : _fontSize; + font.pixelSize: _fontSize < 1 ? 1 : _fontSize; text: _pitch color: "white" visible: (_pitch != 0) && ((_pitch % 10) === 0) diff --git a/src/ui/qmlcommon/QGCSlider.qml b/src/ui/qmlcommon/QGCSlider.qml index 3a0668a37b99f913128d4bfeea7f104e2d66c3c5..c5b4da37e5e89a884d6592cb00ac69367557a2df 100644 --- a/src/ui/qmlcommon/QGCSlider.qml +++ b/src/ui/qmlcommon/QGCSlider.qml @@ -83,7 +83,7 @@ Item { id: label color: "black" text: slider.value.toFixed(2) - width: font.pointSize * 3.5 + width: font.pixelSize * 3.5 anchors.horizontalCenter: labelRect.horizontalCenter horizontalAlignment: Text.AlignHCenter anchors.verticalCenter: labelRect.verticalCenter diff --git a/src/ui/qmlcommon/QGCWaypoint.qml b/src/ui/qmlcommon/QGCWaypoint.qml index 29d59ae38647fe1c62eac7b4fc43ee8d24013488..47daa1806756ec1da379c4842e80775911ca576a 100644 --- a/src/ui/qmlcommon/QGCWaypoint.qml +++ b/src/ui/qmlcommon/QGCWaypoint.qml @@ -45,7 +45,7 @@ MapQuickItem { Text { id: number anchors.centerIn: parent - font.pointSize: 11 + font.pixelSize: 11 font.weight: Font.DemiBold color: "white" text: marker.waypointID diff --git a/src/ui/qmlcommon/qmldir b/src/ui/qmlcommon/qmldir index 389840c256c8784b1d9629c29591ea053c6e35b9..6986e8ab6be935c749efa79a71fa5a53ccf0fcff 100644 --- a/src/ui/qmlcommon/qmldir +++ b/src/ui/qmlcommon/qmldir @@ -15,3 +15,4 @@ QGCAttitudeInstrument 1.0 QGCAttitudeInstrument.qml QGCCompassInstrument 1.0 QGCCompassInstrument.qml QGCArtificialHorizon 1.0 QGCArtificialHorizon.qml QGCWaypoint 1.0 QGCWaypoint.qml +QGCHudMessage 1.0 QGCHudMessage.qml diff --git a/src/ui/toolbar/MainToolBar.cc b/src/ui/toolbar/MainToolBar.cc index d799d8bdd2c8471ea3c8f1c232790e58a7530ca7..845662df04e1db7cb4674d09762fa4c421ae2f37 100644 --- a/src/ui/toolbar/MainToolBar.cc +++ b/src/ui/toolbar/MainToolBar.cc @@ -31,10 +31,13 @@ This file is part of the QGROUNDCONTROL project #include #include "MainToolBar.h" +#include "ScreenTools.h" #include "MainWindow.h" -#include "UASMessageHandler.h" #include "UASMessageView.h" +#include "UASMessageHandler.h" #include "FlightDisplay.h" +#include "QGCApplication.h" +#include "MavManager.h" MainToolBar::MainToolBar(QWidget* parent) : QGCQmlWidgetHolder(parent) @@ -42,12 +45,6 @@ MainToolBar::MainToolBar(QWidget* parent) , _toolBar(NULL) , _currentView(ViewNone) , _connectionCount(0) - , _currentMessageCount(0) - , _messageCount(0) - , _currentErrorCount(0) - , _currentWarningCount(0) - , _currentNormalCount(0) - , _currentMessageType(MessageNone) , _showGPS(true) , _showMav(true) , _showMessages(true) @@ -61,13 +58,14 @@ MainToolBar::MainToolBar(QWidget* parent) { setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); setObjectName("MainToolBar"); - _updatePixelSize(); setMinimumWidth(MainWindow::instance()->minimumWidth()); // Get rid of layout default margins QLayout* pl = layout(); if(pl) { pl->setContentsMargins(0,0,0,0); } + setMinimumHeight(40 * ScreenTools::pixelSizeFactor_s()); + setMaximumHeight(40 * ScreenTools::pixelSizeFactor_s()); // Tool Bar Preferences QSettings settings; settings.beginGroup(TOOL_BAR_SETTINGS_GROUP); @@ -87,7 +85,6 @@ MainToolBar::MainToolBar(QWidget* parent) connect(LinkManager::instance(), &LinkManager::linkConfigurationChanged, this, &MainToolBar::_updateConfigurations); connect(LinkManager::instance(), &LinkManager::linkConnected, this, &MainToolBar::_linkConnected); connect(LinkManager::instance(), &LinkManager::linkDisconnected, this, &MainToolBar::_linkDisconnected); - connect(MainWindow::instance(), &MainWindow::pixelSizeChanged, this, &MainToolBar::_updatePixelSize); // RSSI (didn't like standard connection) connect(MAVLinkProtocol::instance(), SIGNAL(radioStatusChanged(LinkInterface*, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned)), this, @@ -215,20 +212,8 @@ void MainToolBar::onEnterMessageArea(int x, int y) // If not already there and messages are actually present if(!_rollDownMessages && UASMessageHandler::instance()->messages().count()) { - // Reset Counts - int count = _currentMessageCount; - MessageType_t type = _currentMessageType; - _currentErrorCount = 0; - _currentWarningCount = 0; - _currentNormalCount = 0; - _currentMessageCount = 0; - _currentMessageType = MessageNone; - if(count != _currentMessageCount) { - emit newMessageCountChanged(0); - } - if(type != _currentMessageType) { - emit messageTypeChanged(MessageNone); - } + if(qgcApp()->getMavManager()) + qgcApp()->getMavManager()->resetMessages(); // Show messages int dialogWidth = 400; x = x - (dialogWidth >> 1); @@ -280,7 +265,6 @@ void MainToolBar::setCurrentView(int currentView) void MainToolBar::_forgetUAS(UASInterface* uas) { if (_mav != NULL && _mav == uas) { - disconnect(UASMessageHandler::instance(), &UASMessageHandler::textMessageCountChanged, this, &MainToolBar::_handleTextMessage); disconnect(_mav, &UASInterface::remoteControlRSSIChanged, this, &MainToolBar::_remoteControlRSSIChanged); disconnect(AutoPilotPluginManager::instance()->getInstanceForAutoPilotPlugin(_mav).data(), &AutoPilotPlugin::parameterListProgress, this, &MainToolBar::_setProgressBarValue); _mav = NULL; @@ -300,7 +284,6 @@ void MainToolBar::_setActiveUAS(UASInterface* active) _mav = active; if (_mav) { - connect(UASMessageHandler::instance(), &UASMessageHandler::textMessageCountChanged, this, &MainToolBar::_handleTextMessage); connect(_mav, &UASInterface::remoteControlRSSIChanged, this, &MainToolBar::_remoteControlRSSIChanged); connect(AutoPilotPluginManager::instance()->getInstanceForAutoPilotPlugin(_mav).data(), &AutoPilotPlugin::parameterListProgress, this, &MainToolBar::_setProgressBarValue); } @@ -401,75 +384,8 @@ void MainToolBar::_updateConnection(LinkInterface *disconnectedLink) } } -void MainToolBar::_handleTextMessage(int newCount) -{ - // Reset? - if(!newCount) { - _currentMessageCount = 0; - _currentNormalCount = 0; - _currentWarningCount = 0; - _currentErrorCount = 0; - _messageCount = 0; - _currentMessageType = MessageNone; - emit newMessageCountChanged(0); - emit messageTypeChanged(MessageNone); - emit messageCountChanged(0); - return; - } - - UASMessageHandler* pMh = UASMessageHandler::instance(); - Q_ASSERT(pMh); - MessageType_t type = newCount ? _currentMessageType : MessageNone; - int errorCount = _currentErrorCount; - int warnCount = _currentWarningCount; - int normalCount = _currentNormalCount; - //-- Add current message counts - errorCount += pMh->getErrorCount(); - warnCount += pMh->getWarningCount(); - normalCount += pMh->getNormalCount(); - //-- See if we have a higher level - if(errorCount != _currentErrorCount) { - _currentErrorCount = errorCount; - type = MessageError; - } - if(warnCount != _currentWarningCount) { - _currentWarningCount = warnCount; - if(_currentMessageType != MessageError) { - type = MessageWarning; - } - } - if(normalCount != _currentNormalCount) { - _currentNormalCount = normalCount; - if(_currentMessageType != MessageError && _currentMessageType != MessageWarning) { - type = MessageNormal; - } - } - int count = _currentErrorCount + _currentWarningCount + _currentNormalCount; - if(count != _currentMessageCount) { - _currentMessageCount = count; - // Display current total new messages count - emit newMessageCountChanged(count); - } - if(type != _currentMessageType) { - _currentMessageType = type; - // Update message level - emit messageTypeChanged(type); - } - // Update message count (all messages) - if(newCount != _messageCount) { - _messageCount = newCount; - emit messageCountChanged(_messageCount); - } -} - void MainToolBar::_setProgressBarValue(float value) { _progressBarValue = value; emit progressBarValueChanged(value); } - -void MainToolBar::_updatePixelSize() -{ - setMinimumHeight(40 * MainWindow::pixelSizeFactor()); - setMaximumHeight(40 * MainWindow::pixelSizeFactor()); -} diff --git a/src/ui/toolbar/MainToolBar.h b/src/ui/toolbar/MainToolBar.h index a9c26c8b9807cd1fe87787439dac19ffdaf4c251..58f0210a08af3dca2db2f11b6d39975f101f9f8c 100644 --- a/src/ui/toolbar/MainToolBar.h +++ b/src/ui/toolbar/MainToolBar.h @@ -47,17 +47,7 @@ class MainToolBar : public QGCQmlWidgetHolder { Q_OBJECT Q_ENUMS(ViewType_t) - Q_ENUMS(MessageType_t) public: - MainToolBar(QWidget* parent = NULL); - ~MainToolBar(); - - typedef enum { - MessageNone, - MessageNormal, - MessageWarning, - MessageError - } MessageType_t; typedef enum { ViewNone = -1, @@ -67,6 +57,9 @@ public: ViewSetup , // MainWindow::VIEW_SETUP } ViewType_t; + MainToolBar(QWidget* parent = NULL); + ~MainToolBar(); + Q_INVOKABLE void onSetupView(); Q_INVOKABLE void onPlanView(); Q_INVOKABLE void onFlyView(); @@ -78,9 +71,6 @@ public: Q_PROPERTY(ViewType_t currentView MEMBER _currentView NOTIFY currentViewChanged) Q_PROPERTY(QStringList configList MEMBER _linkConfigurations NOTIFY configListChanged) - Q_PROPERTY(MessageType_t messageType MEMBER _currentMessageType NOTIFY messageTypeChanged) - Q_PROPERTY(int newMessageCount MEMBER _currentMessageCount NOTIFY newMessageCountChanged) - Q_PROPERTY(int messageCount MEMBER _messageCount NOTIFY messageCountChanged) Q_PROPERTY(int connectionCount READ connectionCount NOTIFY connectionCountChanged) Q_PROPERTY(QStringList connectedList MEMBER _connectedList NOTIFY connectedListChanged) Q_PROPERTY(bool showGPS MEMBER _showGPS NOTIFY showGPSChanged) @@ -104,9 +94,6 @@ signals: void connectionCountChanged (int count); void currentViewChanged (); void configListChanged (); - void messageTypeChanged (MessageType_t type); - void newMessageCountChanged (int count); - void messageCountChanged (int count); void connectedListChanged (QStringList connectedList); void showGPSChanged (bool value); void showMavChanged (bool value); @@ -124,10 +111,8 @@ private slots: void _updateConfigurations (); void _linkConnected (LinkInterface* link); void _linkDisconnected (LinkInterface* link); - void _handleTextMessage (int newCount); void _leaveMessageView (); void _setProgressBarValue (float value); - void _updatePixelSize (); void _remoteControlRSSIChanged (uint8_t rssi); void _telemetryChanged (LinkInterface* link, unsigned rxerrors, unsigned fixed, unsigned rssi, unsigned remrssi, unsigned txbuf, unsigned noise, unsigned remnoise); @@ -141,12 +126,6 @@ private: ViewType_t _currentView; QStringList _linkConfigurations; int _connectionCount; - int _currentMessageCount; - int _messageCount; - int _currentErrorCount; - int _currentWarningCount; - int _currentNormalCount; - MessageType_t _currentMessageType; QStringList _connectedList; bool _showGPS; bool _showMav; diff --git a/src/ui/toolbar/MainToolBar.qml b/src/ui/toolbar/MainToolBar.qml index ce6f62ed194df639c63dbc549d0abfd21e4b0586..5acd18f9105374b46132a65fb3eb8ed7f6dcf6ac 100644 --- a/src/ui/toolbar/MainToolBar.qml +++ b/src/ui/toolbar/MainToolBar.qml @@ -64,20 +64,20 @@ Rectangle { } function getMessageColor() { - if(mainToolBar.messageType === MainToolBar.MessageNone) + if(MavManager.messageType === MavManager.MessageNone) return qgcPal.button; - if(mainToolBar.messageType === MainToolBar.MessageNormal) + if(MavManager.messageType === MavManager.MessageNormal) return colorBlue; - if(mainToolBar.messageType === MainToolBar.MessageWarning) + if(MavManager.messageType === MavManager.MessageWarning) return colorOrange; - if(mainToolBar.messageType === MainToolBar.MessageError) + if(MavManager.messageType === MavManager.MessageError) return colorRed; // Cannot be so make make it obnoxious to show error return "purple"; } function getMessageIcon() { - if(mainToolBar.messageType === MainToolBar.MessageNormal || mainToolBar.messageType === MainToolBar.MessageNone) + if(MavManager.messageType === MavManager.MessageNormal || MavManager.messageType === MavManager.MessageNone) return "qrc:/res/Megaphone"; else return "qrc:/res/Yield"; @@ -311,7 +311,7 @@ Rectangle { Rectangle { id: messages - width: (mainToolBar.messageCount > 99) ? getProportionalDimmension(65) : getProportionalDimmension(60) + width: (MavManager.messageCount > 99) ? getProportionalDimmension(65) : getProportionalDimmension(60) height: cellHeight visible: (mainToolBar.connectionCount > 0) && (mainToolBar.showMessages) anchors.verticalCenter: parent.verticalCenter @@ -337,8 +337,8 @@ Rectangle { width: messages.width - messageIcon.width QGCLabel { id: messageText - text: (mainToolBar.messageCount > 0) ? mainToolBar.messageCount : '' - font.pointSize: ScreenTools.fontPointFactor * (14); + text: (MavManager.messageCount > 0) ? MavManager.messageCount : '' + font.pixelSize: ScreenTools.font14 font.weight: Font.DemiBold anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter @@ -350,7 +350,7 @@ Rectangle { Image { id: dropDown source: "QGroundControl/Controls/arrow-down.png" - visible: (messages.showTriangle) && (mainToolBar.messageCount > 0) + visible: (messages.showTriangle) && (MavManager.messageCount > 0) anchors.bottom: parent.bottom anchors.right: parent.right anchors.bottomMargin: getProportionalDimmension(3) @@ -424,7 +424,7 @@ Rectangle { QGCLabel { id: satelitteText 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 anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right @@ -459,7 +459,7 @@ Rectangle { anchors.rightMargin: getProportionalDimmension(6) anchors.verticalCenter: parent.verticalCenter horizontalAlignment: Text.AlignRight - font.pointSize: ScreenTools.fontPointFactor * (12); + font.pixelSize: ScreenTools.font12 font.weight: Font.DemiBold color: colorWhite } @@ -492,7 +492,7 @@ Rectangle { anchors.right: parent.right QGCLabel { text: 'R ' - font.pointSize: ScreenTools.fontPointFactor * (11); + font.pixelSize: ScreenTools.font11 font.weight: Font.DemiBold color: colorWhite } @@ -500,7 +500,7 @@ Rectangle { text: mainToolBar.telemetryRRSSI + 'dB' width: getProportionalDimmension(30) horizontalAlignment: Text.AlignRight - font.pointSize: ScreenTools.fontPointFactor * (11); + font.pixelSize: ScreenTools.font11 font.weight: Font.DemiBold color: colorWhite } @@ -509,7 +509,7 @@ Rectangle { anchors.right: parent.right QGCLabel { text: 'L ' - font.pointSize: ScreenTools.fontPointFactor * (11); + font.pixelSize: ScreenTools.font11 font.weight: Font.DemiBold color: colorWhite } @@ -517,7 +517,7 @@ Rectangle { text: mainToolBar.telemetryLRSSI + 'dB' width: getProportionalDimmension(30) horizontalAlignment: Text.AlignRight - font.pointSize: ScreenTools.fontPointFactor * (11); + font.pixelSize: ScreenTools.font11 font.weight: Font.DemiBold color: colorWhite } @@ -548,7 +548,7 @@ Rectangle { QGCLabel { visible: batteryStatus.visible && MavManager.batteryConsumed < 0.0 text: MavManager.batteryVoltage.toFixed(1) + 'V'; - font.pointSize: ScreenTools.fontPointFactor * (11); + font.pixelSize: ScreenTools.font11 font.weight: Font.DemiBold anchors.right: parent.right anchors.rightMargin: getProportionalDimmension(6) @@ -566,7 +566,7 @@ Rectangle { text: MavManager.batteryVoltage.toFixed(1) + 'V'; width: getProportionalDimmension(30) horizontalAlignment: Text.AlignRight - font.pointSize: ScreenTools.fontPointFactor * (11); + font.pixelSize: ScreenTools.font11 font.weight: Font.DemiBold color: colorWhite } @@ -574,7 +574,7 @@ Rectangle { text: MavManager.batteryConsumed.toFixed(0) + 'mA'; width: getProportionalDimmension(30) horizontalAlignment: Text.AlignRight - font.pointSize: ScreenTools.fontPointFactor * (11); + font.pixelSize: ScreenTools.font11 font.weight: Font.DemiBold color: colorWhite } @@ -599,7 +599,7 @@ Rectangle { QGCLabel { id: armedStatusText text: (MavManager.systemArmed) ? qsTr("ARMED") : qsTr("DISARMED") - font.pointSize: ScreenTools.fontPointFactor * (12); + font.pixelSize: ScreenTools.font12 font.weight: Font.DemiBold anchors.centerIn: parent color: (MavManager.systemArmed) ? colorOrangeText : colorGreenText @@ -618,7 +618,7 @@ Rectangle { QGCLabel { id: stateStatusText text: MavManager.currentState - font.pointSize: ScreenTools.fontPointFactor * (12); + font.pixelSize: ScreenTools.font12 font.weight: Font.DemiBold anchors.centerIn: parent color: (MavManager.currentState === "STANDBY") ? colorGreenText : colorRedText @@ -639,7 +639,7 @@ Rectangle { QGCLabel { id: modeStatusText text: MavManager.currentMode - font.pointSize: ScreenTools.fontPointFactor * (12); + font.pixelSize: ScreenTools.font12 font.weight: Font.DemiBold anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter @@ -660,7 +660,7 @@ Rectangle { QGCLabel { id: connectionStatusText text: qsTr("CONNECTION LOST") - font.pointSize: ScreenTools.fontPointFactor * (14); + font.pixelSize: ScreenTools.font14 font.weight: Font.DemiBold anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter diff --git a/src/ui/uas/UASQuickView.cc b/src/ui/uas/UASQuickView.cc index d49e88f89abfff1e3a4c4e84bda6557d43cf786a..be18b191bea6f9739063af482131f8ea98c333dd 100644 --- a/src/ui/uas/UASQuickView.cc +++ b/src/ui/uas/UASQuickView.cc @@ -63,7 +63,8 @@ UASQuickView::~UASQuickView() void UASQuickView::columnActionTriggered() { 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) { return; @@ -110,7 +111,7 @@ void UASQuickView::loadSettings() QSettings settings; m_columnCount = settings.value("UAS_QUICK_VIEW_COLUMNS",1).toInt(); int size = settings.beginReadArray("UAS_QUICK_VIEW_ITEMS"); - for (int i=0;iremoveItem(m_verticalLayoutList[i]); m_verticalLayoutList[i]->deleteLater(); //removeItem de-parents the item. } m_verticalLayoutList.clear(); - //Create a vertical layout for every intended column - for (int i=0;iaddItem(layout); @@ -177,7 +178,7 @@ void UASQuickView::sortItems(int columncount) //Cycle through all items and add them to the layout int currcol = 0; - for (int i=0;iaddWidget(itemlist[i]); currcol++; @@ -206,6 +207,8 @@ void UASQuickView::recalculateItemTextSizing() minpixelsize = tempmin; } } + if(minpixelsize < 6) + minpixelsize = 6; for (QMap::const_iterator i = uasPropertyToLabelMap.constBegin();i!=uasPropertyToLabelMap.constEnd();i++) { i.value()->setValuePixelSize(minpixelsize); diff --git a/src/ui/uas/UASQuickViewTextItem.cc b/src/ui/uas/UASQuickViewTextItem.cc index 5dc09592903177487ab8830b105dcc2cd04d1e27..c11cb817bf3c864c2d9e1efd2cbc675d3cc14432 100644 --- a/src/ui/uas/UASQuickViewTextItem.cc +++ b/src/ui/uas/UASQuickViewTextItem.cc @@ -10,27 +10,27 @@ UASQuickViewTextItem::UASQuickViewTextItem(QWidget *parent) : UASQuickViewItem(p // Create the title label. Scale the font based on available size. titleLabel = new QLabel(this); - titleLabel->setAlignment(Qt::AlignHCenter); - titleLabel->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Minimum); - titleLabel->setObjectName(QString::fromUtf8("title")); - QFont titlefont = titleLabel->font(); - titlefont.setPixelSize(this->height() / 4.0); - titleLabel->setFont(titlefont); - layout->addWidget(titleLabel); + titleLabel->setAlignment(Qt::AlignHCenter); + titleLabel->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Minimum); + titleLabel->setObjectName(QString::fromUtf8("title")); + QFont titlefont = titleLabel->font(); + titlefont.setPixelSize(this->height() / 4.0); + titleLabel->setFont(titlefont); + layout->addWidget(titleLabel); - // Create the value label. Scale the font based on available size. - valueLabel = new QLabel(this); - valueLabel->setAlignment(Qt::AlignHCenter); - valueLabel->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Minimum); - valueLabel->setObjectName(QString::fromUtf8("value")); - valueLabel->setText("0.00"); + // Create the value label. Scale the font based on available size. + valueLabel = new QLabel(this); + valueLabel->setAlignment(Qt::AlignHCenter); + valueLabel->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Minimum); + valueLabel->setObjectName(QString::fromUtf8("value")); + valueLabel->setText("0.00"); QFont valuefont = valueLabel->font(); valuefont.setPixelSize(this->height() / 2.0); valueLabel->setFont(valuefont); layout->addWidget(valueLabel); // 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); } void UASQuickViewTextItem::setValue(double value) @@ -61,7 +61,7 @@ void UASQuickViewTextItem::setTitle(QString title) { if (title.indexOf(".") != -1 && title.indexOf(":") != -1) { - titleLabel->setText(title.mid(title.indexOf(".")+1)); + titleLabel->setText(title.mid(title.indexOf(".") + 1)); } else { @@ -73,7 +73,7 @@ int UASQuickViewTextItem::minValuePixelSize() QFont valuefont = valueLabel->font(); QFont titlefont = titleLabel->font(); 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)); QFontMetrics metrics(valuefont); @@ -87,18 +87,18 @@ int UASQuickViewTextItem::minValuePixelSize() //QFontMetrics titlefm( titlefont ); //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; else { - if (valuefont.pixelSize()-5 <= 0) + if (valuefont.pixelSize() - 1 <= 6) { fit = true; - valuefont.setPixelSize(5); + valuefont.setPixelSize(6); } else { - valuefont.setPixelSize(valuefont.pixelSize() - 5); + valuefont.setPixelSize(valuefont.pixelSize() - 1); } //titlefont.setPixelSize(valuefont.pixelSize() / 2.0); //qDebug() << "Point size:" << valuefont.pixelSize() << valueLabel->width() << valueLabel->height(); @@ -111,7 +111,7 @@ void UASQuickViewTextItem::setValuePixelSize(int size) QFont valuefont = valueLabel->font(); QFont titlefont = titleLabel->font(); valuefont.setPixelSize(size); - titlefont.setPixelSize(valuefont.pixelSize() / 2.0); + titlefont.setPixelSize(valuefont.pixelSize() * 0.75); valueLabel->setFont(valuefont); titleLabel->setFont(titlefont); update();