summaryrefslogtreecommitdiff
path: root/mainwindow.cpp
diff options
context:
space:
mode:
authorIain R. Learmonth <irl@debian.org>2015-10-18 18:51:00 +0100
committerIain R. Learmonth <irl@debian.org>2015-10-18 18:51:00 +0100
commitd63dd8d081a6fcd0715cd13f26df59fb831769d2 (patch)
treeb9c1f6245147a310aac3762630bad389bbb57335 /mainwindow.cpp
parentc720a3d55c5ec832c29cb7ce50b6fb4b70c55b11 (diff)
Imported Upstream version 1.5.0upstream/1.5.0
Diffstat (limited to 'mainwindow.cpp')
-rw-r--r--mainwindow.cpp3995
1 files changed, 2195 insertions, 1800 deletions
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 7b50ec82..e1f6a70f 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -1,60 +1,233 @@
-//------------------------------------------------------------- MainWindow
+//-------------------------------------------------------- MainWindow
+
#include "mainwindow.h"
-#include "ui_mainwindow.h"
-#include "devsetup.h"
+
+#include <cinttypes>
+#include <limits>
+
+#include <QThread>
+#include <QLineEdit>
+#include <QRegExpValidator>
+#include <QRegExp>
+#include <QDesktopServices>
+#include <QUrl>
+#include <QStandardPaths>
+#include <QDir>
+#include <QDebug>
+#include <QtConcurrent/QtConcurrentRun>
+#include <QProgressDialog>
+#include <QHostInfo>
+
+#include "revision_utils.hpp"
+#include "soundout.h"
#include "plotter.h"
#include "about.h"
+#include "astro.h"
#include "widegraph.h"
#include "sleep.h"
#include "getfile.h"
-#include <portaudio.h>
#include "logqso.h"
+#include "Radio.hpp"
+#include "Bands.hpp"
+#include "TransceiverFactory.hpp"
+#include "FrequencyList.hpp"
+#include "StationList.hpp"
+#include "LiveFrequencyValidator.hpp"
+#include "FrequencyItemDelegate.hpp"
+#include "MessageClient.hpp"
-#ifdef QT5
-#include <QtConcurrent/QtConcurrentMap>
-#include <QtConcurrent/QtConcurrentRun>
-#endif
+#include "ui_mainwindow.h"
+#include "moc_mainwindow.cpp"
+
+int volatile itone[NUM_JT65_SYMBOLS]; //Audio tones for all Tx symbols
+int volatile icw[NUM_CW_SYMBOLS]; //Dits for CW ID
-int itone[126]; //Audio tones for all Tx symbols
-int icw[250]; //Dits for CW ID
int outBufSize;
int rc;
-qint32 g_COMportOpen;
qint32 g_iptt;
-static int nc1=1;
wchar_t buffer[256];
-bool btxok; //True if OK to transmit
-bool btxMute;
-double outputLatency; //Latency in seconds
-double dFreq[]={0.13613,0.4742,1.838,3.576,5.357,7.076,10.138,14.076,
- 18.102,21.076,24.917,28.076,50.276,70.091,144.489,432.178};
-
-WideGraph* g_pWideGraph = NULL;
-LogQSO* logDlg = NULL;
-Rig* rig = NULL;
-QTextEdit* pShortcuts;
-QTcpSocket* socket = new QTcpSocket(0);
-
-QString rev="$Rev: 3496 $";
-QString Program_Title_Version=" WSJT-X v1.1, r" + rev.mid(6,4) +
- " by K1JT";
-
-//-------------------------------------------------- MainWindow constructor
-// Multiple instances: new arg *thekey
-MainWindow::MainWindow(QSharedMemory *shdmem, QString *thekey, QWidget *parent) :
+
+
+namespace
+{
+ Radio::Frequency constexpr default_frequency {14076000};
+ QRegExp message_alphabet {"[- A-Za-z0-9+./?]*"};
+
+ bool message_is_73 (int type, QStringList const& msg_parts)
+ {
+ return type >= 0
+ && ((type < 6 && msg_parts.contains ("73"))
+ || (type == 6 && !msg_parts.filter ("73").isEmpty ()));
+ }
+}
+
+class BandAndFrequencyItemDelegate final
+ : public QStyledItemDelegate
+{
+public:
+ explicit BandAndFrequencyItemDelegate (Bands const * bands, QObject * parent = nullptr)
+ : QStyledItemDelegate {parent}
+ , bands_ {bands}
+ {
+ }
+
+ QString displayText (QVariant const& v, QLocale const&) const override
+ {
+ return Radio::pretty_frequency_MHz_string (Radio::frequency (v, 6))
+ + QChar::Nbsp
+ + '(' + (bands_->data (bands_->find (Radio::frequency (v, 6)))).toString () + ')';
+ }
+
+private:
+ Bands const * bands_;
+};
+
+//--------------------------------------------------- MainWindow constructor
+MainWindow::MainWindow(bool multiple, QSettings * settings, QSharedMemory *shdmem,
+ unsigned downSampleFactor, QWidget *parent) :
QMainWindow(parent),
- ui(new Ui::MainWindow)
+ m_dataDir {QStandardPaths::writableLocation (QStandardPaths::DataLocation)},
+ m_revision {revision ()},
+ m_multiple {multiple},
+ m_settings (settings),
+ ui(new Ui::MainWindow),
+ m_config (settings, this),
+ m_wideGraph (new WideGraph (settings)),
+ m_logDlg (new LogQSO (program_title (), settings, this)),
+ m_dialFreq {std::numeric_limits<Radio::Frequency>::max ()},
+ m_detector (RX_SAMPLE_RATE, NTMAX / 2, 6912 / 2, downSampleFactor),
+ m_modulator (TX_SAMPLE_RATE, NTMAX / 2),
+ m_audioThread {new QThread},
+ m_diskData {false},
+ m_sentFirst73 {false},
+ m_currentMessageType {-1},
+ m_lastMessageType {-1},
+ m_appDir {QApplication::applicationDirPath ()},
+ mem_jt9 {shdmem},
+ m_msAudioOutputBuffered (0u),
+ m_framesAudioInputBuffered (RX_SAMPLE_RATE / 10),
+ m_downSampleFactor (downSampleFactor),
+ m_audioThreadPriority (QThread::HighPriority),
+ m_bandEdited {false},
+ m_splitMode {false},
+ m_monitoring {false},
+ m_transmitting {false},
+ m_tune {false},
+ m_lastMonitoredFrequency {default_frequency},
+ m_toneSpacing {0.},
+ m_firstDecode {0},
+ m_optimizingProgress {"Optimizing decoder FFTs for your CPU.\n"
+ "Please be patient,\n"
+ "this may take a few minutes", QString {}, 0, 1, this},
+ m_messageClient {new MessageClient {QApplication::applicationName (), m_config.udp_server_name (), m_config.udp_server_port (), this}},
+ psk_Reporter {new PSK_Reporter {m_messageClient, this}}
{
ui->setupUi(this);
- on_EraseButton_clicked();
- QActionGroup* paletteGroup = new QActionGroup(this);
- ui->actionCuteSDR->setActionGroup(paletteGroup);
- ui->actionLinrad->setActionGroup(paletteGroup);
- ui->actionAFMHot->setActionGroup(paletteGroup);
- ui->actionBlue->setActionGroup(paletteGroup);
+
+ m_optimizingProgress.setWindowModality (Qt::WindowModal);
+ m_optimizingProgress.setAutoReset (false);
+ m_optimizingProgress.setMinimumDuration (15000); // only show after 15s delay
+
+ // Closedown.
+ connect (ui->actionExit, &QAction::triggered, this, &QMainWindow::close);
+
+ // parts of the rig error message box that are fixed
+ m_rigErrorMessageBox.setInformativeText (tr ("Do you want to reconfigure the radio interface?"));
+ m_rigErrorMessageBox.setStandardButtons (QMessageBox::Cancel | QMessageBox::Ok | QMessageBox::Retry);
+ m_rigErrorMessageBox.setDefaultButton (QMessageBox::Ok);
+ m_rigErrorMessageBox.setIcon (QMessageBox::Critical);
+
+ // start audio thread and hook up slots & signals for shutdown management
+ // these objects need to be in the audio thread so that invoking
+ // their slots is done in a thread safe way
+ m_soundOutput.moveToThread (m_audioThread);
+ m_modulator.moveToThread (m_audioThread);
+ m_soundInput.moveToThread (m_audioThread);
+ m_detector.moveToThread (m_audioThread);
+
+ connect (this, &MainWindow::finished, m_audioThread, &QThread::quit); // quit thread event loop
+ connect (m_audioThread, &QThread::finished, m_audioThread, &QThread::deleteLater); // disposal
+
+ // hook up sound output stream slots & signals
+ connect (this, &MainWindow::initializeAudioOutputStream, &m_soundOutput, &SoundOutput::setFormat);
+ connect (&m_soundOutput, &SoundOutput::error, this, &MainWindow::showSoundOutError);
+ // connect (&m_soundOutput, &SoundOutput::status, this, &MainWindow::showStatusMessage);
+ connect (this, &MainWindow::outAttenuationChanged, &m_soundOutput, &SoundOutput::setAttenuation);
+
+ // hook up Modulator slots
+ connect (this, &MainWindow::transmitFrequency, &m_modulator, &Modulator::setFrequency);
+ connect (this, &MainWindow::endTransmitMessage, &m_modulator, &Modulator::stop);
+ connect (this, &MainWindow::tune, &m_modulator, &Modulator::tune);
+ connect (this, &MainWindow::sendMessage, &m_modulator, &Modulator::start);
+
+ // hook up the audio input stream
+ connect (this, &MainWindow::startAudioInputStream, &m_soundInput, &SoundInput::start);
+ connect (this, &MainWindow::suspendAudioInputStream, &m_soundInput, &SoundInput::suspend);
+ connect (this, &MainWindow::resumeAudioInputStream, &m_soundInput, &SoundInput::resume);
+ connect (this, &MainWindow::finished, &m_soundInput, &SoundInput::stop);
+
+ connect (this, &MainWindow::finished, this, &MainWindow::close);
+
+ connect(&m_soundInput, &SoundInput::error, this, &MainWindow::showSoundInError);
+ // connect(&m_soundInput, &SoundInput::status, this, &MainWindow::showStatusMessage);
+
+ // hook up the detector
+ connect(&m_detector, &Detector::framesWritten, this, &MainWindow::dataSink);
+
+ // setup the waterfall
+ connect(m_wideGraph.data (), SIGNAL(freezeDecode2(int)),this,
+ SLOT(freezeDecode(int)));
+ connect(m_wideGraph.data (), SIGNAL(f11f12(int)),this,
+ SLOT(bumpFqso(int)));
+ connect(m_wideGraph.data (), SIGNAL(setXIT2(int)),this,
+ SLOT(setXIT(int)));
+ // connect(m_wideGraph.data (), SIGNAL(dialFreqChanged(double)),this,
+ // SLOT(dialFreqChanged2(double)));
+ connect (this, &MainWindow::finished, m_wideGraph.data (), &WideGraph::close);
+
+
+ // setup the log QSO dialog
+ connect (m_logDlg.data (), &LogQSO::acceptQSO, this, &MainWindow::acceptQSO2);
+ connect (this, &MainWindow::finished, m_logDlg.data (), &LogQSO::close);
+
+ // Network message handlers
+ connect (m_messageClient, &MessageClient::reply, this, &MainWindow::replyToCQ);
+ connect (m_messageClient, &MessageClient::replay, this, &MainWindow::replayDecodes);
+ connect (m_messageClient, &MessageClient::halt_tx, [this] (bool auto_only) {
+ if (m_config.accept_udp_requests ()) {
+ if (auto_only) {
+ if (ui->autoButton->isChecked ()) {
+ ui->autoButton->click ();
+ }
+ } else {
+ ui->stopTxButton->click();
+ }
+ }
+ });
+ connect (m_messageClient, &MessageClient::error, this, &MainWindow::networkError);
+ connect (m_messageClient, &MessageClient::free_text, [this] (QString const& text, bool send) {
+ if (m_config.accept_udp_requests ()) {
+ if (0 == ui->tabWidget->currentIndex ()) {
+ ui->tx5->setCurrentText (text);
+ if (send) {
+ ui->txb5->click ();
+ } else {
+ ui->txrb5->click ();
+ }
+ } else if (1 == ui->tabWidget->currentIndex ()) {
+ ui->freeTextMsg->setCurrentText (text);
+ if (send) {
+ ui->rbFreeText->click ();
+ }
+ }
+ }
+ });
+
+ on_EraseButton_clicked ();
QActionGroup* modeGroup = new QActionGroup(this);
ui->actionJT9_1->setActionGroup(modeGroup);
+ ui->actionJT9W_1->setActionGroup(modeGroup);
ui->actionJT65->setActionGroup(modeGroup);
ui->actionJT9_JT65->setActionGroup(modeGroup);
@@ -82,77 +255,108 @@ MainWindow::MainWindow(QSharedMemory *shdmem, QString *thekey, QWidget *parent)
connect(ui->decodedTextBrowser,SIGNAL(selectCallsign(bool,bool)),this,
SLOT(doubleClickOnCall2(bool,bool)));
- setWindowTitle(Program_Title_Version);
- connect(&soundInThread, SIGNAL(readyForFFT(int)),
- this, SLOT(dataSink(int)));
- connect(&soundInThread, SIGNAL(error(QString)), this,
- SLOT(showSoundInError(QString)));
- connect(&soundInThread, SIGNAL(status(QString)), this,
- SLOT(showStatusMessage(QString)));
+ // initialise decoded text font and hook up change signal
+ setDecodedTextFont (m_config.decoded_text_font ());
+ connect (&m_config, &Configuration::decoded_text_font_changed, [this] (QFont const& font) {
+ setDecodedTextFont (font);
+ });
+
+ setWindowTitle (program_title ());
createStatusBar();
connect(&proc_jt9, SIGNAL(readyReadStandardOutput()),
- this, SLOT(readFromStdout()));
+ this, SLOT(readFromStdout()));
connect(&proc_jt9, SIGNAL(error(QProcess::ProcessError)),
- this, SLOT(jt9_error()));
+ this, SLOT(jt9_error(QProcess::ProcessError)));
connect(&proc_jt9, SIGNAL(readyReadStandardError()),
this, SLOT(readFromStderr()));
- ui->bandComboBox->setEditable(true);
- ui->bandComboBox->lineEdit()->setReadOnly(true);
- ui->bandComboBox->lineEdit()->setAlignment(Qt::AlignCenter);
- for(int i = 0; i < ui->bandComboBox->count(); i++)
- ui->bandComboBox->setItemData(i, Qt::AlignCenter, Qt::TextAlignmentRole);
-
- ui->tx5->setContextMenuPolicy(Qt::CustomContextMenu);
- connect(ui->tx5, SIGNAL(customContextMenuRequested(const QPoint&)),
- this, SLOT(showMacros(const QPoint&)));
-
- ui->freeTextMsg->setContextMenuPolicy(Qt::CustomContextMenu);
- connect(ui->freeTextMsg, SIGNAL(customContextMenuRequested(const QPoint&)),
- this, SLOT(showMacros(const QPoint&)));
+ // Hook up working frequencies.
+ ui->bandComboBox->setModel (m_config.frequencies ());
+ ui->bandComboBox->setModelColumn (1); // MHz
+
+ // Add delegate to show bands alongside frequencies in combo box
+ // popup list.
+ ui->bandComboBox->view ()->setItemDelegateForColumn (1, new BandAndFrequencyItemDelegate {m_config.bands (), this});
+
+ // combo box drop downs are limited to the drop down selector width,
+ // this almost random increase improves the situation
+ ui->bandComboBox->view ()->setMinimumWidth (ui->bandComboBox->view ()->sizeHintForColumn (1) + 40);
+
+ // Enable live band combo box entry validation and action.
+ auto band_validator = new LiveFrequencyValidator {ui->bandComboBox
+ , m_config.bands ()
+ , m_config.frequencies ()
+ , this};
+ ui->bandComboBox->setValidator (band_validator);
+
+ // Hook up signals.
+ connect (band_validator, &LiveFrequencyValidator::valid, this, &MainWindow::band_changed);
+ connect (ui->bandComboBox->lineEdit (), &QLineEdit::textEdited, [this] (QString const&) {m_bandEdited = true;});
+
+ // hook up configuration signals
+ connect (&m_config, &Configuration::transceiver_update, this, &MainWindow::handle_transceiver_update);
+ connect (&m_config, &Configuration::transceiver_failure, this, &MainWindow::handle_transceiver_failure);
+ connect (&m_config, &Configuration::udp_server_changed, m_messageClient, &MessageClient::set_server);
+ connect (&m_config, &Configuration::udp_server_port_changed, m_messageClient, &MessageClient::set_server_port);
+
+ // set up message text validators
+ ui->tx1->setValidator (new QRegExpValidator {message_alphabet, this});
+ ui->tx2->setValidator (new QRegExpValidator {message_alphabet, this});
+ ui->tx3->setValidator (new QRegExpValidator {message_alphabet, this});
+ ui->tx4->setValidator (new QRegExpValidator {message_alphabet, this});
+ ui->tx5->setValidator (new QRegExpValidator {message_alphabet, this});
+ ui->tx6->setValidator (new QRegExpValidator {message_alphabet, this});
+ ui->freeTextMsg->setValidator (new QRegExpValidator {message_alphabet, this});
+
+ // Free text macros model to widget hook up.
+ ui->tx5->setModel (m_config.macros ());
+ connect (ui->tx5->lineEdit ()
+ , &QLineEdit::editingFinished
+ , [this] () {on_tx5_currentTextChanged (ui->tx5->lineEdit ()->text ());});
+ ui->freeTextMsg->setModel (m_config.macros ());
+ connect (ui->freeTextMsg->lineEdit ()
+ , &QLineEdit::editingFinished
+ , [this] () {on_freeTextMsg_currentTextChanged (ui->freeTextMsg->lineEdit ()->text ());});
+
+ auto font = ui->readFreq->font();
+ font.setFamily("helvetica");
+ font.setPointSize(9);
+ font.setWeight(75);
+ ui->readFreq->setFont(font);
+
+ connect(&m_guiTimer, &QTimer::timeout, this, &MainWindow::guiUpdate);
+ m_guiTimer.start(100); //Don't change the 100 ms!
- QTimer *guiTimer = new QTimer(this);
- connect(guiTimer, SIGNAL(timeout()), this, SLOT(guiUpdate()));
- guiTimer->start(100); //Don't change the 100 ms!
ptt0Timer = new QTimer(this);
ptt0Timer->setSingleShot(true);
- connect(ptt0Timer, SIGNAL(timeout()), this, SLOT(stopTx2()));
+ connect(ptt0Timer, &QTimer::timeout, this, &MainWindow::stopTx2);
ptt1Timer = new QTimer(this);
ptt1Timer->setSingleShot(true);
- connect(ptt1Timer, SIGNAL(timeout()), this, SLOT(startTx2()));
+ connect(ptt1Timer, &QTimer::timeout, this, &MainWindow::startTx2);
logQSOTimer = new QTimer(this);
logQSOTimer->setSingleShot(true);
- connect(logQSOTimer, SIGNAL(timeout()), this, SLOT(on_logQSOButton_clicked()));
+ connect(logQSOTimer, &QTimer::timeout, this, &MainWindow::on_logQSOButton_clicked);
tuneButtonTimer= new QTimer(this);
tuneButtonTimer->setSingleShot(true);
- connect(tuneButtonTimer, SIGNAL(timeout()), this,
- SLOT(on_stopTxButton_clicked()));
+ connect(tuneButtonTimer, &QTimer::timeout, this, &MainWindow::on_stopTxButton_clicked);
killFileTimer = new QTimer(this);
killFileTimer->setSingleShot(true);
- connect(killFileTimer, SIGNAL(timeout()), this, SLOT(killFile()));
+ connect(killFileTimer, &QTimer::timeout, this, &MainWindow::killFile);
m_auto=false;
m_waterfallAvg = 1;
m_txFirst=false;
- btxMute=false;
- btxok=false;
+ m_btxok=false;
m_restart=false;
- m_transmitting=false;
m_killAll=false;
m_widebandDecode=false;
m_ntx=1;
- m_myCall="";
- m_myGrid="FN20qi";
- m_appDir = QApplication::applicationDirPath();
- m_saveDir="/users/joe/wsjtx/install/save";
- m_rxFreq=1500;
- m_txFreq=1500;
m_setftx=0;
m_loopall=false;
m_startAnother=false;
@@ -168,101 +372,109 @@ MainWindow::MainWindow(QSharedMemory *shdmem, QString *thekey, QWidget *parent)
m_inGain=0;
m_dataAvailable=false;
g_iptt=0;
- g_COMportOpen=0;
m_secID=0;
- m_promptToLog=false;
m_blankLine=false;
- m_insertBlank=false;
- m_clearCallGrid=false;
- m_bMiles=false;
m_decodedText2=false;
m_freeText=false;
m_msErase=0;
- m_sent73=false;
- m_watchdogLimit=5;
- m_tune=false;
+ m_watchdogLimit=7;
m_repeatMsg=0;
- m_bRigOpen=false;
m_secBandChanged=0;
- m_bMultipleOK=false;
- m_dontReadFreq=false;
m_lockTxFreq=false;
+ m_baseCall = Radio::base_callsign (m_config.my_callsign ());
+
ui->readFreq->setEnabled(false);
- m_QSOmsg="";
- m_CATerror=false;
+ m_QSOText.clear();
decodeBusy(false);
signalMeter = new SignalMeter(ui->meterFrame);
signalMeter->resize(50, 160);
-// qDebug() << signalMeter->size();
-
ui->labAz->setStyleSheet("border: 0px;");
ui->labDist->setStyleSheet("border: 0px;");
- mem_jt9 = shdmem;
-// Multiple instances:
- mykey_jt9 = thekey;
- readSettings(); //Restore user's setup params
- if(m_dFreq.length()<=1) { //Use the startup default frequencies
- m_dFreq.clear();
- for(int i=0; i<16; i++) {
- QString t;
- t.sprintf("%f",dFreq[i]);
- m_dFreq.append(t);
- }
- }
+ readSettings(); //Restore user's setup params
+
+ // start the audio thread
+ m_audioThread->start (m_audioThreadPriority);
#ifdef WIN32
- if(!m_bMultipleOK) {
- while(true) {
- int iret=killbyname("jt9.exe");
- if(iret == 603) break;
- if(iret != 0) msgBox("KillByName return code: " +
- QString::number(iret));
+ if (!m_multiple)
+ {
+ while(true)
+ {
+ int iret=killbyname("jt9.exe");
+ if(iret == 603) break;
+ if(iret != 0) msgBox("KillByName return code: " +
+ QString::number(iret));
+ }
}
- }
#endif
- QFile lockFile(m_appDir + "/.lock"); //Create .lock so jt9 will wait
- lockFile.open(QIODevice::ReadWrite);
- //QFile quitFile(m_appDir + "/.lock");
- //quitFile.remove();
-
-// Multiple instances: make the Qstring key into command line arg
-// Multiple instances: start "jt9 -s <thekey>"
- QByteArray ba = mykey_jt9->toLocal8Bit();
- const char *bc = ba.data();
- proc_jt9.start(QDir::toNativeSeparators('"' + m_appDir + '"' + "/jt9 -s " + bc));
-
- m_pbdecoding_style1="QPushButton{background-color: cyan; \
- border-style: outset; border-width: 1px; border-radius: 5px; \
- border-color: black; min-width: 5em; padding: 3px;}";
- m_pbmonitor_style="QPushButton{background-color: #00ff00; \
- border-style: outset; border-width: 1px; border-radius: 5px; \
- border-color: black; min-width: 5em; padding: 3px;}";
- m_pbAutoOn_style="QPushButton{background-color: red; \
- border-style: outset; border-width: 1px; border-radius: 5px; \
- border-color: black; min-width: 5em; padding: 3px;}";
- m_pbTune_style="QPushButton{background-color: red; \
- border-style: outset; border-width: 1px; border-radius: 5px; \
- border-color: black; min-width: 5em; padding: 3px;}";
+ auto_tx_label->setText (m_config.quick_call () ? "Tx-Enable Armed" : "Tx-Enable Disarmed");
+
+ {
+ //delete any .quit file that might have been left lying around
+ //since its presence will cause jt9 to exit a soon as we start it
+ //and decodes will hang
+ QFile quitFile {m_config.temp_dir ().absoluteFilePath (".quit")};
+ while (quitFile.exists ())
+ {
+ if (!quitFile.remove ())
+ {
+ msgBox ("Error removing \"" + quitFile.fileName () +
+ "\" - OK to retry.");
+ }
+ }
+ }
+
+ //Create .lock so jt9 will wait
+ QFile {m_config.temp_dir ().absoluteFilePath (".lock")}.open(QIODevice::ReadWrite);
+
+ QStringList jt9_args {
+ "-s", QApplication::applicationName () // shared memory key,
+ // includes rig-name
+#ifdef NDEBUG
+ , "-w", "2" //FFTW patience - release
+#else
+ , "-w", "1" //FFTW patience - debug builds for speed
+#endif
+ // The number of threads for FFTW specified here is chosen as
+ // three because that gives the best throughput of the large
+ // FFTs used in jt9. The count is the minimum of (the number
+ // available CPU threads less one) and three. This ensures that
+ // there is always at least one free CPU thread to run the other
+ // mode decoder in parallel.
+ , "-m", QString::number (qMin (qMax (QThread::idealThreadCount () - 1, 1), 3)) //FFTW threads
+
+ , "-e", QDir::toNativeSeparators (m_appDir)
+ , "-a", QDir::toNativeSeparators (m_dataDir.absolutePath ())
+ , "-t", QDir::toNativeSeparators (m_config.temp_dir ().absolutePath ())
+ };
+ proc_jt9.start(QDir::toNativeSeparators (m_appDir) + QDir::separator () +
+ "jt9", jt9_args, QIODevice::ReadWrite | QIODevice::Unbuffered);
+
+ QString fname {QDir::toNativeSeparators(m_dataDir.absoluteFilePath ("wsjtx_wisdom.dat"))};
+ QByteArray cfname=fname.toLocal8Bit();
+ fftwf_import_wisdom_from_filename(cfname);
+
+ getpfx(); //Load the prefix/suffix dictionary
genStdMsgs(m_rpt);
- if(m_mode!="JT9" and m_mode!="JT65" and m_mode!="JT9+JT65") m_mode="JT9";
+ m_ntx=6;
+ ui->txrb6->setChecked(true);
+ if(m_mode!="JT9" and m_mode!="JT9W-1" and m_mode!="JT65" and
+ m_mode!="JT9+JT65") m_mode="JT9";
on_actionWide_Waterfall_triggered(); //###
- g_pWideGraph->setRxFreq(m_rxFreq);
- g_pWideGraph->setTxFreq(m_txFreq);
- g_pWideGraph->setLockTxFreq(m_lockTxFreq);
- g_pWideGraph->setFmin(m_fMin);
- g_pWideGraph->setModeTx(m_mode);
- g_pWideGraph->setModeTx(m_modeTx);
- dialFreqChanged2(m_dialFreq);
-
- connect(g_pWideGraph, SIGNAL(setFreq3(int,int)),this,
+ m_wideGraph->setLockTxFreq(m_lockTxFreq);
+ m_wideGraph->setModeTx(m_mode);
+ m_wideGraph->setModeTx(m_modeTx);
+
+ connect(m_wideGraph.data (), SIGNAL(setFreq3(int,int)),this,
SLOT(setFreq4(int,int)));
if(m_mode=="JT9") on_actionJT9_1_triggered();
+ if(m_mode=="JT9W-1") on_actionJT9W_1_triggered();
if(m_mode=="JT65") on_actionJT65_triggered();
if(m_mode=="JT9+JT65") on_actionJT9_JT65_triggered();
@@ -274,347 +486,146 @@ MainWindow::MainWindow(QSharedMemory *shdmem, QString *thekey, QWidget *parent)
watcher2 = new QFutureWatcher<void>;
connect(watcher2, SIGNAL(finished()),this,SLOT(diskWriteFinished()));
- soundInThread.setInputDevice(m_paInDevice);
- soundInThread.start(QThread::HighestPriority);
- soundOutThread.setOutputDevice(m_paOutDevice);
- soundOutThread.setTxFreq(m_txFreq);
- soundOutThread.setTune(false);
- m_monitoring=!m_monitorStartOFF; // Start with Monitoring ON/OFF
- soundInThread.setMonitoring(m_monitoring);
- m_diskData=false;
-
-// Create "m_worked", a dictionary of all calls in wsjtx.log
- QFile f("wsjtx.log");
- f.open(QIODevice::ReadOnly | QIODevice::Text);
- QTextStream in(&f);
- QString line,t,callsign;
- for(int i=0; i<99999; i++) {
- line=in.readLine();
- if(line.length()<=0) break;
- t=line.mid(18,12);
- callsign=t.mid(0,t.indexOf(","));
- }
- f.close();
+ Q_EMIT startAudioInputStream (m_config.audio_input_device (), m_framesAudioInputBuffered, &m_detector, m_downSampleFactor, m_config.audio_input_channel ());
+ Q_EMIT initializeAudioOutputStream (m_config.audio_output_device (), AudioDevice::Mono == m_config.audio_output_channel () ? 1 : 2, m_msAudioOutputBuffered);
- if(ui->actionLinrad->isChecked()) on_actionLinrad_triggered();
- if(ui->actionCuteSDR->isChecked()) on_actionCuteSDR_triggered();
- if(ui->actionAFMHot->isChecked()) on_actionAFMHot_triggered();
- if(ui->actionBlue->isChecked()) on_actionBlue_triggered();
+ Q_EMIT transmitFrequency (ui->TxFreqSpinBox->value () - m_XIT);
- ui->decodedTextLabel->setFont(ui->decodedTextBrowser2->font());
- ui->decodedTextLabel2->setFont(ui->decodedTextBrowser->font());
- t="UTC dB DT Freq Message";
+ auto t = "UTC dB DT Freq Message";
ui->decodedTextLabel->setText(t);
ui->decodedTextLabel2->setText(t);
-#ifdef WIN32
- if(m_pskReporter) {
- rc=ReporterInitialize(NULL,NULL);
- if(rc==0) {
- m_pskReporterInit=true;
- } else {
- m_pskReporterInit=false;
- rc=ReporterGetInformation(buffer,256);
- msgBox(QString::fromStdWString(buffer));
- }
- }
-#endif
-
-#ifdef UNIX
- psk_Reporter = new PSK_Reporter(this);
- psk_Reporter->setLocalStation(m_myCall,m_myGrid, "WSJT-X r" + rev.mid(6,4) );
-#endif
+ enable_DXCC_entity (m_config.DXCC ()); // sets text window proportions and (re)inits the logbook
ui->label_9->setStyleSheet("QLabel{background-color: #aabec8}");
ui->label_10->setStyleSheet("QLabel{background-color: #aabec8}");
- ui->labUTC->setStyleSheet( \
- "QLabel { background-color : black; color : yellow; }");
- ui->labDialFreq->setStyleSheet( \
- "QLabel { background-color : black; color : yellow; }");
-
- QFile f2("ALL.TXT");
- f2.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append);
- QTextStream out(&f2);
- out << QDateTime::currentDateTimeUtc().toString("yyyy-MMM-dd hh:mm")
- << " " << m_dialFreq << " MHz " << m_mode << endl;
- f2.close();
-} // End of MainWindow constructor
+
+ m_config.transceiver_online (true);
+ on_monitorButton_clicked (!m_config.monitor_off_at_startup ());
+
+#if !WSJT_ENABLE_EXPERIMENTAL_FEATURES
+ ui->actionJT9W_1->setEnabled (false);
+#endif
+}
//--------------------------------------------------- MainWindow destructor
MainWindow::~MainWindow()
{
- writeSettings();
- if (soundInThread.isRunning()) {
- soundInThread.quit();
- soundInThread.wait(3000);
- }
- if (soundOutThread.isRunning()) {
- soundOutThread.quitExecution=true;
- soundOutThread.wait(3000);
- }
- if(!m_decoderBusy) {
- QFile lockFile(m_appDir + "/.lock");
- lockFile.remove();
- }
- delete ui;
+ QString fname {QDir::toNativeSeparators(m_dataDir.absoluteFilePath ("wsjtx_wisdom.dat"))};
+ QByteArray cfname=fname.toLocal8Bit();
+ fftwf_export_wisdom_to_filename(cfname);
+ m_audioThread->wait ();
+ delete ui, ui = 0;
}
//-------------------------------------------------------- writeSettings()
void MainWindow::writeSettings()
{
- QString inifile = m_appDir + "/wsjtx.ini";
- QSettings settings(inifile, QSettings::IniFormat);
-
- settings.beginGroup("MainWindow");
- settings.setValue("geometry", saveGeometry());
- settings.setValue("MRUdir", m_path);
- settings.setValue("TxFirst",m_txFirst);
- settings.setValue("DXcall",ui->dxCallEntry->text());
- settings.setValue("DXgrid",ui->dxGridEntry->text());
- if(g_pWideGraph->isVisible()) {
- m_wideGraphGeom = g_pWideGraph->geometry();
- settings.setValue("WideGraphGeom",m_wideGraphGeom);
- m_fMin=g_pWideGraph->getFmin();
- }
- settings.endGroup();
-
- settings.beginGroup("Common");
- settings.setValue("MyCall",m_myCall);
- settings.setValue("MyGrid",m_myGrid);
- settings.setValue("IDint",m_idInt);
- settings.setValue("PTTmethod",m_pttMethodIndex);
- settings.setValue("PTTport",m_pttPort);
- settings.setValue("SaveDir",m_saveDir);
- char soundName[128];
- if (Pa_GetDeviceInfo( m_paInDevice)) { // store name, number may be different next time
- snprintf( soundName, sizeof( soundName), "%s:%s",
- Pa_GetHostApiInfo( Pa_GetDeviceInfo( m_paInDevice)->hostApi)->name,
- Pa_GetDeviceInfo( m_paInDevice)->name);
- settings.setValue("SoundInName", soundName);
- }
- if (Pa_GetDeviceInfo( m_paOutDevice)) { // store name, number may be different next time
- snprintf( soundName, sizeof( soundName), "%s:%s",
- Pa_GetHostApiInfo( Pa_GetDeviceInfo( m_paOutDevice)->hostApi)->name,
- Pa_GetDeviceInfo( m_paOutDevice)->name);
- settings.setValue("SoundOutName", soundName);
- }
- settings.setValue("PaletteCuteSDR",ui->actionCuteSDR->isChecked());
- settings.setValue("PaletteLinrad",ui->actionLinrad->isChecked());
- settings.setValue("PaletteAFMHot",ui->actionAFMHot->isChecked());
- settings.setValue("PaletteBlue",ui->actionBlue->isChecked());
- settings.setValue("Mode",m_mode);
- settings.setValue("ModeTx",m_modeTx);
- settings.setValue("SaveNone",ui->actionNone->isChecked());
- settings.setValue("SaveDecoded",ui->actionSave_decoded->isChecked());
- settings.setValue("SaveAll",ui->actionSave_all->isChecked());
- settings.setValue("NDepth",m_ndepth);
- settings.setValue("MonitorOFF",m_monitorStartOFF);
- settings.setValue("DialFreq",m_dialFreq);
- settings.setValue("RxFreq",m_rxFreq);
- settings.setValue("TxFreq",m_txFreq);
- settings.setValue("InGain",m_inGain);
- settings.setValue("PSKReporter",m_pskReporter);
- settings.setValue("After73",m_After73);
- settings.setValue("Macros",m_macro);
- settings.setValue("DefaultFreqs",m_dFreq);
- settings.setValue("toRTTY",m_toRTTY);
- settings.setValue("NoSuffix",m_noSuffix);
- settings.setValue("dBtoComments",m_dBtoComments);
- settings.setValue("catEnabled",m_catEnabled);
- settings.setValue("Rig",m_rig);
- settings.setValue("RigIndex",m_rigIndex);
- settings.setValue("CATport",m_catPort);
- settings.setValue("CATportIndex",m_catPortIndex);
- settings.setValue("SerialRate",m_serialRate);
- settings.setValue("SerialRateIndex",m_serialRateIndex);
- settings.setValue("DataBits",m_dataBits);
- settings.setValue("DataBitsIndex",m_dataBitsIndex);
- settings.setValue("StopBits",m_stopBits);
- settings.setValue("StopBitsIndex",m_stopBitsIndex);
- settings.setValue("Handshake",m_handshake);
- settings.setValue("HandshakeIndex",m_handshakeIndex);
- settings.setValue("BandIndex",m_band);
- settings.setValue("PromptToLog",m_promptToLog);
- settings.setValue("InsertBlank",m_insertBlank);
- settings.setValue("ClearCallGrid",m_clearCallGrid);
- settings.setValue("Miles",m_bMiles);
- settings.setValue("GUItab",ui->tabWidget->currentIndex());
- settings.setValue("QuickCall",m_quickCall);
- settings.setValue("73TxDisable",m_73TxDisable);
- settings.setValue("Runaway",m_runaway);
- settings.setValue("Tx2QSO",m_tx2QSO);
- settings.setValue("MultipleOK",m_bMultipleOK);
- settings.setValue("DTRoff",m_bDTRoff);
- settings.setValue("pttData",m_pttData);
- settings.setValue("LogQSOgeom",m_logQSOgeom);
- settings.setValue("Polling",m_poll);
- settings.setValue("OutBufSize",outBufSize);
- settings.setValue("LockTxFreq",m_lockTxFreq);
- settings.setValue("SaveTxPower",m_saveTxPower);
- settings.setValue("SaveComments",m_saveComments);
- settings.setValue("TxPower",m_txPower);
- settings.setValue("LogComments",m_logComments);
- settings.setValue("PSKantenna",m_pskAntenna);
- settings.setValue("Fmin",m_fMin);
- settings.setValue("TxSplit",m_bSplit);
- settings.setValue("UseXIT",m_bXIT);
- settings.setValue("Plus2kHz",m_plus2kHz);
- settings.endGroup();
+ m_settings->beginGroup("MainWindow");
+ m_settings->setValue ("geometry", saveGeometry ());
+ m_settings->setValue ("state", saveState ());
+ m_settings->setValue("MRUdir", m_path);
+ m_settings->setValue("TxFirst",m_txFirst);
+ m_settings->setValue("DXcall",ui->dxCallEntry->text());
+ m_settings->setValue("DXgrid",ui->dxGridEntry->text());
+ m_settings->setValue ("AstroDisplayed", m_astroWidget && m_astroWidget->isVisible());
+ m_settings->setValue ("FreeText", ui->freeTextMsg->currentText ());
+ m_settings->endGroup();
+
+ m_settings->beginGroup("Common");
+ m_settings->setValue("Mode",m_mode);
+ m_settings->setValue("ModeTx",m_modeTx);
+ m_settings->setValue("SaveNone",ui->actionNone->isChecked());
+ m_settings->setValue("SaveDecoded",ui->actionSave_decoded->isChecked());
+ m_settings->setValue("SaveAll",ui->actionSave_all->isChecked());
+ m_settings->setValue("NDepth",m_ndepth);
+ m_settings->setValue("RxFreq",ui->RxFreqSpinBox->value ());
+ m_settings->setValue("TxFreq",ui->TxFreqSpinBox->value ());
+ m_settings->setValue ("DialFreq", QVariant::fromValue(m_lastMonitoredFrequency));
+ m_settings->setValue("InGain",m_inGain);
+ m_settings->setValue("OutAttenuation", ui->outAttenuation->value ());
+ m_settings->setValue("NoSuffix",m_noSuffix);
+ m_settings->setValue("GUItab",ui->tabWidget->currentIndex());
+ m_settings->setValue("OutBufSize",outBufSize);
+ m_settings->setValue("LockTxFreq",m_lockTxFreq);
+ m_settings->setValue("Plus2kHz",m_plus2kHz);
+
+ m_settings->endGroup();
}
//---------------------------------------------------------- readSettings()
void MainWindow::readSettings()
{
- QString inifile = m_appDir + "/wsjtx.ini";
- QSettings settings(inifile, QSettings::IniFormat);
- settings.beginGroup("MainWindow");
- restoreGeometry(settings.value("geometry").toByteArray());
- ui->dxCallEntry->setText(settings.value("DXcall","").toString());
- ui->dxGridEntry->setText(settings.value("DXgrid","").toString());
- m_wideGraphGeom = settings.value("WideGraphGeom", \
- QRect(45,30,726,301)).toRect();
- m_path = settings.value("MRUdir", m_appDir + "/save").toString();
- m_txFirst = settings.value("TxFirst",false).toBool();
+ m_settings->beginGroup("MainWindow");
+ restoreGeometry (m_settings->value ("geometry", saveGeometry ()).toByteArray ());
+ restoreState (m_settings->value ("state", saveState ()).toByteArray ());
+ ui->dxCallEntry->setText(m_settings->value("DXcall","").toString());
+ ui->dxGridEntry->setText(m_settings->value("DXgrid","").toString());
+ m_path = m_settings->value("MRUdir", m_config.save_directory ().absolutePath ()).toString ();
+ m_txFirst = m_settings->value("TxFirst",false).toBool();
ui->txFirstCheckBox->setChecked(m_txFirst);
- settings.endGroup();
-
- settings.beginGroup("Common");
- m_myCall=settings.value("MyCall","").toString();
- morse_(m_myCall.toLatin1().data(),icw,&m_ncw,m_myCall.length());
- m_myGrid=settings.value("MyGrid","").toString();
- m_idInt=settings.value("IDint",0).toInt();
- m_pttMethodIndex=settings.value("PTTmethod",1).toInt();
- m_pttPort=settings.value("PTTport",0).toInt();
- m_saveDir=settings.value("SaveDir",m_appDir + "/save").toString();
-
- char soundName[128];
- QString savedName = settings.value( "SoundInName", "default").toString();
- for (m_paInDevice = Pa_GetDeviceCount() - 1; m_paInDevice >= 0; m_paInDevice--) {
- snprintf( soundName, sizeof( soundName), "%s:%s",
- Pa_GetHostApiInfo( Pa_GetDeviceInfo( m_paInDevice)->hostApi)->name,
- Pa_GetDeviceInfo( m_paInDevice)->name);
- if ((savedName == soundName) && (Pa_GetDeviceInfo(m_paInDevice)->maxInputChannels > 0))
- break;
- }
- if (m_paInDevice < 0) { // no match for device name?
- m_paInDevice = Pa_GetDefaultInputDevice();
- if (m_paInDevice == paNoDevice) // no default input device?
- m_paInDevice = 0;
- }
+ auto displayAstro = m_settings->value ("AstroDisplayed", false).toBool ();
- savedName = settings.value("SoundOutName", "default").toString();
- for (m_paOutDevice = Pa_GetDeviceCount() - 1; m_paOutDevice >= 0; m_paOutDevice--) {
- snprintf( soundName, sizeof( soundName), "%s:%s",
- Pa_GetHostApiInfo( Pa_GetDeviceInfo( m_paOutDevice)->hostApi)->name,
- Pa_GetDeviceInfo( m_paOutDevice)->name);
- if ((savedName == soundName) && (Pa_GetDeviceInfo(m_paOutDevice)->maxOutputChannels > 0))
- break;
- }
- if (m_paOutDevice < 0) { // no match for device name?
- m_paOutDevice = Pa_GetDefaultOutputDevice();
- if (m_paOutDevice == paNoDevice) // no default output device?
- m_paOutDevice = 0;
+ if (m_settings->contains ("FreeText"))
+ {
+ ui->freeTextMsg->setCurrentText (m_settings->value ("FreeText").toString ());
}
- ui->actionCuteSDR->setChecked(settings.value(
- "PaletteCuteSDR",false).toBool());
- ui->actionLinrad->setChecked(settings.value(
- "PaletteLinrad",true).toBool());
- ui->actionAFMHot->setChecked(settings.value(
- "PaletteAFMHot",false).toBool());
- ui->actionBlue->setChecked(settings.value(
- "PaletteBlue",false).toBool());
- m_mode=settings.value("Mode","JT9").toString();
- m_modeTx=settings.value("ModeTx","JT9").toString();
- if(m_modeTx=="JT9") ui->pbTxMode->setText("Tx JT9 @");
+ m_settings->endGroup();
+
+ // do this outside of settings group because it uses groups internally
+ if (displayAstro)
+ {
+ on_actionAstronomical_data_triggered ();
+ }
+
+ m_settings->beginGroup("Common");
+ morse_(const_cast<char *> (m_config.my_callsign ().toLatin1().constData())
+ , const_cast<int *> (icw)
+ , &m_ncw
+ , m_config.my_callsign ().length());
+ m_mode=m_settings->value("Mode","JT9").toString();
+ m_modeTx=m_settings->value("ModeTx","JT9").toString();
+ if(m_modeTx.mid(0,3)=="JT9") ui->pbTxMode->setText("Tx JT9 @");
if(m_modeTx=="JT65") ui->pbTxMode->setText("Tx JT65 #");
- ui->actionNone->setChecked(settings.value("SaveNone",true).toBool());
- ui->actionSave_decoded->setChecked(settings.value(
- "SaveDecoded",false).toBool());
- ui->actionSave_all->setChecked(settings.value("SaveAll",false).toBool());
- m_dialFreq=settings.value("DialFreq",14.078).toDouble();
- m_rxFreq=settings.value("RxFreq",1500).toInt();
- ui->RxFreqSpinBox->setValue(m_rxFreq);
- m_txFreq=settings.value("TxFreq",1500).toInt();
- ui->TxFreqSpinBox->setValue(m_txFreq);
- soundOutThread.setTxFreq(m_txFreq);
+ ui->actionNone->setChecked(m_settings->value("SaveNone",true).toBool());
+ ui->actionSave_decoded->setChecked(m_settings->value(
+ "SaveDecoded",false).toBool());
+ ui->actionSave_all->setChecked(m_settings->value("SaveAll",false).toBool());
+ ui->RxFreqSpinBox->setValue(0); // ensure a change is signaled
+ ui->RxFreqSpinBox->setValue(m_settings->value("RxFreq",1500).toInt());
+ m_lastMonitoredFrequency = m_settings->value ("DialFreq", QVariant::fromValue<Frequency> (default_frequency)).value<Frequency> ();
+ ui->TxFreqSpinBox->setValue(0); // ensure a change is signaled
+ ui->TxFreqSpinBox->setValue(m_settings->value("TxFreq",1500).toInt());
+ Q_EMIT transmitFrequency (ui->TxFreqSpinBox->value () - m_XIT);
m_saveDecoded=ui->actionSave_decoded->isChecked();
m_saveAll=ui->actionSave_all->isChecked();
- m_ndepth=settings.value("NDepth",3).toInt();
- m_inGain=settings.value("InGain",0).toInt();
+ m_ndepth=m_settings->value("NDepth",3).toInt();
+ m_inGain=m_settings->value("InGain",0).toInt();
ui->inGain->setValue(m_inGain);
- m_monitorStartOFF=settings.value("MonitorOFF",false).toBool();
- ui->actionMonitor_OFF_at_startup->setChecked(m_monitorStartOFF);
- m_pskReporter=settings.value("PSKReporter",false).toBool();
- m_After73=settings.value("After73",false).toBool();
- m_macro=settings.value("Macros","TNX 73 GL").toStringList();
- m_dFreq=settings.value("DefaultFreqs","").toStringList();
- m_toRTTY=settings.value("toRTTY",false).toBool();
- ui->actionConvert_JT9_x_to_RTTY->setChecked(m_toRTTY);
- m_noSuffix=settings.value("NoSuffix",false).toBool();
- ui->actionLog_JT9_without_submode->setChecked(m_noSuffix);
- m_dBtoComments=settings.value("dBtoComments",false).toBool();
- ui->actionLog_dB_reports_to_Comments->setChecked(m_dBtoComments);
- m_rig=settings.value("Rig",214).toInt();
- m_rigIndex=settings.value("RigIndex",100).toInt();
- m_catPort=settings.value("CATport","None").toString();
- m_catPortIndex=settings.value("CATportIndex",0).toInt();
- m_serialRate=settings.value("SerialRate",4800).toInt();
- m_serialRateIndex=settings.value("SerialRateIndex",1).toInt();
- m_dataBits=settings.value("DataBits",8).toInt();
- m_dataBitsIndex=settings.value("DataBitsIndex",1).toInt();
- m_stopBits=settings.value("StopBits",2).toInt();
- m_stopBitsIndex=settings.value("StopBitsIndex",1).toInt();
- m_handshake=settings.value("Handshake","None").toString();
- m_handshakeIndex=settings.value("HandshakeIndex",0).toInt();
- m_band=settings.value("BandIndex",7).toInt();
- ui->bandComboBox->setCurrentIndex(m_band);
- dialFreqChanged2(m_dialFreq);
- m_catEnabled=settings.value("catEnabled",false).toBool();
- m_promptToLog=settings.value("PromptToLog",false).toBool();
- ui->actionPrompt_to_log_QSO->setChecked(m_promptToLog);
- m_insertBlank=settings.value("InsertBlank",false).toBool();
- ui->actionBlank_line_between_decoding_periods->setChecked(m_insertBlank);
- m_clearCallGrid=settings.value("ClearCallGrid",false).toBool();
- ui->actionClear_DX_Call_and_Grid_after_logging->setChecked(m_clearCallGrid);
- m_bMiles=settings.value("Miles",false).toBool();
- ui->actionDisplay_distance_in_miles->setChecked(m_bMiles);
- int n=settings.value("GUItab",0).toInt();
+
+ // setup initial value of tx attenuator
+ ui->outAttenuation->setValue (m_settings->value ("OutAttenuation", 0).toInt ());
+ on_outAttenuation_valueChanged (ui->outAttenuation->value ());
+
+ m_noSuffix=m_settings->value("NoSuffix",false).toBool();
+ int n=m_settings->value("GUItab",0).toInt();
ui->tabWidget->setCurrentIndex(n);
- m_quickCall=settings.value("QuickCall",false).toBool();
- ui->actionDouble_click_on_call_sets_Tx_Enable->setChecked(m_quickCall);
- m_73TxDisable=settings.value("73TxDisable",false).toBool();
- ui->action_73TxDisable->setChecked(m_73TxDisable);
- m_runaway=settings.value("Runaway",false).toBool();
- ui->actionRunaway_Tx_watchdog->setChecked(m_runaway);
- m_tx2QSO=settings.value("Tx2QSO",false).toBool();
- ui->actionTx2QSO->setChecked(m_tx2QSO);
- m_bMultipleOK=settings.value("MultipleOK",false).toBool();
- ui->actionAllow_multiple_instances->setChecked(m_bMultipleOK);
- m_bDTRoff=settings.value("DTRoff",false).toBool();
- m_pttData=settings.value("pttData",false).toBool();
- m_poll=settings.value("Polling",0).toInt();
- m_logQSOgeom=settings.value("LogQSOgeom",QRect(500,400,424,283)).toRect();
- outBufSize=settings.value("OutBufSize",4096).toInt();
- m_lockTxFreq=settings.value("LockTxFreq",false).toBool();
+ outBufSize=m_settings->value("OutBufSize",4096).toInt();
+ m_lockTxFreq=m_settings->value("LockTxFreq",false).toBool();
ui->cbTxLock->setChecked(m_lockTxFreq);
- m_saveTxPower=settings.value("SaveTxPower",false).toBool();
- m_saveComments=settings.value("SaveComments",false).toBool();
- m_txPower=settings.value("TxPower","").toString();
- m_logComments=settings.value("LogComments","").toString();
- m_pskAntenna=settings.value("PSKantenna","").toString();
- m_fMin=settings.value("fMin",2500).toInt();
- m_bSplit=settings.value("TxSplit",false).toBool();
- m_bXIT=settings.value("UseXit",false).toBool();
- m_plus2kHz=settings.value("Plus2kHz",false).toBool();
+ m_plus2kHz=m_settings->value("Plus2kHz",false).toBool();
ui->cbPlus2kHz->setChecked(m_plus2kHz);
- settings.endGroup();
+ m_settings->endGroup();
+
+ // use these initialisation settings to tune the audio o/p buffer
+ // size and audio thread priority
+ m_settings->beginGroup ("Tune");
+ m_msAudioOutputBuffered = m_settings->value ("Audio/OutputBufferMs").toInt ();
+ m_framesAudioInputBuffered = m_settings->value ("Audio/InputBufferFrames", RX_SAMPLE_RATE / 10).toInt ();
+ m_audioThreadPriority = static_cast<QThread::Priority> (m_settings->value ("Audio/ThreadPriority", QThread::HighPriority).toInt () % 8);
+ m_settings->endGroup ();
- if(!ui->actionLinrad->isChecked() && !ui->actionCuteSDR->isChecked() &&
- !ui->actionAFMHot->isChecked() && !ui->actionBlue->isChecked()) {
- on_actionLinrad_triggered();
- ui->actionLinrad->setChecked(true);
- }
if(m_ndepth==1) ui->actionQuickDecode->setChecked(true);
if(m_ndepth==2) ui->actionMediumDecode->setChecked(true);
if(m_ndepth==3) ui->actionDeepestDecode->setChecked(true);
@@ -622,17 +633,26 @@ void MainWindow::readSettings()
statusChanged();
}
+void MainWindow::setDecodedTextFont (QFont const& font)
+{
+ ui->decodedTextBrowser->setContentFont (font);
+ ui->decodedTextBrowser2->setContentFont (font);
+ auto style_sheet = "QLabel {" + font_as_stylesheet (font) + '}';
+ ui->decodedTextLabel->setStyleSheet (ui->decodedTextLabel->styleSheet () + style_sheet);
+ ui->decodedTextLabel2->setStyleSheet (ui->decodedTextLabel2->styleSheet () + style_sheet);
+}
+
//-------------------------------------------------------------- dataSink()
-void MainWindow::dataSink(int k)
+void MainWindow::dataSink(qint64 frames)
{
static float s[NSMAX];
static int ihsym=0;
static int nzap=0;
static int trmin;
static int npts8;
+ static int nflatten=0;
static float px=0.0;
static float df3;
- static float slope;
if(m_diskData) {
jt9com_.ndiskdat=1;
@@ -640,18 +660,21 @@ void MainWindow::dataSink(int k)
jt9com_.ndiskdat=0;
}
-// Get power, spectrum, and ihsym
+ // Get power, spectrum, and ihsym
trmin=m_TRperiod/60;
- slope=0.0;
- if(g_pWideGraph!=NULL) slope=(float)g_pWideGraph->getSlope();
- symspec_(&k,&trmin,&m_nsps,&m_inGain,&slope,&px,s,&df3,&ihsym,&npts8);
+ int k (frames - 1);
+ jt9com_.nfa=m_wideGraph->nStartFreq();
+ jt9com_.nfb=m_wideGraph->getFmax();
+ nflatten=0;
+ if(m_wideGraph->flatten()) nflatten=1;
+ symspec_(&k,&trmin,&m_nsps,&m_inGain,&nflatten,&px,s,&df3,&ihsym,&npts8);
if(ihsym <=0) return;
QString t;
m_pctZap=nzap*100.0/m_nsps;
t.sprintf(" Rx noise: %5.1f ",px);
signalMeter->setValue(px); // Update thermometer
if(m_monitoring || m_diskData) {
- g_pWideGraph->dataSink2(s,df3,ihsym,m_diskData);
+ m_wideGraph->dataSink2(s,df3,ihsym,m_diskData);
}
if(ihsym == m_hsymStop) {
@@ -669,305 +692,237 @@ void MainWindow::dataSink(int k)
imin=imin - (imin%(m_TRperiod/60));
QString t2;
t2.sprintf("%2.2d%2.2d",ihr,imin);
- m_fname=m_saveDir + "/" + t.date().toString("yyMMdd") + "_" +
- t2 + ".wav";
+ m_fname=m_config.save_directory ().absoluteFilePath (t.date().toString("yyMMdd") + "_" + t2 + ".wav");
*future2 = QtConcurrent::run(savewav, m_fname, m_TRperiod);
watcher2->setFuture(*future2);
}
}
- soundInThread.m_dataSinkBusy=false;
}
void MainWindow::showSoundInError(const QString& errorMsg)
- {QMessageBox::critical(this, tr("Error in SoundIn"), errorMsg);}
+{QMessageBox::critical(this, tr("Error in SoundInput"), errorMsg);}
+
+void MainWindow::showSoundOutError(const QString& errorMsg)
+{QMessageBox::critical(this, tr("Error in SoundOutput"), errorMsg);}
void MainWindow::showStatusMessage(const QString& statusMsg)
- {statusBar()->showMessage(statusMsg);}
-
-void MainWindow::on_actionDeviceSetup_triggered() //Setup Dialog
-{
- DevSetup dlg(this);
- dlg.m_myCall=m_myCall;
- dlg.m_myGrid=m_myGrid;
- dlg.m_pskAntenna=m_pskAntenna;
- dlg.m_idInt=m_idInt;
- dlg.m_pttMethodIndex=m_pttMethodIndex;
- dlg.m_pttPort=m_pttPort;
- dlg.m_saveDir=m_saveDir;
- dlg.m_paInDevice=m_paInDevice;
- dlg.m_paOutDevice=m_paOutDevice;
- dlg.m_pskReporter=m_pskReporter;
- dlg.m_After73=m_After73;
- dlg.m_macro=m_macro;
- dlg.m_dFreq=m_dFreq;
- dlg.m_catEnabled=m_catEnabled;
- dlg.m_rig=m_rig;
- dlg.m_rigIndex=m_rigIndex;
- dlg.m_catPort=m_catPort;
- dlg.m_catPortIndex=m_catPortIndex;
- dlg.m_serialRate=m_serialRate;
- dlg.m_serialRateIndex=m_serialRateIndex;
- dlg.m_dataBits=m_dataBits;
- dlg.m_dataBitsIndex=m_dataBitsIndex;
- dlg.m_stopBits=m_stopBits;
- dlg.m_stopBitsIndex=m_stopBitsIndex;
- dlg.m_handshake=m_handshake;
- dlg.m_handshakeIndex=m_handshakeIndex;
- dlg.m_bDTRoff=m_bDTRoff;
- dlg.m_pttData=m_pttData;
- dlg.m_poll=m_poll;
- dlg.m_bSplit=m_bSplit;
- dlg.m_bXIT=m_bXIT;
-
- if(m_bRigOpen) {
- rig->close();
- ui->readFreq->setStyleSheet("");
- ui->readFreq->setEnabled(false);
- if(m_rig<9900) delete rig;
- m_bRigOpen=false;
- m_catEnabled=false;
- m_CATerror=false;
- }
+{statusBar()->showMessage(statusMsg);}
- dlg.initDlg();
- if(dlg.exec() == QDialog::Accepted) {
- m_myCall=dlg.m_myCall;
- m_myGrid=dlg.m_myGrid;
- m_pskAntenna=dlg.m_pskAntenna;
- m_idInt=dlg.m_idInt;
- m_pttMethodIndex=dlg.m_pttMethodIndex;
- m_pttPort=dlg.m_pttPort;
- m_saveDir=dlg.m_saveDir;
- m_paInDevice=dlg.m_paInDevice;
- m_paOutDevice=dlg.m_paOutDevice;
- m_macro=dlg.m_macro;
- m_dFreq=dlg.m_dFreq;
- m_catEnabled=dlg.m_catEnabled;
- m_rig=dlg.m_rig;
- m_rigIndex=dlg.m_rigIndex;
- m_catPort=dlg.m_catPort;
- m_catPortIndex=dlg.m_catPortIndex;
- m_serialRate=dlg.m_serialRate;
- m_serialRateIndex=dlg.m_serialRateIndex;
- m_dataBits=dlg.m_dataBits;
- m_dataBitsIndex=dlg.m_dataBitsIndex;
- m_stopBits=dlg.m_stopBits;
- m_stopBitsIndex=dlg.m_stopBitsIndex;
- m_handshake=dlg.m_handshake;
- m_handshakeIndex=dlg.m_handshakeIndex;
- m_bDTRoff=dlg.m_bDTRoff;
- m_pttData=dlg.m_pttData;
- m_poll=dlg.m_poll;
+void MainWindow::on_actionSettings_triggered() //Setup Dialog
+{
+ ui->readFreq->setStyleSheet("");
+ ui->readFreq->setEnabled(false);
-#ifdef WIN32
- if(dlg.m_pskReporter!=m_pskReporter) {
- if(dlg.m_pskReporter) {
- int rc=ReporterInitialize(NULL,NULL);
- if(rc==0) {
- m_pskReporterInit=true;
- } else {
- m_pskReporterInit=false;
- rc=ReporterGetInformation(buffer,256);
- msgBox(QString::fromStdWString(buffer));
+ // things that might change that we need know about
+ auto callsign = m_config.my_callsign ();
+
+ if (QDialog::Accepted == m_config.exec ())
+ {
+ if (m_config.my_callsign () != callsign)
+ {
+ m_baseCall = Radio::base_callsign (m_config.my_callsign ());
+ morse_(const_cast<char *> (m_config.my_callsign ().toLatin1().constData())
+ , const_cast<int *> (icw)
+ , &m_ncw
+ , m_config.my_callsign ().length());
}
- } else {
- rc=ReporterUninitialize();
- m_pskReporterInit=false;
- }
- }
-#endif
- m_pskReporter=dlg.m_pskReporter;
-#ifdef UNIX
- if(m_pskReporter) {
- psk_Reporter->setLocalStation(m_myCall,m_myGrid, "WSJT-X r" + rev.mid(6,4) );
- }
-#endif
+ on_dxGridEntry_textChanged (m_hisGrid); // recalculate distances in case of units change
+ enable_DXCC_entity (m_config.DXCC ()); // sets text window proportions and (re)inits the logbook
- m_After73=dlg.m_After73;
+ if(m_config.spot_to_psk_reporter ())
+ {
+ pskSetLocal ();
+ }
- if(dlg.m_restartSoundIn) {
- soundInThread.quit();
- soundInThread.wait(1000);
- soundInThread.setInputDevice(m_paInDevice);
- soundInThread.start(QThread::HighestPriority);
- }
+ if(m_mode=="JT9W-1") m_toneSpacing=pow(2,m_config.jt9w_bw_mult ())*12000.0/6912.0;
- if(dlg.m_restartSoundOut) {
- soundOutThread.quitExecution=true;
- soundOutThread.wait(1000);
- soundOutThread.setOutputDevice(m_paOutDevice);
- }
- }
- m_catEnabled=dlg.m_catEnabled;
+ if(m_config.restart_audio_input ()) {
+ Q_EMIT startAudioInputStream (m_config.audio_input_device (), m_framesAudioInputBuffered, &m_detector, m_downSampleFactor, m_config.audio_input_channel ());
+ }
+ if(m_config.restart_audio_output ()) {
+ Q_EMIT initializeAudioOutputStream (m_config.audio_output_device (), AudioDevice::Mono == m_config.audio_output_channel () ? 1 : 2, m_msAudioOutputBuffered);
+ }
- if(m_catEnabled) {
- rigOpen();
- } else {
- ui->readFreq->setStyleSheet("");
- }
+ auto_tx_label->setText (m_config.quick_call () ? "Tx-Enable Armed" : "Tx-Enable Disarmed");
- if(dlg.m_bSplit!=m_bSplit or dlg.m_bXIT!=m_bXIT) {
- m_bSplit=dlg.m_bSplit;
- m_bXIT=dlg.m_bXIT;
- if(m_bSplit or m_bXIT) setXIT(m_txFreq);
- if(m_bRigOpen and !m_bSplit) {
- int ret=rig->setSplitFreq(MHz(m_dialFreq),RIG_VFO_B);
- if(ret!=RIG_OK) {
- QString rt;
- rt.sprintf("Setting VFO_B failed: %d",ret);
- msgBox(rt);
- }
+ displayDialFrequency ();
}
- }
-}
-void MainWindow::on_monitorButton_clicked() //Monitor
-{
- m_monitoring=true;
- soundInThread.setMonitoring(true);
- m_diskData=false;
+ setXIT (ui->TxFreqSpinBox->value ());
+ if (m_config.transceiver_online ())
+ {
+ Q_EMIT m_config.transceiver_frequency (m_dialFreq);
+ }
}
-void MainWindow::on_actionLinrad_triggered() //Linrad palette
+void MainWindow::on_monitorButton_clicked (bool checked)
{
- if(g_pWideGraph != NULL) g_pWideGraph->setPalette("Linrad");
-}
+ if (!m_transmitting)
+ {
+ auto prior = m_monitoring;
+ monitor (checked);
-void MainWindow::on_actionCuteSDR_triggered() //CuteSDR palette
-{
- if(g_pWideGraph != NULL) g_pWideGraph->setPalette("CuteSDR");
+ if (checked && !prior)
+ {
+ m_diskData = false; // no longer reading WAV files
+
+ Frequency operating_frequency {m_dialFreq};
+ if (m_config.monitor_last_used ())
+ {
+ // put rig back where it was when last in control
+ operating_frequency = m_lastMonitoredFrequency;
+ Q_EMIT m_config.transceiver_frequency (operating_frequency);
+ }
+ qsy (operating_frequency);
+ if (m_config.monitor_last_used ())
+ {
+ setXIT (ui->TxFreqSpinBox->value ());
+ }
+ }
+
+ Q_EMIT m_config.sync_transceiver (true, checked); // gets
+ // Configuration
+ // in/out of
+ // strict
+ // split and
+ // mode
+ // checking
+
+ }
+ else
+ {
+ ui->monitorButton->setChecked (false); // disallow
+ }
}
-void MainWindow::on_actionAFMHot_triggered()
+void MainWindow::monitor (bool state)
{
- if(g_pWideGraph != NULL) g_pWideGraph->setPalette("AFMHot");
+ ui->monitorButton->setChecked (state);
+ if (state)
+ {
+ if (!m_monitoring)
+ {
+ Q_EMIT resumeAudioInputStream ();
+ }
+ }
+ else
+ {
+ Q_EMIT suspendAudioInputStream ();
+ }
+ m_monitoring = state;
}
-void MainWindow::on_actionBlue_triggered()
+void MainWindow::on_actionAbout_triggered() //Display "About"
{
- if(g_pWideGraph != NULL) g_pWideGraph->setPalette("Blue");
+ CAboutDlg {this}.exec ();
}
-void MainWindow::on_actionAbout_triggered() //Display "About"
+void MainWindow::on_autoButton_clicked (bool checked)
{
- CAboutDlg dlg(this,Program_Title_Version);
- dlg.exec();
+ m_auto = checked;
+ m_messageClient->status_update (m_dialFreq, m_mode, m_hisCall, QString::number (ui->rptSpinBox->value ()), m_modeTx, ui->autoButton->isChecked (), m_transmitting);
}
-void MainWindow::on_autoButton_clicked() //Auto
+void MainWindow::auto_tx_mode (bool state)
{
- m_auto = !m_auto;
- if(m_auto) {
- ui->autoButton->setStyleSheet(m_pbAutoOn_style);
- } else {
- btxok=false;
- ui->autoButton->setStyleSheet("");
- on_monitorButton_clicked();
- m_repeatMsg=0;
- }
+ ui->autoButton->setChecked (state);
+ on_autoButton_clicked (state);
}
void MainWindow::keyPressEvent( QKeyEvent *e ) //keyPressEvent
{
int n;
switch(e->key())
- {
- case Qt::Key_1:
- if(e->modifiers() & Qt::AltModifier) {
- on_txb1_clicked();
- break;
- }
- case Qt::Key_2:
- if(e->modifiers() & Qt::AltModifier) {
- on_txb2_clicked();
- break;
- }
- case Qt::Key_3:
- if(e->modifiers() & Qt::AltModifier) {
- on_txb3_clicked();
- break;
- }
- case Qt::Key_4:
- if(e->modifiers() & Qt::AltModifier) {
- on_txb4_clicked();
- break;
- }
- case Qt::Key_5:
- if(e->modifiers() & Qt::AltModifier) {
- on_txb5_clicked();
- break;
- }
- case Qt::Key_6:
- if(e->modifiers() & Qt::AltModifier) {
- on_txb6_clicked();
+ {
+ case Qt::Key_D:
+ if(e->modifiers() & Qt::ShiftModifier) {
+ if(!m_decoderBusy) {
+ jt9com_.newdat=0;
+ jt9com_.nagain=0;
+ decode();
+ return;
+ }
+ }
break;
- }
- case Qt::Key_D:
- if(e->modifiers() & Qt::ShiftModifier) {
- if(!m_decoderBusy) {
- jt9com_.newdat=0;
- jt9com_.nagain=0;
- decode();
- break;
+ case Qt::Key_F4:
+ ui->dxCallEntry->setText("");
+ ui->dxGridEntry->setText("");
+ m_hisCall="";
+ m_hisGrid="";
+ m_rptSent="";
+ m_rptRcvd="";
+ m_qsoStart="";
+ m_qsoStop="";
+ genStdMsgs("");
+ if (1 == ui->tabWidget->currentIndex())
+ {
+ ui->genMsg->setText(ui->tx6->text());
+ m_ntx=7;
+ ui->rbGenMsg->setChecked(true);
+ }
+ else
+ {
+ m_ntx=6;
+ ui->txrb6->setChecked(true);
+ }
+ return;
+ case Qt::Key_F6:
+ if(e->modifiers() & Qt::ShiftModifier) {
+ on_actionDecode_remaining_files_in_directory_triggered();
+ return;
}
- }
- break;
- case Qt::Key_F4:
- ui->dxCallEntry->setText("");
- ui->dxGridEntry->setText("");
- genStdMsgs("");
- m_ntx=6;
- ui->txrb6->setChecked(true);
- break;
- case Qt::Key_F6:
- if(e->modifiers() & Qt::ShiftModifier) {
- on_actionDecode_remaining_files_in_directory_triggered();
- }
- break;
- case Qt::Key_F11:
- n=11;
- if(e->modifiers() & Qt::ControlModifier) n+=100;
- bumpFqso(n);
- break;
- case Qt::Key_F12:
- n=12;
- if(e->modifiers() & Qt::ControlModifier) n+=100;
- bumpFqso(n);
- break;
- case Qt::Key_F:
- if(e->modifiers() & Qt::ControlModifier) {
- if(ui->tabWidget->currentIndex()==0) {
- ui->tx5->clear();
- ui->tx5->setFocus();
- } else {
- ui->freeTextMsg->clear();
- ui->freeTextMsg->setFocus();
+ break;
+ case Qt::Key_F11:
+ n=11;
+ if(e->modifiers() & Qt::ControlModifier) n+=100;
+ bumpFqso(n);
+ return;
+ case Qt::Key_F12:
+ n=12;
+ if(e->modifiers() & Qt::ControlModifier) n+=100;
+ bumpFqso(n);
+ return;
+ case Qt::Key_F:
+ if(e->modifiers() & Qt::ControlModifier) {
+ if(ui->tabWidget->currentIndex()==0) {
+ ui->tx5->clearEditText();
+ ui->tx5->setFocus();
+ } else {
+ ui->freeTextMsg->clearEditText();
+ ui->freeTextMsg->setFocus();
+ }
+ return;
}
break;
- }
- case Qt::Key_G:
- if(e->modifiers() & Qt::AltModifier) {
- genStdMsgs(m_rpt);
+ case Qt::Key_G:
+ if(e->modifiers() & Qt::AltModifier) {
+ genStdMsgs(m_rpt);
+ return;
+ }
break;
- }
- case Qt::Key_H:
- if(e->modifiers() & Qt::AltModifier) {
- on_stopTxButton_clicked();
+ case Qt::Key_H:
+ if(e->modifiers() & Qt::AltModifier) {
+ on_stopTxButton_clicked();
+ return;
+ }
break;
- }
- case Qt::Key_L:
- if(e->modifiers() & Qt::ControlModifier) {
- lookup();
- genStdMsgs(m_rpt);
+ case Qt::Key_L:
+ if(e->modifiers() & Qt::ControlModifier) {
+ lookup();
+ genStdMsgs(m_rpt);
+ return;
+ }
break;
- }
- case Qt::Key_V:
- if(e->modifiers() & Qt::AltModifier) {
- m_fileToSave=m_fname;
+ case Qt::Key_V:
+ if(e->modifiers() & Qt::AltModifier) {
+ m_fileToSave=m_fname;
+ return;
+ }
break;
}
- }
+
+ QMainWindow::keyPressEvent (e);
}
void MainWindow::bumpFqso(int n) //bumpFqso()
@@ -975,49 +930,101 @@ void MainWindow::bumpFqso(int n) //bumpFqso()
int i;
bool ctrl = (n>=100);
n=n%100;
- i=g_pWideGraph->rxFreq();
+ i=ui->RxFreqSpinBox->value ();
if(n==11) i--;
if(n==12) i++;
- g_pWideGraph->setRxFreq(i);
- if(ctrl) {
- ui->TxFreqSpinBox->setValue(i);
- g_pWideGraph->setTxFreq(i);
- }
+ if (ui->RxFreqSpinBox->isEnabled ())
+ {
+ ui->RxFreqSpinBox->setValue (i);
+ }
+ if(ctrl && ui->TxFreqSpinBox->isEnabled ())
+ {
+ ui->TxFreqSpinBox->setValue (i);
+ }
}
-void MainWindow::dialFreqChanged2(double f)
+void MainWindow::qsy (Frequency f)
{
- m_dialFreq=f;
- if(m_band<0 or m_band>15 or m_dFreq.length()<=1) return;
- QString t;
- t.sprintf("%.6f",m_dialFreq);
- int n=t.length();
- t=t.mid(0,n-3) + " " + t.mid(n-3,3);
- double fBand=m_dFreq[m_band].toDouble();
- if(qAbs(m_dialFreq-fBand)<0.01) {
- ui->labDialFreq->setStyleSheet( \
- "QLabel { background-color : black; color : yellow; }");
- } else {
- ui->labDialFreq->setStyleSheet( \
- "QLabel { background-color : red; color : yellow; }");
- ui->labDialFreq->setText(t);
- }
- ui->labDialFreq->setText(t);
- statusChanged();
- if(g_pWideGraph!=NULL) g_pWideGraph->setDialFreq(m_dialFreq);
+ if (!m_transmitting)
+ {
+ if (m_monitoring)
+ {
+ m_lastMonitoredFrequency = f;
+ }
+
+ if (m_dialFreq != f)
+ {
+ m_dialFreq = f;
+
+ m_repeatMsg=0;
+ m_secBandChanged=QDateTime::currentMSecsSinceEpoch()/1000;
+
+ QFile f2 {m_dataDir.absoluteFilePath ("ALL.TXT")};
+ if (f2.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append))
+ {
+ QTextStream out(&f2);
+ out << QDateTime::currentDateTimeUtc().toString("yyyy-MMM-dd hh:mm")
+ << " " << (m_dialFreq / 1.e6) << " MHz " << m_mode << endl;
+ f2.close();
+ }
+ else
+ {
+ msgBox("Cannot open \"" + f2.fileName () + "\" for append:" + f2.errorString ());
+ }
+ if (m_config.spot_to_psk_reporter ())
+ {
+ pskSetLocal ();
+ }
+
+ displayDialFrequency ();
+ statusChanged();
+ m_wideGraph->setDialFreq(m_dialFreq / 1.e6);
+ }
+ }
+}
+
+void MainWindow::displayDialFrequency ()
+{
+ // lookup band
+ auto bands_model = m_config.bands ();
+ ui->bandComboBox->setCurrentText (bands_model->data (bands_model->find (m_dialFreq)).toString ());
+
+ // search working frequencies for one we are within 10kHz of
+ auto frequencies = m_config.frequencies ();
+ bool valid {false};
+ for (int row = 0; row < frequencies->rowCount (); ++row)
+ {
+ // 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 working_frequency = frequencies->data (frequencies->index (row, 0)).value<Frequency> ();
+ auto offset = m_dialFreq > working_frequency ? m_dialFreq - working_frequency : working_frequency - m_dialFreq;
+ if (offset < 10000u)
+ {
+ valid = true;
+ }
+ }
+ ui->labDialFreq->setProperty ("oob", !valid);
+ // the following sequence is necessary to update the style
+ ui->labDialFreq->style ()->unpolish (ui->labDialFreq);
+ ui->labDialFreq->style ()->polish (ui->labDialFreq);
+ ui->labDialFreq->update ();
+
+ ui->labDialFreq->setText (Radio::pretty_frequency_MHz_string (m_dialFreq));
}
void MainWindow::statusChanged()
{
- QFile f("wsjtx_status.txt");
+ m_messageClient->status_update (m_dialFreq, m_mode, m_hisCall, QString::number (ui->rptSpinBox->value ()), m_modeTx, ui->autoButton->isChecked (), m_transmitting);
+
+ QFile f {m_config.temp_dir ().absoluteFilePath ("wsjtx_status.txt")};
if(f.open(QFile::WriteOnly | QIODevice::Text)) {
QTextStream out(&f);
- out << m_dialFreq << ";" << m_mode << ";" << m_hisCall << ";"
+ out << (m_dialFreq / 1.e6) << ";" << m_mode << ";" << m_hisCall << ";"
<< ui->rptSpinBox->value() << ";" << m_modeTx << endl;
f.close();
} else {
- msgBox("Cannot open file \"wsjtx_status.txt\".");
- return;
+ msgBox("Cannot open \"" + f.fileName () + "\" for writing:" + f.errorString ());
}
}
@@ -1033,56 +1040,60 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event) //eventFilter()
void MainWindow::createStatusBar() //createStatusBar
{
- lab1 = new QLabel("Receiving");
- lab1->setAlignment(Qt::AlignHCenter);
- lab1->setMinimumSize(QSize(80,18));
- lab1->setStyleSheet("QLabel{background-color: #00ff00}");
- lab1->setFrameStyle(QFrame::Panel | QFrame::Sunken);
- statusBar()->addWidget(lab1);
+ tx_status_label = new QLabel("Receiving");
+ tx_status_label->setAlignment(Qt::AlignHCenter);
+ tx_status_label->setMinimumSize(QSize(80,18));
+ tx_status_label->setStyleSheet("QLabel{background-color: #00ff00}");
+ tx_status_label->setFrameStyle(QFrame::Panel | QFrame::Sunken);
+ statusBar()->addWidget(tx_status_label);
- lab2 = new QLabel("");
- lab2->setAlignment(Qt::AlignHCenter);
- lab2->setMinimumSize(QSize(150,18));
- lab2->setFrameStyle(QFrame::Panel | QFrame::Sunken);
- statusBar()->addWidget(lab2);
- lab3 = new QLabel("");
- lab3->setAlignment(Qt::AlignHCenter);
- lab3->setMinimumSize(QSize(80,18));
- lab3->setFrameStyle(QFrame::Panel | QFrame::Sunken);
- statusBar()->addWidget(lab3);
-}
+ mode_label = new QLabel("");
+ mode_label->setAlignment(Qt::AlignHCenter);
+ mode_label->setMinimumSize(QSize(80,18));
+ mode_label->setFrameStyle(QFrame::Panel | QFrame::Sunken);
+ statusBar()->addWidget(mode_label);
-void MainWindow::on_actionExit_triggered() //Exit()
-{
- OnExit();
-}
+ last_tx_label = new QLabel("");
+ last_tx_label->setAlignment(Qt::AlignHCenter);
+ last_tx_label->setMinimumSize(QSize(150,18));
+ last_tx_label->setFrameStyle(QFrame::Panel | QFrame::Sunken);
+ statusBar()->addWidget(last_tx_label);
-void MainWindow::closeEvent(QCloseEvent*)
-{
- OnExit();
+ auto_tx_label = new QLabel("");
+ auto_tx_label->setAlignment(Qt::AlignHCenter);
+ auto_tx_label->setMinimumSize(QSize(150,18));
+ auto_tx_label->setFrameStyle(QFrame::Panel | QFrame::Sunken);
+ statusBar()->addWidget(auto_tx_label);
}
-void MainWindow::OnExit()
+void MainWindow::closeEvent(QCloseEvent * e)
{
- g_pWideGraph->saveSettings();
+ m_config.transceiver_offline ();
+ writeSettings ();
+ m_guiTimer.stop ();
+ m_prefixes.reset ();
+ m_shortcuts.reset ();
+ m_mouseCmnds.reset ();
+
if(m_fname != "") killFile();
m_killAll=true;
mem_jt9->detach();
- QFile quitFile(m_appDir + "/.quit");
+ QFile quitFile {m_config.temp_dir ().absoluteFilePath (".quit")};
quitFile.open(QIODevice::ReadWrite);
- QFile lockFile(m_appDir + "/.lock");
- lockFile.remove(); // Allow jt9 to terminate
+ QFile {m_config.temp_dir ().absoluteFilePath (".lock")}.remove(); // Allow jt9 to terminate
bool b=proc_jt9.waitForFinished(1000);
if(!b) proc_jt9.kill();
quitFile.remove();
- qApp->exit(0); // Exit the event loop
+
+ Q_EMIT finished ();
+
+ QMainWindow::closeEvent (e);
}
void MainWindow::on_stopButton_clicked() //stopButton
{
- m_monitoring=false;
- soundInThread.setMonitoring(m_monitoring);
+ monitor (false);
m_loopall=false;
}
@@ -1092,48 +1103,54 @@ void MainWindow::msgBox(QString t) //msgBox
msgBox0.exec();
}
-void MainWindow::on_actionOnline_Users_Guide_triggered() //Display manual
+void MainWindow::on_actionOnline_User_Guide_triggered() //Display manual
+{
+#if defined (CMAKE_BUILD)
+ QDesktopServices::openUrl (QUrl (PROJECT_MANUAL_DIRECTORY_URL "/" PROJECT_MANUAL));
+#endif
+}
+
+//Display local copy of manual
+void MainWindow::on_actionLocal_User_Guide_triggered()
{
- QDesktopServices::openUrl(QUrl(
- "http://www.physics.princeton.edu/pulsar/K1JT/WSJT-X_Users_Guide_v1.1.pdf",
- QUrl::TolerantMode));
+#if defined (CMAKE_BUILD)
+ auto file = m_config.doc_dir ().absoluteFilePath (PROJECT_MANUAL);
+ QDesktopServices::openUrl (QUrl {"file:///" + file});
+#endif
}
void MainWindow::on_actionWide_Waterfall_triggered() //Display Waterfalls
{
- if(g_pWideGraph==NULL) {
- g_pWideGraph = new WideGraph(0);
- g_pWideGraph->setWindowTitle("Wide Graph");
- g_pWideGraph->setGeometry(m_wideGraphGeom);
- Qt::WindowFlags flags = Qt::WindowCloseButtonHint |
- Qt::WindowMinimizeButtonHint;
- g_pWideGraph->setWindowFlags(flags);
- connect(g_pWideGraph, SIGNAL(freezeDecode2(int)),this,
- SLOT(freezeDecode(int)));
- connect(g_pWideGraph, SIGNAL(f11f12(int)),this,
- SLOT(bumpFqso(int)));
- connect(g_pWideGraph, SIGNAL(setXIT2(int)),this,
- SLOT(setXIT(int)));
-// connect(g_pWideGraph, SIGNAL(dialFreqChanged(double)),this,
-// SLOT(dialFreqChanged2(double)));
- }
- g_pWideGraph->show();
+ m_wideGraph->show();
+}
+
+void MainWindow::on_actionAstronomical_data_triggered()
+{
+ if (!m_astroWidget)
+ {
+ m_astroWidget.reset (new Astro {m_settings});
+
+ // hook up termination signal
+ connect (this, &MainWindow::finished, m_astroWidget.data (), &Astro::close);
+ }
+ m_astroWidget->showNormal();
}
void MainWindow::on_actionOpen_triggered() //Open File
{
- m_monitoring=false;
- soundInThread.setMonitoring(m_monitoring);
+ monitor (false);
+
QString fname;
fname=QFileDialog::getOpenFileName(this, "Open File", m_path,
- "WSJT Files (*.wav)");
+ "WSJT Files (*.wav)");
if(fname != "") {
m_path=fname;
int i;
i=fname.indexOf(".wav") - 11;
if(i>=0) {
- lab1->setStyleSheet("QLabel{background-color: #66ff66}");
- lab1->setText(" " + fname.mid(i,15) + " ");
+ tx_status_label->setStyleSheet("QLabel{background-color: #66ff66}");
+ tx_status_label->setText(" " + fname.mid(i,15) + " ");
+ // lab1->setText(" " + fname + " ");
}
on_stopButton_clicked();
m_diskData=true;
@@ -1144,10 +1161,12 @@ void MainWindow::on_actionOpen_triggered() //Open File
void MainWindow::on_actionOpen_next_in_directory_triggered() //Open Next
{
+ monitor (false);
+
int i,len;
QFileInfo fi(m_path);
QStringList list;
- list= fi.dir().entryList().filter(".wav");
+ list= fi.dir().entryList().filter(".wav",Qt::CaseInsensitive);
for (i = 0; i < list.size()-1; ++i) {
if(i==list.size()-2) m_loopall=false;
len=list.at(i).length();
@@ -1158,8 +1177,8 @@ void MainWindow::on_actionOpen_next_in_directory_triggered() //Open Next
int i;
i=fname.indexOf(".wav") - 11;
if(i>=0) {
- lab1->setStyleSheet("QLabel{background-color: #66ff66}");
- lab1->setText(" " + fname.mid(i,len) + " ");
+ tx_status_label->setStyleSheet("QLabel{background-color: #66ff66}");
+ tx_status_label->setText(" " + fname.mid(i,len) + " ");
}
m_diskData=true;
*future1 = QtConcurrent::run(getfile, fname, m_TRperiod);
@@ -1168,7 +1187,7 @@ void MainWindow::on_actionOpen_next_in_directory_triggered() //Open Next
}
}
}
- //Open all remaining files
+//Open all remaining files
void MainWindow::on_actionDecode_remaining_files_in_directory_triggered()
{
m_loopall=true;
@@ -1183,9 +1202,9 @@ void MainWindow::diskDat() //diskDat()
for(int n=1; n<=m_hsymStop; n++) { // Do the half-symbol FFTs
k=(n+1)*kstep;
jt9com_.npts8=k/8;
- dataSink(k);
+ dataSink(k * sizeof (jt9com_.d2[0]));
if(n%10 == 1 or n == m_hsymStop)
- qApp->processEvents(); //Keep GUI responsive
+ qApp->processEvents(); //Keep GUI responsive
}
}
@@ -1199,11 +1218,11 @@ void MainWindow::on_actionDelete_all_wav_files_in_SaveDir_triggered()
int i;
QString fname;
int ret = QMessageBox::warning(this, "Confirm Delete",
- "Are you sure you want to delete all *.wav files in\n" +
- QDir::toNativeSeparators(m_saveDir) + " ?",
- QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
+ "Are you sure you want to delete all *.wav files in\n" +
+ QDir::toNativeSeparators(m_config.save_directory ().absolutePath ()) + " ?",
+ QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if(ret==QMessageBox::Yes) {
- QDir dir(m_saveDir);
+ QDir dir(m_config.save_directory ());
QStringList files=dir.entryList(QDir::Files);
QList<QString>::iterator f;
for(f=files.begin(); f!=files.end(); ++f) {
@@ -1237,81 +1256,79 @@ void MainWindow::on_actionSave_all_triggered() //Save All
void MainWindow::on_actionKeyboard_shortcuts_triggered()
{
- pShortcuts = new QTextEdit(0);
- pShortcuts->setReadOnly(true);
- pShortcuts->setFontPointSize(10);
- pShortcuts->setWindowTitle("Keyboard Shortcuts");
- pShortcuts->setGeometry(QRect(45,50,430,460));
- Qt::WindowFlags flags = Qt::WindowCloseButtonHint |
- Qt::WindowMinimizeButtonHint;
- pShortcuts->setWindowFlags(flags);
- QString shortcuts = m_appDir + "/shortcuts.txt";
- QFile f(shortcuts);
- if(!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
- msgBox("Cannot open " + shortcuts);
- return;
- }
- QTextStream s(&f);
- QString t;
- for(int i=0; i<100; i++) {
- t=s.readLine();
- pShortcuts->append(t);
- if(s.atEnd()) break;
- }
- pShortcuts->show();
+ if (!m_shortcuts)
+ {
+ QFile f(":/shortcuts.txt");
+ if(!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ msgBox("Cannot open \"" + f.fileName () + "\" for reading:"+f.errorString ());
+ return;
+ }
+ m_shortcuts.reset (new QTextEdit);
+ m_shortcuts->setReadOnly(true);
+ m_shortcuts->setFontPointSize(10);
+ m_shortcuts->setWindowTitle(QApplication::applicationName () + " - " + tr ("Keyboard Shortcuts"));
+ m_shortcuts->setGeometry(QRect(45,50,430,460));
+ Qt::WindowFlags flags = Qt::WindowCloseButtonHint |
+ Qt::WindowMinimizeButtonHint;
+ m_shortcuts->setWindowFlags(flags);
+ QTextStream s(&f);
+ QString t;
+ for(int i=0; i<100; i++) {
+ t=s.readLine();
+ m_shortcuts->append(t);
+ if(s.atEnd()) break;
+ }
+ }
+ m_shortcuts->showNormal();
}
void MainWindow::on_actionSpecial_mouse_commands_triggered()
{
- QTextEdit* pMouseCmnds;
- pMouseCmnds = new QTextEdit(0);
- pMouseCmnds->setReadOnly(true);
- pMouseCmnds->setFontPointSize(10);
- pMouseCmnds->setWindowTitle("Special Mouse Commands");
- pMouseCmnds->setGeometry(QRect(45,50,440,300));
- Qt::WindowFlags flags = Qt::WindowCloseButtonHint |
- Qt::WindowMinimizeButtonHint;
- pMouseCmnds->setWindowFlags(flags);
- QString mouseCmnds = m_appDir + "/mouse_commands.txt";
- QFile f(mouseCmnds);
- if(!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
- msgBox("Cannot open " + mouseCmnds);
- return;
- }
- QTextStream s(&f);
- QString t;
- for(int i=0; i<100; i++) {
- t=s.readLine();
- pMouseCmnds->append(t);
- if(s.atEnd()) break;
- }
- pMouseCmnds->show();
+ if (!m_mouseCmnds)
+ {
+ QFile f(":/mouse_commands.txt");
+ if(!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ msgBox("Cannot open \"" + f.fileName () + "\" for reading:" + f.errorString ());
+ return;
+ }
+ m_mouseCmnds.reset (new QTextEdit);
+ m_mouseCmnds->setReadOnly(true);
+ m_mouseCmnds->setFontPointSize(10);
+ m_mouseCmnds->setWindowTitle(QApplication::applicationName () + " - " + tr ("Special Mouse Commands"));
+ m_mouseCmnds->setGeometry(QRect(45,50,440,300));
+ Qt::WindowFlags flags = Qt::WindowCloseButtonHint |
+ Qt::WindowMinimizeButtonHint;
+ m_mouseCmnds->setWindowFlags(flags);
+ QTextStream s(&f);
+ QString t;
+ for(int i=0; i<100; i++) {
+ t=s.readLine();
+ m_mouseCmnds->append(t);
+ if(s.atEnd()) break;
+ }
+ }
+ m_mouseCmnds->showNormal();
}
-void MainWindow::on_DecodeButton_clicked() //Decode request
+void MainWindow::on_DecodeButton_clicked (bool /* checked */) //Decode request
{
if(!m_decoderBusy) {
jt9com_.newdat=0;
jt9com_.nagain=1;
+ m_blankLine=false; // don't insert the separator again
decode();
}
}
void MainWindow::freezeDecode(int n) //freezeDecode()
{
- bool ctrl = (n>=100);
- int i=g_pWideGraph->rxFreq();
- if(ctrl) {
- ui->TxFreqSpinBox->setValue(i);
- g_pWideGraph->setTxFreq(i);
- }
- if((n%100)==2) on_DecodeButton_clicked();
+ if((n%100)==2) on_DecodeButton_clicked (true);
}
void MainWindow::decode() //decode()
{
if(!m_dataAvailable) return;
- ui->DecodeButton->setStyleSheet(m_pbdecoding_style1);
+ ui->DecodeButton->setChecked (true);
if(jt9com_.newdat==1 && (!m_diskData)) {
qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000;
int imin=ms/60000;
@@ -1321,24 +1338,22 @@ void MainWindow::decode() //decode()
jt9com_.nutc=100*ihr + imin;
}
- jt9com_.nfqso=g_pWideGraph->rxFreq();
+ jt9com_.nfqso=m_wideGraph->rxFreq();
jt9com_.ndepth=m_ndepth;
jt9com_.ndiskdat=0;
if(m_diskData) jt9com_.ndiskdat=1;
- int nfa=g_pWideGraph->getFmin();
- int nfb=g_pWideGraph->getFmax();
- if(m_mode=="JT9") nfa=200; //decode from 0 to fmax
- if(m_mode=="JT65") nfa=nfb; //decode from 0 to fmax
- jt9com_.nfa=nfa;
- jt9com_.nfb=nfb;
+ jt9com_.nfa=m_wideGraph->nStartFreq();
+ jt9com_.nfSplit=m_wideGraph->getFmin();
+ jt9com_.nfb=m_wideGraph->getFmax();
jt9com_.ntol=20;
- if(jt9com_.nutc < m_nutc0) m_RxLog |= 1; //Date and Time to all.txt
+ if(jt9com_.nutc < m_nutc0) m_RxLog = 1; //Date and Time to all.txt
m_nutc0=jt9com_.nutc;
jt9com_.ntxmode=9;
if(m_modeTx=="JT65") jt9com_.ntxmode=65;
jt9com_.nmode=9;
+ if(m_mode=="JT9W-1") jt9com_.nmode=91;
if(m_mode=="JT65") jt9com_.nmode=65;
- if(m_mode=="JT9+JT65") jt9com_.nmode=9+65;
+ if(m_mode=="JT9+JT65") jt9com_.nmode=9+65; // = 74
jt9com_.ntrperiod=m_TRperiod;
m_nsave=0;
if(m_saveDecoded) m_nsave=2;
@@ -1359,15 +1374,15 @@ void MainWindow::decode() //decode()
}
memcpy(to, from, qMin(mem_jt9->size(), size));
- QFile lockFile(m_appDir + "/.lock"); // Allow jt9 to start
- lockFile.remove();
+ QFile {m_config.temp_dir ().absoluteFilePath (".lock")}.remove (); // Allow jt9 to start
decodeBusy(true);
}
-void MainWindow::jt9_error() //jt9_error
+void MainWindow::jt9_error (QProcess::ProcessError e)
{
if(!m_killAll) {
msgBox("Error starting or running\n" + m_appDir + "/jt9 -s");
+ qDebug() << e; // silence compiler warning
exit(1);
}
}
@@ -1380,157 +1395,117 @@ void MainWindow::readFromStderr() //readFromStderr
void MainWindow::readFromStdout() //readFromStdout
{
- while(proc_jt9.canReadLine()) {
- QByteArray t=proc_jt9.readLine();
- if(t.indexOf("<DecodeFinished>") >= 0) {
- m_bdecoded = (t.mid(23,1).toInt()==1);
- bool keepFile=m_saveAll or (m_saveDecoded and m_bdecoded);
- if(!keepFile and !m_diskData) killFileTimer->start(45*1000); //Kill in 45 s
- jt9com_.nagain=0;
- jt9com_.ndiskdat=0;
- QFile lockFile(m_appDir + "/.lock");
- lockFile.open(QIODevice::ReadWrite);
- ui->DecodeButton->setStyleSheet("");
- decodeBusy(false);
- m_RxLog=0;
- m_startAnother=m_loopall;
- m_blankLine=true;
- return;
- } else {
- QFile f("ALL.TXT");
- f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append);
- QTextStream out(&f);
- if(m_RxLog && 1) {
- out << QDateTime::currentDateTimeUtc().toString("yyyy-MMM-dd hh:mm")
- << " " << m_dialFreq << " MHz " << m_mode << endl;
- m_RxLog=0;
- }
- int n=t.length();
- out << t.mid(0,n-2) << endl;
- f.close();
-
- QTextCursor cursor;
- QTextBlockFormat bf;
- if(m_insertBlank and m_blankLine and jt9com_.nagain==0) {
- QString bg="#d3d3d3";
- bf.setBackground(QBrush(QColor(bg)));
- QString tt="----------------------------------------";
- QString s = "<table border=0 cellspacing=0 width=100%><tr><td bgcolor=\"" +
- bg + "\"><pre>" + tt + "</pre></td></tr></table>";
- cursor = ui->decodedTextBrowser->textCursor();
- cursor.movePosition(QTextCursor::End);
- bf = cursor.blockFormat();
- bf.setBackground(QBrush(QColor(bg)));
- cursor.insertHtml(s);
- m_blankLine=false;
- }
-
- QString bg="white";
- if(t.indexOf(" CQ ")>0) bg="#66ff66"; //green
- if(m_myCall!="" and t.indexOf(" "+m_myCall+" ")>0) bg="#ff6666"; //red
- bool bQSO=abs(t.mid(14,4).toInt() - g_pWideGraph->rxFreq()) <= 10;
- QString t1=t.replace("\n","").mid(0,t.length()-4);
- QString s = "<table border=0 cellspacing=0 width=100%><tr><td bgcolor=\"" +
- bg + "\"><pre>" + t1 + "</pre></td></tr></table>";
- bool b65=t1.indexOf("#")==19;
- if(bQSO) {
- cursor = ui->decodedTextBrowser2->textCursor();
- cursor.movePosition(QTextCursor::End);
- bf = cursor.blockFormat();
- bf.setBackground(QBrush(QColor(bg)));
- cursor.insertHtml(s);
- ui->decodedTextBrowser2->setTextCursor(cursor);
- m_QSOmsg=t1;
- if(b65 and m_modeTx!="JT65") on_pbTxMode_clicked();
- if(!b65 and m_modeTx=="JT65") on_pbTxMode_clicked();
- }
-
- if(jt9com_.nagain==0) {
- if(t.indexOf(" CQ ")>0) bg="#66ff66"; //green
- if(m_myCall!="" and t.indexOf(" "+m_myCall+" ")>0) bg="#ff6666"; //red
- QString s = "<table border=0 cellspacing=0 width=100%><tr><td bgcolor=\"" +
- bg + "\"><pre>" + t1 + "</pre></td></tr></table>";
- cursor = ui->decodedTextBrowser->textCursor();
- cursor.movePosition(QTextCursor::End);
- bf = cursor.blockFormat();
- bf.setBackground(QBrush(QColor(bg)));
- cursor.insertHtml(s);
- ui->decodedTextBrowser->setTextCursor(cursor);
- }
-
- QString msg=t.mid(21);
- int i1=msg.indexOf("\r");
- if(i1>0) msg=msg.mid(0,i1-1) + " ";
- bool b=stdmsg_(msg.mid(0,22).toLatin1().constData(),22);
- QStringList w=msg.split(" ",QString::SkipEmptyParts);
- if(b and w[0]==m_myCall) {
- QString tt="";
- if(w.length()>=3) tt=w[2];
- bool ok;
- i1=tt.toInt(&ok);
- if(ok and i1>=-50 and i1<50) {
- m_rptRcvd=tt;
+ QString band = m_config.bands ()->data (m_config.bands ()->find (m_dialFreq)).toString();
+
+ while(proc_jt9.canReadLine())
+ {
+ QByteArray t=proc_jt9.readLine();
+ if(t.indexOf("<DecodeFinished>") >= 0)
+ {
+ m_bdecoded = (t.mid(23,1).toInt()==1);
+ bool keepFile=m_saveAll or (m_saveDecoded and m_bdecoded);
+ if(!keepFile and !m_diskData) killFileTimer->start(45*1000); //Kill in 45 s
+ jt9com_.nagain=0;
+ jt9com_.ndiskdat=0;
+ QFile {m_config.temp_dir ().absoluteFilePath (".lock")}.open(QIODevice::ReadWrite);
+ ui->DecodeButton->setChecked (false);
+ decodeBusy(false);
+ m_RxLog=0;
+ m_startAnother=m_loopall;
+ m_blankLine=true;
+ return;
} else {
- if(tt.mid(0,1)=="R") {
- i1=tt.mid(1).toInt(&ok);
- if(ok and i1>=-50 and i1<50) {
- m_rptRcvd=tt.mid(1);
+ QFile f {m_dataDir.absoluteFilePath ("ALL.TXT")};
+ if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append))
+ {
+ QTextStream out(&f);
+ if(m_RxLog==1) {
+ out << QDateTime::currentDateTimeUtc().toString("yyyy-MMM-dd hh:mm")
+ << " " << (m_dialFreq / 1.e6) << " MHz " << m_mode << endl;
+ m_RxLog=0;
}
+ int n=t.length();
+ out << t.mid(0,n-2) << endl;
+ f.close();
+ }
+ else
+ {
+ msgBox("Cannot open \"" + f.fileName () + "\" for append:" + f.errorString ());
}
- }
- }
- int nsec=QDateTime::currentMSecsSinceEpoch()/1000-m_secBandChanged;
- bool okToPost=(nsec>50);
- QString msgmode="JT9";
- if(b65) msgmode="JT65";
- i1=msg.indexOf(" ");
- QString c2=msg.mid(i1+1);
- int i2=c2.indexOf(" ");
- QString g2=c2.mid(i2+1,4);
- c2=c2.mid(0,i2);
- QString remote="call," + c2 + ",";
- if(gridOK(g2)) remote += "gridsquare," + g2 + ",";
- int nHz=t.mid(14,4).toInt();
- uint nfreq=1000000.0*m_dialFreq + nHz + 0.5;
- remote += "freq," + QString::number(nfreq);
- int nsnr=t.mid(5,3).toInt();
- remote += ",mode," + msgmode + ",snr," + QString::number(nsnr) + ",,";
- wchar_t tremote[256];
- remote.toWCharArray(tremote);
+ if (m_config.insert_blank () && m_blankLine)
+ {
+ QString band;
+ if (QDateTime::currentMSecsSinceEpoch() / 1000 - m_secBandChanged > 50)
+ {
+ auto const& bands_model = m_config.bands ();
+ band = ' ' + bands_model->data (bands_model->find (m_dialFreq + ui->TxFreqSpinBox->value ())).toString ();
+ }
+ ui->decodedTextBrowser->insertLineSpacer (band.rightJustified (40, '-'));
+ m_blankLine = false;
+ }
-#ifdef WIN32
- if(m_pskReporterInit and b and !m_diskData and okToPost) {
-
- QString local="station_callsign#" + m_myCall + "#" +
- "my_gridsquare#" + m_myGrid + "#";
- if(m_pskAntenna!="") local += "my_antenna#" + m_pskAntenna + "#";
- local += "programid#WSJT-X#programversion#" + rev.mid(6,4) + "##";
- wchar_t tlocal[256];
- local.toWCharArray(tlocal);
-
- int flags=REPORTER_SOURCE_AUTOMATIC;
- rc=ReporterSeenCallsign(tremote,tlocal,flags);
- if(rc!=0) {
- ReporterGetInformation(buffer,256);
- }
- rc=ReporterTickle();
- if(rc!=0) {
- rc=ReporterGetInformation(buffer,256);
- }
- }
-#else
- if(m_pskReporter and b and !m_diskData and okToPost) {
- QString freq = QString::number(nfreq);
- QString snr= QString::number(nsnr);
- if(gridOK(g2)) {
- psk_Reporter->addRemoteStation(c2,g2,freq,msgmode,snr,
- QString::number(QDateTime::currentDateTime().toTime_t()));
- }
+ DecodedText decodedtext;
+ decodedtext = t.replace("\n",""); //t.replace("\n","").mid(0,t.length()-4);
+
+ // the left band display
+ ui->decodedTextBrowser->displayDecodedText (decodedtext
+ , m_baseCall
+ , m_config.DXCC ()
+ , m_logBook
+ , m_config.color_CQ()
+ , m_config.color_MyCall()
+ , m_config.color_DXCC()
+ , m_config.color_NewCall());
+
+ if (abs(decodedtext.frequencyOffset() - m_wideGraph->rxFreq()) <= 10) // this msg is within 10 hertz of our tuned frequency
+ {
+ // the right QSO window
+ ui->decodedTextBrowser2->displayDecodedText(decodedtext
+ , m_baseCall
+ , false
+ , m_logBook
+ , m_config.color_CQ()
+ , m_config.color_MyCall()
+ , m_config.color_DXCC()
+ , m_config.color_NewCall());
+
+ bool b65=decodedtext.isJT65();
+ if(b65 and m_modeTx!="JT65") on_pbTxMode_clicked();
+ if(!b65 and m_modeTx=="JT65") on_pbTxMode_clicked();
+ m_QSOText=decodedtext;
+ }
+
+ postDecode (true, decodedtext.string ());
+
+ // find and extract any report for myCall
+ bool stdMsg = decodedtext.report(m_baseCall
+ , Radio::base_callsign (ui->dxCallEntry-> text ().toUpper ().trimmed ())
+ , /*mod*/m_rptRcvd);
+
+ // extract details and send to PSKreporter
+ int nsec=QDateTime::currentMSecsSinceEpoch()/1000-m_secBandChanged;
+ bool okToPost=(nsec>50);
+ if(m_config.spot_to_psk_reporter () and stdMsg and !m_diskData and okToPost)
+ {
+ QString msgmode="JT9";
+ if (decodedtext.isJT65())
+ msgmode="JT65";
+
+ QString deCall;
+ QString grid;
+ decodedtext.deCallAndGrid(/*out*/deCall,grid);
+ int audioFrequency = decodedtext.frequencyOffset();
+ int snr = decodedtext.snr();
+ Frequency frequency = m_dialFreq + audioFrequency;
+
+ pskSetLocal ();
+ if(gridOK(grid))
+ psk_Reporter->addRemoteStation(deCall,grid,QString::number(frequency),msgmode,QString::number(snr),
+ QString::number(QDateTime::currentDateTime().toTime_t()));
+ }
}
-#endif
}
- }
}
void MainWindow::killFile()
@@ -1546,17 +1521,43 @@ void MainWindow::on_EraseButton_clicked() //Erase
{
qint64 ms=QDateTime::currentMSecsSinceEpoch();
ui->decodedTextBrowser2->clear();
- m_QSOmsg="";
+ m_QSOText.clear();
if((ms-m_msErase)<500) {
- ui->decodedTextBrowser->clear();
- QFile f(m_appDir + "/decoded.txt");
- if(f.exists()) f.remove();
+ ui->decodedTextBrowser->clear();
+ m_messageClient->clear_decodes ();
+ QFile f(m_config.temp_dir ().absoluteFilePath ("decoded.txt"));
+ if(f.exists()) f.remove();
}
m_msErase=ms;
}
void MainWindow::decodeBusy(bool b) //decodeBusy()
{
+ bool showProgress = false;
+ if (b && m_firstDecode < 65 && ("JT65" == m_mode || "JT9+JT65" == m_mode))
+ {
+ m_firstDecode += 65;
+ if ("JT9+JT65" == m_mode) m_firstDecode = 65 + 9;
+ showProgress = true;
+ }
+ if (b && m_firstDecode != 9 && m_firstDecode != 65 + 9 && ("JT9" == m_mode || "JT9W-1" == m_mode))
+ {
+ m_firstDecode += 9;
+ showProgress = true;
+ }
+ if (showProgress)
+ {
+ // this sequence is needed to create an indeterminate progress
+ // bar
+ m_optimizingProgress.setRange (0, 1);
+ m_optimizingProgress.setValue (0);
+ m_optimizingProgress.setRange (0, 0);
+ }
+ if (!b)
+ {
+ m_optimizingProgress.reset ();
+ }
+
m_decoderBusy=b;
ui->DecodeButton->setEnabled(!b);
ui->actionOpen->setEnabled(!b);
@@ -1572,10 +1573,7 @@ void MainWindow::guiUpdate()
static char message[29];
static char msgsent[29];
static int nsendingsh=0;
- static int giptt00=-1;
- static int gcomport00=-1;
static double onAirFreq0=0.0;
- int ret=0;
QString rt;
double tx1=0.0;
@@ -1592,335 +1590,336 @@ void MainWindow::guiUpdate()
double t2p=fmod(tsec,2*m_TRperiod);
bool bTxTime = ((t2p >= tx1) and (t2p < tx2)) or m_tune;
- if(m_auto or m_tune) {
- QFile f("txboth");
+ if(m_transmitting || m_auto || m_tune) {
+
+ QFile f(m_config.temp_dir ().absoluteFilePath ("txboth"));
if(f.exists() and fmod(tsec,m_TRperiod) < (1.0 + 85.0*m_nsps/12000.0)) {
bTxTime=true;
}
- double onAirFreq=m_dialFreq+1.e-6*m_txFreq;
- if(onAirFreq>10.139900 and onAirFreq<10.140320) {
- bTxTime=false;
- if(m_tune) on_tuneButton_clicked();
- if(onAirFreq!=onAirFreq0) {
- onAirFreq0=onAirFreq;
- on_autoButton_clicked();
- QString t="Please choose another Tx frequency.\n";
- t+="WSJT-X will not knowingly transmit\n";
- t+="in the WSPR sub-band on 30 m.";
- msgBox0.setText(t);
- msgBox0.show();
+ Frequency onAirFreq = m_dialFreq + ui->TxFreqSpinBox->value ();
+ if (onAirFreq > 10139900 && onAirFreq < 10140320)
+ {
+ bTxTime=false;
+ if (m_tune)
+ {
+ stop_tuning ();
+ }
+
+ if (m_auto)
+ {
+ auto_tx_mode (false);
+ }
+
+ if(onAirFreq!=onAirFreq0)
+ {
+ onAirFreq0=onAirFreq;
+ QString t="Please choose another Tx frequency.\n";
+ t+="WSJT-X will not knowingly transmit\n";
+ t+="in the WSPR sub-band on 30 m.";
+ msgBox(t);
+ }
}
- }
float fTR=float((nsec%m_TRperiod))/m_TRperiod;
- if(g_iptt==0 and ((bTxTime and !btxMute and fTR<0.4) or m_tune )) {
+ if(g_iptt==0 and ((bTxTime and fTR<0.4) or m_tune )) {
icw[0]=m_ncw;
-
-//Raise PTT
- if(m_catEnabled and m_bRigOpen and m_pttMethodIndex==0) {
- g_iptt=1;
- if(m_pttData) ret=rig->setPTT(RIG_PTT_ON_DATA, RIG_VFO_CURR);
- if(!m_pttData) ret=rig->setPTT(RIG_PTT_ON_MIC, RIG_VFO_CURR);
- if(ret!=RIG_OK) {
- rt.sprintf("CAT control PTT failed: %d",ret);
- msgBox(rt);
- }
-
- }
-
- if(m_pttMethodIndex==1 or m_pttMethodIndex==2) { //DTR or RTS
- ptt(m_pttPort,1,&g_iptt,&g_COMportOpen);
- }
- if(m_pttMethodIndex==3) { //VOX
- g_iptt=1;
- }
+ g_iptt = 1;
+ setXIT (ui->TxFreqSpinBox->value ()); // ensure correct offset
+ Q_EMIT m_config.transceiver_ptt (true);
ptt1Timer->start(200); //Sequencer delay
}
- if(!bTxTime || btxMute) {
- btxok=false;
+
+ if(!bTxTime) {
+ m_btxok=false;
}
}
-// Calculate Tx tones when needed
+ // Calculate Tx tones when needed
if((g_iptt==1 && iptt0==0) || m_restart) {
QByteArray ba;
if(m_ntx == 1) ba=ui->tx1->text().toLocal8Bit();
if(m_ntx == 2) ba=ui->tx2->text().toLocal8Bit();
if(m_ntx == 3) ba=ui->tx3->text().toLocal8Bit();
if(m_ntx == 4) ba=ui->tx4->text().toLocal8Bit();
- if(m_ntx == 5) ba=ui->tx5->text().toLocal8Bit();
+ if(m_ntx == 5) ba=ui->tx5->currentText().toLocal8Bit();
if(m_ntx == 6) ba=ui->tx6->text().toLocal8Bit();
if(m_ntx == 7) ba=ui->genMsg->text().toLocal8Bit();
- if(m_ntx == 8) ba=ui->freeTextMsg->text().toLocal8Bit();
+ if(m_ntx == 8) ba=ui->freeTextMsg->currentText().toLocal8Bit();
ba2msg(ba,message);
-// ba2msg(ba,msgsent);
+ // ba2msg(ba,msgsent);
int len1=22;
- int ichk=0,itext=0;
- if(m_modeTx=="JT9") genjt9_(message,&ichk,msgsent,itone,&itext,len1,len1);
- if(m_modeTx=="JT65") gen65_(message,&ichk,msgsent,itone,&itext,len1,len1);
+ int ichk=0;
+ if (m_lastMessageSent != m_currentMessage
+ || m_lastMessageType != m_currentMessageType)
+ {
+ m_lastMessageSent = m_currentMessage;
+ m_lastMessageType = m_currentMessageType;
+ }
+ m_currentMessageType = 0;
+ if(m_modeTx=="JT9") genjt9_(message
+ , &ichk
+ , msgsent
+ , const_cast<int *> (itone)
+ , &m_currentMessageType
+ , len1
+ , len1);
+ if(m_modeTx=="JT65") gen65_(message
+ , &ichk
+ , msgsent
+ , const_cast<int *> (itone)
+ , &m_currentMessageType
+ , len1
+ , len1);
msgsent[22]=0;
- QString t=QString::fromLatin1(msgsent);
- if(m_tune) t="TUNE";
- lab2->setText("Last Tx: " + t);
+ m_currentMessage = QString::fromLatin1(msgsent);
+ if (m_tune)
+ {
+ m_currentMessage = "TUNE";
+ m_currentMessageType = -1;
+ }
+ last_tx_label->setText("Last Tx: " + m_currentMessage);
if(m_restart) {
- QFile f("ALL.TXT");
- f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append);
- QTextStream out(&f);
- out << QDateTime::currentDateTimeUtc().toString("hhmm")
- << " Transmitting " << m_dialFreq << " MHz " << m_modeTx
- << ": " << t << endl;
- f.close();
- if(m_tx2QSO) displayTxMsg(t);
+ QFile f {m_dataDir.absoluteFilePath ("ALL.TXT")};
+ if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append))
+ {
+ QTextStream out(&f);
+ out << QDateTime::currentDateTimeUtc().toString("hhmm")
+ << " Transmitting " << (m_dialFreq / 1.e6) << " MHz " << m_modeTx
+ << ": " << m_currentMessage << endl;
+ f.close();
+ }
+ else
+ {
+ msgBox("Cannot open \"" + f.fileName () + "\" for append:" + f.errorString ());
+ }
+ if (m_config.TX_messages ())
+ {
+ ui->decodedTextBrowser2->displayTransmittedText(m_currentMessage,m_modeTx,
+ ui->TxFreqSpinBox->value(),m_config.color_TxMsg());
+ }
}
- QStringList w=t.split(" ",QString::SkipEmptyParts);
- t="";
- if(w.length()==3) t=w[2];
- icw[0]=0;
- m_sent73=(t=="73" or itext!=0);
- if(m_sent73) {
- if(m_After73) icw[0]=m_ncw;
- if(m_promptToLog and !m_tune) logQSOTimer->start(200);
- }
+ auto t2 = QDateTime::currentDateTimeUtc ().toString ("hhmm");
+ icw[0] = 0;
+ auto msg_parts = m_currentMessage.split (' ', QString::SkipEmptyParts);
+ auto is_73 = message_is_73 (m_currentMessageType, msg_parts);
+ m_sentFirst73 = is_73
+ && !message_is_73 (m_lastMessageType, m_lastMessageSent.split (' ', QString::SkipEmptyParts));
+ if (m_sentFirst73)
+ {
+ m_qsoStop=t2;
+ if(m_config.id_after_73 ())
+ {
+ icw[0] = m_ncw;
+ }
+ if (m_config.prompt_to_log () && !m_tune)
+ {
+ logQSOTimer->start (0);
+ }
+ }
+ if (is_73 && m_config.disable_TX_on_73 ())
+ {
+ auto_tx_mode (false);
+ }
- if(m_idInt>0) {
+ if(m_config.id_interval () >0) {
int nmin=(m_sec0-m_secID)/60;
- if(nmin >= m_idInt) {
+ if(nmin >= m_config.id_interval ()) {
icw[0]=m_ncw;
m_secID=m_sec0;
}
}
- QString t2=QDateTime::currentDateTimeUtc().toString("hhmm");
- if(itext==0 and w.length()>=3 and w[1]==m_myCall) {
- int i1;
- bool ok;
- i1=t.toInt(&ok);
- if(ok and i1>=-50 and i1<50) {
- m_rptSent=t;
- m_qsoStart=t2;
- } else {
- if(t.mid(0,1)=="R") {
- i1=t.mid(1).toInt(&ok);
- if(ok and i1>=-50 and i1<50) {
- m_rptSent=t.mid(1);
- m_qsoStart=t2;
+ if (m_currentMessageType < 6 && msg_parts.length() >= 3
+ && (msg_parts[1] == m_config.my_callsign () || msg_parts[1] == m_baseCall))
+ {
+ int i1;
+ bool ok;
+ i1 = msg_parts[2].toInt(&ok);
+ if(ok and i1>=-50 and i1<50)
+ {
+ m_rptSent = msg_parts[2];
+ m_qsoStart = t2;
+ }
+ else
+ {
+ if (msg_parts[2].mid (0, 1) == "R")
+ {
+ i1 = msg_parts[2].mid (1).toInt (&ok);
+ if (ok and i1 >= -50 and i1 < 50)
+ {
+ m_rptSent = msg_parts[2].mid (1);
+ m_qsoStart = t2;
+ }
+ }
}
- }
}
- }
- if(itext==1 or (w.length()==3 and w[2]=="73")) m_qsoStop=t2;
m_restart=false;
}
+ else
+ {
+ if (!m_auto && m_sentFirst73)
+ {
+ m_sentFirst73 = false;
+ if (1 == ui->tabWidget->currentIndex())
+ {
+ ui->genMsg->setText(ui->tx6->text());
+ m_ntx=7;
+ ui->rbGenMsg->setChecked(true);
+ }
+ else
+ {
+ m_ntx=6;
+ ui->txrb6->setChecked(true);
+ }
+ }
+ }
+ if (g_iptt == 1 && iptt0 == 0)
+ {
+ QString t=QString::fromLatin1(msgsent);
+ if(t==m_msgSent0)
+ {
+ m_repeatMsg++;
+ }
+ else
+ {
+ m_repeatMsg=0;
+ m_msgSent0=t;
+ }
-// If PTT was just raised, start a countdown for raising TxOK:
-// NB: could be better implemented with a timer
- if(g_iptt == 1 && iptt0 == 0) {
- nc1=-9; // TxDelay = 0.8 s
- }
- if(nc1 <= 0) {
- nc1++;
- }
- if(nc1 == 0) {
- QString t=QString::fromLatin1(msgsent);
- if(t==m_msgSent0) {
- m_repeatMsg++;
- } else {
- m_repeatMsg=0;
- m_msgSent0=t;
- }
+ if(!m_tune)
+ {
+ QFile f {m_dataDir.absoluteFilePath ("ALL.TXT")};
+ if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append))
+ {
+ QTextStream out(&f);
+ out << QDateTime::currentDateTimeUtc().toString("hhmm")
+ << " Transmitting " << (m_dialFreq / 1.e6) << " MHz " << m_modeTx
+ << ": " << m_currentMessage << endl;
+ f.close();
+ }
+ else
+ {
+ msgBox("Cannot open \"" + f.fileName () + "\" for append:" + f.errorString ());
+ }
+ }
- signalMeter->setValue(0);
- m_monitoring=false;
- soundInThread.setMonitoring(false);
- btxok=true;
- m_transmitting=true;
- ui->pbTxMode->setEnabled(false);
- if(!m_tune) {
- QFile f("ALL.TXT");
- f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append);
- QTextStream out(&f);
- out << QDateTime::currentDateTimeUtc().toString("hhmm")
- << " Transmitting " << m_dialFreq << " MHz " << m_modeTx
- << ": " << t << endl;
- f.close();
+ if (m_config.TX_messages () && !m_tune)
+ {
+ ui->decodedTextBrowser2->displayTransmittedText(t,m_modeTx,
+ ui->TxFreqSpinBox->value(),m_config.color_TxMsg());
+ }
+
+ m_transmitting = true;
+ transmitDisplay (true);
+ m_messageClient->status_update (m_dialFreq, m_mode, m_hisCall, QString::number (ui->rptSpinBox->value ()), m_modeTx, ui->autoButton->isChecked (), m_transmitting);
}
- if(m_tx2QSO and !m_tune) displayTxMsg(t);
- }
- if(!btxok && btxok0 && g_iptt==1) stopTx();
+ if(!m_btxok && btxok0 && g_iptt==1) stopTx();
-/*
-// If btxok was just lowered, start a countdown for lowering PTT
- if(!btxok && btxok0 && g_iptt==1) nc0=-11; //RxDelay = 1.0 s
+ /*
+ // If m_btxok was just lowered, start a countdown for lowering PTT
+ if(!m_btxok && btxok0 && g_iptt==1) nc0=-11; //RxDelay = 1.0 s
if(nc0 <= 0) {
- nc0++;
- }
-*/
-
- if(m_monitoring) {
- ui->monitorButton->setStyleSheet(m_pbmonitor_style);
- } else {
- ui->monitorButton->setStyleSheet("");
+ nc0++;
}
+ */
if(m_startAnother) {
m_startAnother=false;
on_actionOpen_next_in_directory_triggered();
}
- if(m_catEnabled and !m_bRigOpen) {
- rigOpen();
- }
-
if(nsec != m_sec0) { //Once per second
QDateTime t = QDateTime::currentDateTimeUtc();
+ int fQSO=125;
+ if(m_astroWidget) m_astroWidget->astroUpdate(t, m_config.my_grid (), m_hisGrid, fQSO,
+ m_setftx, ui->TxFreqSpinBox->value ());
+
if(m_transmitting) {
if(nsendingsh==1) {
- lab1->setStyleSheet("QLabel{background-color: #66ffff}");
+ tx_status_label->setStyleSheet("QLabel{background-color: #66ffff}");
} else if(nsendingsh==-1) {
- lab1->setStyleSheet("QLabel{background-color: #ffccff}");
+ tx_status_label->setStyleSheet("QLabel{background-color: #ffccff}");
} else {
- lab1->setStyleSheet("QLabel{background-color: #ffff33}");
+ tx_status_label->setStyleSheet("QLabel{background-color: #ffff33}");
}
if(m_tune) {
- lab1->setText("Tx: TUNE");
+ tx_status_label->setText("Tx: TUNE");
} else {
- char s[37];
- sprintf(s,"Tx: %s",msgsent);
- lab1->setText(s);
+ char s[37];
+ sprintf(s,"Tx: %s",msgsent);
+ tx_status_label->setText(s);
}
} else if(m_monitoring) {
- lab1->setStyleSheet("QLabel{background-color: #00ff00}");
- lab1->setText("Receiving ");
+ tx_status_label->setStyleSheet("QLabel{background-color: #00ff00}");
+ tx_status_label->setText("Receiving ");
} else if (!m_diskData) {
- lab1->setStyleSheet("");
- lab1->setText("");
+ tx_status_label->setStyleSheet("");
+ tx_status_label->setText("");
}
m_setftx=0;
QString utc = t.date().toString("yyyy MMM dd") + "\n " +
- t.time().toString() + " ";
+ t.time().toString() + " ";
ui->labUTC->setText(utc);
if(!m_monitoring and !m_diskData) {
signalMeter->setValue(0);
}
- if(m_catEnabled and m_poll>0 and (nsec%m_poll)==0 and !m_decoderBusy) {
- double fMHz;
- if(m_dontReadFreq) {
- m_dontReadFreq=false;
- } else if(!m_transmitting) {
- for(int iter=0; iter<3; iter++) {
- fMHz=rig->getFreq(RIG_VFO_CURR)/1000000.0;
- if(fMHz<0.0 and iter>=2) {
- rt.sprintf("Rig control error %d\nFailed to read frequency.",
- int(1000000.0*fMHz));
- msgBox(rt);
- m_catEnabled=false;
- ui->readFreq->setStyleSheet("QPushButton{background-color: red; \
- border-width: 0px; border-radius: 5px;}");
- }
- }
- int ndiff=1000000.0*(fMHz-m_dialFreq);
- if(ndiff!=0) dialFreqChanged2(fMHz);
- }
- }
-
m_sec0=nsec;
}
- if(g_iptt!=giptt00 or g_COMportOpen!=gcomport00) {
- giptt00=g_iptt;
- gcomport00=g_COMportOpen;
- }
-
iptt0=g_iptt;
- btxok0=btxok;
+ btxok0=m_btxok;
} //End of GUIupdate
-void MainWindow::displayTxMsg(QString t)
-{
- QString bg="yellow";
- QTextBlockFormat bf;
- QTextCursor cursor;
- QString t1=" @ ";
- if(m_modeTx=="JT65") t1=" # ";
- QString t2;
- t2.sprintf("%4d",m_txFreq);
- t=QDateTime::currentDateTimeUtc().toString("hhmm") + \
- " Tx " + t2 + t1 + t;
- QString s = "<table border=0 cellspacing=0 width=100%><tr><td bgcolor=\"" +
- bg + "\"><pre>" + t + "</pre></td></tr></table>";
- cursor = ui->decodedTextBrowser2->textCursor();
- cursor.movePosition(QTextCursor::End);
- bf = cursor.blockFormat();
- bf.setBackground(QBrush(QColor(bg)));
- cursor.insertHtml(s);
- ui->decodedTextBrowser2->setTextCursor(cursor);
-}
void MainWindow::startTx2()
{
- if(!soundOutThread.isRunning()) {
- QString t=ui->tx6->text();
- double snr=t.mid(1,5).toDouble();
+ if (!m_modulator.isActive ()) {
+ double fSpread=0.0;
+ double snr=99.0;
+ QString t=ui->tx5->currentText();
+ if(t.mid(0,1)=="#") fSpread=t.mid(1,5).toDouble();
+ m_modulator.setSpread(fSpread);
+ t=ui->tx6->text();
+ if(t.mid(0,1)=="#") snr=t.mid(1,5).toDouble();
if(snr>0.0 or snr < -50.0) snr=99.0;
- soundOutThread.setTxSNR(snr);
- soundOutThread.m_modeTx=m_modeTx;
- soundOutThread.start(QThread::HighestPriority);
+ transmit (snr);
signalMeter->setValue(0);
- m_monitoring=false;
- soundInThread.setMonitoring(false);
- btxok=true;
- m_transmitting=true;
- ui->pbTxMode->setEnabled(false);
}
}
void MainWindow::stopTx()
{
- if (soundOutThread.isRunning()) {
- soundOutThread.quitExecution=true;
- soundOutThread.wait(3000);
- }
- m_transmitting=false;
- ui->pbTxMode->setEnabled(true);
+ Q_EMIT endTransmitMessage ();
+ m_btxok = false;
+ m_transmitting = false;
g_iptt=0;
- lab1->setStyleSheet("");
- lab1->setText("");
+ tx_status_label->setStyleSheet("");
+ tx_status_label->setText("");
ptt0Timer->start(200); //Sequencer delay
- m_monitoring=true;
- soundInThread.setMonitoring(true);
+ monitor (true);
+ m_messageClient->status_update (m_dialFreq, m_mode, m_hisCall, QString::number (ui->rptSpinBox->value ()), m_modeTx, ui->autoButton->isChecked (), m_transmitting);
}
void MainWindow::stopTx2()
{
- int ret=0;
QString rt;
-//Lower PTT
- if(m_catEnabled and m_bRigOpen and m_pttMethodIndex==0) {
- ret=rig->setPTT(RIG_PTT_OFF, RIG_VFO_CURR); //CAT control for PTT=0
- if(ret!=RIG_OK) {
- rt.sprintf("CAT control PTT failed: %d",ret);
- msgBox(rt);
- }
- }
- if(m_pttMethodIndex==1 or m_pttMethodIndex==2) {
- ptt(m_pttPort,0,&g_iptt,&g_COMportOpen);
- }
- if(m_73TxDisable and m_sent73) on_stopTxButton_clicked();
+ //Lower PTT
+ Q_EMIT m_config.transceiver_ptt (false);
- if(m_runaway and m_repeatMsg>m_watchdogLimit) {
- on_stopTxButton_clicked();
- msgBox0.setText("Runaway Tx watchdog");
- msgBox0.show();
- m_repeatMsg=0;
- }
+ if (m_config.watchdog () && m_repeatMsg>=m_watchdogLimit-1)
+ {
+ on_stopTxButton_clicked();
+ msgBox("Runaway Tx watchdog");
+ m_repeatMsg=0;
+ }
}
void MainWindow::ba2msg(QByteArray ba, char message[]) //ba2msg()
@@ -1950,47 +1949,46 @@ void MainWindow::on_txb1_clicked() //txb1
{
m_ntx=1;
ui->txrb1->setChecked(true);
- m_restart=true;
+ if (m_transmitting) m_restart=true;
}
void MainWindow::on_txb2_clicked() //txb2
{
m_ntx=2;
ui->txrb2->setChecked(true);
- m_restart=true;
+ if (m_transmitting) m_restart=true;
}
void MainWindow::on_txb3_clicked() //txb3
{
m_ntx=3;
ui->txrb3->setChecked(true);
- m_restart=true;
+ if (m_transmitting) m_restart=true;
}
void MainWindow::on_txb4_clicked() //txb4
{
m_ntx=4;
ui->txrb4->setChecked(true);
- m_restart=true;
+ if (m_transmitting) m_restart=true;
}
void MainWindow::on_txb5_clicked() //txb5
{
m_ntx=5;
ui->txrb5->setChecked(true);
- m_restart=true;
+ if (m_transmitting) m_restart=true;
}
void MainWindow::on_txb6_clicked() //txb6
{
m_ntx=6;
ui->txrb6->setChecked(true);
- m_restart=true;
+ if (m_transmitting) m_restart=true;
}
void MainWindow::doubleClickOnCall2(bool shift, bool ctrl)
{
-
m_decodedText2=true;
doubleClickOnCall(shift,ctrl);
m_decodedText2=false;
@@ -2002,153 +2000,254 @@ void MainWindow::doubleClickOnCall(bool shift, bool ctrl)
if(!m_decodedText2) cursor=ui->decodedTextBrowser2->textCursor();
if(m_decodedText2) cursor=ui->decodedTextBrowser->textCursor();
cursor.select(QTextCursor::LineUnderCursor);
- int i2=cursor.position();
- if(shift and i2==-9999) return; //Silence compiler warning
+ int position {cursor.position()};
+ if(shift && position==-9999) return; //Silence compiler warning
- QString t;
- if(!m_decodedText2) t= ui->decodedTextBrowser2->toPlainText(); //Full contents
- if(m_decodedText2) t= ui->decodedTextBrowser->toPlainText();
+ QString messages;
+ if(!m_decodedText2) messages= ui->decodedTextBrowser2->toPlainText();
+ //Full contents
+ if(m_decodedText2) messages= ui->decodedTextBrowser->toPlainText();
- QString t1 = t.mid(0,i2); //contents up to \n on selected line
+ processMessage(messages, position, ctrl);
+}
+
+void MainWindow::processMessage(QString const& messages, int position, bool ctrl)
+{
+ QString t1 = messages.mid(0,position); //contents up to \n on selected line
int i1=t1.lastIndexOf("\n") + 1; //points to first char of line
- QString t2 = t1.mid(i1,i2-i1); //selected line
-// if(t2.indexOf("Tx")==6) return; //Ignore Tx line
- int i4=t.mid(i1).length();
- if(i4>55) i4=55;
- QString t3=t.mid(i1,i4);
- int i5=t3.indexOf(" CQ DX ");
- if(i5>0) t3=t3.mid(0,i5+3) + "_" + t3.mid(i5+4); //Make it "CQ_DX" (one word)
- QStringList t4=t3.split(" ",QString::SkipEmptyParts);
- if(t4.length() <5) return; //Skip the rest if no decoded text
-
- int i9=m_QSOmsg.indexOf(t2);
- if(i9<0 and t2.indexOf("Tx")==-1) {
- QString bg="white";
- if(t2.indexOf(" CQ ")>0) bg="#66ff66"; //green
- if(m_myCall!="" and t2.indexOf(" "+m_myCall+" ")>0) bg="#ff6666"; //red
- QTextBlockFormat bf;
- QString s = "<table border=0 cellspacing=0 width=100%><tr><td bgcolor=\"" +
- bg + "\"><pre>" + t2 + "</pre></td></tr></table>";
- cursor = ui->decodedTextBrowser2->textCursor();
- cursor.movePosition(QTextCursor::End);
- bf = cursor.blockFormat();
- bf.setBackground(QBrush(QColor(bg)));
- cursor.insertHtml(s);
- ui->decodedTextBrowser2->setTextCursor(cursor);
- m_QSOmsg=t2;
- }
+ DecodedText decodedtext;
+ decodedtext = messages.mid(i1,position-i1); //selected line
+
+ if (decodedtext.indexOf(" CQ ") > 0)
+ {
+ // TODO this magic 36 characters is also referenced in DisplayText::_appendDXCCWorkedB4()
+ auto eom_pos = decodedtext.string ().indexOf (' ', 35);
+ if (eom_pos < 35) eom_pos = decodedtext.string ().size () - 1; // we always want at least the characters
+ // to position 35
+ decodedtext = decodedtext.string ().left (eom_pos + 1); // remove DXCC entity and worked B4 status. TODO need a better way to do this
+ }
- int nfreq=t4.at(3).toInt();
- if(t4.at(1)=="Tx") nfreq=t4.at(2).toInt();
- g_pWideGraph->setRxFreq(nfreq); //Set Rx freq
- if(t4.at(1)=="Tx") {
- if(ctrl) ui->TxFreqSpinBox->setValue(nfreq); //Set Tx freq
- return;
- }
- if(t4.at(4)=="@") {
- m_modeTx="JT9";
- ui->pbTxMode->setText("Tx JT9 @");
- g_pWideGraph->setModeTx(m_modeTx);
- }
- if(t4.at(4)=="#") {
- m_modeTx="JT65";
- ui->pbTxMode->setText("Tx JT65 #");
- g_pWideGraph->setModeTx(m_modeTx);
- }
- QString firstcall=t4.at(5);
+
+ // if(decodedtext.indexOf("Tx")==6) return; //Ignore Tx line
+ // int i4=t.mid(i1).length();
+ // if(i4>55) i4=55;
+ // QString t3=t.mid(i1,i4);
+ auto t3 = decodedtext.string ();
+ auto t4 = t3.replace (" CQ DX ", " CQ_DX ").split (" ", QString::SkipEmptyParts);
+ if(t4.size () < 6) return; //Skip the rest if no decoded text
+
+ QString hiscall;
+ QString hisgrid;
+ decodedtext.deCallAndGrid(/*out*/hiscall,hisgrid);
+ if (!Radio::is_callsign (hiscall) // not interested if not from QSO partner
+ && !(t4.size () == 7 // unless it is of the form
+ && (t4.at (5) == m_baseCall // "<our-call> 73"
+ || t4.at (5).startsWith (m_baseCall + '/')
+ || t4.at (5).endsWith ('/' + m_baseCall))
+ && t4.at (6) == "73"))
+ {
+ qDebug () << "Not processing message - hiscall:" << hiscall << "hisgrid:" << hisgrid;
+ return;
+ }
+
+ // only allow automatic mode changes when not transmitting
+ if (!m_transmitting)
+ {
+ if (decodedtext.isJT9())
+ {
+ m_modeTx="JT9";
+ ui->pbTxMode->setText("Tx JT9 @");
+ m_wideGraph->setModeTx(m_modeTx);
+ }
+ else if (decodedtext.isJT65())
+ {
+ m_modeTx="JT65";
+ ui->pbTxMode->setText("Tx JT65 #");
+ m_wideGraph->setModeTx(m_modeTx);
+ }
+ }
+ else if ((decodedtext.isJT9 () && m_modeTx != "JT9") || (decodedtext.isJT65 () && m_modeTx != "JT65"))
+ {
+ // if we are not allowing mode change then don't process decode
+ return;
+ }
+
+ int frequency = decodedtext.frequencyOffset();
+ QString firstcall = decodedtext.call();
// Don't change Tx freq if a station is calling me, unless m_lockTxFreq
- // is true or CTRL is held down or
- if((firstcall!=m_myCall) or m_lockTxFreq or ctrl) {
- ui->TxFreqSpinBox->setValue(nfreq);
- }
- QString hiscall=t4.at(6);
- QString hisgrid="";
- if(t4.length()>=8) hisgrid=t4.at(7);
- if(hiscall!=ui->dxCallEntry->text()) ui->dxGridEntry->setText("");
- ui->dxCallEntry->setText(hiscall);
- if(gridOK(hisgrid)) ui->dxGridEntry->setText(hisgrid);
- if(ui->dxGridEntry->text()=="") lookup();
- m_hisGrid=ui->dxGridEntry->text();
- int n = 60*t2.mid(0,2).toInt() + t2.mid(2,2).toInt();
+ // is true or CTRL is held down
+ if ((firstcall!=m_config.my_callsign () && firstcall != m_baseCall) || m_lockTxFreq or ctrl)
+ {
+ if (ui->TxFreqSpinBox->isEnabled ())
+ {
+ ui->TxFreqSpinBox->setValue(frequency);
+ }
+ else
+ {
+ return;
+ }
+ }
+
+ int i9=m_QSOText.indexOf(decodedtext.string());
+ if (i9<0 and !decodedtext.isTX())
+ {
+ ui->decodedTextBrowser2->displayDecodedText(decodedtext
+ , m_baseCall
+ , false
+ , m_logBook
+ , m_config.color_CQ()
+ , m_config.color_MyCall()
+ , m_config.color_DXCC()
+ , m_config.color_NewCall());
+ m_QSOText=decodedtext;
+ }
+
+ if (ui->RxFreqSpinBox->isEnabled ())
+ {
+ ui->RxFreqSpinBox->setValue (frequency); //Set Rx freq
+ }
+ if (decodedtext.isTX())
+ {
+ if (ctrl && ui->TxFreqSpinBox->isEnabled ())
+ {
+ ui->TxFreqSpinBox->setValue(frequency); //Set Tx freq
+ }
+ return;
+ }
+
+ // prior DX call (possible QSO partner)
+ auto qso_partner_base_call = Radio::base_callsign (ui->dxCallEntry-> text ().toUpper ().trimmed ());
+
+ auto base_call = Radio::base_callsign (hiscall);
+ if (base_call != Radio::base_callsign (ui->dxCallEntry-> text ().toUpper ().trimmed ()) || base_call != hiscall)
+ {
+ // his base call different or his call more qualified
+ // i.e. compound version of same base call
+ ui->dxCallEntry->setText(hiscall);
+ }
+ if (gridOK(hisgrid))
+ ui->dxGridEntry->setText(hisgrid);
+ if (ui->dxGridEntry->text()=="")
+ lookup();
+ m_hisGrid = ui->dxGridEntry->text();
+
+ int n = decodedtext.timeInSeconds();
int nmod=n%(m_TRperiod/30);
m_txFirst=(nmod!=0);
ui->txFirstCheckBox->setChecked(m_txFirst);
- QString rpt=t4.at(1);
- if(rpt.indexOf(" ")==0) rpt="+" + rpt.mid(2,2);
- if(rpt.indexOf(" -")==0) rpt=rpt.mid(1,2);
- if(rpt.indexOf(" ")==0) rpt="+" + rpt.mid(1,2);
- int nr=rpt.toInt();
- if(nr<-50) rpt="-50";
- if(nr>49) rpt="+49";
- if(nr>=-9 and nr<=-1) rpt="-0" + rpt.mid(1);
- if(nr>=0 and nr<=9) rpt="+0" + rpt;
- if(nr>=10) rpt="+" + rpt;
+
+ QString rpt = decodedtext.report();
ui->rptSpinBox->setValue(rpt.toInt());
genStdMsgs(rpt);
- if(t2.indexOf(m_myCall)>=0) {
- if(t4.length()>=7 and !gridOK(t4.at(7))) {
- QString r=t4.at(7);
- if(r.mid(0,3)=="RRR") {
+
+ // determine the appropriate response to the received msg
+ auto dtext = " " + decodedtext.string () + " ";
+ if(dtext.contains (" " + m_baseCall + " ")
+ || dtext.contains ("/" + m_baseCall + " ")
+ || dtext.contains (" " + m_baseCall + "/")
+ || (firstcall == "DE" && ((t4.size () > 7 && t4.at(7) != "73") || t4.size () <= 7)))
+ {
+ if (t4.size () > 7 // enough fields for a normal msg
+ and !gridOK (t4.at (7))) // but no grid on end of msg
+ {
+ QString r=t4.at (7);
+ if(r.mid(0,3)=="RRR" || (r.toInt()==73)) {
+ m_ntx=5;
+ ui->txrb5->setChecked(true);
+ if(ui->tabWidget->currentIndex()==1) {
+ ui->genMsg->setText(ui->tx5->currentText());
+ m_ntx=7;
+ ui->rbGenMsg->setChecked(true);
+ }
+ } else if(r.mid(0,1)=="R") {
+ m_ntx=4;
+ ui->txrb4->setChecked(true);
+ if(ui->tabWidget->currentIndex()==1) {
+ ui->genMsg->setText(ui->tx4->text());
+ m_ntx=7;
+ ui->rbGenMsg->setChecked(true);
+ }
+ } else if(r.toInt()>=-50 and r.toInt()<=49) {
+ m_ntx=3;
+ ui->txrb3->setChecked(true);
+ if(ui->tabWidget->currentIndex()==1) {
+ ui->genMsg->setText(ui->tx3->text());
+ m_ntx=7;
+ ui->rbGenMsg->setChecked(true);
+ }
+ }
+ }
+ else if (t4.size () == 7 && t4.at (6) == "73") {
+ // 73 back to compound call holder
m_ntx=5;
ui->txrb5->setChecked(true);
if(ui->tabWidget->currentIndex()==1) {
- ui->genMsg->setText(ui->tx5->text());
- m_ntx=7;
- ui->rbGenMsg->setChecked(true);
- }
- } else if(r.mid(0,1)=="R") {
- m_ntx=4;
- ui->txrb4->setChecked(true);
- if(ui->tabWidget->currentIndex()==1) {
- ui->genMsg->setText(ui->tx4->text());
- m_ntx=7;
- ui->rbGenMsg->setChecked(true);
- }
- } else if(r.toInt()>=-50 and r.toInt()<=49) {
- m_ntx=3;
- ui->txrb3->setChecked(true);
- if(ui->tabWidget->currentIndex()==1) {
- ui->genMsg->setText(ui->tx3->text());
+ ui->genMsg->setText(ui->tx5->currentText());
m_ntx=7;
ui->rbGenMsg->setChecked(true);
}
- } else if(r.toInt()==73) {
- m_ntx=5;
- ui->txrb5->setChecked(true);
+ }
+ else {
+ m_ntx=2;
+ ui->txrb2->setChecked(true);
if(ui->tabWidget->currentIndex()==1) {
- ui->genMsg->setText(ui->tx5->text());
+ ui->genMsg->setText(ui->tx2->text());
m_ntx=7;
ui->rbGenMsg->setChecked(true);
}
}
- } else {
- m_ntx=2;
- ui->txrb2->setChecked(true);
+ }
+ else if (firstcall == "DE" && t4.size () == 8 && t4.at (7) == "73") {
+ if (base_call == qso_partner_base_call) {
+ // 73 back to compound call holder
+ m_ntx=5;
+ ui->txrb5->setChecked(true);
if(ui->tabWidget->currentIndex()==1) {
- ui->genMsg->setText(ui->tx2->text());
+ ui->genMsg->setText(ui->tx5->currentText());
m_ntx=7;
ui->rbGenMsg->setChecked(true);
}
}
-
- } else {
- m_ntx=1;
- ui->txrb1->setChecked(true);
- if(ui->tabWidget->currentIndex()==1) {
- ui->genMsg->setText(ui->tx1->text());
- m_ntx=7;
- ui->rbGenMsg->setChecked(true);
+ else {
+ // treat like a CQ/QRZ
+ m_ntx=1;
+ ui->txrb1->setChecked(true);
+ if(ui->tabWidget->currentIndex()==1) {
+ ui->genMsg->setText(ui->tx1->text());
+ m_ntx=7;
+ ui->rbGenMsg->setChecked(true);
+ }
}
}
- if(m_quickCall) {
- m_auto=true;
- ui->autoButton->setStyleSheet(m_pbAutoOn_style);
- }
+ else // myCall not in msg
+ {
+ m_ntx=1;
+ ui->txrb1->setChecked(true);
+ if(ui->tabWidget->currentIndex()==1) {
+ ui->genMsg->setText(ui->tx1->text());
+ m_ntx=7;
+ ui->rbGenMsg->setChecked(true);
+ }
+ }
+ if(m_transmitting) m_restart=true;
+ if(m_config.quick_call ())
+ {
+ auto_tx_mode (true);
+ }
}
void MainWindow::genStdMsgs(QString rpt) //genStdMsgs()
{
QString t;
+ if(m_config.my_callsign () !="" and m_config.my_grid () !="")
+ {
+ t="CQ " + m_config.my_callsign () + " " + m_config.my_grid ().mid(0,4);
+ msgtype(t, ui->tx6);
+ }
+ else
+ {
+ ui->tx6->setText("");
+ }
QString hisCall=ui->dxCallEntry->text().toUpper().trimmed();
ui->dxCallEntry->setText(hisCall);
if(hisCall=="") {
@@ -2158,28 +2257,21 @@ void MainWindow::genStdMsgs(QString rpt) //genStdMsgs()
ui->tx2->setText("");
ui->tx3->setText("");
ui->tx4->setText("");
- ui->tx5->setText("");
- ui->tx6->setText("");
- if(m_myCall!="" and m_myGrid!="") {
- t="CQ " + m_myCall + " " + m_myGrid.mid(0,4);
- msgtype(t, ui->tx6);
- }
+ ui->tx5->setCurrentText("");
ui->genMsg->setText("");
- ui->freeTextMsg->setText("");
return;
}
- QString hisBase=baseCall(hisCall);
- QString myBase=baseCall(m_myCall);
- QString t0=hisBase + " " + myBase + " ";
- t=t0 + m_myGrid.mid(0,4);
- if(myBase!=m_myCall) t="DE " + m_myCall + " " + m_myGrid.mid(0,4);
+ QString hisBase = Radio::base_callsign (hisCall);
+
+ QString t0=hisBase + " " + m_baseCall + " ";
+ t=t0 + m_config.my_grid ().mid(0,4);
msgtype(t, ui->tx1);
if(rpt == "") {
t=t+" OOO";
msgtype(t, ui->tx2);
msgtype("RO", ui->tx3);
msgtype("RRR", ui->tx4);
- msgtype("73", ui->tx5);
+ msgtype("73", ui->tx5->lineEdit ());
} else {
t=t0 + rpt;
msgtype(t, ui->tx2);
@@ -2188,59 +2280,92 @@ void MainWindow::genStdMsgs(QString rpt) //genStdMsgs()
t=t0 + "RRR";
msgtype(t, ui->tx4);
t=t0 + "73";
- if(myBase!=m_myCall) t="DE " + m_myCall + " 73";
- msgtype(t, ui->tx5);
+ msgtype(t, ui->tx5->lineEdit ());
}
- t="CQ " + m_myCall + " " + m_myGrid.mid(0,4);
- msgtype(t, ui->tx6);
+ if(m_config.my_callsign () != m_baseCall) {
+ if(shortList(m_config.my_callsign ())) {
+ t=hisBase + " " + m_config.my_callsign ();
+ msgtype(t, ui->tx1);
+ t="CQ " + m_config.my_callsign ();
+ msgtype(t, ui->tx6);
+ } else {
+ switch (m_config.type_2_msg_gen ())
+ {
+ case Configuration::type_2_msg_1_full:
+ t="DE " + m_config.my_callsign () + " " + m_config.my_grid ().mid(0,4);
+ msgtype(t, ui->tx1);
+ t=t0 + "R" + rpt;
+ msgtype(t, ui->tx3);
+ break;
+
+ case Configuration::type_2_msg_3_full:
+ t = t0 + m_config.my_grid ().mid(0,4);
+ msgtype(t, ui->tx1);
+ t="DE " + m_config.my_callsign () + " R" + rpt;
+ msgtype(t, ui->tx3);
+ break;
+
+ case Configuration::type_2_msg_5_only:
+ t = t0 + m_config.my_grid ().mid(0,4);
+ msgtype(t, ui->tx1);
+ t=t0 + "R" + rpt;
+ msgtype(t, ui->tx3);
+ break;
+ }
+ t="DE " + m_config.my_callsign () + " 73";
+ msgtype(t, ui->tx5->lineEdit ());
+ }
+ } else {
+ if(hisCall!=hisBase) {
+ if(shortList(hisCall)) {
+ t=hisBase + " " + m_config.my_callsign () + " " + m_config.my_grid ().mid (0,4);
+ msgtype(t, ui->tx1);
+ }
+ t=hisCall + " 73";
+ msgtype(t, ui->tx5->lineEdit());
+ }
+ }
m_ntx=1;
ui->txrb1->setChecked(true);
m_rpt=rpt;
}
-QString MainWindow::baseCall(QString t)
-{
- int n1=t.indexOf("/");
- if(n1<0) return t;
- int n2=t.length()-n1-1;
- if(n2>=n1) return t.mid(n1+1);
- return t.mid(0,n1);
-}
-
void MainWindow::lookup() //lookup()
{
QString hisCall=ui->dxCallEntry->text().toUpper().trimmed();
+ if (hisCall.isEmpty ())
+ {
+ return;
+ }
ui->dxCallEntry->setText(hisCall);
- QString call3File = m_appDir + "/CALL3.TXT";
- QFile f(call3File);
- if(!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
- msgBox("Cannot open " + call3File);
- return;
- }
- char c[132];
- qint64 n=0;
- for(int i=0; i<999999; i++) {
- n=f.readLine(c,sizeof(c));
- if(n <= 0) {
- ui->dxGridEntry->setText("");
- break;
- }
- QString t=QString(c);
- if(t.indexOf(hisCall)==0) {
- int i1=t.indexOf(",");
- QString hisgrid=t.mid(i1+1,6);
- i1=hisgrid.indexOf(",");
- if(i1>0) {
- hisgrid=hisgrid.mid(0,4);
- } else {
- hisgrid=hisgrid.mid(0,4) + hisgrid.mid(4,2).toLower();
+ QFile f {m_dataDir.absoluteFilePath ("CALL3.TXT")};
+ if (f.open (QIODevice::ReadOnly | QIODevice::Text))
+ {
+ char c[132];
+ qint64 n=0;
+ for(int i=0; i<999999; i++) {
+ n=f.readLine(c,sizeof(c));
+ if(n <= 0) {
+ ui->dxGridEntry->setText("");
+ break;
+ }
+ QString t=QString(c);
+ if(t.indexOf(hisCall)==0) {
+ int i1=t.indexOf(",");
+ QString hisgrid=t.mid(i1+1,6);
+ i1=hisgrid.indexOf(",");
+ if(i1>0) {
+ hisgrid=hisgrid.mid(0,4);
+ } else {
+ hisgrid=hisgrid.mid(0,4) + hisgrid.mid(4,2).toLower();
+ }
+ ui->dxGridEntry->setText(hisgrid);
+ break;
+ }
}
- ui->dxGridEntry->setText(hisgrid);
- break;
+ f.close();
}
- }
- f.close();
}
void MainWindow::on_lookupButton_clicked() //Lookup button
@@ -2259,61 +2384,54 @@ void MainWindow::on_addButton_clicked() //Add button
QString hisgrid=ui->dxGridEntry->text().trimmed();
QString newEntry=hisCall + "," + hisgrid;
-// int ret = QMessageBox::warning(this, "Add",
-// newEntry + "\n" + "Is this station known to be active on EME?",
-// QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
-// if(ret==QMessageBox::Yes) {
-// newEntry += ",EME,,";
-// } else {
- newEntry += ",,,";
-// }
-
- QString call3File = m_appDir + "/CALL3.TXT";
- QFile f1(call3File);
- if(!f1.open(QIODevice::ReadOnly | QIODevice::Text)) {
- msgBox("Cannot open " + call3File);
+ // int ret = QMessageBox::warning(this, "Add",
+ // newEntry + "\n" + "Is this station known to be active on EME?",
+ // QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
+ // if(ret==QMessageBox::Yes) {
+ // newEntry += ",EME,,";
+ // } else {
+ newEntry += ",,,";
+ // }
+
+ QFile f1 {m_dataDir.absoluteFilePath ("CALL3.TXT")};
+ if(!f1.open(QIODevice::ReadWrite | QIODevice::Text)) {
+ msgBox("Cannot open \"" + f1.fileName () + "\" for read/write:" + f1.errorString ());
return;
}
if(f1.size()==0) {
- f1.close();
- f1.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream out(&f1);
out << "ZZZZZZ" << endl;
f1.close();
f1.open(QIODevice::ReadOnly | QIODevice::Text);
}
- QString tmpFile = m_appDir + "/CALL3.TMP";
- QFile f2(tmpFile);
+ QFile f2 {m_dataDir.absoluteFilePath ("CALL3.TMP")};
if(!f2.open(QIODevice::WriteOnly | QIODevice::Text)) {
- msgBox("Cannot open " + tmpFile);
+ msgBox("Cannot open \"" + f2.fileName () + "\" for writing:" + f2.errorString ());
return;
}
- QTextStream in(&f1);
- QTextStream out(&f2);
+ QTextStream in(&f1); //Read from CALL3.TXT
+ QTextStream out(&f2); //Copy into CALL3.TMP
QString hc=hisCall;
QString hc1="";
- QString hc2="AAAAAA";
+ QString hc2="000000";
QString s;
do {
s=in.readLine();
hc1=hc2;
if(s.mid(0,2)=="//") {
- out << s + "\n";
+ out << s + "\n"; //Copy all comment lines
} else {
int i1=s.indexOf(",");
hc2=s.mid(0,i1);
if(hc>hc1 && hc<hc2) {
out << newEntry + "\n";
- if(s.mid(0,6)=="ZZZZZZ") {
- out << s + "\n";
-// exit; //Statement has no effect!
- }
+ out << s + "\n";
m_call3Modified=true;
} else if(hc==hc2) {
QString t=s + "\n\n is already in CALL3.TXT\n" +
- "Do you wish to replace it?";
+ "Do you wish to replace it?";
int ret = QMessageBox::warning(this, "Add",t,
- QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
+ QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if(ret==QMessageBox::Yes) {
out << newEntry + "\n";
m_call3Modified=true;
@@ -2325,15 +2443,13 @@ void MainWindow::on_addButton_clicked() //Add button
} while(!s.isNull());
f1.close();
- if(hc>hc1 && !m_call3Modified) {
- out << newEntry + "\n";
- }
+ if(hc>hc1 && !m_call3Modified) out << newEntry + "\n";
if(m_call3Modified) {
- QFile f0(m_appDir + "/CALL3.OLD");
+ QFile f0 {m_dataDir.absoluteFilePath ("CALL3.OLD")};
if(f0.exists()) f0.remove();
- QFile f1(m_appDir + "/CALL3.TXT");
- f1.rename(m_appDir + "/CALL3.OLD");
- f2.rename(m_appDir + "/CALL3.TXT");
+ QFile f1 {m_dataDir.absoluteFilePath ("CALL3.TXT")};
+ f1.rename(m_dataDir.absoluteFilePath ("CALL3.OLD"));
+ f2.rename(m_dataDir.absoluteFilePath ("CALL3.TXT"));
f2.close();
}
}
@@ -2347,11 +2463,17 @@ void MainWindow::msgtype(QString t, QLineEdit* tx) //msgtype()
t=t.toUpper();
QByteArray s=t.toUpper().toLocal8Bit();
ba2msg(s,message);
- int ichk=1,itext=0;
- genjt9_(message,&ichk,msgsent,itone,&itext,len1,len1);
+ int ichk=1,itype=0;
+ genjt9_(message
+ , &ichk
+ , msgsent
+ , const_cast<int *> (itone)
+ , &itype
+ , len1
+ , len1);
msgsent[22]=0;
bool text=false;
- if(itext!=0) text=true;
+ if(itype==6) text=true;
QString t1;
t1.fromLatin1(msgsent);
if(text) t1=t1.mid(0,13);
@@ -2363,12 +2485,14 @@ void MainWindow::msgtype(QString t, QLineEdit* tx) //msgtype()
}
tx->setPalette(p);
int len=t.length();
+ auto pos = tx->cursorPosition ();
if(text) {
len=qMin(len,13);
tx->setText(t.mid(0,len).toUpper());
} else {
tx->setText(t);
}
+ tx->setCursorPosition (pos);
}
void MainWindow::on_tx1_editingFinished() //tx1 edited
@@ -2395,19 +2519,22 @@ void MainWindow::on_tx4_editingFinished() //tx4 edited
msgtype(t, ui->tx4);
}
-void MainWindow::on_tx5_editingFinished() //tx5 edited
+void MainWindow::on_tx5_currentTextChanged (QString const& text) //tx5 edited
{
- QString t=ui->tx5->text();
- msgtype(t, ui->tx5);
+ msgtype(text, ui->tx5->lineEdit ());
}
void MainWindow::on_tx6_editingFinished() //tx6 edited
{
QString t=ui->tx6->text();
msgtype(t, ui->tx6);
- double snr=t.mid(1,5).toDouble();
- if(snr>0.0 or snr < -50.0) snr=99.0;
- soundOutThread.setTxSNR(snr);
+
+ // G4WJS: disabled setting of snr from msg 6 on live edit, will
+ // still generate noise on next full tx period
+
+ // double snr=t.mid(1,5).toDouble();
+ // if(snr>0.0 or snr < -50.0) snr=99.0;
+ // m_modulator.setTxSNR(snr);
}
void MainWindow::on_dxCallEntry_textChanged(const QString &t) //dxCall changed
@@ -2429,20 +2556,26 @@ void MainWindow::on_dxGridEntry_textChanged(const QString &t) //dxGrid changed
if(!t[2].isDigit() or !t[3].isDigit()) return;
if(n==4) m_hisGrid=t.mid(0,2).toUpper() + t.mid(2,2);
if(n==6) m_hisGrid=t.mid(0,2).toUpper() + t.mid(2,2) +
- t.mid(4,2).toLower();
+ t.mid(4,2).toLower();
ui->dxGridEntry->setText(m_hisGrid);
if(gridOK(m_hisGrid)) {
qint64 nsec = QDateTime::currentMSecsSinceEpoch() % 86400;
double utch=nsec/3600.0;
int nAz,nEl,nDmiles,nDkm,nHotAz,nHotABetter;
- azdist_(m_myGrid.toLatin1().data(),m_hisGrid.toLatin1().data(),&utch,
- &nAz,&nEl,&nDmiles,&nDkm,&nHotAz,&nHotABetter,6,6);
+ azdist_(const_cast <char *> (m_config.my_grid ().toLatin1().constData()),const_cast<char *> (m_hisGrid.toLatin1().constData()),&utch,
+ &nAz,&nEl,&nDmiles,&nDkm,&nHotAz,&nHotABetter,6,6);
QString t;
t.sprintf("Az: %d",nAz);
ui->labAz->setText(t);
- if(m_bMiles) t.sprintf("%d mi",int(0.621371*nDkm));
- if(!m_bMiles) t.sprintf("%d km",nDkm);
+ if (m_config.miles ())
+ {
+ t.sprintf ("%d mi", int (0.621371 * nDkm));
+ }
+ else
+ {
+ t.sprintf ("%d km", nDkm);
+ }
ui->labDist->setText(t);
} else {
ui->labAz->setText("");
@@ -2460,28 +2593,35 @@ void MainWindow::on_logQSOButton_clicked() //Log QSO button
if(m_hisCall=="") return;
m_dateTimeQSO=QDateTime::currentDateTimeUtc();
- logDlg = new LogQSO(0);
- logDlg->m_saveTxPower=m_saveTxPower;
- logDlg->m_saveComments=m_saveComments;
- logDlg->m_txPower=m_txPower;
- logDlg->m_comments=m_logComments;
- logDlg->initLogQSO(m_hisCall,m_hisGrid,m_modeTx,m_rptSent,m_rptRcvd,
- m_dateTimeQSO,m_dialFreq+m_txFreq/1.0e6,
- m_myCall,m_myGrid,m_noSuffix,m_toRTTY,m_dBtoComments);
- connect(logDlg, SIGNAL(acceptQSO(bool)),this,SLOT(acceptQSO2(bool)));
- if(m_logQSOgeom != QRect(500,400,424,283)) logDlg->setGeometry(m_logQSOgeom);
- logDlg->show();
-}
-
-void MainWindow::acceptQSO2(bool accepted)
-{
- if(accepted) {
- m_logQSOgeom=logDlg->geometry();
- m_saveTxPower=logDlg->m_saveTxPower;
- m_saveComments=logDlg->m_saveComments;
- m_txPower=logDlg->m_txPower;
- m_logComments=logDlg->m_comments;
- if(m_clearCallGrid) {
+ m_logDlg->initLogQSO (m_hisCall
+ , m_hisGrid
+ , m_modeTx
+ , m_rptSent
+ , m_rptRcvd
+ , m_dateTimeQSO
+ , m_dialFreq + ui->TxFreqSpinBox->value ()
+ , m_config.my_callsign ()
+ , m_config.my_grid ()
+ , m_noSuffix
+ , m_config.log_as_RTTY ()
+ , m_config.report_in_comments ()
+ );
+}
+
+void MainWindow::acceptQSO2(QDateTime const& QSO_date, QString const& call, QString const& grid
+ , Frequency dial_freq, QString const& mode
+ , QString const& rpt_sent, QString const& rpt_received
+ , QString const& tx_power, QString const& comments
+ , QString const& name)
+{
+ QString band = ADIF::bandFromFrequency ((m_dialFreq + ui->TxFreqSpinBox->value ()) / 1.e6);
+ QString date = m_dateTimeQSO.toString("yyyyMMdd");
+ m_logBook.addAsWorked(m_hisCall,band,m_modeTx,date);
+
+ m_messageClient->qso_logged (QSO_date, call, grid, dial_freq, mode, rpt_sent, rpt_received, tx_power, comments, name);
+
+ if (m_config.clear_DX ())
+ {
m_hisCall="";
ui->dxCallEntry->setText("");
m_hisGrid="";
@@ -2491,7 +2631,6 @@ void MainWindow::acceptQSO2(bool accepted)
m_qsoStart="";
m_qsoStop="";
}
- }
}
void MainWindow::on_actionJT9_1_triggered()
@@ -2502,14 +2641,31 @@ void MainWindow::on_actionJT9_1_triggered()
m_TRperiod=60;
m_nsps=6912;
m_hsymStop=173;
- soundInThread.setPeriod(m_TRperiod,m_nsps);
- soundOutThread.setPeriod(m_TRperiod,m_nsps);
- lab3->setStyleSheet("QLabel{background-color: #ff6ec7}");
- lab3->setText(m_mode);
+ mode_label->setStyleSheet("QLabel{background-color: #ff6ec7}");
+ mode_label->setText(m_mode);
+ m_toneSpacing=0.0;
ui->actionJT9_1->setChecked(true);
- g_pWideGraph->setPeriod(m_TRperiod,m_nsps);
- g_pWideGraph->setMode(m_mode);
- g_pWideGraph->setModeTx(m_modeTx);
+ m_wideGraph->setPeriod(m_TRperiod,m_nsps);
+ m_wideGraph->setMode(m_mode);
+ m_wideGraph->setModeTx(m_modeTx);
+ ui->pbTxMode->setEnabled(false);
+}
+
+void MainWindow::on_actionJT9W_1_triggered()
+{
+ m_mode="JT9W-1";
+ if(m_modeTx!="JT9") on_pbTxMode_clicked();
+ statusChanged();
+ m_TRperiod=60;
+ m_nsps=6912;
+ m_hsymStop=173;
+ m_toneSpacing=pow(2,m_config.jt9w_bw_mult ())*12000.0/6912.0;
+ mode_label->setStyleSheet("QLabel{background-color: #ff6ec7}");
+ mode_label->setText(m_mode);
+ ui->actionJT9W_1->setChecked(true);
+ m_wideGraph->setPeriod(m_TRperiod,m_nsps);
+ m_wideGraph->setMode(m_mode);
+ m_wideGraph->setModeTx(m_modeTx);
ui->pbTxMode->setEnabled(false);
}
@@ -2521,49 +2677,49 @@ void MainWindow::on_actionJT65_triggered()
m_TRperiod=60;
m_nsps=6912; //For symspec only
m_hsymStop=173;
- soundInThread.setPeriod(m_TRperiod,m_nsps);
- soundOutThread.setPeriod(m_TRperiod,m_nsps);
- lab3->setStyleSheet("QLabel{background-color: #ffff00}");
- lab3->setText(m_mode);
+ m_toneSpacing=0.0;
+ mode_label->setStyleSheet("QLabel{background-color: #ffff00}");
+ mode_label->setText(m_mode);
ui->actionJT65->setChecked(true);
- g_pWideGraph->setPeriod(m_TRperiod,m_nsps);
- g_pWideGraph->setMode(m_mode);
- g_pWideGraph->setModeTx(m_modeTx);
+ m_wideGraph->setPeriod(m_TRperiod,m_nsps);
+ m_wideGraph->setMode(m_mode);
+ m_wideGraph->setModeTx(m_modeTx);
ui->pbTxMode->setEnabled(false);
}
void MainWindow::on_actionJT9_JT65_triggered()
{
m_mode="JT9+JT65";
-// if(m_modeTx!="JT9") on_pbTxMode_clicked();
+ // if(m_modeTx!="JT9") on_pbTxMode_clicked();
statusChanged();
m_TRperiod=60;
m_nsps=6912;
m_hsymStop=173;
- soundInThread.setPeriod(m_TRperiod,m_nsps);
- soundOutThread.setPeriod(m_TRperiod,m_nsps);
- lab3->setStyleSheet("QLabel{background-color: #ffa500}");
- lab3->setText(m_mode);
+ m_toneSpacing=0.0;
+ mode_label->setStyleSheet("QLabel{background-color: #ffa500}");
+ mode_label->setText(m_mode);
ui->actionJT9_JT65->setChecked(true);
- g_pWideGraph->setPeriod(m_TRperiod,m_nsps);
- g_pWideGraph->setMode(m_mode);
- g_pWideGraph->setModeTx(m_modeTx);
+ m_wideGraph->setPeriod(m_TRperiod,m_nsps);
+ m_wideGraph->setMode(m_mode);
+ m_wideGraph->setModeTx(m_modeTx);
ui->pbTxMode->setEnabled(true);
}
void MainWindow::on_TxFreqSpinBox_valueChanged(int n)
{
- m_txFreq=n;
- if(g_pWideGraph!=NULL) g_pWideGraph->setTxFreq(n);
+ m_wideGraph->setTxFreq(n);
if(m_lockTxFreq) ui->RxFreqSpinBox->setValue(n);
- soundOutThread.setTxFreq(n);
+ Q_EMIT transmitFrequency (n - m_XIT);
}
void MainWindow::on_RxFreqSpinBox_valueChanged(int n)
{
- m_rxFreq=n;
- if(g_pWideGraph!=NULL) g_pWideGraph->setRxFreq(n);
- if(m_lockTxFreq) ui->TxFreqSpinBox->setValue(n);
+ m_wideGraph->setRxFreq(n);
+
+ if (m_lockTxFreq && ui->TxFreqSpinBox->isEnabled ())
+ {
+ ui->TxFreqSpinBox->setValue (n);
+ }
}
void MainWindow::on_actionQuickDecode_triggered()
@@ -2589,18 +2745,13 @@ void MainWindow::on_inGain_valueChanged(int n)
m_inGain=n;
}
-void MainWindow::on_actionMonitor_OFF_at_startup_triggered()
-{
- m_monitorStartOFF=!m_monitorStartOFF;
-}
-
void MainWindow::on_actionErase_ALL_TXT_triggered() //Erase ALL.TXT
{
int ret = QMessageBox::warning(this, "Confirm Erase",
- "Are you sure you want to erase file ALL.TXT ?",
- QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
+ "Are you sure you want to erase file ALL.TXT ?",
+ QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if(ret==QMessageBox::Yes) {
- QFile f("ALL.TXT");
+ QFile f {m_dataDir.absoluteFilePath ("ALL.TXT")};
f.remove();
m_RxLog=1;
}
@@ -2609,153 +2760,99 @@ void MainWindow::on_actionErase_ALL_TXT_triggered() //Erase ALL.TXT
void MainWindow::on_actionErase_wsjtx_log_adi_triggered()
{
int ret = QMessageBox::warning(this, "Confirm Erase",
- "Are you sure you want to erase file wsjtx_log.adi ?",
- QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
+ "Are you sure you want to erase file wsjtx_log.adi ?",
+ QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if(ret==QMessageBox::Yes) {
- QFile f("wsjtx_log.adi");
+ QFile f {m_dataDir.absoluteFilePath ("wsjtx_log.adi")};
f.remove();
}
}
-void MainWindow::showMacros(const QPoint &pos)
-{
- if(m_macro.length()<10) return;
- QPoint globalPos = ui->tx5->mapToGlobal(pos);
- QMenu popupMenu;
- QAction* popup1 = new QAction(m_macro[0],ui->tx5);
- QAction* popup2 = new QAction(m_macro[1],ui->tx5);
- QAction* popup3 = new QAction(m_macro[2],ui->tx5);
- QAction* popup4 = new QAction(m_macro[3],ui->tx5);
- QAction* popup5 = new QAction(m_macro[4],ui->tx5);
- QAction* popup6 = new QAction(m_macro[5],ui->tx5);
- QAction* popup7 = new QAction(m_macro[6],ui->tx5);
- QAction* popup8 = new QAction(m_macro[7],ui->tx5);
- QAction* popup9 = new QAction(m_macro[8],ui->tx5);
- QAction* popup10 = new QAction(m_macro[9],ui->tx5);
-
- if(m_macro[0]!="") popupMenu.addAction(popup1);
- if(m_macro[1]!="") popupMenu.addAction(popup2);
- if(m_macro[2]!="") popupMenu.addAction(popup3);
- if(m_macro[3]!="") popupMenu.addAction(popup4);
- if(m_macro[4]!="") popupMenu.addAction(popup5);
- if(m_macro[5]!="") popupMenu.addAction(popup6);
- if(m_macro[6]!="") popupMenu.addAction(popup7);
- if(m_macro[7]!="") popupMenu.addAction(popup8);
- if(m_macro[8]!="") popupMenu.addAction(popup9);
- if(m_macro[9]!="") popupMenu.addAction(popup10);
-
- connect(popup1,SIGNAL(triggered()), this, SLOT(onPopup1()));
- connect(popup2,SIGNAL(triggered()), this, SLOT(onPopup2()));
- connect(popup3,SIGNAL(triggered()), this, SLOT(onPopup3()));
- connect(popup4,SIGNAL(triggered()), this, SLOT(onPopup4()));
- connect(popup5,SIGNAL(triggered()), this, SLOT(onPopup5()));
- connect(popup6,SIGNAL(triggered()), this, SLOT(onPopup6()));
- connect(popup7,SIGNAL(triggered()), this, SLOT(onPopup7()));
- connect(popup8,SIGNAL(triggered()), this, SLOT(onPopup8()));
- connect(popup9,SIGNAL(triggered()), this, SLOT(onPopup9()));
- connect(popup10,SIGNAL(triggered()), this, SLOT(onPopup10()));
- popupMenu.exec(globalPos);
-}
-
-void MainWindow::onPopup1() { ui->tx5->setText(m_macro[0]); freeText(); }
-void MainWindow::onPopup2() { ui->tx5->setText(m_macro[1]); freeText(); }
-void MainWindow::onPopup3() { ui->tx5->setText(m_macro[2]); freeText(); }
-void MainWindow::onPopup4() { ui->tx5->setText(m_macro[3]); freeText(); }
-void MainWindow::onPopup5() { ui->tx5->setText(m_macro[4]); freeText(); }
-void MainWindow::onPopup6() { ui->tx5->setText(m_macro[5]); freeText(); }
-void MainWindow::onPopup7() { ui->tx5->setText(m_macro[6]); freeText(); }
-void MainWindow::onPopup8() { ui->tx5->setText(m_macro[7]); freeText(); }
-void MainWindow::onPopup9() { ui->tx5->setText(m_macro[8]); freeText(); }
-void MainWindow::onPopup10() { ui->tx5->setText(m_macro[9]); freeText(); }
-
-void MainWindow::freeText() { ui->freeTextMsg->setText(ui->tx5->text()); }
+void MainWindow::on_actionOpen_log_directory_triggered ()
+{
+ QDesktopServices::openUrl (QUrl::fromLocalFile (m_dataDir.absolutePath ()));
+}
bool MainWindow::gridOK(QString g)
{
bool b=g.mid(0,1).compare("A")>=0 and
- g.mid(0,1).compare("R")<=0 and
- g.mid(1,1).compare("A")>=0 and
- g.mid(1,1).compare("R")<=0 and
- g.mid(2,1).compare("0")>=0 and
- g.mid(2,1).compare("9")<=0 and
- g.mid(3,1).compare("0")>=0 and
- g.mid(3,1).compare("9")<=0;
+ g.mid(0,1).compare("R")<=0 and
+ g.mid(1,1).compare("A")>=0 and
+ g.mid(1,1).compare("R")<=0 and
+ g.mid(2,1).compare("0")>=0 and
+ g.mid(2,1).compare("9")<=0 and
+ g.mid(3,1).compare("0")>=0 and
+ g.mid(3,1).compare("9")<=0;
return b;
}
-void MainWindow::on_actionConvert_JT9_x_to_RTTY_triggered(bool checked)
+void MainWindow::on_bandComboBox_activated (int index)
{
- m_toRTTY=checked;
-}
+ auto frequencies = m_config.frequencies ();
+ auto frequency = frequencies->data (frequencies->index (index, 0));
-void MainWindow::on_actionLog_JT9_without_submode_triggered(bool checked)
-{
- m_noSuffix=checked;
-}
+ // Lookup band
+ auto bands = m_config.bands ();
+ auto band_index = bands->find (frequency);
+ if (band_index.isValid ())
+ {
+ ui->bandComboBox->lineEdit ()->setStyleSheet ({});
+ ui->bandComboBox->setCurrentText (band_index.data ().toString ());
+ }
+ else
+ {
+ ui->bandComboBox->lineEdit ()->setStyleSheet ("QLineEdit {color: yellow; background-color : red;}");
+ ui->bandComboBox->setCurrentText (bands->data (QModelIndex {}).toString ());
+ }
-void MainWindow::on_actionLog_dB_reports_to_Comments_triggered(bool checked)
-{
- m_dBtoComments=checked;
+ auto f = frequency.value<Frequency> ();
+ if (m_plus2kHz)
+ {
+ f += 2000;
+ }
+
+ m_bandEdited = true;
+ band_changed (f);
}
-void MainWindow::on_bandComboBox_activated(int index)
+void MainWindow::band_changed (Frequency f)
{
- int ret=0;
- QString rt;
+ if (m_bandEdited)
+ {
+ m_bandEdited = false;
- m_band=index;
- QString t=m_dFreq[index];
- m_dialFreq=t.toDouble();
- if(m_plus2kHz) m_dialFreq+=0.002;
- dialFreqChanged2(m_dialFreq);
- m_repeatMsg=0;
- m_secBandChanged=QDateTime::currentMSecsSinceEpoch()/1000;
- if(m_catEnabled) {
- if(!m_bRigOpen) {
- rigOpen();
- }
- if(m_bRigOpen) {
- m_dontReadFreq=true;
- ret=rig->setFreq(MHz(m_dialFreq));
- if(m_bSplit or m_bXIT) setXIT(m_txFreq);
-
- if(g_pWideGraph!=NULL) {
- bumpFqso(11);
- bumpFqso(12);
- }
- if(ret!=RIG_OK) {
- rt.sprintf("Set rig frequency failed: %d",ret);
- msgBox(rt);
- }
- }
- }
- QFile f2("ALL.TXT");
- f2.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append);
- QTextStream out(&f2);
- out << QDateTime::currentDateTimeUtc().toString("yyyy-MMM-dd hh:mm")
- << " " << m_dialFreq << " MHz " << m_mode << endl;
- f2.close();
-}
+ // Upload any queued spots before changing band
+ psk_Reporter->sendReport();
-void MainWindow::on_actionPrompt_to_log_QSO_triggered(bool checked)
-{
- m_promptToLog=checked;
-}
+ if (!m_transmitting)
+ {
+ monitor (true);
+ }
-void MainWindow::on_actionBlank_line_between_decoding_periods_triggered(bool checked)
-{
- m_insertBlank=checked;
+ Q_EMIT m_config.transceiver_frequency (f);
+ qsy (f);
+ setXIT (ui->TxFreqSpinBox->value ());
+ }
}
-void MainWindow::on_actionClear_DX_Call_and_Grid_after_logging_triggered(bool checked)
+void MainWindow::enable_DXCC_entity (bool on)
{
- m_clearCallGrid=checked;
-}
+ if (on)
+ {
+ // re-read the log and cty.dat files
+ m_logBook.init();
+ }
-void MainWindow::on_actionDisplay_distance_in_miles_triggered(bool checked)
-{
- m_bMiles=checked;
- on_dxGridEntry_textChanged(m_hisGrid);
+ if (on) // adjust the proportions between the two text displays
+ {
+ ui->gridLayout->setColumnStretch(0,55);
+ ui->gridLayout->setColumnStretch(1,45);
+ }
+ else
+ {
+ ui->gridLayout->setColumnStretch(0,0);
+ ui->gridLayout->setColumnStretch(1,0);
+ }
}
void MainWindow::on_pbCallCQ_clicked()
@@ -2770,7 +2867,11 @@ void MainWindow::on_pbCallCQ_clicked()
void MainWindow::on_pbAnswerCaller_clicked()
{
genStdMsgs(m_rpt);
- ui->genMsg->setText(ui->tx2->text());
+ QString t=ui->tx3->text();
+ int i0=t.indexOf(" R-");
+ if(i0<0) i0=t.indexOf(" R+");
+ t=t.mid(0,i0+1)+t.mid(i0+2,3);
+ ui->genMsg->setText(t);
m_ntx=7;
ui->rbGenMsg->setChecked(true);
if(m_transmitting) m_restart=true;
@@ -2789,6 +2890,10 @@ void MainWindow::on_pbAnswerCQ_clicked()
{
genStdMsgs(m_rpt);
ui->genMsg->setText(ui->tx1->text());
+ QString t=ui->tx2->text();
+ int i0=t.indexOf("/");
+ int i1=t.indexOf(" ");
+ if(i0>0 and i0<i1) ui->genMsg->setText(t);
m_ntx=7;
ui->rbGenMsg->setChecked(true);
if(m_transmitting) m_restart=true;
@@ -2806,22 +2911,22 @@ void MainWindow::on_pbSendReport_clicked()
void MainWindow::on_pbSend73_clicked()
{
genStdMsgs(m_rpt);
- ui->genMsg->setText(ui->tx5->text());
+ ui->genMsg->setText(ui->tx5->currentText());
m_ntx=7;
ui->rbGenMsg->setChecked(true);
if(m_transmitting) m_restart=true;
}
-void MainWindow::on_rbGenMsg_toggled(bool checked)
+void MainWindow::on_rbGenMsg_clicked(bool checked)
{
m_freeText=!checked;
if(!m_freeText) {
+ if(m_ntx != 7 && m_transmitting) m_restart=true;
m_ntx=7;
- if(m_transmitting) m_restart=true;
}
}
-void MainWindow::on_rbFreeText_toggled(bool checked)
+void MainWindow::on_rbFreeText_clicked(bool checked)
{
m_freeText=checked;
if(m_freeText) {
@@ -2830,24 +2935,18 @@ void MainWindow::on_rbFreeText_toggled(bool checked)
}
}
-void MainWindow::on_freeTextMsg_editingFinished()
-{
- QString t=ui->freeTextMsg->text();
- msgtype(t, ui->freeTextMsg);
-}
-
-void MainWindow::on_actionDouble_click_on_call_sets_Tx_Enable_triggered(bool checked)
+void MainWindow::on_freeTextMsg_currentTextChanged (QString const& text)
{
- m_quickCall=checked;
+ msgtype(text, ui->freeTextMsg->lineEdit ());
}
void MainWindow::on_rptSpinBox_valueChanged(int n)
{
m_rpt=QString::number(n);
int ntx0=m_ntx;
- QString t=ui->tx5->text();
+ QString t=ui->tx5->currentText();
genStdMsgs(m_rpt);
- ui->tx5->setText(t);
+ ui->tx5->setCurrentText(t);
m_ntx=ntx0;
if(m_ntx==1) ui->txrb1->setChecked(true);
if(m_ntx==2) ui->txrb2->setChecked(true);
@@ -2858,132 +2957,79 @@ void MainWindow::on_rptSpinBox_valueChanged(int n)
statusChanged();
}
-void MainWindow::on_action_73TxDisable_triggered(bool checked)
+void MainWindow::on_tuneButton_clicked (bool checked)
{
- m_73TxDisable=checked;
-}
-
-void MainWindow::on_actionRunaway_Tx_watchdog_triggered(bool checked)
-{
- m_runaway=checked;
+ if (m_tune)
+ {
+ tuneButtonTimer->start(250);
+ }
+ else
+ {
+ m_sentFirst73=false;
+ m_repeatMsg=0;
+ on_monitorButton_clicked (true);
+ }
+ m_tune = checked;
+ Q_EMIT tune (checked);
}
-void MainWindow::on_tuneButton_clicked()
+void MainWindow::stop_tuning ()
{
- if(m_tune) {
- nc1=1; //disable the countdown timer
- tuneButtonTimer->start(250);
- } else {
- m_tune=true;
- m_sent73=false;
- soundOutThread.setTune(m_tune);
- m_repeatMsg=0;
- ui->tuneButton->setStyleSheet(m_pbTune_style);
- }
+ ui->tuneButton->setChecked (false);
+ on_tuneButton_clicked (false);
}
void MainWindow::on_stopTxButton_clicked() //Stop Tx
{
- if(m_tune) {
- m_tune=false;
- soundOutThread.setTune(m_tune);
- }
- if(m_auto) on_autoButton_clicked();
- btxok=false;
- m_repeatMsg=0;
- ui->tuneButton->setStyleSheet("");
-}
-
-void MainWindow::rigOpen()
-{
- QString t;
- int ret;
- rig = new Rig();
-
- if(m_rig<9900) {
- if (!rig->init(m_rig)) {
- msgBox("Rig init failure");
- return;
+ if (m_tune)
+ {
+ stop_tuning ();
}
- QString sCATport=m_catPort;
-#ifdef WIN32
- sCATport="\\\\.\\" + m_catPort; //Allow COM ports above 9
-#endif
- rig->setConf("rig_pathname", sCATport.toLatin1().data());
- char buf[80];
- sprintf(buf,"%d",m_serialRate);
- rig->setConf("serial_speed",buf);
- sprintf(buf,"%d",m_dataBits);
- rig->setConf("data_bits",buf);
- sprintf(buf,"%d",m_stopBits);
- rig->setConf("stop_bits",buf);
- rig->setConf("serial_handshake",m_handshake.toLatin1().data());
- if(m_bDTRoff) {
- rig->setConf("rts_state","OFF");
- rig->setConf("dtr_state","OFF");
- }
- }
- ret=rig->open(m_rig);
- if(ret==RIG_OK) {
- m_bRigOpen=true;
- if(m_poll==0) ui->readFreq->setEnabled(true);
- m_CATerror=false;
- } else {
- t="Open rig failed";
- msgBox(t);
- m_catEnabled=false;
- m_bRigOpen=false;
- m_CATerror=true;
- }
-
- if(m_bRigOpen) {
- if(m_poll>0) {
- ui->readFreq->setStyleSheet("QPushButton{background-color: #00ff00; \
- border-width: 0px; border-radius: 5px;}");
- } else {
- ui->readFreq->setStyleSheet("QPushButton{background-color: orange; \
- border-width: 0px; border-radius: 5px;}");
+ if (m_auto)
+ {
+ auto_tx_mode (false);
}
-} else {
-if(m_CATerror) ui->readFreq->setStyleSheet("QPushButton{background-color: red; \
- border-width: 0px; border-radius: 5px;}");
-if(!m_CATerror) ui->readFreq->setStyleSheet("");
- }
+
+ m_btxok=false;
+ m_repeatMsg=0;
}
-void MainWindow::on_actionAllow_multiple_instances_triggered(bool checked)
+void MainWindow::rigOpen ()
{
- m_bMultipleOK=checked;
+ ui->readFreq->setStyleSheet ("");
+ ui->readFreq->setText ("");
+ m_config.transceiver_online (true);
+ Q_EMIT m_config.sync_transceiver (true);
+ ui->readFreq->setStyleSheet("QPushButton{background-color: orange;"
+ "border-width: 0px; border-radius: 5px;}");
}
void MainWindow::on_pbR2T_clicked()
{
- int n=g_pWideGraph->rxFreq();
- ui->TxFreqSpinBox->setValue(n);
+ if (ui->TxFreqSpinBox->isEnabled ())
+ {
+ ui->TxFreqSpinBox->setValue(ui->RxFreqSpinBox->value ());
+ }
}
void MainWindow::on_pbT2R_clicked()
{
- g_pWideGraph->setRxFreq(m_txFreq);
+ if (ui->RxFreqSpinBox->isEnabled ())
+ {
+ ui->RxFreqSpinBox->setValue (ui->TxFreqSpinBox->value ());
+ }
}
void MainWindow::on_readFreq_clicked()
{
- if(m_transmitting) return;
- m_dontReadFreq=false;
- double fMHz=rig->getFreq(RIG_VFO_CURR)/1000000.0;
- if(fMHz<0.0) {
- QString rt;
- rt.sprintf("Rig control error %d\nFailed to read frequency.",
- int(1000000.0*fMHz));
- msgBox(rt);
- m_catEnabled=false;
- }
- if(fMHz<0.01 or fMHz>1300.0) fMHz=0;
- int ndiff=1000000.0*(fMHz-m_dialFreq);
- if(ndiff!=0) dialFreqChanged2(fMHz);
+ if (m_transmitting) return;
+
+ if (m_config.transceiver_online (true))
+ {
+ Q_EMIT m_config.sync_transceiver (true);
+ }
}
void MainWindow::on_pbTxMode_clicked()
@@ -2995,58 +3041,407 @@ void MainWindow::on_pbTxMode_clicked()
m_modeTx="JT9";
ui->pbTxMode->setText("Tx JT9 @");
}
- g_pWideGraph->setModeTx(m_modeTx);
+ m_wideGraph->setModeTx(m_modeTx);
statusChanged();
}
void MainWindow::setXIT(int n)
{
- int ret;
- int xit=0;
- if(m_bRigOpen) {
- xit=-1000;
- if(n>1000) xit=0;
- if(n>2000) xit=1000;
- if(n>3000) xit=2000;
- if(n>4000) xit=3000;
- if(m_bXIT) {
- ret=rig->setXit((shortfreq_t)xit,RIG_VFO_TX);
- if(ret!=RIG_OK) {
- QString rt;
- rt.sprintf("Setting RIG_VFO_TX failed: %d",ret);
- msgBox(rt);
- }
+ m_XIT = 0;
+ if (m_config.split_mode ())
+ {
+ m_XIT=(n/500)*500 - 1500;
}
- if(m_bSplit) {
- ret=rig->setSplitFreq(MHz(m_dialFreq)+xit,RIG_VFO_B);
+
+ if (m_monitoring || m_transmitting)
+ {
+ if (m_config.transceiver_online ())
+ {
+ if (m_config.split_mode ())
+ {
+ Q_EMIT m_config.transceiver_tx_frequency (m_dialFreq + m_XIT);
+ }
+ }
}
- }
- if(m_bSplit) soundOutThread.setXIT(xit);
- if(!m_bSplit) soundOutThread.setXIT(0);
+
+ Q_EMIT transmitFrequency (ui->TxFreqSpinBox->value () - m_XIT);
}
void MainWindow::setFreq4(int rxFreq, int txFreq)
{
- m_rxFreq=rxFreq;
- m_txFreq=txFreq;
- ui->RxFreqSpinBox->setValue(m_rxFreq);
- ui->TxFreqSpinBox->setValue(m_txFreq);
+ if (ui->RxFreqSpinBox->isEnabled ())
+ {
+ ui->RxFreqSpinBox->setValue(rxFreq);
+ }
+
+ if (ui->TxFreqSpinBox->isEnabled ())
+ {
+ ui->TxFreqSpinBox->setValue(txFreq);
+ }
}
void MainWindow::on_cbTxLock_clicked(bool checked)
{
m_lockTxFreq=checked;
- g_pWideGraph->setLockTxFreq(m_lockTxFreq);
+ m_wideGraph->setLockTxFreq(m_lockTxFreq);
if(m_lockTxFreq) on_pbR2T_clicked();
}
-void MainWindow::on_actionTx2QSO_triggered(bool checked)
+void MainWindow::on_cbPlus2kHz_toggled(bool checked)
+{
+ m_plus2kHz = checked;
+
+ if (m_config.transceiver_online (false)) // only update state if not
+ // starting up
+ {
+ // Upload any queued spots before changing band
+ psk_Reporter->sendReport();
+
+ auto f = m_dialFreq;
+
+ if (m_plus2kHz)
+ {
+ f += 2000;
+ }
+ else
+ {
+ f -= 2000;
+ }
+
+ m_bandEdited = true;
+ band_changed (f);
+ }
+}
+
+void MainWindow::handle_transceiver_update (Transceiver::TransceiverState s)
+{
+ transmitDisplay (s.ptt ());
+
+ if ((s.frequency () - m_dialFreq) || s.split () != m_splitMode)
+ {
+ m_splitMode = s.split ();
+ qsy (s.frequency ());
+ }
+
+ ui->readFreq->setStyleSheet("QPushButton{background-color: #00ff00;"
+ "border-width: 0px; border-radius: 5px;}");
+ ui->readFreq->setText (s.split () ? "S" : "");
+}
+
+void MainWindow::handle_transceiver_failure (QString reason)
{
- m_tx2QSO=checked;
+ ui->readFreq->setStyleSheet("QPushButton{background-color: red;"
+ "border-width: 0px; border-radius: 5px;}");
+ on_stopTxButton_clicked ();
+ rigFailure ("Rig Control Error", reason);
}
-void MainWindow::on_cbPlus2kHz_toggled(bool checked)
+void MainWindow::rigFailure (QString const& reason, QString const& detail)
+{
+ static bool first_error {true};
+ if (first_error)
+ {
+ // one automatic retry
+ QTimer::singleShot (0, this, SLOT (rigOpen ()));
+ first_error = false;
+ }
+ else
+ {
+ m_rigErrorMessageBox.setText (reason);
+ m_rigErrorMessageBox.setDetailedText (detail);
+
+ // don't call slot functions directly to avoid recursion
+ switch (m_rigErrorMessageBox.exec ())
+ {
+ case QMessageBox::Ok:
+ QTimer::singleShot (0, this, SLOT (on_actionSettings_triggered ()));
+ break;
+
+ case QMessageBox::Retry:
+ QTimer::singleShot (0, this, SLOT (rigOpen ()));
+ break;
+
+ case QMessageBox::Cancel:
+ QTimer::singleShot (0, this, SLOT (close ()));
+ break;
+ }
+ first_error = true; // reset
+ }
+}
+
+void MainWindow::transmit (double snr)
+{
+ if (m_modeTx == "JT65")
+ {
+ Q_EMIT sendMessage (NUM_JT65_SYMBOLS, 4096.0 * 12000.0 / 11025.0, ui->TxFreqSpinBox->value () - m_XIT, m_toneSpacing, &m_soundOutput, m_config.audio_output_channel (), true, snr);
+ }
+ else
+ {
+ Q_EMIT sendMessage (NUM_JT9_SYMBOLS, m_nsps, ui->TxFreqSpinBox->value () - m_XIT, m_toneSpacing, &m_soundOutput, m_config.audio_output_channel (), true, snr);
+ }
+}
+
+void MainWindow::on_outAttenuation_valueChanged (int a)
+{
+ qreal dBAttn (a / 10.); // slider interpreted as hundredths of a dB
+ ui->outAttenuation->setToolTip (tr ("Transmit digital gain ") + (a ? QString::number (-dBAttn, 'f', 1) : "0") + "dB");
+ Q_EMIT outAttenuationChanged (dBAttn);
+}
+
+void MainWindow::on_actionShort_list_of_add_on_prefixes_and_suffixes_triggered()
+{
+ if (!m_prefixes)
+ {
+ QFile f(":/prefixes.txt");
+ if(!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ msgBox("Cannot open \"" + f.fileName () + "\" for reading:" + f.errorString ());
+ return;
+ }
+ m_prefixes.reset (new QTextEdit);
+ m_prefixes->setReadOnly(true);
+ m_prefixes->setFontPointSize(10);
+ m_prefixes->setWindowTitle(QApplication::applicationName () + " - " + tr ("Prefixes"));
+ m_prefixes->setGeometry(QRect(45,50,565,450));
+ Qt::WindowFlags flags = Qt::WindowCloseButtonHint |
+ Qt::WindowMinimizeButtonHint;
+ m_prefixes->setWindowFlags(flags);
+ QTextStream s(&f);
+ QString t;
+ for(int i=0; i<100; i++) {
+ t=s.readLine();
+ m_prefixes->append(t);
+ if(s.atEnd()) break;
+ }
+ }
+ m_prefixes->showNormal();
+}
+
+void MainWindow::getpfx()
+{
+ m_prefix <<"1A" <<"1S" <<"3A" <<"3B6" <<"3B8" <<"3B9" <<"3C" <<"3C0" \
+ <<"3D2" <<"3D2C" <<"3D2R" <<"3DA" <<"3V" <<"3W" <<"3X" <<"3Y" \
+ <<"3YB" <<"3YP" <<"4J" <<"4L" <<"4S" <<"4U1I" <<"4U1U" <<"4W" \
+ <<"4X" <<"5A" <<"5B" <<"5H" <<"5N" <<"5R" <<"5T" <<"5U" \
+ <<"5V" <<"5W" <<"5X" <<"5Z" <<"6W" <<"6Y" <<"7O" <<"7P" \
+ <<"7Q" <<"7X" <<"8P" <<"8Q" <<"8R" <<"9A" <<"9G" <<"9H" \
+ <<"9J" <<"9K" <<"9L" <<"9M2" <<"9M6" <<"9N" <<"9Q" <<"9U" \
+ <<"9V" <<"9X" <<"9Y" <<"A2" <<"A3" <<"A4" <<"A5" <<"A6" \
+ <<"A7" <<"A9" <<"AP" <<"BS7" <<"BV" <<"BV9" <<"BY" <<"C2" \
+ <<"C3" <<"C5" <<"C6" <<"C9" <<"CE" <<"CE0X" <<"CE0Y" <<"CE0Z" \
+ <<"CE9" <<"CM" <<"CN" <<"CP" <<"CT" <<"CT3" <<"CU" <<"CX" \
+ <<"CY0" <<"CY9" <<"D2" <<"D4" <<"D6" <<"DL" <<"DU" <<"E3" \
+ <<"E4" <<"EA" <<"EA6" <<"EA8" <<"EA9" <<"EI" <<"EK" <<"EL" \
+ <<"EP" <<"ER" <<"ES" <<"ET" <<"EU" <<"EX" <<"EY" <<"EZ" \
+ <<"F" <<"FG" <<"FH" <<"FJ" <<"FK" <<"FKC" <<"FM" <<"FO" \
+ <<"FOA" <<"FOC" <<"FOM" <<"FP" <<"FR" <<"FRG" <<"FRJ" <<"FRT" \
+ <<"FT5W" <<"FT5X" <<"FT5Z" <<"FW" <<"FY" <<"M" <<"MD" <<"MI" \
+ <<"MJ" <<"MM" <<"MU" <<"MW" <<"H4" <<"H40" <<"HA" \
+ <<"HB" <<"HB0" <<"HC" <<"HC8" <<"HH" <<"HI" <<"HK" <<"HK0A" \
+ <<"HK0M" <<"HL" <<"HM" <<"HP" <<"HR" <<"HS" <<"HV" <<"HZ" \
+ <<"I" <<"IS" <<"IS0" <<"J2" <<"J3" <<"J5" <<"J6" \
+ <<"J7" <<"J8" <<"JA" <<"JDM" <<"JDO" <<"JT" <<"JW" \
+ <<"JX" <<"JY" <<"K" <<"KG4" <<"KH0" <<"KH1" <<"KH2" <<"KH3" \
+ <<"KH4" <<"KH5" <<"KH5K" <<"KH6" <<"KH7" <<"KH8" <<"KH9" <<"KL" \
+ <<"KP1" <<"KP2" <<"KP4" <<"KP5" <<"LA" <<"LU" <<"LX" <<"LY" \
+ <<"LZ" <<"OA" <<"OD" <<"OE" <<"OH" <<"OH0" <<"OJ0" <<"OK" \
+ <<"OM" <<"ON" <<"OX" <<"OY" <<"OZ" <<"P2" <<"P4" <<"PA" \
+ <<"PJ2" <<"PJ7" <<"PY" <<"PY0F" <<"PT0S" <<"PY0T" <<"PZ" <<"R1F" \
+ <<"R1M" <<"S0" <<"S2" <<"S5" <<"S7" <<"S9" <<"SM" <<"SP" \
+ <<"ST" <<"SU" <<"SV" <<"SVA" <<"SV5" <<"SV9" <<"T2" <<"T30" \
+ <<"T31" <<"T32" <<"T33" <<"T5" <<"T7" <<"T8" <<"T9" <<"TA" \
+ <<"TF" <<"TG" <<"TI" <<"TI9" <<"TJ" <<"TK" <<"TL" \
+ <<"TN" <<"TR" <<"TT" <<"TU" <<"TY" <<"TZ" <<"UA" <<"UA2" \
+ <<"UA9" <<"UK" <<"UN" <<"UR" <<"V2" <<"V3" <<"V4" <<"V5" \
+ <<"V6" <<"V7" <<"V8" <<"VE" <<"VK" <<"VK0H" <<"VK0M" <<"VK9C" \
+ <<"VK9L" <<"VK9M" <<"VK9N" <<"VK9W" <<"VK9X" <<"VP2E" <<"VP2M" <<"VP2V" \
+ <<"VP5" <<"VP6" <<"VP6D" <<"VP8" <<"VP8G" <<"VP8H" <<"VP8O" <<"VP8S" \
+ <<"VP9" <<"VQ9" <<"VR" <<"VU" <<"VU4" <<"VU7" <<"XE" <<"XF4" \
+ <<"XT" <<"XU" <<"XW" <<"XX9" <<"XZ" <<"YA" <<"YB" <<"YI" \
+ <<"YJ" <<"YK" <<"YL" <<"YN" <<"YO" <<"YS" <<"YU" <<"YV" \
+ <<"YV0" <<"Z2" <<"Z3" <<"ZA" <<"ZB" <<"ZC4" <<"ZD7" <<"ZD8" \
+ <<"ZD9" <<"ZF" <<"ZK1N" <<"ZK1S" <<"ZK2" <<"ZK3" <<"ZL" <<"ZL7" \
+ <<"ZL8" <<"ZL9" <<"ZP" <<"ZS" <<"ZS8" <<"KC4" <<"E5";
+
+ m_suffix << "P" << "0" << "1" << "2" << "3" << "4" << "5" << "6" \
+ << "7" << "8" << "9" << "A";
+
+ for(int i=0; i<12; i++) {
+ m_sfx.insert(m_suffix[i],true);
+ }
+ for(int i=0; i<339; i++) {
+ m_pfx.insert(m_prefix[i],true);
+ }
+}
+
+bool MainWindow::shortList(QString callsign)
+{
+ int n=callsign.length();
+ int i1=callsign.indexOf("/");
+ Q_ASSERT(i1>0 and i1<n);
+ QString t1=callsign.mid(0,i1);
+ QString t2=callsign.mid(i1+1,n-i1-1);
+ bool b=(m_pfx.contains(t1) or m_sfx.contains(t2));
+ return b;
+}
+
+void MainWindow::pskSetLocal ()
{
- m_plus2kHz=checked;
- on_bandComboBox_activated(m_band);
+ // find the station row, if any, that matches the band we are on
+ auto stations = m_config.stations ();
+ auto matches = stations->match (stations->index (0, 0)
+ , Qt::DisplayRole
+ , ui->bandComboBox->currentText ()
+ , 1
+ , Qt::MatchExactly);
+ QString antenna_description;
+ if (!matches.isEmpty ())
+ {
+ antenna_description = stations->index (matches.first ().row (), 2).data ().toString ();
+ }
+ psk_Reporter->setLocalStation(
+ m_config.my_callsign ()
+ , m_config.my_grid ()
+ , antenna_description, QString {"WSJT-X v" + version() + " " + m_revision}.simplified ());
+}
+
+void MainWindow::transmitDisplay (bool transmitting)
+{
+
+ if (transmitting == m_transmitting)
+ {
+ if (transmitting)
+ {
+ signalMeter->setValue(0);
+
+ if (m_monitoring)
+ {
+ monitor (false);
+ }
+
+ m_btxok=true;
+ }
+
+ auto QSY_allowed = !transmitting || m_config.tx_QSY_allowed () || !m_config.split_mode ();
+ if (ui->cbTxLock->isChecked ())
+ {
+ ui->RxFreqSpinBox->setEnabled (QSY_allowed);
+ ui->pbT2R->setEnabled (QSY_allowed);
+ }
+ ui->TxFreqSpinBox->setEnabled (QSY_allowed);
+ ui->pbR2T->setEnabled (QSY_allowed);
+ ui->cbTxLock->setEnabled (QSY_allowed);
+
+ // only allow +2kHz when not transmitting or if TX QSYs are allowed
+ ui->cbPlus2kHz->setEnabled (!transmitting || m_config.tx_QSY_allowed ());
+
+ // the following are always disallowed in transmit
+ ui->menuMode->setEnabled (!transmitting);
+ ui->bandComboBox->setEnabled (!transmitting);
+ if (!transmitting)
+ {
+ if ("JT9+JT65" == m_mode)
+ {
+ // allow mode switch in Rx when in dual mode
+ ui->pbTxMode->setEnabled (true);
+ }
+ }
+ else
+ {
+ ui->pbTxMode->setEnabled (false);
+ }
+ }
+}
+
+// Takes a decoded CQ line and sets it up for reply
+void MainWindow::replyToCQ (QTime time, qint32 snr, float delta_time, quint32 delta_frequency, QString const& mode, QString const& message_text)
+{
+ if (!m_config.accept_udp_requests ())
+ {
+ return;
+ }
+
+ auto decode_parts = message_text.split (' ', QString::SkipEmptyParts);
+
+ if (decode_parts.contains ("CQ") || decode_parts.contains ("QRZ"))
+ {
+ // a message we are willing to accept
+ auto cqtext = QString {"%1 %2 %3 %4 %5 %6"}.arg (time.toString ("hhmm"))
+ .arg (snr, 3)
+ .arg (delta_time, 4, 'f', 1)
+ .arg (delta_frequency, 4)
+ .arg (mode)
+ .arg (message_text);
+ auto messages = ui->decodedTextBrowser->toPlainText ();
+ auto position = messages.lastIndexOf (cqtext);
+ if (position >= 0)
+ {
+ if (m_config.udpWindowToFront ())
+ {
+ show ();
+ raise ();
+ activateWindow ();
+ }
+ if (m_config.udpWindowRestore () && isMinimized ())
+ {
+ showNormal ();
+ raise ();
+ }
+ // find the linefeed at the end of the line
+ position = ui->decodedTextBrowser->toPlainText().indexOf("\n",position);
+ processMessage (messages, position, false);
+ }
+ else
+ {
+ qDebug () << "reply to CQ request ignored, decode not found:" << cqtext;
+ }
+ }
+ else
+ {
+ qDebug () << "rejecting UDP request to reply as decode is not a CQ or QRZ";
+ }
+}
+
+void MainWindow::replayDecodes ()
+{
+ // we accept this request even if the setting to accept UDP requests
+ // is not checked
+ Q_FOREACH (auto const& message, ui->decodedTextBrowser->toPlainText ().split ('\n', QString::SkipEmptyParts))
+ {
+ if (message.size() >= 4 && message.left (4) != "----")
+ {
+ auto eom_pos = message.indexOf (' ', 35);
+ // we always want at least the characters to position 35
+ if (eom_pos < 35)
+ {
+ eom_pos = message.size () - 1;
+ }
+ postDecode (false, message.left (eom_pos + 1));
+ }
+ }
+ statusChanged ();
+}
+
+void MainWindow::postDecode (bool is_new, QString const& message)
+{
+ auto decode = message.trimmed ();
+ auto parts = decode.left (21).split (' ', QString::SkipEmptyParts);
+ if (parts.size () >= 5)
+ {
+ m_messageClient->decode (is_new, QTime::fromString (parts[0], "hhmm"), parts[1].toInt ()
+ , parts[2].toFloat (), parts[3].toUInt (), parts[4], decode.mid (21));
+ }
+}
+
+void MainWindow::networkError (QString const& e)
+{
+ if (QMessageBox::Retry == QMessageBox::warning (this, tr ("Network Error")
+ , tr ("Error: %1\nUDP server %2:%3")
+ .arg (e)
+ .arg (m_config.udp_server_name ())
+ .arg (m_config.udp_server_port ())
+ , QMessageBox::Cancel | QMessageBox::Retry, QMessageBox::Cancel))
+ {
+ // retry server lookup
+ m_messageClient->set_server (m_config.udp_server_name ());
+ }
}