From a72de82a3969d0842d89cabc0b319d16a5c32637 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Thu, 2 Nov 2017 18:45:19 +0000 Subject: [PATCH] Experimenting with a new Fox GUI. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@8210 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- CMakeLists.txt | 2 - displaytext.cpp | 2 +- foxcalls.cpp | 181 -------------------------------- foxcalls.h | 50 --------- foxcalls.ui | 266 ------------------------------------------------ mainwindow.cpp | 125 ++++++++++++++++++----- mainwindow.h | 6 +- wsjtx.pro | 9 +- 8 files changed, 106 insertions(+), 535 deletions(-) delete mode 100644 foxcalls.cpp delete mode 100644 foxcalls.h delete mode 100644 foxcalls.ui diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f53fa07a..e67843ad5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -297,7 +297,6 @@ set (wsjtx_CXXSRCS widegraph.cpp echograph.cpp echoplot.cpp - foxcalls.cpp fastgraph.cpp fastplot.cpp about.cpp @@ -654,7 +653,6 @@ set (wsjtx_UISRCS astro.ui echograph.ui fastgraph.ui - foxcalls.ui messageaveraging.ui widegraph.ui logqso.ui diff --git a/displaytext.cpp b/displaytext.cpp index 989e206bd..56a711454 100644 --- a/displaytext.cpp +++ b/displaytext.cpp @@ -1,5 +1,5 @@ #include "displaytext.h" - +#include "mainwindow.h" #include #include #include diff --git a/foxcalls.cpp b/foxcalls.cpp deleted file mode 100644 index 8217209e4..000000000 --- a/foxcalls.cpp +++ /dev/null @@ -1,181 +0,0 @@ -#include "foxcalls.h" -#include "qt_helpers.hpp" -#include -#include -#include -#include "ui_foxcalls.h" -#include "moc_foxcalls.cpp" - -FoxCalls::FoxCalls(QSettings * settings, QWidget *parent) : - QWidget {parent, Qt::Window | Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint}, - m_settings (settings), - ui(new Ui::FoxCalls) -{ - ui->setupUi(this); - setWindowTitle (QApplication::applicationName () + " - " + tr ("Fox Callers")); - installEventFilter(parent); //Installing the filter - -//Restore user's settings - m_settings->beginGroup("FoxCalls"); - restoreGeometry (m_settings->value("geometry").toByteArray()); - ui->cbReverse->setVisible(false); - ui->foxPlainTextEdit->setReadOnly (true); - ui->foxPlainTextEdit->viewport()->installEventFilter(this); - m_nToBeCalled=0; -} - -FoxCalls::~FoxCalls() -{ - saveSettings(); -} - -void FoxCalls::closeEvent (QCloseEvent * e) -{ - saveSettings (); - QWidget::closeEvent (e); -} - -void FoxCalls::saveSettings() -{ -//Save user's settings - m_settings->beginGroup("FoxCalls"); - m_settings->setValue("geometry", saveGeometry()); - m_settings->endGroup(); -} - -void FoxCalls::insertText(QString t) -{ - QMap map; - QStringList lines; - QString msg,c2,t1; - QString ABC{"ABCDEFGHIJKLMNOPQRSTUVWXYZ"}; - QList list; - int i,j,k,n,nlines; - - if(m_bFirst) { - QTextDocument *doc = ui->foxPlainTextEdit->document(); - QFont font = doc->defaultFont(); - font.setFamily("Courier New"); - font.setPointSize(12); - doc->setDefaultFont(font); - ui->label_2->setFont(font); - ui->label_2->setText("Call Grid dB Freq Age"); - ui->pteToBeCalled->setFont(font); - ui->pteCalled->setFont(font); - m_bFirst=false; - } - - m_t0=t; -// Save only the most recent transmission from each caller. - lines = t.split("\n"); - nlines=lines.length()-1; - for(i=0; i=ui->sbMinDB->value() and nsnr<=ui->sbMaxDB->value()) { - if(ui->rbCall->isChecked()) t += map[a] + "\n"; - if(ui->rbSNR->isChecked() or ui->rbAge->isChecked()) { - i=2; - if(ui->rbAge->isChecked()) i=4; - t1=map[a].split(" ",QString::SkipEmptyParts).at(i); - n=1000*(t1.toInt()+100) + j; - } - - if(ui->rbGrid->isChecked()) { - t1=map[a].split(" ",QString::SkipEmptyParts).at(1); - int i1=ABC.indexOf(t1.mid(0,1)); - int i2=ABC.indexOf(t1.mid(1,1)); - n=100*(26*i1+i2)+t1.mid(2,2).toInt(); - n=1000*n + j; - } - - list.insert(j,n); - m_lines2.insert(j,map[a]); - j++; - } - } - - if(ui->rbSNR->isChecked() or ui->rbAge->isChecked() or ui->rbGrid->isChecked()) { - if(m_bReverse) { - qSort(list.begin(),list.end(),qGreater()); - } else { - qSort(list.begin(),list.end()); - } - } - - if(ui->rbSNR->isChecked() or ui->rbAge->isChecked() or ui->rbGrid->isChecked()) { - for(i=0; ifoxPlainTextEdit->setPlainText(t); - QString uniqueCalls; - uniqueCalls.sprintf(" Unique callers: %d",j); - ui->labCallers->setText(uniqueCalls); -} - -void FoxCalls::on_rbCall_toggled(bool b) -{ - ui->cbReverse->setVisible(!b); - insertText(m_t0); -} - -void FoxCalls::on_rbGrid_toggled(bool b) -{ - ui->cbReverse->setVisible(b); - insertText(m_t0); -} -void FoxCalls::on_rbSNR_toggled(bool b) -{ - ui->cbReverse->setVisible(b); - insertText(m_t0); -} -void FoxCalls::on_rbAge_toggled(bool b) -{ - ui->cbReverse->setVisible(b); - insertText(m_t0); -} - -void FoxCalls::on_cbReverse_toggled(bool b) -{ - m_bReverse=b; - insertText(m_t0); -} - -void FoxCalls::on_sbMaxDB_valueChanged(int n) -{ - insertText(m_t0); -} - -void FoxCalls::on_sbMinDB_valueChanged(int n) -{ - insertText(m_t0); -} - -bool FoxCalls::eventFilter(QObject *obj, QEvent *e) -{ - if(m_nToBeCalled<4) { - if ((obj == ui->foxPlainTextEdit || obj==ui->foxPlainTextEdit->viewport()) && - e->type() == QEvent::MouseButtonPress) { - QMouseEvent *me= static_cast(e); - int i=int(0.05592*me->y()+0.5) - 1; - QString t3=m_lines2.at(i); - t3=t3.split(" ").at(0) + "\n"; - ui->pteToBeCalled->insertPlainText(t3); - m_nToBeCalled++; - qDebug() << "a" << m_nToBeCalled; - } - } - return QWidget::eventFilter(obj, e); -} diff --git a/foxcalls.h b/foxcalls.h deleted file mode 100644 index d1bb014d5..000000000 --- a/foxcalls.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef FOXCALLS_H -#define FOXCALLS_H - -#include -#include -#include -#include - -namespace Ui { -class FoxCalls; -} - -class QSettings; -class QFont; - -class FoxCalls : public QWidget -{ - Q_OBJECT - -protected: - void closeEvent (QCloseEvent *) override; - -public: - explicit FoxCalls(QSettings *, QWidget *parent = 0); - ~FoxCalls(); - - void saveSettings(); - void insertText(QString t); - -private slots: - void on_rbCall_toggled(bool b); - void on_rbGrid_toggled(bool b); - void on_rbSNR_toggled(bool b); - void on_rbAge_toggled(bool b); - void on_cbReverse_toggled(bool b); - void on_sbMaxDB_valueChanged(int n); - void on_sbMinDB_valueChanged(int n); - bool eventFilter(QObject *obj, QEvent *event); - -private: - bool m_bFirst=true; - bool m_bReverse; - qint32 m_nToBeCalled; - QString m_t0; - QStringList m_lines2; - QSettings * m_settings; - QScopedPointer ui; -}; - -#endif // FOXCALLS_H diff --git a/foxcalls.ui b/foxcalls.ui deleted file mode 100644 index 32b4ec02f..000000000 --- a/foxcalls.ui +++ /dev/null @@ -1,266 +0,0 @@ - - - FoxCalls - - - - 0 - 0 - 546 - 562 - - - - - 0 - 0 - - - - Form - - - - - - - - - - - Sort by: - - - - - - - Call - - - true - - - - - - - Grid - - - - - - - dB - - - - - - - Age - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 30 - 20 - - - - - - - - Reverse - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - Courier New - 12 - - - - - - - - - - - - - - 0 - 0 - - - - - 375 - 0 - - - - - 375 - 16777215 - - - - - Courier New - 12 - - - - - - - - - - - 16777215 - 20 - - - - Unique callers: 0 - - - - - - - To be called: - - - - - 8 - 17 - 100 - 90 - - - - - 100 - 16777215 - - - - - - - 0 - 130 - 128 - 126 - - - - Called: - - - - - 9 - 16 - 100 - 90 - - - - - 100 - 16777215 - - - - - - - - 13 - 270 - 90 - 22 - - - - Max dB: - - - -50 - - - 50 - - - 30 - - - - - - 13 - 300 - 90 - 22 - - - - Min dB: - - - -50 - - - 50 - - - -30 - - - - - - - - - - - - - diff --git a/mainwindow.cpp b/mainwindow.cpp index 3dc2be6f7..ef8384fc8 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -37,7 +37,6 @@ #include "echograph.h" #include "fastplot.h" #include "fastgraph.h" -#include "foxcalls.h" #include "about.h" #include "messageaveraging.h" #include "widegraph.h" @@ -204,7 +203,6 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, m_echoGraph (new EchoGraph(m_settings)), m_fastGraph (new FastGraph(m_settings)), m_logDlg (new LogQSO (program_title (), m_settings, &m_config, this)), - m_foxCalls (new FoxCalls(m_settings)), m_lastDialFreq {0}, m_dialFreqRxWSPR {0}, m_detector {new Detector {RX_SAMPLE_RATE, NTMAX, downSampleFactor}}, @@ -866,6 +864,7 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, m_bDoubleClicked=false; m_bCallingCQ=false; m_bCheckedContest=false; + m_bDisplayedOnce=false; m_wait=0; m_CQtype="CQ"; @@ -2050,7 +2049,6 @@ void MainWindow::closeEvent(QCloseEvent * e) m_config.transceiver_offline (); writeSettings (); m_astroWidget.reset (); - m_foxCalls.reset(); m_guiTimer.stop (); m_prefixes.reset (); m_shortcuts.reset (); @@ -2114,10 +2112,6 @@ void MainWindow::on_actionFast_Graph_triggered() m_fastGraph->show(); } -void MainWindow::on_actionFox_Callers_triggered() -{ - m_foxCalls->show(); -} void MainWindow::on_actionSolve_FreqCal_triggered() { QString dpath{QDir::toNativeSeparators(m_config.writeable_data_dir().absolutePath()+"/")}; @@ -2718,7 +2712,8 @@ void MainWindow::decodeDone () if(f.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream s(&f); QString t=s.readAll(); - m_foxCalls->insertText(t); + QString t1=sortFoxCalls(t,1,10,-30,30); + ui->decodedTextBrowser->setText(t1); } } } @@ -2755,12 +2750,14 @@ void MainWindow::readFromStdout() //readFromStdout if(navg>1 or t.indexOf("f*")>0) bAvgMsg=true; } } + /* if(m_mode=="FT8" and m_bDXped) { int i3bit=t.mid(44,1).toInt(); t=t.mid(0,44) + " " + t.mid(45); if(i3bit==1) t=t.mid(0,24) + "RR73 NOW " + t.mid(24); if(i3bit==2) t=t.mid(0,24) + "NIL NOW " + t.mid(24); } + */ QFile f {m_config.writeable_data_dir ().absoluteFilePath ("ALL.TXT")}; if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) { QTextStream out(&f); @@ -2779,24 +2776,34 @@ void MainWindow::readFromStdout() //readFromStdout .arg (f.fileName ()).arg (f.errorString ())); } - if (m_config.insert_blank () && m_blankLine) - { - QString band; - if((QDateTime::currentMSecsSinceEpoch() / 1000 - m_secBandChanged) > 4*m_TRperiod/4) { - band = ' ' + m_config.bands ()->find (m_freqNominal); - } - ui->decodedTextBrowser->insertLineSpacer (band.rightJustified (40, '-')); - m_blankLine = false; + if (m_config.insert_blank () && m_blankLine && !m_config.bFox()) { + QString band; + if((QDateTime::currentMSecsSinceEpoch() / 1000 - m_secBandChanged) > 4*m_TRperiod/4) { + band = ' ' + m_config.bands ()->find (m_freqNominal); } + ui->decodedTextBrowser->insertLineSpacer (band.rightJustified (40, '-')); + m_blankLine = false; + } DecodedText decodedtext {QString::fromUtf8 (t.constData ()).remove (QRegularExpression {"\r|\n"}), "FT8" == m_mode && ui->cbVHFcontest->isChecked(), m_config.my_grid ()}; //Left (Band activity) window if(!bAvgMsg) { - ui->decodedTextBrowser->displayDecodedText(decodedtext,m_baseCall,m_config.DXCC(), + if(m_config.bFox()) { + if(!m_bDisplayedOnce) { + // This hack sets the font. Surely there's a better way! + DecodedText dt{".",false," "}; + ui->decodedTextBrowser->displayDecodedText(dt,m_baseCall,m_config.DXCC(), + m_logBook,m_config.color_CQ(),m_config.color_MyCall(), + m_config.color_DXCC(), m_config.color_NewCall()); + m_bDisplayedOnce=true; + } + } else { + ui->decodedTextBrowser->displayDecodedText(decodedtext,m_baseCall,m_config.DXCC(), m_logBook,m_config.color_CQ(),m_config.color_MyCall(), m_config.color_DXCC(), m_config.color_NewCall()); + } } //Right (Rx Frequency) window @@ -4744,19 +4751,14 @@ void MainWindow::on_actionFT8_triggered() ui->label_6->setText("Band Activity"); ui->label_7->setText("Rx Frequency"); displayWidgets(nWidgets("111010000100111000010000")); - if(m_config.bFox()) { - if(!m_foxCalls->isVisible()) { - m_foxCalls->show(); - } - } else { - if(m_foxCalls) m_foxCalls->hide(); - } if(m_config.bFox() or m_config.bHound()) { - if(m_config.bFox()) ui->labDXped->setText("DXpeditiion Fox"); - if(m_config.bHound()) ui->labDXped->setText("DXpeditiion Hound"); + if(m_config.bFox()) ui->labDXped->setText("DXpedition: Fox"); + if(m_config.bHound()) ui->labDXped->setText("DXpedition: Hound"); ui->labDXped->setVisible(true); + ui->cbVHFcontest->setVisible(false); } else { ui->labDXped->setVisible(false); + ui->cbVHFcontest->setVisible(true); } statusChanged(); } @@ -6919,3 +6921,74 @@ void MainWindow::write_transmit_entry (QString const& file_name) #endif } } + +QString MainWindow::sortFoxCalls(QString t, int isort, int max_N, int min_dB, int max_dB) +{ + QMap map; + QStringList lines,lines2; + QString msg,c2,t1; + QString ABC{"ABCDEFGHIJKLMNOPQRSTUVWXYZ"}; + QList list; + int i,j,k,n,nlines; + bool bReverse; + + bReverse=(isort<0); + isort=qAbs(isort); +// Save only the most recent transmission from each caller. + lines = t.split("\n"); + nlines=lines.length()-1; + for(i=0; i= min_dB and nsnr <= max_dB) { + if(isort==1) t += map[a] + "\n"; + if(isort==3 or isort==4) { + i=2; + if(isort==4) i=4; + t1=map[a].split(" ",QString::SkipEmptyParts).at(i); + n=1000*(t1.toInt()+100) + j; + } + + if(isort==2) { + t1=map[a].split(" ",QString::SkipEmptyParts).at(1); + int i1=ABC.indexOf(t1.mid(0,1)); + int i2=ABC.indexOf(t1.mid(1,1)); + n=100*(26*i1+i2)+t1.mid(2,2).toInt(); + n=1000*n + j; + } + + list.insert(j,n); + lines2.insert(j,map[a]); + j++; + } + } + + if(isort>1) { + if(bReverse) { + qSort(list.begin(),list.end(),qGreater()); + } else { + qSort(list.begin(),list.end()); + } + } + + if(isort>1) { + for(i=0; ilabCallers->setText(uniqueCalls); + return t; +} diff --git a/mainwindow.h b/mainwindow.h index f67d1a350..e930add8a 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -65,7 +65,6 @@ class QFont; class QHostInfo; class EchoGraph; class FastGraph; -class FoxCalls; class WideGraph; class LogQSO; class Transceiver; @@ -97,6 +96,7 @@ public: QSharedMemory *shdmem, unsigned downSampleFactor, QSplashScreen *, QWidget *parent = nullptr); + qint32 m_isort; ~MainWindow(); public slots: @@ -269,7 +269,6 @@ private slots: void on_actionEcho_triggered(); void on_actionISCAT_triggered(); void on_actionFast_Graph_triggered(); - void on_actionFox_Callers_triggered(); void fast_decode_done(); void on_actionMeasure_reference_spectrum_triggered(); void on_actionErase_reference_spectrum_triggered(); @@ -342,7 +341,6 @@ private: QScopedPointer m_prefixes; QScopedPointer m_mouseCmnds; QScopedPointer m_msgAvgWidget; - QScopedPointer m_foxCalls; Transceiver::TransceiverState m_rigState; Frequency m_lastDialFreq; @@ -569,6 +567,7 @@ private: bool m_block_pwr_tooltip; bool m_PwrBandSetOK; bool m_bVHFwarned; + bool m_bDisplayedOnce; Frequency m_lastMonitoredFrequency; double m_toneSpacing; int m_firstDecode; @@ -629,6 +628,7 @@ private: , Frequency frequency , QString const& his_call , QString const& his_grid) const; + QString sortFoxCalls(QString t, int m_isort, int max_N, int min_dB, int max_dB); void read_wav_file (QString const& fname); void decodeDone (); void subProcessFailed (QProcess *, int exit_code, QProcess::ExitStatus); diff --git a/wsjtx.pro b/wsjtx.pro index d685e08cb..1a327c919 100644 --- a/wsjtx.pro +++ b/wsjtx.pro @@ -67,8 +67,7 @@ SOURCES += \ echoplot.cpp echograph.cpp fastgraph.cpp fastplot.cpp Modes.cpp \ WSPRBandHopping.cpp MessageAggregator.cpp SampleDownloader.cpp qt_helpers.cpp\ MultiSettings.cpp PhaseEqualizationDialog.cpp IARURegions.cpp MessageBox.cpp \ - EqualizationToolsDialog.cpp \ - foxcalls.cpp + EqualizationToolsDialog.cpp HEADERS += qt_helpers.hpp \ pimpl_h.hpp pimpl_impl.hpp \ @@ -84,8 +83,7 @@ HEADERS += qt_helpers.hpp \ logbook/logbook.h logbook/countrydat.h logbook/countriesworked.h logbook/adif.h \ messageaveraging.h echoplot.h echograph.h fastgraph.h fastplot.h Modes.hpp WSPRBandHopping.hpp \ WsprTxScheduler.h SampleDownloader.hpp MultiSettings.hpp PhaseEqualizationDialog.hpp \ - IARURegions.hpp MessageBox.hpp EqualizationToolsDialog.hpp \ - foxcalls.h + IARURegions.hpp MessageBox.hpp EqualizationToolsDialog.hpp INCLUDEPATH += qmake_only @@ -97,8 +95,7 @@ HEADERS += OmniRigTransceiver.hpp FORMS += mainwindow.ui about.ui Configuration.ui widegraph.ui astro.ui \ logqso.ui wf_palette_design_dialog.ui messageaveraging.ui echograph.ui \ - fastgraph.ui \ - foxcalls.ui + fastgraph.ui RC_FILE = wsjtx.rc RESOURCES = wsjtx.qrc