From 28df33b2182be25a6b1ada7456e9cd47d7a645a7 Mon Sep 17 00:00:00 2001 From: Jordan Sherer Date: Sun, 15 Jul 2018 11:00:57 -0400 Subject: [PATCH] Better parsing of selected callsign. Blur edit box while transmitting --- mainwindow.cpp | 26 ++++++++++++++++++++++++-- mainwindow.h | 1 + mainwindow.ui | 5 +++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 94733be..ad1292c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -4115,6 +4115,7 @@ void MainWindow::startTx() // disallow editing of the text while transmitting ui->extFreeTextMsgEdit->setReadOnly(true); + update_dynamic_property(ui->extFreeTextMsgEdit, "transmitting", true); } void MainWindow::startTx2() @@ -4165,6 +4166,7 @@ void MainWindow::stopTx() } else { // TODO: jsherer - split this up... ui->extFreeTextMsgEdit->setReadOnly(false); + update_dynamic_property(ui->extFreeTextMsgEdit, "transmitting", false); on_stopTxButton_clicked(); } @@ -6889,7 +6891,6 @@ void MainWindow::on_tableWidgetCalls_cellDoubleClicked(int row, int col){ addMessageText(call); } - void MainWindow::on_tableWidgetCalls_selectionChanged(const QItemSelection &selected, const QItemSelection &deselected){ on_tableWidgetRXAll_selectionChanged(selected, deselected); @@ -7793,7 +7794,8 @@ void MainWindow::displayTransmit(){ } void MainWindow::updateButtonDisplay(){ - if(ui->tableWidgetRXAll->selectedItems().isEmpty() && ui->tableWidgetCalls->selectedItems().isEmpty()){ + QString callsign = callsignSelected(); + if(callsign.isEmpty()){ ui->replyMacroButton->setDisabled(true); ui->snrMacroButton->setDisabled(true); ui->queryButton->setDisabled(true); @@ -7804,6 +7806,26 @@ void MainWindow::updateButtonDisplay(){ } } +QString MainWindow::callsignSelected(){ + if(!ui->tableWidgetCalls->selectedItems().isEmpty()){ + auto selectedCalls = ui->tableWidgetCalls->selectedItems(); + return selectedCalls.first()->text(); + } + + if(!ui->tableWidgetRXAll->selectedItems().isEmpty()){ + int selectedOffset = -1; + auto selectedItems = ui->tableWidgetRXAll->selectedItems(); + selectedOffset = selectedItems.first()->text().toInt(); + foreach(auto call, m_callActivity.keys()){ + if(m_callActivity[call].freq == selectedOffset){ + return call; + } + } + } + + return QString(); +} + bool MainWindow::isRecentOffset(int offset){ return ( m_rxRecentCache.contains(offset/10*10) && diff --git a/mainwindow.h b/mainwindow.h index 4a6d2e3..0404b91 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -757,6 +757,7 @@ private: void displayTransmit(); void updateButtonDisplay(); bool isMyCallIncluded(QString const &text); + QString callsignSelected(); bool isRecentOffset(int offset); bool isDirectedOffset(int offset); void displayActivity(bool force=false); diff --git a/mainwindow.ui b/mainwindow.ui index 26093a2..eab8440 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -956,6 +956,11 @@ background-color: yellow; QTextEdit[readOnly="true"] { background:#EEE; font-style:italic; +} + +QTextEdit[transmitting="true"] { + background:#EEE; + font-style:italic; }