Turn off counting to start...

This commit is contained in:
Jordan Sherer 2018-10-05 18:40:56 -04:00
parent cfa93839df
commit 0e82edc9ea
2 changed files with 59 additions and 23 deletions

View File

@ -1409,7 +1409,7 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
*/ */
m_txTextDirtyDebounce.setSingleShot(true); m_txTextDirtyDebounce.setSingleShot(true);
connect(&m_txTextDirtyDebounce, &QTimer::timeout, this, &MainWindow::buildMessageFramesAndUpdateCountDisplay); connect(&m_txTextDirtyDebounce, &QTimer::timeout, this, &MainWindow::refreshTextDisplay);
QTimer::singleShot(0, this, &MainWindow::initializeDummyData); QTimer::singleShot(0, this, &MainWindow::initializeDummyData);
@ -6160,6 +6160,10 @@ bool MainWindow::prepareNextMessageFrame()
QString frame = popMessageFrame(); QString frame = popMessageFrame();
if(frame.isEmpty()){ if(frame.isEmpty()){
ui->nextFreeTextMsg->clear(); ui->nextFreeTextMsg->clear();
// TODO: jsherer - this button thing is duplicated in two places :(
ui->startTxButton->setText(QString("Send"));
return false; return false;
} else { } else {
ui->nextFreeTextMsg->setText(frame); ui->nextFreeTextMsg->setText(frame);
@ -6174,6 +6178,7 @@ bool MainWindow::prepareNextMessageFrame()
m_i3bit |= Varicode::JS8CallLast; m_i3bit |= Varicode::JS8CallLast;
} }
// TODO: jsherer - this button thing is duplicated in two places :(
ui->startTxButton->setText(QString("Sending (%1/%2)").arg(sent).arg(count)); ui->startTxButton->setText(QString("Sending (%1/%2)").arg(sent).arg(count));
if(ui->beaconButton->isChecked()){ if(ui->beaconButton->isChecked()){
@ -8710,18 +8715,15 @@ void MainWindow::displayTransmit(){
} }
void MainWindow::updateButtonDisplay(){ void MainWindow::updateButtonDisplay(){
// Transmit Activity
update_dynamic_property (ui->startTxButton, "transmitting", m_transmitting);
bool isTransmitting = m_transmitting || m_txFrameCount > 0; bool isTransmitting = m_transmitting || m_txFrameCount > 0;
// Transmit Activity
update_dynamic_property (ui->startTxButton, "transmitting", isTransmitting);
auto selectedCallsign = callsignSelected(true); auto selectedCallsign = callsignSelected(true);
bool emptyCallsign = selectedCallsign.isEmpty(); bool emptyCallsign = selectedCallsign.isEmpty();
bool hasText = !ui->extFreeTextMsgEdit->toPlainText().isEmpty(); bool emptyText = ui->extFreeTextMsgEdit->toPlainText().isEmpty();
bool invalidSelcal = !ensureSelcalCallsignSelected(false);
// 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,19 +8733,44 @@ void MainWindow::updateButtonDisplay(){
ui->queryButton->setDisabled(isTransmitting || emptyCallsign); ui->queryButton->setDisabled(isTransmitting || emptyCallsign);
ui->deselectButton->setDisabled(isTransmitting || emptyCallsign); ui->deselectButton->setDisabled(isTransmitting || emptyCallsign);
ui->queryButton->setText(emptyCallsign ? "Directed" : QString("Directed to %1").arg(selectedCallsign)); ui->queryButton->setText(emptyCallsign ? "Directed" : QString("Directed to %1").arg(selectedCallsign));
ui->startTxButton->setDisabled(ui->selcalButton->isChecked() && emptyCallsign); ui->startTxButton->setDisabled(isTransmitting || emptyText || invalidSelcal);
#if 0
// update transmit button
if(isTransmitting){ if(isTransmitting){
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));
ui->startTxButton->setEnabled(false);
} else { } else {
if(ui->extFreeTextMsgEdit->toPlainText().isEmpty()){
m_txFrameCountEstimate = 0;
}
ui->startTxButton->setText(m_txFrameCountEstimate <= 0 ? QString("Send") : QString("Send (%1)").arg(m_txFrameCountEstimate)); ui->startTxButton->setText(m_txFrameCountEstimate <= 0 ? QString("Send") : QString("Send (%1)").arg(m_txFrameCountEstimate));
ui->startTxButton->setEnabled(m_txFrameCountEstimate > 0 && ensureSelcalCallsignSelected(false)); ui->startTxButton->setEnabled(m_txFrameCountEstimate > 0 && ensureSelcalCallsignSelected(false));
} }
// debounce frame and word count
if(m_txTextDirtyDebounce.isActive()){
m_txTextDirtyDebounce.stop();
}
m_txTextDirtyDebounce.start(150);
#endif
// schedule count update #if 0
auto text = ui->extFreeTextMsgEdit->toPlainText();
bool hasText = !text.isEmpty();
// update the estimate immediately if we know that the text box is empty...
if(hasText){
countMessageFrames(text);
} else {
updateFrameCountEstimate(0);
}
#endif
#if 0
// schedule word count update
if(hasText && m_txTextDirty && (m_txTextDirtyLastText != ui->extFreeTextMsgEdit->toPlainText() || m_txTextDirtyLastSelectedCall != selectedCallsign)){ if(hasText && m_txTextDirty && (m_txTextDirtyLastText != ui->extFreeTextMsgEdit->toPlainText() || m_txTextDirtyLastSelectedCall != selectedCallsign)){
if(m_txTextDirtyDebounce.isActive()){ if(m_txTextDirtyDebounce.isActive()){
@ -8752,15 +8779,28 @@ void MainWindow::updateButtonDisplay(){
m_txTextDirtyDebounce.start(100); m_txTextDirtyDebounce.start(100);
m_txTextDirty = false; m_txTextDirty = false;
} }
#endif
} }
void MainWindow::buildMessageFramesAndUpdateCountDisplay(){ #define USE_SYNC_FRAME_COUNT 1
void MainWindow::refreshTextDisplay(){
auto text = ui->extFreeTextMsgEdit->toPlainText(); auto text = ui->extFreeTextMsgEdit->toPlainText();
m_txTextDirtyLastText = text; m_txTextDirtyLastText = text;
#if USE_SYNC_FRAME_COUNT #if USE_SYNC_FRAME_COUNT
int count = countMessageFrames(text); auto frames = buildMessageFrames(text);
updateFrameCountDisplay(text, count);
QStringList textList;
qDebug() << "frames:";
foreach(auto frame, frames){
auto dt = DecodedText(frame);
qDebug() << "->" << frame << dt.message() << Varicode::frameTypeString(dt.frameType());
textList.append(dt.message());
}
updateTextStatsDisplay(textList.join(""), m_txFrameCountEstimate);
m_txFrameCountEstimate = frames.length();
#else #else
// prepare selected callsign for directed message // prepare selected callsign for directed message
QString selectedCall = callsignSelected(); QString selectedCall = callsignSelected();
@ -8782,26 +8822,22 @@ void MainWindow::buildMessageFramesAndUpdateCountDisplay(){
connect(t, &BuildMessageFramesThread::finished, t, &QObject::deleteLater); connect(t, &BuildMessageFramesThread::finished, t, &QObject::deleteLater);
connect(t, &BuildMessageFramesThread::resultReady, this, [this](const QStringList frames){ connect(t, &BuildMessageFramesThread::resultReady, this, [this](const QStringList frames){
QStringList text; QStringList textList;
qDebug() << "frames:"; qDebug() << "frames:";
foreach(auto frame, frames){ foreach(auto frame, frames){
auto dt = DecodedText(frame); auto dt = DecodedText(frame);
qDebug() << "->" << frame << dt.message() << Varicode::frameTypeString(dt.frameType()); qDebug() << "->" << frame << dt.message() << Varicode::frameTypeString(dt.frameType());
text.append(dt.message()); textList.append(dt.message());
} }
updateFrameCountEstimate(frames.length()); updateFrameCountEstimate(frames.length());
updateTextStatsDisplay(text.join(""), frames.length()); updateTextStatsDisplay(textList.join(""), frames.length());
}); });
t->start(); t->start();
#endif #endif
} }
void MainWindow::updateFrameCountEstimate(int count){
m_txFrameCountEstimate = count;
}
void MainWindow::updateTextStatsDisplay(QString text, int count){ void MainWindow::updateTextStatsDisplay(QString text, int count){
if(count > 0){ if(count > 0){
auto words = text.split(" ", QString::SkipEmptyParts).length(); auto words = text.split(" ", QString::SkipEmptyParts).length();

View File

@ -385,7 +385,7 @@ private slots:
void expiry_warning_message (); void expiry_warning_message ();
void not_GA_warning_message (); void not_GA_warning_message ();
void clearCallsignSelected(); void clearCallsignSelected();
void buildMessageFramesAndUpdateCountDisplay(); void refreshTextDisplay();
private: private:
Q_SIGNAL void initializeAudioOutputStream (QAudioDeviceInfo, Q_SIGNAL void initializeAudioOutputStream (QAudioDeviceInfo,