From f350443dff295bc01a941dcfd6a462b2b0868cb8 Mon Sep 17 00:00:00 2001 From: Jordan Sherer Date: Mon, 17 Feb 2020 20:43:26 -0500 Subject: [PATCH] Added option to confirm before sending autoreply message --- Configuration.cpp | 6 ++++++ Configuration.hpp | 1 + Configuration.ui | 53 +++++++++++++++++++++++++++-------------------- mainwindow.cpp | 46 ++++++++++++++++++++++++++++++++++------ mainwindow.h | 1 + 5 files changed, 78 insertions(+), 29 deletions(-) diff --git a/Configuration.cpp b/Configuration.cpp index 3cba864..69b33ea 100644 --- a/Configuration.cpp +++ b/Configuration.cpp @@ -639,6 +639,7 @@ private: bool spot_to_reporting_networks_; bool transmit_directed_; bool autoreply_on_at_startup_; + bool autoreply_confirmation_; bool heartbeat_anywhere_; bool heartbeat_qso_pause_; bool relay_disabled_; @@ -805,6 +806,7 @@ bool Configuration::autoreply_on_at_startup () const { } return m_->autoreply_on_at_startup_; } +bool Configuration::autoreply_confirmation() const { return m_->autoreply_confirmation_; } bool Configuration::heartbeat_anywhere() const { return m_->heartbeat_anywhere_;} bool Configuration::heartbeat_qso_pause() const { return m_->heartbeat_qso_pause_;} bool Configuration::relay_off() const { return m_->relay_disabled_; } @@ -1508,6 +1510,7 @@ void Configuration::impl::initialize_models () ui_->psk_reporter_check_box->setChecked (spot_to_reporting_networks_); ui_->transmit_directed_check_box->setChecked(transmit_directed_); ui_->autoreply_on_check_box->setChecked (autoreply_on_at_startup_); + ui_->autoreply_confirmation_check_box->setChecked (autoreply_confirmation_); ui_->heartbeat_anywhere_check_box->setChecked(heartbeat_anywhere_); ui_->heartbeat_qso_pause_check_box->setChecked(heartbeat_qso_pause_); ui_->relay_disabled_check_box->setChecked(relay_disabled_); @@ -1925,6 +1928,7 @@ void Configuration::impl::read_settings () transmit_directed_ = settings_->value ("TransmitDirected", true).toBool(); autoreply_on_at_startup_ = settings_->value ("AutoreplyOnAtStartup", false).toBool (); + autoreply_confirmation_ = settings_->value ("AutoreplyConfirmation", false).toBool (); heartbeat_anywhere_ = settings_->value("BeaconAnywhere", false).toBool(); heartbeat_qso_pause_ = settings_->value("HeartbeatQSOPause", true).toBool(); relay_disabled_ = settings_->value ("RelayOFF", false).toBool (); @@ -2137,6 +2141,7 @@ void Configuration::impl::write_settings () settings_->setValue ("Type2MsgGen", QVariant::fromValue (type_2_msg_gen_)); settings_->setValue ("TransmitDirected", transmit_directed_); settings_->setValue ("AutoreplyOnAtStartup", autoreply_on_at_startup_); + settings_->setValue ("AutoreplyConfirmation", autoreply_confirmation_); settings_->setValue ("BeaconAnywhere", heartbeat_anywhere_); settings_->setValue ("HeartbeatQSOPause", heartbeat_qso_pause_); settings_->setValue ("RelayOFF", relay_disabled_); @@ -2763,6 +2768,7 @@ void Configuration::impl::accept () tx_qsy_allowed_ = ui_->tx_qsy_check_box->isChecked (); transmit_directed_ = ui_->transmit_directed_check_box->isChecked(); autoreply_on_at_startup_ = ui_->autoreply_on_check_box->isChecked (); + autoreply_confirmation_ = ui_->autoreply_confirmation_check_box->isChecked (); heartbeat_anywhere_ = ui_->heartbeat_anywhere_check_box->isChecked(); heartbeat_qso_pause_ = ui_->heartbeat_qso_pause_check_box->isChecked(); relay_disabled_ = ui_->relay_disabled_check_box->isChecked(); diff --git a/Configuration.hpp b/Configuration.hpp index eac37eb..2c5f450 100644 --- a/Configuration.hpp +++ b/Configuration.hpp @@ -138,6 +138,7 @@ public: void set_spot_to_reporting_networks (bool); bool transmit_directed() const; bool autoreply_on_at_startup () const; + bool autoreply_confirmation () const; bool heartbeat_anywhere() const; bool heartbeat_qso_pause() const; bool relay_off() const; diff --git a/Configuration.ui b/Configuration.ui index 8fd5962..b38b970 100644 --- a/Configuration.ui +++ b/Configuration.ui @@ -39,7 +39,7 @@ - 1 + 0 @@ -281,7 +281,7 @@ 0 0 - 724 + 615 537 @@ -873,34 +873,34 @@ text message. - + Disable message relay (>) when autoreply is enabled - + Only autoreply to these callsigns (comma separated): - + - + Never autoreply to these callsigns (comma separated): - + - + Idle timeout - disable autoreply after: @@ -910,7 +910,7 @@ text message. - + <html><head/><body><p>Number of minutes before unattended heartbeat transmissions are aborted.</p></body></html> @@ -938,6 +938,13 @@ text message. + + + + Ask for confirmation before sending autoreply transmissions + + + @@ -1527,7 +1534,7 @@ a few, particularly some Kenwood rigs, require it). 0 0 - 718 + 494 490 @@ -1931,8 +1938,8 @@ this setting allows you to select which audio input will be used 0 0 - 760 - 510 + 266 + 345 @@ -2318,7 +2325,7 @@ both here. 0 0 - 746 + 508 567 @@ -2843,8 +2850,8 @@ for assessing propagation and system performance. 0 0 - 760 - 510 + 487 + 341 @@ -3180,8 +3187,8 @@ QListView::item:hover { 0 0 - 760 - 510 + 163 + 99 @@ -3323,8 +3330,8 @@ QListView::item:hover { 0 0 - 724 - 418 + 274 + 690 @@ -4583,12 +4590,12 @@ soundcard changes - - + + - + + - diff --git a/mainwindow.cpp b/mainwindow.cpp index 1ee804b..03373fa 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -6598,6 +6598,30 @@ void MainWindow::addMessageText(QString text, bool clear, bool selectFirstPlaceh ui->extFreeTextMsgEdit->setFocus(); } +void MainWindow::confirmThenEnqueueMessage(int timeout, int priority, QString message, int freq, Callback c){ + SelfDestructMessageBox * m = new SelfDestructMessageBox(timeout, + "Autoreply Confirmation Required", + QString("A transmission is queued for autoreply:\n\n%1\n\nWould you like to send this transmission?").arg(message), + QMessageBox::Question, + QMessageBox::Yes | QMessageBox::No, + QMessageBox::No, + false, + this); + + connect(m, &SelfDestructMessageBox::finished, this, [this, m, priority, message, freq, c](int result){ + // make sure we delete the message box later... + m->deleteLater(); + + if(result != QMessageBox::Yes){ + return; + } + + enqueueMessage(priority, message, freq, c); + }); + + m->show(); +} + void MainWindow::enqueueMessage(int priority, QString message, int freq, Callback c){ m_txMessageQueue.enqueue( PrioritizedMessage{ @@ -8121,7 +8145,7 @@ void MainWindow::sendHeartbeat(){ f = -1; } - enqueueMessage(PriorityLow + 1, message, f, [this](){ /* */ }); + enqueueMessage(PriorityLow + 1, message, f, nullptr); processTxQueue(); } @@ -8135,8 +8159,14 @@ void MainWindow::sendHeartbeatAck(QString to, int snr, QString extra){ auto f = m_config.heartbeat_anywhere() ? -1 : findFreeFreqOffset(500, 1000, 50); - enqueueMessage(PriorityLow + 1, message, f, [this](){ /* */ }); - processTxQueue(); + if(m_config.autoreply_confirmation()){ + confirmThenEnqueueMessage(90, PriorityLow + 1, message, f, [this](){ + processTxQueue(); + }); + } else { + enqueueMessage(PriorityLow + 1, message, f, nullptr); + processTxQueue(); + } } void MainWindow::on_hbMacroButton_toggled(bool checked){ @@ -11195,6 +11225,7 @@ void MainWindow::processCommandActivity() { extra = QString("MSG ID %1").arg(mid); } + // TODO: require confirmation? sendHeartbeatAck(d.from, d.snr, extra); if(isAllCall){ @@ -11440,9 +11471,7 @@ void MainWindow::processCommandActivity() { // do not queue for reply if there's a buffer open to us int bufferOffset = 0; if(hasExistingMessageBufferToMe(&bufferOffset)){ - qDebug() << "skipping reply due to open buffer" << bufferOffset << m_messageBuffer.count(); - continue; } @@ -11455,7 +11484,11 @@ void MainWindow::processCommandActivity() { // unless, this is an allcall, to which we should be responding on a clear frequency offset // we always want to make sure that the directed cache has been updated at this point so we have the // most information available to make a frequency selection. - enqueueMessage(priority, reply, freq, nullptr); + if(m_config.autoreply_confirmation()){ + confirmThenEnqueueMessage(90, priority, reply, freq, nullptr); + } else { + enqueueMessage(priority, reply, freq, nullptr); + } } } @@ -12640,6 +12673,7 @@ void MainWindow::networkMessage(Message const &message) auto text = message.value(); if(!text.isEmpty()){ enqueueMessage(PriorityNormal, text, -1, nullptr); + processTxQueue(); return; } } diff --git a/mainwindow.h b/mainwindow.h index 3744761..aca65e3 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -149,6 +149,7 @@ public slots: bool isInDecodeDelayThreshold(int seconds); void prependMessageText(QString text); void addMessageText(QString text, bool clear=false, bool selectFirstPlaceholder=false); + void confirmThenEnqueueMessage(int timeout, int priority, QString message, int freq, Callback c); void enqueueMessage(int priority, QString message, int freq, Callback c); void resetMessage(); void resetMessageUI();