Commit 3cb8ec89 authored by Don Gagne's avatar Don Gagne

Add support for queued modeless messages

parent d63457c5
...@@ -56,6 +56,7 @@ MainToolBar::MainToolBar(QWidget* parent) ...@@ -56,6 +56,7 @@ MainToolBar::MainToolBar(QWidget* parent)
, _telemetryRRSSI(0) , _telemetryRRSSI(0)
, _telemetryLRSSI(0) , _telemetryLRSSI(0)
, _rollDownMessages(0) , _rollDownMessages(0)
, _toolbarMessageVisible(false)
{ {
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
setObjectName("MainToolBar"); setObjectName("MainToolBar");
...@@ -404,3 +405,43 @@ void MainToolBar::_heightChanged(double height) ...@@ -404,3 +405,43 @@ void MainToolBar::_heightChanged(double height)
setMinimumHeight(height); setMinimumHeight(height);
setMaximumHeight(height); setMaximumHeight(height);
} }
void MainToolBar::showToolBarMessage(const QString& message)
{
_toolbarMessageQueueMutex.lock();
if (_toolbarMessageQueue.count() == 0 && !_toolbarMessageVisible) {
QTimer::singleShot(500, this, &MainToolBar::_delayedShowToolBarMessage);
}
_toolbarMessageQueue += message;
_toolbarMessageQueueMutex.unlock();
}
void MainToolBar::_delayedShowToolBarMessage(void)
{
QString messages;
if (!_toolbarMessageVisible) {
_toolbarMessageQueueMutex.lock();
foreach (QString message, _toolbarMessageQueue) {
messages += message + "\n";
}
_toolbarMessageQueue.clear();
_toolbarMessageQueueMutex.unlock();
if (!messages.isEmpty()) {
_toolbarMessageVisible = true;
emit showMessage(messages);
}
}
}
void MainToolBar::onToolBarMessageClosed(void)
{
_toolbarMessageVisible = false;
_delayedShowToolBarMessage();
}
\ No newline at end of file
...@@ -68,6 +68,7 @@ public: ...@@ -68,6 +68,7 @@ public:
Q_INVOKABLE void onConnect(QString conf); Q_INVOKABLE void onConnect(QString conf);
Q_INVOKABLE void onDisconnect(QString conf); Q_INVOKABLE void onDisconnect(QString conf);
Q_INVOKABLE void onEnterMessageArea(int x, int y); Q_INVOKABLE void onEnterMessageArea(int x, int y);
Q_INVOKABLE void onToolBarMessageClosed(void);
Q_PROPERTY(double height MEMBER _toolbarHeight NOTIFY heightChanged) Q_PROPERTY(double height MEMBER _toolbarHeight NOTIFY heightChanged)
Q_PROPERTY(ViewType_t currentView MEMBER _currentView NOTIFY currentViewChanged) Q_PROPERTY(ViewType_t currentView MEMBER _currentView NOTIFY currentViewChanged)
...@@ -91,7 +92,7 @@ public: ...@@ -91,7 +92,7 @@ public:
int telemetryLRSSI () { return _telemetryLRSSI; } int telemetryLRSSI () { return _telemetryLRSSI; }
int connectionCount () { return _connectionCount; } int connectionCount () { return _connectionCount; }
void showToolBarMessage(const QString& message) { emit showMessage(message); } void showToolBarMessage(const QString& message);
signals: signals:
void connectionCountChanged (int count); void connectionCountChanged (int count);
...@@ -123,6 +124,7 @@ private slots: ...@@ -123,6 +124,7 @@ private slots:
void _remoteControlRSSIChanged (uint8_t rssi); void _remoteControlRSSIChanged (uint8_t rssi);
void _telemetryChanged (LinkInterface* link, unsigned rxerrors, unsigned fixed, unsigned rssi, unsigned remrssi, unsigned txbuf, unsigned noise, unsigned remnoise); void _telemetryChanged (LinkInterface* link, unsigned rxerrors, unsigned fixed, unsigned rssi, unsigned remrssi, unsigned txbuf, unsigned noise, unsigned remnoise);
void _heightChanged (double height); void _heightChanged (double height);
void _delayedShowToolBarMessage (void);
private: private:
void _updateConnection (LinkInterface *disconnectedLink = NULL); void _updateConnection (LinkInterface *disconnectedLink = NULL);
...@@ -148,6 +150,10 @@ private: ...@@ -148,6 +150,10 @@ private:
double _toolbarHeight; double _toolbarHeight;
UASMessageViewRollDown* _rollDownMessages; UASMessageViewRollDown* _rollDownMessages;
bool _toolbarMessageVisible;
QStringList _toolbarMessageQueue;
QMutex _toolbarMessageQueueMutex;
}; };
#endif // MAINTOOLBAR_H #endif // MAINTOOLBAR_H
...@@ -68,7 +68,11 @@ Rectangle { ...@@ -68,7 +68,11 @@ Rectangle {
onShowMessage: { onShowMessage: {
toolBarMessage.text = message toolBarMessage.text = message
mainToolBar.height = toolBarHeight + toolBarMessage.contentHeight + verticalMargins if (toolBarMessage.contentHeight > toolBarMessageCloseButton.height) {
mainToolBar.height = toolBarHeight + toolBarMessage.contentHeight + (verticalMargins * 2)
} else {
mainToolBar.height = toolBarHeight + toolBarMessageCloseButton.height + (verticalMargins * 2)
}
toolBarMessageArea.visible = true toolBarMessageArea.visible = true
} }
} }
...@@ -771,14 +775,17 @@ Rectangle { ...@@ -771,14 +775,17 @@ Rectangle {
// Toolbar message area // Toolbar message area
Rectangle { Rectangle {
id: toolBarMessageArea id: toolBarMessageArea
anchors.margins: horizontalMargins anchors.leftMargin: horizontalMargins
anchors.top: progressBar.bottom anchors.rightMargin: horizontalMargins
anchors.bottom: parent.bottom anchors.topMargin: verticalMargins
anchors.left: parent.left anchors.bottomMargin: verticalMargins
anchors.right: parent.right anchors.top: progressBar.bottom
color: qgcPal.windowShadeDark anchors.bottom: parent.bottom
visible: false anchors.left: parent.left
anchors.right: parent.right
color: qgcPal.windowShadeDark
visible: false
QGCLabel { QGCLabel {
id: toolBarMessage id: toolBarMessage
...@@ -790,7 +797,6 @@ Rectangle { ...@@ -790,7 +797,6 @@ Rectangle {
QGCButton { QGCButton {
id: toolBarMessageCloseButton id: toolBarMessageCloseButton
anchors.rightMargin: horizontalMargins anchors.rightMargin: horizontalMargins
anchors.topMargin: verticalMargins
anchors.top: parent.top anchors.top: parent.top
anchors.right: parent.right anchors.right: parent.right
primary: true primary: true
...@@ -799,6 +805,7 @@ Rectangle { ...@@ -799,6 +805,7 @@ Rectangle {
onClicked: { onClicked: {
parent.visible = false parent.visible = false
mainToolBar.height = toolBarHeight mainToolBar.height = toolBarHeight
mainToolBar.onToolBarMessageClosed()
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment