Commit 6ba5865c authored by dogmaphobic's avatar dogmaphobic

Fixing signal/slot connections

Removed "Clear Text" context menu from roll down dialog
Fixed "Clear Text" context menu in Info Dialog (renamed to "Clear Messages" in the process)
parent 74524490
...@@ -50,10 +50,10 @@ UASMessageHandler::UASMessageHandler(QObject *parent) ...@@ -50,10 +50,10 @@ UASMessageHandler::UASMessageHandler(QObject *parent)
UASMessageHandler::~UASMessageHandler() UASMessageHandler::~UASMessageHandler()
{ {
_clearMessages(); clearMessages();
} }
void UASMessageHandler::_clearMessages() void UASMessageHandler::clearMessages()
{ {
_mutex.lock(); _mutex.lock();
while(_messages.count()) { while(_messages.count()) {
...@@ -70,14 +70,14 @@ void UASMessageHandler::setActiveUAS(UASInterface* uas) ...@@ -70,14 +70,14 @@ void UASMessageHandler::setActiveUAS(UASInterface* uas)
{ {
disconnect(_activeUAS, SIGNAL(textMessageReceived(int,int,int,QString)), this, SLOT(handleTextMessage(int,int,int,QString))); disconnect(_activeUAS, SIGNAL(textMessageReceived(int,int,int,QString)), this, SLOT(handleTextMessage(int,int,int,QString)));
_activeUAS = NULL; _activeUAS = NULL;
_clearMessages(); clearMessages();
emit textMessageReceived(NULL); emit textMessageReceived(NULL);
} }
// And now if there's an autopilot to follow, set up the UI. // And now if there's an autopilot to follow, set up the UI.
if (uas) if (uas)
{ {
// Connect to the new UAS. // Connect to the new UAS.
_clearMessages(); clearMessages();
_activeUAS = uas; _activeUAS = uas;
connect(uas, SIGNAL(textMessageReceived(int,int,int,QString)), this, SLOT(handleTextMessage(int,int,int,QString))); connect(uas, SIGNAL(textMessageReceived(int,int,int,QString)), this, SLOT(handleTextMessage(int,int,int,QString)));
} }
......
...@@ -91,6 +91,10 @@ public: ...@@ -91,6 +91,10 @@ public:
* @brief Access to the message list * @brief Access to the message list
*/ */
const QVector<UASMessage*>& messages() { return _messages; } const QVector<UASMessage*>& messages() { return _messages; }
/**
* @brief Clear messages
*/
void clearMessages();
public slots: public slots:
/** /**
* @brief Set currently active UAS * @brief Set currently active UAS
...@@ -112,7 +116,6 @@ signals: ...@@ -112,7 +116,6 @@ signals:
*/ */
void textMessageReceived(UASMessage* message); void textMessageReceived(UASMessage* message);
private: private:
void _clearMessages();
// Stores the UAS that we're currently receiving messages from. // Stores the UAS that we're currently receiving messages from.
UASInterface* _activeUAS; UASInterface* _activeUAS;
QVector<UASMessage*> _messages; QVector<UASMessage*> _messages;
......
...@@ -434,7 +434,11 @@ void QGCToolBar::updateView() ...@@ -434,7 +434,11 @@ void QGCToolBar::updateView()
if (QGC::groundTimeMilliseconds() - lastSystemMessageTimeMs < 15000) { if (QGC::groundTimeMilliseconds() - lastSystemMessageTimeMs < 15000) {
toolBarMessageLabel->setText(QString("%1").arg(lastSystemMessage)); toolBarMessageLabel->setText(QString("%1").arg(lastSystemMessage));
} else { } else {
toolBarMessageLabel->setText(tr("Messages")); if(UASMessageHandler::instance()->messages().count()) {
toolBarMessageLabel->setText(tr("Messages"));
} else {
toolBarMessageLabel->setText(tr("No Messages"));
}
} }
} }
......
...@@ -63,11 +63,11 @@ UASMessageViewWidget::UASMessageViewWidget(QWidget *parent) ...@@ -63,11 +63,11 @@ UASMessageViewWidget::UASMessageViewWidget(QWidget *parent)
// widget has its context menu policy set to its actions list. So any actions we add // widget has its context menu policy set to its actions list. So any actions we add
// to this widget's action list will be automatically displayed. // to this widget's action list will be automatically displayed.
// We only have the clear action right now. // We only have the clear action right now.
QAction* clearAction = new QAction(tr("Clear Text"), this); QAction* clearAction = new QAction(tr("Clear Messages"), this);
connect(clearAction, SIGNAL(triggered()), ui()->plainTextEdit, SLOT(clear())); connect(clearAction, &QAction::triggered, this, &UASMessageViewWidget::clearMessages);
ui()->plainTextEdit->addAction(clearAction); ui()->plainTextEdit->addAction(clearAction);
// Connect message handler // Connect message handler
connect(UASMessageHandler::instance(), SIGNAL(textMessageReceived(UASMessage*)), this, SLOT(handleTextMessage(UASMessage*))); connect(UASMessageHandler::instance(), &UASMessageHandler::textMessageReceived, this, &UASMessageViewWidget::handleTextMessage);
} }
UASMessageViewWidget::~UASMessageViewWidget() UASMessageViewWidget::~UASMessageViewWidget()
...@@ -75,6 +75,12 @@ UASMessageViewWidget::~UASMessageViewWidget() ...@@ -75,6 +75,12 @@ UASMessageViewWidget::~UASMessageViewWidget()
} }
void UASMessageViewWidget::clearMessages()
{
ui()->plainTextEdit->clear();
UASMessageHandler::instance()->clearMessages();
}
void UASMessageViewWidget::handleTextMessage(UASMessage *message) void UASMessageViewWidget::handleTextMessage(UASMessage *message)
{ {
// Reset // Reset
...@@ -112,9 +118,6 @@ UASMessageViewRollDown::UASMessageViewRollDown(QWidget *parent, QGCToolBar *tool ...@@ -112,9 +118,6 @@ UASMessageViewRollDown::UASMessageViewRollDown(QWidget *parent, QGCToolBar *tool
setAttribute(Qt::WA_TranslucentBackground); setAttribute(Qt::WA_TranslucentBackground);
setStyleSheet("background-color: rgba(0%,0%,0%,80%); border: 2px;"); setStyleSheet("background-color: rgba(0%,0%,0%,80%); border: 2px;");
QPlainTextEdit *msgWidget = ui()->plainTextEdit; QPlainTextEdit *msgWidget = ui()->plainTextEdit;
QAction* clearAction = new QAction(tr("Clear Text"), this);
connect(clearAction, SIGNAL(triggered()), msgWidget, SLOT(clear()));
msgWidget->addAction(clearAction);
// Init Messages // Init Messages
UASMessageHandler::instance()->lockAccess(); UASMessageHandler::instance()->lockAccess();
msgWidget->setUpdatesEnabled(false); msgWidget->setUpdatesEnabled(false);
...@@ -125,7 +128,7 @@ UASMessageViewRollDown::UASMessageViewRollDown(QWidget *parent, QGCToolBar *tool ...@@ -125,7 +128,7 @@ UASMessageViewRollDown::UASMessageViewRollDown(QWidget *parent, QGCToolBar *tool
QScrollBar *scroller = msgWidget->verticalScrollBar(); QScrollBar *scroller = msgWidget->verticalScrollBar();
scroller->setValue(scroller->maximum()); scroller->setValue(scroller->maximum());
msgWidget->setUpdatesEnabled(true); msgWidget->setUpdatesEnabled(true);
connect(UASMessageHandler::instance(), SIGNAL(textMessageReceived(UASMessage*)), this, SLOT(handleTextMessage(UASMessage*))); connect(UASMessageHandler::instance(), &UASMessageHandler::textMessageReceived, this, &UASMessageViewRollDown::handleTextMessage);
UASMessageHandler::instance()->unlockAccess(); UASMessageHandler::instance()->unlockAccess();
} }
......
...@@ -59,6 +59,7 @@ public: ...@@ -59,6 +59,7 @@ public:
~UASMessageViewWidget(); ~UASMessageViewWidget();
public slots: public slots:
void handleTextMessage(UASMessage* message); void handleTextMessage(UASMessage* message);
void clearMessages();
private: private:
QGCUnconnectedInfoWidget* _unconnectedWidget; QGCUnconnectedInfoWidget* _unconnectedWidget;
}; };
......
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