From eb676850ab7af445d7ce728c7fa85e6afac06571 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Fri, 7 Aug 2015 12:08:57 -0400 Subject: [PATCH 1/4] commit --- src/QGCQmlWidgetHolder.cpp | 7 ++++++- src/QGCQmlWidgetHolder.h | 3 +++ src/ui/toolbar/MainToolBar.cc | 8 ++++++++ src/ui/toolbar/MainToolBar.h | 35 ++++++++++++++++++++-------------- src/ui/toolbar/MainToolBar.qml | 22 +++++++++++++-------- 5 files changed, 52 insertions(+), 23 deletions(-) diff --git a/src/QGCQmlWidgetHolder.cpp b/src/QGCQmlWidgetHolder.cpp index 9651cf262cb..a769ea39e69 100644 --- a/src/QGCQmlWidgetHolder.cpp +++ b/src/QGCQmlWidgetHolder.cpp @@ -30,7 +30,7 @@ QGCQmlWidgetHolder::QGCQmlWidgetHolder(QWidget *parent) : QWidget(parent) { _ui.setupUi(this); - _ui.qmlWidget->setResizeMode(QQuickWidget::SizeRootObjectToView); + setResizeMode(QQuickWidget::SizeRootObjectToView); } QGCQmlWidgetHolder::~QGCQmlWidgetHolder() @@ -62,3 +62,8 @@ QQuickItem* QGCQmlWidgetHolder::getRootObject(void) { return _ui.qmlWidget->rootObject(); } + +void QGCQmlWidgetHolder::setResizeMode(QQuickWidget::ResizeMode resizeMode) +{ + _ui.qmlWidget->setResizeMode(resizeMode); +} \ No newline at end of file diff --git a/src/QGCQmlWidgetHolder.h b/src/QGCQmlWidgetHolder.h index 0439d01b8b6..ae99070283f 100644 --- a/src/QGCQmlWidgetHolder.h +++ b/src/QGCQmlWidgetHolder.h @@ -60,6 +60,9 @@ class QGCQmlWidgetHolder : public QWidget bool setSource(const QUrl& qmlUrl); void setContextPropertyObject(const QString& name, QObject* object); + + /// Sets the resize mode for the QQuickWidget container + void setResizeMode(QQuickWidget::ResizeMode resizeMode); private: Ui::QGCQmlWidgetHolder _ui; diff --git a/src/ui/toolbar/MainToolBar.cc b/src/ui/toolbar/MainToolBar.cc index 73e7a48c170..8048875cfec 100644 --- a/src/ui/toolbar/MainToolBar.cc +++ b/src/ui/toolbar/MainToolBar.cc @@ -92,6 +92,8 @@ MainToolBar::MainToolBar(QWidget* parent) SLOT(_telemetryChanged(LinkInterface*, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned))); connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(_setActiveUAS(UASInterface*))); connect(UASManager::instance(), SIGNAL(UASDeleted(UASInterface*)), this, SLOT(_forgetUAS(UASInterface*))); + + connect(this, &MainToolBar::heightChanged, this, &MainToolBar::_heightChanged); } MainToolBar::~MainToolBar() @@ -396,3 +398,9 @@ void MainToolBar::_setProgressBarValue(float value) _progressBarValue = value; emit progressBarValueChanged(value); } + +void MainToolBar::_heightChanged(double height) +{ + setMinimumHeight(height); + setMaximumHeight(height); +} diff --git a/src/ui/toolbar/MainToolBar.h b/src/ui/toolbar/MainToolBar.h index 94bf57af40b..0e0ab74eddb 100644 --- a/src/ui/toolbar/MainToolBar.h +++ b/src/ui/toolbar/MainToolBar.h @@ -69,19 +69,20 @@ class MainToolBar : public QGCQmlWidgetHolder Q_INVOKABLE void onDisconnect(QString conf); Q_INVOKABLE void onEnterMessageArea(int x, int y); - Q_PROPERTY(ViewType_t currentView MEMBER _currentView NOTIFY currentViewChanged) - Q_PROPERTY(QStringList configList MEMBER _linkConfigurations NOTIFY configListChanged) - Q_PROPERTY(int connectionCount READ connectionCount NOTIFY connectionCountChanged) - Q_PROPERTY(QStringList connectedList MEMBER _connectedList NOTIFY connectedListChanged) - Q_PROPERTY(bool showGPS MEMBER _showGPS NOTIFY showGPSChanged) - Q_PROPERTY(bool showMav MEMBER _showMav NOTIFY showMavChanged) - Q_PROPERTY(bool showMessages MEMBER _showMessages NOTIFY showMessagesChanged) - Q_PROPERTY(bool showBattery MEMBER _showBattery NOTIFY showBatteryChanged) - Q_PROPERTY(bool showRSSI MEMBER _showRSSI NOTIFY showRSSIChanged) - Q_PROPERTY(float progressBarValue MEMBER _progressBarValue NOTIFY progressBarValueChanged) - Q_PROPERTY(int remoteRSSI READ remoteRSSI NOTIFY remoteRSSIChanged) - Q_PROPERTY(int telemetryRRSSI READ telemetryRRSSI NOTIFY telemetryRRSSIChanged) - Q_PROPERTY(int telemetryLRSSI READ telemetryLRSSI NOTIFY telemetryLRSSIChanged) + Q_PROPERTY(double height MEMBER _toolbarHeight NOTIFY heightChanged) + Q_PROPERTY(ViewType_t currentView MEMBER _currentView NOTIFY currentViewChanged) + Q_PROPERTY(QStringList configList MEMBER _linkConfigurations NOTIFY configListChanged) + Q_PROPERTY(int connectionCount READ connectionCount NOTIFY connectionCountChanged) + Q_PROPERTY(QStringList connectedList MEMBER _connectedList NOTIFY connectedListChanged) + Q_PROPERTY(bool showGPS MEMBER _showGPS NOTIFY showGPSChanged) + Q_PROPERTY(bool showMav MEMBER _showMav NOTIFY showMavChanged) + Q_PROPERTY(bool showMessages MEMBER _showMessages NOTIFY showMessagesChanged) + Q_PROPERTY(bool showBattery MEMBER _showBattery NOTIFY showBatteryChanged) + Q_PROPERTY(bool showRSSI MEMBER _showRSSI NOTIFY showRSSIChanged) + Q_PROPERTY(float progressBarValue MEMBER _progressBarValue NOTIFY progressBarValueChanged) + Q_PROPERTY(int remoteRSSI READ remoteRSSI NOTIFY remoteRSSIChanged) + Q_PROPERTY(int telemetryRRSSI READ telemetryRRSSI NOTIFY telemetryRRSSIChanged) + Q_PROPERTY(int telemetryLRSSI READ telemetryLRSSI NOTIFY telemetryLRSSIChanged) void setCurrentView (int currentView); void viewStateChanged (const QString& key, bool value); @@ -89,7 +90,7 @@ class MainToolBar : public QGCQmlWidgetHolder int telemetryRRSSI () { return _telemetryRRSSI; } int telemetryLRSSI () { return _telemetryLRSSI; } int connectionCount () { return _connectionCount; } - + signals: void connectionCountChanged (int count); void currentViewChanged (); @@ -104,6 +105,10 @@ class MainToolBar : public QGCQmlWidgetHolder void remoteRSSIChanged (int value); void telemetryRRSSIChanged (int value); void telemetryLRSSIChanged (int value); + void heightChanged (double height); + + /// Shows a non-modal message below the toolbar + void showMessage(const QString& message); private slots: void _forgetUAS (UASInterface* uas); @@ -115,6 +120,7 @@ private slots: void _setProgressBarValue (float value); void _remoteControlRSSIChanged (uint8_t rssi); void _telemetryChanged (LinkInterface* link, unsigned rxerrors, unsigned fixed, unsigned rssi, unsigned remrssi, unsigned txbuf, unsigned noise, unsigned remnoise); + void _heightChanged (double height); private: void _updateConnection (LinkInterface *disconnectedLink = NULL); @@ -137,6 +143,7 @@ private slots: double _remoteRSSIstore; int _telemetryRRSSI; int _telemetryLRSSI; + double _toolbarHeight; UASMessageViewRollDown* _rollDownMessages; }; diff --git a/src/ui/toolbar/MainToolBar.qml b/src/ui/toolbar/MainToolBar.qml index 11bc7309b49..96c9e631b35 100644 --- a/src/ui/toolbar/MainToolBar.qml +++ b/src/ui/toolbar/MainToolBar.qml @@ -43,14 +43,15 @@ Rectangle { property var qgcPal: QGCPalette { id: palette; colorGroupEnabled: true } - property int cellSpacerSize: ScreenTools.isMobile ? getProportionalDimmension(6) : getProportionalDimmension(4) - property int cellHeight: getProportionalDimmension(30) + readonly property real toolBarHeight: ScreenTools.defaultFontPixelHeight * 3 + property int cellSpacerSize: ScreenTools.isMobile ? getProportionalDimmension(6) : getProportionalDimmension(4) + readonly property int cellHeight: getProportionalDimmension(30) - property var colorBlue: "#1a6eaa" - property var colorGreen: "#329147" - property var colorRed: "#942324" - property var colorOrange: "#a76f26" - property var colorWhite: "#f0f0f0" + readonly property var colorBlue: "#1a6eaa" + readonly property var colorGreen: "#329147" + readonly property var colorRed: "#942324" + readonly property var colorOrange: "#a76f26" + readonly property var colorWhite: "#f0f0f0" property var colorOrangeText: (qgcPal.globalTheme === QGCPalette.Light) ? "#b75711" : "#ea8225" property var colorRedText: (qgcPal.globalTheme === QGCPalette.Light) ? "#ee1112" : "#ef2526" @@ -59,8 +60,13 @@ Rectangle { color: qgcPal.windowShade + Connections { + target: mainToolBar + onShowMessage: mainToolBar.height = 100 + } + function getProportionalDimmension(val) { - return toolBarHolder.height * val / 40 + return toolBarHeight * val / 40 } function getMessageColor() { From af46dc40a45305096e70b1a61df5b61db897f433 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Sat, 15 Aug 2015 14:56:53 -0400 Subject: [PATCH 2/4] Add new API --- src/QGCApplication.cc | 10 ++++++++++ src/QGCApplication.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index d2a0b65241d..87c2c2068ce 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -772,3 +772,13 @@ MavManager* QGCApplication::getMavManager() { return _pMavManager; } + +void QGCApplication::showToolBarMessage(const QString& message) +{ + MainWindow* mainWindow = MainWindow::instance(); + if (mainWindow) { + mainWindow->getMainToolBar()->showToolBarMessage(message); + } else { + QGCMessageBox::information("", message); + } +} diff --git a/src/QGCApplication.h b/src/QGCApplication.h index 8b01ce266f9..eabafd4d9ad 100644 --- a/src/QGCApplication.h +++ b/src/QGCApplication.h @@ -107,6 +107,9 @@ class QGCApplication : public QApplication /// MavManager accessor MavManager* getMavManager(); + /// Show a non-modal message to the user + void showToolBarMessage(const QString& message); + public slots: /// You can connect to this slot to show an information message box from a different thread. void informationMessageBoxOnMainThread(const QString& title, const QString& msg); From fa12589e3383c695a8d570a5cafe31504070b097 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Sat, 15 Aug 2015 14:57:40 -0400 Subject: [PATCH 3/4] Add toolbar message support Also restructured some toolbar positioning QML to handle resizing. --- src/ui/toolbar/MainToolBar.h | 2 + src/ui/toolbar/MainToolBar.qml | 110 +++++++++++++++++++++------------ 2 files changed, 72 insertions(+), 40 deletions(-) diff --git a/src/ui/toolbar/MainToolBar.h b/src/ui/toolbar/MainToolBar.h index 0e0ab74eddb..a3f4a157553 100644 --- a/src/ui/toolbar/MainToolBar.h +++ b/src/ui/toolbar/MainToolBar.h @@ -91,6 +91,8 @@ class MainToolBar : public QGCQmlWidgetHolder int telemetryLRSSI () { return _telemetryLRSSI; } int connectionCount () { return _connectionCount; } + void showToolBarMessage(const QString& message) { emit showMessage(message); } + signals: void connectionCountChanged (int count); void currentViewChanged (); diff --git a/src/ui/toolbar/MainToolBar.qml b/src/ui/toolbar/MainToolBar.qml index 96c9e631b35..5b11d4f6350 100644 --- a/src/ui/toolbar/MainToolBar.qml +++ b/src/ui/toolbar/MainToolBar.qml @@ -45,7 +45,10 @@ Rectangle { readonly property real toolBarHeight: ScreenTools.defaultFontPixelHeight * 3 property int cellSpacerSize: ScreenTools.isMobile ? getProportionalDimmension(6) : getProportionalDimmension(4) - readonly property int cellHeight: getProportionalDimmension(30) + readonly property int cellHeight: toolBarHeight * 0.75 + + readonly property real horizontalMargins: ScreenTools.defaultFontPixelWidth / 2 + readonly property real verticalMargins: ScreenTools.defaultFontPixelHeight / 4 readonly property var colorBlue: "#1a6eaa" readonly property var colorGreen: "#329147" @@ -62,7 +65,12 @@ Rectangle { Connections { target: mainToolBar - onShowMessage: mainToolBar.height = 100 + + onShowMessage: { + toolBarMessage.text = message + mainToolBar.height = toolBarHeight + toolBarMessage.contentHeight + verticalMargins + toolBarMessageArea.visible = true + } } function getProportionalDimmension(val) { @@ -183,24 +191,24 @@ Rectangle { mainToolBar.onFlyViewMenu(); } } - } + } // Menu Row { - id: row1 - height: cellHeight - anchors.left: parent.left - spacing: getProportionalDimmension(4) - anchors.verticalCenter: parent.verticalCenter - anchors.leftMargin: getProportionalDimmension(10) + id: toolRow + x: horizontalMargins + y: (toolBarHeight - cellHeight) / 2 + height: cellHeight + spacing: getProportionalDimmension(4) //--------------------------------------------------------------------- //-- Main menu for Non Mobile Devices (Chevron Buttons) Row { - id: row11 - height: cellHeight - spacing: -getProportionalDimmension(12) - anchors.verticalCenter: parent.verticalCenter - visible: !ScreenTools.isMobile + id: row11 + height: cellHeight + spacing: -getProportionalDimmension(12) + anchors.top: parent.top + visible: !ScreenTools.isMobile + Connections { target: ScreenTools onRepaintRequested: { @@ -219,7 +227,6 @@ Rectangle { height: cellHeight exclusiveGroup: mainActionGroup text: qsTr("Setup") - anchors.verticalCenter: parent.verticalCenter checked: (mainToolBar.currentView === MainToolBar.ViewSetup) onClicked: { mainToolBar.onSetupView(); @@ -233,7 +240,6 @@ Rectangle { height: cellHeight exclusiveGroup: mainActionGroup text: qsTr("Plan") - anchors.verticalCenter: parent.verticalCenter checked: (mainToolBar.currentView === MainToolBar.ViewPlan) onClicked: { mainToolBar.onPlanView(); @@ -247,7 +253,6 @@ Rectangle { height: cellHeight exclusiveGroup: mainActionGroup text: qsTr("Fly") - anchors.verticalCenter: parent.verticalCenter checked: (mainToolBar.currentView === MainToolBar.ViewFly) onClicked: { mainToolBar.onFlyView(); @@ -261,15 +266,13 @@ Rectangle { height: cellHeight exclusiveGroup: mainActionGroup text: qsTr("Analyze") - anchors.verticalCenter: parent.verticalCenter checked: (mainToolBar.currentView === MainToolBar.ViewAnalyze) onClicked: { mainToolBar.onAnalyzeView(); } z: 700 } - - } + } // Row //--------------------------------------------------------------------- //-- Indicators @@ -673,17 +676,17 @@ Rectangle { color: colorRedText } } - } - } + } // Row + } // Row Row { - id: row2 - height: cellHeight - spacing: cellSpacerSize - anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter - anchors.leftMargin: getProportionalDimmension(10) - anchors.rightMargin: getProportionalDimmension(10) + id: connectRow + anchors.rightMargin: verticalMargins + anchors.right: parent.right + anchors.top: toolRow.top + anchors.verticalCenter: toolRow.verticalCenter + height: toolRow.height + spacing: cellSpacerSize Menu { id: connectMenu @@ -718,7 +721,6 @@ Rectangle { visible: mainToolBar.connectionCount === 0 text: qsTr("Connect") menu: connectMenu - anchors.verticalCenter: parent.verticalCenter } QGCButton { @@ -726,7 +728,6 @@ Rectangle { width: getProportionalDimmension(100) visible: mainToolBar.connectionCount === 1 text: qsTr("Disconnect") - anchors.verticalCenter: parent.verticalCenter onClicked: { mainToolBar.onDisconnect(""); } @@ -756,18 +757,47 @@ Rectangle { text: "Disconnect" visible: mainToolBar.connectionCount > 1 menu: disconnectMenu - anchors.verticalCenter: parent.verticalCenter } - - } + } // Row // Progress bar Rectangle { - readonly property int progressBarHeight: getProportionalDimmension(3) - y: parent.height - progressBarHeight - height: progressBarHeight - width: parent.width * mainToolBar.progressBarValue - color: qgcPal.text + id: progressBar + anchors.top: toolRow.bottom + height: getProportionalDimmension(3) + width: parent.width * mainToolBar.progressBarValue + color: qgcPal.text } -} + // Toolbar message area + Rectangle { + id: toolBarMessageArea + anchors.margins: horizontalMargins + anchors.top: progressBar.bottom + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + color: qgcPal.windowShadeDark + visible: false + + QGCLabel { + id: toolBarMessage + anchors.fill: parent + wrapMode: Text.WordWrap + } + + QGCButton { + id: toolBarMessageCloseButton + anchors.rightMargin: horizontalMargins + anchors.topMargin: verticalMargins + anchors.top: parent.top + anchors.right: parent.right + text: "Close Message" + + onClicked: { + parent.visible = false + mainToolBar.height = toolBarHeight + } + } + } +} // Rectangle From f1196e141e61b36bf96fd0b345bbcb6c618113e7 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Sat, 15 Aug 2015 14:57:57 -0400 Subject: [PATCH 4/4] Show vehicle errors after parameter load --- src/FactSystem/ParameterLoader.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/FactSystem/ParameterLoader.cc b/src/FactSystem/ParameterLoader.cc index dcc65db0e53..f1e425271e5 100644 --- a/src/FactSystem/ParameterLoader.cc +++ b/src/FactSystem/ParameterLoader.cc @@ -758,20 +758,25 @@ void ParameterLoader::_checkInitialLoadComplete(void) UASMessageHandler* msgHandler = UASMessageHandler::instance(); if (msgHandler->getErrorCountTotal()) { QString errors; + bool firstError = true; msgHandler->lockAccess(); foreach (UASMessage* msg, msgHandler->messages()) { if (msg->severityIsError()) { + if (!firstError) { + errors += "\n"; + } + errors += " - "; errors += msg->getText(); - errors += "\n"; + firstError = false; } } msgHandler->unlockAccess(); - QGCMessageBox::critical("Vehicle startup errors", - QString("Errors were detected during vehicle startup:\n" - "%1" - "You should resolve these prior to flight.").arg(errors)); + if (!firstError) { + QString errorMsg = QString("Errors were detected during vehicle startup. You should resolve these prior to flight.\n%1").arg(errors); + qgcApp()->showToolBarMessage(errorMsg); + } } // Warn of parameter load failure