diff --git a/Configuration.cpp b/Configuration.cpp index 4980b3e..27644b4 100644 --- a/Configuration.cpp +++ b/Configuration.cpp @@ -629,6 +629,7 @@ private: qint32 RxBandwidth_; double degrade_; double txDelay_; + bool reset_activity_; bool check_for_updates_; bool id_after_73_; bool tx_qsy_allowed_; @@ -753,6 +754,7 @@ qint32 Configuration::aggressive() const {return m_->aggressive_;} double Configuration::degrade() const {return m_->degrade_;} double Configuration::txDelay() const {return m_->txDelay_;} qint32 Configuration::RxBandwidth() const {return m_->RxBandwidth_;} +bool Configuration::reset_activity() const { return m_->reset_activity_;} bool Configuration::check_for_updates() const { return m_->check_for_updates_; } bool Configuration::id_after_73 () const {return m_->id_after_73_;} bool Configuration::tx_qsy_allowed () const {return m_->tx_qsy_allowed_;} @@ -1432,6 +1434,7 @@ void Configuration::impl::initialize_models () ui_->sound_cq_path_display_label->setText(sound_cq_path_); ui_->sound_dm_path_display_label->setText(sound_dm_path_); ui_->sound_am_path_display_label->setText(sound_am_path_); + ui_->reset_activity_check_box->setChecked (reset_activity_); ui_->checkForUpdates_checkBox->setChecked (check_for_updates_); ui_->CW_id_after_73_check_box->setChecked (id_after_73_); ui_->tx_qsy_check_box->setChecked (tx_qsy_allowed_); @@ -1716,6 +1719,7 @@ void Configuration::impl::read_settings () monitor_off_at_startup_ = settings_->value ("MonitorOFF", false).toBool (); monitor_last_used_ = settings_->value ("MonitorLastUsed", false).toBool (); spot_to_reporting_networks_ = settings_->value ("PSKReporter", true).toBool (); + reset_activity_ = settings_->value("ResetActivity", false).toBool(); check_for_updates_ = settings_->value("CheckForUpdates", true).toBool(); id_after_73_ = settings_->value ("After73", false).toBool (); tx_qsy_allowed_ = settings_->value ("TxQSYAllowed", false).toBool (); @@ -1895,6 +1899,7 @@ void Configuration::impl::write_settings () settings_->setValue ("MonitorOFF", monitor_off_at_startup_); settings_->setValue ("MonitorLastUsed", monitor_last_used_); settings_->setValue ("PSKReporter", spot_to_reporting_networks_); + settings_->setValue ("ResetActivity", reset_activity_); settings_->setValue ("CheckForUpdates", check_for_updates_); settings_->setValue ("After73", id_after_73_); settings_->setValue ("TxQSYAllowed", tx_qsy_allowed_); @@ -2439,6 +2444,7 @@ void Configuration::impl::accept () aggressive_ = ui_->sbAggressive->value (); degrade_ = ui_->sbDegrade->value (); RxBandwidth_ = ui_->sbBandwidth->value (); + reset_activity_ = ui_->reset_activity_check_box->isChecked(); check_for_updates_ = ui_->checkForUpdates_checkBox->isChecked(); id_after_73_ = ui_->CW_id_after_73_check_box->isChecked (); tx_qsy_allowed_ = ui_->tx_qsy_check_box->isChecked (); diff --git a/Configuration.hpp b/Configuration.hpp index d2eeac1..8ccc39a 100644 --- a/Configuration.hpp +++ b/Configuration.hpp @@ -119,6 +119,7 @@ public: qint32 RxBandwidth() const; double degrade() const; double txDelay() const; + bool reset_activity() const; bool check_for_updates() const; bool id_after_73 () const; bool tx_qsy_allowed () const; diff --git a/Configuration.ui b/Configuration.ui index d8b0ff9..8675d77 100644 --- a/Configuration.ui +++ b/Configuration.ui @@ -36,7 +36,7 @@ - 0 + 1 @@ -279,7 +279,7 @@ 0 0 724 - 779 + 808 @@ -401,6 +401,13 @@ + + + + Reset the Band Activity, Call Activity, and RX history at startup + + + diff --git a/mainwindow.cpp b/mainwindow.cpp index 9fc7900..a9fed69 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -392,6 +392,7 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, m_multi_settings {multi_settings}, m_configurations_button {0}, m_settings {multi_settings->settings ()}, + m_settings_read {false}, ui(new Ui::MainWindow), m_config {temp_directory, m_settings, this}, m_WSPR_band_hopping {m_settings, &m_config, this}, @@ -1651,7 +1652,7 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, m_txTextDirtyDebounce.setSingleShot(true); connect(&m_txTextDirtyDebounce, &QTimer::timeout, this, &MainWindow::refreshTextDisplay); - QTimer::singleShot(0, this, &MainWindow::initializeDummyData); + QTimer::singleShot(500, this, &MainWindow::initializeDummyData); // this must be the last statement of constructor if (!m_valid) throw std::runtime_error {"Fatal initialization exception"}; @@ -2190,8 +2191,7 @@ void MainWindow::readSettings() ui->actionShow_Tooltips->setChecked(m_settings->value("ShowTooltips", true).toBool()); ui->actionShow_Statusbar->setChecked(m_settings->value("ShowStatusbar",true).toBool()); ui->statusBar->setVisible(ui->actionShow_Statusbar->isChecked()); - ui->textEditRX->setHtml(m_settings->value("RXActivity", "").toString()); - + ui->textEditRX->setHtml(m_config.reset_activity() ? "" : m_settings->value("RXActivity", "").toString()); m_settings->endGroup(); // do this outside of settings group because it uses groups internally @@ -2288,41 +2288,47 @@ void MainWindow::readSettings() m_audioThreadPriority = static_cast (m_settings->value ("Audio/ThreadPriority", QThread::HighPriority).toInt () % 8); m_settings->endGroup (); - m_settings->beginGroup("CallActivity"); - foreach(auto call, m_settings->allKeys()){ + if(m_config.reset_activity()){ + // NOOP + } else { + m_settings->beginGroup("CallActivity"); + foreach(auto call, m_settings->allKeys()){ - auto values = m_settings->value(call).toMap(); + auto values = m_settings->value(call).toMap(); - auto snr = values.value("snr", -64).toInt(); - auto grid = values.value("grid", "").toString(); - auto freq = values.value("freq", 0).toInt(); + auto snr = values.value("snr", -64).toInt(); + auto grid = values.value("grid", "").toString(); + auto freq = values.value("freq", 0).toInt(); #if CACHE_CALL_DATETIME_AS_STRINGS - auto ackTimestampStr = values.value("ackTimestamp", "").toString(); - auto ackTimestamp = QDateTime::fromString(ackTimestampStr, "yyyy-MM-dd hh:mm:ss"); - ackTimestamp.setUtcOffset(0); + auto ackTimestampStr = values.value("ackTimestamp", "").toString(); + auto ackTimestamp = QDateTime::fromString(ackTimestampStr, "yyyy-MM-dd hh:mm:ss"); + ackTimestamp.setUtcOffset(0); - auto utcTimestampStr = values.value("utcTimestamp", "").toString(); - auto utcTimestamp = QDateTime::fromString(utcTimestampStr, "yyyy-MM-dd hh:mm:ss"); - utcTimestamp.setUtcOffset(0); + auto utcTimestampStr = values.value("utcTimestamp", "").toString(); + auto utcTimestamp = QDateTime::fromString(utcTimestampStr, "yyyy-MM-dd hh:mm:ss"); + utcTimestamp.setUtcOffset(0); #else - auto ackTimestamp = values.value("ackTimestamp").toDateTime(); - auto utcTimestamp = values.value("utcTimestamp").toDateTime(); + auto ackTimestamp = values.value("ackTimestamp").toDateTime(); + auto utcTimestamp = values.value("utcTimestamp").toDateTime(); #endif - CallDetail cd = {}; - cd.call = call; - cd.snr = snr; - cd.grid = grid; - cd.freq = freq; - cd.ackTimestamp = ackTimestamp; - cd.utcTimestamp = utcTimestamp; + CallDetail cd = {}; + cd.call = call; + cd.snr = snr; + cd.grid = grid; + cd.freq = freq; + cd.ackTimestamp = ackTimestamp; + cd.utcTimestamp = utcTimestamp; - logCallActivity(cd, false); + logCallActivity(cd, false); + } + m_settings->endGroup(); } - m_settings->endGroup(); if (displayMsgAvg) on_actionMessage_averaging_triggered(); + + m_settings_read = true; } void MainWindow::set_application_font (QFont const& font) @@ -3228,6 +3234,38 @@ Radio::Frequency MainWindow::dialFrequency() { m_rigState.tx_frequency () : m_rigState.frequency ()}; } +void MainWindow::updateCurrentBand(){ + QVariant state = ui->readFreq->property("state"); + if(!state.isValid()){ + return; + } + + auto dial_frequency = dialFrequency(); + auto const& band_name = m_config.bands ()->find(dial_frequency); + + if (m_lastBand == band_name){ + return; + } + + cacheActivity(m_lastBand); + + // clear activity on startup if asked or on when the previous band is not empty + if(m_config.reset_activity() || !m_lastBand.isEmpty()){ + clearActivity(); + } + + // only change this when necessary as we get called a lot and it + // would trash any user input to the band combo box line edit + ui->bandComboBox->setCurrentText (band_name); + m_wideGraph->setRxBand (band_name); + + qDebug() << "setting band" << band_name; + m_lastBand = band_name; + + band_changed(dial_frequency); + restoreActivity(m_lastBand); +} + void MainWindow::displayDialFrequency (){ #if 0 qDebug() << "rx nominal" << m_freqNominal; @@ -3240,48 +3278,6 @@ void MainWindow::displayDialFrequency (){ // lookup band auto const& band_name = m_config.bands ()->find (dial_frequency); - if (m_lastBand != band_name){ - cacheActivity(m_lastBand); - - // don't clear activity on startup - if(!m_lastBand.isEmpty()){ - clearActivity(); - } - - // only change this when necessary as we get called a lot and it - // would trash any user input to the band combo box line edit - ui->bandComboBox->setCurrentText (band_name); - m_wideGraph->setRxBand (band_name); - m_lastBand = band_name; - band_changed(dial_frequency); - - restoreActivity(m_lastBand); - } - - // TODO: jsherer - this doesn't validate anything else right? we are disabling this because as long as you're in a band, it's valid. - /* - // search working frequencies for one we are within 10kHz of (1 Mhz - // of on VHF and up) - bool valid {false}; - quint64 min_offset {99999999}; - for (auto const& item : *m_config.frequencies ()) - { - // we need to do specific checks for above and below here to - // ensure that we can use unsigned Radio::Frequency since we - // potentially use the full 64-bit unsigned range. - auto const& working_frequency = item.frequency_; - auto const& offset = dial_frequency > working_frequency ? - dial_frequency - working_frequency : - working_frequency - dial_frequency; - if (offset < min_offset) { - min_offset = offset; - } - } - if (min_offset < 10000u || (m_config.enable_VHF_features() && min_offset < 1000000u)) { - valid = true; - } - */ - bool valid = !band_name.isEmpty(); update_dynamic_property (ui->labDialFreq, "oob", !valid); @@ -5874,6 +5870,7 @@ void MainWindow::restoreActivity(QString key){ } void MainWindow::clearActivity(){ + qDebug() << "clear activity"; m_bandActivity.clear(); m_callActivity.clear(); m_callSeenHeartbeat.clear(); @@ -8871,6 +8868,7 @@ void MainWindow::handle_transceiver_update (Transceiver::TransceiverState const& m_tx_when_ready = false; } m_rigState = s; + auto old_freqNominal = m_freqNominal; if (!old_freqNominal) { @@ -8878,6 +8876,7 @@ void MainWindow::handle_transceiver_update (Transceiver::TransceiverState const& // with bogus Tx frequencies m_freqNominal = s.frequency (); } + if (old_state.online () == false && s.online () == true) { // initializing @@ -8885,6 +8884,7 @@ void MainWindow::handle_transceiver_update (Transceiver::TransceiverState const& ui->autoReplyButton->setChecked(!m_config.autoreply_off_at_startup()); } + if (s.frequency () != old_state.frequency () || s.split () != m_splitMode) { m_splitMode = s.split (); @@ -8943,6 +8943,7 @@ void MainWindow::handle_transceiver_update (Transceiver::TransceiverState const& // ensure frequency display is correct if (m_astroWidget && old_state.ptt () != s.ptt ()) setRig (); + updateCurrentBand(); displayDialFrequency (); update_dynamic_property (ui->readFreq, "state", "ok"); ui->readFreq->setEnabled (false); diff --git a/mainwindow.h b/mainwindow.h index 8c3c7dd..5981af2 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -462,6 +462,7 @@ private: MultiSettings * m_multi_settings; QPushButton * m_configurations_button; QSettings * m_settings; + bool m_settings_read; QScopedPointer ui; // other windows @@ -940,6 +941,7 @@ private: void pskLogReport(QString mode, int offset, int snr, QString callsign, QString grid); void aprsLogReport(int offset, int snr, QString callsign, QString grid); Radio::Frequency dialFrequency(); + void updateCurrentBand(); void displayDialFrequency (); void transmitDisplay (bool); void locationChange(QString const& location);