Take advantage of the new KVASD v1.12

Pass the  temporary directory to  jt9 and use  it to give  the correct
paths  to  temporary files.  Also  jt9  passes  the absolute  path  to
kvasd.dat in the temporary directory to kvasd.

Clear out all the annoying cruft that has accumulated due to having to
run with $CWD as the temporary directory.

Use QStandardPaths  to find the  writable data directory  where needed
rather than passing it around  between objects. This now works because
the $CWD hasn't been changed.

Do away with the CMake option WSJT_STANDARD_FILE_LOCATIONS as it is no
longer needed.

Fix astro status file azel.dat formatting.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@4732 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Bill Somerville 2014-12-03 00:06:54 +00:00
parent c7e74af254
commit f37ed4cd78
22 changed files with 535 additions and 571 deletions

View File

@ -83,7 +83,6 @@ option (WSJT_QDEBUG_TO_FILE "Redirect Qt debuging messages to a trace file.")
option (WSJT_TRACE_CAT "Debugging option that turns on CAT diagnostics.")
option (WSJT_TRACE_CAT_POLLS "Debugging option that turns on CAT diagnostics during polling.")
option (WSJT_HAMLIB_TRACE "Debugging option that turns on full Hamlib internal diagnostics.")
option (WSJT_STANDARD_FILE_LOCATIONS "All non-installation files located in \"Standard\" platfom specific locations." ON)
option (WSJT_SOFT_KEYING "Apply a ramp to CW keying envelope to reduce transients." ON)
option (WSJT_SKIP_MANPAGES "Skip *nix manpage generation.")

View File

@ -343,9 +343,8 @@ private:
QSettings * settings_;
QDir doc_path_;
QDir temp_path_;
QDir data_path_;
QDir doc_dir_;
QDir temp_dir_;
QDir default_save_directory_;
QDir save_directory_;
@ -438,8 +437,8 @@ Configuration::~Configuration ()
{
}
QDir Configuration::doc_path () const {return m_->doc_path_;}
QDir Configuration::data_path () const {return m_->data_path_;}
QDir Configuration::doc_dir () const {return m_->doc_dir_;}
QDir Configuration::temp_dir () const {return m_->temp_dir_;}
int Configuration::exec () {return m_->exec ();}
@ -554,9 +553,6 @@ Configuration::impl::impl (Configuration * self, QSettings * settings, QWidget *
, self_ {self}
, ui_ {new Ui::configuration_dialog}
, settings_ {settings}
, doc_path_ {QApplication::applicationDirPath ()}
, temp_path_ {QApplication::applicationDirPath ()}
, data_path_ {QApplication::applicationDirPath ()}
, font_ {QApplication::font ()}
, font_changed_ {false}
, decoded_text_font_changed_ {false}
@ -601,64 +597,51 @@ Configuration::impl::impl (Configuration * self, QSettings * settings, QWidget *
#define WSJT_DOC_DESTINATION "."
#endif
// we must find this before changing the CWD since that breaks
// QCoreApplication::applicationDirPath() which is used internally
// by QStandardPaths :(
#if !defined (Q_OS_WIN) || QT_VERSION >= 0x050300
auto path = QStandardPaths::locate (QStandardPaths::DataLocation, WSJT_DOC_DESTINATION, QStandardPaths::LocateDirectory);
if (path.isEmpty ())
{
doc_path_.cdUp ();
doc_dir_.cdUp ();
#if defined (Q_OS_MAC)
doc_path_.cdUp ();
doc_path_.cdUp ();
doc_dir_.cdUp ();
doc_dir_.cdUp ();
#endif
doc_path_.cd (WSJT_SHARE_DESTINATION);
doc_path_.cd (WSJT_DOC_DESTINATION);
doc_dir_.cd (WSJT_SHARE_DESTINATION);
doc_dir_.cd (WSJT_DOC_DESTINATION);
}
else
{
doc_path_.cd (path);
doc_dir_.cd (path);
}
#else
doc_path_.cd (WSJT_DOC_DESTINATION);
doc_dir_.cd (WSJT_DOC_DESTINATION);
#endif
#if WSJT_STANDARD_FILE_LOCATIONS
// the following needs to be done on all platforms but changes need
// coordination with JTAlert developers
{
// Create a temporary directory in a suitable location
QString temp_location {QStandardPaths::writableLocation (QStandardPaths::TempLocation)};
if (!temp_location.isEmpty ())
{
temp_path_.setPath (temp_location);
temp_dir_.setPath (temp_location);
}
QString unique_directory {QApplication::applicationName ()};
if (!temp_path_.mkpath (unique_directory) || !temp_path_.cd (unique_directory))
if (!temp_dir_.mkpath (unique_directory) || !temp_dir_.cd (unique_directory))
{
QMessageBox::critical (this, "WSJT-X", tr ("Create temporary directory error: ") + temp_path_.absolutePath ());
QMessageBox::critical (this, "WSJT-X", tr ("Create temporary directory error: ") + temp_dir_.absolutePath ());
throw std::runtime_error {"Failed to create usable temporary directory"};
}
}
// kvasd writes files to $cwd so by changing to the temp directory
// we can keep these files out of the startup directory
QDir::setCurrent (temp_path_.absolutePath ());
// we run kvasd with a $cwd of our temp directory so we need to copy
// in a fresh kvasd.dat for it
//
// this requirement changes with kvasd v 1.12 since it has a
// parameter to set the data file path
// copy the kvasd.dat file used for inter-process communication with
// kvasd from the resources file system to the temporary directory
QString kvasd_data_file {"kvasd.dat"};
if (!temp_path_.exists (kvasd_data_file))
if (!temp_dir_.exists (kvasd_data_file))
{
auto dest_file = temp_path_.absoluteFilePath (kvasd_data_file);
auto dest_file = temp_dir_.absoluteFilePath (kvasd_data_file);
if (!QFile::copy (":/" + kvasd_data_file, dest_file))
{
QMessageBox::critical (this, "WSJT-X", tr ("Cannot copy: :/") + kvasd_data_file + tr (" to: ") + temp_path_.absolutePath ());
QMessageBox::critical (this, "WSJT-X", tr ("Cannot copy: :/") + kvasd_data_file + tr (" to: ") + temp_dir_.absolutePath ());
throw std::runtime_error {"Failed to copy kvasd.dat to temporary directory"};
}
else
@ -670,30 +653,16 @@ Configuration::impl::impl (Configuration * self, QSettings * settings, QWidget *
{
// Find a suitable data file location
QString data_location {QStandardPaths::writableLocation (QStandardPaths::DataLocation)};
if (!data_location.isEmpty ())
QDir data_dir {QStandardPaths::writableLocation (QStandardPaths::DataLocation)};
if (!data_dir.mkpath ("."))
{
data_path_.setPath (data_location);
}
if (!data_path_.mkpath ("."))
{
QMessageBox::critical (this, "WSJT-X", tr ("Create data directory error: ") + data_path_.absolutePath ());
QMessageBox::critical (this, "WSJT-X", tr ("Create data directory error: ") + data_dir.absolutePath ());
throw std::runtime_error {"Failed to create data directory"};
}
}
// qDebug () << "Data store path:" << data_path_.absolutePath ();
// auto paths = QStandardPaths::standardLocations (QStandardPaths::DataLocation);
// Q_FOREACH (auto const& path, paths)
// {
// qDebug () << "path:" << path;
// }
#endif
{
// Make sure the default save directory exists
QString save_dir {"save"};
default_save_directory_ = data_path_;
default_save_directory_ = data_dir;
if (!default_save_directory_.mkpath (save_dir) || !default_save_directory_.cd (save_dir))
{
QMessageBox::critical (this, "WSJT-X", tr ("Create Directory", "Cannot create directory \"") + default_save_directory_.absoluteFilePath (save_dir) + "\".");
@ -869,10 +838,7 @@ Configuration::impl::~impl ()
transceiver_thread_.quit ();
transceiver_thread_.wait ();
QDir::setCurrent (QApplication::applicationDirPath ());
#if WSJT_STANDARD_FILE_LOCATIONS
temp_path_.removeRecursively (); // clean up temp files
#endif
temp_dir_.removeRecursively (); // clean up temp files
}
void Configuration::impl::initialise_models ()
@ -1809,7 +1775,6 @@ bool Configuration::impl::open_rig ()
, static_cast<TransceiverFactory::SplitMode> (ui_->split_mode_button_group->checkedId ())
, ui_->PTT_port_combo_box->currentText ()
, ui_->CAT_poll_interval_spin_box->value () * 1000
, data_path_
, &transceiver_thread_
);

View File

@ -66,8 +66,8 @@ public:
int exec ();
QDir data_path () const;
QDir doc_path () const;
QDir temp_dir () const;
QDir doc_dir () const;
QAudioDeviceInfo const& audio_input_device () const;
AudioDevice::Channel audio_input_channel () const;

View File

@ -5,6 +5,8 @@
#include <QRegExp>
#include <QTcpSocket>
#include <QThread>
#include <QStandardPaths>
#include <QDir>
#include "NetworkServerLookup.hpp"
@ -66,13 +68,11 @@ qint32 const HRDMessage::magic_2_value_ (0xABCD1234);
HRDTransceiver::HRDTransceiver (std::unique_ptr<TransceiverBase> wrapped
, QString const& server
, bool use_for_ptt
, int poll_interval
, QDir const& data_path)
, int poll_interval)
: PollingTransceiver {poll_interval}
, wrapped_ {std::move (wrapped)}
, use_for_ptt_ {use_for_ptt}
, server_ {server}
, data_path_ {data_path}
, hrd_ {0}
, protocol_ {none}
, current_radio_ {0}
@ -158,11 +158,10 @@ void HRDTransceiver::do_start ()
send_command ("get context", false, false);
}
QString HRD_info_path {data_path_.absoluteFilePath ("HRD Interface Information.txt")};
QFile HRD_info_file {HRD_info_path};
QFile HRD_info_file {QDir {QStandardPaths::writableLocation (QStandardPaths::DataLocation)}.absoluteFilePath ("HRD Interface Information.txt")};
if (!HRD_info_file.open (QFile::WriteOnly | QFile::Text | QFile::Truncate))
{
throw error {tr ("Failed to open file \"%1\".").arg (HRD_info_path)};
throw error {tr ("Failed to open file \"%1\".").arg (HRD_info_file.fileName ())};
}
QTextStream HRD_info {&HRD_info_file};

View File

@ -8,7 +8,6 @@
#include <QScopedPointer>
#include <QString>
#include <QStringList>
#include <QDir>
#include "TransceiverFactory.hpp"
#include "PollingTransceiver.hpp"
@ -34,8 +33,7 @@ public:
explicit HRDTransceiver (std::unique_ptr<TransceiverBase> wrapped
, QString const& server
, bool use_for_ptt
, int poll_interval
, QDir const& data_path);
, int poll_interval);
~HRDTransceiver ();
protected:
@ -81,8 +79,6 @@ private:
QString server_; // The TCP/IP addrress and port for
// the HRD server.
QDir data_path_; // Directory to write files to
QTcpSocket * hrd_; // The TCP/IP client that links to the
// HRD server.

View File

@ -107,7 +107,6 @@ std::unique_ptr<Transceiver> TransceiverFactory::create (QString const& name
, SplitMode split_mode
, QString const& ptt_port
, int poll_interval
, QDir const& data_path
, QThread * target_thread
)
{
@ -170,7 +169,7 @@ std::unique_ptr<Transceiver> TransceiverFactory::create (QString const& name
}
// wrap the basic Transceiver object instance with a decorator object that talks to ham Radio Deluxe
result.reset (new HRDTransceiver {std::move (basic_transceiver), cat_port, PTT_method_CAT == ptt_type, poll_interval, data_path});
result.reset (new HRDTransceiver {std::move (basic_transceiver), cat_port, PTT_method_CAT == ptt_type, poll_interval});
if (target_thread)
{
result.get ()->moveToThread (target_thread);

View File

@ -112,7 +112,6 @@ public:
, SplitMode split_mode // how to support split TX mode
, QString const& ptt_port // serial port device name or special value "CAT"
, int poll_interval // in milliseconds for interfaces that require polling for parameter changes
, QDir const& data_path
, QThread * target_thread = nullptr
);

393
astro.cpp
View File

@ -1,187 +1,206 @@
#include "astro.h"
#include <stdio.h>
#include <QApplication>
#include <QFile>
#include <QTextStream>
#include <QMessageBox>
#include <QSettings>
#include <QDateTime>
#include <QFont>
#include <QFontDialog>
#include "commons.h"
#include "ui_astro.h"
#include "moc_astro.cpp"
Astro::Astro(QSettings * settings, QDir const& dataPath, QWidget * parent) :
QWidget {parent},
settings_ {settings},
ui_ {new Ui::Astro},
data_path_ {dataPath}
{
ui_->setupUi(this);
setWindowFlags (Qt::Dialog | Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint);
setWindowTitle(QApplication::applicationName () + " - " + tr ("Astronomical Data"));
read_settings ();
ui_->text_label->clear();
}
Astro::~Astro ()
{
if (isVisible ())
{
write_settings ();
}
}
void Astro::closeEvent (QCloseEvent * e)
{
write_settings ();
QWidget::closeEvent (e);
}
void Astro::read_settings ()
{
settings_->beginGroup ("Astro");
move (settings_->value ("window/pos", pos ()).toPoint ());
QFont font;
if (font.fromString (settings_->value ("font", ui_->text_label->font ().toString ()).toString ()))
{
ui_->text_label->setFont (font);
adjustSize ();
}
settings_->endGroup ();
}
void Astro::write_settings ()
{
settings_->beginGroup ("Astro");
settings_->setValue ("window/pos", pos ());
settings_->setValue ("font", ui_->text_label->font ().toString ());
settings_->endGroup ();
}
void Astro::on_font_push_button_clicked (bool /* checked */)
{
bool changed;
ui_->text_label->setFont (QFontDialog::getFont (&changed
, ui_->text_label->font ()
, this
, tr ("WSJT-X Astro Text Font Chooser")
#if QT_VERSION >= 0x050201
, QFontDialog::MonospacedFonts
#endif
));
if (changed)
{
adjustSize ();
}
}
void Astro::astroUpdate(QDateTime t, QString mygrid, QString hisgrid,
int fQSO, int nsetftx, int ntxFreq)
{
static int ntxFreq0=-99;
double azsun,elsun,azmoon,elmoon,azmoondx,elmoondx;
double ramoon,decmoon,dgrd,poloffset,xnr,techo;
int ntsky,ndop,ndop00;
QString date = t.date().toString("yyyy MMM dd").trimmed ();
QString utc = t.time().toString().trimmed ();
int nyear=t.date().year();
int month=t.date().month();
int nday=t.date().day();
int nhr=t.time().hour();
int nmin=t.time().minute();
double sec=t.time().second() + 0.001*t.time().msec();
int isec=sec;
double uth=nhr + nmin/60.0 + sec/3600.0;
// int nfreq=(int)datcom_.fcenter;
int nfreq=10368;
if(nfreq<10 or nfreq > 50000) nfreq=144;
astrosub_(&nyear, &month, &nday, &uth, &nfreq, mygrid.toLatin1(),
hisgrid.toLatin1(), &azsun, &elsun, &azmoon, &elmoon,
&azmoondx, &elmoondx, &ntsky, &ndop, &ndop00,&ramoon, &decmoon,
&dgrd, &poloffset, &xnr, &techo, 6, 6);
QString message;
{
QTextStream out {&message};
out
<< " " << date << "\n"
"UTC: " << utc << "\n"
<< fixed
<< qSetFieldWidth (6)
<< qSetRealNumberPrecision (1)
<< "Az: " << azmoon << "\n"
"El: " << elmoon << "\n"
"MyDop: " << ndop00 << "\n"
<< qSetRealNumberPrecision (2)
<< "Delay: " << techo << "\n"
<< qSetRealNumberPrecision (1)
<< "DxAz: " << azmoondx << "\n"
"DxEl: " << elmoondx << "\n"
"DxDop: " << ndop << "\n"
"Dec: " << decmoon << "\n"
"SunAz: " << azsun << "\n"
"SunEl: " << elsun << "\n"
"Freq: " << nfreq << "\n"
"Tsky: " << ntsky << "\n"
"MNR: " << xnr << "\n"
"Dgrd: " << dgrd;
}
ui_->text_label->setText(message);
QString fname {"azel.dat"};
QFile f(data_path_.absoluteFilePath (fname));
if(!f.open(QIODevice::WriteOnly | QIODevice::Text)) {
QMessageBox mb;
mb.setText("Cannot open \"" + f.fileName () + "\".");
mb.exec();
return;
}
int ndiff=0;
if(ntxFreq != ntxFreq0) ndiff=1;
ntxFreq0=ntxFreq;
{
QTextStream out {&f};
out << fixed
<< qSetFieldWidth (2)
<< qSetRealNumberPrecision (1)
<< qSetPadChar ('0')
<< right
<< nhr << ':' << nmin << ':' << isec
<< qSetFieldWidth (5)
<< ',' << azmoon << ',' << elmoon << ",Moon\n"
<< qSetFieldWidth (2)
<< nhr << ':' << nmin << ':' << isec
<< qSetFieldWidth (5)
<< ',' << azsun << ',' << elsun << ",Sun\n"
<< qSetFieldWidth (2)
<< nhr << ':' << nmin << ':' << isec
<< qSetFieldWidth (5)
<< ',' << 0. << ',' << 0. << ",Sun\n"
<< qSetPadChar (' ')
<< qSetFieldWidth (4)
<< nfreq << ','
<< qSetFieldWidth (6)
<< ndop << ",Doppler\n"
<< qSetFieldWidth (3)
<< fQSO << ','
<< qSetFieldWidth (1)
<< nsetftx << ",fQSO\n"
<< qSetFieldWidth (3)
<< ntxFreq << ','
<< qSetFieldWidth (1)
<< ndiff << ",fQSO2";
}
f.close();
}
#include "astro.h"
#include <stdio.h>
#include <QApplication>
#include <QFile>
#include <QTextStream>
#include <QMessageBox>
#include <QSettings>
#include <QDateTime>
#include <QFont>
#include <QFontDialog>
#include <QStandardPaths>
#include <QDir>
#include "commons.h"
#include "ui_astro.h"
#include "moc_astro.cpp"
Astro::Astro(QSettings * settings, QWidget * parent)
: QWidget {parent}
, settings_ {settings}
, ui_ {new Ui::Astro}
{
ui_->setupUi(this);
setWindowFlags (Qt::Dialog | Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint);
setWindowTitle(QApplication::applicationName () + " - " + tr ("Astronomical Data"));
read_settings ();
ui_->text_label->clear();
}
Astro::~Astro ()
{
if (isVisible ())
{
write_settings ();
}
}
void Astro::closeEvent (QCloseEvent * e)
{
write_settings ();
QWidget::closeEvent (e);
}
void Astro::read_settings ()
{
settings_->beginGroup ("Astro");
move (settings_->value ("window/pos", pos ()).toPoint ());
QFont font;
if (font.fromString (settings_->value ("font", ui_->text_label->font ().toString ()).toString ()))
{
ui_->text_label->setFont (font);
adjustSize ();
}
settings_->endGroup ();
}
void Astro::write_settings ()
{
settings_->beginGroup ("Astro");
settings_->setValue ("window/pos", pos ());
settings_->setValue ("font", ui_->text_label->font ().toString ());
settings_->endGroup ();
}
void Astro::on_font_push_button_clicked (bool /* checked */)
{
bool changed;
ui_->text_label->setFont (QFontDialog::getFont (&changed
, ui_->text_label->font ()
, this
, tr ("WSJT-X Astro Text Font Chooser")
#if QT_VERSION >= 0x050201
, QFontDialog::MonospacedFonts
#endif
));
if (changed)
{
adjustSize ();
}
}
void Astro::astroUpdate(QDateTime t, QString mygrid, QString hisgrid,
int fQSO, int nsetftx, int ntxFreq)
{
static int ntxFreq0=-99;
double azsun,elsun,azmoon,elmoon,azmoondx,elmoondx;
double ramoon,decmoon,dgrd,poloffset,xnr,techo;
int ntsky,ndop,ndop00;
QString date = t.date().toString("yyyy MMM dd").trimmed ();
QString utc = t.time().toString().trimmed ();
int nyear=t.date().year();
int month=t.date().month();
int nday=t.date().day();
int nhr=t.time().hour();
int nmin=t.time().minute();
double sec=t.time().second() + 0.001*t.time().msec();
int isec=sec;
double uth=nhr + nmin/60.0 + sec/3600.0;
// int nfreq=(int)datcom_.fcenter;
int nfreq=10368;
if(nfreq<10 or nfreq > 50000) nfreq=144;
astrosub_(&nyear, &month, &nday, &uth, &nfreq, mygrid.toLatin1(),
hisgrid.toLatin1(), &azsun, &elsun, &azmoon, &elmoon,
&azmoondx, &elmoondx, &ntsky, &ndop, &ndop00,&ramoon, &decmoon,
&dgrd, &poloffset, &xnr, &techo, 6, 6);
QString message;
{
QTextStream out {&message};
out
<< " " << date << "\n"
"UTC: " << utc << "\n"
<< fixed
<< qSetFieldWidth (6)
<< qSetRealNumberPrecision (1)
<< "Az: " << azmoon << "\n"
"El: " << elmoon << "\n"
"MyDop: " << ndop00 << "\n"
<< qSetRealNumberPrecision (2)
<< "Delay: " << techo << "\n"
<< qSetRealNumberPrecision (1)
<< "DxAz: " << azmoondx << "\n"
"DxEl: " << elmoondx << "\n"
"DxDop: " << ndop << "\n"
"Dec: " << decmoon << "\n"
"SunAz: " << azsun << "\n"
"SunEl: " << elsun << "\n"
"Freq: " << nfreq << "\n"
"Tsky: " << ntsky << "\n"
"MNR: " << xnr << "\n"
"Dgrd: " << dgrd;
}
ui_->text_label->setText(message);
static QFile f {QDir {QStandardPaths::writableLocation (QStandardPaths::DataLocation)}.absoluteFilePath ("azel.dat")};
if (!f.open (QIODevice::WriteOnly | QIODevice::Text))
{
QMessageBox mb;
mb.setText ("Cannot open \"" + f.fileName () + "\".");
mb.exec();
return;
}
int ndiff=0;
if(ntxFreq != ntxFreq0) ndiff=1;
ntxFreq0=ntxFreq;
{
QTextStream out {&f};
out << fixed
<< qSetRealNumberPrecision (1)
<< qSetPadChar ('0')
<< right
<< qSetFieldWidth (2) << nhr
<< qSetFieldWidth (0) << ':'
<< qSetFieldWidth (2) << nmin
<< qSetFieldWidth (0) << ':'
<< qSetFieldWidth (2) << isec
<< qSetFieldWidth (0) << ','
<< qSetFieldWidth (5) << azmoon
<< qSetFieldWidth (0) << ','
<< qSetFieldWidth (5) << elmoon
<< qSetFieldWidth (0) << ",Moon\n"
<< qSetFieldWidth (2) << nhr
<< qSetFieldWidth (0) << ':'
<< qSetFieldWidth (2) << nmin
<< qSetFieldWidth (0) << ':'
<< qSetFieldWidth (2) << isec
<< qSetFieldWidth (0) << ','
<< qSetFieldWidth (5) << azsun
<< qSetFieldWidth (0) << ','
<< qSetFieldWidth (5) << elsun
<< qSetFieldWidth (0) << ",Sun\n"
<< qSetFieldWidth (2) << nhr
<< qSetFieldWidth (0) << ':'
<< qSetFieldWidth (2) << nmin
<< qSetFieldWidth (0) << ':'
<< qSetFieldWidth (2) << isec
<< qSetFieldWidth (0) << ','
<< qSetFieldWidth (5) << 0.
<< qSetFieldWidth (0) << ','
<< qSetFieldWidth (5) << 0.
<< qSetFieldWidth (0) << ",Sun\n"
<< qSetPadChar (' ')
<< qSetFieldWidth (4) << nfreq
<< qSetFieldWidth (0) << ','
<< qSetFieldWidth (6) << ndop
<< qSetFieldWidth (0) << ",Doppler\n"
<< qSetFieldWidth (3) << fQSO
<< qSetFieldWidth (0) << ','
<< qSetFieldWidth (1) << nsetftx
<< qSetFieldWidth (0) << ",fQSO\n"
<< qSetFieldWidth (3) << ntxFreq
<< qSetFieldWidth (0) << ','
<< qSetFieldWidth (1) << ndiff
<< qSetFieldWidth (0) << ",fQSO2";
}
f.close();
}

103
astro.h
View File

@ -1,52 +1,51 @@
// -*- Mode: C++ -*-
#ifndef ASTRO_H
#define ASTRO_H
#include <QWidget>
#include <QDir>
class QSettings;
namespace Ui {
class Astro;
}
class Astro final
: public QWidget
{
Q_OBJECT;
private:
Q_DISABLE_COPY (Astro);
public:
explicit Astro(QSettings * settings, QDir const& dataPath, QWidget * parent = nullptr);
~Astro ();
void astroUpdate(QDateTime t, QString mygrid, QString hisgrid,
int fQSO, int nsetftx, int ntxFreq);
Q_SLOT void on_font_push_button_clicked (bool);
protected:
void closeEvent (QCloseEvent *) override;
private:
void read_settings ();
void write_settings ();
QSettings * settings_;
QScopedPointer<Ui::Astro> ui_;
QDir data_path_;
};
extern "C" {
void astrosub_(int* nyear, int* month, int* nday, double* uth, int* nfreq,
const char* mygrid, const char* hisgrid, double* azsun,
double* elsun, double* azmoon, double* elmoon, double* azmoondx,
double* elmoondx, int* ntsky, int* ndop, int* ndop00,
double* ramoon, double* decmoon, double* dgrd, double* poloffset,
double* xnr, double* techo, int len1, int len2);
}
#endif // ASTRO_H
// -*- Mode: C++ -*-
#ifndef ASTRO_H
#define ASTRO_H
#include <QWidget>
#include <QDir>
class QSettings;
namespace Ui {
class Astro;
}
class Astro final
: public QWidget
{
Q_OBJECT;
private:
Q_DISABLE_COPY (Astro);
public:
explicit Astro(QSettings * settings, QWidget * parent = nullptr);
~Astro ();
void astroUpdate(QDateTime t, QString mygrid, QString hisgrid,
int fQSO, int nsetftx, int ntxFreq);
Q_SLOT void on_font_push_button_clicked (bool);
protected:
void closeEvent (QCloseEvent *) override;
private:
void read_settings ();
void write_settings ();
QSettings * settings_;
QScopedPointer<Ui::Astro> ui_;
};
extern "C" {
void astrosub_(int* nyear, int* month, int* nday, double* uth, int* nfreq,
const char* mygrid, const char* hisgrid, double* azsun,
double* elsun, double* azmoon, double* elmoon, double* azmoondx,
double* elmoondx, int* ntsky, int* ndop, int* ndop00,
double* ramoon, double* decmoon, double* dgrd, double* poloffset,
double* xnr, double* techo, int len1, int len2);
}
#endif // ASTRO_H

View File

@ -27,12 +27,12 @@ subroutine decoder(ss,id2)
ndecodes1=0
if (nagain .eq. 0) then
open(13,file='decoded.txt',status='unknown')
open(13,file=trim(temp_dir)//'/decoded.txt',status='unknown')
else
open(13,file='decoded.txt',status='unknown',position='append')
open(13,file=trim(temp_dir)//'/decoded.txt',status='unknown',position='append')
end if
open(22,file='kvasd.dat',access='direct',recl=1024,status='unknown')
open(22,file=trim(temp_dir)//'/kvasd.dat',access='direct',recl=1024,status='unknown')
npts65=52*12000
if(baddata(id2,npts65)) then

View File

@ -1,121 +1,117 @@
subroutine extract(s3,nadd,ncount,nhist,decoded,ltext,nbmkv)
!subroutine extract(s3,nadd,nbirdie,afac1,xlambda,ncount,nhist,decoded, &
! ltext,nbmkv,ntest)
! Input:
! s3 64-point spectra for each of 63 data symbols
! nadd number of spectra summed into s3
! Output:
! ncount number of symbols requiring correction
! nhist maximum number of identical symbol values
! decoded decoded message (if ncount >=0)
! ltext true if decoded message is free text
! nbmkv 0=no decode; 1=BM decode; 2=KV decode
use prog_args !shm_key, exe_dir, data_dir
real s3(64,63)
character decoded*22
integer dat4(12)
integer mrsym(63),mr2sym(63),mrprob(63),mr2prob(63)
logical nokv,ltext
data nokv/.false./,nsec1/0/
save
nbirdie=7
npct=40
afac1=10.1
xlambda=8.0
nbmkv=0
nfail=0
decoded=' '
call pctile(s3,4032,npct,base)
s3=s3/base
! Get most reliable and second-most-reliable symbol values, and their
! probabilities
1 call demod64a(s3,nadd,afac1,mrsym,mrprob,mr2sym,mr2prob,ntest,nlow)
if(ntest.lt.100) then
ncount=-999 !Flag and reject bad data
go to 900
endif
call chkhist(mrsym,nhist,ipk) !Test for birdies and QRM
if(nhist.ge.nbirdie) then
nfail=nfail+1
call pctile(s3,4032,npct,base)
s3(ipk,1:63)=base
if(nfail.gt.30) then
decoded=' '
ncount=-1
go to 900
endif
go to 1
endif
call graycode65(mrsym,63,-1) !Remove gray code and interleaving
call interleave63(mrsym,-1) !from most reliable symbols
call interleave63(mrprob,-1)
! Decode using Berlekamp-Massey algorithm
call timer('rs_decod',0)
call rs_decode(mrsym,0,0,dat4,ncount)
call timer('rs_decod',1)
if(ncount.ge.0) then
call unpackmsg(dat4,decoded)
if(iand(dat4(10),8).ne.0) ltext=.true.
nbmkv=1
go to 900
endif
! Berlekamp-Massey algorithm failed, try Koetter-Vardy
if(nokv) go to 900
maxe=8 !Max KV errors in 12 most reliable symbols
call graycode65(mr2sym,63,-1) !Remove gray code and interleaving
call interleave63(mr2sym,-1) !from second-most-reliable symbols
call interleave63(mr2prob,-1)
nsec1=nsec1+1
dat4=0
write(22,rec=1) nsec1,xlambda,maxe,200,mrsym,mrprob,mr2sym,mr2prob
write(22,rec=2) -1,-1,dat4
call flush(22)
call timer('kvasd ',0)
! TODO G4WJS: Take out '-q' argument once kvasd 1.12 is available for
! Mac and in the repo where CMake fetches it from.
#ifdef WIN32
iret=system('""'//trim(exe_dir)//'/kvasd" -q >dev_null"')
! iret=system('""'//trim(exe_dir)//'/kvasd" kvasd.dat >dev_null"')
#else
iret=system('"'//trim(exe_dir)//'/kvasd" -q >/dev/null')
! iret=system('"'//trim(exe_dir)//'/kvasd" kvasd.dat >/dev/null')
#endif
call timer('kvasd ',1)
if(iret.ne.0) then
if(.not.nokv) write(*,1000) iret
1000 format('Error in KV decoder, or no KV decoder present.',i12)
! nokv=.true.
go to 900
endif
read(22,rec=2,err=900) nsec2,ncount,dat4
j=nsec2 !Silence compiler warning
decoded=' '
ltext=.false.
if(ncount.ge.0) then
call unpackmsg(dat4,decoded) !Unpack the user message
if(index(decoded,'...... ').gt.0) then
ncount=-1
go to 900
endif
if(iand(dat4(10),8).ne.0) ltext=.true.
nbmkv=2
endif
900 return
end subroutine extract
subroutine extract(s3,nadd,ncount,nhist,decoded,ltext,nbmkv)
!subroutine extract(s3,nadd,nbirdie,afac1,xlambda,ncount,nhist,decoded, &
! ltext,nbmkv,ntest)
! Input:
! s3 64-point spectra for each of 63 data symbols
! nadd number of spectra summed into s3
! Output:
! ncount number of symbols requiring correction
! nhist maximum number of identical symbol values
! decoded decoded message (if ncount >=0)
! ltext true if decoded message is free text
! nbmkv 0=no decode; 1=BM decode; 2=KV decode
use prog_args !shm_key, exe_dir, data_dir
real s3(64,63)
character decoded*22
integer dat4(12)
integer mrsym(63),mr2sym(63),mrprob(63),mr2prob(63)
logical nokv,ltext
data nokv/.false./,nsec1/0/
save
nbirdie=7
npct=40
afac1=10.1
xlambda=8.0
nbmkv=0
nfail=0
decoded=' '
call pctile(s3,4032,npct,base)
s3=s3/base
! Get most reliable and second-most-reliable symbol values, and their
! probabilities
1 call demod64a(s3,nadd,afac1,mrsym,mrprob,mr2sym,mr2prob,ntest,nlow)
if(ntest.lt.100) then
ncount=-999 !Flag and reject bad data
go to 900
endif
call chkhist(mrsym,nhist,ipk) !Test for birdies and QRM
if(nhist.ge.nbirdie) then
nfail=nfail+1
call pctile(s3,4032,npct,base)
s3(ipk,1:63)=base
if(nfail.gt.30) then
decoded=' '
ncount=-1
go to 900
endif
go to 1
endif
call graycode65(mrsym,63,-1) !Remove gray code and interleaving
call interleave63(mrsym,-1) !from most reliable symbols
call interleave63(mrprob,-1)
! Decode using Berlekamp-Massey algorithm
call timer('rs_decod',0)
call rs_decode(mrsym,0,0,dat4,ncount)
call timer('rs_decod',1)
if(ncount.ge.0) then
call unpackmsg(dat4,decoded)
if(iand(dat4(10),8).ne.0) ltext=.true.
nbmkv=1
go to 900
endif
! Berlekamp-Massey algorithm failed, try Koetter-Vardy
if(nokv) go to 900
maxe=8 !Max KV errors in 12 most reliable symbols
call graycode65(mr2sym,63,-1) !Remove gray code and interleaving
call interleave63(mr2sym,-1) !from second-most-reliable symbols
call interleave63(mr2prob,-1)
nsec1=nsec1+1
dat4=0
write(22,rec=1) nsec1,xlambda,maxe,200,mrsym,mrprob,mr2sym,mr2prob
write(22,rec=2) -1,-1,dat4
call flush(22)
call timer('kvasd ',0)
#ifdef WIN32
iret=system('""'//trim(exe_dir)//'/kvasd" "'//trim(temp_dir)//'/kvasd.dat" >"'//trim(temp_dir)//'/dev_null""')
#else
iret=system('"'//trim(exe_dir)//'/kvasd" "'//trim(temp_dir)//'/kvasd.dat" >/dev/null')
#endif
call timer('kvasd ',1)
if(iret.ne.0) then
if(.not.nokv) write(*,1000) iret
1000 format('Error in KV decoder, or no KV decoder present.',i12)
! nokv=.true.
go to 900
endif
read(22,rec=2,err=900) nsec2,ncount,dat4
j=nsec2 !Silence compiler warning
decoded=' '
ltext=.false.
if(ncount.ge.0) then
call unpackmsg(dat4,decoded) !Unpack the user message
if(index(decoded,'...... ').gt.0) then
ncount=-1
go to 900
endif
if(iand(dat4(10),8).ne.0) ltext=.true.
nbmkv=2
endif
900 return
end subroutine extract

View File

@ -23,7 +23,7 @@ program jt9
data npatience/1/
do
call getopt('s:e:a:r:p:d:f:w:',long_options,c,optarg,arglen,stat,offset,remain)
call getopt('s:e:a:r:p:d:f:w:t:',long_options,c,optarg,arglen,stat,offset,remain)
if (stat .ne. 0) then
exit
end if
@ -39,6 +39,9 @@ program jt9
case ('a')
data_dir = optarg(:arglen)
case ('t')
temp_dir = optarg(:arglen)
case ('p')
read_files = .true.
read (optarg(:arglen), *) ntrperiod
@ -62,7 +65,7 @@ program jt9
print*,'Usage: jt9 -p TRperiod [-d ndepth] [-f rxfreq] {-w patience] -e exe_dir file1 [file2 ...]'
print*,' Reads data from *.wav files.'
print*,''
print*,' jt9 -s <key> [-w patience] -e exe_dir'
print*,' jt9 -s <key> [-w patience] -e exe_dir -a data_dir -t temp_dir'
print*,' Gets data from shared memory region with key==<key>'
go to 999
endif

View File

@ -1,71 +1,71 @@
subroutine jt9a()
use prog_args
! These routines connect the shared memory region to the decoder.
interface
function address_jt9()
integer*1, pointer :: address_jt9
end function address_jt9
end interface
integer*1 attach_jt9
! integer*1 lock_jt9,unlock_jt9
integer size_jt9
integer*1, pointer :: p_jt9
character*80 cwd
! Multiple instances:
character*80 mykey
logical fileExists
common/tracer/limtrace,lu
! Multiple instances:
i0 = len(trim(shm_key))
call getcwd(cwd)
open(12,file=trim(data_dir)//'/timer.out',status='unknown')
limtrace=0
! limtrace=-1 !Disable all calls to timer()
lu=12
! Multiple instances: set the shared memory key before attaching
mykey=trim(repeat(shm_key,1))
i0 = len(mykey)
i0=setkey_jt9(trim(mykey))
i1=attach_jt9()
10 inquire(file='.lock',exist=fileExists)
if(fileExists) then
call sleep_msec(100)
go to 10
endif
inquire(file='.quit',exist=fileExists)
if(fileExists) then
i1=detach_jt9()
go to 999
endif
if(i1.eq.999999) stop !Silence compiler warning
nbytes=size_jt9()
if(nbytes.le.0) then
print*,'jt9a: Shared memory mem_jt9 does not exist.'
print*,"Must start 'jt9 -s <thekey>' from within WSJT-X."
go to 999
endif
p_jt9=>address_jt9()
call timer('jt9b ',0)
call jt9b(p_jt9,nbytes)
call timer('jt9b ',1)
100 inquire(file='.lock',exist=fileExists)
if(fileExists) go to 10
call sleep_msec(100)
go to 100
999 call timer('jt9b ',101)
return
end subroutine jt9a
subroutine jt9a()
use prog_args
! These routines connect the shared memory region to the decoder.
interface
function address_jt9()
integer*1, pointer :: address_jt9
end function address_jt9
end interface
integer*1 attach_jt9
! integer*1 lock_jt9,unlock_jt9
integer size_jt9
integer*1, pointer :: p_jt9
character*80 cwd
! Multiple instances:
character*80 mykey
logical fileExists
common/tracer/limtrace,lu
! Multiple instances:
i0 = len(trim(shm_key))
call getcwd(cwd)
open(12,file=trim(data_dir)//'/timer.out',status='unknown')
limtrace=0
! limtrace=-1 !Disable all calls to timer()
lu=12
! Multiple instances: set the shared memory key before attaching
mykey=trim(repeat(shm_key,1))
i0 = len(mykey)
i0=setkey_jt9(trim(mykey))
i1=attach_jt9()
10 inquire(file=trim(temp_dir)//'/.lock',exist=fileExists)
if(fileExists) then
call sleep_msec(100)
go to 10
endif
inquire(file=trim(temp_dir)//'/.quit',exist=fileExists)
if(fileExists) then
i1=detach_jt9()
go to 999
endif
if(i1.eq.999999) stop !Silence compiler warning
nbytes=size_jt9()
if(nbytes.le.0) then
print*,'jt9a: Shared memory mem_jt9 does not exist.'
print*,"Must start 'jt9 -s <thekey>' from within WSJT-X."
go to 999
endif
p_jt9=>address_jt9()
call timer('jt9b ',0)
call jt9b(p_jt9,nbytes)
call timer('jt9b ',1)
100 inquire(file=trim(temp_dir)//'/.lock',exist=fileExists)
if(fileExists) go to 10
call sleep_msec(100)
go to 100
999 call timer('jt9b ',101)
return
end subroutine jt9a

View File

@ -1,4 +1,4 @@
MODULE prog_args
CHARACTER(len=80) :: shm_key
CHARACTER(len=500) :: exe_dir = '.', data_dir = '.'
CHARACTER(len=500) :: exe_dir = '.', data_dir = '.', temp_dir = '.'
END MODULE prog_args

View File

@ -1,6 +1,7 @@
#include "logbook.h"
#include <QDebug>
#include <QFontMetrics>
#include <QStandardPaths>
#include <QDir>
namespace
@ -9,8 +10,9 @@ namespace
auto countryFileName = "cty.dat";
}
void LogBook::init(QDir const& dataPath)
void LogBook::init()
{
QDir dataPath {QStandardPaths::writableLocation (QStandardPaths::DataLocation)};
QString countryDataFilename;
if (dataPath.exists (countryFileName))
{

View File

@ -19,7 +19,7 @@ class QDir;
class LogBook
{
public:
void init(QDir const& dataPath);
void init();
void match(/*in*/ const QString call,
/*out*/ QString &countryName,
bool &callWorkedBefore,

View File

@ -2,21 +2,20 @@
#include <QString>
#include <QSettings>
#include <QStandardPaths>
#include <QDir>
#include <QDebug>
#include "Configuration.hpp"
#include "logbook/adif.h"
#include "ui_logqso.h"
#include "moc_logqso.cpp"
LogQSO::LogQSO(QString const& programTitle, QSettings * settings, Configuration const * configuration, QWidget *parent) :
QDialog(parent),
ui(new Ui::LogQSO),
m_settings (settings),
m_configuration (configuration)
LogQSO::LogQSO(QString const& programTitle, QSettings * settings, QWidget *parent)
: QDialog(parent)
, ui(new Ui::LogQSO)
, m_settings (settings)
{
ui->setupUi(this);
setWindowTitle(programTitle + " - Log QSO");
@ -109,7 +108,7 @@ void LogQSO::accept()
//Log this QSO to ADIF file "wsjtx_log.adi"
QString filename = "wsjtx_log.adi"; // TODO allow user to set
ADIF adifile;
auto adifilePath = m_configuration->data_path ().absoluteFilePath (filename);
auto adifilePath = QDir {QStandardPaths::writableLocation (QStandardPaths::DataLocation)}.absoluteFilePath ("wsjtx_log.adi");
adifile.init(adifilePath);
if (!adifile.addQSOToFile(hisCall,hisGrid,mode,rptSent,rptRcvd,date,time,band,comments,name,strDialFreq,m_myCall,m_myGrid,m_txPower))
{
@ -119,7 +118,7 @@ void LogQSO::accept()
}
//Log this QSO to file "wsjtx.log"
QFile f(m_configuration->data_path ().absoluteFilePath ("wsjtx.log"));
static QFile f {QDir {QStandardPaths::writableLocation (QStandardPaths::DataLocation)}.absoluteFilePath ("wsjtx.log")};
if(!f.open(QIODevice::Text | QIODevice::Append)) {
QMessageBox m;
m.setText("Cannot open file \"" + f.fileName () + "\".");
@ -138,13 +137,13 @@ void LogQSO::accept()
}
//Clean up and finish logging
emit(acceptQSO(true));
Q_EMIT acceptQSO(true);
QDialog::accept();
}
void LogQSO::reject()
{
emit(acceptQSO(false));
Q_EMIT acceptQSO(false);
QDialog::reject();
}

View File

@ -15,14 +15,13 @@ namespace Ui {
}
class QSettings;
class Configuration;
class LogQSO : public QDialog
{
Q_OBJECT
public:
explicit LogQSO(QString const& programTitle, QSettings *, Configuration const *, QWidget *parent = 0);
explicit LogQSO(QString const& programTitle, QSettings *, QWidget *parent = 0);
~LogQSO();
void initLogQSO(QString hisCall, QString hisGrid, QString mode,
QString rptSent, QString rptRcvd, QDateTime dateTime,
@ -45,7 +44,6 @@ private:
QScopedPointer<Ui::LogQSO> ui;
QSettings * m_settings;
Configuration const * m_configuration;
QString m_txPower;
QString m_comments;
double m_dialFreq;

View File

@ -5,11 +5,6 @@
#include <locale.h>
#ifdef QT5
#include <QtWidgets>
#else
#include <QtGui>
#endif
#include <QApplication>
#include <QRegularExpression>
#include <QObject>
@ -65,13 +60,11 @@ int main(int argc, char *argv[])
auto help_option = parser.addHelpOption ();
auto version_option = parser.addVersionOption ();
#if WSJT_STANDARD_FILE_LOCATIONS
// support for multiple instances running from a single installation
QCommandLineOption rig_option (QStringList {} << "r" << "rig-name"
, a.translate ("main", "Where <rig-name> is for multi-instance support.")
, a.translate ("main", "rig-name"));
parser.addOption (rig_option);
#endif
QCommandLineOption test_option (QStringList {} << "test-mode"
, a.translate ("main", "Writable files in test location. Use with caution, for testing only."));
@ -98,7 +91,6 @@ int main(int argc, char *argv[])
QStandardPaths::setTestModeEnabled (parser.isSet (test_option));
#if WSJT_STANDARD_FILE_LOCATIONS
// support for multiple instances running from a single installation
if (parser.isSet (rig_option))
{
@ -148,7 +140,6 @@ int main(int argc, char *argv[])
}
}
}
#endif
#endif
auto config_directory = QStandardPaths::writableLocation (QStandardPaths::ConfigLocation);

View File

@ -11,6 +11,7 @@
#include <QRegExp>
#include <QDesktopServices>
#include <QUrl>
#include <QStandardPaths>
#include <QDir>
#include <QDebug>
#include <QtConcurrent/QtConcurrentRun>
@ -74,13 +75,14 @@ private:
MainWindow::MainWindow(bool multiple, QSettings * settings, QSharedMemory *shdmem,
unsigned downSampleFactor, QWidget *parent) :
QMainWindow(parent),
m_dataDir {QStandardPaths::writableLocation (QStandardPaths::DataLocation)},
m_revision {revision ("$Rev$")},
m_multiple {multiple},
m_settings (settings),
ui(new Ui::MainWindow),
m_config (settings, this),
m_wideGraph (new WideGraph (settings)),
m_logDlg (new LogQSO (program_title (), settings, &m_config, this)),
m_logDlg (new LogQSO (program_title (), settings, this)),
m_dialFreq {0},
m_detector (RX_SAMPLE_RATE, NTMAX / 2, 6912 / 2, downSampleFactor),
m_modulator (TX_SAMPLE_RATE, NTMAX / 2),
@ -357,7 +359,7 @@ MainWindow::MainWindow(bool multiple, QSettings * settings, QSharedMemory *shdme
//delete any .quit file that might have been left lying around
//since its presence will cause jt9 to exit a soon as we start it
//and decodes will hang
QFile quitFile (".quit");
QFile quitFile {m_config.temp_dir ().absoluteFilePath (".quit")};
while (quitFile.exists ())
{
if (!quitFile.remove ())
@ -368,19 +370,20 @@ MainWindow::MainWindow(bool multiple, QSettings * settings, QSharedMemory *shdme
}
}
QFile lockFile(".lock"); //Create .lock so jt9 will wait
lockFile.open(QIODevice::ReadWrite);
//Create .lock so jt9 will wait
QFile {m_config.temp_dir ().absoluteFilePath (".lock")}.open(QIODevice::ReadWrite);
QStringList jt9_args {
"-s", QApplication::applicationName ()
, "-w", "1"
, "-e", QDir::toNativeSeparators (m_appDir)
, "-a", QDir::toNativeSeparators (m_config.data_path ().absolutePath ())
, "-a", QDir::toNativeSeparators (m_dataDir.absolutePath ())
, "-t", QDir::toNativeSeparators (m_config.temp_dir ().absolutePath ())
};
proc_jt9.start(QDir::toNativeSeparators (m_appDir) + QDir::separator () +
"jt9", jt9_args, QIODevice::ReadWrite | QIODevice::Unbuffered);
QString fname(QDir::toNativeSeparators(m_config.data_path ().absoluteFilePath ("wsjtx_wisdom.dat")));
QString fname {QDir::toNativeSeparators(m_dataDir.absoluteFilePath ("wsjtx_wisdom.dat"))};
QByteArray cfname=fname.toLocal8Bit();
fftwf_import_wisdom_from_filename(cfname);
@ -439,7 +442,7 @@ MainWindow::MainWindow(bool multiple, QSettings * settings, QSharedMemory *shdme
//--------------------------------------------------- MainWindow destructor
MainWindow::~MainWindow()
{
QString fname(QDir::toNativeSeparators(m_config.data_path ().absoluteFilePath ("wsjtx_wisdom.dat")));
QString fname {QDir::toNativeSeparators(m_dataDir.absoluteFilePath ("wsjtx_wisdom.dat"))};
QByteArray cfname=fname.toLocal8Bit();
fftwf_export_wisdom_to_filename(cfname);
m_audioThread->wait ();
@ -898,7 +901,7 @@ void MainWindow::qsy (Frequency f)
m_repeatMsg=0;
m_secBandChanged=QDateTime::currentMSecsSinceEpoch()/1000;
QFile f2(m_config.data_path ().absoluteFilePath ("ALL.TXT"));
QFile f2 {m_dataDir.absoluteFilePath ("ALL.TXT")};
f2.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append);
QTextStream out(&f2);
out << QDateTime::currentDateTimeUtc().toString("yyyy-MMM-dd hh:mm")
@ -947,7 +950,7 @@ void MainWindow::displayDialFrequency ()
void MainWindow::statusChanged()
{
QFile f("wsjtx_status.txt");
QFile f {m_config.temp_dir ().absoluteFilePath ("wsjtx_status.txt")};
if(f.open(QFile::WriteOnly | QIODevice::Text)) {
QTextStream out(&f);
out << (m_dialFreq / 1.e6) << ";" << m_mode << ";" << m_hisCall << ";"
@ -1010,10 +1013,9 @@ void MainWindow::closeEvent(QCloseEvent * e)
if(m_fname != "") killFile();
m_killAll=true;
mem_jt9->detach();
QFile quitFile(".quit");
QFile quitFile {m_config.temp_dir ().absoluteFilePath (".quit")};
quitFile.open(QIODevice::ReadWrite);
QFile lockFile(".lock");
lockFile.remove(); // Allow jt9 to terminate
QFile {m_config.temp_dir ().absoluteFilePath (".lock")}.remove(); // Allow jt9 to terminate
bool b=proc_jt9.waitForFinished(1000);
if(!b) proc_jt9.kill();
quitFile.remove();
@ -1046,7 +1048,7 @@ void MainWindow::on_actionOnline_User_Guide_triggered() //Display manual
void MainWindow::on_actionLocal_User_Guide_triggered()
{
#if defined (CMAKE_BUILD)
auto file = m_config.doc_path ().absoluteFilePath (PROJECT_MANUAL);
auto file = m_config.doc_dir ().absoluteFilePath (PROJECT_MANUAL);
QDesktopServices::openUrl (QUrl {"file:///" + file});
#endif
}
@ -1060,7 +1062,7 @@ void MainWindow::on_actionAstronomical_data_triggered()
{
if (!m_astroWidget)
{
m_astroWidget.reset (new Astro {m_settings, m_config.data_path ()});
m_astroWidget.reset (new Astro {m_settings});
// hook up termination signal
connect (this, &MainWindow::finished, m_astroWidget.data (), &Astro::close);
@ -1306,8 +1308,7 @@ void MainWindow::decode() //decode()
}
memcpy(to, from, qMin(mem_jt9->size(), size));
QFile lockFile(".lock"); // Allow jt9 to start
lockFile.remove();
QFile {m_config.temp_dir ().absoluteFilePath (".lock")}.remove (); // Allow jt9 to start
decodeBusy(true);
}
@ -1338,8 +1339,7 @@ void MainWindow::readFromStdout() //readFromStdout
if(!keepFile and !m_diskData) killFileTimer->start(45*1000); //Kill in 45 s
jt9com_.nagain=0;
jt9com_.ndiskdat=0;
QFile lockFile(".lock");
lockFile.open(QIODevice::ReadWrite);
QFile {m_config.temp_dir ().absoluteFilePath (".lock")}.open(QIODevice::ReadWrite);
ui->DecodeButton->setChecked (false);
decodeBusy(false);
m_RxLog=0;
@ -1347,7 +1347,7 @@ void MainWindow::readFromStdout() //readFromStdout
m_blankLine=true;
return;
} else {
QFile f(m_config.data_path().absoluteFilePath ("ALL.TXT"));
QFile f {m_dataDir.absoluteFilePath ("ALL.TXT")};
f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append);
QTextStream out(&f);
if(m_RxLog==1) {
@ -1547,7 +1547,7 @@ void MainWindow::guiUpdate()
if(m_tune) t="TUNE";
last_tx_label->setText("Last Tx: " + t);
if(m_restart) {
QFile f(m_config.data_path ().absoluteFilePath ("ALL.TXT"));
QFile f {m_dataDir.absoluteFilePath ("ALL.TXT")};
f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append);
QTextStream out(&f);
out << QDateTime::currentDateTimeUtc().toString("hhmm")
@ -1615,7 +1615,7 @@ void MainWindow::guiUpdate()
if(!m_tune)
{
QFile f(m_config.data_path ().absoluteFilePath ("ALL.TXT"));
QFile f {m_dataDir.absoluteFilePath ("ALL.TXT")};
f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append);
QTextStream out(&f);
out << QDateTime::currentDateTimeUtc().toString("hhmm")
@ -2089,7 +2089,7 @@ void MainWindow::lookup() //lookup()
{
QString hisCall=ui->dxCallEntry->text().toUpper().trimmed();
ui->dxCallEntry->setText(hisCall);
QFile f(m_config.data_path ().absoluteFilePath ("CALL3.TXT"));
QFile f {m_dataDir.absoluteFilePath ("CALL3.TXT")};
if (f.open (QIODevice::ReadOnly | QIODevice::Text))
{
char c[132];
@ -2143,7 +2143,7 @@ void MainWindow::on_addButton_clicked() //Add button
newEntry += ",,,";
// }
QFile f1(m_config.data_path ().absoluteFilePath ("CALL3.TXT"));
QFile f1 {m_dataDir.absoluteFilePath ("CALL3.TXT")};
if(!f1.open(QIODevice::ReadWrite | QIODevice::Text)) {
msgBox("Cannot open \"" + f1.fileName () + "\".");
return;
@ -2154,7 +2154,7 @@ void MainWindow::on_addButton_clicked() //Add button
f1.close();
f1.open(QIODevice::ReadOnly | QIODevice::Text);
}
QFile f2(m_config.data_path ().absoluteFilePath ("CALL3.TMP"));
QFile f2 {m_dataDir.absoluteFilePath ("CALL3.TMP")};
if(!f2.open(QIODevice::WriteOnly | QIODevice::Text)) {
msgBox("Cannot open \"" + f2.fileName () + "\".");
return;
@ -2195,12 +2195,11 @@ void MainWindow::on_addButton_clicked() //Add button
f1.close();
if(hc>hc1 && !m_call3Modified) out << newEntry + "\n";
if(m_call3Modified) {
QDir data_path {m_config.data_path ()};
QFile f0(data_path.absoluteFilePath ("CALL3.OLD"));
QFile f0 {m_dataDir.absoluteFilePath ("CALL3.OLD")};
if(f0.exists()) f0.remove();
QFile f1(data_path.absoluteFilePath ("CALL3.TXT"));
f1.rename(data_path.absoluteFilePath ("CALL3.OLD"));
f2.rename(data_path.absoluteFilePath ("CALL3.TXT"));
QFile f1 {m_dataDir.absoluteFilePath ("CALL3.TXT")};
f1.rename(m_dataDir.absoluteFilePath ("CALL3.OLD"));
f2.rename(m_dataDir.absoluteFilePath ("CALL3.TXT"));
f2.close();
}
}
@ -2500,7 +2499,7 @@ void MainWindow::on_actionErase_ALL_TXT_triggered() //Erase ALL.TXT
"Are you sure you want to erase file ALL.TXT ?",
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if(ret==QMessageBox::Yes) {
QFile f(m_config.data_path ().absoluteFilePath ("ALL.TXT"));
QFile f {m_dataDir.absoluteFilePath ("ALL.TXT")};
f.remove();
m_RxLog=1;
}
@ -2512,14 +2511,14 @@ void MainWindow::on_actionErase_wsjtx_log_adi_triggered()
"Are you sure you want to erase file wsjtx_log.adi ?",
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if(ret==QMessageBox::Yes) {
QFile f(m_config.data_path ().absoluteFilePath ("wsjtx_log.adi"));
QFile f {m_dataDir.absoluteFilePath ("wsjtx_log.adi")};
f.remove();
}
}
void MainWindow::on_actionOpen_log_directory_triggered ()
{
QDesktopServices::openUrl (QUrl::fromLocalFile (m_config.data_path ().absolutePath ()));
QDesktopServices::openUrl (QUrl::fromLocalFile (m_dataDir.absolutePath ()));
}
bool MainWindow::gridOK(QString g)
@ -2589,7 +2588,7 @@ void MainWindow::enable_DXCC_entity (bool on)
if (on)
{
// re-read the log and cty.dat files
m_logBook.init(m_config.data_path ());
m_logBook.init();
}
if (on) // adjust the proportions between the two text displays

View File

@ -12,6 +12,7 @@
#include <QList>
#include <QAudioDeviceInfo>
#include <QScopedPointer>
#include <QDir>
#include "soundin.h"
#include "AudioDevice.hpp"
@ -197,6 +198,7 @@ private:
Q_SIGNAL void outAttenuationChanged (qreal) const;
private:
QDir m_dataDir;
QString m_revision;
bool m_multiple;
QSettings * m_settings;

View File

@ -22,7 +22,6 @@
#cmakedefine01 WSJT_TRACE_CAT
#cmakedefine01 WSJT_TRACE_CAT_POLLS
#cmakedefine01 WSJT_HAMLIB_TRACE
#cmakedefine01 WSJT_STANDARD_FILE_LOCATIONS
#cmakedefine01 WSJT_SOFT_KEYING
#cmakedefine01 WSJT_ENABLE_EXPERIMENTAL_FEATURES
#cmakedefine01 WSJT_INCLUDE_KVASD