From a902475f0159ed84d3b4ae7558ad6718de3dc75f Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Wed, 6 Jan 2016 17:24:17 +0000 Subject: [PATCH] Add facility to reset split mode when closing a rig connection This option defaults to on but may be unchecked in settings. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6359 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- Configuration.cpp | 14 +++++++++++--- Configuration.ui | 31 ++++++++++++++++++------------- EmulateSplitTransceiver.hpp | 2 +- Transceiver.hpp | 2 +- TransceiverBase.cpp | 8 +++++++- TransceiverBase.hpp | 2 +- 6 files changed, 39 insertions(+), 20 deletions(-) diff --git a/Configuration.cpp b/Configuration.cpp index 74caa6548..644257f7e 100644 --- a/Configuration.cpp +++ b/Configuration.cpp @@ -61,7 +61,7 @@ // need be carried out since the UI control data models are used as // the temporary store of unconfirmed settings. As some settings will // depend on each other a validate() operation is available, this -// operations implements a check of any complex multi-field values. +// operation implements a check of any complex multi-field values. // // 4) If the user discards the settings changes by dismissing the UI // with the "Cancel" button; the reject() operation is called. The @@ -424,7 +424,7 @@ private: // typenames used as arguments must match registered type names :( Q_SIGNAL void start_transceiver () const; - Q_SIGNAL void stop_transceiver () const; + Q_SIGNAL void stop_transceiver (bool reset_split) const; Q_SIGNAL void frequency (Frequency rx, Transceiver::MODE) const; Q_SIGNAL void tx_frequency (Frequency tx, bool rationalize_mode) const; Q_SIGNAL void mode (Transceiver::MODE, bool rationalize) const; @@ -504,6 +504,7 @@ private: // no split. bool enforce_mode_and_split_; + bool reset_split_; // configuration fields that we publish QString my_callsign_; @@ -1081,6 +1082,7 @@ void Configuration::impl::initialize_models () ui_->rig_combo_box->setCurrentText (rig_params_.rig_name); ui_->TX_mode_button_group->button (data_mode_)->setChecked (true); ui_->split_mode_button_group->button (rig_params_.split_mode)->setChecked (true); + ui_->reset_split_check_box->setChecked (reset_split_); ui_->CAT_serial_baud_combo_box->setCurrentText (QString::number (rig_params_.baud)); ui_->CAT_data_bits_button_group->button (rig_params_.data_bits)->setChecked (true); ui_->CAT_stop_bits_button_group->button (rig_params_.stop_bits)->setChecked (true); @@ -1305,6 +1307,7 @@ void Configuration::impl::read_settings () offsetRxFreq_ = settings_->value("OffsetRx",false).toBool(); rig_params_.poll_interval = settings_->value ("Polling", 0).toInt (); rig_params_.split_mode = settings_->value ("SplitMode", QVariant::fromValue (TransceiverFactory::split_mode_none)).value (); + reset_split_ = settings_->value ("ResetSplitOnExit", true).toBool (); udp_server_name_ = settings_->value ("UDPServer", "127.0.0.1").toString (); udp_server_port_ = settings_->value ("UDPServerPort", 2237).toUInt (); accept_udp_requests_ = settings_->value ("AcceptUDPRequests", false).toBool (); @@ -1391,6 +1394,7 @@ void Configuration::impl::write_settings () settings_->setValue ("TXAudioSource", QVariant::fromValue (rig_params_.audio_source)); settings_->setValue ("Polling", rig_params_.poll_interval); settings_->setValue ("SplitMode", QVariant::fromValue (rig_params_.split_mode)); + settings_->setValue ("ResetSplitOnExit", reset_split_); settings_->setValue ("VHFUHF", enable_VHF_features_); settings_->setValue ("Decode52", decode_at_52s_); settings_->setValue ("TwoPass", twoPass_); @@ -1528,6 +1532,8 @@ void Configuration::impl::set_rig_invariants () && (cat_port != ptt_port || !ui_->PTT_RTS_radio_button->isEnabled () || !ui_->PTT_RTS_radio_button->isChecked ())); + ui_->reset_split_check_box->setEnabled (TransceiverFactory::split_mode_rig + == static_cast (ui_->split_mode_button_group->checkedId ())); } } @@ -1788,6 +1794,7 @@ void Configuration::impl::accept () NDxG_ = ui_->cbNDxG->isChecked (); NN_ = ui_->cbNN->isChecked (); EMEonly_ = ui_->cbEMEonly->isChecked (); + reset_split_ = ui_->reset_split_check_box->isChecked (); offsetRxFreq_ = ui_->offset_Rx_freq_check_box->isChecked(); frequency_calibration_intercept_ = ui_->calibration_intercept_spin_box->value (); @@ -1977,6 +1984,7 @@ void Configuration::impl::on_split_mode_button_group_buttonClicked (int /* id */ { setup_split_ = true; required_tx_frequency_ = 0; + set_rig_invariants (); } void Configuration::impl::on_test_CAT_push_button_clicked () @@ -2458,7 +2466,7 @@ void Configuration::impl::close_rig () if (rig_active_) { ui_->test_CAT_push_button->setStyleSheet ("QPushButton {background-color: red;}"); - Q_EMIT stop_transceiver (); + Q_EMIT stop_transceiver (reset_split_); Q_FOREACH (auto const& connection, rig_connections_) { disconnect (connection); diff --git a/Configuration.ui b/Configuration.ui index 32a998478..1155cb92b 100644 --- a/Configuration.ui +++ b/Configuration.ui @@ -2,14 +2,6 @@ configuration_dialog - - - 0 - 0 - 670 - 564 - - Settings @@ -1161,6 +1153,19 @@ radio interface behave as expected. + + + + <html><head/><body><p>Reset split on program exit</p></body></html> + + + Reset split on exit + + + true + + + @@ -2491,12 +2496,12 @@ soundcard changes - - - - - + + + + + diff --git a/EmulateSplitTransceiver.hpp b/EmulateSplitTransceiver.hpp index d08887154..1e35e7424 100644 --- a/EmulateSplitTransceiver.hpp +++ b/EmulateSplitTransceiver.hpp @@ -37,7 +37,7 @@ public: void ptt (bool on) noexcept override; // forward everything else to wrapped Transceiver - void stop () noexcept override {wrapped_->stop (); Q_EMIT finished ();} + void stop (bool /* reset_split */) noexcept override {wrapped_->stop (false); Q_EMIT finished ();} void mode (MODE m, bool /* rationalise */) noexcept override {wrapped_->mode (m, false);} void sync (bool force_signal) noexcept override {wrapped_->sync (force_signal);} diff --git a/Transceiver.hpp b/Transceiver.hpp index 983d596d6..067608d44 100644 --- a/Transceiver.hpp +++ b/Transceiver.hpp @@ -122,7 +122,7 @@ public: // Connect and disconnect. Q_SLOT virtual void start () noexcept = 0; - Q_SLOT virtual void stop () noexcept = 0; + Q_SLOT virtual void stop (bool reset_split = false) noexcept = 0; // Set frequency in Hertz. Q_SLOT virtual void frequency (Frequency, MODE = UNK) noexcept = 0; diff --git a/TransceiverBase.cpp b/TransceiverBase.cpp index 74e5d98a5..fc1d5f09a 100644 --- a/TransceiverBase.cpp +++ b/TransceiverBase.cpp @@ -52,7 +52,7 @@ void TransceiverBase::start () noexcept } } -void TransceiverBase::stop () noexcept +void TransceiverBase::stop (bool reset_split) noexcept { QString message; try @@ -64,6 +64,12 @@ void TransceiverBase::stop () noexcept // try and ensure PTT isn't left set do_ptt (false); do_post_ptt (false); + if (reset_split) + { + // try and reset split mode + do_tx_frequency (0, false); + do_post_tx_frequency (0, false); + } } catch (...) { diff --git a/TransceiverBase.hpp b/TransceiverBase.hpp index 673736380..578c012ac 100644 --- a/TransceiverBase.hpp +++ b/TransceiverBase.hpp @@ -68,7 +68,7 @@ public: // Implement the Transceiver abstract interface. // void start () noexcept override final; - void stop () noexcept override final; + void stop (bool reset_split = false) noexcept override final; void frequency (Frequency rx, MODE = UNK) noexcept override final; void tx_frequency (Frequency tx, bool rationalise_mode) noexcept override final; void mode (MODE, bool rationalise) noexcept override final;