summaryrefslogtreecommitdiff
path: root/widgets/mainwindow.h
blob: 52d7fdc0d59281c67ed27fdc5468df1facc773d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
// -*- Mode: C++ -*-
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QByteArray>
#include <QString>
#include <QStringList>
#include <QLabel>
#include <QThread>
#include <QProcess>
#include <QProgressBar>
#include <QTimer>
#include <QDateTime>
#include <QElapsedTimer>
#include <QMap>
#include <QRegExp>
#include <QRegularExpression>
#include <QList>
#include <QAudioDeviceInfo>
#include <QStringList>
#include <QScopedPointer>
#include <QDir>
#include <QAbstractSocket>
#include <QHostAddress>
#include <QPointer>
#include <QSet>
#include <QHash>
#include <QVector>
#include <QScrollBar>
#include <QTextBlock>
#include <QQueue>
#include <QFuture>
#include <QFutureSynchronizer>
#include <QFutureWatcher>
#include <QDateTime>
#include <array>
#include <initializer_list>
#include <memory>

class QHBoxLayout;

#include "MultiGeometryWidget.hpp"
#include "NonInheritingProcess.hpp"
#include "Audio/AudioDevice.hpp"
#include "Audio/TxIdentity.hpp"
#include "Audio/TxPlaybackDiagnostics.hpp"
#include "Audio/TxPlaybackEvidence.hpp"
#include "Audio/TxRequest.hpp"
#include "Audio/WavLoadCoordinator.hpp"
#include "commons.h"
#include "lib/qra/q65/q65_limits.h"
#include "FastDecode.hpp"
#include "ReferenceSpectrum.hpp"
#include "Radio.hpp"
#include "OperatingFrequency.hpp"
#include "models/Modes.hpp"
#include "models/FrequencyList.hpp"
#include "Configuration.hpp"
#include "JttyN1mmOutput.hpp"
#include "JttyReceiveAudio.hpp"
#include "JttyMmttyHandoff.hpp"
#include "JttyTxLifecycle.hpp"
#include "WSPR/WSPRBandHopping.hpp"
#include "Transceiver/Transceiver.hpp"
#include "DisplayManual.hpp"
#include "Network/PSKReporter.hpp"
#include "Network/Cloudlog.hpp"
#include "logbook/logbook.h"
#include "astro.h"
#include "qtextbrowser.h"
#include "widgets/QSYMessageCreator.h"
#include "widgets/QSYMessage.h"
#include "widgets/displaytext.h"
#include "widgets/qsymonitor.h"
#include "MessageBox.hpp"
#include "Network/NetworkAccessManager.hpp"
#include "AutoRespondSelectionLatch.hpp"
#include "AutoRespondScoring.hpp"
#include "AutoRespondPeriod.hpp"
#include "HoundTransmissionPolicy.hpp"
#include "JttyLiveEntry.hpp"
#include "JttyTransmitQueue.hpp"
#include "QsoProgress.hpp"
#include "DecodeOperatingContext.hpp"
#include "DecoderOutputFramer.hpp"
#include "Ft8MtdDecodeCoordinator.hpp"
#include "RigFrequencyChangePolicy.hpp"
#include "BeaconTxController.hpp"

#define NUM_JT4_SYMBOLS 206                //(72+31)*2, embedded sync
#define NUM_JT65_SYMBOLS 126               //63 data + 63 sync
#define NUM_JT9_SYMBOLS 85                 //69 data + 16 sync
#define NUM_WSPR_SYMBOLS 162               //(50+31)*2, embedded sync
#define NUM_MSK144_SYMBOLS 144             //s8 + d48 + s8 + d80
#define NUM_Q65_SYMBOLS 85                 //63 data + 22 sync
#define NUM_FT8_SYMBOLS 79
#define NUM_SUPERFOX_SYMBOLS 153
#define NUM_FT4_SYMBOLS 105
#define NUM_FST4_SYMBOLS 160             //240/2 data + 5*8 sync
#define NUM_CW_SYMBOLS 250
#define MAX_NUM_SYMBOLS 250
#define TX_SAMPLE_RATE 48000
#define NRING 3456000
#define MAX_HOUNDS_IN_QUEUE 10

// extern int volatile itone[MAX_NUM_SYMBOLS];   //Audio tones for all Tx symbols
// extern int volatile icw[NUM_CW_SYMBOLS];	    //Dits for CW ID

//--------------------------------------------------------------- MainWindow
namespace Ui {
  class MainWindow;
}

class QWidget;
class QRadioButton;
struct QMapDecodeRecord;
class QFocusFrame;
class QFrame;
class QButtonGroup;

class QProcessEnvironment;
class QPaintEvent;
class QSharedMemory;
class QSplashScreen;
class QSettings;
class QLineEdit;
class QFont;
class QHostInfo;
class EchoGraph;
class FastGraph;
class WideGraph;
class LogQSO;
class Transceiver;
class MessageAveraging;
class ActiveStations;
class FoxLogWindow;
class CabrilloLogWindow;
class ColorHighlighting;
class MessageClient;
class QTime;
class WSPRBandHopping;
class HelpTextWindow;
class EQSL;
class WSPRNet;
class SoundOutput;
class Modulator;
class AudioInputSource;
class Detector;
class SampleDownloader;
class MultiSettings;

namespace DecodedMessageReaction
{
  enum class ContestHint;
  enum class ReactionDisposition;
  enum class SelectionOrigin;
  enum class WaitDecodeSource;
  struct QsoReactionEffect;
  struct QsoReactionPlan;
  struct QsoReactionSnapshot;
}
class EqualizationToolsDialog;
class DecodedText;
class Cloudlog;

#include "Audio/TxAudioQueue.hpp"
#include "Modulator/JttyTxStream.hpp"

#ifdef WIN32
class MMTTYIF;
#endif

class MainWindow
  : public MultiGeometryWidget<3, QMainWindow>
{
  Q_OBJECT;

public:
  using Frequency = Radio::Frequency;
  using FrequencyDelta = Radio::FrequencyDelta;
  using Mode = Modes::Mode;
  using SpecOp = Configuration::SpecialOperatingActivity;

  enum class JttyTxRejectReason
  {
    Empty,
    EncodingFailed,
    QueueFull,
    BackendRejected,
    Aborted,
    NotAvailable,
    BackendTimedOut
  };
  Q_ENUM(JttyTxRejectReason)

  static QRegExp const message_alphabet;
  static QRegularExpression const grid_regexp;
  static QRegularExpression const non_r_db_regexp;

  explicit MainWindow(QDir const& temp_directory, bool multiple, MultiSettings *,
                      DecoderIpc::Session& decoderSession, unsigned downSampleFactor,
                      QSplashScreen *, QProcessEnvironment const&, bool automated_test,
                      QString base_style_sheet,
                      std::unique_ptr<AudioInputSource> audio_input_source = {},
                      std::unique_ptr<SoundOutput> sound_output = {},
                      QString decoder_data_path = {},
                      QWidget *parent = nullptr);
  ~MainWindow();

#ifdef WIN32
  void initMMTTY(quint16 port);
  MMTTYIF *getMmttyIf() const;
#endif

  bool decoderBusy () const
    {return m_fastDecodePending || DecodeOwner::None != m_decodeOwner || m_ft8MtdDecodeCoordinator.hasPending () || jttyReviewBusy();}
  void set_mode_from_command_line(const QString& mode, bool lock_mode = false);
  bool decoderBackendRunning () const;
  bool diskDataActive () const {return m_diskData;}
  bool monitoringActive () const {return m_monitoring;}
#if defined (WSJT_ENABLE_LIVE_AUDIO_TEST)
  struct LiveAudioTestFt8TransmitRequest
  {
    qint64 session_id {-1};
    qint64 generation {-1};
  };

  bool liveAudioTestMultithreadedFt8Enabled () const {return m_multithreadFT8;}
  int liveAudioTestFt8ThreadCount () const {return m_ft8threads;}
  int liveAudioTestDecodeDepth () const {return m_ndepth & 7;}
  int liveAudioTestFt8Cycles () const {return m_nFT8Cycles;}
  int liveAudioTestFt8Sensitivity () const {return m_ft8Sensitivity;}
  int liveAudioTestFt8DecoderStart () const {return m_ft8DecoderStart;}
  QString liveAudioTestFt8BackpressureDiagnostics () const;
  static constexpr int liveAudioTestDecodeLowFrequency () {return 200;}
  static constexpr int liveAudioTestDecodeHighFrequency () {return 3000;}
  bool configureLiveAudioTestDecodeRange ();
  bool startWavDecodeTest (QString const& path);
  bool prepareLiveAudioTestFt8InputCompletion ();
  QString completeLiveAudioTestFt8Input (qint64 frames);
  bool configureLiveAudioTestHandoff ();
  quint64 liveAudioTestPublishedDecoderGeneration () const
  {
    return m_automated_test && DecodeOwner::Jt9 == m_decodeOwner
      && m_decoderSession.accepts (m_activeJt9Decode.generation)
      ? m_activeJt9Decode.generation : 0;
  }
  quint64 liveAudioTestDecodeCycleGeneration () const {return m_decodeCycleGeneration;}
  quint64 liveAudioTestReceiveEpoch () const {return m_receiveConsumer.epoch ();}
  bool liveAudioTestReceivingAudio () const {return m_receivingAudio;}
  QString checkLiveAudioTestJttyFrequencyChanges();
  bool startLiveAudioTestJttyWav(QString const& path);
  QString checkLiveAudioTestJttyMailboxOverflow();
  QString checkLiveAudioTestJttyDrain();
  bool liveAudioTestJttyStreamActive () const
  {
    return m_jttyTxStream && m_jttyTxStream->isActive ();
  }
  LiveAudioTestFt8TransmitRequest startLiveAudioTestFt8Transmit (
    qint64 targetPeriodStartMs);
#endif

  Q_SIGNALS:
  void decoderBackendStarted () const;
  void decoderBackendFailed (QString reason) const;
  void decodeCycleStarted (quint64 generation) const;
  void decodeCycleCompleted (quint64 generation) const;
  void decodeCycleAborted (quint64 generation) const;
#if defined (WSJT_ENABLE_LIVE_AUDIO_TEST)
  void ft8DecoderInvocation (bool multithreaded, int threadCount, int depth,
                             int cycles, bool subpass, int decoderStart,
                             int halfSymbols, int sampleCount,
                             int lowFrequency, int highFrequency) const;
  void decoderOutputLine (QByteArray line) const;
  void liveAudioTestJttyFramesConsumed (qint64 frames) const;
  void liveAudioTestReceiveRejected (qint64 notifiedFrames) const;
  void liveAudioTestReceiveRange (quint64 epoch, int start, int end, bool accepted) const;
  void liveAudioTestReceiveBlock (ReceiveAudio block) const;
  void liveAudioTestReceiveCallback (qint64 notifiedFrames,
                                     qint64 currentFrames,
                                     qint16 observedLastSample) const;
  void liveAudioTestFt8TransmitStartDecided (qint64 sessionId,
                                             qint64 generation,
                                             qint64 targetPeriodStartMs,
                                             bool accepted,
                                             qint64 actualStartMs) const;
#endif
  void decodedMessageProcessed (QString message) const;
  void decodedMessageDisplayed (QString message) const;
  void jttyTextAccepted(qint64 requestId) const;
  void jttyTextRejected(qint64 requestId, JttyTxRejectReason reason) const;
  void jttyTextCompleted(qint64 requestId) const;
  void jttySessionDrained(qint64 sessionId) const;

  public slots:
  void showSoundInError(const QString& errorMsg);
  void showSoundOutError(const QString& errorMsg);
  void showStatusMessage(const QString& statusMsg);
  // JTTY text submission is asynchronous. The returned request id is completed
  // by accepted/rejected signals; accepted means queued for backend transmit,
  // not finished on RF. Graceful external OFF commands should stop submitting
  // new text and let the JTTY drain path stop TX; use abort_jtty_tx() for hard
  // abort.
  qint64 submitJttyText(QString message);
  void updateJttyDecodeHeadings();
  void dataSink(qint64 frames);
  void fastSink(qint64 frames);
  void tci_mod_active(bool on) {m_tci_mod_active = on;}
  void diskDat();
  void freezeDecode(int n);
  void guiUpdate();
  void doubleClickOnCall (QString const& line, QString const& word, Qt::KeyboardModifiers);
  void doubleClickOnCall2(QString const& line, QString const& word, Qt::KeyboardModifiers);
  void doubleClickOnFoxQueue(QString const& line, QString const& word, Qt::KeyboardModifiers);
  void doubleClickOnFoxInProgress(QString const& line, QString const& word, Qt::KeyboardModifiers modifiers);
  void readFromStdout();
  void p1ReadFromStdout();
  void setXIT(int n, Frequency base = 0u);
  void setFreq4(int rxFreq, int txFreq);
  void msgAvgDecode2();
  void fastPick(int x0, int x1, int y);
  void skedFreq(double sf);
  void jttyDecodeAgainAtSample(quint64 reception, qint64 sample);

private:
  enum class DecodeOwner
  {
    None,
    Jt9,
    Wsprd
  };

  enum class DecodeEndState
  {
    Completed,
    Aborted
  };

  enum class Jt9ProcessPhase
  {
    InitialStarting,
    Ready,
    StopRequested,
    Terminating,
    Killing,
    ReplacementStarting,
    Failed,
    Closing
  };

  enum class DecodePublishResult
  {
    Published,
    Unavailable,
    Failed
  };

  struct ActiveJt9Decode
  {
    qint32 generation {0};
    DecodeOperatingContext context;
    bool obsolete {false};
    Ft8MtdDecodeCoordinator::Stage ft8Stage {Ft8MtdDecodeCoordinator::Stage::None};
    qint64 ft8Period {-1};
  };

  static constexpr int MaxActiveStationRows = 50;
  static constexpr int MaxQ65PileupCallers = Q65_CALLER_CAPACITY;

  void change_layout (std::size_t) override;
  void keyPressEvent (QKeyEvent *) override;
  void closeEvent(QCloseEvent *) override;
  void paintEvent(QPaintEvent *) override;
  void childEvent(QChildEvent *) override;
  bool eventFilter(QObject *, QEvent *) override;
  void showQSYMessage(QString message);
  void save_wave_file(QString const& name, int samples, Frequency frequency,
                      QString const& dgrd);

private slots:
  void initialize_fonts ();
  void ScrollBarPosition(int n);
  void on_actionUse_Dark_Style_triggered (bool checked);
  void on_actionBand_Buttons_triggered ();
  void on_actionVHF_UHF_Buttons_triggered ();
  void on_pb160_clicked();
  void on_pb80_clicked();
  void on_pb60_clicked();
  void on_pb40_clicked();
  void on_pb30_clicked();
  void on_pb20_clicked();
  void on_pb17_clicked();
  void on_pb15_clicked();
  void on_pb12_clicked();
  void on_pb10_clicked();
  void on_pb8_clicked();
  void on_pb6_clicked();
  void on_pb2_clicked();
  void on_pb70_clicked();
  void on_pb50_clicked();
  void on_pb4_clicked();
  void on_pb144_clicked();
  void on_pb220_clicked();
  void on_pb432_clicked();
  void on_pb902_clicked();
  void on_pb23_clicked();
  void on_pb13_clicked();
  void on_pb9_clicked();
  void on_pb5G_clicked();
  void on_pb10G_clicked();
  void on_pb24G_clicked();
  void check_button_color();
  void reset_transmit_controls_after_stop ();
  void stopWRTimeout();
  void stopWCTimeout();
  void bandHoppingTimer();
  void bandHopping(bool user_requested = false);
  void on_houndButton_clicked(bool checked);
  void on_cbHoldTxFreq_clicked (bool);
  void on_ft8Button_clicked();
  void on_ft4Button_clicked();
  void on_msk144Button_clicked();
  void on_q65Button_clicked();
  void on_jt65Button_clicked();
  void on_echoButton_clicked();
  void on_pb15A_clicked();
  void on_pb15C_clicked();
  void on_pb30B_clicked();
  void on_pb60C_clicked();
  void on_pb60D_clicked();
  void on_pb60E_clicked();
  void on_tx1_editingFinished();
  void on_tx2_editingFinished();
  void on_tx3_editingFinished();
  void on_tx4_editingFinished();
  void on_tx5_currentTextChanged (QString const&);
  void on_tx6_editingFinished();
  void on_actionSettings_triggered();
  void on_monitorButton_clicked (bool);
  void on_actionAbout_triggered();
  void on_autoButton_clicked (bool);
  void on_stopTxButton_clicked();
  void on_stopButton_clicked();
  void on_pbBandHopping_clicked();
  void on_actionRelease_Notes_triggered ();
  void on_actionFT8_DXpedition_Mode_User_Guide_triggered();
  void on_actionSuperFox_User_Guide_triggered();
  void on_actionQSG_FST4_triggered();
  void on_actionQSG_Q65_triggered();
  void on_actionQSG_X250_M3_triggered();
  void on_actionQuick_Start_Guide_to_WSJT_X_2_7_and_QMAP_triggered();
  void on_actionOnline_User_Guide_triggered();
  void on_actionLocal_User_Guide_triggered();
  void on_actionWide_Waterfall_triggered();
  void on_actionOpen_triggered();
  void on_actionOpen_next_in_directory_triggered();
  void on_actionDecode_remaining_files_in_directory_triggered();
  void on_actionDelete_all_wav_files_in_SaveDir_triggered();
  void on_actionOpen_log_directory_triggered ();
  void on_actionNone_triggered();
  void on_actionSave_all_triggered();
  void on_actionDefault_event_logging_triggered();
  void on_actionDiagnostic_mode_triggered();
  void on_actionDisable_event_logging_triggered();
  void on_actionDownload_EME_Ephemeris_Chart_triggered();
  void on_actionKeyboard_shortcuts_triggered();
  void on_actionSpecial_mouse_commands_triggered();
  void on_actionSolve_FreqCal_triggered();
  void on_actionCopyright_Notice_triggered();
  void on_actionTrademark_Policy_triggered();
  void on_actionSWL_Mode_triggered (bool checked);
  void on_DecodeButton_clicked (bool);
  void decode();
  void on_EraseButton_clicked();
  void band_activity_cleared ();
  void rx_frequency_activity_cleared ();
  void on_txFirstCheckBox_stateChanged(int arg1);
  void set_dateTimeQSO(int m_ntx);
  void set_ntx(int n);
  void on_txrb1_toggled(bool status);
  void on_txrb1_doubleClicked ();
  void on_txrb2_toggled(bool status);
  void on_txrb3_toggled(bool status);
  void on_txrb4_toggled(bool status);
  void on_txrb4_doubleClicked ();
  void on_txrb5_toggled(bool status);
  void on_txrb5_doubleClicked ();
  void on_txrb6_toggled(bool status);
  void on_txb1_clicked();
  void on_txb1_doubleClicked ();
  void on_txb2_clicked();
  void on_txb3_clicked();
  void on_txb4_clicked();
  void on_txb4_doubleClicked ();
  void on_txb5_clicked();
  void on_txb5_doubleClicked ();
  void on_txb6_clicked();
  void on_lookupButton_clicked();
  void on_addButton_clicked();
  void on_ignoreButton_clicked();
  void on_comboBoxCQ_activated ();
  void on_DX_Call_Button_clicked (bool checked);
  void wheelEvent(QWheelEvent *event) override;
  void mousePressEvent(QMouseEvent *event) override;
  void on_dxCallEntry_textChanged (QString const&);
  void on_dxGridEntry_textChanged (QString const&);
  void on_dxCallEntry_editingFinished();
  void on_dxCallEntry_returnPressed ();
  void on_genStdMsgsPushButton_clicked();
  void on_logQSOButton_clicked();
  void read_txLog();
  void on_actionErase_Tx_Log_triggered();
  void read_ignoreList();
  void addCallsignToignoreList();
  void on_actionErase_Ignore_List_triggered();
  void read_ALLCALL7();
  void remove_old_files(const QString &directoryPath, int daysOld);
  void on_actionJT9_triggered();
  void on_actionJT65_triggered();
  void on_actionJT4_triggered();
  void on_actionFT4_triggered();
  void on_actionFT8_triggered();
  void on_actionFST4_triggered();
  void on_actionFST4W_triggered();
  void on_TxFreqSpinBox_valueChanged(int arg1);
  void on_TxFreqSpinBox_2_valueChanged(int arg1);
  void on_actionSave_decoded_triggered();
  void on_actionQuickDecode_toggled (bool);
  void on_actionMediumDecode_toggled (bool);
  void on_actionDeepestDecode_toggled (bool);

  //ft8md
  void on_actionDecFT8cycles1_triggered();
  void on_actionDecFT8cycles2_triggered();
  void on_actionDecFT8cycles3_triggered();
  void on_actionRXfLow_triggered();
  void on_actionRXfMedium_triggered();
  void on_actionRXfHigh_triggered();
  void on_actionMTAuto_triggered();
  void on_actionMT1_triggered();
  void on_actionMT2_triggered();
  void on_actionMT3_triggered();
  void on_actionMT4_triggered();
  void on_actionMT5_triggered();
  void on_actionMT6_triggered();
  void on_actionMT7_triggered();
  void on_actionMT8_triggered();
  void on_actionMT9_triggered();
  void on_actionMT10_triggered();
  void on_actionMT11_triggered();
  void on_actionMT12_triggered();
  void on_actionFT8SensMin_toggled(bool checked);
  void on_actionlowFT8thresholds_toggled(bool checked);
  void on_actionFT8subpass_toggled(bool checked);
  void on_actionStartTwoStage_toggled(bool checked);
  void on_actionStartThreeStage_toggled(bool checked);
  void on_actionStartEarly_toggled(bool checked);
  void on_actionStartNormal_toggled(bool checked);
  void on_actionStartLate_toggled(bool checked);
  void on_actionFT8WidebandDXCallSearch_toggled(bool checked);
  void on_actionUse_multithreaded_FT8_decoder_triggered(bool checked);

  void bumpFqso(int n);
  void on_actionErase_ALL_TXT_triggered();
  void on_reset_cabrillo_log_action_triggered ();
  void on_actionErase_wsjtx_log_adi_triggered();
  void on_actionErase_WSPR_hashtable_triggered();
  void on_actionErase_list_of_Q65_callers_triggered();
  void on_actionExport_Cabrillo_log_triggered();
  bool startTx2();
  void startP1();
  void stopTx();
  void stopTx2();
  void on_rptSpinBox_valueChanged(int n);
  void killWaveFile();
  void on_tuneButton_clicked (bool);
  void on_pbR2T_clicked();
  void on_pbR2T_2_clicked();
  void on_pbT2R_clicked();
  void on_pbT2R_2_clicked();
  void acceptQSO (QDateTime const&, 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, QDateTime const& QSO_date_on, QString const& operator_call
                  , QString const& my_call, QString const& my_grid
                  , QString const& exchange_sent, QString const& exchange_rcvd
                  , QString const& propmode, QString const& satellite
                  , QString const& sat_mode
                  , QString const& freqRx, QByteArray const& ADIF);
  void on_bandComboBox_currentIndexChanged (int index);
  void on_bandComboBox_editTextChanged (QString const& text);
  void on_bandComboBox_activated (int index);
  void on_readFreq_clicked();
  void on_RxFreqSpinBox_valueChanged(int n);
  void on_RxFreqSpinBox_2_valueChanged(int n);
  void on_outAttenuation_valueChanged (int);
  void rigOpen ();
  void handle_transceiver_update (Transceiver::TransceiverState const&);
  void handle_transceiver_closing (bool failed);
  void handle_transceiver_failure (QString const& reason);
  void handle_leavingSettings();
  void on_actionAstronomical_data_toggled (bool);
  void on_actionQSYMessage_Creator_triggered();
  void on_actionQSY_Monitor_triggered();
  void alertQSYmessage();
  void on_actionShort_list_of_add_on_prefixes_and_suffixes_triggered();
  void band_changed (Frequency);
  void monitor (bool);
  void applyMonitorEffects (bool checked, bool restored);
  void applyOperatingFrequencyTransition (OperatingFrequency::Transition const&);
  OperatingFrequency::Context operatingFrequencyContext () const;
  void end_tuning ();
  void stop_tuning ();
  void stopTuneATU();
  void auto_tx_mode(bool);
  void on_actionMessage_averaging_triggered();
  void on_actionActiveStations_triggered();
  void on_contest_log_action_triggered ();
  void on_fox_log_action_triggered ();
  void on_actionColors_triggered();
  void on_actionInclude_averaging_toggled (bool);
  void on_actionInclude_correlation_toggled (bool);
  void on_actionEnable_AP_DXcall_toggled (bool);
  void on_actionAuto_Clear_Avg_toggled (bool);
  void VHF_features_enabled(bool b);
  void on_sbSubmode_valueChanged(int n);
  void on_cbSendMsg_toggled(bool b);
  void on_cbShMsgs_toggled(bool b);
  void on_cbSWL_toggled(bool b);
  void on_cbTx6_toggled(bool b);
  void on_cbMenus_toggled(bool b);
  void on_cbAutoSeq_toggled(bool b);
  void on_cbIncludeTime_toggled(bool b);
  void on_cbLowerCase_toggled(bool);
  void networkError (QString const&);
  void on_ClrAvgButton_clicked();
  void on_actionWSPR_triggered();
  void on_syncSpinBox_valueChanged(int n);
  void on_TxPowerComboBox_currentIndexChanged(int);
  void on_sbTxPercent_valueChanged(int n);
  void on_cbUploadWSPR_Spots_toggled(bool b);
  void WSPR_config(bool b);
  void uploadWSPRSpots (bool direct_post = false, QString const& decode_text = QString {});
  void TxAgain();
  void uploadResponse(QString const& response);
  void on_WSPRfreqSpinBox_valueChanged(int n);
  void on_sbFST4W_RxFreq_valueChanged(int n);
  void on_sbFST4W_FTol_valueChanged(int n);
  void on_pbTxNext_clicked(bool b);
  void on_actionEcho_Graph_triggered();
  void on_actionEcho_triggered();
  void on_actionFast_Graph_triggered();
  void fast_decode_done();
  void on_actionMeasure_reference_spectrum_triggered();
  void on_actionErase_reference_spectrum_triggered();
  void on_actionMeasure_phase_response_triggered();
  void on_sbTR_valueChanged (int);
  void on_sbTR_FST4W_valueChanged (int);
  void on_sbFtol_valueChanged (int);
  void on_sbFtol_2_valueChanged (int);
  void on_comboBoxJttyStyle_currentIndexChanged (int index);
  void on_cbFast9_clicked(bool b);
  void on_sbCQTxFreq_valueChanged(int n);
  void on_cbCQTx_toggled(bool b);
  void on_actionMSK144_triggered();
  void on_actionJTTY_triggered();
  void on_actionQ65_triggered();
  void on_actionFreqCal_triggered();
  void splash_done ();
  void on_measure_check_box_stateChanged (int);
  void on_sbNlist_valueChanged(int n);
  void on_sbNslots_valueChanged(int n);
  void on_sbF_Low_valueChanged(int n);
  void on_sbF_High_valueChanged(int n);
  void chk_FST4_freq_range();
  void on_pbFoxReset_clicked();
  void on_pbFreeText_clicked();
  void FoxReset(QString reason);
  void on_comboBoxHoundSort_activated (int index);
  void checkMSK144ContestType();
  void on_pbBestSP_clicked();
  void on_RoundRobin_currentTextChanged(QString);
  void setTxMsg(int n);
  bool stdCall(QString const& w);
  void remote_configure (QString const& mode, quint32 frequency_tolerance, QString const& submode
                         , bool fast_mode, quint32 tr_period, quint32 rx_df, QString const& dx_call
                         , QString const& dx_grid, bool generate_messages);
  void callSandP2(int nline);
  void qmapCallSandP(QMapDecodeRecord const& record, bool doubleClick);
  void refreshHoundQueueDisplay();
  void queueActiveWindowHound2(QString text);
  void update_tx5(const QString &qsy_text);
  void reply_tx5(const QString &qsy_text);
  void setQSYMessageCreatorStatus(const bool &QSYMessageCreatorValue);
  void on_rbFixedTone_toggled(bool b);
  void on_rbEchoMessage_toggled(bool b);
  void on_rbEchoCW_toggled(bool b);
  void on_leEchoMessage_textChanged();
  void on_pbSendMessage_clicked();

  void on_pbF1_clicked();
  void on_pbF2_clicked();
  void on_pbF3_clicked();
  void on_pbF4_clicked();
  void on_pbF5_clicked();
  void on_pbF6_clicked();
  void on_pbF7_clicked();
  void on_pbF8_clicked();
#ifdef WIN32
  void logText(const QString &text);
#endif

private:
  enum class FrequencyRequestOrigin
  {
    User,
    Automatic
  };

  enum class DecodeAlertSound { None, DXcall, Wanted };

  struct Q65StationSelection
  {
    QString call;
    QString grid;
    QString submode;
    QString report;
    bool txFirst;
  };

  void applyExperimentalFT8Filter(const DecodedText& dt, bool& filtered);
  void applyQ65StationSelection (Q65StationSelection const& selection);
  void processFoxSignals(const DecodedText& dt);
  void processSFoxVerification(const DecodedText& dt, bool& filtered);
  DecodedMessageReaction::ReactionDisposition processWaitReplyCall(
    DecodedText const& dt, DecodedMessageReaction::WaitDecodeSource source,
    bool * block_right_display = nullptr);
  bool applyFiltering(const DecodedText& dt, bool& filtered);
  void applyHighlighting(const DecodedText& dt, DisplayText * decodePane, bool updateAlertState,
                         bool& play_Wanted, bool& play_DXcall);
  void cycleRespondMode();
  static DecodeAlertSound selectDecodeAlertSound(bool alertsEnabled, bool dxCallAlertEnabled, bool wantedAlertEnabled,
                                                 bool play_Wanted, bool play_DXcall, bool hasDXCall);
  void playDecodeAlertSound(bool play_Wanted, bool play_DXcall);
  void playDecodeAlertSound(DecodeAlertSound sound);
  void updateRespondTarget(const DecodedText& dt, const QString& text, bool pounce,
                           QDateTime const& decodePeriodStart, bool diskData);
  QString selectedTxMessage() const;
  AutoRespondPolicy autoRespondPolicy() const;
  bool pendingCqAutoRespondIntent() const;
  void displayDecodedTextLine(const DecodedText& dt, const QByteArray& line_read, const QString& distance, bool haveFSpread, float fSpread, bool bDisplayPoints);
  QString calculateDistanceAndBearing(const DecodedText& dt);
  void processSuperHoundVerification(const DecodedText& dt);

private:
  Q_SIGNAL void initializeAudioOutputStream (QAudioDeviceInfo,
      unsigned channels, unsigned msBuffered) const;
  Q_SIGNAL void stopAudioOutputStream () const;
  Q_SIGNAL void startAudioInputStream (QAudioDeviceInfo const&,
      int framesPerBuffer, AudioDevice * sink,
      unsigned downSampleFactor, AudioDevice::Channel) const;
  Q_SIGNAL void suspendAudioInputStream () const;
  Q_SIGNAL void resumeAudioInputStream () const;
  Q_SIGNAL void stopAudioInputStream () const;
  Q_SIGNAL void startDetector (AudioDevice::Channel) const;
  Q_SIGNAL void FFTSize (unsigned) const;
  Q_SIGNAL void detectorClose () const;
  Q_SIGNAL void finished () const;
  Q_SIGNAL void transmitFrequency (double) const;
  Q_SIGNAL void endTransmitMessage (bool quick = false) const;
  Q_SIGNAL void tune (bool = true) const;
  Q_SIGNAL void sendMessage (TxEvidence::TxRequest, SoundOutput *) const;
  Q_SIGNAL void startJttyStream (TxEvidence::TxRequest, SoundOutput *);
  Q_SIGNAL void endJttyStream () const;
  Q_SIGNAL void clearJttyStream (TxAudioQueueEpoch epoch) const;
  Q_SIGNAL void enqueueJttyStream (QByteArray const& samples,
                                   TxAudioQueueEpoch epoch,
                                   qint64 enqueueId) const;
  Q_SIGNAL void outAttenuationChanged (qreal) const;
  Q_SIGNAL void toggleShorthand () const;
  Q_SIGNAL void reset_audio_input_stream (bool report_dropped_frames) const;

private:
  void set_mode (QString const& mode);
  void dispatchTxRequest (TxEvidence::TxRequest const& request);
  void beginTxEvidenceSession ();
  void beginTxEvidenceGeneration (qint64 committedEndSample = -1,
                                  bool targetKnown = false);
  void recordTxSourceCommit (TxEvidence::TxStartSnapshot const& snapshot);
  void recordRawTxPlayout (TxEvidence::TxRawPlayoutSnapshot const& snapshot);
  void noteTxStopReason (TxEvidence::TxStopReason reason);
  void requestTxStop (TxEvidence::TxStopReason reason);
  void noteTxModeChange (QString const& mode);
  void updateModeControlLock ();
  int txStopTailMs (bool tciAudio) const;
  void stopTxEvidence (int tailMs);
  void captureJttyTxEvidenceTotals (qint64 servedSamples, qint64 totalSamples,
                                    QString const& diagnostic);
  void astroUpdate ();
  void writeAllTxt(QString message);
  void auto_sequence (DecodedText const& message, unsigned start_tolerance, unsigned stop_tolerance);
  void trim_view (bool b);
  void foxTest();
  void setColorHighlighting();
  void chkFT4();
  bool elide_tx1_not_allowed () const;
  void toggle_tx1_enabled_preference ();
  bool rr73_tx4_allowed () const;
  bool send_rr73_for_tx4 () const;
  void set_rr73_tx4 (bool enabled);
  void readWidebandDecodes();
  void configActiveStations();
  bool sfox_tx();
  void clearSuperFoxPreparedTx();
  void abortSuperFoxTxStart();
  void displayFoxTxMsgs();
  void jtty_tx(QString message);
  void commitJttyLiveEntry();
  void startJttyLiveStream();
  void autoAdvanceJttyLiveEntry();
  void idleFlushJttyLiveEntry();
  bool commitJttyLiveEntryPlan(bool forceFlush, int holdbackWords, bool isFinal);
  void sendJttyFillerPadding();
  void clearJttyLiveEntry();
  void insertJttyLiveEntryText(QString const& text);
  void insertJttyChatOpener();
  void insertJttyChatSignoff();
  void applyJttyLiveEntryFormatting();
  void guardJttyLiveEntryLock();
  void updateJttyLiveEntryFrameLabel();
  double jttyRequestSentFraction(qint64 requestId) const;
  int jttyRequestFramesDone(qint64 requestId) const;
  int countJttyTransmitFrames(QString const& preparedMessage) const;
#ifdef WIN32
  void handleMmttyTxString(QString message);
  void handleMmttyStartTx();
  void handleMmttyStopTx();
  void handleMmttyAbortTx();
  void handleMmttyJttyAccepted(qint64 requestId);
  void handleMmttyJttyRejected(qint64 requestId, JttyTxRejectReason reason);
  void handleMmttyJttyCompleted(qint64 requestId);
  void handleMmttyJttySessionDrained(qint64 sessionId);
  void completeMmttyJttyOutput(bool drained = false);
  void startPendingMmttyJttyTx();
  void beginMmttyHandoff();
  void resumeMmttyHandoff();
  void handleMmttyHandoffTimeout();
  void finalizeMmttyExternalAbort();
  bool mmttyNeedsHandoff() const;
  QString jttyRejectReasonText(JttyTxRejectReason reason) const;
#endif
  void execute_jtty_tx(qint64 requestId, QString message, bool isFinal = true);
  void execute_jtty_tones(qint64 requestId, QString const& message,
                          int const itone[], int nsym, int frequency = -1);
  void enqueueJttySegments(qint64 requestId, QVector<Jtty::TransmitSegment> segments);
  void enqueueJttyToneSegment(qint64 requestId, QString const& message,
                              int const tones[], int toneCount);
  void feedJttyTransmitQueue();
  void updateJttyTransmitDisplay(qint64 servedSamples);
  void updateJttySendButton();
  void onJttyBackendProgress(TxAudioQueueProgress progress);
  qint64 jttyTxCommittedSamples() const;
  void completeJttyTxEnqueue(qint64 requestId, QString const& message,
                             TxAudioQueueProgress progress, bool newSession,
                             bool useTciAudio);
  void handleJttyContestSerial(QString const& message);
  void abort_jtty_tx();
  void interruptJttyTx();
  void rejectPendingJttyMessages(JttyTxRejectReason reason);
  void sync_tci_tx_volume (bool force = false);
  void onJttyBackendDrained(TxAudioQueueDrainState drain);
  void finishJttyDrain(JttyTxLifecycle::Drain const& drain);
  void onJttyBackendEnqueueAccepted(qint64 enqueueId, qint64 sampleCount,
                                    TxAudioQueueProgress progress);
  void onJttyBackendEnqueueFailed(TxAudioQueueEpoch epoch, qint64 enqueueId,
                                  TxAudioQueueEnqueueFailure failure);
  void handleJttyEnqueueTimeout();
  void handleJttyTxWatchdog();
  void startJttyTxWatchdog(int durationMs);
  bool jtty_key_struck(QKeyEvent * e);
  bool sendJttyFunctionKey(int index);
  struct JttyReceiveState;
  std::shared_ptr<JttyReceiveState> m_jttyReceive;
  void initializeJttyReceive();
  void consumeJttyAudio(JttyReceiveMailboxPtr mailbox);
  void pumpJttyReceive();
  void refreshJttyReceiveLines();
  void cancelJttyReview();
  void finishJttyReception();
  void restartJttyReception();
  void startJttyReview(quint64 reception, qint64 sample, bool picked);
  void decodeJttyDisk(int k);
  void finishJttyDisk();
  void updateJttyReceivePolicy(bool continuous);
  void updateJttyReceiveContext();
  void updateJttySavePolicy();
  void beginJttyDisk();
  bool jttyReviewBusy() const;
  bool jttyDrainInProgress() const;
  bool jttyDiskActive() const;
  void closeAfterJttyDrain();
  bool m_discardJttyWavLoad = false;
  void drainJttyReceive();
  void jtty_again();
  QString jtty_msg_expand(QString msg);
  int jttySnrForSelectedWord(QString const& word, bool leftPane) const;
  QString specOpLabel() const;
  void initializeFFT(int nsps);
  void initializeFFT(int nsps, int fftSize);
  void setTxButtonsEnabled(bool enabled);
  void setDXInfo(QString const& call, QString const& grid);
  void setDecodeTitles(QString const& lh, QString const& rh);
  void setDecodeHeadings(QString const& lh, QString const& rh);
  void updateDecodeAccessibility();

  bool play_DXcall = false;
  bool play_Wanted = false;
  bool inSettings = false;

  quint64 m_startup_trace_run {0};
  bool m_startup_paint_reported {false};
  bool m_startup_decoder_reported {false};
  bool m_startup_audio_reported {false};
  bool m_startup_logbook_reported {false};
  bool m_startup_rig_reported {false};
  bool m_event_filter_ready {false};
  QProcessEnvironment const& m_env;
  NetworkAccessManager m_network_manager;
  bool m_valid;
  QSplashScreen * m_splash;
  QString m_revision;
  bool m_multiple;
  bool m_automated_test;
  MultiSettings * m_multi_settings;
  QPushButton * m_configurations_button;
  QSettings * m_settings;
  QString m_base_style_sheet;
  QScopedPointer<Ui::MainWindow> ui;
  QButtonGroup * m_tx_message_button_group {nullptr};
  QFocusFrame * m_main_window_focus_frame {nullptr};
  QFrame * m_message_selector_focus_frame {nullptr};
  bool m_keyboard_focus_active {false};
  bool m_tx_first_user_enabled {true};
  bool m_tx_first_mode_enabled {true};

#ifdef WIN32
  MMTTYIF * m_mmttyif {nullptr};
#endif

  Configuration m_config;
  QDir m_decoderDataDir;
  LogBook m_logBook;            // must be after Configuration construction
  Cloudlog m_cloudlog;
  WSPRBandHopping m_WSPR_band_hopping;
  BeaconTx::Controller m_beaconTxController;
  MessageBox m_rigErrorMessageBox;
  QScopedPointer<SampleDownloader> m_sampleDownloader;
  QScopedPointer<EqualizationToolsDialog> m_equalizationToolsDialog;

  QScopedPointer<WideGraph> m_wideGraph;
  QScopedPointer<EchoGraph> m_echoGraph;
  QScopedPointer<FastGraph> m_fastGraph;
  QScopedPointer<LogQSO> m_logDlg;
  QScopedPointer<Astro> m_astroWidget;
  QScopedPointer<QSYMessageCreator> m_QSYMessageCreatorWidget;
  QScopedPointer<QSYMessage> m_QSYMessageWidget;
  QScopedPointer<QSYMonitor> m_qsymonitorWidget;
  QScopedPointer<HelpTextWindow> m_shortcuts;
  QScopedPointer<HelpTextWindow> m_prefixes;
  QScopedPointer<HelpTextWindow> m_mouseCmnds;
  QScopedPointer<MessageAveraging> m_msgAvgWidget;
  QScopedPointer<ActiveStations> m_ActiveStationsWidget;
  QScopedPointer<FoxLogWindow> m_foxLogWindow;
  QScopedPointer<CabrilloLogWindow> m_contestLogWindow;
  QScopedPointer<ColorHighlighting> m_colorHighlighting;
  Transceiver::TransceiverState m_rigState;
  QPointer<MessageBox> m_swrWarning;
  Frequency  m_lastDialFreq;
  QString m_lastBand;
  QString m_lastCallsign;
  Frequency  m_dialFreqRxWSPR;  // best guess at WSPR QRG
  bool m_QSYMessageCreatorValue = false;
  bool m_qsymonitorValue = false;

  Detector * m_detector;
  unsigned m_FFTSize;
  AudioInputSource * m_soundInput;
  quint64 m_decodeCycleGeneration {0};
  Modulator * m_modulator;
  QScopedPointer<TxAudioQueue> m_jttyTxQueue;
  JttyTxStream * m_jttyTxStream;
  SoundOutput * m_soundOutput;
  int m_rx_audio_buffer_frames;
  int m_tx_audio_buffer_frames;
  QThread m_audioThread;

  qint64  m_msErase;
  qint64  m_secBandChanged;
  qint64  m_msDecStarted; //ft8md
  qint64  m_freqMoon;
  qint64  m_fullFoxCallTime;
  qint64  m_msEchoTxStart=0;

  OperatingFrequency m_operatingFrequency;
  Frequency m_freqNominalPeriod;
  Frequency m_msk144basefreq {0};
  quint64  m_mslastTX;   //ft8md
  qint32  m_nlasttx;     //ft8md
  qint32  m_lapmyc;      //ft8md
  Astro::Correction m_astroCorrection;
  bool m_reverse_Doppler;

  double  m_tRemaining;
  double  m_TRperiod;
  double  m_fSpread {0.};
  double  m_s6;
  double  m_fDither {0.};
  double  m_fAudioShift {0.};
  double  m_skedFreq {1296.065};

  float   m_DTtol;
  float   m_t0;
  float   m_t1;
  float   m_t0Pick;
  float   m_t1Pick;
  float   m_fCPUmskrtd;
  float   m_tEcho=0;

  qint32  m_waterfallAvg;
  qint32  m_ntx;
  bool m_gen_message_is_cq;
  bool m_send_RR73;
  qint32  m_timeout;
  qint32  m_XIT;
  qint32  m_setftx;
  qint32  m_ndepth;
  qint32  m_ncandthin; //ft8md

  //ft8md
  qint32  m_nFT8Cycles;
  qint32  m_nFT8SWLCycles;
  qint32  m_nFT8RXfSens;
  qint32  m_ft8threads;
  qint32  m_ft8Sensitivity;
  qint32  m_ft8DecoderStart;
  qint32  m_nsecBandChanged;
  qint32  m_nFT4depth;
  qint32  m_nsym_jtty;
  //ft8md

  qint32  m_sec0;
  qint32  m_RxLog;
  qint32  m_nutc0;
  qint32  m_tx;
  quint64  m_mslastMon;
  int     m_addtx;
  quint32 m_delay;
  qint32  m_hsym;
  qint32  m_nsps;
  qint32  m_hsymStop;
  qint32  m_inGain;
  qint32  m_ncw;
  qint32  m_secID;
  qint32  m_idleMinutes;
  qint32  m_nSubMode;
  qint32  m_nclearave;
  bool m_jt65ClearAveragesPending {true};
  bool m_q65ClearAveragesPending {true};
  qint32  m_minSync;
  qint32  m_dBm;
  qint32  m_nWSPRdecodes;
  qint32  m_k0;
  qint32  m_kdone;
  qint32  m_nPick;
  FrequencyList_v2_101::const_iterator m_frequency_list_fcal_iter;
  qint32  m_nTx73;
  qint32  m_UTCdisk;
  QDateTime    m_UTCdiskDateTime;
  qint32  m_wait;
  qint32  m_isort;
  qint32  m_max_dB;
  qint32  m_nDXped=0;
  qint32  m_nSortedHounds=0;
  qint32  m_nHoundsCalling=0;
  qint32  m_Nlist=12;
  qint32  m_Nslots=5;
  qint32  m_Nslots0=0;
  qint32  m_nFoxMsgTimes[5]={0,0,0,0,0};
  qint32  m_tAutoOn;
  qint32  m_tFoxTx=0;
  qint32  m_tFoxTx0=0;
  qint32  m_maxStrikes=3;      //Max # of repeats: 3 strikes and you're out
  qint32  m_maxFoxWait=3;      //Max wait time for expected Hound replies
  qint32  m_foxCQtime=10;      //CQs at least every 5 minutes
  qint32  m_tFoxTxSinceCQ=999; //Fox Tx cycles since most recent CQ
  HoundTransmissionPolicy::State m_houndTransmissionState;
  qint32  m_kin0=0;
  qint32  m_earlyDecode=41;
  qint32  m_earlyDecode2=47;
  qint32  m_nDecodes=0;
  qint32  m_maxPoints=-1;
  qint32  m_latestDecodeTime=-1;
  qint32  m_points=-99;
  qint32  m_score=0;
  qint32  m_fDop=0;
  qint32  m_echoSec0=0;
  qint32  m_fetched=0;
  qint32  m_position;
  qint64  m_decoderDiagSequence=0;
  qint64  m_decoderDiagActiveSequence=0;
  DecoderIpc::InputState m_decoderInput;
  qint32  m_decoderDiagStartIhsym=0;
  qint32  m_decoderDiagStartHsymStop=0;
  qint32  m_decoderDiagStartNzhsym=0;
  qint32  m_decoderDiagStartNewdat=0;
  qint32  m_decoderDiagStartNagain=0;
  qint32  m_decoderDiagStartNdiskdat=0;
  qint32  m_decoderDiagProgressCount=0;
  double  m_decoderDiagStartTRperiod=0.0;
  QElapsedTimer m_decoderDiagElapsedTimer;
  QElapsedTimer m_decoderDiagProgressTimer;
  QString m_decoderDiagStartMode;
  QMap<QString, QDateTime> m_decoderDiagLastSampleUtc;

  bool    m_btxok;		//True if OK to transmit
  bool    m_diskData;
  bool    m_loopall;
  DecodeOwner m_decodeOwner=DecodeOwner::None;
  Jt9ProcessPhase m_jt9ProcessPhase=Jt9ProcessPhase::InitialStarting;
  bool    m_modeLocked = false;
  bool    m_decoderDiagActive=false;
  bool    m_decoderDiagBusyRequestLogged=false;
  bool    m_decoderDiagOverrunLogged=false;
  bool    m_decoderDiagHardHangLogged=false;
  bool    m_decoderDiagAbnormalClear=false;
  bool    m_decoderCompletedSinceStart=false;
  bool    m_closing=false;
  bool    m_txFirst;
  bool    m_tx1_enabled_preference {true};
  bool    m_auto;
  bool    m_restart;
  bool    m_generated_message_error;
  bool    m_startAnother;
  ActiveJt9Decode m_activeJt9Decode;
  DecoderOutputFramer m_decoderOutputFramer;
  Ft8MtdDecodeCoordinator m_ft8MtdDecodeCoordinator;
#if defined (WSJT_ENABLE_LIVE_AUDIO_TEST)
  qint64 m_liveAudioTestPendingFt8FinalPeriod {-1};
  bool m_liveAudioTestAwaitFt8InputCompletion {false};
  bool m_liveAudioTestFt8InputComplete {false};
#endif

  // start ft8md
  bool    m_FT8EarlyStart;   
  bool    m_FT8WideDxCallSearch; 
  bool    m_skipTx1;
  bool    m_swl; 
  bool    m_filter;
  bool    m_agcc;
  bool    m_hint;
  bool	  m_multithreadFT8; 
  bool 	  m_houndMode;
  bool    m_commonFT8b;
  bool	  m_manualDecode;   
  bool	  m_modeChanged;   
  bool    m_bMyCallStd;
  bool    m_bHisCallStd;
  bool    m_multInst;
  bool    m_bandChanged;
  bool 	  m_lasthint; 
  // end ft8md

  bool    m_saveDecoded;
  bool    m_saveAll;
  bool    m_widebandDecode;
  bool    m_call3Modified;
  bool    m_dataAvailable;
  bool    m_bDecoded;
  bool    m_noSuffix;
  bool    m_sentFirst73;
  bool	  m_tci_mod_active;
  bool    m_tci;
  bool    m_tci_audio;
  int     m_currentMessageType;
  QString m_currentMessage;
  int     m_lastMessageType;
  QString m_lastMessageSent;
  QString m_tBlankLine;
  bool    m_bShMsgs;
  bool    m_bSWL;
  bool    m_uploadWSPRSpots;
  bool    m_grid6;
  bool    m_bTxTime;
  bool    m_bSimplex; // not using split even if it is available
  bool    m_bEchoTxOK;
  bool    m_bTransmittedEcho;
  bool    m_bEchoTxed;
  bool    m_bFastMode=false;
  bool    m_bFast9;
  bool    m_bFastDecodeCalled;
  bool    m_bDoubleClickAfterCQnnn;
  bool    m_bRefSpec;
  bool    m_bClearRefSpec;
  bool    m_bTrain;
  bool    m_bUseRef;
  bool    m_bFastDone;
  bool    m_bAltV;
  bool    m_bNoMoreFiles;
  bool    m_bDoubleClicked;
  bool    m_bCallingCQ;
  bool    m_bAutoReply;
  QString m_lastloggedcall; //ft8md
  bool    m_contestModeHintShown;
  bool    m_bWarnedSplit=false;
  bool    m_bTUmsg;
  bool    m_bBestSPArmed=false;
  bool    m_bOK_to_chk=false;
  bool    m_bSentReport=false;
  bool    m_discard_decoded_hounds_this_cycle=false;     // if something changes, like frequency, discard decoded messages that may be in-flight.
  bool    m_houndVerified=false;

  SpecOp  m_specOp;

  static constexpr QsoProgress CALLING {QsoProgress::Calling};
  static constexpr QsoProgress REPLYING {QsoProgress::Replying};
  static constexpr QsoProgress REPORT {QsoProgress::Report};
  static constexpr QsoProgress ROGER_REPORT {QsoProgress::RogerReport};
  static constexpr QsoProgress ROGERS {QsoProgress::Rogers};
  static constexpr QsoProgress SIGNOFF {QsoProgress::Signoff};
  QsoProgress m_QSOProgress;

  enum {CALL, GRID, DXCC, MULT};

  int			m_ihsym;
  int			m_nzap;
  int			m_npts8;
  float		m_px;
  float   m_pxmax;
  float		m_df3;
  int			m_iptt0;
  bool		m_btxok0;
  int			m_nsendingsh;
  double	m_onAirFreq0;
  bool		m_first_error;

  char    m_msg[100][80];

  // labels in status bar
  QLabel tx_status_label;
  bool m_tx_inhibited {false};
  QLabel config_label;
  QLabel mode_label;
  QLabel last_tx_label;
  QLabel auto_tx_label;
  QLabel band_hopping_label;
  QLabel swr_label;
  QLabel ndecodes_label;
  QProgressBar progressBar;
  QLabel watchdog_label;
  QLabel * m_txFrequencyLabel {};
  QLabel * m_frequencyToleranceLabel {};
  QLabel * m_rxFrequencyLabel {};
  QLabel * m_reportLabel {};
  QLabel * m_trPeriodLabel {};
  QLabel * m_submodeLabel {};
  QLabel * m_maxDriftLabel {};
  QHBoxLayout * m_frequencyToleranceRow {};
  QHBoxLayout * m_modeCheckboxRow {};
  WavLoadCoordinator m_wav_load_coordinator;
  QFutureWatcher<FastDecodeResult> watcher3;
  bool m_fastDecodePending = false;
  ReferenceSpectrumInput m_referenceInput;
  ReceiveAudioConsumer m_receiveConsumer;
  QQueue<ReceiveAudio> m_receiveQueue;
  ReceiveAudio m_activeReceiveAudio;
  bool m_receivingAudio = false;
  QFutureSynchronizer<QString> m_saveWAVSynchronizer;
  QFutureWatcher<QString> m_saveWAVWatcher;

  NonInheritingProcess proc_jt9;
  NonInheritingProcess p1;
  NonInheritingProcess p3;

  QProcess p2;
  QProcess p4;

  WSPRNet *wsprNet;
  EQSL *Eqsl;

  QTimer m_guiTimer;
  QTimer m_decoderShutdownTimer;
  QTimer m_decoderTerminateTimer;
  QTimer m_decoderKillTimer;
  QTimer m_decoderStartTimer;
  QTimer stopWRTimer;               //Wait & Reply
  QTimer stopWCTimer;               //Wait & Call
  QTimer ptt1Timer;                 //StartTx delay
  QTimer ptt0Timer;                 //StopTx delay
  QTimer logQSOTimer;
  QTimer killFileTimer;
  QTimer tuneButtonTimer;
  QTimer rigTuneTimer;
  QTimer uploadTimer;
  QTimer tuneATU_Timer;
  QTimer TxAgainTimer;
  QTimer minuteTimer;
  QTimer splashTimer;
  QTimer p1Timer;
  QTimer m_jttyTxWatchdog;
  QTimer m_jttyEnqueueWatchdog;
  QTimer m_refSpecTimer;
  AutoRespondSelectionLatch m_autoRespondSelectionLatch;
  AutoRespondScores m_autoRespondScores;
  AutoRespondPeriodState m_autoRespondPeriodState;
  int m_refSpecSecondsRemaining = 0;

  QString m_path;
  QString m_baseCall;
  QString m_hisCall;
  QString m_hisGrid;
  int m_jttyHisCallSnr = -10;  // SNR of the decode selected as DX call, for %R; cleared when the DX call changes
  int m_jttyMessageStyle = 0;  // Jtty::MessageStyle: 0=Contest, 1=Ft8 (see JttyMessages.hpp)
  QString m_appDir;
  QString m_cqStr;
  QString m_palette;
  QString m_dateTime;
  QString m_mode;
  QString m_fnameWE;            // save path without extension
  QString m_rpt;
  QString m_nextRpt;
  QString m_rptSent;
  QString m_rptRcvd;
  QString m_qsoStart;
  QString m_qsoStop;
  QStringList m_cmndP1;
  QString m_msgSent0;
  QString m_calls;
  QString m_CQtype;
  QString m_opCall;
  QString m_houndCallers;        //Sorted list of Hound callers
  QString m_fm0;
  QString m_fm1;
  QString m_xSent;               //Contest exchange sent
  QString m_xRcvd;               //Contest exchange received
  QString m_currentBand;
  QString m_currentBandPeriod;
  QString m_nextCall;
  QString m_nextGrid;
  QString m_fileDateTime;
  QString m_inQSOwith;
  QString m_BestCQpriority;
  QString m_deCall;
  QString m_deGrid;
  QString m_freeTextMsg;
  QString m_freeTextMsg0;
  std::array<QString, MaxActiveStationRows> m_ready2call;
  std::array<QString, MaxQ65PileupCallers> m_callers;
  // Q65 Pileup mode: selected DX call whose last Tx was copied by a decode.
  // The value is consumed by the next matching Q65 Tx message.
  QString m_q65PileupCopiedLastRxCall;
  // Q65 Pileup mode: callers whose latest decode carried the copied flag ('#'); a standing display annotation, cleared only on leaving the Pileup context, not per decode pass.
  QSet<QString> m_q65PileupCopiedCallers;

  QSet<QString> m_pfx;
  QSet<QString> m_sfx;

  struct FoxQSO       //Everything we need to know about QSOs in progress (or recently logged).
  {
    QString grid;       //Hound's declared locator
    QString sent;       //Report sent to Hound
    QString rcvd;       //Report received from Hound
    qint32  ncall;      //Number of times report sent to Hound
    qint32  nRR73;      //Number of times RR73 sent to Hound
    qint32  tFoxRrpt;   //m_tFoxTx (Fox Tx cycle counter) when R+rpt was received from Hound
    qint32  tFoxTxRR73; //m_tFoxTx when RR73 was sent to Hound
  };

  QMap<QString,FoxQSO> m_foxQSO;       //Key = HoundCall, value = parameters for QSO in progress
  QMap<QString,QString> m_loggedByFox; //Key = HoundCall, value = logged band
  QMap<QString,qint32> m_annotated_callsigns;  //Key = HoundCall, value = provided by api call

  struct FixupQSO       //Info for fixing Fox's log from file "FoxQSO.txt"
  {
    QString grid;       //Hound's declared locator
    QString sent;       //Report sent to Hound
    QString rcvd;       //Report received from Hound
    QDateTime QSO_time;
  };
  QMap<QString,FixupQSO> m_fixupQSO;       //Key = HoundCall, value = info for QSO in progress

  struct ActiveCall
  {
    QString grid4;
    QString bands;
    qint32 az;
    qint32 points;
  };
  QMap<QString,ActiveCall> m_activeCall;   //Key = callsign, value = grid4, az, points for ARRL_DIGI

  struct EMECall
  {
    QString grid4;
    double frx;
    double fsked;
    qint32 nsnr;
    qint32 t;
    bool worked;
    bool ready2call;
    QString submode;
  };
  QMap<QString,EMECall> m_EMECall;

  QMap<QString,bool> m_EMEworked;

  struct RecentCall
  {
    qint64 dialFreq;
    qint32 audioFreq;
    qint32 snr;
    qint32 decodeTime;
    bool   txEven;
    bool   ready2call;
  };
  QMap<QString,RecentCall> m_recentCall;   //Key = callsign, value = snr, dialFreq, audioFreq, decodeTime
  struct ARRL_logged
  {
    QDateTime time;
    QString band;
    qint32 points;
  };
  QList<ARRL_logged> m_arrl_log;

  QQueue<QString> m_houndQueue;        //Selected Hounds available for starting a QSO
  QQueue<QString> m_foxQSOinProgress;  //QSOs in progress: Fox has sent a report
  QQueue<qint64>  m_foxRateQueue;

  QDateTime m_dateTimeQSOOn;
  QDateTime m_dateTimeLastTX;
  QDateTime m_dateTimeSentTx3;
  QDateTime m_dateTimeRcvdRR73;
  QDateTime m_dateTimeBestSP;
  QDateTime m_dateTimeSeqStart;        //Nominal start time of Rx sequence about to be decoded

  DecoderIpc::Session& m_decoderSession;
  QString m_QSOText;
  unsigned m_downSampleFactor;
  QThread::Priority m_audioThreadPriority;
  bool m_bandEdited;
  bool m_splitMode;
  bool m_monitoring=false;
  bool m_echoRunning=false;
  bool m_tx_when_ready;
  bool m_transmitting;
  bool m_tune;
  bool m_tx_watchdog;           // true when watchdog triggered
  TxEvidence::TxPlaybackDiagnostics m_txPlaybackDiagnostics;
  TxEvidence::TxSessionId m_txEvidenceSession;
  TxEvidence::TxSessionId m_txEvidenceSourceSession;
  TxEvidence::TxGeneration m_txEvidenceGeneration;
  TxEvidence::TxStopReason m_pendingTxStopReason {TxEvidence::TxStopReason::NormalEnd};
#if defined (WSJT_ENABLE_LIVE_AUDIO_TEST)
  qint64 m_liveAudioTestFt8StartWindowOpenMs {-1};
  qint64 m_liveAudioTestFt8StartWindowCloseMs {-1};
  qint64 m_liveAudioTestFt8StartSessionId {-1};
  qint64 m_liveAudioTestFt8StartGeneration {-1};
#endif
  JttyTxLifecycle m_jttyTxLifecycle;
  JttyTxLifecycle::StopContext m_delayedJttyStopContext;
  struct PendingJttyMessage
  {
    TxAudioQueueEpoch epoch;
    qint64 enqueueId;
    qint64 requestId;
    qint64 sampleCount;
    QString message;
    bool newSession;
  };
  QVector<PendingJttyMessage> m_pendingJttyMessages;
  Jtty::TransmitQueue m_jttyTransmitQueue;
  TxAudioQueueProgress m_jttyQueueProgress;
  bool m_feedingJttyTransmitQueue {false};
  qint64 m_jttyDisplayedEndSample {0};
  QString m_jttyQueueNotice;
  bool m_jttyLiveEntryArmed {false};
  bool m_guardingJttyLiveEntryLock {false};
  int m_jttyLiveEntryCommitted {0};   // Tx_Message chars already sent/queued; locked against edits.
  QString m_jttyLiveEntryLockedText;  // cached committed prefix, to detect edits that touch it
  struct PendingLiveEntryCommit { qint64 requestId; int start, end; int totalFrames {0}; };
  // Committed spans not yet confirmed fully transmitted; drives progressive sent/queued coloring and reject-triggered unlocking.
  QVector<PendingLiveEntryCommit> m_jttyLiveEntryPending;
  // Frames from commits that have fully drained since the box was last cleared; the frame-count label adds this to still-pending progress.
  int m_jttyLiveEntryFramesSent {0};
  // Fires a batch flush of whatever's safely committable after a short typing pause, so auto-advance doesn't wait indefinitely for kJttyAutoAdvanceBatchWords to pile up on a short message.
  QTimer m_jttyAutoAdvanceIdleTimer;
  qint64 m_jttyTxRequestId;
  qint64 m_jttyEnqueueId;
#ifdef WIN32
  Jtty::N1mmOutput m_mmttyJttyOutput;
  struct PendingMmttyJttyMessage
  {
    qint64 requestId;
    QString message;
    QVector<int> tones;
    bool literal {false};
  };
  QVector<PendingMmttyJttyMessage> m_pendingMmttyJttyMessages;
  Jtty::MmttyHandoff m_mmttyHandoff;
  QTimer m_mmttyHandoffWatchdog;
  bool m_preserveMmttyOutputDuringStop {false};
#endif
  bool m_block_pwr_tooltip;
  bool m_PwrBandSetOK;
  bool m_bDisplayedOnce;
  double m_toneSpacing;
  QTimer m_heartbeat;
  MessageClient * m_messageClient;
  PSKReporter m_psk_Reporter;
  DisplayManual m_manual;
  QHash<QString, QVariant> m_pwrBandTxMemory; // Remembers power level by band
  QHash<QString, QVariant> m_pwrBandTuneMemory; // Remembers power level by band for tuning
  QByteArray m_geometryNoControls;
  QVector<double> m_phaseEqCoefficients;
  bool m_block_udp_status_updates;
  bool m_useDarkStyle;

  //---------------------------------------------------- private functions
  void readSettings();
  void configureModeControlsLayout();
  void updateModeControlsLayout();
  void applyApplicationStyle(QFont const&, bool dark);
  void setTrPeriodVisible(bool);
  void set_application_font (QFont const&);
  void updateMainWindowControlSizes();
  void updateFrequencyToleranceRowAlignment();
  void setDecodedTextFont (QFont const&);
  void writeSettings();
  void createStatusBar();
  void handleTxInhibitStatus (bool supported, bool inhibited, QString const& holder,
                              quint32 hold_rx, quint32 release_rx,
                              quint32 expiries, quint32 invalid);
  void startTxAudioAfterPttDelay ();
  void updateRigMeters (Transceiver::TransceiverState const&);
  bool stopForHighSWR (Transceiver::TransceiverState const&);
  void showHighSWRWarning (unsigned swr);
  void updateStatusBar();
  void updateMainWindowAccessibility();
  void registerMainWindowFocusControls();
  std::array<QRadioButton *, 6> txNextButtons() const;
  std::array<QWidget *, 13> focusIndicatorWidgets() const;
  void showMainWindowFocusIndicator(QWidget *widget);
  void hideMainWindowFocusIndicators();
  void updateTxNextFocusPolicies();
  void updateTxFirstEnabledState();
  void setTxFirstModeEnabled(bool enabled);
  bool switchTxNextMessage(QKeyEvent const *key_event);
  bool switchMainWindowTab(QKeyEvent const *key_event);
  void genStdMsgs(QString rpt, bool unconditional = false);
  void genCQMsg();
  void clearDX ();
  void lookup();
  QString expandTxMacros(QString const& message) const;
  void ba2msg(QByteArray ba, char* message);
  void msgtype(QString t, QLineEdit* tx);
  void show_generated_message_error ();
  void clear_generated_message_error ();
  void update_generated_message_error ();
  void stub();
  void statusChanged();
  void fixStop();
  void finishReferenceSpectrumMeasurement(bool notify);
  void updateReferenceSpectrumCountdown();
  bool shortList(QString callsign) const;
  void transmit (double snr = 99.);
  void rigFailure (QString const& reason);
  void pskSetLocal ();
  void pskPost(DecodedText const& decodedtext);
  void pskPost(DecodedText const& decodedtext,
               DecodeOperatingContext const& context);
  void displayDialFrequency ();
  void transmitDisplay (bool);
  void handleDecodeSelection(QString const& line, QString const& word,
                             Qt::KeyboardModifiers modifiers,
                             DecodedMessageReaction::SelectionOrigin selection_origin);
  void processMessage(DecodedText const& message, Qt::KeyboardModifiers modifiers,
                      DecodedMessageReaction::SelectionOrigin selection_origin);
  void processSyntheticMessage(DecodedText const& message);
  DecodedMessageReaction::QsoReactionSnapshot qsoReactionSnapshot(
    Qt::KeyboardModifiers modifiers = Qt::NoModifier) const;
  DecodedMessageReaction::QsoReactionSnapshot qsoReactionSnapshot(
    Qt::KeyboardModifiers modifiers,
    DecodedMessageReaction::SelectionOrigin selection_origin) const;
  void applyQsoReactionPlan(DecodedMessageReaction::QsoReactionPlan const& plan,
                            DecodedText const& message, bool * block_right_display = nullptr);
  void applyQsoReactionEffect(DecodedMessageReaction::QsoReactionEffect const& effect,
                              DecodedText const& message, bool * block_right_display);
  void showContestHint(DecodedMessageReaction::ContestHint hint);
  void refreshQsoPane(DecodedText const& message);
  void replyToCQ (QTime, qint32 snr, float delta_time, quint32 delta_frequency, QString const& mode, QString const& message_text, bool low_confidence, quint8 modifiers);
  void locationChange(QString const& location);
  void replayDecodes ();
  void postDecode (bool is_new, QString const& message);
  void postWSPRDecode (bool is_new, QStringList message_parts);
  void enable_DXCC_entity (bool on);
  void switch_mode (Mode);
  bool hasMsk144BaseFrequency () const {return m_msk144basefreq > 0;}
  BeaconTx::RoundRobinPolicy beaconRoundRobinPolicy () const;
  BeaconTx::RoundRobinPolicy configuredRoundRobinPolicy () const;
  void enterBeaconMode ();
  void processBeaconActions (BeaconTx::Controller::Actions actions);
  BeaconTx::ScheduleProposal beaconScheduleProposal ();
  bool applyBeaconBandChange (BeaconTx::HoppingProposal const& proposal);
  void freqCalStep();
  RigFrequencyChangePolicy::Activity rigFrequencyActivity () const;
  RigFrequencyChangePolicy::Decision rigFrequencyChangeDecision (
    RigFrequencyChangePolicy::ChangeKind) const;
  bool nominalFrequencyChangeAllowed (FrequencyRequestOrigin);
  bool requestNominalFrequencyChange (Frequency, FrequencyRequestOrigin);
  bool dispatchNominalFrequency (Frequency corrected, FrequencyRequestOrigin, bool monitoring);
  bool requestBandChange (Frequency, FrequencyRequestOrigin);
  bool workingFrequencyAt (int row, Frequency&) const;
  void applyBandChange (Frequency, Frequency previous_frequency);
  bool requestBandButtonFrequency (Frequency lookup_frequency, Frequency fallback_frequency,
                                   double msk144_tr_period = 0.);
  bool requestAlternateBandFrequency (Frequency);
  bool reapplyCurrentRigFrequencyCorrection ();
  void restoreNominalFrequencySelection ();
  void WSPR_history(Frequency dialFreq, int ndecodes);
  QString beacon_start_time (int n = 0);
  QString WSPR_message();
  void fast_config(bool b);
  void CQTxFreq();
  void useNextCall();
  void abortQSO();
  void updateRate();
  void write_all(QString txRx, QString message,
                 DecodeOperatingContext const * context = nullptr);
  bool isWorked(int itype, QString key, float fMHz=0, QString="");

  void hound_reply (int foxFrequency);
  QString sortHoundCalls(QString t, int isort, int max_dB);
  void rm_tb4(QString houndCall);
  void read_wav_file (QString const& fname);
  void wav_file_loaded ();
  void update_wav_file_actions ();
  void finishDecodeUi ();
  bool subProcessFailed (QProcess *, int exit_code, QProcess::ExitStatus);
  void subProcessError (QProcess *, QProcess::ProcessError);
  void statusUpdate () const;
  void update_watchdog_label ();
  bool normalWatchdogWarningActive () const;
  bool isHoundOperation () const;
  bool isSuperHoundOperation () const;
  void updateHoundVerificationStyle ();
  void invalidate_frequencies_filter ();
  void on_the_minute ();
  void add_child_to_event_filter (QObject *);
  void remove_child_from_event_filter (QObject *);
  void setup_status_bar (bool vhf);
  void tx_watchdog (bool triggered);
  enum class ModeUiControl
  {
    TxFirst,
    TxFrequency,
    RxFrequency,
    FrequencyTolerance,
    Report,
    TrPeriod,
    CqTxFrequency,
    ShortMessages,
    Fast9,
    AutoSequence,
    Tx6,
    CopyRxToTx,
    CopyTxToRx,
    HoldTxFrequency,
    Submode,
    Sync,
    WsprControls,
    ClearAverage,
    DecodeDepth,
    IncludeAveraging,
    IncludeCorrelation,
    EchoGraph,
    Swl,
    ApFt8,
    ApJt65,
    ApDxCall,
    Respond,
    Measure,
    DxpedLabel,
    RxAll,
    CqOnly,
    Fst4wTrPeriod,
    LowFrequency,
    HighFrequency,
    AutoClearAverage,
    MaxDrift,
    FoxQueueTab
  };
  using ModeUiState = std::initializer_list<ModeUiControl>;
  void applyModeUiState(ModeUiState);
  QChar current_submode () const; // returns QChar {0} if submode is not appropriate
  void write_transmit_entry (QString const& file_name);
  void selectHound(QString t, bool bTopQueue);
  void removeHoundFromCallingList(QString callsign);
  void houndCallers();
  void updateFoxQSOsInProgressDisplay();
  void foxQueueTopCallCommand();
  void foxRxSequencer(QString msg, QString houndCall, QString rptRcvd);
  bool foxTxSequencer();
  void foxGenWaveform(int i,QString fm);
  void writeFoxQSO (QString const& msg);
  void update_foxLogWindow_rate();
  DecodePublishResult publishDecodeRequest(
      bool copySamples,
      Ft8MtdDecodeCoordinator::Stage ft8Stage = Ft8MtdDecodeCoordinator::Stage::None,
      qint64 ft8Period = -1);
  DecodePublishResult publishPendingFt8Decode ();
  void decode (Ft8MtdDecodeCoordinator::Stage stage, qint64 ft8Period = -1);
  qint64 currentFt8DecodePeriod () const;
  void beginDecoderInput ();
  bool usesFt8MtdFinal () const;
  int configuredFt8MtdEarlyStageCount () const;
  std::unique_ptr<Ft8MtdDecodeCoordinator::PendingMtdDecode>
    capturePendingFt8MtdDecode (qint64 period);
  void cancelPendingFt8Decode (QString const& reason);
  void reportFt8BackpressureDecision (
      Ft8MtdDecodeCoordinator::Decision const& decision, qint64 period);
  void reportFt8BackpressureRecovery (qint64 period);
  void emitFt8DecoderInvocation (decoder_params_t const& params) const;
  bool handleDecoderOutputEvent(DecoderOutputFramer::Event const& event,
                                bool& decodeCompleted);
  DecodeOperatingContext currentDecodeOperatingContext() const;
  bool decodeOperatingContextMatchesCurrent(
      DecodeOperatingContext const& context) const;
  bool pendingFt8DecodeOperatingContextMatchesCurrent(
      DecodeOperatingContext const& context) const;
  bool activeDecodeOperatingContextMatchesCurrent() const;
  bool initializeDecoderSharedMemory();
  void startDecoderProcess();
  void failDecoderStartup(QString const& reason);
  bool beginDecode(
      DecodeOwner owner, decoder_params_t const * diagnosticParams = nullptr,
      DecodeOperatingContext const * diagnosticContext = nullptr);
  void endDecode(DecodeOwner owner,
                 DecodeEndState state = DecodeEndState::Completed);
  void updateDecodeControls();
  bool usesJt9Process() const;
  bool decoderRestartInProgress() const;
  void abortJt9Transaction();
  void recoverDecoderAtBoundary(QString const& reason, bool manual);
  void requestDecoderRestart(QString const& reason);
  qint64 decoderDiagnosticElapsedMs() const;
  qint64 decoderDiagnosticIdleMs() const;
  qint64 decoderRequestDeadlineMs() const;
  bool decoderRequestDeadlineExpired() const;
  void beginDecoderDiagnostic(
      decoder_params_t const * params = nullptr,
      DecodeOperatingContext const * context = nullptr);
  void markDecoderProgress();
  void logDecoderBusyRequest(QString const& reason);
  void logDecoderProgress();
  void logDecoderAbnormalClear(QString const& reason);
  void finishDecoderDiagnostic();
  void clearHungDecoderStatus(QString const& reason);
  bool is77BitMode () const;
  void cease_auto_Tx_after_QSO ();
  Q_SLOT void ARRL_Digi_Display();
  void ARRL_Digi_Update(DecodedText dt);
  void activeWorked(QString call, QString band);
  void read_log();
  void refreshPileupList();
  void handleVerifyMsg(int status, QDateTime ts, QString callsign, QString code, unsigned int hz, QString const &response);
  void writeFoxTxMsgs();
#ifdef FOX_OTP
  QString foxOTPcode();
#endif
};

extern int killbyname(const char* progName);
extern void getDev(int* numDevices,char hostAPI_DeviceName[][50],
                   int minChan[], int maxChan[],
                   int minSpeed[], int maxSpeed[]);
extern int next_tx_state(int pctx);

#endif // MAINWINDOW_H