Refactor window widget management to fix initialization errors

This commit is contained in:
Bill Somerville 2021-05-17 19:30:51 +01:00
parent a139bb98f5
commit d93b5fc908
No known key found for this signature in database
GPG Key ID: D864B06D1E81618F
10 changed files with 367 additions and 375 deletions

View File

@ -1,16 +1,34 @@
#include "astro.h" #include "astro.h"
#include <QSettings>
#include "ui_astro.h" #include "ui_astro.h"
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
#include <QMessageBox> #include <QMessageBox>
#include <stdio.h> #include <stdio.h>
#include "SettingsGroup.hpp"
#include "commons.h" #include "commons.h"
Astro::Astro(QWidget *parent) : 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, int len1, int len2);
}
Astro::Astro (QString const& settings_filename, QWidget *parent) :
QWidget(parent), QWidget(parent),
ui(new Ui::Astro) ui(new Ui::Astro),
m_settings_filename {settings_filename}
{ {
ui->setupUi(this); ui->setupUi (this);
setWindowTitle ("Astronomical Data");
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint);
QSettings settings {m_settings_filename, QSettings::IniFormat};
SettingsGroup g {&settings, "MainWindow"}; // MainWindow group for
// historical reasons
setGeometry (settings.value ("AstroGeom", QRect {71, 390, 227, 403}).toRect ());
ui->astroTextBrowser->setStyleSheet( ui->astroTextBrowser->setStyleSheet(
"QTextBrowser { background-color : cyan; color : black; }"); "QTextBrowser { background-color : cyan; color : black; }");
ui->astroTextBrowser->clear(); ui->astroTextBrowser->clear();
@ -19,7 +37,10 @@ Astro::Astro(QWidget *parent) :
Astro::~Astro() Astro::~Astro()
{ {
delete ui; QSettings settings {m_settings_filename, QSettings::IniFormat};
SettingsGroup g {&settings, "MainWindow"};
settings.setValue ("AstroGeom", geometry ());
delete ui;
} }
void Astro::astroUpdate(QDateTime t, QString mygrid, QString hisgrid, void Astro::astroUpdate(QDateTime t, QString mygrid, QString hisgrid,

View File

@ -13,24 +13,16 @@ class Astro : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit Astro(QWidget *parent = 0); explicit Astro (QString const& settings_filename, QWidget *parent = 0);
void astroUpdate(QDateTime t, QString mygrid, QString hisgrid, void astroUpdate(QDateTime t, QString mygrid, QString hisgrid,
int fQSO, int nsetftx, int ntxFreq, QString azelDir); int fQSO, int nsetftx, int ntxFreq, QString azelDir);
void setFontSize(int n); void setFontSize(int n);
~Astro(); ~Astro ();
private: private:
Ui::Astro *ui; Ui::Astro *ui;
QString m_AzElDir0; QString m_settings_filename;
QString m_AzElDir0;
}; };
extern "C" { #endif
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, int len1, int len2);
}
#endif // ASTRO_H

View File

@ -1,21 +1,31 @@
#include "bandmap.h" #include "bandmap.h"
#include <QSettings>
#include "ui_bandmap.h" #include "ui_bandmap.h"
#include "qt_helpers.hpp" #include "qt_helpers.hpp"
#include "SettingsGroup.hpp"
#include <QDebug> #include <QDebug>
BandMap::BandMap(QWidget *parent) : BandMap::BandMap (QString const& settings_filename, QWidget * parent)
QWidget(parent), : QWidget {parent},
ui(new Ui::BandMap) ui {new Ui::BandMap},
m_settings_filename {settings_filename}
{ {
ui->setupUi(this); ui->setupUi (this);
setWindowTitle ("Band Map");
setWindowFlags (Qt::Dialog | Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint);
QSettings settings {m_settings_filename, QSettings::IniFormat};
SettingsGroup g {&settings, "MainWindow"}; // MainWindow group for
// historical reasons
setGeometry (settings.value ("BandMapGeom", QRect {280, 400, 142, 400}).toRect ());
ui->bmTextBrowser->setStyleSheet( ui->bmTextBrowser->setStyleSheet(
"QTextBrowser { background-color : #000066; color : red; }"); "QTextBrowser { background-color : #000066; color : red; }");
m_bandMapText="";
ui->bmTextBrowser->clear();
} }
BandMap::~BandMap() BandMap::~BandMap ()
{ {
QSettings settings {m_settings_filename, QSettings::IniFormat};
SettingsGroup g {&settings, "MainWindow"};
settings.setValue ("BandMapGeom", geometry ());
delete ui; delete ui;
} }

View File

@ -9,10 +9,10 @@ namespace Ui {
class BandMap : public QWidget class BandMap : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit BandMap(QWidget *parent = 0); explicit BandMap (QString const& settings_filename, QWidget *parent = 0);
void setText(QString t); void setText(QString t);
void setColors(QString t); void setColors(QString t);
@ -22,13 +22,14 @@ protected:
void resizeEvent(QResizeEvent* event); void resizeEvent(QResizeEvent* event);
private: private:
Ui::BandMap *ui; Ui::BandMap *ui;
QString m_bandMapText; QString m_settings_filename;
QString m_colorBackground; QString m_bandMapText;
QString m_color0; QString m_colorBackground;
QString m_color1; QString m_color0;
QString m_color2; QString m_color1;
QString m_color3; QString m_color2;
QString m_color3;
}; };
#endif // BANDMAP_H #endif

View File

@ -2,7 +2,9 @@
#include "mainwindow.h" #include "mainwindow.h"
#include <fftw3.h> #include <fftw3.h>
#include <QDir> #include <QDir>
#include <QSettings>
#include "revision_utils.hpp" #include "revision_utils.hpp"
#include "SettingsGroup.hpp"
#include "widgets/MessageBox.hpp" #include "widgets/MessageBox.hpp"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include "devsetup.h" #include "devsetup.h"
@ -29,10 +31,6 @@ int iqAmp;
int iqPhase; int iqPhase;
qint16 id[4*60*96000]; qint16 id[4*60*96000];
Astro* g_pAstro = NULL;
WideGraph* g_pWideGraph = NULL;
Messages* g_pMessages = NULL;
BandMap* g_pBandMap = NULL;
TxTune* g_pTxTune = NULL; TxTune* g_pTxTune = NULL;
QSharedMemory mem_m65("mem_m65"); QSharedMemory mem_m65("mem_m65");
@ -42,10 +40,15 @@ extern const int TxDataFrequency = 11025;
//-------------------------------------------------- MainWindow constructor //-------------------------------------------------- MainWindow constructor
MainWindow::MainWindow(QWidget *parent) : MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
ui(new Ui::MainWindow) ui(new Ui::MainWindow),
m_appDir {QApplication::applicationDirPath ()},
m_settings_filename {m_appDir + "/map65.ini"},
m_astro_window {new Astro {m_settings_filename}},
m_band_map_window {new BandMap {m_settings_filename}},
m_messages_window {new Messages {m_settings_filename}},
m_wide_graph_window {new WideGraph {m_settings_filename}}
{ {
ui->setupUi(this); ui->setupUi(this);
on_EraseButton_clicked(); on_EraseButton_clicked();
ui->labUTC->setStyleSheet( \ ui->labUTC->setStyleSheet( \
"QLabel { background-color : black; color : yellow; }"); "QLabel { background-color : black; color : yellow; }");
@ -133,7 +136,6 @@ MainWindow::MainWindow(QWidget *parent) :
m_ntx=1; m_ntx=1;
m_myCall="K1JT"; m_myCall="K1JT";
m_myGrid="FN20qi"; m_myGrid="FN20qi";
m_appDir = QApplication::applicationDirPath();
m_saveDir="/users/joe/map65/install/save"; m_saveDir="/users/joe/map65/install/save";
m_azelDir="/users/joe/map65/install/"; m_azelDir="/users/joe/map65/install/";
m_editorCommand="notepad"; m_editorCommand="notepad";
@ -224,9 +226,9 @@ MainWindow::MainWindow(QWidget *parent) :
on_actionWide_Waterfall_triggered(); on_actionWide_Waterfall_triggered();
on_actionMessages_triggered(); on_actionMessages_triggered();
on_actionBand_Map_triggered(); on_actionBand_Map_triggered();
g_pMessages->setColors(m_colors); if (m_messages_window) m_messages_window->setColors(m_colors);
g_pBandMap->setColors(m_colors); m_band_map_window->setColors(m_colors);
g_pAstro->setFontSize(m_astroFont); if (m_astro_window) m_astro_window->setFontSize (m_astroFont);
if(m_modeQ65==0) on_actionNoQ65_triggered(); if(m_modeQ65==0) on_actionNoQ65_triggered();
if(m_modeQ65==1) on_actionQ65A_triggered(); if(m_modeQ65==1) on_actionQ65A_triggered();
@ -266,15 +268,15 @@ MainWindow::MainWindow(QWidget *parent) :
soundInThread.setMonitoring(m_monitoring); soundInThread.setMonitoring(m_monitoring);
m_diskData=false; m_diskData=false;
m_tol=500; m_tol=500;
g_pWideGraph->setTol(m_tol); m_wide_graph_window->setTol(m_tol);
g_pWideGraph->setFcal(m_fCal); m_wide_graph_window->setFcal(m_fCal);
if(m_fs96000) g_pWideGraph->setFsample(96000); if(m_fs96000) m_wide_graph_window->setFsample(96000);
if(!m_fs96000) g_pWideGraph->setFsample(95238); if(!m_fs96000) m_wide_graph_window->setFsample(95238);
g_pWideGraph->m_mult570=m_mult570; m_wide_graph_window->m_mult570=m_mult570;
g_pWideGraph->m_mult570Tx=m_mult570Tx; m_wide_graph_window->m_mult570Tx=m_mult570Tx;
g_pWideGraph->m_cal570=m_cal570; m_wide_graph_window->m_cal570=m_cal570;
g_pWideGraph->m_TxOffset=m_TxOffset; m_wide_graph_window->m_TxOffset=m_TxOffset;
if(m_initIQplus) g_pWideGraph->initIQplus(); if(m_initIQplus) m_wide_graph_window->initIQplus();
// Create "m_worked", a dictionary of all calls in wsjt.log // Create "m_worked", a dictionary of all calls in wsjt.log
QFile f("wsjt.log"); QFile f("wsjt.log");
@ -297,6 +299,10 @@ MainWindow::MainWindow(QWidget *parent) :
if(ui->actionAFMHot->isChecked()) on_actionAFMHot_triggered(); if(ui->actionAFMHot->isChecked()) on_actionAFMHot_triggered();
if(ui->actionBlue->isChecked()) on_actionBlue_triggered(); if(ui->actionBlue->isChecked()) on_actionBlue_triggered();
connect (m_messages_window, &Messages::click2OnCallsign, this, &MainWindow::doubleClickOnMessages);
connect (m_wide_graph_window, &WideGraph::freezeDecode2, this, &MainWindow::freezeDecode);
connect (m_wide_graph_window, &WideGraph::f11f12, this, &MainWindow::bumpDF);
// only start the guiUpdate timer after this constructor has finished // only start the guiUpdate timer after this constructor has finished
QTimer::singleShot (0, [=] { QTimer::singleShot (0, [=] {
guiTimer->start(100); //Don't change the 100 ms! guiTimer->start(100); //Don't change the 100 ms!
@ -327,36 +333,17 @@ MainWindow::~MainWindow()
//-------------------------------------------------------- writeSettings() //-------------------------------------------------------- writeSettings()
void MainWindow::writeSettings() void MainWindow::writeSettings()
{ {
QString inifile = m_appDir + "/map65.ini"; QSettings settings(m_settings_filename, QSettings::IniFormat);
QSettings settings(inifile, QSettings::IniFormat); {
SettingsGroup g {&settings, "MainWindow"};
settings.beginGroup("MainWindow"); settings.setValue("geometry", saveGeometry());
settings.setValue("geometry", saveGeometry()); settings.setValue("MRUdir", m_path);
settings.setValue("MRUdir", m_path); settings.setValue("TxFirst",m_txFirst);
settings.setValue("TxFirst",m_txFirst); settings.setValue("DXcall",ui->dxCallEntry->text());
settings.setValue("DXcall",ui->dxCallEntry->text()); settings.setValue("DXgrid",ui->dxGridEntry->text());
settings.setValue("DXgrid",ui->dxGridEntry->text());
if(g_pAstro->isVisible()) {
m_astroGeom = g_pAstro->geometry();
settings.setValue("AstroGeom",m_astroGeom);
} }
if(g_pWideGraph->isVisible()) { SettingsGroup g {&settings, "Common"};
m_wideGraphGeom = g_pWideGraph->geometry();
settings.setValue("WideGraphGeom",m_wideGraphGeom);
}
if(g_pMessages->isVisible()) {
m_messagesGeom = g_pMessages->geometry();
settings.setValue("MessagesGeom",m_messagesGeom);
}
if(g_pBandMap->isVisible()) {
m_bandMapGeom = g_pBandMap->geometry();
settings.setValue("BandMapGeom",m_bandMapGeom);
}
settings.endGroup();
settings.beginGroup("Common");
settings.setValue("MyCall",m_myCall); settings.setValue("MyCall",m_myCall);
settings.setValue("MyGrid",m_myGrid); settings.setValue("MyGrid",m_myGrid);
settings.setValue("IDint",m_idInt); settings.setValue("IDint",m_idInt);
@ -411,33 +398,23 @@ void MainWindow::writeSettings()
settings.setValue("Cal570",m_cal570); settings.setValue("Cal570",m_cal570);
settings.setValue("TxOffset",m_TxOffset); settings.setValue("TxOffset",m_TxOffset);
settings.setValue("Colors",m_colors); settings.setValue("Colors",m_colors);
settings.endGroup();
} }
//---------------------------------------------------------- readSettings() //---------------------------------------------------------- readSettings()
void MainWindow::readSettings() void MainWindow::readSettings()
{ {
QString inifile = m_appDir + "/map65.ini"; QSettings settings(m_settings_filename, QSettings::IniFormat);
QSettings settings(inifile, QSettings::IniFormat); {
settings.beginGroup("MainWindow"); SettingsGroup g {&settings, "MainWindow"};
restoreGeometry(settings.value("geometry").toByteArray()); restoreGeometry(settings.value("geometry").toByteArray());
ui->dxCallEntry->setText(settings.value("DXcall","").toString()); ui->dxCallEntry->setText(settings.value("DXcall","").toString());
ui->dxGridEntry->setText(settings.value("DXgrid","").toString()); ui->dxGridEntry->setText(settings.value("DXgrid","").toString());
m_path = settings.value("MRUdir", m_appDir + "/save").toString();
m_txFirst = settings.value("TxFirst",false).toBool();
ui->txFirstCheckBox->setChecked(m_txFirst);
}
m_astroGeom = settings.value("AstroGeom", QRect(71,390,227,403)).toRect(); SettingsGroup g {&settings, "Common"};
m_wideGraphGeom = settings.value("WideGraphGeom", \
QRect(45,30,1023,340)).toRect();
m_messagesGeom = settings.value("MessagesGeom", \
QRect(800,400,381,400)).toRect();
m_bandMapGeom = settings.value("BandMapGeom", \
QRect(280,400,142,400)).toRect();
m_path = settings.value("MRUdir", m_appDir + "/save").toString();
m_txFirst = settings.value("TxFirst",false).toBool();
ui->txFirstCheckBox->setChecked(m_txFirst);
settings.endGroup();
settings.beginGroup("Common");
m_myCall=settings.value("MyCall","").toString(); m_myCall=settings.value("MyCall","").toString();
m_myGrid=settings.value("MyGrid","").toString(); m_myGrid=settings.value("MyGrid","").toString();
m_idInt=settings.value("IDint",0).toInt(); m_idInt=settings.value("IDint",0).toInt();
@ -517,7 +494,6 @@ void MainWindow::readSettings()
m_cal570=settings.value("Cal570",0.0).toDouble(); m_cal570=settings.value("Cal570",0.0).toDouble();
m_TxOffset=settings.value("TxOffset",130.9).toDouble(); m_TxOffset=settings.value("TxOffset",130.9).toDouble();
m_colors=settings.value("Colors","000066ff0000ffff00969696646464").toString(); m_colors=settings.value("Colors","000066ff0000ffff00969696646464").toString();
settings.endGroup();
if(!ui->actionLinrad->isChecked() && !ui->actionCuteSDR->isChecked() && if(!ui->actionLinrad->isChecked() && !ui->actionCuteSDR->isChecked() &&
!ui->actionAFMHot->isChecked() && !ui->actionBlue->isChecked()) { !ui->actionAFMHot->isChecked() && !ui->actionBlue->isChecked()) {
@ -565,7 +541,7 @@ void MainWindow::dataSink(int k)
if(!m_fs96000) nfsample=95238; if(!m_fs96000) nfsample=95238;
nxpol=0; nxpol=0;
if(m_xpol) nxpol=1; if(m_xpol) nxpol=1;
fgreen=(float)g_pWideGraph->fGreen(); fgreen=m_wide_graph_window->fGreen();
nadj++; nadj++;
if(m_adjustIQ==0) nadj=0; if(m_adjustIQ==0) nadj=0;
symspec_(&k, &nxpol, &ndiskdat, &nb, &m_NBslider, &m_dPhi, symspec_(&k, &nxpol, &ndiskdat, &nb, &m_NBslider, &m_dPhi,
@ -591,7 +567,7 @@ void MainWindow::dataSink(int k)
xSignalMeter->setValue(px); // Update the signal meters xSignalMeter->setValue(px); // Update the signal meters
ySignalMeter->setValue(py); ySignalMeter->setValue(py);
if(m_monitoring || m_diskData) { if(m_monitoring || m_diskData) {
g_pWideGraph->dataSink2(s,nkhz,ihsym,m_diskData,lstrong); m_wide_graph_window->dataSink2(s,nkhz,ihsym,m_diskData,lstrong);
} }
if(nadj == 10) { if(nadj == 10) {
@ -705,7 +681,7 @@ void MainWindow::on_actionDeviceSetup_triggered() //Setup Dialog
m_idInt=dlg.m_idInt; m_idInt=dlg.m_idInt;
m_pttPort=dlg.m_pttPort; m_pttPort=dlg.m_pttPort;
m_astroFont=dlg.m_astroFont; m_astroFont=dlg.m_astroFont;
if(g_pAstro->isVisible()) g_pAstro->setFontSize(m_astroFont); if(m_astro_window && m_astro_window->isVisible()) m_astro_window->setFontSize(m_astroFont);
m_xpol=dlg.m_xpol; m_xpol=dlg.m_xpol;
ui->actionFind_Delta_Phi->setEnabled(m_xpol); ui->actionFind_Delta_Phi->setEnabled(m_xpol);
m_xpolx=dlg.m_xpolx; m_xpolx=dlg.m_xpolx;
@ -717,7 +693,7 @@ void MainWindow::on_actionDeviceSetup_triggered() //Setup Dialog
m_dPhi=dlg.m_dPhi; m_dPhi=dlg.m_dPhi;
m_fCal=dlg.m_fCal; m_fCal=dlg.m_fCal;
m_fAdd=dlg.m_fAdd; m_fAdd=dlg.m_fAdd;
g_pWideGraph->setFcal(m_fCal); m_wide_graph_window->setFcal(m_fCal);
m_fs96000=dlg.m_fs96000; m_fs96000=dlg.m_fs96000;
m_network=dlg.m_network; m_network=dlg.m_network;
m_nDevIn=dlg.m_nDevIn; m_nDevIn=dlg.m_nDevIn;
@ -730,14 +706,14 @@ void MainWindow::on_actionDeviceSetup_triggered() //Setup Dialog
m_initIQplus=dlg.m_initIQplus; m_initIQplus=dlg.m_initIQplus;
m_bIQxt=dlg.m_bIQxt; m_bIQxt=dlg.m_bIQxt;
m_colors=dlg.m_colors; m_colors=dlg.m_colors;
g_pMessages->setColors(m_colors); m_messages_window->setColors(m_colors);
g_pBandMap->setColors(m_colors); m_band_map_window->setColors(m_colors);
m_cal570=dlg.m_cal570; m_cal570=dlg.m_cal570;
m_TxOffset=dlg.m_TxOffset; m_TxOffset=dlg.m_TxOffset;
m_mult570Tx=dlg.m_mult570Tx; m_mult570Tx=dlg.m_mult570Tx;
g_pWideGraph->m_mult570=m_mult570; m_wide_graph_window->m_mult570=m_mult570;
g_pWideGraph->m_mult570Tx=m_mult570Tx; m_wide_graph_window->m_mult570Tx=m_mult570Tx;
g_pWideGraph->m_cal570=m_cal570; m_wide_graph_window->m_cal570=m_cal570;
soundInThread.setSwapIQ(m_IQswap); soundInThread.setSwapIQ(m_IQswap);
soundInThread.set10db(m_10db); soundInThread.set10db(m_10db);
@ -771,22 +747,22 @@ void MainWindow::on_monitorButton_clicked() //Monitor
} }
void MainWindow::on_actionLinrad_triggered() //Linrad palette void MainWindow::on_actionLinrad_triggered() //Linrad palette
{ {
if(g_pWideGraph != NULL) g_pWideGraph->setPalette("Linrad"); if(m_wide_graph_window) m_wide_graph_window->setPalette("Linrad");
} }
void MainWindow::on_actionCuteSDR_triggered() //CuteSDR palette void MainWindow::on_actionCuteSDR_triggered() //CuteSDR palette
{ {
if(g_pWideGraph != NULL) g_pWideGraph->setPalette("CuteSDR"); if(m_wide_graph_window) m_wide_graph_window->setPalette("CuteSDR");
} }
void MainWindow::on_actionAFMHot_triggered() void MainWindow::on_actionAFMHot_triggered()
{ {
if(g_pWideGraph != NULL) g_pWideGraph->setPalette("AFMHot"); if(m_wide_graph_window) m_wide_graph_window->setPalette("AFMHot");
} }
void MainWindow::on_actionBlue_triggered() void MainWindow::on_actionBlue_triggered()
{ {
if(g_pWideGraph != NULL) g_pWideGraph->setPalette("Blue"); if(m_wide_graph_window) m_wide_graph_window->setPalette("Blue");
} }
void MainWindow::on_actionAbout_triggered() //Display "About" void MainWindow::on_actionAbout_triggered() //Display "About"
@ -838,19 +814,19 @@ void MainWindow::keyPressEvent( QKeyEvent *e ) //keyPressEvent
case Qt::Key_F11: case Qt::Key_F11:
if(e->modifiers() & Qt::ShiftModifier) { if(e->modifiers() & Qt::ShiftModifier) {
} else { } else {
int n0=g_pWideGraph->DF(); int n0=m_wide_graph_window->DF();
int n=(n0 + 10000) % 5; int n=(n0 + 10000) % 5;
if(n==0) n=5; if(n==0) n=5;
g_pWideGraph->setDF(n0-n); m_wide_graph_window->setDF(n0-n);
} }
break; break;
case Qt::Key_F12: case Qt::Key_F12:
if(e->modifiers() & Qt::ShiftModifier) { if(e->modifiers() & Qt::ShiftModifier) {
} else { } else {
int n0=g_pWideGraph->DF(); int n0=m_wide_graph_window->DF();
int n=(n0 + 10000) % 5; int n=(n0 + 10000) % 5;
if(n==0) n=5; if(n==0) n=5;
g_pWideGraph->setDF(n0+n); m_wide_graph_window->setDF(n0+n);
} }
break; break;
case Qt::Key_G: case Qt::Key_G:
@ -870,16 +846,16 @@ void MainWindow::keyPressEvent( QKeyEvent *e ) //keyPressEvent
void MainWindow::bumpDF(int n) //bumpDF() void MainWindow::bumpDF(int n) //bumpDF()
{ {
if(n==11) { if(n==11) {
int n0=g_pWideGraph->DF(); int n0=m_wide_graph_window->DF();
int n=(n0 + 10000) % 5; int n=(n0 + 10000) % 5;
if(n==0) n=5; if(n==0) n=5;
g_pWideGraph->setDF(n0-n); m_wide_graph_window->setDF(n0-n);
} }
if(n==12) { if(n==12) {
int n0=g_pWideGraph->DF(); int n0=m_wide_graph_window->DF();
int n=(n0 + 10000) % 5; int n=(n0 + 10000) % 5;
if(n==0) n=5; if(n==0) n=5;
g_pWideGraph->setDF(n0+n); m_wide_graph_window->setDF(n0+n);
} }
} }
@ -944,7 +920,7 @@ void MainWindow::on_tolSpinBox_valueChanged(int i) //tolSpinBox
{ {
static int ntol[] = {10,20,50,100,200,500,1000}; static int ntol[] = {10,20,50,100,200,500,1000};
m_tol=ntol[i]; m_tol=ntol[i];
g_pWideGraph->setTol(m_tol); m_wide_graph_window->setTol(m_tol);
ui->labTol1->setText(QString::number(ntol[i])); ui->labTol1->setText(QString::number(ntol[i]));
} }
@ -960,9 +936,11 @@ void MainWindow::closeEvent(QCloseEvent*)
void MainWindow::OnExit() void MainWindow::OnExit()
{ {
g_pWideGraph->saveSettings(); m_wide_graph_window->saveSettings();
m_killAll=true; m_killAll=true;
mem_m65.detach(); mem_m65.detach();
proc_m65.closeReadChannel (QProcess::StandardOutput);
proc_m65.closeReadChannel (QProcess::StandardError);
QFile quitFile(m_appDir + "/.quit"); QFile quitFile(m_appDir + "/.quit");
quitFile.open(QIODevice::ReadWrite); quitFile.open(QIODevice::ReadWrite);
QFile lockFile(m_appDir + "/.lock"); QFile lockFile(m_appDir + "/.lock");
@ -1010,60 +988,22 @@ void MainWindow::on_actionQSG_MAP65_v3_triggered()
void MainWindow::on_actionAstro_Data_triggered() //Display Astro void MainWindow::on_actionAstro_Data_triggered() //Display Astro
{ {
if(g_pAstro==NULL) { if (m_astro_window ) m_astro_window->show();
g_pAstro = new Astro(0);
g_pAstro->setWindowTitle("Astronomical Data");
Qt::WindowFlags flags = Qt::Dialog | Qt::WindowCloseButtonHint |
Qt::WindowMinimizeButtonHint;
g_pAstro->setWindowFlags(flags);
g_pAstro->setGeometry(m_astroGeom);
}
g_pAstro->show();
} }
void MainWindow::on_actionWide_Waterfall_triggered() //Display Waterfalls void MainWindow::on_actionWide_Waterfall_triggered() //Display Waterfalls
{ {
if(g_pWideGraph==NULL) { m_wide_graph_window->show();
g_pWideGraph = new WideGraph(0);
g_pWideGraph->setWindowTitle("Wide Graph");
g_pWideGraph->setGeometry(m_wideGraphGeom);
Qt::WindowFlags flags = Qt::WindowCloseButtonHint |
Qt::WindowMinimizeButtonHint;
g_pWideGraph->setWindowFlags(flags);
connect(g_pWideGraph, SIGNAL(freezeDecode2(int)),this,
SLOT(freezeDecode(int)));
connect(g_pWideGraph, SIGNAL(f11f12(int)),this,
SLOT(bumpDF(int)));
}
g_pWideGraph->show();
} }
void MainWindow::on_actionBand_Map_triggered() //Display BandMap void MainWindow::on_actionBand_Map_triggered() //Display BandMap
{ {
if(g_pBandMap==NULL) { m_band_map_window->show ();
g_pBandMap = new BandMap(0);
g_pBandMap->setWindowTitle("Band Map");
Qt::WindowFlags flags = Qt::Dialog | Qt::WindowCloseButtonHint |
Qt::WindowMinimizeButtonHint;
g_pBandMap->setWindowFlags(flags);
g_pBandMap->setGeometry(m_bandMapGeom);
}
g_pBandMap->show();
} }
void MainWindow::on_actionMessages_triggered() //Display Messages void MainWindow::on_actionMessages_triggered() //Display Messages
{ {
if(g_pMessages==NULL) { m_messages_window->show();
g_pMessages = new Messages(0);
g_pMessages->setWindowTitle("Messages");
Qt::WindowFlags flags = Qt::Dialog | Qt::WindowCloseButtonHint |
Qt::WindowMinimizeButtonHint;
g_pMessages->setWindowFlags(flags);
g_pMessages->setGeometry(m_messagesGeom);
connect(g_pMessages, SIGNAL(click2OnCallsign(QString, QString)),this,
SLOT(doubleClickOnMessages(QString, QString)));
}
g_pMessages->show();
} }
void MainWindow::on_actionOpen_triggered() //Open File void MainWindow::on_actionOpen_triggered() //Open File
@ -1181,8 +1121,8 @@ void MainWindow::on_actionDelete_all_tf2_files_in_SaveDir_triggered()
//Clear BandMap and Messages windows //Clear BandMap and Messages windows
void MainWindow::on_actionErase_Band_Map_and_Messages_triggered() void MainWindow::on_actionErase_Band_Map_and_Messages_triggered()
{ {
g_pBandMap->setText(""); m_band_map_window->setText("");
g_pMessages->setText("",""); m_messages_window->setText("","");
m_map65RxLog |= 4; m_map65RxLog |= 4;
} }
@ -1289,18 +1229,18 @@ void MainWindow::decode() //decode()
} }
datcom_.idphi=m_dPhi; datcom_.idphi=m_dPhi;
datcom_.mousedf=g_pWideGraph->DF(); datcom_.mousedf=m_wide_graph_window->DF();
datcom_.mousefqso=g_pWideGraph->QSOfreq(); datcom_.mousefqso=m_wide_graph_window->QSOfreq();
datcom_.ndepth=m_ndepth; datcom_.ndepth=m_ndepth;
datcom_.ndiskdat=0; datcom_.ndiskdat=0;
if(m_diskData) datcom_.ndiskdat=1; if(m_diskData) datcom_.ndiskdat=1;
datcom_.neme=0; datcom_.neme=0;
if(ui->actionOnly_EME_calls->isChecked()) datcom_.neme=1; if(ui->actionOnly_EME_calls->isChecked()) datcom_.neme=1;
int ispan=int(g_pWideGraph->fSpan()); int ispan=int(m_wide_graph_window->fSpan());
if(ispan%2 == 1) ispan++; if(ispan%2 == 1) ispan++;
int ifc=int(1000.0*(datcom_.fcenter - int(datcom_.fcenter))+0.5); int ifc=int(1000.0*(datcom_.fcenter - int(datcom_.fcenter))+0.5);
int nfa=g_pWideGraph->nStartFreq(); int nfa=m_wide_graph_window->nStartFreq();
int nfb=nfa+ispan; int nfb=nfa+ispan;
int nfshift=nfa + ispan/2 - ifc; int nfshift=nfa + ispan/2 - ifc;
@ -1404,12 +1344,12 @@ void MainWindow::readFromStdout() //readFromStdout
m_nsum=t.mid(17,4).toInt(); m_nsum=t.mid(17,4).toInt();
m_nsave=t.mid(21,4).toInt(); m_nsave=t.mid(21,4).toInt();
lab7->setText (QString {"Avg: %1"}.arg (m_nsum)); lab7->setText (QString {"Avg: %1"}.arg (m_nsum));
if(m_modeQ65>0) g_pWideGraph->setDecodeFinished(); if(m_modeQ65>0) m_wide_graph_window->setDecodeFinished();
} }
if(t.indexOf("<DecodeFinished>") >= 0) { if(t.indexOf("<DecodeFinished>") >= 0) {
if(m_widebandDecode) { if(m_widebandDecode) {
g_pMessages->setText(m_messagesText,m_bandmapText); m_messages_window->setText(m_messagesText,m_bandmapText);
g_pBandMap->setText(m_bandmapText); m_band_map_window->setText(m_bandmapText);
m_widebandDecode=false; m_widebandDecode=false;
} }
QFile lockFile(m_appDir + "/.lock"); QFile lockFile(m_appDir + "/.lock");
@ -1527,7 +1467,7 @@ void MainWindow::guiUpdate()
msgBox(s); msgBox(s);
} }
if(m_bIQxt) g_pWideGraph->tx570(); // Set Si570 to Tx Freq if(m_bIQxt) m_wide_graph_window->tx570(); // Set Si570 to Tx Freq
if(!soundOutThread.isRunning()) { if(!soundOutThread.isRunning()) {
soundOutThread.start(QThread::HighPriority); soundOutThread.start(QThread::HighPriority);
@ -1593,7 +1533,7 @@ void MainWindow::guiUpdate()
soundInThread.setMonitoring(false); soundInThread.setMonitoring(false);
btxok=true; btxok=true;
m_transmitting=true; m_transmitting=true;
g_pWideGraph->enableSetRxHardware(false); m_wide_graph_window->enableSetRxHardware(false);
QFile f("map65_tx.log"); QFile f("map65_tx.log");
f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append); f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append);
@ -1614,14 +1554,14 @@ void MainWindow::guiUpdate()
btxok0=btxok; btxok0=btxok;
if(nc0 <= 0) nc0++; if(nc0 <= 0) nc0++;
if(nc0 == 0) { if(nc0 == 0) {
if(m_bIQxt) g_pWideGraph->rx570(); // Set Si570 back to Rx Freq if(m_bIQxt) m_wide_graph_window->rx570(); // Set Si570 back to Rx Freq
int itx=0; int itx=0;
ptt_(&m_pttPort,&itx,&iptt); // Lower PTT ptt_(&m_pttPort,&itx,&iptt); // Lower PTT
if(!m_txMute) { if(!m_txMute) {
soundOutThread.quitExecution=true;\ soundOutThread.quitExecution=true;\
} }
m_transmitting=false; m_transmitting=false;
g_pWideGraph->enableSetRxHardware(true); m_wide_graph_window->enableSetRxHardware(true);
if(m_auto) { if(m_auto) {
m_monitoring=true; m_monitoring=true;
soundInThread.setMonitoring(m_monitoring); soundInThread.setMonitoring(m_monitoring);
@ -1639,10 +1579,10 @@ void MainWindow::guiUpdate()
ui->monitorButton->setStyleSheet(""); ui->monitorButton->setStyleSheet("");
} }
lab2->setText("QSO Freq: " + QString::number(g_pWideGraph->QSOfreq())); lab2->setText("QSO Freq: " + QString::number(m_wide_graph_window->QSOfreq()));
lab3->setText("QSO DF: " + QString::number(g_pWideGraph->DF())); lab3->setText("QSO DF: " + QString::number(m_wide_graph_window->DF()));
g_pWideGraph->updateFreqLabel(); m_wide_graph_window->updateFreqLabel();
if(m_startAnother) { if(m_startAnother) {
m_startAnother=false; m_startAnother=false;
@ -1653,8 +1593,8 @@ void MainWindow::guiUpdate()
if(nsec != m_sec0) { //Once per second if(nsec != m_sec0) { //Once per second
// qDebug() << "A" << nsec%60 << m_mode65 << m_modeQ65 << m_modeTx; // qDebug() << "A" << nsec%60 << m_mode65 << m_modeQ65 << m_modeTx;
soundInThread.setForceCenterFreqMHz(g_pWideGraph->m_dForceCenterFreq); soundInThread.setForceCenterFreqMHz(m_wide_graph_window->m_dForceCenterFreq);
soundInThread.setForceCenterFreqBool(g_pWideGraph->m_bForceCenterFreq); soundInThread.setForceCenterFreqBool(m_wide_graph_window->m_bForceCenterFreq);
if(m_pctZap>30.0 and !m_transmitting) { if(m_pctZap>30.0 and !m_transmitting) {
lab4->setStyleSheet("QLabel{background-color: #ff0000}"); lab4->setStyleSheet("QLabel{background-color: #ff0000}");
@ -1700,8 +1640,8 @@ void MainWindow::guiUpdate()
} }
QDateTime t = QDateTime::currentDateTimeUtc(); QDateTime t = QDateTime::currentDateTimeUtc();
int fQSO=g_pWideGraph->QSOfreq(); int fQSO=m_wide_graph_window->QSOfreq();
g_pAstro->astroUpdate(t, m_myGrid, m_hisGrid, fQSO, m_setftx, m_astro_window->astroUpdate(t, m_myGrid, m_hisGrid, fQSO, m_setftx,
m_txFreq, m_azelDir); m_txFreq, m_azelDir);
m_setftx=0; m_setftx=0;
QString utc = t.date().toString(" yyyy MMM dd \n") + t.time().toString(); QString utc = t.date().toString(" yyyy MMM dd \n") + t.time().toString();
@ -2087,7 +2027,7 @@ void MainWindow::on_tx6_editingFinished() //tx6 edited
void MainWindow::on_setTxFreqButton_clicked() //Set Tx Freq void MainWindow::on_setTxFreqButton_clicked() //Set Tx Freq
{ {
m_setftx=1; m_setftx=1;
m_txFreq=g_pWideGraph->QSOfreq(); m_txFreq=m_wide_graph_window->QSOfreq();
} }
void MainWindow::on_dxCallEntry_textChanged(const QString &t) //dxCall changed void MainWindow::on_dxCallEntry_textChanged(const QString &t) //dxCall changed
@ -2164,8 +2104,8 @@ void MainWindow::on_actionNoJT65_triggered()
m_TRperiod=60; m_TRperiod=60;
soundInThread.setPeriod(m_TRperiod); soundInThread.setPeriod(m_TRperiod);
soundOutThread.setPeriod(m_TRperiod); soundOutThread.setPeriod(m_TRperiod);
g_pWideGraph->setMode65(m_mode65); m_wide_graph_window->setMode65(m_mode65);
g_pWideGraph->setPeriod(m_TRperiod); m_wide_graph_window->setPeriod(m_TRperiod);
lab5->setStyleSheet(""); lab5->setStyleSheet("");
lab5->setText(""); lab5->setText("");
} }
@ -2178,8 +2118,8 @@ void MainWindow::on_actionJT65A_triggered()
m_TRperiod=60; m_TRperiod=60;
soundInThread.setPeriod(m_TRperiod); soundInThread.setPeriod(m_TRperiod);
soundOutThread.setPeriod(m_TRperiod); soundOutThread.setPeriod(m_TRperiod);
g_pWideGraph->setMode65(m_mode65); m_wide_graph_window->setMode65(m_mode65);
g_pWideGraph->setPeriod(m_TRperiod); m_wide_graph_window->setPeriod(m_TRperiod);
lab5->setStyleSheet("QLabel{background-color: #ff6666}"); lab5->setStyleSheet("QLabel{background-color: #ff6666}");
lab5->setText("JT65A"); lab5->setText("JT65A");
ui->actionJT65A->setChecked(true); ui->actionJT65A->setChecked(true);
@ -2194,8 +2134,8 @@ void MainWindow::on_actionJT65B_triggered()
m_TRperiod=60; m_TRperiod=60;
soundInThread.setPeriod(m_TRperiod); soundInThread.setPeriod(m_TRperiod);
soundOutThread.setPeriod(m_TRperiod); soundOutThread.setPeriod(m_TRperiod);
g_pWideGraph->setMode65(m_mode65); m_wide_graph_window->setMode65(m_mode65);
g_pWideGraph->setPeriod(m_TRperiod); m_wide_graph_window->setPeriod(m_TRperiod);
lab5->setStyleSheet("QLabel{background-color: #ffff66}"); lab5->setStyleSheet("QLabel{background-color: #ffff66}");
lab5->setText("JT65B"); lab5->setText("JT65B");
ui->actionJT65B->setChecked(true); ui->actionJT65B->setChecked(true);
@ -2209,8 +2149,8 @@ void MainWindow::on_actionJT65C_triggered()
m_TRperiod=60; m_TRperiod=60;
soundInThread.setPeriod(m_TRperiod); soundInThread.setPeriod(m_TRperiod);
soundOutThread.setPeriod(m_TRperiod); soundOutThread.setPeriod(m_TRperiod);
g_pWideGraph->setMode65(m_mode65); m_wide_graph_window->setMode65(m_mode65);
g_pWideGraph->setPeriod(m_TRperiod); m_wide_graph_window->setPeriod(m_TRperiod);
lab5->setStyleSheet("QLabel{background-color: #66ffb2}"); lab5->setStyleSheet("QLabel{background-color: #66ffb2}");
lab5->setText("JT65C"); lab5->setText("JT65C");
ui->actionJT65C->setChecked(true); ui->actionJT65C->setChecked(true);

View File

@ -2,6 +2,7 @@
#define MAINWINDOW_H #define MAINWINDOW_H
#include <QtGui> #include <QtGui>
#include <QtWidgets> #include <QtWidgets>
#include <QPointer>
#include <QLabel> #include <QLabel>
#include <QTimer> #include <QTimer>
#include <QDateTime> #include <QDateTime>
@ -20,9 +21,14 @@
//--------------------------------------------------------------- MainWindow //--------------------------------------------------------------- MainWindow
namespace Ui { namespace Ui {
class MainWindow; class MainWindow;
} }
class Astro;
class BandMap;
class Messages;
class WideGraph;
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
@ -139,147 +145,149 @@ private slots:
void on_pbTxMode_clicked(); void on_pbTxMode_clicked();
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
qint64 m_msErase; QString m_appDir;
qint32 m_nDevIn; QString m_settings_filename;
qint32 m_nDevOut; QPointer<Astro> m_astro_window;
qint32 m_idInt; QPointer<BandMap> m_band_map_window;
qint32 m_waterfallAvg; QPointer<Messages> m_messages_window;
qint32 m_DF; QPointer<WideGraph> m_wide_graph_window;
qint32 m_tol; qint64 m_msErase;
qint32 m_QSOfreq0; qint32 m_nDevIn;
qint32 m_ntx; qint32 m_nDevOut;
qint32 m_pttPort; qint32 m_idInt;
qint32 m_astroFont; qint32 m_waterfallAvg;
qint32 m_timeout; qint32 m_DF;
qint32 m_dPhi; qint32 m_tol;
qint32 m_fCal; qint32 m_QSOfreq0;
qint32 m_txFreq; qint32 m_ntx;
qint32 m_setftx; qint32 m_pttPort;
qint32 m_ndepth; qint32 m_astroFont;
qint32 m_sec0; qint32 m_timeout;
qint32 m_map65RxLog; qint32 m_dPhi;
qint32 m_nutc0; qint32 m_fCal;
qint32 m_mode65; qint32 m_txFreq;
qint32 m_nrx; qint32 m_setftx;
qint32 m_hsym0; qint32 m_ndepth;
qint32 m_paInDevice; qint32 m_sec0;
qint32 m_paOutDevice; qint32 m_map65RxLog;
qint32 m_udpPort; qint32 m_nutc0;
qint32 m_NBslider; qint32 m_mode65;
qint32 m_adjustIQ; qint32 m_nrx;
qint32 m_applyIQcal; qint32 m_hsym0;
qint32 m_mult570; qint32 m_paInDevice;
qint32 m_mult570Tx; qint32 m_paOutDevice;
qint32 m_nsum; qint32 m_udpPort;
qint32 m_nsave; qint32 m_NBslider;
qint32 m_TRperiod; qint32 m_adjustIQ;
qint32 m_modeJT65; qint32 m_applyIQcal;
qint32 m_modeQ65; qint32 m_mult570;
qint32 m_mult570Tx;
qint32 m_nsum;
qint32 m_nsave;
qint32 m_TRperiod;
qint32 m_modeJT65;
qint32 m_modeQ65;
double m_fAdd; double m_fAdd;
// double m_IQamp; // double m_IQamp;
// double m_IQphase; // double m_IQphase;
double m_cal570; double m_cal570;
double m_TxOffset; double m_TxOffset;
bool m_monitoring; bool m_monitoring;
bool m_transmitting; bool m_transmitting;
bool m_diskData; bool m_diskData;
bool m_loopall; bool m_loopall;
bool m_decoderBusy; bool m_decoderBusy;
bool m_txFirst; bool m_txFirst;
bool m_auto; bool m_auto;
bool m_txMute; bool m_txMute;
bool m_restart; bool m_restart;
bool m_killAll; bool m_killAll;
bool m_xpol; bool m_xpol;
bool m_xpolx; bool m_xpolx;
bool m_call3Modified; bool m_call3Modified;
bool m_startAnother; bool m_startAnother;
bool m_saveAll; bool m_saveAll;
bool m_onlyEME; bool m_onlyEME;
bool m_widebandDecode; bool m_widebandDecode;
bool m_kb8rq; bool m_kb8rq;
bool m_NB; bool m_NB;
bool m_fs96000; bool m_fs96000;
bool m_IQswap; bool m_IQswap;
bool m_10db; bool m_10db;
bool m_initIQplus; bool m_initIQplus;
bool m_bIQxt; bool m_bIQxt;
float m_gainx; float m_gainx;
float m_gainy; float m_gainy;
float m_phasex; float m_phasex;
float m_phasey; float m_phasey;
float m_pctZap; float m_pctZap;
QRect m_astroGeom; QRect m_wideGraphGeom;
QRect m_wideGraphGeom;
QRect m_messagesGeom;
QRect m_bandMapGeom;
QLabel* lab1; // labels in status bar QLabel* lab1; // labels in status bar
QLabel* lab2; QLabel* lab2;
QLabel* lab3; QLabel* lab3;
QLabel* lab4; QLabel* lab4;
QLabel* lab5; QLabel* lab5;
QLabel* lab6; QLabel* lab6;
QLabel* lab7; QLabel* lab7;
QMessageBox msgBox0; QMessageBox msgBox0;
QFuture<void>* future1; QFuture<void>* future1;
QFuture<void>* future2; QFuture<void>* future2;
QFutureWatcher<void>* watcher1; QFutureWatcher<void>* watcher1;
QFutureWatcher<void>* watcher2; QFutureWatcher<void>* watcher2;
QProcess proc_m65; QProcess proc_m65;
QProcess proc_qthid; QProcess proc_qthid;
QProcess proc_editor; QProcess proc_editor;
QString m_path; QString m_path;
QString m_pbdecoding_style1; QString m_pbdecoding_style1;
QString m_pbmonitor_style; QString m_pbmonitor_style;
QString m_pbAutoOn_style; QString m_pbAutoOn_style;
QString m_messagesText; QString m_messagesText;
QString m_bandmapText; QString m_bandmapText;
QString m_myCall; QString m_myCall;
QString m_myGrid; QString m_myGrid;
QString m_hisCall; QString m_hisCall;
QString m_hisGrid; QString m_hisGrid;
QString m_appDir; QString m_saveDir;
QString m_saveDir; QString m_azelDir;
QString m_azelDir; QString m_dxccPfx;
QString m_dxccPfx; QString m_palette;
QString m_palette; QString m_dateTime;
QString m_dateTime; QString m_mode;
QString m_mode; QString m_colors;
QString m_colors; QString m_editorCommand;
QString m_editorCommand; QString m_modeTx;
QString m_modeTx;
QHash<QString,bool> m_worked; QHash<QString,bool> m_worked;
SignalMeter *xSignalMeter; SignalMeter *xSignalMeter;
SignalMeter *ySignalMeter; SignalMeter *ySignalMeter;
SoundInThread soundInThread; //Instantiate the audio threads SoundInThread soundInThread; //Instantiate the audio threads
SoundOutThread soundOutThread; SoundOutThread soundOutThread;
//---------------------------------------------------- private functions //---------------------------------------------------- private functions
void readSettings(); void readSettings();
void writeSettings(); void writeSettings();
void createStatusBar(); void createStatusBar();
void updateStatusBar(); void updateStatusBar();
void msgBox(QString t); void msgBox(QString t);
void genStdMsgs(QString rpt); void genStdMsgs(QString rpt);
void lookup(); void lookup();
void ba2msg(QByteArray ba, char* message); void ba2msg(QByteArray ba, char* message);
void msgtype(QString t, QLineEdit* tx); void msgtype(QString t, QLineEdit* tx);
void stub(); void stub();
bool subProcessFailed (QProcess *, int exit_code, QProcess::ExitStatus); bool subProcessFailed (QProcess *, int exit_code, QProcess::ExitStatus);
}; };

View File

@ -1,24 +1,35 @@
#include "messages.h" #include "messages.h"
#include <QSettings>
#include "SettingsGroup.hpp"
#include "ui_messages.h" #include "ui_messages.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "qt_helpers.hpp" #include "qt_helpers.hpp"
Messages::Messages(QWidget *parent) : Messages::Messages (QString const& settings_filename, QWidget * parent) :
QDialog(parent), QDialog {parent},
ui(new Ui::Messages) ui {new Ui::Messages},
m_settings_filename {settings_filename}
{ {
ui->setupUi(this); ui->setupUi(this);
setWindowTitle("Messages");
setWindowFlags (Qt::Dialog | Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint);
QSettings settings {m_settings_filename, QSettings::IniFormat};
SettingsGroup g {&settings, "MainWindow"}; // MainWindow group for
// historical reasons
setGeometry (settings.value ("MessagesGeom", QRect {800, 400, 381, 400}).toRect ());
ui->messagesTextBrowser->setStyleSheet( \ ui->messagesTextBrowser->setStyleSheet( \
"QTextBrowser { background-color : #000066; color : red; }"); "QTextBrowser { background-color : #000066; color : red; }");
ui->messagesTextBrowser->clear(); ui->messagesTextBrowser->clear();
m_cqOnly=false; m_cqOnly=false;
m_cqStarOnly=false; m_cqStarOnly=false;
connect(ui->messagesTextBrowser,SIGNAL(selectCallsign(bool)),this, connect (ui->messagesTextBrowser, &DisplayText::selectCallsign, this, &Messages::selectCallsign2);
SLOT(selectCallsign2(bool)));
} }
Messages::~Messages() Messages::~Messages()
{ {
QSettings settings {m_settings_filename, QSettings::IniFormat};
SettingsGroup g {&settings, "MainWindow"};
settings.setValue ("MessagesGeom", geometry ());
delete ui; delete ui;
} }

View File

@ -12,11 +12,11 @@ class Messages : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit Messages(QWidget *parent = 0); explicit Messages (QString const& settings_filename, QWidget * parent = nullptr);
void setText(QString t, QString t2); void setText(QString t, QString t2);
void setColors(QString t); void setColors(QString t);
~Messages(); ~Messages();
signals: signals:
void click2OnCallsign(QString hiscall, QString t2); void click2OnCallsign(QString hiscall, QString t2);
@ -27,17 +27,18 @@ private slots:
void on_cbCQstar_toggled(bool checked); void on_cbCQstar_toggled(bool checked);
private: private:
Ui::Messages *ui; Ui::Messages *ui;
QString m_t; QString m_settings_filename;
QString m_t2; QString m_t;
QString m_colorBackground; QString m_t2;
QString m_color0; QString m_colorBackground;
QString m_color1; QString m_color0;
QString m_color2; QString m_color1;
QString m_color3; QString m_color2;
QString m_color3;
bool m_cqOnly; bool m_cqOnly;
bool m_cqStarOnly; bool m_cqStarOnly;
}; };
#endif // MESSAGES_H #endif

View File

@ -1,29 +1,35 @@
#include "widegraph.h" #include "widegraph.h"
#include <QSettings>
#include <QMessageBox>
#include "SettingsGroup.hpp"
#include "ui_widegraph.h" #include "ui_widegraph.h"
#define NFFT 32768 #define NFFT 32768
WideGraph::WideGraph(QWidget *parent) : WideGraph::WideGraph (QString const& settings_filename, QWidget * parent)
QDialog(parent), : QDialog {parent},
ui(new Ui::WideGraph) ui {new Ui::WideGraph},
m_settings_filename {settings_filename}
{ {
ui->setupUi(this); ui->setupUi(this);
this->setWindowFlags(Qt::Dialog); setWindowTitle("Wide Graph");
this->installEventFilter(parent); //Installing the filter setWindowFlags(Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint);
installEventFilter(parent); //Installing the filter
ui->widePlot->setCursor(Qt::CrossCursor); ui->widePlot->setCursor(Qt::CrossCursor);
this->setMaximumWidth(2048); setMaximumWidth(2048);
this->setMaximumHeight(880); setMaximumHeight(880);
ui->widePlot->setMaximumHeight(800); ui->widePlot->setMaximumHeight(800);
m_bIQxt=false; m_bIQxt=false;
connect(ui->widePlot, SIGNAL(freezeDecode1(int)),this, connect(ui->widePlot, SIGNAL(freezeDecode1(int)),this,
SLOT(wideFreezeDecode(int))); SLOT(wideFreezeDecode(int)));
//Restore user's settings //Restore user's settings
QString inifile(QApplication::applicationDirPath()); QSettings settings {m_settings_filename, QSettings::IniFormat};
inifile += "/map65.ini"; {
QSettings settings(inifile, QSettings::IniFormat); SettingsGroup g {&settings, "MainWindow"}; // historical reasons
setGeometry (settings.value ("WideGraphGeom", QRect {45,30,1023,340}).toRect ());
settings.beginGroup("WideGraph"); }
SettingsGroup g {&settings, "WideGraph"};
ui->widePlot->setPlotZero(settings.value("PlotZero", 20).toInt()); ui->widePlot->setPlotZero(settings.value("PlotZero", 20).toInt());
ui->widePlot->setPlotGain(settings.value("PlotGain", 0).toInt()); ui->widePlot->setPlotGain(settings.value("PlotGain", 0).toInt());
ui->zeroSpinBox->setValue(ui->widePlot->getPlotZero()); ui->zeroSpinBox->setValue(ui->widePlot->getPlotZero());
@ -44,7 +50,6 @@ WideGraph::WideGraph(QWidget *parent) :
ui->fCenterLineEdit->setText(QString::number(m_dForceCenterFreq)); ui->fCenterLineEdit->setText(QString::number(m_dForceCenterFreq));
m_bLockTxRx=settings.value("LockTxRx",false).toBool(); m_bLockTxRx=settings.value("LockTxRx",false).toBool();
ui->cbLockTxRx->setChecked(m_bLockTxRx); ui->cbLockTxRx->setChecked(m_bLockTxRx);
settings.endGroup();
} }
WideGraph::~WideGraph() WideGraph::~WideGraph()
@ -64,11 +69,12 @@ void WideGraph::resizeEvent(QResizeEvent* ) //resizeEvent()
void WideGraph::saveSettings() void WideGraph::saveSettings()
{ {
//Save user's settings //Save user's settings
QString inifile(QApplication::applicationDirPath()); QSettings settings {m_settings_filename, QSettings::IniFormat};
inifile += "/map65.ini"; {
QSettings settings(inifile, QSettings::IniFormat); SettingsGroup g {&settings, "MainWindow"}; // for historical reasons
settings.setValue ("WideGraphGeom", geometry());
settings.beginGroup("WideGraph"); }
SettingsGroup g {&settings, "WideGraph"};
settings.setValue("PlotZero",ui->widePlot->m_plotZero); settings.setValue("PlotZero",ui->widePlot->m_plotZero);
settings.setValue("PlotGain",ui->widePlot->m_plotGain); settings.setValue("PlotGain",ui->widePlot->m_plotGain);
settings.setValue("PlotWidth",ui->widePlot->plotWidth()); settings.setValue("PlotWidth",ui->widePlot->plotWidth());
@ -78,7 +84,6 @@ void WideGraph::saveSettings()
settings.setValue("ForceCenterFreqBool",m_bForceCenterFreq); settings.setValue("ForceCenterFreqBool",m_bForceCenterFreq);
settings.setValue("ForceCenterFreqMHz",m_dForceCenterFreq); settings.setValue("ForceCenterFreqMHz",m_dForceCenterFreq);
settings.setValue("LockTxRx",m_bLockTxRx); settings.setValue("LockTxRx",m_bLockTxRx);
settings.endGroup();
} }
void WideGraph::dataSink2(float s[], int nkhz, int ihsym, int ndiskdata, void WideGraph::dataSink2(float s[], int nkhz, int ihsym, int ndiskdata,

View File

@ -1,6 +1,6 @@
#ifndef WIDEGRAPH_H #ifndef WIDEGRAPH_H
#define WIDEGRAPH_H #define WIDEGRAPH_H
#include <QtWidgets>
#include <QDialog> #include <QDialog>
namespace Ui { namespace Ui {
@ -12,17 +12,9 @@ class WideGraph : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit WideGraph(QWidget *parent = 0); explicit WideGraph (QString const& settings_filename, QWidget * parent = nullptr);
~WideGraph(); ~WideGraph();
bool m_bForceCenterFreq;
bool m_bLockTxRx;
qint32 m_mult570;
qint32 m_mult570Tx;
double m_dForceCenterFreq;
double m_cal570;
double m_TxOffset;
void dataSink2(float s[], int nkhz, int ihsym, int ndiskdata, void dataSink2(float s[], int nkhz, int ihsym, int ndiskdata,
uchar lstrong[]); uchar lstrong[]);
int QSOfreq(); int QSOfreq();
@ -73,6 +65,19 @@ private slots:
void on_cbSpec2d_toggled(bool checked); void on_cbSpec2d_toggled(bool checked);
void on_cbLockTxRx_stateChanged(int arg1); void on_cbLockTxRx_stateChanged(int arg1);
private:
Ui::WideGraph * ui;
QString m_settings_filename;
public:
bool m_bForceCenterFreq;
private:
bool m_bLockTxRx;
public:
qint32 m_mult570;
qint32 m_mult570Tx;
double m_dForceCenterFreq;
double m_cal570;
double m_TxOffset;
private: private:
bool m_bIQxt; bool m_bIQxt;
qint32 m_waterfallAvg; qint32 m_waterfallAvg;
@ -80,8 +85,6 @@ private:
qint32 m_fSample; qint32 m_fSample;
qint32 m_mode65; qint32 m_mode65;
qint32 m_TRperiod=60; qint32 m_TRperiod=60;
Ui::WideGraph *ui;
}; };
extern int set570(double freq_MHz); extern int set570(double freq_MHz);