Fixed bug with send button not disabling on text clear
This commit is contained in:
parent
f4090ece63
commit
97ccbbd049
@ -8716,6 +8716,12 @@ void MainWindow::updateButtonDisplay(){
|
|||||||
bool isTransmitting = m_transmitting || m_txFrameCount > 0;
|
bool isTransmitting = m_transmitting || m_txFrameCount > 0;
|
||||||
auto selectedCallsign = callsignSelected(true);
|
auto selectedCallsign = callsignSelected(true);
|
||||||
bool emptyCallsign = selectedCallsign.isEmpty();
|
bool emptyCallsign = selectedCallsign.isEmpty();
|
||||||
|
bool hasText = !ui->extFreeTextMsgEdit->toPlainText().isEmpty();
|
||||||
|
|
||||||
|
// update the estimate immediately if we know that the text box is empty...
|
||||||
|
if(!hasText){
|
||||||
|
updateFrameCountEstimate(0);
|
||||||
|
}
|
||||||
|
|
||||||
ui->cqMacroButton->setDisabled(isTransmitting);
|
ui->cqMacroButton->setDisabled(isTransmitting);
|
||||||
ui->replyMacroButton->setDisabled(isTransmitting || emptyCallsign);
|
ui->replyMacroButton->setDisabled(isTransmitting || emptyCallsign);
|
||||||
@ -8731,20 +8737,24 @@ void MainWindow::updateButtonDisplay(){
|
|||||||
int count = m_txFrameCount;
|
int count = m_txFrameCount;
|
||||||
int sent = count - m_txFrameQueue.count();
|
int sent = count - m_txFrameQueue.count();
|
||||||
ui->startTxButton->setText(m_tune ? "Tuning" : QString("Sending (%1/%2)").arg(sent).arg(count));
|
ui->startTxButton->setText(m_tune ? "Tuning" : QString("Sending (%1/%2)").arg(sent).arg(count));
|
||||||
} else if(m_txTextDirty && (m_txTextDirtyLastText != ui->extFreeTextMsgEdit->toPlainText() || m_txTextDirtyLastSelectedCall != selectedCallsign)){
|
} else {
|
||||||
|
ui->startTxButton->setText(m_txFrameCountEstimate <= 0 ? QString("Send") : QString("Send (%1)").arg(m_txFrameCountEstimate));
|
||||||
|
ui->startTxButton->setEnabled(m_txFrameCountEstimate > 0 && ensureSelcalCallsignSelected(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// schedule count update
|
||||||
|
if(hasText && m_txTextDirty && (m_txTextDirtyLastText != ui->extFreeTextMsgEdit->toPlainText() || m_txTextDirtyLastSelectedCall != selectedCallsign)){
|
||||||
|
|
||||||
if(m_txTextDirtyDebounce.isActive()){
|
if(m_txTextDirtyDebounce.isActive()){
|
||||||
m_txTextDirtyDebounce.stop();
|
m_txTextDirtyDebounce.stop();
|
||||||
}
|
}
|
||||||
m_txTextDirtyDebounce.start(100);
|
m_txTextDirtyDebounce.start(100);
|
||||||
m_txTextDirty = false;
|
m_txTextDirty = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::buildMessageFramesAndUpdateCountDisplay(){
|
void MainWindow::buildMessageFramesAndUpdateCountDisplay(){
|
||||||
qDebug() << "buildMessageFramesAndUpdateCountDisplay";
|
|
||||||
|
|
||||||
auto text = ui->extFreeTextMsgEdit->toPlainText();
|
auto text = ui->extFreeTextMsgEdit->toPlainText();
|
||||||
m_txTextDirtyLastText = text;
|
m_txTextDirtyLastText = text;
|
||||||
|
|
||||||
@ -8780,26 +8790,26 @@ void MainWindow::buildMessageFramesAndUpdateCountDisplay(){
|
|||||||
text.append(dt.message());
|
text.append(dt.message());
|
||||||
}
|
}
|
||||||
|
|
||||||
updateFrameCountDisplay(text.join(""), frames.length());
|
updateFrameCountEstimate(frames.length());
|
||||||
|
updateTextStatsDisplay(text.join(""), frames.length());
|
||||||
|
|
||||||
});
|
});
|
||||||
t->start();
|
t->start();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updateFrameCountDisplay(QString text, int count){
|
void MainWindow::updateFrameCountEstimate(int count){
|
||||||
if(count > 0){
|
m_txFrameCountEstimate = count;
|
||||||
ui->startTxButton->setText(QString("Send (%1)").arg(count));
|
}
|
||||||
ui->startTxButton->setEnabled(ensureSelcalCallsignSelected(false));
|
|
||||||
|
|
||||||
|
void MainWindow::updateTextStatsDisplay(QString text, int count){
|
||||||
|
if(count > 0){
|
||||||
auto words = text.split(" ", QString::SkipEmptyParts).length();
|
auto words = text.split(" ", QString::SkipEmptyParts).length();
|
||||||
auto wpm = QString::number(words/(count/4.0), 'f', 1);
|
auto wpm = QString::number(words/(count/4.0), 'f', 1);
|
||||||
auto cpm = QString::number(text.length()/(count/4.0), 'f', 1);
|
auto cpm = QString::number(text.length()/(count/4.0), 'f', 1);
|
||||||
wpm_label.setText(QString("%1wpm / %2cpm").arg(wpm).arg(cpm));
|
wpm_label.setText(QString("%1wpm / %2cpm").arg(wpm).arg(cpm));
|
||||||
wpm_label.setVisible(true);
|
wpm_label.setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
ui->startTxButton->setText("Send");
|
|
||||||
ui->startTxButton->setEnabled(false);
|
|
||||||
wpm_label.setVisible(false);
|
wpm_label.setVisible(false);
|
||||||
wpm_label.clear();
|
wpm_label.clear();
|
||||||
}
|
}
|
||||||
|
@ -728,6 +728,7 @@ private:
|
|||||||
|
|
||||||
bool m_rxDirty;
|
bool m_rxDirty;
|
||||||
bool m_rxDisplayDirty;
|
bool m_rxDisplayDirty;
|
||||||
|
int m_txFrameCountEstimate;
|
||||||
int m_txFrameCount;
|
int m_txFrameCount;
|
||||||
QTimer m_txTextDirtyDebounce;
|
QTimer m_txTextDirtyDebounce;
|
||||||
bool m_txTextDirty;
|
bool m_txTextDirty;
|
||||||
@ -882,7 +883,8 @@ private:
|
|||||||
void postDecode (bool is_new, QString const& message);
|
void postDecode (bool is_new, QString const& message);
|
||||||
void displayTransmit();
|
void displayTransmit();
|
||||||
void updateButtonDisplay();
|
void updateButtonDisplay();
|
||||||
void updateFrameCountDisplay(QString text, int count);
|
void updateFrameCountEstimate(int count);
|
||||||
|
void updateTextStatsDisplay(QString text, int count);
|
||||||
bool isMyCallIncluded(QString const &text);
|
bool isMyCallIncluded(QString const &text);
|
||||||
bool isAllCallIncluded(QString const &text);
|
bool isAllCallIncluded(QString const &text);
|
||||||
QString callsignSelected(bool useInputText=false);
|
QString callsignSelected(bool useInputText=false);
|
||||||
|
Loading…
Reference in New Issue
Block a user