Fixed self destruct alert for new messages
This commit is contained in:
parent
845022c9bd
commit
9e655f7f12
@ -1392,21 +1392,21 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Message> msgs;
|
QList<QPair<int, Message> > msgs;
|
||||||
foreach(auto pair, inbox.values("READ", "$.params.FROM", selectedCall, 0, 1000)){
|
|
||||||
msgs.append(pair.second);
|
msgs.append(inbox.values("READ", "$.params.FROM", selectedCall, 0, 1000));
|
||||||
}
|
|
||||||
foreach(auto pair, inbox.values("UNREAD", "$.params.FROM", selectedCall, 0, 1000)){
|
foreach(auto pair, inbox.values("UNREAD", "$.params.FROM", selectedCall, 0, 1000)){
|
||||||
auto msg = pair.second;
|
msgs.append(pair);
|
||||||
msgs.append(msg);
|
|
||||||
|
|
||||||
// mark as read
|
// mark as read
|
||||||
|
auto msg = pair.second;
|
||||||
msg.setType("READ");
|
msg.setType("READ");
|
||||||
inbox.set(pair.first, msg);
|
inbox.set(pair.first, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
qStableSort(msgs.begin(), msgs.end(), [](Message const &a, Message const &b){
|
qStableSort(msgs.begin(), msgs.end(), [](QPair<int, Message> const &a, QPair<int, Message> const &b){
|
||||||
return a.params().value("UTC") > b.params().value("UTC");
|
return a.second.params().value("UTC") > b.second.params().value("UTC");
|
||||||
});
|
});
|
||||||
|
|
||||||
auto mw = new MessageWindow(this);
|
auto mw = new MessageWindow(this);
|
||||||
@ -7436,6 +7436,19 @@ void MainWindow::buildQueryMenu(QMenu * menu, QString call){
|
|||||||
addMessageText(QString("%1>[MESSAGE]").arg(selectedCall), true, true);
|
addMessageText(QString("%1>[MESSAGE]").arg(selectedCall), true, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
auto msgAction = menu->addAction(QString("%1 MSG [MESSAGE] - Please store this message in your inbox").arg(call).trimmed());
|
||||||
|
msgAction->setDisabled(isAllCall);
|
||||||
|
connect(msgAction, &QAction::triggered, this, [this](){
|
||||||
|
|
||||||
|
QString selectedCall = callsignSelected();
|
||||||
|
if(selectedCall.isEmpty()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
addMessageText(QString("%1 MSG [MESSAGE]").arg(selectedCall), true, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
auto msgToAction = menu->addAction(QString("%1 MSG TO:[CALLSIGN] [MESSAGE] - Please store this message at your station for later retreival by [CALLSIGN]").arg(call).trimmed());
|
auto msgToAction = menu->addAction(QString("%1 MSG TO:[CALLSIGN] [MESSAGE] - Please store this message at your station for later retreival by [CALLSIGN]").arg(call).trimmed());
|
||||||
msgToAction->setDisabled(isAllCall);
|
msgToAction->setDisabled(isAllCall);
|
||||||
connect(msgToAction, &QAction::triggered, this, [this](){
|
connect(msgToAction, &QAction::triggered, this, [this](){
|
||||||
@ -7459,7 +7472,7 @@ void MainWindow::buildQueryMenu(QMenu * menu, QString call){
|
|||||||
addMessageText(QString("%1 QUERY CALL [CALLSIGN]?").arg(selectedCall), true, true);
|
addMessageText(QString("%1 QUERY CALL [CALLSIGN]?").arg(selectedCall), true, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
auto qsoQueryMsgAction = menu->addAction(QString("%1 QUERY MSGS - Please deliver any messages you have for me").arg(call).trimmed());
|
auto qsoQueryMsgAction = menu->addAction(QString("%1 QUERY MSGS - Do you have any messages for me?").arg(call).trimmed());
|
||||||
connect(qsoQueryMsgAction, &QAction::triggered, this, [this](){
|
connect(qsoQueryMsgAction, &QAction::triggered, this, [this](){
|
||||||
|
|
||||||
QString selectedCall = callsignSelected();
|
QString selectedCall = callsignSelected();
|
||||||
@ -9992,12 +10005,6 @@ void MainWindow::processCommandActivity() {
|
|||||||
// if we make it here, this is a message
|
// if we make it here, this is a message
|
||||||
addCommandToMyInbox(d);
|
addCommandToMyInbox(d);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ALERT_ON_NEW_MSG
|
|
||||||
QTimer::singleShot(500, this, [this, d](){
|
|
||||||
MessageBox::information_message(this, QString("A new message was received at %1 UTC from %2").arg(d.utcTimestamp.time().toString()).arg(d.from));
|
|
||||||
});
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10083,6 +10090,19 @@ void MainWindow::processCommandActivity() {
|
|||||||
|
|
||||||
// we haven't replaced the from with the relay path, so we have to use it for the ack if there is one
|
// we haven't replaced the from with the relay path, so we have to use it for the ack if there is one
|
||||||
reply = QString("%1 ACK").arg(calls.length() > 1 ? d.relayPath : d.from);
|
reply = QString("%1 ACK").arg(calls.length() > 1 ? d.relayPath : d.from);
|
||||||
|
|
||||||
|
#define SHOW_ALERT_FOR_MSG 1
|
||||||
|
#if SHOW_ALERT_FOR_MSG
|
||||||
|
SelfDestructMessageBox * m = new SelfDestructMessageBox(300,
|
||||||
|
"New Message Received",
|
||||||
|
QString("A new message was received at %1 UTC from %2").arg(d.utcTimestamp.time().toString()).arg(d.from),
|
||||||
|
QMessageBox::Information,
|
||||||
|
QMessageBox::Ok,
|
||||||
|
QMessageBox::Ok,
|
||||||
|
this);
|
||||||
|
|
||||||
|
m->show();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// PROCESS ACKS
|
// PROCESS ACKS
|
||||||
@ -11894,7 +11914,7 @@ void MainWindow::tx_watchdog (bool triggered)
|
|||||||
|
|
||||||
QMessageBox * msgBox = new QMessageBox(this);
|
QMessageBox * msgBox = new QMessageBox(this);
|
||||||
msgBox->setIcon(QMessageBox::Information);
|
msgBox->setIcon(QMessageBox::Information);
|
||||||
msgBox->setText("Idle Timeout");
|
msgBox->setWindowTitle("Idle Timeout");
|
||||||
msgBox->setInformativeText(QString("You have been idle for more than %1 minutes.").arg(m_config.watchdog()));
|
msgBox->setInformativeText(QString("You have been idle for more than %1 minutes.").arg(m_config.watchdog()));
|
||||||
msgBox->addButton(QMessageBox::Ok);
|
msgBox->addButton(QMessageBox::Ok);
|
||||||
|
|
||||||
|
@ -52,14 +52,16 @@ void MessageWindow::setCall(const QString &call){
|
|||||||
setWindowTitle(QString("Message History: %1").arg(call));
|
setWindowTitle(QString("Message History: %1").arg(call));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageWindow::populateMessages(QList<Message> msgs){
|
void MessageWindow::populateMessages(QList<QPair<int, Message> > msgs){
|
||||||
for(int i = ui->messageTableWidget->rowCount(); i >= 0; i--){
|
for(int i = ui->messageTableWidget->rowCount(); i >= 0; i--){
|
||||||
ui->messageTableWidget->removeRow(i);
|
ui->messageTableWidget->removeRow(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->messageTableWidget->setUpdatesEnabled(false);
|
ui->messageTableWidget->setUpdatesEnabled(false);
|
||||||
{
|
{
|
||||||
foreach(auto msg, msgs){
|
foreach(auto pair, msgs){
|
||||||
|
auto mid = pair.first;
|
||||||
|
auto msg = pair.second;
|
||||||
auto params = msg.params();
|
auto params = msg.params();
|
||||||
|
|
||||||
int row = ui->messageTableWidget->rowCount();
|
int row = ui->messageTableWidget->rowCount();
|
||||||
@ -72,6 +74,11 @@ void MessageWindow::populateMessages(QList<Message> msgs){
|
|||||||
typeItem->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
|
typeItem->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
|
||||||
ui->messageTableWidget->setItem(row, col++, typeItem);
|
ui->messageTableWidget->setItem(row, col++, typeItem);
|
||||||
|
|
||||||
|
auto midItem = new QTableWidgetItem(QString::number(mid));
|
||||||
|
midItem->setData(Qt::UserRole, mid);
|
||||||
|
midItem->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
|
||||||
|
ui->messageTableWidget->setItem(row, col++, midItem);
|
||||||
|
|
||||||
auto date = params.value("UTC").toString();
|
auto date = params.value("UTC").toString();
|
||||||
auto timestamp = QDateTime::fromString(date, "yyyy-MM-dd hh:mm:ss");
|
auto timestamp = QDateTime::fromString(date, "yyyy-MM-dd hh:mm:ss");
|
||||||
auto dateItem = new QTableWidgetItem(timestamp.toString());
|
auto dateItem = new QTableWidgetItem(timestamp.toString());
|
||||||
@ -103,6 +110,7 @@ void MessageWindow::populateMessages(QList<Message> msgs){
|
|||||||
ui->messageTableWidget->resizeColumnToContents(1);
|
ui->messageTableWidget->resizeColumnToContents(1);
|
||||||
ui->messageTableWidget->resizeColumnToContents(2);
|
ui->messageTableWidget->resizeColumnToContents(2);
|
||||||
ui->messageTableWidget->resizeColumnToContents(3);
|
ui->messageTableWidget->resizeColumnToContents(3);
|
||||||
|
ui->messageTableWidget->resizeColumnToContents(4);
|
||||||
}
|
}
|
||||||
ui->messageTableWidget->setUpdatesEnabled(true);
|
ui->messageTableWidget->setUpdatesEnabled(true);
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define MESSAGEWINDOW_H
|
#define MESSAGEWINDOW_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QPair>
|
||||||
#include <QItemSelection>
|
#include <QItemSelection>
|
||||||
|
|
||||||
#include "Message.h"
|
#include "Message.h"
|
||||||
@ -23,7 +24,7 @@ signals:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setCall(const QString &call);
|
void setCall(const QString &call);
|
||||||
void populateMessages(QList<Message> msgs);
|
void populateMessages(QList<QPair<int, Message>> msgs);
|
||||||
QString prepareReplyMessage(QString path, QString text);
|
QString prepareReplyMessage(QString path, QString text);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -110,10 +110,18 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>⚑</string>
|
<string>⚑</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Read / Unread Status</string>
|
||||||
|
</property>
|
||||||
<property name="textAlignment">
|
<property name="textAlignment">
|
||||||
<set>AlignCenter</set>
|
<set>AlignCenter</set>
|
||||||
</property>
|
</property>
|
||||||
</column>
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>ID</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
<column>
|
<column>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Date</string>
|
<string>Date</string>
|
||||||
@ -136,7 +144,6 @@
|
|||||||
</column>
|
</column>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QTextEdit" name="messageTextEdit">
|
<widget class="QTextEdit" name="messageTextEdit">
|
||||||
<property name="visible"><bool>false</bool></property>
|
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
|
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@ -148,18 +155,23 @@
|
|||||||
<pointsize>14</pointsize>
|
<pointsize>14</pointsize>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="visible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">QTextEdit { background-color:#ffeaa7; }</string>
|
<string notr="true">QTextEdit { background-color:#ffeaa7; }</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QTextEdit" name="replytextEdit">
|
<widget class="QTextEdit" name="replytextEdit">
|
||||||
<property name="visible"><bool>false</bool></property>
|
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
|
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>1</verstretch>
|
<verstretch>1</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="visible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user