diff --git a/MessageAggregator.cpp b/MessageAggregator.cpp index f4b0b8ec5..2471ec2a5 100644 --- a/MessageAggregator.cpp +++ b/MessageAggregator.cpp @@ -222,7 +222,7 @@ public: Q_EMIT do_free_text (id_, text, false); }); connect (message_line_edit_, &QLineEdit::editingFinished, [this] () { - Q_EMIT do_free_text (id_, message_line_edit_->text (), !message_line_edit_->text ().isEmpty ()); + Q_EMIT do_free_text (id_, message_line_edit_->text (), true); }); control_layout->addLayout (form_layout); control_layout->addWidget (auto_off_button_); diff --git a/NetworkMessage.hpp b/NetworkMessage.hpp index cce1380b5..de18461d0 100644 --- a/NetworkMessage.hpp +++ b/NetworkMessage.hpp @@ -199,14 +199,29 @@ * Send bool * * This message allows the server to set the current free text - * message content. Sending this message is equivalent to typing - * a new message (old contents are discarded) in to the WSJT-X - * free text message field or "Tx5" field (both are updated) and - * if the Send flag is set then clicking the "Now" radio button - * for the "Tx5" field if tab one is current or clicking the - * "Free msg" radio button if tab two is current. It is the - * responsibility of the sender to limit the length of the - * message text and to limit it to legal message characters. + * message content. Sending this message with a non-empty "Text" + * field is equivalent to typing a new message (old contents are + * discarded) in to the WSJT-X free text message field or "Tx5" + * field (both are updated) and if the "Send" flag is set then + * clicking the "Now" radio button for the "Tx5" field if tab one + * is current or clicking the "Free msg" radio button if tab two + * is current. + * + * It is the responsibility of the sender to limit the length of + * the message text and to limit it to legal message + * characters. Despite this, it may be difficult for the sender + * to determine the maximum message length without reimplementing + * the complete message encoding protocol. Because of this is may + * be better to allow any reasonable message length and to let + * the WSJT-X application encode and possibly truncate the actual + * on-air message. + * + * If the message text is empty the meaning of the message is + * refined to send the current free text unchanged when the + * "Send" flag is set or to clear the current free text when the + * "Send" flag is unset. Note that this API does not include a + * command to determine the contents of the current free text + * message. */ #include diff --git a/mainwindow.cpp b/mainwindow.cpp index f27ff1e7c..f4694c3c4 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -201,22 +201,34 @@ MainWindow::MainWindow(bool multiple, QSettings * settings, QSharedMemory *shdme }); connect (m_messageClient, &MessageClient::error, this, &MainWindow::networkError); connect (m_messageClient, &MessageClient::free_text, [this] (QString const& text, bool send) { - if (m_config.accept_udp_requests ()) { - if (0 == ui->tabWidget->currentIndex ()) { - ui->tx5->setCurrentText (text); - if (send) { - ui->txb5->click (); - } else { - ui->txrb5->click (); - } - } else if (1 == ui->tabWidget->currentIndex ()) { - ui->freeTextMsg->setCurrentText (text); - if (send) { - ui->rbFreeText->click (); + if (m_config.accept_udp_requests ()) { + // send + non-empty text means set and send the free text + // message, !send + non-empty text means set the current free + // text message, send + empty text means send the current free + // text message without change, !send + empty text means clear + // the current free text message + qDebug () << "Free text UDP message - text:" << text << "send:" << send << "text empty:" << text.isEmpty (); + if (0 == ui->tabWidget->currentIndex ()) { + if (!text.isEmpty ()) { + ui->tx5->setCurrentText (text); + } + if (send) { + ui->txb5->click (); + } else if (text.isEmpty ()) { + ui->tx5->setCurrentText (text); + } + } else if (1 == ui->tabWidget->currentIndex ()) { + if (!text.isEmpty ()) { + ui->freeTextMsg->setCurrentText (text); + } + if (send) { + ui->rbFreeText->click (); + } else if (text.isEmpty ()) { + ui->freeTextMsg->setCurrentText (text); + } } } - } - }); + }); // Hook up WSPR band hopping connect (ui->band_hopping_schedule_push_button, &QPushButton::clicked