From 571aa6446d7699f9b532d6c54a6fd478d1fdbe7f Mon Sep 17 00:00:00 2001 From: Jordan Sherer Date: Thu, 26 Jul 2018 15:57:19 -0400 Subject: [PATCH] Added message alerts --- mainwindow.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++++- varicode.cpp | 2 +- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 166cd0b..8100ac5 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -7232,6 +7232,18 @@ void MainWindow::buildQueryMenu(QMenu * menu){ addMessageText(QString("%1|").arg(selectedCall), true); }); + auto alertAction = menu->addAction("!message - Please display this message in an alert dialog and ACK if acknowledged"); + alertAction->setDisabled(isAllCall); + connect(alertAction, &QAction::triggered, this, [this](){ + + QString selectedCall = callsignSelected(); + if(selectedCall.isEmpty()){ + return; + } + + addMessageText(QString("%1!").arg(selectedCall), true); + }); + menu->addSeparator(); auto agnAction = menu->addAction("AGN? - Please repeat your last transmission"); @@ -8633,6 +8645,8 @@ void MainWindow::displayActivity(bool force){ if(Varicode::checksum16Valid(checksum, message)){ buffer.cmd.text = message; m_rxCommandQueue.append(buffer.cmd); + } else { + qDebug() << "Buffered message failed checksum...discarding"; } // regardless of valid or not, remove the "complete" buffered message from the buffer cache @@ -8653,7 +8667,7 @@ void MainWindow::displayActivity(bool force){ bool isAllCall = d.to == "ALLCALL"; -#if 0 +#if 1 qDebug() << "processing command" << d.from << d.to << d.cmd << d.freq; #endif @@ -8735,6 +8749,35 @@ void MainWindow::displayActivity(bool force){ // TODO: jsherer - perhaps parse d.text and ensure it is a valid message as well as prefix it with our call... reply = QString("%1 ACK\n%2 DE %1").arg(d.from).arg(d.text); } + // PROCESS ALERT + else if(d.cmd == "!" && !isAllCall){ + + QMessageBox * msgBox = new QMessageBox(this); + msgBox->setIcon(QMessageBox::Information); + + auto header = QString("Message from %3 at %1 (%2):"); + header = header.arg(d.utcTimestamp.time().toString()); + header = header.arg(d.freq); + header = header.arg(d.from); + msgBox->setText(header); + msgBox->setInformativeText(d.text); + + + auto ab = msgBox->addButton("ACK", QMessageBox::AcceptRole); + auto db = msgBox->addButton("Discard", QMessageBox::NoRole); + + connect(msgBox, &QMessageBox::buttonClicked, this, [this, d, db, ab](QAbstractButton * btn){ + if(btn != ab){ + return; + } + addMessageText(QString("%1 ACK").arg(d.from)); + toggleTx(true); + }); + + msgBox->show(); + + continue; + } if(reply.isEmpty()){ continue; diff --git a/varicode.cpp b/varicode.cpp index 4df7778..269b248 100644 --- a/varicode.cpp +++ b/varicode.cpp @@ -63,7 +63,7 @@ QMap directed_cmds = { {" ", 31 }, // send freetext }; -QSet allowed_cmds = {0, 1, 2, 3, 4, 5, 6, /*7,*/ 23, 24, 25, 26, 27, 28, 29, 30, 31}; +QSet allowed_cmds = {0, 1, 2, 3, 4, 5, 6, 7, 23, 24, 25, 26, 27, 28, 29, 30, 31}; QSet buffered_cmds = {6, 7};