Added option to confirm before sending autoreply message

This commit is contained in:
Jordan Sherer 2020-02-17 20:43:26 -05:00
parent ab3a927c2a
commit f350443dff
5 changed files with 78 additions and 29 deletions

View File

@ -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();

View File

@ -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;

View File

@ -39,7 +39,7 @@
<item>
<widget class="QTabWidget" name="tabWidget_2">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="stationTab">
<attribute name="title">
@ -281,7 +281,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>724</width>
<width>615</width>
<height>537</height>
</rect>
</property>
@ -873,34 +873,34 @@ text message.</string>
</property>
</widget>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QCheckBox" name="relay_disabled_check_box">
<property name="text">
<string>Disable message relay (&gt;) when autoreply is enabled</string>
</property>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="label_23">
<property name="text">
<string>Only autoreply to these callsigns (comma separated):</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="QLineEdit" name="auto_whitelist_line_edit"/>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Never autoreply to these callsigns (comma separated):</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="QLineEdit" name="auto_blacklist_line_edit"/>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Idle timeout - disable autoreply after:</string>
@ -910,7 +910,7 @@ text message.</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="QSpinBox" name="tx_watchdog_spin_box">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of minutes before unattended heartbeat transmissions are aborted.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
@ -938,6 +938,13 @@ text message.</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="autoreply_confirmation_check_box">
<property name="text">
<string>Ask for confirmation before sending autoreply transmissions</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -1527,7 +1534,7 @@ a few, particularly some Kenwood rigs, require it).</string>
<rect>
<x>0</x>
<y>0</y>
<width>718</width>
<width>494</width>
<height>490</height>
</rect>
</property>
@ -1931,8 +1938,8 @@ this setting allows you to select which audio input will be used
<rect>
<x>0</x>
<y>0</y>
<width>760</width>
<height>510</height>
<width>266</width>
<height>345</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_29">
@ -2318,7 +2325,7 @@ both here.</string>
<rect>
<x>0</x>
<y>0</y>
<width>746</width>
<width>508</width>
<height>567</height>
</rect>
</property>
@ -2843,8 +2850,8 @@ for assessing propagation and system performance.</string>
<rect>
<x>0</x>
<y>0</y>
<width>760</width>
<height>510</height>
<width>487</width>
<height>341</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_31">
@ -3180,8 +3187,8 @@ QListView::item:hover {
<rect>
<x>0</x>
<y>0</y>
<width>760</width>
<height>510</height>
<width>163</width>
<height>99</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_35">
@ -3323,8 +3330,8 @@ QListView::item:hover {
<rect>
<x>0</x>
<y>0</y>
<width>724</width>
<height>418</height>
<width>274</width>
<height>690</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_14">
@ -4583,12 +4590,12 @@ soundcard changes</string>
</connection>
</connections>
<buttongroups>
<buttongroup name="TX_audio_source_button_group"/>
<buttongroup name="CAT_data_bits_button_group"/>
<buttongroup name="split_mode_button_group"/>
<buttongroup name="CAT_stop_bits_button_group"/>
<buttongroup name="TX_mode_button_group"/>
<buttongroup name="CAT_handshake_button_group"/>
<buttongroup name="split_mode_button_group"/>
<buttongroup name="CAT_data_bits_button_group"/>
<buttongroup name="TX_audio_source_button_group"/>
<buttongroup name="PTT_method_button_group"/>
<buttongroup name="CAT_stop_bits_button_group"/>
</buttongroups>
</ui>

View File

@ -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;
}
}

View File

@ -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();