From a0d27d23f7105fb6fb421e3bf8de962e7a8dd958 Mon Sep 17 00:00:00 2001
From: Joe Taylor <k1jt@arrl.org>
Date: Wed, 26 Oct 2016 19:01:46 +0000
Subject: [PATCH] Introduce a 1-second delay before starting wsprd.  (There is
 probably a better way to make sure that the new .wav file is ready, before
 starting wsprd?)

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7242 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
---
 mainwindow.cpp | 15 ++++++++++++---
 mainwindow.h   |  5 ++++-
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/mainwindow.cpp b/mainwindow.cpp
index b1724fcbf..a207d79f6 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -4,9 +4,7 @@
 #include <cinttypes>
 #include <limits>
 #include <functional>
-
 #include <fftw3.h>
-
 #include <QLineEdit>
 #include <QRegExpValidator>
 #include <QRegExp>
@@ -610,9 +608,13 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
 
   ptt0Timer.setSingleShot(true);
   connect(&ptt0Timer, &QTimer::timeout, this, &MainWindow::stopTx2);
+
   ptt1Timer.setSingleShot(true);
   connect(&ptt1Timer, &QTimer::timeout, this, &MainWindow::startTx2);
 
+  p1Timer.setSingleShot(true);
+  connect(&p1Timer, &QTimer::timeout, this, &MainWindow::startP1);
+
   logQSOTimer.setSingleShot(true);
   connect(&logQSOTimer, &QTimer::timeout, this, &MainWindow::on_logQSOButton_clicked);
 
@@ -1180,7 +1182,8 @@ void MainWindow::dataSink(qint64 frames)
       int i1=cmnd.indexOf("/wsprd ");
       cmnd=t3.mid(0,i1+7) + t3.mid(i1+7);
       if (ui) ui->DecodeButton->setChecked (true);
-      p1.start(QDir::toNativeSeparators(cmnd));
+      m_cmndP1=QDir::toNativeSeparators(cmnd);
+      p1Timer.start(1000);
       m_decoderBusy = true;
       statusUpdate ();
     }
@@ -1188,6 +1191,12 @@ void MainWindow::dataSink(qint64 frames)
   }
 }
 
+void MainWindow::startP1()
+{
+  qDebug() << m_cmndP1;
+  p1.start(m_cmndP1);
+}
+
 QString MainWindow::save_wave_file (QString const& name, short const * data, int seconds,
         QString const& my_callsign, QString const& my_grid, QString const& mode, qint32 sub_mode,
         Frequency frequency, QString const& his_call, QString const& his_grid) const
diff --git a/mainwindow.h b/mainwindow.h
index a6e693fab..853999e19 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -175,6 +175,7 @@ private slots:
   void on_actionErase_ALL_TXT_triggered();
   void on_actionErase_wsjtx_log_adi_triggered();
   void startTx2();
+  void startP1();
   void stopTx();
   void stopTx2();
   void on_pbCallCQ_clicked();
@@ -453,7 +454,7 @@ private:
 
   WSPRNet *wsprNet;
 
-  QTimer  m_guiTimer;
+  QTimer m_guiTimer;
   QTimer ptt1Timer;                 //StartTx delay
   QTimer ptt0Timer;                 //StopTx delay
   QTimer logQSOTimer;
@@ -465,6 +466,7 @@ private:
   QTimer RxQSYTimer;
   QTimer minuteTimer;
   QTimer splashTimer;
+  QTimer p1Timer;
 
   QString m_path;
   QString m_baseCall;
@@ -482,6 +484,7 @@ private:
   QString m_qsoStart;
   QString m_qsoStop;
   QString m_cmnd;
+  QString m_cmndP1;
   QString m_msgSent0;
   QString m_fileToSave;
   QString m_calls;