Qt v5.15 compatibility

This commit is contained in:
Bill Somerville 2020-06-13 16:04:41 +01:00
parent 4913929c99
commit 4e07c9abc1
No known key found for this signature in database
GPG Key ID: D864B06D1E81618F
27 changed files with 459 additions and 150 deletions

View File

@ -67,16 +67,34 @@ public:
private: private:
Q_SLOT void start_recording () Q_SLOT void start_recording ()
{ {
qtout << "started recording at " << QDateTime::currentDateTimeUtc ().toString ("hh:mm:ss.zzz UTC") << endl; qtout << "started recording at " << QDateTime::currentDateTimeUtc ().toString ("hh:mm:ss.zzz UTC")
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
<< Qt::endl
#else
<< endl
#endif
;
source_.start (output_); source_.start (output_);
if (!notify_interval_) QTimer::singleShot (duration_ * 1000, Qt::PreciseTimer, this, &Record::stop_recording); if (!notify_interval_) QTimer::singleShot (duration_ * 1000, Qt::PreciseTimer, this, &Record::stop_recording);
qtout << QString {"buffer size used is: %1"}.arg (source_.bufferSize ()) << endl; qtout << QString {"buffer size used is: %1"}.arg (source_.bufferSize ())
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
<< Qt::endl
#else
<< endl
#endif
;
} }
Q_SLOT void notify () Q_SLOT void notify ()
{ {
auto length = source_.elapsedUSecs (); auto length = source_.elapsedUSecs ();
qtout << QString {"%1 μs recorded\r"}.arg (length) << flush; qtout << QString {"%1 μs recorded\r"}.arg (length)
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
<< Qt::flush
#else
<< flush
#endif
;
if (length >= duration_ * 1000 * 1000) stop_recording (); if (length >= duration_ * 1000 * 1000) stop_recording ();
} }
@ -85,7 +103,13 @@ private:
auto length = source_.elapsedUSecs (); auto length = source_.elapsedUSecs ();
source_.stop (); source_.stop ();
qtout << QString {"%1 μs recorded "}.arg (length) << '(' << source_.format ().framesForBytes (output_->size ()) << " frames recorded)\n"; qtout << QString {"%1 μs recorded "}.arg (length) << '(' << source_.format ().framesForBytes (output_->size ()) << " frames recorded)\n";
qtout << "stopped recording at " << QDateTime::currentDateTimeUtc ().toString ("hh:mm:ss.zzz UTC") << endl; qtout << "stopped recording at " << QDateTime::currentDateTimeUtc ().toString ("hh:mm:ss.zzz UTC")
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
<< Qt::endl
#else
<< endl
#endif
;
Q_EMIT done (); Q_EMIT done ();
} }
@ -134,15 +158,33 @@ public:
private: private:
Q_SLOT void start_playback () Q_SLOT void start_playback ()
{ {
qtout << "started playback at " << QDateTime::currentDateTimeUtc ().toString ("hh:mm:ss.zzz UTC") << endl; qtout << "started playback at " << QDateTime::currentDateTimeUtc ().toString ("hh:mm:ss.zzz UTC")
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
<< Qt::endl
#else
<< endl
#endif
;
sink_.start (input_); sink_.start (input_);
qtout << QString {"buffer size used is: %1 (%2 frames)"}.arg (sink_.bufferSize ()).arg (sink_.format ().framesForBytes (sink_.bufferSize ())) << endl; qtout << QString {"buffer size used is: %1 (%2 frames)"}.arg (sink_.bufferSize ()).arg (sink_.format ().framesForBytes (sink_.bufferSize ()))
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
<< Qt::endl
#else
<< endl
#endif
;
} }
Q_SLOT void notify () Q_SLOT void notify ()
{ {
auto length = sink_.elapsedUSecs (); auto length = sink_.elapsedUSecs ();
qtout << QString {"%1 μs rendered\r"}.arg (length) << flush; qtout << QString {"%1 μs rendered\r"}.arg (length) <<
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
Qt::flush
#else
flush
#endif
;
} }
Q_SLOT void sink_state_changed (QAudio::State state) Q_SLOT void sink_state_changed (QAudio::State state)
@ -175,7 +217,13 @@ private:
auto length = sink_.elapsedUSecs (); auto length = sink_.elapsedUSecs ();
sink_.stop (); sink_.stop ();
qtout << QString {"%1 μs rendered "}.arg (length) << '(' << sink_.format ().framesForBytes (input_->size ()) << " frames rendered)\n"; qtout << QString {"%1 μs rendered "}.arg (length) << '(' << sink_.format ().framesForBytes (input_->size ()) << " frames rendered)\n";
qtout << "stopped playback at " << QDateTime::currentDateTimeUtc ().toString ("hh:mm:ss.zzz UTC") << endl; qtout << "stopped playback at " << QDateTime::currentDateTimeUtc ().toString ("hh:mm:ss.zzz UTC")
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
<< Qt::endl
#else
<< endl
#endif
;
Q_EMIT done (); Q_EMIT done ();
} }
@ -258,7 +306,13 @@ int main(int argc, char *argv[])
int n {0}; int n {0};
for (auto const& device : input_devices) for (auto const& device : input_devices)
{ {
qtout << ++n << " - [" << device.deviceName () << ']' << endl; qtout << ++n << " - [" << device.deviceName () << ']'
#if QT_VERSION >= QT_VERSION_CHECK (5, 15, 0)
<< Qt::endl
#else
<< endl
#endif
;
} }
return 0; return 0;
} }
@ -269,7 +323,13 @@ int main(int argc, char *argv[])
int n {0}; int n {0};
for (auto const& device : output_devices) for (auto const& device : output_devices)
{ {
qtout << ++n << " - [" << device.deviceName () << ']' << endl; qtout << ++n << " - [" << device.deviceName () << ']'
#if QT_VERSION >= QT_VERSION_CHECK (5, 15, 0)
<< Qt::endl
#else
<< endl
#endif
;
} }
return 0; return 0;
} }
@ -352,7 +412,13 @@ int main(int argc, char *argv[])
auto source = input_device ? input_devices[input_device - 1] : QAudioDeviceInfo::defaultInputDevice (); auto source = input_device ? input_devices[input_device - 1] : QAudioDeviceInfo::defaultInputDevice ();
if (!source.isFormatSupported (audio_format)) if (!source.isFormatSupported (audio_format))
{ {
qtout << "warning, requested format not supported, using nearest" << endl; qtout << "warning, requested format not supported, using nearest"
#if QT_VERSION >= QT_VERSION_CHECK (5, 15, 0)
<< Qt::endl
#else
<< endl
#endif
;
audio_format = source.nearestFormat (audio_format); audio_format = source.nearestFormat (audio_format);
} }
BWFFile output_file {audio_format, ofi.filePath ()}; BWFFile output_file {audio_format, ofi.filePath ()};

View File

@ -887,7 +887,7 @@ message (STATUS "hamlib_LIBRARY_DIRS: ${hamlib_LIBRARY_DIRS}")
# #
# Widgets finds its own dependencies. # Widgets finds its own dependencies.
find_package (Qt5 COMPONENTS Widgets Multimedia PrintSupport Sql LinguistTools REQUIRED) find_package (Qt5 COMPONENTS Widgets SerialPort Multimedia PrintSupport Sql LinguistTools REQUIRED)
if (WIN32) if (WIN32)
add_definitions (-DQT_NEEDS_QTMAIN) add_definitions (-DQT_NEEDS_QTMAIN)
@ -1378,9 +1378,9 @@ set_target_properties (wsjtx PROPERTIES
target_include_directories (wsjtx PRIVATE ${FFTW3_INCLUDE_DIRS}) target_include_directories (wsjtx PRIVATE ${FFTW3_INCLUDE_DIRS})
if (APPLE) if (APPLE)
target_link_libraries (wsjtx wsjt_fort wsjt_cxx wsjt_qt wsjt_qtmm ${hamlib_LIBRARIES} ${FFTW3_LIBRARIES}) target_link_libraries (wsjtx Qt5::SerialPort wsjt_fort wsjt_cxx wsjt_qt wsjt_qtmm ${hamlib_LIBRARIES} ${FFTW3_LIBRARIES})
else () else ()
target_link_libraries (wsjtx wsjt_fort_omp wsjt_cxx wsjt_qt wsjt_qtmm ${hamlib_LIBRARIES} ${FFTW3_LIBRARIES}) target_link_libraries (wsjtx Qt5::SerialPort wsjt_fort_omp wsjt_cxx wsjt_qt wsjt_qtmm ${hamlib_LIBRARIES} ${FFTW3_LIBRARIES})
if (OpenMP_C_FLAGS) if (OpenMP_C_FLAGS)
set_target_properties (wsjtx PROPERTIES set_target_properties (wsjtx PROPERTIES
COMPILE_FLAGS "${OpenMP_C_FLAGS}" COMPILE_FLAGS "${OpenMP_C_FLAGS}"
@ -1396,7 +1396,6 @@ else ()
) )
endif () endif ()
endif () endif ()
qt5_use_modules (wsjtx SerialPort) # not sure why the interface link library syntax above doesn't work
# make a library for WSJT-X UDP servers # make a library for WSJT-X UDP servers
# add_library (wsjtx_udp SHARED ${UDP_library_CXXSRCS}) # add_library (wsjtx_udp SHARED ${UDP_library_CXXSRCS})
@ -1416,8 +1415,7 @@ set_target_properties (wsjtx_udp-static PROPERTIES
OUTPUT_NAME wsjtx_udp OUTPUT_NAME wsjtx_udp
) )
target_compile_definitions (wsjtx_udp-static PUBLIC UDP_STATIC_DEFINE) target_compile_definitions (wsjtx_udp-static PUBLIC UDP_STATIC_DEFINE)
#qt5_use_modules (wsjtx_udp Network) target_link_libraries (wsjtx_udp-static Qt5::Network Qt5::Gui)
qt5_use_modules (wsjtx_udp-static Network Gui)
generate_export_header (wsjtx_udp-static BASE_NAME udp) generate_export_header (wsjtx_udp-static BASE_NAME udp)
add_executable (udp_daemon UDPExamples/UDPDaemon.cpp UDPExamples/udp_daemon.rc ${WSJTX_ICON_FILE}) add_executable (udp_daemon UDPExamples/UDPDaemon.cpp UDPExamples/udp_daemon.rc ${WSJTX_ICON_FILE})

View File

@ -3,6 +3,7 @@
#include <QStringList> #include <QStringList>
#include <QRegularExpression> #include <QRegularExpression>
#include <QDebug> #include <QDebug>
#include "qt_helpers.hpp"
extern "C" { extern "C" {
bool stdmsg_(char const * msg, fortran_charlen_t); bool stdmsg_(char const * msg, fortran_charlen_t);
@ -58,7 +59,7 @@ QStringList DecodedText::messageWords () const
return words_re.match(t).capturedTexts(); return words_re.match(t).capturedTexts();
} }
// simple word split for free text messages // simple word split for free text messages
auto words = message_.split (' ', QString::SkipEmptyParts); auto words = message_.split (' ', SkipEmptyParts);
// add whole message as item 0 to mimic RE capture list // add whole message as item 0 to mimic RE capture list
words.prepend (message_); words.prepend (message_);
return words; return words;
@ -122,7 +123,7 @@ bool DecodedText::report(QString const& myBaseCall, QString const& dxBaseCall, /
{ {
if (message_.size () < 1) return false; if (message_.size () < 1) return false;
QStringList const& w = message_.split(" ",QString::SkipEmptyParts); QStringList const& w = message_.split(" ", Qt::SkipEmptyParts);
if (w.size () if (w.size ()
&& is_standard_ && (w[0] == myBaseCall && is_standard_ && (w[0] == myBaseCall
|| w[0].endsWith ("/" + myBaseCall) || w[0].endsWith ("/" + myBaseCall)

View File

@ -49,10 +49,12 @@ public:
void display (QUrl const& url, QString const& name_we) void display (QUrl const& url, QString const& name_we)
{ {
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
if (QNetworkAccessManager::Accessible != qnam_->networkAccessible ()) { if (QNetworkAccessManager::Accessible != qnam_->networkAccessible ()) {
// try and recover network access for QNAM // try and recover network access for QNAM
qnam_->setNetworkAccessible (QNetworkAccessManager::Accessible); qnam_->setNetworkAccessible (QNetworkAccessManager::Accessible);
} }
#endif
// try and find a localized manual // try and find a localized manual
auto lang = QLocale::system ().name (); auto lang = QLocale::system ().name ();

View File

@ -2,6 +2,9 @@
#include <limits> #include <limits>
#include <qmath.h> #include <qmath.h>
#include <QDateTime> #include <QDateTime>
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
#include <QRandomGenerator>
#endif
#include <QDebug> #include <QDebug>
#include "widgets/mainwindow.h" // TODO: G4WJS - break this dependency #include "widgets/mainwindow.h" // TODO: G4WJS - break this dependency
#include "Audio/soundout.h" #include "Audio/soundout.h"
@ -278,8 +281,13 @@ qint64 Modulator::readData (char * data, qint64 maxSize)
int j=m_ic/480; int j=m_ic/480;
if(m_fSpread>0.0 and j!=m_j0) { if(m_fSpread>0.0 and j!=m_j0) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
float x1=QRandomGenerator::global ()->generateDouble ();
float x2=QRandomGenerator::global ()->generateDouble ();
#else
float x1=(float)qrand()/RAND_MAX; float x1=(float)qrand()/RAND_MAX;
float x2=(float)qrand()/RAND_MAX; float x2=(float)qrand()/RAND_MAX;
#endif
toneFrequency = m_toneFrequency0 + 0.5*m_fSpread*(x1+x2-1.0); toneFrequency = m_toneFrequency0 + 0.5*m_fSpread*(x1+x2-1.0);
m_dphi = m_twoPi * toneFrequency / m_frameRate; m_dphi = m_twoPi * toneFrequency / m_frameRate;
m_j0=j; m_j0=j;

View File

@ -69,11 +69,13 @@ public:
void download (QUrl url) void download (QUrl url)
{ {
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
if (QNetworkAccessManager::Accessible != network_manager_->networkAccessible ()) if (QNetworkAccessManager::Accessible != network_manager_->networkAccessible ())
{ {
// try and recover network access for QNAM // try and recover network access for QNAM
network_manager_->setNetworkAccessible (QNetworkAccessManager::Accessible); network_manager_->setNetworkAccessible (QNetworkAccessManager::Accessible);
} }
#endif
QNetworkRequest request {url}; QNetworkRequest request {url};
request.setRawHeader ("User-Agent", "WSJT LotW User Downloader"); request.setRawHeader ("User-Agent", "WSJT LotW User Downloader");

View File

@ -423,6 +423,7 @@ MessageClient::MessageClient (QString const& id, QString const& version, QString
: QObject {self} : QObject {self}
, m_ {id, version, revision, server_port, this} , m_ {id, version, revision, server_port, this}
{ {
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
connect (&*m_, static_cast<void (impl::*) (impl::SocketError)> (&impl::error) connect (&*m_, static_cast<void (impl::*) (impl::SocketError)> (&impl::error)
, [this] (impl::SocketError e) , [this] (impl::SocketError e)
{ {
@ -441,6 +442,11 @@ MessageClient::MessageClient (QString const& id, QString const& version, QString
Q_EMIT error (m_->errorString ()); Q_EMIT error (m_->errorString ());
} }
}); });
#else
connect (&*m_, &impl::errorOccurred, [this] (impl::SocketError) {
Q_EMIT error (m_->errorString ());
});
#endif
set_server (server); set_server (server);
} }

View File

@ -7,6 +7,9 @@
#include <QHostInfo> #include <QHostInfo>
#include <QTimer> #include <QTimer>
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
#include <QRandomGenerator>
#endif
#include "Network/MessageClient.hpp" #include "Network/MessageClient.hpp"
@ -43,7 +46,11 @@ PSK_Reporter::PSK_Reporter(MessageClient * message_client, QObject *parent) :
"00960004"; // Report time "00960004"; // Report time
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
m_randomId_h = QString("%1").arg(qrand(),8,16,QChar('0')); m_randomId_h = QString("%1").arg(qrand(),8,16,QChar('0'));
#else
m_randomId_h = QString("%1").arg(QRandomGenerator::global ()->generate (), 8, 16, QChar('0'));
#endif
QHostInfo::lookupHost("report.pskreporter.info", this, SLOT(dnsLookupResult(QHostInfo))); QHostInfo::lookupHost("report.pskreporter.info", this, SLOT(dnsLookupResult(QHostInfo)));

View File

@ -208,10 +208,12 @@ QString WSPRNet::urlEncodeSpot(QHash<QString,QString> const& query)
void WSPRNet::work() void WSPRNet::work()
{ {
if (!urlQueue.isEmpty()) { if (!urlQueue.isEmpty()) {
#if QT_VERSION < QT_VERSION_CHECK (5, 15, 0)
if (QNetworkAccessManager::Accessible != networkManager->networkAccessible ()) { if (QNetworkAccessManager::Accessible != networkManager->networkAccessible ()) {
// try and recover network access for QNAM // try and recover network access for QNAM
networkManager->setNetworkAccessible (QNetworkAccessManager::Accessible); networkManager->setNetworkAccessible (QNetworkAccessManager::Accessible);
} }
#endif
QUrl url(urlQueue.dequeue()); QUrl url(urlQueue.dequeue());
QNetworkRequest request(url); QNetworkRequest request(url);
m_outstandingRequests << networkManager->get(request); m_outstandingRequests << networkManager->get(request);

View File

@ -121,10 +121,12 @@ bool RemoteFile::sync (QUrl const& url, bool local, bool force)
void RemoteFile::download (QUrl url) void RemoteFile::download (QUrl url)
{ {
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
if (QNetworkAccessManager::Accessible != network_manager_->networkAccessible ()) { if (QNetworkAccessManager::Accessible != network_manager_->networkAccessible ()) {
// try and recover network access for QNAM // try and recover network access for QNAM
network_manager_->setNetworkAccessible (QNetworkAccessManager::Accessible); network_manager_->setNetworkAccessible (QNetworkAccessManager::Accessible);
} }
#endif
if (url.isValid () && (!QSslSocket::supportsSsl () || http_only_)) if (url.isValid () && (!QSslSocket::supportsSsl () || http_only_))
{ {

View File

@ -78,7 +78,12 @@ void TraceFile::impl::message_handler (QtMsgType type, QMessageLogContext const&
Q_ASSERT_X (current_stream_, "TraceFile:message_handler", "no stream to write to"); Q_ASSERT_X (current_stream_, "TraceFile:message_handler", "no stream to write to");
{ {
QMutexLocker lock {&mutex_}; // thread safety - serialize writes to the trace file QMutexLocker lock {&mutex_}; // thread safety - serialize writes to the trace file
*current_stream_ << qFormatLogMessage (type, context, msg) << endl; *current_stream_ << qFormatLogMessage (type, context, msg) <<
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
endl;
#else
Qt::endl;
#endif
} }
if (QtFatalMsg == type) if (QtFatalMsg == type)

View File

@ -10,6 +10,7 @@
#include <QDir> #include <QDir>
#include "Network/NetworkServerLookup.hpp" #include "Network/NetworkServerLookup.hpp"
#include "qt_helpers.hpp"
namespace namespace
{ {
@ -167,7 +168,7 @@ int HRDTransceiver::do_start ()
HRD_info << "Id: " << id << "\n"; HRD_info << "Id: " << id << "\n";
HRD_info << "Version: " << version << "\n"; HRD_info << "Version: " << version << "\n";
auto radios = send_command ("get radios", false, false).trimmed ().split (',', QString::SkipEmptyParts); auto radios = send_command ("get radios", false, false).trimmed ().split (',', Qt::SkipEmptyParts);
if (radios.isEmpty ()) if (radios.isEmpty ())
{ {
TRACE_CAT ("HRDTransceiver", "no rig found"); TRACE_CAT ("HRDTransceiver", "no rig found");
@ -178,7 +179,7 @@ int HRDTransceiver::do_start ()
Q_FOREACH (auto const& radio, radios) Q_FOREACH (auto const& radio, radios)
{ {
HRD_info << "\t" << radio << "\n"; HRD_info << "\t" << radio << "\n";
auto entries = radio.trimmed ().split (':', QString::SkipEmptyParts); auto entries = radio.trimmed ().split (':', Qt::SkipEmptyParts);
radios_.push_back (std::forward_as_tuple (entries[0].toUInt (), entries[1])); radios_.push_back (std::forward_as_tuple (entries[0].toUInt (), entries[1]));
} }
@ -202,11 +203,11 @@ int HRDTransceiver::do_start ()
HRD_info << "VFO count: " << vfo_count_ << "\n"; HRD_info << "VFO count: " << vfo_count_ << "\n";
TRACE_CAT ("HRDTransceiver", "vfo count:" << vfo_count_); TRACE_CAT ("HRDTransceiver", "vfo count:" << vfo_count_);
buttons_ = send_command ("get buttons").trimmed ().split (',', QString::SkipEmptyParts).replaceInStrings (" ", "~"); buttons_ = send_command ("get buttons").trimmed ().split (',', Qt::SkipEmptyParts).replaceInStrings (" ", "~");
TRACE_CAT ("HRDTransceiver", "HRD Buttons: " << buttons_); TRACE_CAT ("HRDTransceiver", "HRD Buttons: " << buttons_);
HRD_info << "Buttons: {" << buttons_.join (", ") << "}\n"; HRD_info << "Buttons: {" << buttons_.join (", ") << "}\n";
dropdown_names_ = send_command ("get dropdowns").trimmed ().split (',', QString::SkipEmptyParts); dropdown_names_ = send_command ("get dropdowns").trimmed ().split (',', Qt::SkipEmptyParts);
TRACE_CAT ("HRDTransceiver", "Dropdowns:"); TRACE_CAT ("HRDTransceiver", "Dropdowns:");
HRD_info << "Dropdowns:\n"; HRD_info << "Dropdowns:\n";
Q_FOREACH (auto const& dd, dropdown_names_) Q_FOREACH (auto const& dd, dropdown_names_)
@ -217,12 +218,12 @@ int HRDTransceiver::do_start ()
dropdowns_[dd] = selections; dropdowns_[dd] = selections;
} }
slider_names_ = send_command ("get sliders").trimmed ().split (',', QString::SkipEmptyParts).replaceInStrings (" ", "~"); slider_names_ = send_command ("get sliders").trimmed ().split (',', Qt::SkipEmptyParts).replaceInStrings (" ", "~");
TRACE_CAT ("HRDTransceiver", "Sliders:-"); TRACE_CAT ("HRDTransceiver", "Sliders:-");
HRD_info << "Sliders:\n"; HRD_info << "Sliders:\n";
Q_FOREACH (auto const& s, slider_names_) Q_FOREACH (auto const& s, slider_names_)
{ {
auto range = send_command ("get slider-range " + current_radio_name + " " + s).trimmed ().split (',', QString::SkipEmptyParts); auto range = send_command ("get slider-range " + current_radio_name + " " + s).trimmed ().split (',', Qt::SkipEmptyParts);
TRACE_CAT ("HRDTransceiver", "\t" << s << ": {" << range.join (", ") << "}"); TRACE_CAT ("HRDTransceiver", "\t" << s << ": {" << range.join (", ") << "}");
HRD_info << "\t" << s << ": {" << range.join (", ") << "}\n"; HRD_info << "\t" << s << ": {" << range.join (", ") << "}\n";
sliders_[s] = range; sliders_[s] = range;
@ -601,7 +602,7 @@ void HRDTransceiver::do_frequency (Frequency f, MODE m, bool /*no_ignore*/)
auto fo_string = QString::number (f); auto fo_string = QString::number (f);
if (vfo_count_ > 1 && reversed_) if (vfo_count_ > 1 && reversed_)
{ {
auto frequencies = send_command ("get frequencies").trimmed ().split ('-', QString::SkipEmptyParts); auto frequencies = send_command ("get frequencies").trimmed ().split ('-', Qt::SkipEmptyParts);
send_simple_command ("set frequencies-hz " + QString::number (frequencies[0].toUInt ()) + ' ' + fo_string); send_simple_command ("set frequencies-hz " + QString::number (frequencies[0].toUInt ()) + ' ' + fo_string);
} }
else else
@ -687,14 +688,14 @@ void HRDTransceiver::do_tx_frequency (Frequency tx, MODE mode, bool /*no_ignore*
{ {
Q_ASSERT (vfo_count_ > 1); Q_ASSERT (vfo_count_ > 1);
auto frequencies = send_command ("get frequencies").trimmed ().split ('-', QString::SkipEmptyParts); auto frequencies = send_command ("get frequencies").trimmed ().split ('-', Qt::SkipEmptyParts);
send_simple_command ("set frequencies-hz " + fo_string + ' ' + QString::number (frequencies[1].toUInt ())); send_simple_command ("set frequencies-hz " + fo_string + ' ' + QString::number (frequencies[1].toUInt ()));
} }
else else
{ {
if (vfo_count_ > 1) if (vfo_count_ > 1)
{ {
auto frequencies = send_command ("get frequencies").trimmed ().split ('-', QString::SkipEmptyParts); auto frequencies = send_command ("get frequencies").trimmed ().split ('-', Qt::SkipEmptyParts);
send_simple_command ("set frequencies-hz " + QString::number (frequencies[0].toUInt ()) + ' ' + fo_string); send_simple_command ("set frequencies-hz " + QString::number (frequencies[0].toUInt ()) + ' ' + fo_string);
} }
else if ((vfo_B_button_ >= 0 && vfo_A_button_ >= 0) || vfo_toggle_button_ >= 0) else if ((vfo_B_button_ >= 0 && vfo_A_button_ >= 0) || vfo_toggle_button_ >= 0)
@ -986,7 +987,7 @@ void HRDTransceiver::do_poll ()
if (vfo_count_ > 1) if (vfo_count_ > 1)
{ {
auto frequencies = send_command ("get frequencies", quiet).trimmed ().split ('-', QString::SkipEmptyParts); auto frequencies = send_command ("get frequencies", quiet).trimmed ().split ('-', Qt::SkipEmptyParts);
update_rx_frequency (frequencies[reversed_ ? 1 : 0].toUInt ()); update_rx_frequency (frequencies[reversed_ ? 1 : 0].toUInt ());
update_other_frequency (frequencies[reversed_ ? 0 : 1].toUInt ()); update_other_frequency (frequencies[reversed_ ? 0 : 1].toUInt ());
} }

View File

@ -39,11 +39,18 @@ public:
Radio::register_types (); Radio::register_types ();
connect (this, &QIODevice::readyRead, this, &MessageServer::impl::pending_datagrams); connect (this, &QIODevice::readyRead, this, &MessageServer::impl::pending_datagrams);
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
connect (this, static_cast<void (impl::*) (SocketError)> (&impl::error) connect (this, static_cast<void (impl::*) (SocketError)> (&impl::error)
, [this] (SocketError /* e */) , [this] (SocketError /* e */)
{ {
Q_EMIT self_->error (errorString ()); Q_EMIT self_->error (errorString ());
}); });
#else
connect (this, &impl::errorOccurred, [this] (SocketError /* e */)
{
Q_EMIT self_->error (errorString ());
});
#endif
connect (clock_, &QTimer::timeout, this, &impl::tick); connect (clock_, &QTimer::timeout, this, &impl::tick);
clock_->start (NetworkMessage::pulse * 1000); clock_->start (NetworkMessage::pulse * 1000);
} }

View File

@ -242,7 +242,13 @@ namespace
QTextStream stream {&file}; QTextStream stream {&file};
Q_FOREACH (auto colour, colours_) Q_FOREACH (auto colour, colours_)
{ {
stream << colour.red () << ';' << colour.green () << ';' << colour.blue () << endl; stream << colour.red () << ';' << colour.green () << ';' << colour.blue () <<
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
endl
#else
Qt::endl
#endif
;
} }
} }
else else

View File

@ -1,5 +1,9 @@
#include "getfile.h" #include "getfile.h"
#include <QDir> #include <QDir>
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
#include <QRandomGenerator>
#include <random>
#endif
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
@ -171,6 +175,10 @@ void savewav(QString fname, int ntrperiod)
/* Generate gaussian random float with mean=0 and std_dev=1 */ /* Generate gaussian random float with mean=0 and std_dev=1 */
float gran() float gran()
{ {
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
static std::normal_distribution<float> d;
return d (*QRandomGenerator::global ());
#else
float fac,rsq,v1,v2; float fac,rsq,v1,v2;
static float gset; static float gset;
static int iset; static int iset;
@ -192,6 +200,7 @@ float gran()
gset = v1*fac; gset = v1*fac;
iset++; iset++;
return v2*fac; return v2*fac;
#endif
} }
int ptt(int nport, int ntx, int* iptt, int* nopen) int ptt(int nport, int ntx, int* iptt, int* nopen)

View File

@ -84,12 +84,12 @@ int killbyname(const char *szToTerminate)
if(hInstLib == NULL) return 605; if(hInstLib == NULL) return 605;
// Get procedure addresses. // Get procedure addresses.
lpfEnumProcesses = (BOOL(WINAPI *)(DWORD *,DWORD,DWORD*)) lpfEnumProcesses = (BOOL(WINAPI *)(DWORD *,DWORD,DWORD*))(void (*)())
GetProcAddress( hInstLib, "EnumProcesses" ) ; GetProcAddress( hInstLib, "EnumProcesses" ) ;
lpfEnumProcessModules = (BOOL(WINAPI *)(HANDLE, HMODULE *, lpfEnumProcessModules = (BOOL(WINAPI *)(HANDLE, HMODULE *,
DWORD, LPDWORD)) GetProcAddress( hInstLib, "EnumProcessModules" ) ; DWORD, LPDWORD))(void (*)()) GetProcAddress( hInstLib, "EnumProcessModules" ) ;
lpfGetModuleBaseName =(DWORD (WINAPI *)(HANDLE, HMODULE, LPTSTR, lpfGetModuleBaseName =(DWORD (WINAPI *)(HANDLE, HMODULE, LPTSTR,
DWORD )) GetProcAddress( hInstLib, "GetModuleBaseNameA" ) ; DWORD ))(void (*)()) GetProcAddress( hInstLib, "GetModuleBaseNameA" ) ;
if(lpfEnumProcesses == NULL || lpfEnumProcessModules == NULL || if(lpfEnumProcesses == NULL || lpfEnumProcessModules == NULL ||
lpfGetModuleBaseName == NULL) { lpfGetModuleBaseName == NULL) {
@ -164,20 +164,20 @@ int killbyname(const char *szToTerminate)
// which does not have the Toolhelp32 // which does not have the Toolhelp32
// functions in the Kernel 32. // functions in the Kernel 32.
lpfCreateToolhelp32Snapshot= lpfCreateToolhelp32Snapshot=
(HANDLE(WINAPI *)(DWORD,DWORD)) (HANDLE(WINAPI *)(DWORD,DWORD))(void (*)())
GetProcAddress( hInstLib, GetProcAddress( hInstLib,
"CreateToolhelp32Snapshot" ) ; "CreateToolhelp32Snapshot" ) ;
lpfProcess32First= lpfProcess32First=
(BOOL(WINAPI *)(HANDLE,LPPROCESSENTRY32)) (BOOL(WINAPI *)(HANDLE,LPPROCESSENTRY32))(void (*)())
GetProcAddress( hInstLib, "Process32First" ) ; GetProcAddress( hInstLib, "Process32First" ) ;
lpfProcess32Next= lpfProcess32Next=
(BOOL(WINAPI *)(HANDLE,LPPROCESSENTRY32)) (BOOL(WINAPI *)(HANDLE,LPPROCESSENTRY32))(void (*)())
GetProcAddress( hInstLib, "Process32Next" ) ; GetProcAddress( hInstLib, "Process32Next" ) ;
lpfModule32First= lpfModule32First=
(BOOL(WINAPI *)(HANDLE,LPMODULEENTRY32)) (BOOL(WINAPI *)(HANDLE,LPMODULEENTRY32))(void (*)())
GetProcAddress( hInstLib, "Module32First" ) ; GetProcAddress( hInstLib, "Module32First" ) ;
lpfModule32Next= lpfModule32Next=
(BOOL(WINAPI *)(HANDLE,LPMODULEENTRY32)) (BOOL(WINAPI *)(HANDLE,LPMODULEENTRY32))(void (*)())
GetProcAddress( hInstLib, "Module32Next" ) ; GetProcAddress( hInstLib, "Module32Next" ) ;
if( lpfProcess32Next == NULL || if( lpfProcess32Next == NULL ||
lpfProcess32First == NULL || lpfProcess32First == NULL ||

View File

@ -442,9 +442,21 @@ bool WorkedBefore::add (QString const& call
QTextStream out {&file}; QTextStream out {&file};
if (!file.size ()) if (!file.size ())
{ {
out << "WSJT-X ADIF Export<eoh>" << endl; // new file out << "WSJT-X ADIF Export<eh>" << // new file
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
endl
#else
Qt::endl
#endif
;
} }
out << ADIF_record << " <eor>" << endl; out << ADIF_record << " <eor>" <<
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
endl
#else
Qt::endl
#endif
;
} }
m_->worked_.emplace (call.toUpper (), grid.left (4).toUpper (), band.toUpper (), mode.toUpper () m_->worked_.emplace (call.toUpper (), grid.left (4).toUpper (), band.toUpper (), mode.toUpper ()
, entity.entity_name, entity.continent, entity.CQ_zone, entity.ITU_zone); , entity.entity_name, entity.continent, entity.CQ_zone, entity.ITU_zone);

View File

@ -103,7 +103,13 @@ QByteArray LogBook::QSOToADIF (QString const& hisCall, QString const& hisGrid, Q
if(operator_call!="") t+=" <operator:" + QString::number(operator_call.size()) + ">" + operator_call; if(operator_call!="") t+=" <operator:" + QString::number(operator_call.size()) + ">" + operator_call;
if (xSent.size ()) if (xSent.size ())
{ {
auto words = xSent.split (' ', QString::SkipEmptyParts); auto words = xSent.split (' '
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
, QString::SkipEmptyParts
#else
, Qt::SkipEmptyParts
#endif
);
if (words.size () > 1) if (words.size () > 1)
{ {
if (words.back ().toUInt ()) if (words.back ().toUInt ())
@ -126,7 +132,13 @@ QByteArray LogBook::QSOToADIF (QString const& hisCall, QString const& hisGrid, Q
} }
} }
if (xRcvd.size ()) { if (xRcvd.size ()) {
auto words = xRcvd.split (' ', QString::SkipEmptyParts); auto words = xRcvd.split (' '
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
, QString::SkipEmptyParts
#else
, Qt::SkipEmptyParts
#endif
);
if (words.size () == 2) if (words.size () == 2)
{ {
if (words.at (1).toUInt ()) if (words.at (1).toUInt ())

View File

@ -49,6 +49,7 @@ extern "C" {
namespace namespace
{ {
#if QT_VERSION < QT_VERSION_CHECK (5, 15, 0)
struct RNGSetup struct RNGSetup
{ {
RNGSetup () RNGSetup ()
@ -58,6 +59,7 @@ namespace
qsrand (seed); // this is good for rand() as well qsrand (seed); // this is good for rand() as well
} }
} seeding; } seeding;
#endif
// We can't use the GUI after QApplication::exit() is called so // We can't use the GUI after QApplication::exit() is called so
// uncaught exceptions can get lost on Windows systems where there // uncaught exceptions can get lost on Windows systems where there

View File

@ -274,5 +274,9 @@ void FoxLog::export_qsos (QTextStream& out) const
<< ADIF_field {"operator", m_->configuration_->opCall ()} << ADIF_field {"operator", m_->configuration_->opCall ()}
<< "<eor>"; << "<eor>";
} }
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
out << endl; out << endl;
#else
out << Qt::endl;
#endif
} }

View File

@ -4766,7 +4766,7 @@ Qt::Alignment QCPLayoutInset::insetAlignment(int index) const
else else
{ {
qDebug() << Q_FUNC_INFO << "Invalid element index:" << index; qDebug() << Q_FUNC_INFO << "Invalid element index:" << index;
return 0; return Qt::Alignment {};
} }
} }
@ -6015,8 +6015,10 @@ double QCPAxisTickerDateTime::dateTimeToKey(const QDate date)
{ {
#if QT_VERSION < QT_VERSION_CHECK(4, 7, 0) #if QT_VERSION < QT_VERSION_CHECK(4, 7, 0)
return QDateTime(date).toTime_t(); return QDateTime(date).toTime_t();
# else #elif QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
return QDateTime(date).toMSecsSinceEpoch()/1000.0; return QDateTime(date).toMSecsSinceEpoch()/1000.0;
#else
return date.startOfDay().toMSecsSinceEpoch()/1000.0;
#endif #endif
} }
/* end of 'src/axis/axistickerdatetime.cpp' */ /* end of 'src/axis/axistickerdatetime.cpp' */
@ -6499,7 +6501,11 @@ void QCPAxisTickerText::addTick(double position, QString label)
*/ */
void QCPAxisTickerText::addTicks(const QMap<double, QString> &ticks) void QCPAxisTickerText::addTicks(const QMap<double, QString> &ticks)
{ {
# if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
mTicks.unite(ticks); mTicks.unite(ticks);
#else
mTicks.insert(ticks);
#endif
} }
/*! \overload /*! \overload
@ -12598,9 +12604,11 @@ QCustomPlot::QCustomPlot(QWidget *parent) :
mBufferDevicePixelRatio(1.0), // will be adapted to primary screen below mBufferDevicePixelRatio(1.0), // will be adapted to primary screen below
mPlotLayout(0), mPlotLayout(0),
mAutoAddPlottableToLegend(true), mAutoAddPlottableToLegend(true),
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
mAntialiasedElements(QCP::aeNone), mAntialiasedElements(QCP::aeNone),
mNotAntialiasedElements(QCP::aeNone), mNotAntialiasedElements(QCP::aeNone),
mInteractions(0), mInteractions(0),
#endif
mSelectionTolerance(8), mSelectionTolerance(8),
mNoAntialiasingOnDrag(false), mNoAntialiasingOnDrag(false),
mBackgroundBrush(Qt::white, Qt::SolidPattern), mBackgroundBrush(Qt::white, Qt::SolidPattern),
@ -12617,7 +12625,9 @@ QCustomPlot::QCustomPlot(QWidget *parent) :
mReplotting(false), mReplotting(false),
mReplotQueued(false), mReplotQueued(false),
mOpenGlMultisamples(16), mOpenGlMultisamples(16),
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
mOpenGlAntialiasedElementsBackup(QCP::aeNone), mOpenGlAntialiasedElementsBackup(QCP::aeNone),
#endif
mOpenGlCacheLabelsBackup(true) mOpenGlCacheLabelsBackup(true)
{ {
setAttribute(Qt::WA_NoMousePropagation); setAttribute(Qt::WA_NoMousePropagation);
@ -14668,7 +14678,15 @@ void QCustomPlot::wheelEvent(QWheelEvent *event)
{ {
emit mouseWheel(event); emit mouseWheel(event);
// forward event to layerable under cursor: // forward event to layerable under cursor:
QList<QCPLayerable*> candidates = layerableListAt(event->pos(), false); QList<QCPLayerable*> candidates = layerableListAt(
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
event->pos()
#elif QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
event->posF()
#else
event->position()
#endif
, false);
for (int i=0; i<candidates.size(); ++i) for (int i=0; i<candidates.size(); ++i)
{ {
event->accept(); // default impl of QCPLayerable's mouse events ignore the event, in that case propagate to next candidate in list event->accept(); // default impl of QCPLayerable's mouse events ignore the event, in that case propagate to next candidate in list
@ -15002,7 +15020,7 @@ void QCustomPlot::processRectSelection(QRect rect, QMouseEvent *event)
if (mInteractions.testFlag(QCP::iSelectPlottables)) if (mInteractions.testFlag(QCP::iSelectPlottables))
{ {
QMap<int, QPair<QCPAbstractPlottable*, QCPDataSelection> > potentialSelections; // map key is number of selected data points, so we have selections sorted by size QMultiMap<int, QPair<QCPAbstractPlottable*, QCPDataSelection> > potentialSelections; // map key is number of selected data points, so we have selections sorted by size
QRectF rectF(rect.normalized()); QRectF rectF(rect.normalized());
if (QCPAxisRect *affectedAxisRect = axisRectAt(rectF.topLeft())) if (QCPAxisRect *affectedAxisRect = axisRectAt(rectF.topLeft()))
{ {
@ -15013,7 +15031,7 @@ void QCustomPlot::processRectSelection(QRect rect, QMouseEvent *event)
{ {
QCPDataSelection dataSel = plottableInterface->selectTestRect(rectF, true); QCPDataSelection dataSel = plottableInterface->selectTestRect(rectF, true);
if (!dataSel.isEmpty()) if (!dataSel.isEmpty())
potentialSelections.insertMulti(dataSel.dataPointCount(), QPair<QCPAbstractPlottable*, QCPDataSelection>(plottable, dataSel)); potentialSelections.insert(dataSel.dataPointCount(), QPair<QCPAbstractPlottable*, QCPDataSelection>(plottable, dataSel));
} }
} }
@ -15022,7 +15040,7 @@ void QCustomPlot::processRectSelection(QRect rect, QMouseEvent *event)
// only leave plottable with most selected points in map, since we will only select a single plottable: // only leave plottable with most selected points in map, since we will only select a single plottable:
if (!potentialSelections.isEmpty()) if (!potentialSelections.isEmpty())
{ {
QMap<int, QPair<QCPAbstractPlottable*, QCPDataSelection> >::iterator it = potentialSelections.begin(); QMultiMap<int, QPair<QCPAbstractPlottable*, QCPDataSelection> >::iterator it = potentialSelections.begin();
while (it != potentialSelections.end()-1) // erase all except last element while (it != potentialSelections.end()-1) // erase all except last element
it = potentialSelections.erase(it); it = potentialSelections.erase(it);
} }
@ -15048,7 +15066,7 @@ void QCustomPlot::processRectSelection(QRect rect, QMouseEvent *event)
} }
// go through selections in reverse (largest selection first) and emit select events: // go through selections in reverse (largest selection first) and emit select events:
QMap<int, QPair<QCPAbstractPlottable*, QCPDataSelection> >::const_iterator it = potentialSelections.constEnd(); QMultiMap<int, QPair<QCPAbstractPlottable*, QCPDataSelection> >::const_iterator it = potentialSelections.constEnd();
while (it != potentialSelections.constBegin()) while (it != potentialSelections.constBegin())
{ {
--it; --it;
@ -17619,14 +17637,24 @@ void QCPAxisRect::wheelEvent(QWheelEvent *event)
if (mRangeZoom != 0) if (mRangeZoom != 0)
{ {
double factor; double factor;
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
double wheelSteps = event->delta()/120.0; // a single step delta is +/-120 usually double wheelSteps = event->delta()/120.0; // a single step delta is +/-120 usually
#else
double wheelSteps = event->angleDelta().y()/120.0; // a single step delta is +/-120 usually
#endif
if (mRangeZoom.testFlag(Qt::Horizontal)) if (mRangeZoom.testFlag(Qt::Horizontal))
{ {
factor = qPow(mRangeZoomFactorHorz, wheelSteps); factor = qPow(mRangeZoomFactorHorz, wheelSteps);
for (int i=0; i<mRangeZoomHorzAxis.size(); ++i) for (int i=0; i<mRangeZoomHorzAxis.size(); ++i)
{ {
if (!mRangeZoomHorzAxis.at(i).isNull()) if (!mRangeZoomHorzAxis.at(i).isNull())
mRangeZoomHorzAxis.at(i)->scaleRange(factor, mRangeZoomHorzAxis.at(i)->pixelToCoord(event->pos().x())); mRangeZoomHorzAxis.at(i)->scaleRange(factor, mRangeZoomHorzAxis.at(i)->pixelToCoord(
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
event->posF().x()
#else
event->position().x()
#endif
));
} }
} }
if (mRangeZoom.testFlag(Qt::Vertical)) if (mRangeZoom.testFlag(Qt::Vertical))
@ -17635,7 +17663,13 @@ void QCPAxisRect::wheelEvent(QWheelEvent *event)
for (int i=0; i<mRangeZoomVertAxis.size(); ++i) for (int i=0; i<mRangeZoomVertAxis.size(); ++i)
{ {
if (!mRangeZoomVertAxis.at(i).isNull()) if (!mRangeZoomVertAxis.at(i).isNull())
mRangeZoomVertAxis.at(i)->scaleRange(factor, mRangeZoomVertAxis.at(i)->pixelToCoord(event->pos().y())); mRangeZoomVertAxis.at(i)->scaleRange(factor, mRangeZoomVertAxis.at(i)->pixelToCoord(
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
event->posF().y()
#else
event->position().y()
#endif
));
} }
} }
mParentPlot->replot(); mParentPlot->replot();
@ -19262,7 +19296,7 @@ void QCPColorScale::setRangeDrag(bool enabled)
if (enabled) if (enabled)
mAxisRect.data()->setRangeDrag(QCPAxis::orientation(mType)); mAxisRect.data()->setRangeDrag(QCPAxis::orientation(mType));
else else
mAxisRect.data()->setRangeDrag(0); mAxisRect.data()->setRangeDrag(Qt::Orientations());
} }
/*! /*!
@ -19282,7 +19316,7 @@ void QCPColorScale::setRangeZoom(bool enabled)
if (enabled) if (enabled)
mAxisRect.data()->setRangeZoom(QCPAxis::orientation(mType)); mAxisRect.data()->setRangeZoom(QCPAxis::orientation(mType));
else else
mAxisRect.data()->setRangeZoom(0); mAxisRect.data()->setRangeZoom(Qt::Orientations());
} }
/*! /*!

View File

@ -51,6 +51,12 @@
return QString {mo.enumerator (mo.indexOfEnumerator (#ENUM)).valueToKey (static_cast<int> (m))}; \ return QString {mo.enumerator (mo.indexOfEnumerator (#ENUM)).valueToKey (static_cast<int> (m))}; \
} }
#if QT_VERSION >= QT_VERSION_CHECK (5, 15, 0)
Qt::SplitBehaviorFlags const SkipEmptyParts = Qt::SkipEmptyParts;
#else
QString::SplitBehavior const SkipEmptyParts = QString::SkipEmptyParts;
#endif
inline inline
void throw_qstring (QString const& qs) void throw_qstring (QString const& qs)
{ {

View File

@ -99,7 +99,13 @@ void ExportCabrillo::save_log ()
<< "ADDRESS: " << ui->addr_1_line_edit->text() << '\n' << "ADDRESS: " << ui->addr_1_line_edit->text() << '\n'
<< "ADDRESS: " << ui->addr_2_line_edit->text() << '\n'; << "ADDRESS: " << ui->addr_2_line_edit->text() << '\n';
if (log_) log_->export_qsos (out); if (log_) log_->export_qsos (out);
out << "END-OF-LOG:" << endl; out << "END-OF-LOG:"
#if QT_VERSION >= QT_VERSION_CHECK (5, 15, 0)
<< Qt::endl
#else
<< endl
#endif
;
return; return;
} else { } else {
auto const& message = tr ("Cannot open \"%1\" for writing: %2") auto const& message = tr ("Cannot open \"%1\" for writing: %2")

View File

@ -131,7 +131,11 @@ auto Astro::astroUpdate(QDateTime const& t, QString const& mygrid, QString const
QTextStream out {&message}; QTextStream out {&message};
out << " " << date << "\n" out << " " << date << "\n"
"UTC: " << utc << "\n" "UTC: " << utc << "\n"
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
<< Qt::fixed
#else
<< fixed << fixed
#endif
<< qSetFieldWidth (6) << qSetFieldWidth (6)
<< qSetRealNumberPrecision (1) << qSetRealNumberPrecision (1)
<< "Az: " << azmoon << "\n" << "Az: " << azmoon << "\n"

View File

@ -142,8 +142,20 @@ void LogQSO::accept()
} }
if ((special_op == SpOp::RTTY and xsent!="" and xrcvd!="")) { if ((special_op == SpOp::RTTY and xsent!="" and xrcvd!="")) {
if(rptSent=="" or !xsent.contains(rptSent+" ")) rptSent=xsent.split(" ",QString::SkipEmptyParts).at(0); if(rptSent=="" or !xsent.contains(rptSent+" ")) rptSent=xsent.split(" "
if(rptRcvd=="" or !xrcvd.contains(rptRcvd+" ")) rptRcvd=xrcvd.split(" ",QString::SkipEmptyParts).at(0); #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
, QString::SkipEmptyParts
#else
, Qt::SkipEmptyParts
#endif
).at(0);
if(rptRcvd=="" or !xrcvd.contains(rptRcvd+" ")) rptRcvd=xrcvd.split(" "
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
, QString::SkipEmptyParts
#else
, Qt::SkipEmptyParts
#endif
).at(0);
} }
// validate // validate
@ -181,7 +193,13 @@ void LogQSO::accept()
"," + rptSent + "," + rptRcvd + "," + m_txPower + "," + rptSent + "," + rptRcvd + "," + m_txPower +
"," + m_comments + "," + name; "," + m_comments + "," + name;
QTextStream out(&f); QTextStream out(&f);
out << logEntry << endl; out << logEntry <<
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
endl
#else
Qt::endl
#endif
;
f.close(); f.close();
} }

View File

@ -39,6 +39,9 @@
#include <QUdpSocket> #include <QUdpSocket>
#include <QAbstractItemView> #include <QAbstractItemView>
#include <QInputDialog> #include <QInputDialog>
#if QT_VERSION >= QT_VERSION_CHECK (5, 15, 0)
#include <QRandomGenerator>
#endif
#include "revision_utils.hpp" #include "revision_utils.hpp"
#include "qt_helpers.hpp" #include "qt_helpers.hpp"
@ -84,7 +87,6 @@
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include "moc_mainwindow.cpp" #include "moc_mainwindow.cpp"
extern "C" { extern "C" {
//----------------------------------------------------- C and Fortran routines //----------------------------------------------------- C and Fortran routines
void symspec_(struct dec_data *, int* k, int* ntrperiod, int* nsps, int* ingain, void symspec_(struct dec_data *, int* k, int* ntrperiod, int* nsps, int* ingain,
@ -654,8 +656,7 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
subProcessError (&proc_jt9, error); subProcessError (&proc_jt9, error);
}); });
#else #else
connect(&proc_jt9, static_cast<void (QProcess::*) (QProcess::ProcessError)> (&QProcess::errorOccurred), connect(&proc_jt9, &QProcess::errorOccurred, [this] (QProcess::ProcessError error) {
[this] (QProcess::ProcessError error) {
subProcessError (&proc_jt9, error); subProcessError (&proc_jt9, error);
}); });
#endif #endif
@ -663,7 +664,9 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
[this] (int exitCode, QProcess::ExitStatus status) { [this] (int exitCode, QProcess::ExitStatus status) {
subProcessFailed (&proc_jt9, exitCode, status); subProcessFailed (&proc_jt9, exitCode, status);
}); });
connect(&p1, &QProcess::started, [this] () {
showStatusMessage (QString {"Started: %1 \"%2\""}.arg (p1.program ()).arg (p1.arguments ().join (QLatin1String {"\" \""})));
});
connect(&p1, &QProcess::readyReadStandardOutput, this, &MainWindow::p1ReadFromStdout); connect(&p1, &QProcess::readyReadStandardOutput, this, &MainWindow::p1ReadFromStdout);
#if QT_VERSION < QT_VERSION_CHECK (5, 6, 0) #if QT_VERSION < QT_VERSION_CHECK (5, 6, 0)
connect(&p1, static_cast<void (QProcess::*) (QProcess::ProcessError)> (&QProcess::error), connect(&p1, static_cast<void (QProcess::*) (QProcess::ProcessError)> (&QProcess::error),
@ -671,8 +674,7 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
subProcessError (&p1, error); subProcessError (&p1, error);
}); });
#else #else
connect(&p1, static_cast<void (QProcess::*) (QProcess::ProcessError)> (&QProcess::errorOccurred), connect(&p1, &QProcess::errorOccurred, [this] (QProcess::ProcessError error) {
[this] (QProcess::ProcessError error) {
subProcessError (&p1, error); subProcessError (&p1, error);
}); });
#endif #endif
@ -687,11 +689,13 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
subProcessError (&p3, error); subProcessError (&p3, error);
}); });
#else #else
connect(&p3, static_cast<void (QProcess::*) (QProcess::ProcessError)> (&QProcess::errorOccurred), connect(&p3, &QProcess::errorOccurred, [this] (QProcess::ProcessError error) {
[this] (QProcess::ProcessError error) {
subProcessError (&p3, error); subProcessError (&p3, error);
}); });
#endif #endif
connect(&p3, &QProcess::started, [this] () {
showStatusMessage (QString {"Started: %1 \"%2\""}.arg (p3.program ()).arg (p3.arguments ().join (QLatin1String {"\" \""})));
});
connect(&p3, static_cast<void (QProcess::*) (int, QProcess::ExitStatus)> (&QProcess::finished), connect(&p3, static_cast<void (QProcess::*) (int, QProcess::ExitStatus)> (&QProcess::finished),
[this] (int exitCode, QProcess::ExitStatus status) { [this] (int exitCode, QProcess::ExitStatus status) {
subProcessFailed (&p3, exitCode, status); subProcessFailed (&p3, exitCode, status);
@ -1400,7 +1404,13 @@ void MainWindow::dataSink(qint64 frames)
QFile f {m_config.writeable_data_dir ().absoluteFilePath ("fmt.all")}; QFile f {m_config.writeable_data_dir ().absoluteFilePath ("fmt.all")};
if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) { if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) {
QTextStream out(&f); QTextStream out(&f);
out << t << endl; out << t
#if QT_VERSION >= QT_VERSION_CHECK (5, 15, 0)
<< Qt::endl
#else
<< endl
#endif
;
f.close(); f.close();
} else { } else {
MessageBox::warning_message (this, tr ("File Open Error") MessageBox::warning_message (this, tr ("File Open Error")
@ -1507,36 +1517,39 @@ void MainWindow::dataSink(qint64 frames)
} }
if(m_mode.startsWith ("WSPR")) { if(m_mode.startsWith ("WSPR")) {
QString t2,cmnd,depth_string; QStringList t2;
double f0m1500=m_dialFreqRxWSPR/1000000.0; // + 0.000001*(m_BFO - 1500); QStringList depth_args;
t2 = t2.asprintf(" -f %.6f ",f0m1500); t2 << "-f" << QString {"%1"}.arg (m_dialFreqRxWSPR / 1000000.0, 0, 'f', 6);
if((m_ndepth&7)==1) depth_string=" -qB "; //2 pass w subtract, no Block detection, no shift jittering if((m_ndepth&7)==1) depth_args << "-qB"; //2 pass w subtract, no Block detection, no shift jittering
if((m_ndepth&7)==2) depth_string=" -C 500 -o 4 "; //3 pass, subtract, Block detection, OSD if((m_ndepth&7)==2) depth_args << "-C" << "500" << "-o" << "4"; //3 pass, subtract, Block detection, OSD
if((m_ndepth&7)==3) depth_string=" -C 500 -o 4 -d "; //3 pass, subtract, Block detect, OSD, more candidates if((m_ndepth&7)==3) depth_args << "-C" << "500" << "-o" << "4" << "-d"; //3 pass, subtract, Block detect, OSD, more candidates
QString degrade; QStringList degrade;
degrade = degrade.asprintf("-d %4.1f ",m_config.degrade()); degrade << "-d" << QString {"%1"}.arg (m_config.degrade(), 4, 'f', 1);
m_cmndP1.clear ();
if(m_diskData) { if(m_diskData) {
cmnd='"' + m_appDir + '"' + "/wsprd " + depth_string + " -a \"" + m_cmndP1 << depth_args << "-a"
QDir::toNativeSeparators(m_config.writeable_data_dir ().absolutePath()) + "\" \"" + m_path + "\""; << QDir::toNativeSeparators (m_config.writeable_data_dir ().absolutePath()) << m_path;
} else { } else {
if(m_mode=="WSPR-LF") { // if(m_mode=="WSPR-LF")
// cmnd='"' + m_appDir + '"' + "/wspr_fsk8d " + degrade + t2 +" -a \"" + // {
// QDir::toNativeSeparators(m_config.writeable_data_dir ().absolutePath()) + "\" " + // m_cmndP1 << degrade << t2 << "-a"
// '"' + m_fnameWE + ".wav\""; // << QDir::toNativeSeparators (m_config.writeable_data_dir ().absolutePath())
} else { // << m_fnameWE + ".wav";
cmnd='"' + m_appDir + '"' + "/wsprd " + depth_string + " -a \"" + // }
QDir::toNativeSeparators(m_config.writeable_data_dir ().absolutePath()) + "\" " + // else
t2 + '"' + m_fnameWE + ".wav\""; {
m_cmndP1 << depth_args << "-a"
<< QDir::toNativeSeparators (m_config.writeable_data_dir ().absolutePath())
<< t2 << m_fnameWE + ".wav";
} }
} }
QString t3=cmnd; // QString t3=cmnd;
int i1=cmnd.indexOf("/wsprd "); // int i1=cmnd.indexOf("/wsprd ");
cmnd=t3.mid(0,i1+7) + t3.mid(i1+7); // cmnd=t3.mid(0,i1+7) + t3.mid(i1+7);
// if(m_mode=="WSPR-LF") cmnd=cmnd.replace("/wsprd ","/wspr_fsk8d "+degrade+t2); // if(m_mode=="WSPR-LF") cmnd=cmnd.replace("/wsprd ","/wspr_fsk8d "+degrade+t2);
if (ui) ui->DecodeButton->setChecked (true); if (ui) ui->DecodeButton->setChecked (true);
m_cmndP1=QDir::toNativeSeparators(cmnd); // m_cmndP1=QDir::toNativeSeparators(cmnd);
p1Timer.start(1000); p1Timer.start(1000);
m_decoderBusy = true; m_decoderBusy = true;
statusUpdate (); statusUpdate ();
@ -1547,7 +1560,14 @@ void MainWindow::dataSink(qint64 frames)
void MainWindow::startP1() void MainWindow::startP1()
{ {
p1.start(m_cmndP1); // if (m_mode=="WSPR-LF")
// {
// p1.start (QDir::toNativeSeparators (QDir {QApplication::applicationDirPath ()}.absoluteFilePath ("wspr_fsk8d")), m_cmndP1);
// }
// else
{
p1.start (QDir::toNativeSeparators (QDir {QApplication::applicationDirPath ()}.absoluteFilePath ("wsprd")), m_cmndP1);
}
} }
QString MainWindow::save_wave_file (QString const& name, short const * data, int samples, QString MainWindow::save_wave_file (QString const& name, short const * data, int samples,
@ -2184,7 +2204,13 @@ void MainWindow::statusChanged()
if (!tmpGrid.size ()) tmpGrid="n/a"; // Not Available if (!tmpGrid.size ()) tmpGrid="n/a"; // Not Available
out << qSetRealNumberPrecision (12) << (m_freqNominal / 1.e6) out << qSetRealNumberPrecision (12) << (m_freqNominal / 1.e6)
<< ";" << m_mode << ";" << m_hisCall << ";" << ";" << m_mode << ";" << m_hisCall << ";"
<< ui->rptSpinBox->value() << ";" << m_modeTx << ";" << tmpGrid << endl; << ui->rptSpinBox->value() << ";" << m_modeTx << ";" << tmpGrid
#if QT_VERSION >= QT_VERSION_CHECK (5, 15, 0)
<< Qt::endl
#else
<< endl
#endif
;
f.close(); f.close();
} else { } else {
if (m_splash && m_splash->isVisible ()) m_splash->hide (); if (m_splash && m_splash->isVisible ()) m_splash->hide ();
@ -2851,7 +2877,13 @@ void MainWindow::decode() //decode()
if( m_dateTimeLastTX.isValid () ) { if( m_dateTimeLastTX.isValid () ) {
qint64 isecs_since_tx = m_dateTimeLastTX.secsTo(now); qint64 isecs_since_tx = m_dateTimeLastTX.secsTo(now);
dec_data.params.lapcqonly= (isecs_since_tx > 300); dec_data.params.lapcqonly= (isecs_since_tx > 300);
// QTextStream(stdout) << "last tx " << isecs_since_tx << endl; // QTextStream(stdout) << "last tx " << isecs_since_tx
// #if QT_VERSION >= QT_VERSION_CHECK (5, 15, 0)
// << Qt::endl
// #else
// << endl
// #endif
// ;
} else { } else {
m_dateTimeLastTX = now.addSecs(-900); m_dateTimeLastTX = now.addSecs(-900);
dec_data.params.lapcqonly=true; dec_data.params.lapcqonly=true;
@ -3240,7 +3272,7 @@ void MainWindow::readFromStdout() //readFromStdout
int audioFreq=decodedtext.frequencyOffset(); int audioFreq=decodedtext.frequencyOffset();
if(m_mode=="FT8" or m_mode=="FT4") { if(m_mode=="FT8" or m_mode=="FT4") {
auto const& parts = decodedtext.string().remove("<").remove(">") auto const& parts = decodedtext.string().remove("<").remove(">")
.split (' ', QString::SkipEmptyParts); .split (' ', SkipEmptyParts);
if (parts.size() > 6) { if (parts.size() > 6) {
auto for_us = parts[5].contains (m_baseCall) auto for_us = parts[5].contains (m_baseCall)
|| ("DE" == parts[5] && qAbs (ui->RxFreqSpinBox->value () - audioFreq) <= 10); || ("DE" == parts[5] && qAbs (ui->RxFreqSpinBox->value () - audioFreq) <= 10);
@ -3280,7 +3312,7 @@ void MainWindow::readFromStdout() //readFromStdout
if(m_mode=="FT8" and SpecOp::HOUND==m_config.special_op_id()) { if(m_mode=="FT8" and SpecOp::HOUND==m_config.special_op_id()) {
if(decodedtext.string().contains(";")) { if(decodedtext.string().contains(";")) {
QStringList w=decodedtext.string().mid(24).split(" ",QString::SkipEmptyParts); QStringList w=decodedtext.string().mid(24).split(" ",SkipEmptyParts);
QString foxCall=w.at(3); QString foxCall=w.at(3);
foxCall=foxCall.remove("<").remove(">"); foxCall=foxCall.remove("<").remove(">");
if(w.at(0)==m_config.my_callsign() or w.at(0)==Radio::base_callsign(m_config.my_callsign())) { if(w.at(0)==m_config.my_callsign() or w.at(0)==Radio::base_callsign(m_config.my_callsign())) {
@ -3296,7 +3328,7 @@ void MainWindow::readFromStdout() //readFromStdout
hound_reply (); hound_reply ();
} }
} else { } else {
QStringList w=decodedtext.string().mid(24).split(" ",QString::SkipEmptyParts); QStringList w=decodedtext.string().mid(24).split(" ",SkipEmptyParts);
if(decodedtext.string().contains("/")) w.append(" +00"); //Add a dummy report if(decodedtext.string().contains("/")) w.append(" +00"); //Add a dummy report
if(w.size()>=3) { if(w.size()>=3) {
QString foxCall=w.at(1); QString foxCall=w.at(1);
@ -3384,7 +3416,7 @@ void MainWindow::auto_sequence (DecodedText const& message, unsigned start_toler
|| message_words.contains ("DE"))) || message_words.contains ("DE")))
|| !message.isStandardMessage ()); // free text 73/RR73 || !message.isStandardMessage ()); // free text 73/RR73
QStringList w=message.string().mid(22).remove("<").remove(">").split(" ",QString::SkipEmptyParts); QStringList w=message.string().mid(22).remove("<").remove(">").split(" ",SkipEmptyParts);
QString w2; QString w2;
int nrpt=0; int nrpt=0;
if (w.size () > 2) if (w.size () > 2)
@ -3665,8 +3697,12 @@ void MainWindow::guiUpdate()
else if (SpecOp::HOUND == m_config.special_op_id()) { else if (SpecOp::HOUND == m_config.special_op_id()) {
if(m_auto && !m_tune) { if(m_auto && !m_tune) {
if (ui->TxFreqSpinBox->value() < 999 && m_ntx != 3) { if (ui->TxFreqSpinBox->value() < 999 && m_ntx != 3) {
int nf = (qrand() % 2000) + 1000; // Hound randomized range: 1000-3000 Hz // Hound randomized range: 1000-3000 Hz
ui->TxFreqSpinBox->setValue(nf); #if QT_VERSION >= QT_VERSION_CHECK (5, 15, 0)
ui->TxFreqSpinBox->setValue (QRandomGenerator::global ()->bounded (1000, 2999));
#else
ui->TxFreqSpinBox->setValue ((qrand () % 2000) + 1000);
#endif
} }
} }
if (m_nSentFoxRrpt==2 and m_ntx==3) { if (m_nSentFoxRrpt==2 and m_ntx==3) {
@ -3685,8 +3721,11 @@ void MainWindow::guiUpdate()
// If HoldTxFreq is not checked, randomize Fox's Tx Freq // If HoldTxFreq is not checked, randomize Fox's Tx Freq
// NB: Maybe this should be done no more than once every 5 minutes or so ? // NB: Maybe this should be done no more than once every 5 minutes or so ?
if(m_mode=="FT8" and SpecOp::FOX==m_config.special_op_id() and !ui->cbHoldTxFreq->isChecked()) { if(m_mode=="FT8" and SpecOp::FOX==m_config.special_op_id() and !ui->cbHoldTxFreq->isChecked()) {
int fTx = 300.0 + 300.0*double(qrand())/RAND_MAX; #if QT_VERSION >= QT_VERSION_CHECK (5, 15, 0)
ui->TxFreqSpinBox->setValue(fTx); ui->TxFreqSpinBox->setValue (QRandomGenerator::global ()->bounded (300, 599));
#else
ui->TxFreqSpinBox->setValue(300.0 + 300.0*double(qrand())/RAND_MAX);
#endif
} }
setXIT (ui->TxFreqSpinBox->value ()); setXIT (ui->TxFreqSpinBox->value ());
@ -3858,7 +3897,7 @@ void MainWindow::guiUpdate()
if(SpecOp::FIELD_DAY==m_config.special_op_id() or SpecOp::RTTY==m_config.special_op_id()) { if(SpecOp::FIELD_DAY==m_config.special_op_id() or SpecOp::RTTY==m_config.special_op_id()) {
if(m_ntx==2 or m_ntx==3) { if(m_ntx==2 or m_ntx==3) {
QStringList t=ui->tx2->text().split(' ', QString::SkipEmptyParts); QStringList t=ui->tx2->text().split(' ', SkipEmptyParts);
int n=t.size(); int n=t.size();
m_xSent=t.at(n-2) + " " + t.at(n-1); m_xSent=t.at(n-2) + " " + t.at(n-1);
} }
@ -3893,7 +3932,7 @@ void MainWindow::guiUpdate()
auto t2 = QDateTime::currentDateTimeUtc ().toString ("hhmm"); auto t2 = QDateTime::currentDateTimeUtc ().toString ("hhmm");
icw[0] = 0; icw[0] = 0;
auto msg_parts = m_currentMessage.split (' ', QString::SkipEmptyParts); auto msg_parts = m_currentMessage.split (' ', SkipEmptyParts);
if (msg_parts.size () > 2) { if (msg_parts.size () > 2) {
// clean up short code forms // clean up short code forms
msg_parts[0].remove (QChar {'<'}); msg_parts[0].remove (QChar {'<'});
@ -3904,7 +3943,7 @@ void MainWindow::guiUpdate()
auto is_73 = m_QSOProgress >= ROGER_REPORT auto is_73 = m_QSOProgress >= ROGER_REPORT
&& message_is_73 (m_currentMessageType, msg_parts); && message_is_73 (m_currentMessageType, msg_parts);
m_sentFirst73 = is_73 m_sentFirst73 = is_73
&& !message_is_73 (m_lastMessageType, m_lastMessageSent.split (' ', QString::SkipEmptyParts)); && !message_is_73 (m_lastMessageType, m_lastMessageSent.split (' ', SkipEmptyParts));
if (m_sentFirst73) { if (m_sentFirst73) {
m_qsoStop=t2; m_qsoStop=t2;
if(m_config.id_after_73 ()) { if(m_config.id_after_73 ()) {
@ -4472,7 +4511,7 @@ void MainWindow::processMessage (DecodedText const& message, Qt::KeyboardModifie
auto ctrl = modifiers.testFlag (Qt::ControlModifier); auto ctrl = modifiers.testFlag (Qt::ControlModifier);
// auto alt = modifiers.testFlag (Qt::AltModifier); // auto alt = modifiers.testFlag (Qt::AltModifier);
// basic mode sanity checks // basic mode sanity checks
auto const& parts = message.string ().split (' ', QString::SkipEmptyParts); auto const& parts = message.string ().split (' ', SkipEmptyParts);
if (parts.size () < 5) return; if (parts.size () < 5) return;
auto const& mode = parts.at (4).left (1); auto const& mode = parts.at (4).left (1);
if (("JT9+JT65" == m_mode && !("@" == mode || "#" == mode)) if (("JT9+JT65" == m_mode && !("@" == mode || "#" == mode))
@ -4530,7 +4569,7 @@ void MainWindow::processMessage (DecodedText const& message, Qt::KeyboardModifie
ui->dxCallEntry->setText(hiscall); ui->dxCallEntry->setText(hiscall);
} }
QStringList w=message.string().mid(22).remove("<").remove(">").split(" ",QString::SkipEmptyParts); QStringList w=message.string().mid(22).remove("<").remove(">").split(" ",SkipEmptyParts);
int nw=w.size(); int nw=w.size();
if(nw>=4) { if(nw>=4) {
if(message_words.size()<3) return; if(message_words.size()<3) return;
@ -4622,7 +4661,7 @@ void MainWindow::processMessage (DecodedText const& message, Qt::KeyboardModifie
MessageBox::information_message (this, msg); MessageBox::information_message (this, msg);
} }
QStringList t=message.string().split(' ', QString::SkipEmptyParts); QStringList t=message.string().split(' ', SkipEmptyParts);
int n=t.size(); int n=t.size();
QString t0=t.at(n-2); QString t0=t.at(n-2);
QString t1=t0.right(1); QString t1=t0.right(1);
@ -5396,7 +5435,13 @@ void MainWindow::on_addButton_clicked() //Add button
} }
if(f1.size()==0) { if(f1.size()==0) {
QTextStream out(&f1); QTextStream out(&f1);
out << "ZZZZZZ" << endl; out << "ZZZZZZ"
#if QT_VERSION >= QT_VERSION_CHECK (5, 15, 0)
<< Qt::endl
#else
<< endl
#endif
;
f1.close(); f1.close();
f1.open(QIODevice::ReadOnly | QIODevice::Text); f1.open(QIODevice::ReadOnly | QIODevice::Text);
} }
@ -6975,7 +7020,13 @@ void MainWindow::handle_transceiver_update (Transceiver::TransceiverState const&
QTextStream out(&f2); QTextStream out(&f2);
out << QDateTime::currentDateTimeUtc().toString("yyyy-MM-dd hh:mm") out << QDateTime::currentDateTimeUtc().toString("yyyy-MM-dd hh:mm")
<< " " << qSetRealNumberPrecision (12) << (m_freqNominal / 1.e6) << " MHz " << " " << qSetRealNumberPrecision (12) << (m_freqNominal / 1.e6) << " MHz "
<< m_mode << endl; << m_mode
#if QT_VERSION >= QT_VERSION_CHECK (5, 15, 0)
<< Qt::endl
#else
<< endl
#endif
;
f2.close(); f2.close();
} else { } else {
MessageBox::warning_message (this, tr ("File Error") MessageBox::warning_message (this, tr ("File Error")
@ -7553,7 +7604,7 @@ void MainWindow::replayDecodes ()
// appended info // appended info
if (message.size() >= 4 && message.left (4) != "----") if (message.size() >= 4 && message.left (4) != "----")
{ {
auto const& parts = message.split (' ', QString::SkipEmptyParts); auto const& parts = message.split (' ', SkipEmptyParts);
if (parts.size () >= 5 && parts[3].contains ('.')) // WSPR if (parts.size () >= 5 && parts[3].contains ('.')) // WSPR
{ {
postWSPRDecode (false, parts); postWSPRDecode (false, parts);
@ -7571,7 +7622,7 @@ void MainWindow::replayDecodes ()
void MainWindow::postDecode (bool is_new, QString const& message) void MainWindow::postDecode (bool is_new, QString const& message)
{ {
auto const& decode = message.trimmed (); auto const& decode = message.trimmed ();
auto const& parts = decode.left (22).split (' ', QString::SkipEmptyParts); auto const& parts = decode.left (22).split (' ', SkipEmptyParts);
if (parts.size () >= 5) if (parts.size () >= 5)
{ {
auto has_seconds = parts[0].size () > 4; auto has_seconds = parts[0].size () > 4;
@ -7644,9 +7695,11 @@ void MainWindow::p1ReadFromStdout() //p1readFromStdout
ui->DecodeButton->setChecked (false); ui->DecodeButton->setChecked (false);
if(m_uploadSpots if(m_uploadSpots
&& m_config.is_transceiver_online ()) { // need working rig control && m_config.is_transceiver_online ()) { // need working rig control
float x=qrand()/((double)RAND_MAX + 1.0); #if QT_VERSION >= QT_VERSION_CHECK (5, 15, 0)
int msdelay=20000*x; uploadTimer.start(QRandomGenerator::global ()->bounded (0, 20000)); // Upload delay
uploadTimer.start(msdelay); //Upload delay #else
uploadTimer.start(20000 * qrand()/((double)RAND_MAX + 1.0)); // Upload delay
#endif
} else { } else {
QFile f(QDir::toNativeSeparators(m_config.writeable_data_dir ().absolutePath()) + "/wspr_spots.txt"); QFile f(QDir::toNativeSeparators(m_config.writeable_data_dir ().absolutePath()) + "/wspr_spots.txt");
if(f.exists()) f.remove(); if(f.exists()) f.remove();
@ -7746,7 +7799,13 @@ void MainWindow::WSPR_history(Frequency dialFreq, int ndecodes)
QFile f {m_config.writeable_data_dir ().absoluteFilePath ("WSPR_history.txt")}; QFile f {m_config.writeable_data_dir ().absoluteFilePath ("WSPR_history.txt")};
if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) { if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) {
QTextStream out(&f); QTextStream out(&f);
out << t1 << endl; out << t1
#if QT_VERSION >= QT_VERSION_CHECK (5, 15, 0)
<< Qt::endl
#else
<< endl
#endif
;
f.close(); f.close();
} else { } else {
MessageBox::warning_message (this, tr ("File Error") MessageBox::warning_message (this, tr ("File Error")
@ -7836,18 +7895,22 @@ void MainWindow::WSPR_scheduling ()
if (hop_data.frequencies_index_ >= 0) { // new band if (hop_data.frequencies_index_ >= 0) { // new band
ui->bandComboBox->setCurrentIndex (hop_data.frequencies_index_); ui->bandComboBox->setCurrentIndex (hop_data.frequencies_index_);
on_bandComboBox_activated (hop_data.frequencies_index_); on_bandComboBox_activated (hop_data.frequencies_index_);
m_cmnd.clear ();
QStringList prefixes {".bat", ".cmd", ".exe", ""}; QStringList prefixes {".bat", ".cmd", ".exe", ""};
QString target;
for (auto const& prefix : prefixes) for (auto const& prefix : prefixes)
{ {
auto const& path = m_appDir + "/user_hardware" + prefix; target = QDir {m_appDir}.absoluteFilePath (QLatin1String {"user_hardware"});
QFile f {path}; QFileInfo f {target + prefix};
if (f.exists ()) { if (f.isExecutable ()) {
m_cmnd = QDir::toNativeSeparators (f.fileName ()) + ' ' + break;
m_config.bands ()->find (m_freqNominal).remove ('m');
} }
} }
if(m_cmnd!="") p3.start(m_cmnd); // Execute user's hardware controller if (target.size ())
{
// Execute user's hardware controller
p3.start(QDir::toNativeSeparators (target)
, QStringList {m_config.bands ()->find (m_freqNominal).remove ('m')});
}
// Produce a short tuneup signal // Produce a short tuneup signal
m_tuneup = false; m_tuneup = false;
@ -8173,7 +8236,13 @@ void MainWindow::write_transmit_entry (QString const& file_name)
out << time.toString("yyMMdd_hhmmss") out << time.toString("yyMMdd_hhmmss")
<< " Transmitting " << qSetRealNumberPrecision (12) << (m_freqNominal / 1.e6) << " Transmitting " << qSetRealNumberPrecision (12) << (m_freqNominal / 1.e6)
<< " MHz " << m_modeTx << " MHz " << m_modeTx
<< ": " << m_currentMessage << endl; << ": " << m_currentMessage
#if QT_VERSION >= QT_VERSION_CHECK (5, 15, 0)
<< Qt::endl
#else
<< endl
#endif
;
f.close(); f.close();
} }
else else
@ -8261,7 +8330,7 @@ QString MainWindow::sortHoundCalls(QString t, int isort, int max_dB)
QString msg,houndCall,t1; QString msg,houndCall,t1;
QString ABC{"ABCDEFGHIJKLMNOPQRSTUVWXYZ _"}; QString ABC{"ABCDEFGHIJKLMNOPQRSTUVWXYZ _"};
QList<int> list; QList<int> list;
int i,j,k,m,n,nlines; int i,j,k,n,nlines;
bool bReverse=(isort >= 3); bool bReverse=(isort >= 3);
isort=qAbs(isort); isort=qAbs(isort);
@ -8278,20 +8347,20 @@ QString MainWindow::sortHoundCalls(QString t, int isort, int max_dB)
j=0; j=0;
t=""; t="";
for(auto a: map.keys()) { for(auto a: map.keys()) {
t1=map[a].split(" ",QString::SkipEmptyParts).at(2); t1=map[a].split(" ",SkipEmptyParts).at(2);
int nsnr=t1.toInt(); // get snr int nsnr=t1.toInt(); // get snr
if(nsnr <= max_dB) { // keep only if snr in specified range if(nsnr <= max_dB) { // keep only if snr in specified range
if(isort==1) t += map[a] + "\n"; if(isort==1) t += map[a] + "\n";
if(isort==3 or isort==4) { if(isort==3 or isort==4) {
i=2; // sort Hound calls by snr i=2; // sort Hound calls by snr
if(isort==4) i=4; // sort Hound calls by distance if(isort==4) i=4; // sort Hound calls by distance
t1=map[a].split(" ",QString::SkipEmptyParts).at(i); t1=map[a].split(" ",SkipEmptyParts).at(i);
n=1000*(t1.toInt()+100) + j; // pack (snr or dist) and index j into n n=1000*(t1.toInt()+100) + j; // pack (snr or dist) and index j into n
list.insert(j,n); // add n to list at [j] list.insert(j,n); // add n to list at [j]
} }
if(isort==2) { // sort Hound calls by grid if(isort==2) { // sort Hound calls by grid
t1=map[a].split(" ",QString::SkipEmptyParts).at(1); t1=map[a].split(" ",SkipEmptyParts).at(1);
if(t1=="....") t1="ZZ99"; if(t1=="....") t1="ZZ99";
int i1=ABC.indexOf(t1.mid(0,1)); int i1=ABC.indexOf(t1.mid(0,1));
int i2=ABC.indexOf(t1.mid(1,1)); int i2=ABC.indexOf(t1.mid(1,1));
@ -8328,11 +8397,13 @@ QString MainWindow::sortHoundCalls(QString t, int isort, int max_dB)
a[i]=i; a[i]=i;
} }
for(i=nn-1; i>-1; i--) { for(i=nn-1; i>-1; i--) {
#if QT_VERSION >= QT_VERSION_CHECK (5, 15, 0)
j = (i + 1) * QRandomGenerator::global ()->generateDouble ();
#else
j=(i+1)*double(qrand())/RAND_MAX; j=(i+1)*double(qrand())/RAND_MAX;
m=a[j]; #endif
a[j]=a[i]; std::swap (a[j], a[i]);
a[i]=m; t += lines2.at(a[i]) + "\n";
t += lines2.at(m) + "\n";
} }
} }
@ -8356,13 +8427,13 @@ void MainWindow::selectHound(QString line)
*/ */
if(line.length()==0) return; if(line.length()==0) return;
QString houndCall=line.split(" ",QString::SkipEmptyParts).at(0); QString houndCall=line.split(" ",SkipEmptyParts).at(0);
// Don't add a call already enqueued or in QSO // Don't add a call already enqueued or in QSO
if(ui->textBrowser4->toPlainText().indexOf(houndCall) >= 0) return; if(ui->textBrowser4->toPlainText().indexOf(houndCall) >= 0) return;
QString houndGrid=line.split(" ",QString::SkipEmptyParts).at(1); // Hound caller's grid QString houndGrid=line.split(" ",SkipEmptyParts).at(1); // Hound caller's grid
QString rpt=line.split(" ",QString::SkipEmptyParts).at(2); // Hound SNR QString rpt=line.split(" ",SkipEmptyParts).at(2); // Hound SNR
m_houndCallers=m_houndCallers.remove(line+"\n"); // Remove t from sorted Hound list m_houndCallers=m_houndCallers.remove(line+"\n"); // Remove t from sorted Hound list
m_nSortedHounds--; m_nSortedHounds--;
@ -8726,9 +8797,20 @@ void MainWindow::writeFoxQSO(QString const& msg)
QFile f {m_config.writeable_data_dir ().absoluteFilePath ("FoxQSO.txt")}; QFile f {m_config.writeable_data_dir ().absoluteFilePath ("FoxQSO.txt")};
if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) { if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) {
QTextStream out(&f); QTextStream out(&f);
out << QDateTime::currentDateTimeUtc().toString("yyyy-MM-dd hh:mm:ss") out << QDateTime::currentDateTimeUtc().toString("yyyy-MM-dd hh:mm:ss") << " "
<< " " << fixed << qSetRealNumberPrecision (3) << (m_freqNominal/1.e6) #if QT_VERSION >= QT_VERSION_CHECK (5, 15, 0)
<< t << msg << endl; << Qt::fixed
#else
<< fixed
#endif
<< qSetRealNumberPrecision (3) << (m_freqNominal/1.e6)
<< t << msg
#if QT_VERSION >= QT_VERSION_CHECK (5, 15, 0)
<< Qt::endl
#else
<< endl
#endif
;
f.close(); f.close();
} else { } else {
MessageBox::warning_message (this, tr("File Open Error"), MessageBox::warning_message (this, tr("File Open Error"),
@ -8855,7 +8937,13 @@ void MainWindow::write_all(QString txRx, QString message)
QFile f{m_config.writeable_data_dir().absoluteFilePath(file_name)}; QFile f{m_config.writeable_data_dir().absoluteFilePath(file_name)};
if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) { if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) {
QTextStream out(&f); QTextStream out(&f);
out << line << endl; out << line
#if QT_VERSION >= QT_VERSION_CHECK (5, 15, 0)
<< Qt::endl
#else
<< endl
#endif
;
f.close(); f.close();
} else { } else {
auto const& message2 = tr ("Cannot open \"%1\" for append: %2") auto const& message2 = tr ("Cannot open \"%1\" for append: %2")

View File

@ -3,6 +3,8 @@
#define MAINWINDOW_H #define MAINWINDOW_H
#include <QMainWindow> #include <QMainWindow>
#include <QString>
#include <QStringList>
#include <QLabel> #include <QLabel>
#include <QThread> #include <QThread>
#include <QProcess> #include <QProcess>
@ -605,8 +607,7 @@ private:
QString m_rptRcvd; QString m_rptRcvd;
QString m_qsoStart; QString m_qsoStart;
QString m_qsoStop; QString m_qsoStop;
QString m_cmnd; QStringList m_cmndP1;
QString m_cmndP1;
QString m_msgSent0; QString m_msgSent0;
QString m_calls; QString m_calls;
QString m_CQtype; QString m_CQtype;
@ -713,7 +714,7 @@ private:
void pskPost(DecodedText const& decodedtext); void pskPost(DecodedText const& decodedtext);
void displayDialFrequency (); void displayDialFrequency ();
void transmitDisplay (bool); void transmitDisplay (bool);
void processMessage(DecodedText const&, Qt::KeyboardModifiers = 0); void processMessage(DecodedText const&, Qt::KeyboardModifiers = Qt::NoModifier);
void replyToCQ (QTime, qint32 snr, float delta_time, quint32 delta_frequency, QString const& mode, QString const& message_text, bool low_confidence, quint8 modifiers); 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 locationChange(QString const& location);
void replayDecodes (); void replayDecodes ();