From 00685b911725cc4466059874310429a6a969c467 Mon Sep 17 00:00:00 2001 From: Jordan Sherer Date: Sat, 27 Oct 2018 15:01:27 -0400 Subject: [PATCH] Warning message for stupid messages --- mainwindow.cpp | 34 ++++++++++++++++++++++++++++++++-- mainwindow.h | 1 + 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 1753b53..f85703b 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -5225,12 +5225,24 @@ bool MainWindow::ensureSelcalCallsignSelected(bool alert){ bool blockTransmit = ui->selcalButton->isChecked() && (isAllCall || missingCall); if(blockTransmit && alert){ - MessageBox::warning_message(this, tr ("Please select or enter a callsign to direct this message while SELCAL is enabled.")); + MessageBox::warning_message(this, tr ("Please select or enter a callsign to direct this message while SELCALL is enabled.")); } return !blockTransmit; } +bool MainWindow::ensureKeyNotStuck(QString const& text){ + // be annoying and drop messages with all the same character to reduce spam... + if(text.length() > 10 && QString(text).replace(text.at(0), "").isEmpty()){ + + MessageBox::warning_message(this, tr ("Please enter a message before trying to transmit")); + + return false; + } + + return true; +} + void MainWindow::createMessage(QString const& text){ if(!ensureCallsignSet()){ on_stopTxButton_clicked(); @@ -5242,6 +5254,11 @@ void MainWindow::createMessage(QString const& text){ return; } + if(!ensureKeyNotStuck(text)){ + on_stopTxButton_clicked(); + return; + } + if(text.contains("APRS:") && !m_aprsClient->isPasscodeValid()){ MessageBox::warning_message(this, tr ("Please ensure a valid APRS passcode is set in the settings when sending an APRS packet.")); return; @@ -6697,7 +6714,7 @@ void MainWindow::buildQueryMenu(QMenu * menu, QString call){ if(m_config.transmit_directed()) toggleTx(true); }); - auto sevenThreeAction = menu->addAction(QString("%1 73 - I send my best regards / end of contact").arg(call).trimmed()); + auto sevenThreeAction = menu->addAction(QString("%1 73 - I send my best regards").arg(call).trimmed()); connect(sevenThreeAction, &QAction::triggered, this, [this](){ QString selectedCall = callsignSelected(); @@ -6709,6 +6726,19 @@ void MainWindow::buildQueryMenu(QMenu * menu, QString call){ if(m_config.transmit_directed()) toggleTx(true); }); + + auto skAction = menu->addAction(QString("%1 SK - End of contact").arg(call).trimmed()); + connect(skAction, &QAction::triggered, this, [this](){ + + QString selectedCall = callsignSelected(); + if(selectedCall.isEmpty()){ + return; + } + + addMessageText(QString("%1 SK").arg(selectedCall), true); + + if(m_config.transmit_directed()) toggleTx(true); + }); } void MainWindow::buildRelayMenu(QMenu *menu){ diff --git a/mainwindow.h b/mainwindow.h index 4015beb..1f0a03c 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -151,6 +151,7 @@ public slots: void initializeDummyData(); bool ensureCallsignSet(bool alert=true); bool ensureSelcalCallsignSelected(bool alert=true); + bool ensureKeyNotStuck(QString const& text); void createMessage(QString const& text); void createMessageTransmitQueue(QString const& text); void resetMessageTransmitQueue();