diff options
| author | Christoph Berg <myon@debian.org> | 2018-12-19 22:58:32 +0100 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2018-12-19 22:58:32 +0100 |
| commit | e0737c56c1e384e05064a0c6e1ac46979371041b (patch) | |
| tree | a0123d694a2d36c43dabdf0a3907392fce11d457 /widgets | |
| parent | b4aebf2d137b892f53503b13785ecae900062ff7 (diff) | |
New upstream version 2.0.0+repackupstream/2.0.0+repack
Diffstat (limited to 'widgets')
71 files changed, 21533 insertions, 0 deletions
diff --git a/widgets/AbstractLogWindow.cpp b/widgets/AbstractLogWindow.cpp new file mode 100644 index 00000000..efa1e60f --- /dev/null +++ b/widgets/AbstractLogWindow.cpp @@ -0,0 +1,150 @@ +#include "AbstractLogWindow.hpp" + +#include <algorithm> +#include <QSettings> +#include <QString> +#include <QTableView> +#include <QHeaderView> +#include <QAction> +#include <QSqlTableModel> +#include <QItemSelectionModel> +#include <QItemSelection> +#include "Configuration.hpp" +#include "SettingsGroup.hpp" +#include "MessageBox.hpp" +#include "models/FontOverrideModel.hpp" +#include "pimpl_impl.hpp" + +class AbstractLogWindow::impl final +{ +public: + impl (AbstractLogWindow * self, QString const& settings_key, QSettings * settings + , Configuration const * configuration) + : self_ {self} + , settings_key_ {settings_key} + , settings_ {settings} + , configuration_ {configuration} + , log_view_ {nullptr} + { + } + + void delete_QSOs (); + + AbstractLogWindow * self_; + QString settings_key_; + QSettings * settings_; + Configuration const * configuration_; + QTableView * log_view_; + FontOverrideModel model_; +}; + +namespace +{ + bool row_is_higher (QModelIndex const& lhs, QModelIndex const& rhs) + { + return lhs.row () > rhs.row (); + } +} + +void AbstractLogWindow::impl::delete_QSOs () +{ + auto selection_model = log_view_->selectionModel (); + selection_model->select (selection_model->selection (), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); + auto row_indexes = selection_model->selectedRows (); + + if (row_indexes.size () + && MessageBox::Yes == MessageBox::query_message (self_ + , tr ("Confirm Delete") + , tr ("Are you sure you want to delete the %n " + "selected QSO(s) from the log", "" + , row_indexes.size ()))) + { + // We must work with source model indexes because we don't want row + // removes to invalidate model indexes we haven't yet processed. We + // achieve that by processing them in decending row order. + for (auto& row_index : row_indexes) + { + row_index = model_.mapToSource (row_index); + } + + // reverse sort by row + std::sort (row_indexes.begin (), row_indexes.end (), row_is_higher); + for (auto index : row_indexes) + { + auto row = model_.mapFromSource (index).row (); + model_.removeRow (row); + self_->log_model_changed (); + } + } +} + +AbstractLogWindow::AbstractLogWindow (QString const& settings_key, QSettings * settings + , Configuration const * configuration + , QWidget * parent) + : QWidget {parent} + , m_ {this, settings_key, settings, configuration} +{ + // this attempt to scroll to the last new record doesn't work, some + // sort of issue with model indexes and optimized DB fetches. For + // now sorting by the same column and direction as the underlying DB + // select and that DB select being in descending order so new rows + // at the end appear at view row 0 gets the job done + + // // ensure view scrolls to latest new row + // connect (&m_->model_, &QAbstractItemModel::rowsInserted, this, [this] (QModelIndex const& parent, int first, int last) { + // // note col 0 is hidden so use col 1 + // // queued connection required otherwise row may not be available + // // in time + // auto index = m_->model_.index (last, 1, parent); + // if (m_->log_view_) + // { + // m_->log_view_->scrollTo (index); + // } + // }, Qt::QueuedConnection); +} + +AbstractLogWindow::~AbstractLogWindow () +{ + SettingsGroup g {m_->settings_, m_->settings_key_}; + m_->settings_->setValue ("window/geometry", saveGeometry ()); +} + +void AbstractLogWindow::set_log_view (QTableView * log_view) +{ + // do this here because we know the UI must be setup before this + SettingsGroup g {m_->settings_, m_->settings_key_}; + restoreGeometry (m_->settings_->value ("window/geometry").toByteArray ()); + m_->log_view_ = log_view; + set_log_view_font (m_->configuration_->decoded_text_font ()); + log_view->setSortingEnabled (true); + log_view->setContextMenuPolicy (Qt::ActionsContextMenu); + log_view->setAlternatingRowColors (true); + log_view->setSelectionBehavior (QAbstractItemView::SelectRows); + log_view->setSelectionMode (QAbstractItemView::ExtendedSelection); + log_view->setVerticalScrollMode (QAbstractItemView::ScrollPerPixel); + m_->model_.setSourceModel (log_view->model ()); + log_view->setModel (&m_->model_); + log_view->setColumnHidden (0, true); + auto horizontal_header = log_view->horizontalHeader (); + horizontal_header->setResizeContentsPrecision (0); // visible region only + horizontal_header->setSectionResizeMode (QHeaderView::ResizeToContents); + horizontal_header->setSectionsMovable (true); + auto vertical_header = log_view->horizontalHeader (); + vertical_header->setResizeContentsPrecision (0); // visible region only + vertical_header->setSectionResizeMode (QHeaderView::ResizeToContents); + + // actions + auto delete_action = new QAction {tr ("&Delete ..."), log_view}; + log_view->insertAction (nullptr, delete_action); + connect (delete_action, &QAction::triggered, [this] (bool /*checked*/) { + m_->delete_QSOs (); + }); +} + +void AbstractLogWindow::set_log_view_font (QFont const& font) +{ + m_->log_view_->setFont (font); + m_->log_view_->horizontalHeader ()->setFont (font); + m_->log_view_->verticalHeader ()->setFont (font); + m_->model_.set_font (font); +} diff --git a/widgets/AbstractLogWindow.hpp b/widgets/AbstractLogWindow.hpp new file mode 100644 index 00000000..581212d8 --- /dev/null +++ b/widgets/AbstractLogWindow.hpp @@ -0,0 +1,41 @@ +#ifndef ABSTRACT_LOG_WINDOW_HPP_ +#define ABSTRACT_LOG_WINDOW_HPP_ + +#include <QWidget> +#include "pimpl_h.hpp" + +class QString; +class QSettings; +class Configuration; +class QTableView; +class QFont; + +// +// AbstractLogWindow - Base class for log view windows +// +// QWidget that manages the common functionality shared by windows +// that include a QSO log view. +// +class AbstractLogWindow + : public QWidget +{ +public: + AbstractLogWindow (QString const& settings_key, QSettings * settings + , Configuration const * configuration + , QWidget * parent = nullptr); + virtual ~AbstractLogWindow () = 0; + + // set the QTableView that shows the log records, must have its + // model set before calling this + void set_log_view (QTableView *); + + void set_log_view_font (QFont const&); + +private: + virtual void log_model_changed (int row = -1) = 0; + + class impl; + pimpl<impl> m_; +}; + +#endif diff --git a/widgets/CabrilloLogWindow.cpp b/widgets/CabrilloLogWindow.cpp new file mode 100644 index 00000000..44a52cc6 --- /dev/null +++ b/widgets/CabrilloLogWindow.cpp @@ -0,0 +1,88 @@ +#include "CabrilloLogWindow.hpp" + +#include <QApplication> +#include <QIdentityProxyModel> +#include <QSqlTableModel> +#include "Configuration.hpp" +#include "models/Bands.hpp" +#include "item_delegates/ForeignKeyDelegate.hpp" +#include "item_delegates/DateTimeAsSecsSinceEpochDelegate.hpp" +#include "item_delegates/CallsignDelegate.hpp" +#include "pimpl_impl.hpp" + +#include "ui_CabrilloLogWindow.h" + +namespace +{ + class FormatProxyModel final + : public QIdentityProxyModel + { + public: + explicit FormatProxyModel (QObject * parent = nullptr) + : QIdentityProxyModel {parent} + { + } + + QVariant data (QModelIndex const& index, int role) const override + { + if (Qt::TextAlignmentRole == role && index.isValid ()) + { + switch (index.column ()) + { + case 1: + case 6: + return Qt::AlignRight + Qt::AlignVCenter; + default: + break; + } + } + return QIdentityProxyModel::data (index, role); + } + }; +} + +class CabrilloLogWindow::impl final +{ +public: + explicit impl (QSqlTableModel * log_model) + : log_model_ {log_model} + { + } + + QSqlTableModel * log_model_; + FormatProxyModel format_model_; + Ui::CabrilloLogWindow ui_; +}; + +CabrilloLogWindow::CabrilloLogWindow (QSettings * settings, Configuration const * configuration + , QSqlTableModel * cabrillo_log_model, QWidget * parent) + : AbstractLogWindow {"Cabrillo Log Window", settings, configuration, parent} + , m_{cabrillo_log_model} +{ + setWindowTitle (QApplication::applicationName () + " - Cabrillo Log"); + m_->ui_.setupUi (this); + m_->format_model_.setSourceModel (m_->log_model_); + m_->ui_.log_table_view->setModel (&m_->format_model_); + set_log_view (m_->ui_.log_table_view); + m_->ui_.log_table_view->setItemDelegateForColumn (2, new DateTimeAsSecsSinceEpochDelegate {this}); + m_->ui_.log_table_view->setItemDelegateForColumn (3, new CallsignDelegate {this}); + m_->ui_.log_table_view->setItemDelegateForColumn (6, new ForeignKeyDelegate {configuration->bands (), 0, this}); + auto h_header = m_->ui_.log_table_view->horizontalHeader (); + h_header->moveSection (6, 1); // band to first column +} + +CabrilloLogWindow::~CabrilloLogWindow () +{ +} + +void CabrilloLogWindow::log_model_changed (int row) +{ + if (row >= 0) + { + m_->log_model_->selectRow (row); + } + else + { + m_->log_model_->select (); + } +} diff --git a/widgets/CabrilloLogWindow.hpp b/widgets/CabrilloLogWindow.hpp new file mode 100644 index 00000000..e2aa1627 --- /dev/null +++ b/widgets/CabrilloLogWindow.hpp @@ -0,0 +1,27 @@ +#ifndef CABRILLO_LOG_WINDOW_HPP_ +#define CABRILLO_LOG_WINDOW_HPP_ + +#include "AbstractLogWindow.hpp" +#include "pimpl_h.hpp" + +class QSettings; +class Configuration; +class QFont; +class QSqlTableModel; + +class CabrilloLogWindow final + : public AbstractLogWindow +{ +public: + explicit CabrilloLogWindow (QSettings *, Configuration const *, QSqlTableModel * cabrillo_log_model + , QWidget * parent = nullptr); + ~CabrilloLogWindow (); + +private: + void log_model_changed (int row) override; + + class impl; + pimpl<impl> m_; +}; + +#endif diff --git a/widgets/CabrilloLogWindow.ui b/widgets/CabrilloLogWindow.ui new file mode 100644 index 00000000..efefe5d3 --- /dev/null +++ b/widgets/CabrilloLogWindow.ui @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>CabrilloLogWindow</class> + <widget class="QWidget" name="CabrilloLogWindow"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>493</width> + <height>210</height> + </rect> + </property> + <property name="windowTitle"> + <string>Contest Log</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QTableView" name="log_table_view"> + <property name="toolTip"> + <string><html><head/><body><p>Right-click here for available actions.</p></body></html></string> + </property> + <attribute name="horizontalHeaderStretchLastSection"> + <bool>true</bool> + </attribute> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/widgets/DecodeHighlightingListView.cpp b/widgets/DecodeHighlightingListView.cpp new file mode 100644 index 00000000..cc5ea5d2 --- /dev/null +++ b/widgets/DecodeHighlightingListView.cpp @@ -0,0 +1,72 @@ +#include "DecodeHighlightingListView.hpp" + +#include <QAction> +#include <QColorDialog> + +#include "models/DecodeHighlightingModel.hpp" +#include "MessageBox.hpp" + +DecodeHighlightingListView::DecodeHighlightingListView (QWidget * parent) + : QListView {parent} +{ + auto * fg_colour_action = new QAction {tr ("&Foreground color ..."), this}; + addAction (fg_colour_action); + connect (fg_colour_action, &QAction::triggered, [this] (bool /*checked*/) { + auto const& index = currentIndex (); + auto colour = QColorDialog::getColor (model ()->data (index, Qt::ForegroundRole).value<QBrush> ().color () + , this + , tr ("Choose %1 Foreground Color") + .arg (model ()->data (index).toString ())); + if (colour.isValid ()) + { + model ()->setData (index, QBrush {colour}, Qt::ForegroundRole); + } + }); + + auto * unset_fg_colour_action = new QAction {tr ("&Unset foreground color"), this}; + addAction (unset_fg_colour_action); + connect (unset_fg_colour_action, &QAction::triggered, [this] (bool /*checked*/) { + model ()->setData (currentIndex (), QBrush {}, Qt::ForegroundRole); + }); + + auto * bg_colour_action = new QAction {tr ("&Background color ..."), this}; + addAction (bg_colour_action); + connect (bg_colour_action, &QAction::triggered, [this] (bool /*checked*/) { + auto const& index = currentIndex (); + auto colour = QColorDialog::getColor (model ()->data (index, Qt::BackgroundRole).value<QBrush> ().color () + , this + , tr ("Choose %1 Background Color") + .arg (model ()->data (index).toString ())); + if (colour.isValid ()) + { + model ()->setData (index, QBrush {colour}, Qt::BackgroundRole); + } + }); + + auto * unset_bg_colour_action = new QAction {tr ("U&nset background color"), this}; + addAction (unset_bg_colour_action); + connect (unset_bg_colour_action, &QAction::triggered, [this] (bool /*checked*/) { + model ()->setData (currentIndex (), QBrush {}, Qt::BackgroundRole); + }); + + auto * defaults_action = new QAction {tr ("&Reset this item to defaults"), this}; + addAction (defaults_action); + connect (defaults_action, &QAction::triggered, [this] (bool /*checked*/) { + auto const& index = currentIndex (); + model ()->setData (index, model ()->data (index, DecodeHighlightingModel::EnabledDefaultRole).toBool () ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole); + model ()->setData (index, model ()->data (index, DecodeHighlightingModel::ForegroundDefaultRole), Qt::ForegroundRole); + model ()->setData (index, model ()->data (index, DecodeHighlightingModel::BackgroundDefaultRole), Qt::BackgroundRole); + }); +} + +QSize DecodeHighlightingListView::sizeHint () const +{ + auto item_height = sizeHintForRow (0); + if (item_height >= 0) + { + // set the height hint to exactly the space required for all the + // items + return {width (), (model ()->rowCount () * (item_height + 2 * spacing ())) + 2 * frameWidth ()}; + } + return QListView::sizeHint (); +} diff --git a/widgets/DecodeHighlightingListView.hpp b/widgets/DecodeHighlightingListView.hpp new file mode 100644 index 00000000..86aa86f4 --- /dev/null +++ b/widgets/DecodeHighlightingListView.hpp @@ -0,0 +1,26 @@ +#ifndef DECODE_HIGHLIGHTING_LIST_VIEW_HPP_ +#define DECODE_HIGHLIGHTING_LIST_VIEW_HPP_ + +#include <QListView> + +class QWidget; + +// Class Decode Highlighting List View +// +// Sub-class of a QListView that adds a context menu to adjust the +// foreground and background colour roles of the the underlying model +// item that lies at the context menu right-click position. It also +// constrains the vertical size hint to limit the height to exactly +// that of the sum of the items. +// +class DecodeHighlightingListView final + : public QListView +{ +public: + explicit DecodeHighlightingListView (QWidget * parent = nullptr); + +private: + QSize sizeHint () const override; +}; + +#endif diff --git a/widgets/DoubleClickablePushButton.cpp b/widgets/DoubleClickablePushButton.cpp new file mode 100644 index 00000000..2c37a55e --- /dev/null +++ b/widgets/DoubleClickablePushButton.cpp @@ -0,0 +1,14 @@ +#include "DoubleClickablePushButton.hpp" + +#include "moc_DoubleClickablePushButton.cpp" + +DoubleClickablePushButton::DoubleClickablePushButton (QWidget * parent) + : QPushButton {parent} +{ +} + +void DoubleClickablePushButton::mouseDoubleClickEvent (QMouseEvent * event) +{ + Q_EMIT doubleClicked (); + QPushButton::mouseDoubleClickEvent (event); +} diff --git a/widgets/DoubleClickablePushButton.hpp b/widgets/DoubleClickablePushButton.hpp new file mode 100644 index 00000000..ebc1ab84 --- /dev/null +++ b/widgets/DoubleClickablePushButton.hpp @@ -0,0 +1,27 @@ +#ifndef DOUBLE_CLICKABLE_PUSH_BUTTON_HPP_ +#define DOUBLE_CLICKABLE_PUSH_BUTTON_HPP_ + +#include <QPushButton> + +// +// DoubleClickablePushButton - QPushButton that emits a mouse double +// click signal +// +// Clients should be aware of the QWidget::mouseDoubleClickEvent() +// notes about receipt of mouse press and mouse release events. +// +class DoubleClickablePushButton + : public QPushButton +{ + Q_OBJECT + +public: + DoubleClickablePushButton (QWidget * = nullptr); + + Q_SIGNAL void doubleClicked (); + +protected: + void mouseDoubleClickEvent (QMouseEvent *) override; +}; + +#endif diff --git a/widgets/DoubleClickableRadioButton.cpp b/widgets/DoubleClickableRadioButton.cpp new file mode 100644 index 00000000..892b3c29 --- /dev/null +++ b/widgets/DoubleClickableRadioButton.cpp @@ -0,0 +1,14 @@ +#include "DoubleClickableRadioButton.hpp" + +#include "moc_DoubleClickableRadioButton.cpp" + +DoubleClickableRadioButton::DoubleClickableRadioButton (QWidget * parent) + : QRadioButton {parent} +{ +} + +void DoubleClickableRadioButton::mouseDoubleClickEvent (QMouseEvent * event) +{ + Q_EMIT doubleClicked (); + QRadioButton::mouseDoubleClickEvent (event); +} diff --git a/widgets/DoubleClickableRadioButton.hpp b/widgets/DoubleClickableRadioButton.hpp new file mode 100644 index 00000000..dec715ab --- /dev/null +++ b/widgets/DoubleClickableRadioButton.hpp @@ -0,0 +1,27 @@ +#ifndef DOUBLE_CLICKABLE_RADIO_BUTTON_HPP_ +#define DOUBLE_CLICKABLE_RADIO_BUTTON_HPP_ + +#include <QRadioButton> + +// +// DoubleClickableRadioButton - QRadioButton that emits a mouse double +// click signal +// +// Clients should be aware of the QWidget::mouseDoubleClickEvent() +// notes about receipt of mouse press and mouse release events. +// +class DoubleClickableRadioButton + : public QRadioButton +{ + Q_OBJECT + +public: + DoubleClickableRadioButton (QWidget * = nullptr); + + Q_SIGNAL void doubleClicked (); + +protected: + void mouseDoubleClickEvent (QMouseEvent *) override; +}; + +#endif diff --git a/widgets/ExportCabrillo.cpp b/widgets/ExportCabrillo.cpp new file mode 100644 index 00000000..0e61f0f0 --- /dev/null +++ b/widgets/ExportCabrillo.cpp @@ -0,0 +1,110 @@ +#include "ExportCabrillo.h" + +#include <QApplication> +#include <QFileDialog> +#include <QDir> +#include <QDebug> + +#include "SettingsGroup.hpp" +#include "Configuration.hpp" +#include "MessageBox.hpp" +#include "models/CabrilloLog.hpp" + +#include "ui_ExportCabrillo.h" + +ExportCabrillo::ExportCabrillo (QSettings * settings, Configuration const * configuration + , CabrilloLog const * log, QWidget * parent) + : QDialog {parent}, + settings_ {settings}, + configuration_ {configuration}, + log_ {log}, + ui {new Ui::ExportCabrillo} +{ + ui->setupUi (this); + read_settings (); + setWindowTitle (QApplication::applicationName() + " - Export Cabrillo"); + connect (ui->buttonBox, &QDialogButtonBox::accepted, this, &ExportCabrillo::save_log); +} + +ExportCabrillo::~ExportCabrillo () +{ + write_settings (); +} + +void ExportCabrillo::read_settings () +{ + SettingsGroup group {settings_, "ExportCabrillo"}; + restoreGeometry (settings_->value("window/geometry").toByteArray()); + ui->location_line_edit->setText(settings_->value("Location").toString()); + ui->contest_line_edit->setText(settings_->value("Contest").toString()); + ui->call_line_edit->setText(settings_->value("Callsign").toString()); + ui->category_op_line_edit->setText(settings_->value("Category-Operator").toString()); + ui->category_xmtr_line_edit->setText(settings_->value("Category-Transmitter").toString()); + ui->category_pwr_line_edit->setText(settings_->value("Category-Power").toString()); + ui->category_assisted_line_edit->setText(settings_->value("Category-Assisted").toString()); + ui->category_band_line_edit->setText(settings_->value("Category-Band").toString()); + ui->claimed_line_edit->setText(settings_->value("Claimed-Score").toString()); + ui->operators_line_edit->setText(settings_->value("Operators").toString()); + ui->club_line_edit->setText(settings_->value("Club").toString()); + ui->name_line_edit->setText(settings_->value("Name").toString()); + ui->addr_1_line_edit->setText(settings_->value("Address1").toString()); + ui->addr_2_line_edit->setText(settings_->value("Address2").toString()); +} + +void ExportCabrillo::write_settings () +{ + SettingsGroup group {settings_, "ExportCabrillo"}; + settings_->setValue ("window/geometry", saveGeometry ()); + settings_->setValue("Location",ui->location_line_edit->text()); + settings_->setValue("Contest",ui->contest_line_edit->text()); + settings_->setValue("Callsign",ui->call_line_edit->text()); + settings_->setValue("Category-Operator",ui->category_op_line_edit->text()); + settings_->setValue("Category-Transmitter",ui->category_xmtr_line_edit->text()); + settings_->setValue("Category-Power",ui->category_pwr_line_edit->text()); + settings_->setValue("Category-Assisted",ui->category_assisted_line_edit->text()); + settings_->setValue("Category-Band",ui->category_band_line_edit->text()); + settings_->setValue("Claimed-Score",ui->claimed_line_edit->text()); + settings_->setValue("Operators",ui->operators_line_edit->text()); + settings_->setValue("Club",ui->club_line_edit->text()); + settings_->setValue("Name",ui->name_line_edit->text()); + settings_->setValue("Address1",ui->addr_1_line_edit->text()); + settings_->setValue("Address2",ui->addr_2_line_edit->text()); +} + +void ExportCabrillo::save_log () +{ + auto fname = QFileDialog::getSaveFileName (this + , tr ("Save Log File") + , configuration_->writeable_data_dir ().absolutePath () + , tr ("Cabrillo Log (*.cbr)")); + if (fname.size ()) + { + QFile f {fname}; + if (f.open (QIODevice::WriteOnly | QIODevice::Text)) { + QTextStream out {&f}; + out << "START-OF-LOG:3.0\n" + << "LOCATION: " << ui->location_line_edit->text() << '\n' + << "CONTEST: " << ui->contest_line_edit->text() << '\n' + << "CALLSIGN: " << ui->call_line_edit->text() << '\n' + << "CATEGORY-OPERATOR: " << ui->category_op_line_edit->text() << '\n' + << "CATEGORY-TRANSMITTER: " << ui->category_xmtr_line_edit->text() << '\n' + << "CATEGORY-POWER: " << ui->category_pwr_line_edit->text() << '\n' + << "CATEGORY-ASSISTED: " << ui->category_assisted_line_edit->text() << '\n' + << "CATEGORY-BAND: " << ui->category_band_line_edit->text() << '\n' + << "CLAIMED-SCORE: " << ui->claimed_line_edit->text() << '\n' + << "OPERATORS: " << ui->operators_line_edit->text() << '\n' + << "CLUB: " << ui->club_line_edit->text() << '\n' + << "NAME: " << ui->name_line_edit->text() << '\n' + << "ADDRESS: " << ui->addr_1_line_edit->text() << '\n' + << "ADDRESS: " << ui->addr_2_line_edit->text() << '\n'; + if (log_) log_->export_qsos (out); + out << "END-OF-LOG:" << endl; + return; + } else { + auto const& message = tr ("Cannot open \"%1\" for writing: %2") + .arg (f.fileName ()).arg (f.errorString ()); + MessageBox::warning_message (this, tr ("Export Cabrillo File Error"), message); + } + } + setResult (Rejected); +} diff --git a/widgets/ExportCabrillo.h b/widgets/ExportCabrillo.h new file mode 100644 index 00000000..fbc9294c --- /dev/null +++ b/widgets/ExportCabrillo.h @@ -0,0 +1,34 @@ +// -*- Mode: C++ -*- +#ifndef EXPORTCABRILLO_H +#define EXPORTCABRILLO_H + +#include <QDialog> +#include <QScopedPointer> + +class QSettings; +class Configuration; +class CabrilloLog; +namespace Ui { + class ExportCabrillo; +} + +class ExportCabrillo final + : public QDialog +{ +public: + explicit ExportCabrillo (QSettings *, Configuration const * + , CabrilloLog const *, QWidget * parent = nullptr); + ~ExportCabrillo (); + +private: + void read_settings(); + void write_settings(); + void save_log (); + + QSettings * settings_; + Configuration const * configuration_; + CabrilloLog const * log_; + QScopedPointer<Ui::ExportCabrillo> ui; +}; + +#endif diff --git a/widgets/ExportCabrillo.ui b/widgets/ExportCabrillo.ui new file mode 100644 index 00000000..eddbab9c --- /dev/null +++ b/widgets/ExportCabrillo.ui @@ -0,0 +1,331 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ExportCabrillo</class> + <widget class="QDialog" name="ExportCabrillo"> + <property name="windowTitle"> + <string>Dialog</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QFormLayout" name="formLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="location_label"> + <property name="text"> + <string>Location:</string> + </property> + <property name="buddy"> + <cstring>location_line_edit</cstring> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="location_line_edit"> + <property name="text"> + <string>SNJ</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="contest_label"> + <property name="text"> + <string>Contest:</string> + </property> + <property name="buddy"> + <cstring>contest_line_edit</cstring> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="contest_line_edit"> + <property name="text"> + <string>ARRL-RTTY</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="call_label"> + <property name="text"> + <string>Callsign:</string> + </property> + <property name="buddy"> + <cstring>call_line_edit</cstring> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLineEdit" name="call_line_edit"> + <property name="text"> + <string/> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="category_op_label"> + <property name="text"> + <string>Category-Operator: </string> + </property> + <property name="buddy"> + <cstring>category_op_line_edit</cstring> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLineEdit" name="category_op_line_edit"> + <property name="text"> + <string>SINGLE-OP</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="category_xmtr_label"> + <property name="text"> + <string>Category-Transmitter:</string> + </property> + <property name="buddy"> + <cstring>category_xmtr_line_edit</cstring> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QLineEdit" name="category_xmtr_line_edit"> + <property name="text"> + <string>ONE</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QLabel" name="category_pwr_label"> + <property name="text"> + <string>Category-Power:</string> + </property> + <property name="buddy"> + <cstring>category_pwr_line_edit</cstring> + </property> + </widget> + </item> + <item row="5" column="1"> + <widget class="QLineEdit" name="category_pwr_line_edit"> + <property name="text"> + <string>LOW</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="6" column="0"> + <widget class="QLabel" name="category_assisted_label"> + <property name="text"> + <string>Category-Assisted:</string> + </property> + <property name="buddy"> + <cstring>category_assisted_line_edit</cstring> + </property> + </widget> + </item> + <item row="6" column="1"> + <widget class="QLineEdit" name="category_assisted_line_edit"> + <property name="text"> + <string>NON-ASSISTED</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="7" column="0"> + <widget class="QLabel" name="category_band_label"> + <property name="text"> + <string>Category-Band:</string> + </property> + <property name="buddy"> + <cstring>category_band_line_edit</cstring> + </property> + </widget> + </item> + <item row="7" column="1"> + <widget class="QLineEdit" name="category_band_line_edit"> + <property name="text"> + <string>ALL</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="8" column="0"> + <widget class="QLabel" name="claimed_label"> + <property name="text"> + <string>Claimed-Score:</string> + </property> + <property name="buddy"> + <cstring>claimed_line_edit</cstring> + </property> + </widget> + </item> + <item row="8" column="1"> + <widget class="QLineEdit" name="claimed_line_edit"> + <property name="text"> + <string/> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="9" column="0"> + <widget class="QLabel" name="operators_label"> + <property name="text"> + <string>Operators:</string> + </property> + <property name="buddy"> + <cstring>operators_line_edit</cstring> + </property> + </widget> + </item> + <item row="9" column="1"> + <widget class="QLineEdit" name="operators_line_edit"> + <property name="text"> + <string/> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="10" column="0"> + <widget class="QLabel" name="club_label"> + <property name="text"> + <string>Club:</string> + </property> + <property name="buddy"> + <cstring>club_line_edit</cstring> + </property> + </widget> + </item> + <item row="10" column="1"> + <widget class="QLineEdit" name="club_line_edit"> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="11" column="0"> + <widget class="QLabel" name="name_label"> + <property name="text"> + <string>Name:</string> + </property> + <property name="buddy"> + <cstring>name_line_edit</cstring> + </property> + </widget> + </item> + <item row="11" column="1"> + <widget class="QLineEdit" name="name_line_edit"> + <property name="text"> + <string/> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="12" column="0"> + <widget class="QLabel" name="addr_1_label"> + <property name="text"> + <string>Address:</string> + </property> + <property name="buddy"> + <cstring>addr_1_line_edit</cstring> + </property> + </widget> + </item> + <item row="12" column="1"> + <widget class="QLineEdit" name="addr_1_line_edit"> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="13" column="0"> + <widget class="QLabel" name="addr_2_label"> + <property name="text"> + <string>Address:</string> + </property> + <property name="buddy"> + <cstring>addr_2_line_edit</cstring> + </property> + </widget> + </item> + <item row="13" column="1"> + <widget class="QLineEdit" name="addr_2_line_edit"> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>ExportCabrillo</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>ExportCabrillo</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/widgets/FoxLogWindow.cpp b/widgets/FoxLogWindow.cpp new file mode 100644 index 00000000..4b8fbc25 --- /dev/null +++ b/widgets/FoxLogWindow.cpp @@ -0,0 +1,97 @@ +#include "FoxLogWindow.hpp" + +#include <QApplication> +#include <QSqlTableModel> +#include <QAction> +#include <QFile> +#include <QDir> + +#include "SettingsGroup.hpp" +#include "Configuration.hpp" +#include "MessageBox.hpp" +#include "models/Bands.hpp" +#include "item_delegates/ForeignKeyDelegate.hpp" +#include "item_delegates/DateTimeAsSecsSinceEpochDelegate.hpp" +#include "item_delegates/CallsignDelegate.hpp" +#include "item_delegates/MaidenheadLocatorDelegate.hpp" +#include "pimpl_impl.hpp" + +#include "ui_FoxLogWindow.h" +#include "moc_FoxLogWindow.cpp" + +class FoxLogWindow::impl final +{ +public: + explicit impl (QSqlTableModel * log_model) + : log_model_ {log_model} + { + } + + QSqlTableModel * log_model_; + Ui::FoxLogWindow ui_; +}; + +FoxLogWindow::FoxLogWindow (QSettings * settings, Configuration const * configuration + , QSqlTableModel * fox_log_model, QWidget * parent) + : AbstractLogWindow {"Fox Log Window", settings, configuration, parent} + , m_ {fox_log_model} +{ + setWindowTitle (QApplication::applicationName () + " - Fox Log"); + m_->ui_.setupUi (this); + m_->ui_.log_table_view->setModel (m_->log_model_); + set_log_view (m_->ui_.log_table_view); + m_->ui_.log_table_view->setItemDelegateForColumn (1, new DateTimeAsSecsSinceEpochDelegate {this}); + m_->ui_.log_table_view->setItemDelegateForColumn (2, new CallsignDelegate {this}); + m_->ui_.log_table_view->setItemDelegateForColumn (3, new MaidenheadLocatorDelegate {this}); + m_->ui_.log_table_view->setItemDelegateForColumn (6, new ForeignKeyDelegate {configuration->bands (), 0, this}); + m_->ui_.log_table_view->horizontalHeader ()->moveSection (6, 1); // move band to first column + m_->ui_.rate_label->setNum (0); + m_->ui_.queued_label->setNum (0); + m_->ui_.callers_label->setNum (0); + + // actions + auto reset_action = new QAction {tr ("&Reset ..."), m_->ui_.log_table_view}; + m_->ui_.log_table_view->insertAction (nullptr, reset_action); + connect (reset_action, &QAction::triggered, [this, configuration] (bool /*checked*/) { + if (MessageBox::Yes == MessageBox::query_message( this + , tr ("Confirm Reset") + , tr ("Are you sure you want to erase file FoxQSO.txt " + "and start a new Fox log?"))) + { + QFile f{configuration->writeable_data_dir ().absoluteFilePath ("FoxQSO.txt")}; + f.remove (); + Q_EMIT reset_log_model (); + } + }); +} + +FoxLogWindow::~FoxLogWindow () +{ +} + +void FoxLogWindow::callers (int n) +{ + m_->ui_.callers_label->setNum (n); +} + +void FoxLogWindow::queued (int n) +{ + m_->ui_.queued_label->setNum (n); +} + +void FoxLogWindow::rate (int n) +{ + m_->ui_.rate_label->setNum (n); +} + +void FoxLogWindow::log_model_changed (int row) +{ + if (row >= 0) + { + m_->log_model_->selectRow (row); + } + else + { + m_->log_model_->select (); + } +} diff --git a/widgets/FoxLogWindow.hpp b/widgets/FoxLogWindow.hpp new file mode 100644 index 00000000..65bcb0bd --- /dev/null +++ b/widgets/FoxLogWindow.hpp @@ -0,0 +1,35 @@ +#ifndef FOX_LOG_WINDOW_HPP_ +#define FOX_LOG_WINDOW_HPP_ + +#include "AbstractLogWindow.hpp" +#include "pimpl_h.hpp" + +class QSettings; +class Configuration; +class QFont; +class QSqlTableModel; + +class FoxLogWindow final + : public AbstractLogWindow +{ + Q_OBJECT + +public: + explicit FoxLogWindow (QSettings *, Configuration const *, QSqlTableModel * fox_log_model + , QWidget * parent = nullptr); + ~FoxLogWindow (); + + void callers (int); + void queued (int); + void rate (int); + + Q_SIGNAL void reset_log_model () const; + +private: + void log_model_changed (int row) override; + + class impl; + pimpl<impl> m_; +}; + +#endif diff --git a/widgets/FoxLogWindow.ui b/widgets/FoxLogWindow.ui new file mode 100644 index 00000000..cd224ed3 --- /dev/null +++ b/widgets/FoxLogWindow.ui @@ -0,0 +1,122 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>FoxLogWindow</class> + <widget class="QWidget" name="FoxLogWindow"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>453</width> + <height>238</height> + </rect> + </property> + <property name="contextMenuPolicy"> + <enum>Qt::DefaultContextMenu</enum> + </property> + <property name="windowTitle"> + <string>Fox Log</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QTableView" name="log_table_view"> + <property name="contextMenuPolicy"> + <enum>Qt::ActionsContextMenu</enum> + </property> + <property name="toolTip"> + <string><html><head/><body><p>Right-click here for available actions.</p></body></html></string> + </property> + <attribute name="horizontalHeaderStretchLastSection"> + <bool>true</bool> + </attribute> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Callers:</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="callers_label"> + <property name="text"> + <string>N</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>In progress:</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="queued_label"> + <property name="text"> + <string>N</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Rate:</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="rate_label"> + <property name="text"> + <string>N</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/widgets/FrequencyLineEdit.cpp b/widgets/FrequencyLineEdit.cpp new file mode 100644 index 00000000..78f8b2e1 --- /dev/null +++ b/widgets/FrequencyLineEdit.cpp @@ -0,0 +1,71 @@ +#include "FrequencyLineEdit.hpp" + +#include <limits> + +#include <QDoubleValidator> +#include <QString> +#include <QLocale> + +#include "moc_FrequencyLineEdit.cpp" + +namespace +{ + class MHzValidator + : public QDoubleValidator + { + public: + MHzValidator (double bottom, double top, QObject * parent = nullptr) + : QDoubleValidator {bottom, top, 6, parent} + { + } + + State validate (QString& input, int& pos) const override + { + State result = QDoubleValidator::validate (input, pos); + if (Acceptable == result) + { + bool ok; + (void)QLocale {}.toDouble (input, &ok); + if (!ok) + { + result = Intermediate; + } + } + return result; + } + }; +} + +FrequencyLineEdit::FrequencyLineEdit (QWidget * parent) + : QLineEdit (parent) +{ + setValidator (new MHzValidator {0., std::numeric_limits<Radio::Frequency>::max () / 10.e6, this}); +} + +auto FrequencyLineEdit::frequency () const -> Frequency +{ + return Radio::frequency (text (), 6); +} + +void FrequencyLineEdit::frequency (Frequency f) +{ + setText (Radio::frequency_MHz_string (f)); +} + + +FrequencyDeltaLineEdit::FrequencyDeltaLineEdit (QWidget * parent) + : QLineEdit (parent) +{ + setValidator (new MHzValidator {-std::numeric_limits<FrequencyDelta>::max () / 10.e6, + std::numeric_limits<FrequencyDelta>::max () / 10.e6, this}); +} + +auto FrequencyDeltaLineEdit::frequency_delta () const -> FrequencyDelta +{ + return Radio::frequency_delta (text (), 6); +} + +void FrequencyDeltaLineEdit::frequency_delta (FrequencyDelta d) +{ + setText (Radio::frequency_MHz_string (d)); +} diff --git a/widgets/FrequencyLineEdit.hpp b/widgets/FrequencyLineEdit.hpp new file mode 100644 index 00000000..dec0feb0 --- /dev/null +++ b/widgets/FrequencyLineEdit.hpp @@ -0,0 +1,45 @@ +#ifndef FREQUENCY_LINE_EDIT_HPP_ +#define FREQUENCY_LINE_EDIT_HPP_ + +#include <QLineEdit> + +#include "Radio.hpp" + +class QWidget; + +// +// MHz frequency line edits with validation +// +class FrequencyLineEdit final + : public QLineEdit +{ + Q_OBJECT; + Q_PROPERTY (Frequency frequency READ frequency WRITE frequency USER true); + +public: + using Frequency = Radio::Frequency; + + explicit FrequencyLineEdit (QWidget * parent = nullptr); + + // Property frequency implementation + Frequency frequency () const; + void frequency (Frequency); +}; + +class FrequencyDeltaLineEdit final + : public QLineEdit +{ + Q_OBJECT; + Q_PROPERTY (FrequencyDelta frequency_delta READ frequency_delta WRITE frequency_delta USER true); + +public: + using FrequencyDelta = Radio::FrequencyDelta; + + explicit FrequencyDeltaLineEdit (QWidget * parent = nullptr); + + // Property frequency_delta implementation + FrequencyDelta frequency_delta () const; + void frequency_delta (FrequencyDelta); +}; + +#endif diff --git a/widgets/HelpTextWindow.cpp b/widgets/HelpTextWindow.cpp new file mode 100644 index 00000000..98c2b38e --- /dev/null +++ b/widgets/HelpTextWindow.cpp @@ -0,0 +1,29 @@ +#include "HelpTextWindow.hpp" + +#include <QApplication> +#include <QString> +#include <QPalette> +#include <QFile> +#include <QTextStream> + +#include "qt_helpers.hpp" +#include "widgets/MessageBox.hpp" + +HelpTextWindow::HelpTextWindow (QString const& title, QString const& file_name, QFont const& font, QWidget * parent) + : QLabel {parent, Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint} +{ + QFile source {file_name}; + if (!source.open (QIODevice::ReadOnly | QIODevice::Text)) + { + MessageBox::warning_message (this, tr ("Help file error") + , tr ("Cannot open \"%1\" for reading").arg (source.fileName ()) + , tr ("Error: %1").arg (source.errorString ())); + return; + } + setText (QTextStream {&source}.readAll ()); + setWindowTitle(QApplication::applicationName () + " - " + title); + setMargin (10); + setBackgroundRole (QPalette::Base); + setAutoFillBackground (true); + setStyleSheet (font_as_stylesheet (font)); +} diff --git a/widgets/HelpTextWindow.hpp b/widgets/HelpTextWindow.hpp new file mode 100644 index 00000000..c5793ae9 --- /dev/null +++ b/widgets/HelpTextWindow.hpp @@ -0,0 +1,16 @@ +#ifndef HELP_TEXT_WINDOW_HPP__ +#define HELP_TEXT_WINDOW_HPP__ + +#include <QLabel> +#include <QFont> + +class QString; + +class HelpTextWindow final + : public QLabel +{ +public: + HelpTextWindow (QString const& title, QString const& file_name, QFont const& = QFont {}, QWidget * parent = nullptr); +}; + +#endif diff --git a/widgets/HintedSpinBox.cpp b/widgets/HintedSpinBox.cpp new file mode 100644 index 00000000..25ffcc71 --- /dev/null +++ b/widgets/HintedSpinBox.cpp @@ -0,0 +1,55 @@ +#include "HintedSpinBox.hpp" + +#include <algorithm> + +auto HintedSpinBox::values (values_type values, bool set_min_max) -> values_type +{ + // replace any prior values + std::swap (values, values_); + + // sort values and make unique + std::sort (values_.begin (), values_.end ()); + auto last = std::unique (values_.begin (), values_.end ()); + values_.erase (last, values_.end ()); + if (set_min_max) + { + setMinimum (values_.front ()); + setMaximum (values_.back ()); + } + return values; // return old values +} + +void HintedSpinBox::stepBy (int steps) +{ + if (values_.size ()) + { + if (steps > 0) + { + auto p = std::upper_bound (values_.begin (), values_.end (), value ()); + if (p != values_.end () && *p <= maximum ()) + { + setValue (*p); + } + else if (wrapping ()) + { + setValue (values_.front ()); + } + } + else if (steps < 0) + { + auto p = std::lower_bound (values_.begin (), values_.end (), value ()); + if (p != values_.begin () && *(p - 1) >= minimum ()) + { + setValue (*(p - 1)); + } + else if (wrapping ()) + { + setValue (values_.back ()); + } + } + } + else + { + QSpinBox::stepBy (steps); // no values so revert to QSpinBox behaviour + } +} diff --git a/widgets/HintedSpinBox.hpp b/widgets/HintedSpinBox.hpp new file mode 100644 index 00000000..8498b29e --- /dev/null +++ b/widgets/HintedSpinBox.hpp @@ -0,0 +1,53 @@ +#ifndef HINTED_SPIN_BOX_HPP_ +#define HINTED_SPIN_BOX_HPP_ + +#include <vector> + +#include <QSpinBox> + +// +// HintedSpinBox - QSpinBox refinement with an optional sequence of +// discrete hints +// +// The hint sequence values are used as step values and can +// optionally define the minimum and maximum value. Intermediate +// values are allowed but the step up/down arrows and accelerator +// keys will only use the hints. +// +// Ensure that the default minimum and maximum values are sufficient +// to allow initial initialization if done before the hints are set. +// +class HintedSpinBox + : public QSpinBox +{ +public: + typedef std::vector<int> values_type; + + HintedSpinBox (QWidget * parent = nullptr) + : QSpinBox {parent} + { + } + + // Initialize sequence of values allowed. + // + // This spin box behaves exactly as a standard QSpinBox if the + // sequence of values is empty. + // + // The minimum and maximum are automatically set to the lowest and + // highest value provided if required. + // + // Returns the previous sequence. + values_type values (values_type values, bool set_min_max = true); + + // Read access to the values. + values_type const& values () const {return values_;} + +protected: + // override the QSpinBox stepping + void stepBy (int steps) override; + +private: + values_type values_; +}; + +#endif diff --git a/widgets/LettersSpinBox.cpp b/widgets/LettersSpinBox.cpp new file mode 100644 index 00000000..9079d8d9 --- /dev/null +++ b/widgets/LettersSpinBox.cpp @@ -0,0 +1,25 @@ +#include "LettersSpinBox.hpp" + +#include <QString> +#include "moc_LettersSpinBox.cpp" + +QString LettersSpinBox::textFromValue (int value) const +{ + QString text; + do { + auto digit = value % 26; + value /= 26; + text = QChar {lowercase_ ? 'a' + digit : 'A' + digit} + text; + } while (value); + return text; +} + +int LettersSpinBox::valueFromText (QString const& text) const +{ + int value {0}; + for (int index = text.size (); index > 0; --index) + { + value = value * 26 + text[index - 1].toLatin1 () - (lowercase_ ? 'a' : 'A'); + } + return value; +} diff --git a/widgets/LettersSpinBox.hpp b/widgets/LettersSpinBox.hpp new file mode 100644 index 00000000..aaa37d7f --- /dev/null +++ b/widgets/LettersSpinBox.hpp @@ -0,0 +1,31 @@ +#ifndef LETTERS_SPIN_BOX_HPP_ +#define LETTERS_SPIN_BOX_HPP_ + +#include <QSpinBox> + +class QString; + +// +// LettersSpinBox - select from consecutive letters +// +class LettersSpinBox final + : public QSpinBox +{ + Q_OBJECT + Q_PROPERTY (bool lowercase MEMBER lowercase_) + +public: + LettersSpinBox (QWidget * parent = nullptr) + : QSpinBox {parent} + , lowercase_ {false} + { + } + + QString textFromValue (int) const override; + int valueFromText (QString const&) const override; + +private: + bool lowercase_; +}; + +#endif diff --git a/widgets/MessageBox.cpp b/widgets/MessageBox.cpp new file mode 100644 index 00000000..7c6f0513 --- /dev/null +++ b/widgets/MessageBox.cpp @@ -0,0 +1,102 @@ +#include "MessageBox.hpp" + +#include <QDialogButtonBox> +#include <QPushButton> +#include <QCoreApplication> + +#include "revision_utils.hpp" + +MessageBox::MessageBox (QWidget * parent) + : QMessageBox {parent} +{ + setWindowTitle (program_title ()); +} + +MessageBox::MessageBox (Icon icon, QString const& text, StandardButtons buttons + , QWidget * parent, Qt::WindowFlags flags) + : QMessageBox {icon, QCoreApplication::applicationName (), text, buttons, parent, flags} +{ +} + +void MessageBox::about_message (QWidget * parent, QString const& text) +{ + QMessageBox::about (parent, program_title (), text); +} + +void MessageBox::about_Qt_message (QWidget * parent) +{ + QMessageBox::aboutQt (parent, program_title ()); +} + +namespace +{ + QMessageBox::StandardButton show_it (QWidget * parent, MessageBox::Icon icon + , QString const& text + , QString const& informative + , QString const& detail + , MessageBox::StandardButtons buttons + , MessageBox::StandardButton default_button) + { + MessageBox mb {icon, text, MessageBox::NoButton, parent}; + QDialogButtonBox * button_box = mb.findChild<QDialogButtonBox *> (); + Q_ASSERT (button_box); + + uint mask = MessageBox::FirstButton; + while (mask <= MessageBox::LastButton) { + uint sb = buttons & mask; + mask <<= 1; + if (!sb) + continue; + QPushButton * button = mb.addButton (static_cast<MessageBox::StandardButton> (sb)); + // Choose the first accept role as the default + if (mb.defaultButton ()) + continue; + if ((default_button == MessageBox::NoButton + && button_box->buttonRole (button) == QDialogButtonBox::AcceptRole) + || (default_button != MessageBox::NoButton + && sb == static_cast<uint> (default_button))) + mb.setDefaultButton (button); + } + mb.setInformativeText (informative); + mb.setDetailedText (detail); + if (mb.exec() == -1) + return MessageBox::Cancel; + return mb.standardButton (mb.clickedButton ()); + } +} + +auto MessageBox::information_message (QWidget * parent, QString const& text + , QString const& informative + , QString const& detail + , StandardButtons buttons + , StandardButton default_button) -> StandardButton +{ + return show_it (parent, Information, text, informative, detail, buttons, default_button); +} + +auto MessageBox::query_message (QWidget * parent, QString const& text + , QString const& informative + , QString const& detail + , StandardButtons buttons + , StandardButton default_button) -> StandardButton +{ + return show_it (parent, Question, text, informative, detail, buttons, default_button); +} + +auto MessageBox::warning_message (QWidget * parent, QString const& text + , QString const& informative + , QString const& detail + , StandardButtons buttons + , StandardButton default_button) -> StandardButton +{ + return show_it (parent, Warning, text, informative, detail, buttons, default_button); +} + +auto MessageBox::critical_message (QWidget * parent, QString const& text + , QString const& informative + , QString const& detail + , StandardButtons buttons + , StandardButton default_button) -> StandardButton +{ + return show_it (parent, Critical, text, informative, detail, buttons, default_button); +} diff --git a/widgets/MessageBox.hpp b/widgets/MessageBox.hpp new file mode 100644 index 00000000..7290b73a --- /dev/null +++ b/widgets/MessageBox.hpp @@ -0,0 +1,58 @@ +#ifndef MESSAGE_BOX_HPP__ +#define MESSAGE_BOX_HPP__ + +#include <QMessageBox> + +// get rid of the nasty MS define +#ifdef MessageBox +#undef MessageBox +#endif + +// +// MessageBox - wrap the Qt QMessageBox class to give a more platform +// neutral and functional interface +// +class MessageBox + : public QMessageBox +{ +public: + explicit MessageBox (QWidget * parent = nullptr); + explicit MessageBox (Icon, QString const& text, StandardButtons = NoButton + , QWidget * parent = nullptr + , Qt::WindowFlags = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint); + + static void about_message (QWidget * parent, QString const& text); + static void about_Qt_message (QWidget * parent); + static StandardButton information_message (QWidget * parent, QString const& text + , QString const& informative = QString {} + , QString const& detail = QString {} + , StandardButtons buttons = Ok + , StandardButton default_button = NoButton); + static StandardButton query_message (QWidget * parent, QString const& text + , QString const& informative = QString {} + , QString const& detail = QString {} + , StandardButtons buttons = Yes | No + , StandardButton default_button = NoButton); + static StandardButton warning_message (QWidget * parent, QString const& text + , QString const& informative = QString {} + , QString const& detail = QString {} + , StandardButtons buttons = Ok + , StandardButton default_button = NoButton); + static StandardButton critical_message (QWidget * parent, QString const& text + , QString const& informative = QString {} + , QString const& detail = QString {} + , StandardButtons buttons = Ok + , StandardButton default_button = NoButton); +private: + // hide the parent static functions so that users use our versions + // above that are correctly branded and have better platform + // independence + using QMessageBox::about; + using QMessageBox::aboutQt; + using QMessageBox::information; + using QMessageBox::question; + using QMessageBox::warning; + using QMessageBox::critical; +}; + +#endif diff --git a/widgets/RestrictedSpinBox.cpp b/widgets/RestrictedSpinBox.cpp new file mode 100644 index 00000000..d3201b33 --- /dev/null +++ b/widgets/RestrictedSpinBox.cpp @@ -0,0 +1,19 @@ +#include "RestrictedSpinBox.hpp" + +#include <algorithm> +#include <utility> + +#include <QString> + +QValidator::State RestrictedSpinBox::validate (QString& input, int& pos) const +{ + // start by doing the standard QSpinBox validation + auto valid = HintedSpinBox::validate (input, pos); + // extra validation + if (QValidator::Acceptable + && values ().end () == std::find (values ().begin (), values ().end (), valueFromText (input))) + { + valid = QValidator::Intermediate; + } + return valid; +} diff --git a/widgets/RestrictedSpinBox.hpp b/widgets/RestrictedSpinBox.hpp new file mode 100644 index 00000000..f856e90c --- /dev/null +++ b/widgets/RestrictedSpinBox.hpp @@ -0,0 +1,25 @@ +#ifndef RESTRICTED_SPIN_BOX_HPP_ +#define RESTRICTED_SPIN_BOX_HPP_ + +#include "HintedSpinBox.hpp" + +class QString; + +// +// RestrictedSpinBox - select only from a sequence of values +// +class RestrictedSpinBox final + : public HintedSpinBox +{ +public: + RestrictedSpinBox (QWidget * parent = nullptr) + : HintedSpinBox {parent} + { + } + +protected: + // override the base class validation + QValidator::State validate (QString& input, int& pos) const override; +}; + +#endif diff --git a/widgets/SplashScreen.cpp b/widgets/SplashScreen.cpp new file mode 100644 index 00000000..42f82877 --- /dev/null +++ b/widgets/SplashScreen.cpp @@ -0,0 +1,48 @@ +#include "SplashScreen.hpp" + +#include <QPixmap> +#include <QVBoxLayout> +#include <QCheckBox> +#include <QCoreApplication> + +#include "revision_utils.hpp" +#include "pimpl_impl.hpp" + +#include "moc_SplashScreen.cpp" + +class SplashScreen::impl +{ +public: + impl () + : checkbox_ {"Do not show this again"} + { + main_layout_.addStretch (); + main_layout_.addWidget (&checkbox_, 0, Qt::AlignRight); + } + + QVBoxLayout main_layout_; + QCheckBox checkbox_; +}; + +SplashScreen::SplashScreen () + : QSplashScreen {QPixmap {":/splash.png"}, Qt::WindowStaysOnTopHint} +{ + setLayout (&m_->main_layout_); + showMessage ("<h2>" + QString {"WSJT-X v" + + QCoreApplication::applicationVersion() + " " + + revision ()}.simplified () + "</h2>" + "V2.0 has many new features.<br /><br />" + "The release notes have more details.<br /><br />" + "Send issue reports to wsjtgroup@yahoogroups.com, and be sure to save .wav<br />" + "files where appropriate.<br /><br />" + "<b>Open the Help menu and select Release Notes for more details.</b><br />" + "<img src=\":/icon_128x128.png\" />" + "<img src=\":/gpl-v3-logo.svg\" height=\"80\" />", Qt::AlignCenter); + connect (&m_->checkbox_, &QCheckBox::stateChanged, [this] (int s) { + if (Qt::Checked == s) Q_EMIT disabled (); + }); +} + +SplashScreen::~SplashScreen () +{ +} diff --git a/widgets/SplashScreen.hpp b/widgets/SplashScreen.hpp new file mode 100644 index 00000000..2ec3238c --- /dev/null +++ b/widgets/SplashScreen.hpp @@ -0,0 +1,24 @@ +#ifndef SPLASH_SCREEN_HPP___ +#define SPLASH_SCREEN_HPP___ + +#include <QSplashScreen> + +#include "pimpl_h.hpp" + +class SplashScreen final + : public QSplashScreen +{ + Q_OBJECT + +public: + SplashScreen (); + ~SplashScreen (); + + Q_SIGNAL void disabled (); + +private: + class impl; + pimpl<impl> m_; +}; + +#endif diff --git a/widgets/about.cpp b/widgets/about.cpp new file mode 100644 index 00000000..f0b51a77 --- /dev/null +++ b/widgets/about.cpp @@ -0,0 +1,37 @@ +#include "about.h" + +#include <QCoreApplication> +#include <QString> + +#include "revision_utils.hpp" + +#include "ui_about.h" + +CAboutDlg::CAboutDlg(QWidget *parent) : + QDialog(parent), + ui(new Ui::CAboutDlg) +{ + ui->setupUi(this); + + ui->labelTxt->setText ("<h2>" + QString {"WSJT-X v" + + QCoreApplication::applicationVersion () + + " " + revision ()}.simplified () + "</h2><br />" + "WSJT-X implements a number of digital modes designed for <br />" + "weak-signal Amateur Radio communication. <br /><br />" + "© 2001-2018 by Joe Taylor, K1JT, with grateful <br />" + "acknowledgment for contributions from AC6SL, AE4JY, <br />" + "DJ0OT, G3WDG, G4KLA, G4WJS, IV3NWV, IW3RAB, K3WYC, K9AN, <br />" + "KA6MAL, KA9Q, KB1ZMX, KD6EKQ, KI7MT, KK1D, ND0B, PY2SDR, <br />" + "VE1SKY, VK3ACF, VK4BDJ, VK7MO, W4TI, W4TV, and W9MDB.<br /><br />" + "WSJT-X is licensed under the terms of Version 3 <br />" + "of the GNU General Public License (GPL) <br />" + "<a href=" WSJTX_STRINGIZE (PROJECT_HOMEPAGE) ">" + "<img src=\":/icon_128x128.png\" /></a>" + "<a href=\"https://www.gnu.org/licenses/gpl-3.0.txt\">" + "<img src=\":/gpl-v3-logo.svg\" height=\"80\" /><br />" + "https://www.gnu.org/licenses/gpl-3.0.txt</a>"); +} + +CAboutDlg::~CAboutDlg() +{ +} diff --git a/widgets/about.h b/widgets/about.h new file mode 100644 index 00000000..460b7eff --- /dev/null +++ b/widgets/about.h @@ -0,0 +1,23 @@ +// -*- Mode: C++ -*- +#ifndef ABOUTDLG_H +#define ABOUTDLG_H + +#include <QDialog> +#include <QScopedPointer> + +namespace Ui { + class CAboutDlg; +} + +class CAboutDlg + : public QDialog +{ +public: + explicit CAboutDlg(QWidget *parent = nullptr); + ~CAboutDlg (); + +private: + QScopedPointer<Ui::CAboutDlg> ui; +}; + +#endif // ABOUTDLG_H diff --git a/widgets/about.ui b/widgets/about.ui new file mode 100644 index 00000000..84157c4d --- /dev/null +++ b/widgets/about.ui @@ -0,0 +1,100 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>CAboutDlg</class> + <widget class="QDialog" name="CAboutDlg"> + <property name="windowModality"> + <enum>Qt::NonModal</enum> + </property> + <property name="windowTitle"> + <string>About WSJT-X</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QLabel" name="labelTxt"> + <property name="text"> + <string/> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="openExternalLinks"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="okButton"> + <property name="text"> + <string>OK</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>okButton</sender> + <signal>clicked()</signal> + <receiver>CAboutDlg</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>321</x> + <y>120</y> + </hint> + <hint type="destinationlabel"> + <x>186</x> + <y>71</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/widgets/astro.cpp b/widgets/astro.cpp new file mode 100644 index 00000000..4ee55da4 --- /dev/null +++ b/widgets/astro.cpp @@ -0,0 +1,340 @@ +#include "astro.h" + +#include <stdio.h> + +#include <QApplication> +#include <QFile> +#include <QTextStream> +#include <QSettings> +#include <QDateTime> +#include <QTimeZone> +#include <QDir> +#include <QCloseEvent> +#include <QDebug> + +#include "commons.h" +#include "MessageBox.hpp" +#include "Configuration.hpp" +#include "SettingsGroup.hpp" +#include "qt_helpers.hpp" + +#include "ui_astro.h" +#include "moc_astro.cpp" + + +extern "C" { + void astrosub_(int* nyear, int* month, int* nday, double* uth, double* freqMoon, + 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, double* width1, double* width2, + bool* bTx, const char* AzElFileName, const char* jpleph, + fortran_charlen_t, fortran_charlen_t, fortran_charlen_t, fortran_charlen_t); +} + +Astro::Astro(QSettings * settings, Configuration const * configuration, QWidget * parent) + : QDialog {parent, Qt::WindowTitleHint} + , settings_ {settings} + , configuration_ {configuration} + , ui_ {new Ui::Astro} + , m_DopplerMethod {0} + , m_dop {0} + , m_dop00 {0} + , m_dx_two_way_dop {0} +{ + ui_->setupUi (this); + setWindowTitle (QApplication::applicationName () + " - " + tr ("Astronomical Data")); + setStyleSheet ("QWidget {background: white;}"); + connect (ui_->cbDopplerTracking, &QAbstractButton::toggled, ui_->doppler_widget, &QWidget::setVisible); + read_settings (); + ui_->text_label->clear (); +} + +Astro::~Astro () +{ + ui_->cbDopplerTracking->setChecked (false); + Q_EMIT tracking_update (); + if (isVisible ()) write_settings (); +} + +void Astro::closeEvent (QCloseEvent * e) +{ + write_settings (); + e->ignore (); // do not allow closure by the window system +} + +void Astro::read_settings () +{ + SettingsGroup g (settings_, "Astro"); + ui_->doppler_widget->setVisible (ui_->cbDopplerTracking->isChecked ()); + m_DopplerMethod=settings_->value("DopplerMethod",0).toInt(); + switch (m_DopplerMethod) + { + case 0: ui_->rbNoDoppler->setChecked (true); break; + case 1: ui_->rbFullTrack->setChecked (true); break; + case 2: ui_->rbConstFreqOnMoon->setChecked (true); break; + case 3: ui_->rbOwnEcho->setChecked (true); break; + case 4: ui_->rbOnDxEcho->setChecked (true); break; + case 5: ui_->rbCallDx->setChecked (true); break; + } + move (settings_->value ("window/pos", pos ()).toPoint ()); +} + +void Astro::write_settings () +{ + SettingsGroup g (settings_, "Astro"); + //settings_->setValue ("DopplerTracking", ui_->cbDopplerTracking->isChecked ()); + settings_->setValue ("DopplerMethod",m_DopplerMethod); + settings_->setValue ("window/pos", pos ()); +} + +auto Astro::astroUpdate(QDateTime const& t, QString const& mygrid, QString const& hisgrid, Frequency freq, + bool dx_is_self, bool bTx, bool no_tx_QSY, int TR_period) -> Correction +{ + Frequency freq_moon {freq}; + double azsun,elsun,azmoon,elmoon,azmoondx,elmoondx; + double ramoon,decmoon,dgrd,poloffset,xnr,techo,width1,width2; + int ntsky; + 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()}; + double uth {nhr + nmin/60.0 + sec/3600.0}; + if(freq_moon < 1) freq_moon = 144000000; + int nfreq {static_cast<int> (freq_moon / 1000000u)}; + double freq8 {static_cast<double> (freq_moon)}; + auto const& AzElFileName = QDir::toNativeSeparators (configuration_->azel_directory ().absoluteFilePath ("azel.dat")); + auto const& jpleph = configuration_->data_dir ().absoluteFilePath ("JPLEPH"); + + + + + QString mygrid_padded {(mygrid + " ").left (6)}; + QString hisgrid_padded {(hisgrid + " ").left (6)}; + astrosub_(&nyear, &month, &nday, &uth, &freq8, mygrid_padded.toLatin1().constData(), + hisgrid_padded.toLatin1().constData(), &azsun, &elsun, &azmoon, &elmoon, + &azmoondx, &elmoondx, &ntsky, &m_dop, &m_dop00, &ramoon, &decmoon, + &dgrd, &poloffset, &xnr, &techo, &width1, &width2, &bTx, + AzElFileName.toLatin1().constData(), jpleph.toLatin1().constData(), 6, 6, + AzElFileName.length(), jpleph.length()); + + if(hisgrid_padded==" ") { + azmoondx=0.0; + elmoondx=0.0; + m_dop=0; + width2=0.0; + } + QString message; + { + QTextStream out {&message}; + out << " " << date << "\n" + "UTC: " << utc << "\n" + << fixed + << qSetFieldWidth (6) + << qSetRealNumberPrecision (1) + << "Az: " << azmoon << "\n" + "El: " << elmoon << "\n" + "SelfDop:" << m_dop00 << "\n" + "Width: " << int(width1) << "\n" + << qSetRealNumberPrecision (2) + << "Delay: " << techo << "\n" + << qSetRealNumberPrecision (1) + << "DxAz: " << azmoondx << "\n" + "DxEl: " << elmoondx << "\n" + "DxDop: " << m_dop << "\n" + "DxWid: " << int(width2) << "\n" + "Dec: " << decmoon << "\n" + "SunAz: " << azsun << "\n" + "SunEl: " << elsun << "\n" + "Freq: " << nfreq << "\n"; + if(nfreq>=50) { //Suppress data not relevant below VHF + out << "Tsky: " << ntsky << "\n" + "Dpol: " << poloffset << "\n" + "MNR: " << xnr << "\n" + "Dgrd: " << dgrd; + } + } + ui_->text_label->setText(message); + + Correction correction; + if (ui_->cbDopplerTracking->isChecked ()) { + switch (m_DopplerMethod) + { + case 1: // All Doppler correction done here; DX station stays at nominal dial frequency. + correction.rx = m_dop; + break; + case 4: // All Doppler correction done here; DX station stays at nominal dial frequency. (Trial for OnDxEcho) + correction.rx = m_dop; + break; + //case 5: // All Doppler correction done here; DX station stays at nominal dial frequency. + + case 3: // Both stations do full correction on Rx and none on Tx + //correction.rx = dx_is_self ? m_dop00 : m_dop; + correction.rx = m_dop00; // Now always sets RX to *own* echo freq + break; + case 2: + // Doppler correction to constant frequency on Moon + correction.rx = m_dop00 / 2; + break; + + } + switch (m_DopplerMethod) + { + case 1: correction.tx = -correction.rx; + break; + case 2: correction.tx = -correction.rx; + break; + case 3: correction.tx = 0; + break; + case 4: // correction.tx = m_dop - m_dop00; + + correction.tx = m_dx_two_way_dop - m_dop; + qDebug () << "correction.tx:" << correction.tx; + break; + case 5: correction.tx = - m_dop00; + break; + } + //if (3 != m_DopplerMethod || 4 != m_DopplerMethod) correction.tx = -correction.rx; + + if(dx_is_self && m_DopplerMethod == 1) correction.rx = 0; + + if (no_tx_QSY && 3 != m_DopplerMethod && 0 != m_DopplerMethod) + { + // calculate a single correction for transmit half way through + // the period as a compromise for rigs that can't CAT QSY + // while transmitting + // + // use a base time of (secs-since-epoch + 2) so as to be sure + // we do the next period if we calculate just before it starts + auto sec_since_epoch = t.toMSecsSinceEpoch () / 1000 + 2; + auto target_sec = sec_since_epoch - sec_since_epoch % TR_period + TR_period / 2; + auto target_date_time = QDateTime::fromMSecsSinceEpoch (target_sec * 1000, Qt::UTC); + QString date {target_date_time.date().toString("yyyy MMM dd").trimmed ()}; + QString utc {target_date_time.time().toString().trimmed ()}; + int nyear {target_date_time.date().year()}; + int month {target_date_time.date().month()}; + int nday {target_date_time.date().day()}; + int nhr {target_date_time.time().hour()}; + int nmin {target_date_time.time().minute()}; + double sec {target_date_time.time().second() + 0.001*target_date_time.time().msec()}; + double uth {nhr + nmin/60.0 + sec/3600.0}; + astrosub_(&nyear, &month, &nday, &uth, &freq8, mygrid_padded.toLatin1().constData(), + hisgrid_padded.toLatin1().constData(), &azsun, &elsun, &azmoon, &elmoon, + &azmoondx, &elmoondx, &ntsky, &m_dop, &m_dop00, &ramoon, &decmoon, + &dgrd, &poloffset, &xnr, &techo, &width1, &width2, &bTx, + "", jpleph.toLatin1().constData(), 6, 6, + 0, jpleph.length()); + FrequencyDelta offset {0}; + switch (m_DopplerMethod) + { + case 1: + // All Doppler correction done here; DX station stays at nominal dial frequency. + offset = dx_is_self ? m_dop00 : m_dop; + break; + + case 2: + // Doppler correction to constant frequency on Moon + offset = m_dop00 / 2; + break; + + case 4: + // Doppler correction for OnDxEcho + offset = m_dop - m_dx_two_way_dop; + break; + + //case 5: correction.tx = - m_dop00; + case 5: offset = m_dop00;// version for _7 + break; + + + } + correction.tx = -offset; + qDebug () << "correction.tx (no tx qsy):" << correction.tx; + } + } + return correction; +} + +void Astro::check_split () +{ + if (doppler_tracking () && !configuration_->split_mode ()) + { + MessageBox::warning_message (this, tr ("Doppler Tracking Error"), + tr ("Split operating is required for Doppler tracking"), + tr ("Go to \"Menu->File->Settings->Radio\" to enable split operation")); + ui_->rbNoDoppler->click (); + } +} + +void Astro::on_rbFullTrack_clicked() +{ + m_DopplerMethod = 1; + check_split (); + Q_EMIT tracking_update (); +} + +void Astro::on_rbOnDxEcho_clicked(bool checked) +{ + m_DopplerMethod = 4; + check_split (); + if (checked) { + m_dx_two_way_dop = 2 * (m_dop - (m_dop00/2)); + qDebug () << "Starting Doppler:" << m_dx_two_way_dop; + } + Q_EMIT tracking_update (); +} + +void Astro::on_rbOwnEcho_clicked() +{ + m_DopplerMethod = 3; + check_split (); + Q_EMIT tracking_update (); +} + +void Astro::on_rbCallDx_clicked() +{ + m_DopplerMethod = 5; + check_split (); + Q_EMIT tracking_update (); +} + +void Astro::on_rbConstFreqOnMoon_clicked() +{ + m_DopplerMethod = 2; + check_split (); + Q_EMIT tracking_update (); +} + +void Astro::on_rbNoDoppler_clicked() +{ + m_DopplerMethod = 0; + Q_EMIT tracking_update (); +} + +bool Astro::doppler_tracking () const +{ + return ui_->cbDopplerTracking->isChecked () && m_DopplerMethod; +} + +void Astro::on_cbDopplerTracking_toggled(bool) +{ + check_split (); + Q_EMIT tracking_update (); +} + +void Astro::nominal_frequency (Frequency rx, Frequency tx) +{ + ui_->sked_frequency_label->setText (Radio::pretty_frequency_MHz_string (rx)); + ui_->sked_tx_frequency_label->setText (Radio::pretty_frequency_MHz_string (tx)); +} + +void Astro::hideEvent (QHideEvent * e) +{ + Q_EMIT tracking_update (); + QWidget::hideEvent (e); +} diff --git a/widgets/astro.h b/widgets/astro.h new file mode 100644 index 00000000..03d8c66c --- /dev/null +++ b/widgets/astro.h @@ -0,0 +1,93 @@ +// -*- Mode: C++ -*- +#ifndef ASTRO_H +#define ASTRO_H + +#include <QDialog> +#include <QScopedPointer> + +#include "Radio.hpp" + +class QSettings; +class Configuration; +namespace Ui { + class Astro; +} + +class Astro final + : public QDialog +{ + Q_OBJECT; + +public: + using Frequency = Radio::Frequency; + using FrequencyDelta = Radio::FrequencyDelta; + + explicit Astro(QSettings * settings, Configuration const *, QWidget * parent = nullptr); + ~Astro (); + + struct Correction + { + Correction () + : rx {0} + , tx {0} + {} + Correction (Correction const&) = default; + Correction& operator = (Correction const&) = default; + + FrequencyDelta rx; + FrequencyDelta tx; + }; + Correction astroUpdate(QDateTime const& t, + QString const& mygrid, + QString const& hisgrid, + Frequency frequency, + bool dx_is_self, + bool bTx, + bool no_tx_QSY, + int TR_period); + + bool doppler_tracking () const; + Q_SLOT void nominal_frequency (Frequency rx, Frequency tx); + Q_SIGNAL void tracking_update () const; + +protected: + void hideEvent (QHideEvent *) override; + void closeEvent (QCloseEvent *) override; + +private slots: + void on_rbConstFreqOnMoon_clicked(); + void on_rbFullTrack_clicked(); + void on_rbOwnEcho_clicked(); + void on_rbNoDoppler_clicked(); + void on_rbOnDxEcho_clicked(bool); + void on_rbCallDx_clicked(); + void on_cbDopplerTracking_toggled(bool); + +private: + void read_settings (); + void write_settings (); + void check_split (); + + QSettings * settings_; + Configuration const * configuration_; + QScopedPointer<Ui::Astro> ui_; + + qint32 m_DopplerMethod; + int m_dop; + int m_dop00; + int m_dx_two_way_dop; +}; + +inline +bool operator == (Astro::Correction const& lhs, Astro::Correction const& rhs) +{ + return lhs.rx == rhs.rx && lhs.tx == rhs.tx; +} + +inline +bool operator != (Astro::Correction const& lhs, Astro::Correction const& rhs) +{ + return !(lhs == rhs); +} + +#endif // ASTRO_H diff --git a/widgets/astro.ui b/widgets/astro.ui new file mode 100644 index 00000000..6bbb1574 --- /dev/null +++ b/widgets/astro.ui @@ -0,0 +1,272 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Astro</class> + <widget class="QWidget" name="Astro"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>359</width> + <height>342</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <layout class="QGridLayout" name="gridLayout"> + <property name="sizeConstraint"> + <enum>QLayout::SetFixedSize</enum> + </property> + <item row="0" column="1"> + <widget class="QWidget" name="doppler_widget" native="true"> + <property name="styleSheet"> + <string notr="true">* { + font-weight: normal; +}</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>Doppler tracking</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QRadioButton" name="rbFullTrack"> + <property name="toolTip"> + <string><html><head/><body><p>One station does all Doppler shift correction, their QSO partner receives and transmits on the sked frequency.</p><p>If the rig does not accept CAT QSY commands while transmitting a single correction is applied for the whole transmit period.</p></body></html></string> + </property> + <property name="text"> + <string>Full Doppler to DX Grid</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="rbOwnEcho"> + <property name="toolTip"> + <string><html><head/><body><p>Transmit takes place on sked frequency and receive frequency is corrected for own echoes. </p><p>This mode can be used for calling CQ, or when using Echo mode.</p></body></html></string> + </property> + <property name="text"> + <string>Own Echo</string> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="rbConstFreqOnMoon"> + <property name="toolTip"> + <string><html><head/><body><p>Both stations correct for Doppler shift such that they would be heard on the moon at the sked frequency.</p><p>If the rig does not accept CAT QSY commands while transmitting a single correction is applied for the whole transmit period.</p><p>Use this option also for Echo mode.</p></body></html></string> + </property> + <property name="text"> + <string>Constant frequency on Moon</string> + </property> + <property name="checked"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="rbOnDxEcho"> + <property name="toolTip"> + <string><html><head/><body><p>DX station announces their TX Freq, which is entered as the Sked Freq. Correction applied to RX and TX so you appear on the DX's station's own echo Freq.</p><p>If the rig does not accept CAT QSY commands while transmitting a single correction is applied for the whole transmit period.</p></body></html></string> + </property> + <property name="text"> + <string>On DX Echo</string> + </property> + <property name="checked"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="rbCallDx"> + <property name="toolTip"> + <string><html><head/><body><p>Tune radio manually and select this mode to put your echo on the same frequency.</p><p>If the rig does not accept CAT QSY commands while transmitting a single correction is applied for the whole transmit period.</p></body></html></string> + </property> + <property name="text"> + <string>Call DX</string> + </property> + <property name="checked"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="rbNoDoppler"> + <property name="toolTip"> + <string><html><head/><body><p>No Doppler shift correction is applied. This may be used when the QSO partner does full Doppler correction to your grid square.</p></body></html></string> + </property> + <property name="text"> + <string>None</string> + </property> + <property name="checked"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_3"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="title"> + <string>Sked frequency</string> + </property> + <layout class="QGridLayout" name="gridLayout_2" columnstretch="0,1"> + <item row="1" column="1"> + <widget class="QLabel" name="sked_tx_frequency_label"> + <property name="styleSheet"> + <string notr="true">* { + font-family: Courier; + font-size: 12pt; + font-weight: bold; +}</string> + </property> + <property name="text"> + <string>0</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="sked_frequency_label"> + <property name="styleSheet"> + <string notr="true">* { + font-family: Courier; + font-size: 12pt; + font-weight: bold; +}</string> + </property> + <property name="text"> + <string>0</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="styleSheet"> + <string notr="true">* { + font-family: Courier; + font-size: 12pt; + font-weight: bold; +}</string> + </property> + <property name="text"> + <string>Rx:</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_2"> + <property name="styleSheet"> + <string notr="true">* { + font-family: Courier; + font-size: 12pt; + font-weight: bold; +}</string> + </property> + <property name="text"> + <string>Tx:</string> + </property> + </widget> + </item> + <item row="2" column="0" colspan="2"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string><html><head/><body><p>Press and hold the CTRL key to adjust the sked frequency manually with the rig's VFO dial or enter frequency directly into the band entry field on the main window.</p></body></html></string> + </property> + <property name="textFormat"> + <enum>Qt::AutoText</enum> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + <item row="0" column="0"> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item alignment="Qt::AlignHCenter"> + <widget class="QLabel" name="text_label"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="styleSheet"> + <string notr="true">* { + font-family: Courier; + font-size: 12pt; + font-weight: bold; +}</string> + </property> + <property name="frameShadow"> + <enum>QFrame::Sunken</enum> + </property> + <property name="text"> + <string>Astro Data</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="margin"> + <number>6</number> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QCheckBox" name="cbDopplerTracking"> + <property name="styleSheet"> + <string notr="true"/> + </property> + <property name="text"> + <string>Doppler tracking</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/widgets/colorhighlighting.cpp b/widgets/colorhighlighting.cpp new file mode 100644 index 00000000..c5e2289e --- /dev/null +++ b/widgets/colorhighlighting.cpp @@ -0,0 +1,128 @@ +#include "colorhighlighting.h" + +#include <QApplication> +#include <QDebug> + +#include "SettingsGroup.hpp" +#include "models/DecodeHighlightingModel.hpp" + +#include "ui_colorhighlighting.h" +#include "moc_colorhighlighting.cpp" + +ColorHighlighting::ColorHighlighting (QSettings * settings, DecodeHighlightingModel const& highlight_model, QWidget * parent) + : QDialog {parent} + , ui {new Ui::ColorHighlighting} + , settings_ {settings} +{ + ui->setupUi(this); + setWindowTitle (QApplication::applicationName () + " - Colors"); + read_settings (); + set_items (highlight_model); +} + +ColorHighlighting::~ColorHighlighting() +{ + if (isVisible ()) write_settings (); +} + +void ColorHighlighting::read_settings () +{ + SettingsGroup group {settings_, "ColorScheme"}; + restoreGeometry (settings_->value ("window/geometry").toByteArray ()); +} + +void ColorHighlighting::write_settings () +{ + SettingsGroup group {settings_, "ColorScheme"}; + settings_->setValue ("window/geometry", saveGeometry ()); +} + +void ColorHighlighting::set_items (DecodeHighlightingModel const& highlighting_model) +{ + int index {0}; + for (auto const& item : highlighting_model.items ()) + { + QLabel * example; + QLabel * label; + switch (index++) + { + case 0: + example = ui->example1_label; + label = ui->p1_label; + break; + case 1: + example = ui->example2_label; + label = ui->p2_label; + break; + case 2: + example = ui->example3_label; + label = ui->p3_label; + break; + case 3: + example = ui->example4_label; + label = ui->p4_label; + break; + case 4: + example = ui->example5_label; + label = ui->p5_label; + break; + case 5: + example = ui->example6_label; + label = ui->p6_label; + break; + case 6: + example = ui->example7_label; + label = ui->p7_label; + break; + case 7: + example = ui->example8_label; + label = ui->p8_label; + break; + case 8: + example = ui->example9_label; + label = ui->p9_label; + break; + case 9: + example = ui->example10_label; + label = ui->p10_label; + break; + case 10: + example = ui->example11_label; + label = ui->p11_label; + break; + case 11: + example = ui->example12_label; + label = ui->p12_label; + break; + case 12: + example = ui->example13_label; + label = ui->p13_label; + break; + case 13: + example = ui->example14_label; + label = ui->p14_label; + break; + case 14: + example = ui->example15_label; + label = ui->p15_label; + break; + case 15: + example = ui->example16_label; + label = ui->p16_label; + break; + } + auto palette = example->parentWidget ()->palette (); + if (Qt::NoBrush != item.background_.style ()) + { + palette.setColor (QPalette::Window, item.background_.color ()); + } + if (Qt::NoBrush != item.foreground_.style ()) + { + palette.setColor (QPalette::WindowText, item.foreground_.color ()); + } + example->setPalette (palette); + example->setEnabled (item.enabled_); + label->setText (DecodeHighlightingModel::highlight_name (item.type_)); + label->setEnabled (item.enabled_); + } +} diff --git a/widgets/colorhighlighting.h b/widgets/colorhighlighting.h new file mode 100644 index 00000000..69e0391c --- /dev/null +++ b/widgets/colorhighlighting.h @@ -0,0 +1,33 @@ +#ifndef COLORHIGHLIGHTING_H_ +#define COLORHIGHLIGHTING_H_ + +#include <QDialog> +#include <QScopedPointer> + +class QSettings; +class DecodeHighlightingModel; + +namespace Ui { + class ColorHighlighting; +} + +class ColorHighlighting final +: public QDialog +{ + Q_OBJECT; + + public: + explicit ColorHighlighting(QSettings *, DecodeHighlightingModel const&, QWidget * parent = nullptr); + ~ColorHighlighting (); + + Q_SLOT void set_items (DecodeHighlightingModel const&); + + private: + void read_settings (); + void write_settings (); + + QScopedPointer<Ui::ColorHighlighting> ui; + QSettings * settings_; +}; + +#endif diff --git a/widgets/colorhighlighting.ui b/widgets/colorhighlighting.ui new file mode 100644 index 00000000..5242c402 --- /dev/null +++ b/widgets/colorhighlighting.ui @@ -0,0 +1,338 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ColorHighlighting</class> + <widget class="QDialog" name="ColorHighlighting"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>382</width> + <height>253</height> + </rect> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="1" column="0"> + <widget class="QLabel" name="example2_label"> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="text"> + <string>K1ABC</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="example1_label"> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="text"> + <string>K1ABC</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="p1_label"> + <property name="text"> + <string>CQ in message</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="example3_label"> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="text"> + <string>K1ABC</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLabel" name="p2_label"> + <property name="text"> + <string>My Call in message</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLabel" name="p3_label"> + <property name="text"> + <string>Transmitted message</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="example4_label"> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="text"> + <string>K1ABC</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLabel" name="p4_label"> + <property name="text"> + <string>New DXCC</string> + </property> + </widget> + </item> + <item row="5" column="1"> + <widget class="QLabel" name="p6_label"> + <property name="text"> + <string>New Grid</string> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QLabel" name="p5_label"> + <property name="text"> + <string>New DXCC on Band</string> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="example5_label"> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="text"> + <string>K1ABC</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QLabel" name="example6_label"> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="text"> + <string>K1ABC</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="6" column="0"> + <widget class="QLabel" name="example7_label"> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="text"> + <string>K1ABC</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="7" column="1"> + <widget class="QLabel" name="p8_label"> + <property name="text"> + <string>New Call</string> + </property> + </widget> + </item> + <item row="6" column="1"> + <widget class="QLabel" name="p7_label"> + <property name="text"> + <string>New Grid on Band</string> + </property> + </widget> + </item> + <item row="7" column="0"> + <widget class="QLabel" name="example8_label"> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="text"> + <string>K1ABC</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QLabel" name="example9_label"> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="text"> + <string>K1ABC</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QLabel" name="example10_label"> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="text"> + <string>K1ABC</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="0" column="3"> + <widget class="QLabel" name="p9_label"> + <property name="text"> + <string>New Call on Band</string> + </property> + </widget> + </item> + <item row="1" column="3"> + <widget class="QLabel" name="p10_label"> + <property name="text"> + <string>Uploads to LotW</string> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QLabel" name="example11_label"> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="text"> + <string>K1ABC</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QLabel" name="example12_label"> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="text"> + <string>K1ABC</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="4" column="2"> + <widget class="QLabel" name="example13_label"> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="text"> + <string>K1ABC</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="5" column="2"> + <widget class="QLabel" name="example14_label"> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="text"> + <string>K1ABC</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="6" column="2"> + <widget class="QLabel" name="example15_label"> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="text"> + <string>K1ABC</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="7" column="2"> + <widget class="QLabel" name="example16_label"> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="text"> + <string>K1ABC</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="2" column="3"> + <widget class="QLabel" name="p11_label"> + <property name="text"> + <string>New Continent</string> + </property> + </widget> + </item> + <item row="3" column="3"> + <widget class="QLabel" name="p12_label"> + <property name="text"> + <string>New Continent on Band</string> + </property> + </widget> + </item> + <item row="4" column="3"> + <widget class="QLabel" name="p13_label"> + <property name="text"> + <string>New CQ Zone</string> + </property> + </widget> + </item> + <item row="5" column="3"> + <widget class="QLabel" name="p14_label"> + <property name="text"> + <string>New CQ Zone on Band</string> + </property> + </widget> + </item> + <item row="6" column="3"> + <widget class="QLabel" name="p15_label"> + <property name="text"> + <string>New ITU Zone</string> + </property> + </widget> + </item> + <item row="7" column="3"> + <widget class="QLabel" name="p16_label"> + <property name="text"> + <string>New ITU Zone on Band</string> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/widgets/displaytext.cpp b/widgets/displaytext.cpp new file mode 100644 index 00000000..73df8af6 --- /dev/null +++ b/widgets/displaytext.cpp @@ -0,0 +1,541 @@ +#include "displaytext.h" + +#include <vector> +#include <algorithm> + +#include <QMouseEvent> +#include <QDateTime> +#include <QTextCharFormat> +#include <QTextCursor> +#include <QTextBlock> +#include <QMenu> +#include <QAction> +#include <QListIterator> +#include <QRegularExpression> + +#include "Configuration.hpp" +#include "LotWUsers.hpp" +#include "models/DecodeHighlightingModel.hpp" +#include "logbook/logbook.h" + +#include "qt_helpers.hpp" +#include "moc_displaytext.cpp" + +DisplayText::DisplayText(QWidget *parent) + : QTextEdit(parent) + , m_config {nullptr} + , erase_action_ {new QAction {tr ("&Erase"), this}} +{ + setReadOnly (true); + setUndoRedoEnabled (false); + viewport ()->setCursor (Qt::ArrowCursor); + setWordWrapMode (QTextOption::NoWrap); + + // max lines to limit heap usage + document ()->setMaximumBlockCount (5000); + + // context menu erase action + setContextMenuPolicy (Qt::CustomContextMenu); + connect (this, &DisplayText::customContextMenuRequested, [this] (QPoint const& position) { + auto * menu = createStandardContextMenu (position); + menu->addAction (erase_action_); + menu->exec (mapToGlobal (position)); + delete menu; + }); + connect (erase_action_, &QAction::triggered, this, &DisplayText::erase); +} + +void DisplayText::erase () +{ + clear (); + Q_EMIT erased (); +} + +void DisplayText::setContentFont(QFont const& font) +{ + char_font_ = font; + selectAll (); + auto cursor = textCursor (); + cursor.beginEditBlock (); + auto char_format = cursor.charFormat (); + char_format.setFont (char_font_); + cursor.mergeCharFormat (char_format); + cursor.clearSelection (); + cursor.movePosition (QTextCursor::End); + + // position so viewport scrolled to left + cursor.movePosition (QTextCursor::Up); + cursor.movePosition (QTextCursor::StartOfLine); + cursor.endEditBlock (); + + setTextCursor (cursor); + ensureCursorVisible (); +} + +void DisplayText::mouseDoubleClickEvent(QMouseEvent *e) +{ + Q_EMIT selectCallsign(e->modifiers ()); + QTextEdit::mouseDoubleClickEvent(e); +} + +void DisplayText::insertLineSpacer(QString const& line) +{ + appendText (line, "#d3d3d3"); +} + +namespace +{ + using Highlight = DecodeHighlightingModel::Highlight; + using highlight_types = std::vector<Highlight>; + Highlight set_colours (Configuration const * config, QColor * bg, QColor * fg, highlight_types const& types) + { + Highlight result = Highlight::CQ; + if (config) + { + QListIterator<DecodeHighlightingModel::HighlightInfo> it {config->decode_highlighting ().items ()}; + // iterate in reverse to honor priorities + it.toBack (); + while (it.hasPrevious ()) + { + auto const& item = it.previous (); + auto const& type = std::find (types.begin (), types.end (), item.type_); + if (type != types.end () && item.enabled_) + { + if (item.background_.style () != Qt::NoBrush) + { + *bg = item.background_.color (); + } + if (item.foreground_.style () != Qt::NoBrush) + { + *fg = item.foreground_.color (); + } + result = item.type_; + } + } + } + return result; // highest priority enabled highlighting + } +} + +void DisplayText::appendText(QString const& text, QColor bg, QColor fg + , QString const& call1, QString const& call2) +{ +// qDebug () << "DisplayText::appendText: text:" << text << "Nbsp pos:" << text.indexOf (QChar::Nbsp); + + auto cursor = textCursor (); + cursor.movePosition (QTextCursor::End); + auto block_format = cursor.blockFormat (); + auto format = cursor.blockCharFormat (); + format.setFont (char_font_); + block_format.clearBackground (); + if (bg.isValid ()) + { + block_format.setBackground (bg); + } + format.clearForeground (); + if (fg.isValid ()) + { + format.setForeground (fg); + } + if (cursor.position ()) + { + cursor.insertBlock (block_format, format); + } + else + { + cursor.setBlockFormat (block_format); + cursor.setBlockCharFormat (format); + } + + int text_index {0}; + auto temp_format = format; + if (call1.size ()) + { + auto call_index = text.indexOf (call1); + if (call_index != -1) // sanity check + { + auto pos = highlighted_calls_.find (call1); + if (pos != highlighted_calls_.end ()) + { + cursor.insertText(text.left (call_index)); + if (pos.value ().first.isValid ()) + { + temp_format.setBackground (pos.value ().first); + } + if (pos.value ().second.isValid ()) + { + temp_format.setForeground (pos.value ().second); + } + cursor.insertText(text.mid (call_index, call1.size ()), temp_format); + text_index = call_index + call1.size (); + } + } + } + if (call2.size ()) + { + auto call_index = text.indexOf (call2, text_index); + if (call_index != -1) // sanity check + { + auto pos = highlighted_calls_.find (call2); + if (pos != highlighted_calls_.end ()) + { + temp_format = format; + cursor.insertText(text.mid (text_index, call_index - text_index), format); + if (pos.value ().second.isValid ()) + { + temp_format.setBackground (pos.value ().first); + } + if (pos.value ().second.isValid ()) + { + temp_format.setForeground (pos.value ().second); + } + cursor.insertText(text.mid (call_index, call2.size ()), temp_format); + text_index = call_index + call2.size (); + } + } + } + cursor.insertText(text.mid (text_index), format); + + // position so viewport scrolled to left + cursor.movePosition (QTextCursor::StartOfLine); + setTextCursor (cursor); + ensureCursorVisible (); + document ()->setMaximumBlockCount (document ()->maximumBlockCount ()); +} + +QString DisplayText::appendWorkedB4 (QString message, QString call, QString const& grid, + QColor * bg, QColor * fg, LogBook const& logBook, + QString const& currentBand, QString const& currentMode) +{ + // allow for seconds + int padding {message.indexOf (" ") > 4 ? 2 : 0}; + QString countryName; + bool callB4; + bool callB4onBand; + bool countryB4; + bool countryB4onBand; + bool gridB4; + bool gridB4onBand; + bool continentB4; + bool continentB4onBand; + bool CQZoneB4; + bool CQZoneB4onBand; + bool ITUZoneB4; + bool ITUZoneB4onBand; + + if(call.length()==2) { + int i0=message.indexOf("CQ "+call); + call=message.mid(i0+6,-1); + i0=call.indexOf(" "); + call=call.mid(0,i0); + } + if(call.length()<3) return message; + if(!call.contains(QRegExp("[0-9]|[A-Z]"))) return message; + + auto const& looked_up = logBook.countries ().lookup (call); + logBook.match (call, currentMode, grid, looked_up, callB4, countryB4, gridB4, continentB4, CQZoneB4, ITUZoneB4); + logBook.match (call, currentMode, grid, looked_up, callB4onBand, countryB4onBand, gridB4onBand, + continentB4onBand, CQZoneB4onBand, ITUZoneB4onBand, currentBand); + if(grid=="") { + gridB4=true; + gridB4onBand=true; + } + + message = message.trimmed (); + QString appendage; + + highlight_types types; + // no shortcuts here as some types may be disabled + if (!countryB4) { + types.push_back (Highlight::DXCC); + } + if(!countryB4onBand) { + types.push_back (Highlight::DXCCBand); + } + if(!gridB4) { + types.push_back (Highlight::Grid); + } + if(!gridB4onBand) { + types.push_back (Highlight::GridBand); + } + if (!callB4) { + types.push_back (Highlight::Call); + } + if(!callB4onBand) { + types.push_back (Highlight::CallBand); + } + if (!continentB4) { + types.push_back (Highlight::Continent); + } + if(!continentB4onBand) { + types.push_back (Highlight::ContinentBand); + } + if (!CQZoneB4) { + types.push_back (Highlight::CQZone); + } + if(!CQZoneB4onBand) { + types.push_back (Highlight::CQZoneBand); + } + if (!ITUZoneB4) { + types.push_back (Highlight::ITUZone); + } + if(!ITUZoneB4onBand) { + types.push_back (Highlight::ITUZoneBand); + } + if (m_config && m_config->lotw_users ().user (call)) + { + types.push_back (Highlight::LotW); + } + types.push_back (Highlight::CQ); + auto top_highlight = set_colours (m_config, bg, fg, types); + + switch (top_highlight) + { + case Highlight::Continent: + case Highlight::ContinentBand: + appendage = AD1CCty::continent (looked_up.continent); + break; + case Highlight::CQZone: + case Highlight::CQZoneBand: + appendage = QString {"CQ Zone %1"}.arg (looked_up.CQ_zone); + break; + case Highlight::ITUZone: + case Highlight::ITUZoneBand: + appendage = QString {"ITU Zone %1"}.arg (looked_up.ITU_zone); + break; + default: + if (m_bPrincipalPrefix) + { + appendage = looked_up.primary_prefix; + } + else + { + auto countryName = looked_up.entity_name; + + // do some obvious abbreviations + countryName.replace ("Islands", "Is."); + countryName.replace ("Island", "Is."); + countryName.replace ("North ", "N. "); + countryName.replace ("Northern ", "N. "); + countryName.replace ("South ", "S. "); + countryName.replace ("East ", "E. "); + countryName.replace ("Eastern ", "E. "); + countryName.replace ("West ", "W. "); + countryName.replace ("Western ", "W. "); + countryName.replace ("Central ", "C. "); + countryName.replace (" and ", " & "); + countryName.replace ("Republic", "Rep."); + countryName.replace ("United States", "U.S.A."); + countryName.replace ("Fed. Rep. of ", ""); + countryName.replace ("French ", "Fr."); + countryName.replace ("Asiatic", "AS"); + countryName.replace ("European", "EU"); + countryName.replace ("African", "AF"); + + appendage += countryName; + } + } + + // use a nbsp to save the start of appended text so we can find + // it again later, align appended data at a fixed column if + // there is space otherwise let it float to the right + int space_count {40 + padding - message.size ()}; + if (space_count > 0) { + message += QString {space_count, QChar {' '}}; + } + message += QChar::Nbsp + appendage; + return message; +} + +void DisplayText::displayDecodedText(DecodedText const& decodedText, QString const& myCall, + QString const& mode, + bool displayDXCCEntity, LogBook const& logBook, + QString const& currentBand, bool ppfx, bool bCQonly) +{ + m_bPrincipalPrefix=ppfx; + QColor bg; + QColor fg; + bool CQcall = false; + if (decodedText.string ().contains (" CQ ") + || decodedText.string ().contains (" CQDX ") + || decodedText.string ().contains (" QRZ ")) + { + CQcall = true; + } + else + { + if (bCQonly) return; + if (myCall != "" && (decodedText.indexOf (" " + myCall + " ") >= 0 + or decodedText.indexOf (" " + myCall + "/") >= 0 + or decodedText.indexOf ("<" + myCall + "/") >= 0 + or decodedText.indexOf ("/" + myCall + " ") >= 0 + or decodedText.indexOf ("/" + myCall + ">") >= 0 + or decodedText.indexOf ("<" + myCall + " ") >= 0 + or decodedText.indexOf ("<" + myCall + ">") >= 0 + or decodedText.indexOf (" " + myCall + ">") >= 0)) { + highlight_types types {Highlight::MyCall}; + set_colours (m_config, &bg, &fg, types); + } + } + auto message = decodedText.string(); + QString dxCall; + QString dxGrid; + decodedText.deCallAndGrid (/*out*/ dxCall, dxGrid); + QRegularExpression grid_regexp {"\\A(?![Rr]{2}73)[A-Ra-r]{2}[0-9]{2}([A-Xa-x]{2}){0,1}\\z"}; + if(!dxGrid.contains(grid_regexp)) dxGrid=""; + message = message.left (message.indexOf (QChar::Nbsp)); // strip appended info + if (CQcall) + { + if (displayDXCCEntity) + { + // if enabled add the DXCC entity and B4 status to the end of the + // preformated text line t1 + auto currentMode = mode; + if ("JT9+JT65" == mode) + { + currentMode = decodedText.isJT65 () ? "JT65" : "JT9"; + } + message = appendWorkedB4 (message, decodedText.CQersCall(), dxGrid, &bg, &fg + , logBook, currentBand, currentMode); + } + else + { + highlight_types types {Highlight::CQ, Highlight::LotW}; + set_colours (m_config, &bg, &fg, types); + } + } + appendText (message.trimmed (), bg, fg, decodedText.call (), dxCall); +} + + +void DisplayText::displayTransmittedText(QString text, QString modeTx, qint32 txFreq,bool bFastMode) +{ + QString t1=" @ "; + if(modeTx=="FT8") t1=" ~ "; + if(modeTx=="JT4") t1=" $ "; + if(modeTx=="JT65") t1=" # "; + if(modeTx=="MSK144") t1=" & "; + QString t2; + t2.sprintf("%4d",txFreq); + QString t; + if(bFastMode or modeTx=="FT8") { + t = QDateTime::currentDateTimeUtc().toString("hhmmss") + \ + " Tx " + t2 + t1 + text; + } else if(modeTx.mid(0,6)=="FT8fox") { + t = QDateTime::currentDateTimeUtc().toString("hhmmss") + \ + " Tx" + modeTx.mid(7) + " " + text; + } else { + t = QDateTime::currentDateTimeUtc().toString("hhmm") + \ + " Tx " + t2 + t1 + text; + } + QColor bg; + QColor fg; + highlight_types types {Highlight::Tx}; + set_colours (m_config, &bg, &fg, types); + appendText (t, bg, fg); +} + +void DisplayText::displayQSY(QString text) +{ + QString t = QDateTime::currentDateTimeUtc().toString("hhmmss") + " " + text; + appendText (t, "hotpink"); +} + +void DisplayText::displayFoxToBeCalled(QString t, QColor bg, QColor fg) +{ + appendText (t, bg, fg); +} + +namespace +{ + void update_selection (QTextCursor& cursor, QColor const& bg, QColor const& fg) + { + if (!cursor.isNull ()) + { + QTextCharFormat format {cursor.charFormat ()}; + if (bg.isValid ()) + { + format.setBackground (bg); + } + else + { + format.clearBackground (); + } + if (fg.isValid ()) + { + format.setForeground (fg); + } + else + { + format.clearForeground (); + } + cursor.mergeCharFormat (format); + } + } + + void reset_selection (QTextCursor& cursor) + { + if (!cursor.isNull ()) + { + // restore previous text format, we rely on the text + // char format at he start of the selection being the + // old one which should be the case + auto c2 = cursor; + c2.setPosition (c2.selectionStart ()); + cursor.setCharFormat (c2.charFormat ()); + } + } +} + +void DisplayText::highlight_callsign (QString const& callsign, QColor const& bg, + QColor const& fg, bool last_only) +{ + QTextCharFormat old_format {currentCharFormat ()}; + QTextCursor cursor {document ()}; + if (last_only) + { + cursor.movePosition (QTextCursor::End); + cursor = document ()->find (callsign, cursor + , QTextDocument::FindBackward | QTextDocument::FindWholeWords); + if (bg.isValid () || fg.isValid ()) + { + update_selection (cursor, bg, fg); + } + else + { + reset_selection (cursor); + } + } + else + { + auto pos = highlighted_calls_.find (callsign); + if (bg.isValid () || fg.isValid ()) + { + auto colours = qMakePair (bg, fg); + if (pos == highlighted_calls_.end ()) + { + pos = highlighted_calls_.insert (callsign.toUpper (), colours); + } + else + { + pos.value () = colours; // update colours + } + while (!cursor.isNull ()) + { + cursor = document ()->find (callsign, cursor, QTextDocument::FindWholeWords); + update_selection (cursor, bg, fg); + } + } + else if (pos != highlighted_calls_.end ()) + { + highlighted_calls_.erase (pos); + QTextCursor cursor {document ()}; + while (!cursor.isNull ()) + { + cursor = document ()->find (callsign, cursor, QTextDocument::FindWholeWords); + reset_selection (cursor); + } + } + } + setCurrentCharFormat (old_format); +} diff --git a/widgets/displaytext.h b/widgets/displaytext.h new file mode 100644 index 00000000..1f20ac15 --- /dev/null +++ b/widgets/displaytext.h @@ -0,0 +1,58 @@ +// -*- Mode: C++ -*- +#ifndef DISPLAYTEXT_H +#define DISPLAYTEXT_H + +#include <QTextEdit> +#include <QFont> +#include <QHash> +#include <QPair> +#include <QString> + +#include "decodedtext.h" + +class QAction; +class Configuration; +class LogBook; + +class DisplayText + : public QTextEdit +{ + Q_OBJECT +public: + explicit DisplayText(QWidget *parent = 0); + void set_configuration (Configuration const * configuration) {m_config = configuration;} + void setContentFont (QFont const&); + void insertLineSpacer(QString const&); + void displayDecodedText(DecodedText const& decodedText, QString const& myCall, QString const& mode, + bool displayDXCCEntity, LogBook const& logBook, + QString const& currentBand=QString {}, bool ppfx=false, bool bCQonly=false); + void displayTransmittedText(QString text, QString modeTx, qint32 txFreq, bool bFastMode); + void displayQSY(QString text); + void displayFoxToBeCalled(QString t, QColor bg = QColor {}, QColor fg = QColor {}); + + Q_SIGNAL void selectCallsign (Qt::KeyboardModifiers); + Q_SIGNAL void erased (); + + Q_SLOT void appendText (QString const& text, QColor bg = QColor {}, QColor fg = QColor {} + , QString const& call1 = QString {}, QString const& call2 = QString {}); + Q_SLOT void erase (); + Q_SLOT void highlight_callsign (QString const& callsign, QColor const& bg, QColor const& fg, bool last_only); + +protected: + void mouseDoubleClickEvent(QMouseEvent *e); + +private: + Configuration const * m_config; + bool m_bPrincipalPrefix; + QString appendWorkedB4(QString message, QString callsign + , QString const& grid, QColor * bg, QColor * fg + , LogBook const& logBook, QString const& currentBand + , QString const& currentMode); + QFont char_font_; + QAction * erase_action_; + QHash<QString, QPair<QColor, QColor>> highlighted_calls_; +}; + + extern QHash<QString,int> m_LoTW; + +#endif // DISPLAYTEXT_H diff --git a/widgets/echograph.cpp b/widgets/echograph.cpp new file mode 100644 index 00000000..4bcaa717 --- /dev/null +++ b/widgets/echograph.cpp @@ -0,0 +1,103 @@ +#include "echograph.h" +#include "commons.h" +#include <QSettings> +#include <QApplication> +#include "echoplot.h" +#include "ui_echograph.h" +#include "moc_echograph.cpp" + +#define NSMAX2 1366 + +EchoGraph::EchoGraph(QSettings * settings, QWidget *parent) : + QDialog {parent, Qt::Window | Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint}, + m_settings (settings), + ui(new Ui::EchoGraph) +{ + ui->setupUi(this); + setWindowTitle (QApplication::applicationName () + " - " + tr ("Echo Graph")); + installEventFilter(parent); //Installing the filter + ui->echoPlot->setCursor(Qt::CrossCursor); + setMaximumWidth(2048); + setMaximumHeight(880); + ui->echoPlot->setMaximumHeight(800); + +//Restore user's settings + m_settings->beginGroup("EchoGraph"); + restoreGeometry (m_settings->value ("geometry", saveGeometry ()).toByteArray ()); + ui->echoPlot->setPlotZero(m_settings->value("PlotZero", 0).toInt()); + ui->echoPlot->setPlotGain(m_settings->value("PlotGain", 0).toInt()); + ui->zeroSlider->setValue(ui->echoPlot->getPlotZero()); + ui->gainSlider->setValue(ui->echoPlot->getPlotGain()); + int n=m_settings->value("Smooth",0).toInt(); + ui->echoPlot->m_smooth=n; + ui->smoothSpinBox->setValue(n); + n=m_settings->value("EchoBPP",1).toInt(); + ui->echoPlot->m_binsPerPixel=n; + ui->binsPerPixelSpinBox->setValue(n); + ui->echoPlot->m_blue=m_settings->value("BlueCurve",false).toBool(); + m_nColor=m_settings->value("EchoColors",0).toInt(); + m_settings->endGroup(); + ui->echoPlot->setColors(m_nColor); +} + +EchoGraph::~EchoGraph() +{ + saveSettings(); +} + +void EchoGraph::closeEvent (QCloseEvent * e) +{ + saveSettings (); + QDialog::closeEvent (e); +} + +void EchoGraph::saveSettings() +{ +//Save user's settings + m_settings->beginGroup("EchoGraph"); + m_settings->setValue ("geometry", saveGeometry ()); + m_settings->setValue("PlotZero",ui->echoPlot->m_plotZero); + m_settings->setValue("PlotGain",ui->echoPlot->m_plotGain); + m_settings->setValue("Smooth",ui->echoPlot->m_smooth); + m_settings->setValue("EchoBPP",ui->echoPlot->m_binsPerPixel); + m_settings->setValue("BlueCurve",ui->echoPlot->m_blue); + m_settings->setValue("EchoColors",m_nColor); + m_settings->endGroup(); +} + +void EchoGraph::plotSpec() +{ + ui->echoPlot->draw(); + ui->nsum_label->setText("N: " + QString::number(echocom_.nsum)); +} + +void EchoGraph::on_smoothSpinBox_valueChanged(int n) +{ + ui->echoPlot->setSmooth(n); + ui->echoPlot->draw(); +} + +void EchoGraph::on_gainSlider_valueChanged(int value) +{ + ui->echoPlot->setPlotGain(value); + ui->echoPlot->draw(); +} + +void EchoGraph::on_zeroSlider_valueChanged(int value) +{ + ui->echoPlot->setPlotZero(value); + ui->echoPlot->draw(); +} + +void EchoGraph::on_binsPerPixelSpinBox_valueChanged(int n) +{ + ui->echoPlot->m_binsPerPixel=n; + ui->echoPlot->DrawOverlay(); + ui->echoPlot->draw(); +} + +void EchoGraph::on_pbColors_clicked() +{ + m_nColor = (m_nColor+1) % 6; + ui->echoPlot->setColors(m_nColor); +} diff --git a/widgets/echograph.h b/widgets/echograph.h new file mode 100644 index 00000000..6e91782f --- /dev/null +++ b/widgets/echograph.h @@ -0,0 +1,41 @@ +#ifndef ECHOGRAPH_H +#define ECHOGRAPH_H + +#include <QDialog> +#include <QScopedPointer> + +namespace Ui { + class EchoGraph; +} + +class QSettings; + +class EchoGraph : public QDialog +{ + Q_OBJECT + +protected: + void closeEvent (QCloseEvent *) override; + +public: + explicit EchoGraph(QSettings *, QWidget *parent = 0); + ~EchoGraph(); + + void plotSpec(); + void saveSettings(); + +private slots: + void on_smoothSpinBox_valueChanged(int n); + void on_gainSlider_valueChanged(int value); + void on_zeroSlider_valueChanged(int value); + void on_binsPerPixelSpinBox_valueChanged(int n); + void on_pbColors_clicked(); + +private: + QSettings * m_settings; + qint32 m_nColor; + + QScopedPointer<Ui::EchoGraph> ui; +}; + +#endif // ECHOGRAPH_H diff --git a/widgets/echograph.ui b/widgets/echograph.ui new file mode 100644 index 00000000..470a2cc8 --- /dev/null +++ b/widgets/echograph.ui @@ -0,0 +1,294 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>EchoGraph</class> + <widget class="QDialog" name="EchoGraph"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>625</width> + <height>336</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>570</width> + <height>0</height> + </size> + </property> + <property name="windowTitle"> + <string>Echo Graph</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <property name="spacing"> + <number>2</number> + </property> + <property name="topMargin"> + <number>2</number> + </property> + <property name="bottomMargin"> + <number>2</number> + </property> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="spacing"> + <number>2</number> + </property> + <item> + <widget class="EPlotter" name="echoPlot"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>273</width> + <height>200</height> + </size> + </property> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Sunken</enum> + </property> + <property name="lineWidth"> + <number>1</number> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <property name="spacing"> + <number>6</number> + </property> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QSpinBox" name="binsPerPixelSpinBox"> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="toolTip"> + <string><html><head/><body><p>Compression factor for frequency scale</p></body></html></string> + </property> + <property name="prefix"> + <string>Bins/Pixel </string> + </property> + <property name="minimum"> + <number>1</number> + </property> + <property name="maximum"> + <number>10</number> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Gain</string> + </property> + </widget> + </item> + <item> + <widget class="QSlider" name="gainSlider"> + <property name="toolTip"> + <string><html><head/><body><p>Echo spectrum gain</p></body></html></string> + </property> + <property name="minimum"> + <number>-30</number> + </property> + <property name="maximum"> + <number>30</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_7"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Preferred</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Zero</string> + </property> + </widget> + </item> + <item> + <widget class="QSlider" name="zeroSlider"> + <property name="toolTip"> + <string><html><head/><body><p>Echo spectrum zero</p></body></html></string> + </property> + <property name="minimum"> + <number>-150</number> + </property> + <property name="maximum"> + <number>150</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Preferred</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QSpinBox" name="smoothSpinBox"> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="toolTip"> + <string><html><head/><body><p>Smoothing of echo spectrum</p></body></html></string> + </property> + <property name="prefix"> + <string>Smooth </string> + </property> + <property name="maximum"> + <number>20</number> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Preferred</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="nsum_label"> + <property name="minimumSize"> + <size> + <width>30</width> + <height>0</height> + </size> + </property> + <property name="toolTip"> + <string><html><head/><body><p>Number of echo transmissions averaged</p></body></html></string> + </property> + <property name="text"> + <string>N: 0</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="pbColors"> + <property name="maximumSize"> + <size> + <width>50</width> + <height>16777215</height> + </size> + </property> + <property name="toolTip"> + <string><html><head/><body><p>Click to cycle through a sequence of colors and line widths.</p></body></html></string> + </property> + <property name="text"> + <string>Colors</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_5"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>EPlotter</class> + <extends>QFrame</extends> + <header>widgets/plotter.h</header> + <container>1</container> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> diff --git a/widgets/echoplot.cpp b/widgets/echoplot.cpp new file mode 100644 index 00000000..0a93e889 --- /dev/null +++ b/widgets/echoplot.cpp @@ -0,0 +1,326 @@ +#include "echoplot.h" +#include "commons.h" +#include <math.h> +#include <QPainter> +#include <QPen> +#include <QDebug> +#include "moc_echoplot.cpp" + +#define MAX_SCREENSIZE 2048 + + +EPlotter::EPlotter(QWidget *parent) : //EPlotter Constructor + QFrame(parent) +{ + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + setFocusPolicy(Qt::StrongFocus); + setAttribute(Qt::WA_PaintOnScreen,false); + setAutoFillBackground(false); + setAttribute(Qt::WA_OpaquePaintEvent, false); + setAttribute(Qt::WA_NoSystemBackground, true); + + m_StartFreq = -200; + m_fftBinWidth=12000.0/32768.0; + m_binsPerPixel=1; + m_fSpan=1000.0; + m_hdivs = HORZ_DIVS; + m_Running = false; + m_paintEventBusy=false; + m_2DPixmap = QPixmap(0,0); + m_ScalePixmap = QPixmap(0,0); + m_OverlayPixmap = QPixmap(0,0); + m_Size = QSize(0,0); + m_TxFreq = 1500; + m_line = 0; + m_dBStepSize=10; +} + +EPlotter::~EPlotter() { } // Destructor + +QSize EPlotter::minimumSizeHint() const +{ + return QSize(50, 50); +} + +QSize EPlotter::sizeHint() const +{ + return QSize(180, 180); +} + +void EPlotter::resizeEvent(QResizeEvent* ) //resizeEvent() +{ + if(!size().isValid()) return; + if( m_Size != size() ) { //if changed, resize pixmaps to new screensize + m_Size = size(); + m_w = m_Size.width(); + m_h = m_Size.height(); + m_h1=30; + m_h2=m_h-m_h1; + m_2DPixmap = QPixmap(m_Size.width(), m_h2); + m_2DPixmap.fill(Qt::black); + m_OverlayPixmap = QPixmap(m_Size.width(), m_h2); + m_ScalePixmap = QPixmap(m_w,30); + m_ScalePixmap.fill(Qt::white); + m_fSpan=m_w*m_fftBinWidth*m_binsPerPixel; + m_StartFreq=50 * int((-0.5*m_fSpan)/50.0 - 0.5); + } + DrawOverlay(); + draw(); +} + +void EPlotter::paintEvent(QPaintEvent *) // paintEvent() +{ + if(m_paintEventBusy) return; + m_paintEventBusy=true; + QPainter painter(this); + painter.drawPixmap(0,0,m_ScalePixmap); + painter.drawPixmap(0,m_h1,m_2DPixmap); + m_paintEventBusy=false; +} + +void EPlotter::draw() //draw() +{ + int i,j,y; + float blue[4096],red[4096]; + float gain = pow(10.0,(m_plotGain/20.0)); + QPen penBlue(QColor(0,255,255),1); + QPen penRed(Qt::red,1); + QPen penRed2(Qt::red,2); + QPen penBlack(Qt::black,1); + QPen penBlack2(Qt::black,2); + + if(m_2DPixmap.size().width()==0) return; + QPainter painter2D(&m_2DPixmap); + QRect tmp(0,0,m_w,m_h2); + if(m_nColor < 2) { + painter2D.fillRect(tmp,Qt::black); + } else { + painter2D.fillRect(tmp,Qt::white); + painter2D.setPen(penBlack); + painter2D.drawLine(0,0,m_w,0); + } + + QPoint LineBuf[MAX_SCREENSIZE]; + + if(m_binsPerPixel==0) m_binsPerPixel=1; + j=0; + for(i=0; i<4096/m_binsPerPixel; i++) { + blue[i]=0.0; + red[i]=0.0; + for(int k=0; k<m_binsPerPixel; k++) { + blue[i]+=echocom_.blue[j]; + red[i]+=echocom_.red[j]; + j++; + } + } + if(m_smooth>0) { + for(i=0; i<m_smooth; i++) { + int n4096=4096; + smo121_(blue,&n4096); + smo121_(red,&n4096); + } + } + +// check i0 value! ... + int i0=2048/m_binsPerPixel + int(m_StartFreq/(m_fftBinWidth*m_binsPerPixel)); + if(m_blue) { + painter2D.setPen(penBlue); + j=0; + for(i=0; i<m_w; i++) { + y = 0.9*m_h2 - gain*(m_h/10.0)*(blue[i0+i]-1.0) - 0.01*m_h2*m_plotZero; + LineBuf[j].setX(i); + LineBuf[j].setY(y); + j++; + } + painter2D.drawPolyline(LineBuf,j); + } + switch (m_nColor) { + case 0: painter2D.setPen(penRed); break; + case 1: painter2D.setPen(penRed2); break; + case 2: painter2D.setPen(penRed); break; + case 3: painter2D.setPen(penRed2); break; + case 4: painter2D.setPen(penBlack); break; + case 5: painter2D.setPen(penBlack2); break; + } + + j=0; + for(int i=0; i<m_w; i++) { + y = 0.9*m_h2 - gain*(m_h/10.0)*(red[i0+i]-1.0) - 0.01*m_h2*m_plotZero; + LineBuf[j].setX(i); + LineBuf[j].setY(y); + j++; + } + painter2D.drawPolyline(LineBuf,j); + update(); //trigger a new paintEvent +} + +void EPlotter::DrawOverlay() //DrawOverlay() +{ + if(m_OverlayPixmap.isNull() or m_2DPixmap.isNull()) return; +// int w = m_WaterfallPixmap.width(); + int x,y; + + QRect rect; + QPainter painter(&m_OverlayPixmap); + painter.initFrom(this); + QLinearGradient gradient(0, 0, 0 ,m_h2); //fill background with gradient + gradient.setColorAt(1, Qt::black); + gradient.setColorAt(0, Qt::darkBlue); + painter.setBrush(gradient); + painter.drawRect(0, 0, m_w, m_h2); + painter.setBrush(Qt::SolidPattern); + + m_fSpan = m_w*m_fftBinWidth*m_binsPerPixel; + m_freqPerDiv=20; + if(m_fSpan>250) m_freqPerDiv=50; + if(m_fSpan>500) m_freqPerDiv=100; + if(m_fSpan>1000) m_freqPerDiv=200; + if(m_fSpan>2000) m_freqPerDiv=500; + +// m_StartFreq=50 * int((-0.5*m_fSpan)/50.0 - 0.5); + m_StartFreq=m_freqPerDiv * int((-0.5*m_fSpan)/m_freqPerDiv - 0.5); + + float pixPerHdiv = m_freqPerDiv/(m_fftBinWidth*m_binsPerPixel); + float pixPerVdiv = float(m_h2)/float(VERT_DIVS); + + m_hdivs = m_w*m_fftBinWidth*m_binsPerPixel/m_freqPerDiv + 0.9999; + + painter.setPen(QPen(Qt::white, 1,Qt::DotLine)); + for( int i=1; i<m_hdivs; i++) //draw vertical grids + { + x=int(i*pixPerHdiv); + painter.drawLine(x,0,x,m_h2); + } + + for( int i=1; i<VERT_DIVS; i++) //draw horizontal grids + { + y = (int)( (float)i*pixPerVdiv ); + painter.drawLine(0,y,m_w,y); + } + + QRect rect0; + QPainter painter0(&m_ScalePixmap); + painter0.initFrom(this); + + //create Font to use for scales + QFont Font("Arial"); + Font.setPointSize(12); + QFontMetrics metrics(Font); + Font.setWeight(QFont::Normal); + painter0.setFont(Font); + painter0.setPen(Qt::black); + + m_ScalePixmap.fill(Qt::white); + painter0.drawRect(0, 0, m_w, 30); + +//draw tick marks on upper scale + for( int i=1; i<m_hdivs; i++) { //major ticks + x = (int)( (float)i*pixPerHdiv ); + painter0.drawLine(x,18,x,30); + } + int minor=5; + if(m_freqPerDiv==200) minor=4; + for( int i=1; i<minor*m_hdivs; i++) { //minor ticks + x = i*pixPerHdiv/minor; + painter0.drawLine(x,24,x,30); + } + +//draw frequency values + MakeFrequencyStrs(); + for( int i=0; i<=m_hdivs; i++) { + if(0==i) { + //left justify the leftmost text + x = (int)( (float)i*pixPerHdiv); + rect0.setRect(x,0, (int)pixPerHdiv, 20); + painter0.drawText(rect0, Qt::AlignLeft|Qt::AlignVCenter, + m_HDivText[i]); + } + else if(m_hdivs == i) { + //right justify the rightmost text + x = (int)( (float)i*pixPerHdiv - pixPerHdiv); + rect0.setRect(x,0, (int)pixPerHdiv, 20); + painter0.drawText(rect0, Qt::AlignRight|Qt::AlignVCenter, + m_HDivText[i]); + } else { + //center justify the rest of the text + x = (int)( (float)i*pixPerHdiv - pixPerHdiv/2); + rect0.setRect(x,0, (int)pixPerHdiv, 20); + painter0.drawText(rect0, Qt::AlignHCenter|Qt::AlignVCenter, + m_HDivText[i]); + } + } + +/* + QPen pen1(Qt::red, 3); //Mark Tx Freq with red tick + painter0.setPen(pen1); + x = XfromFreq(m_TxFreq); + painter0.drawLine(x,17,x,30); +*/ +} + +void EPlotter::MakeFrequencyStrs() //MakeFrequencyStrs +{ + float freq; + for(int i=0; i<=m_hdivs; i++) { + freq=m_StartFreq + i*m_freqPerDiv; + m_HDivText[i].setNum((int)freq); + } +} + +int EPlotter::XfromFreq(float f) //XfromFreq() +{ + int x = (int) m_w * (f - m_StartFreq)/m_fSpan; + if(x<0 ) return 0; + if(x>m_w) return m_w; + return x; +} + +float EPlotter::FreqfromX(int x) //FreqfromX() +{ + return float(m_StartFreq + x*m_fftBinWidth*m_binsPerPixel); +} + +void EPlotter::SetRunningState(bool running) //SetRunningState() +{ + m_Running = running; +} + +void EPlotter::setPlotZero(int plotZero) //setPlotZero() +{ + m_plotZero=plotZero; +} + +int EPlotter::getPlotZero() //getPlotZero() +{ + return m_plotZero; +} + +void EPlotter::setPlotGain(int plotGain) //setPlotGain() +{ + m_plotGain=plotGain; +} + +int EPlotter::getPlotGain() //getPlotGain() +{ + return m_plotGain; +} + +void EPlotter::setSmooth(int n) //setSmooth() +{ + m_smooth=n; +} + +int EPlotter::getSmooth() //getSmooth() +{ + return m_smooth; +} + +void EPlotter::setColors(qint32 n) //setSmooth() +{ + m_nColor=n; + draw(); +} + +int EPlotter::plotWidth(){return m_2DPixmap.width();} + +void EPlotter::UpdateOverlay() {DrawOverlay();} diff --git a/widgets/echoplot.h b/widgets/echoplot.h new file mode 100644 index 00000000..a7492b97 --- /dev/null +++ b/widgets/echoplot.h @@ -0,0 +1,96 @@ +/////////////////////////////////////////////////////////////////////////// +// Some code in this file and accompanying files is based on work by +// Moe Wheatley, AE4Y, released under the "Simplified BSD License". +// For more details see the accompanying file LICENSE_WHEATLEY.TXT +/////////////////////////////////////////////////////////////////////////// + +#ifndef EPLOTTER_H_ +#define EPLOTTER_H_ + +#include <QFrame> +#include <QSize> +#include <QImage> +#include <QString> + +#define VERT_DIVS 7 //specify grid screen divisions +#define HORZ_DIVS 20 + +class QPaintEvent; +class QResizeEvent; + +class EPlotter : public QFrame +{ + Q_OBJECT +public: + explicit EPlotter(QWidget *parent = 0); + ~EPlotter(); + + QSize minimumSizeHint() const; + QSize sizeHint() const; + float m_fSpan; + qint32 m_TxFreq; + qint32 m_w; + qint32 m_plotZero; + qint32 m_plotGain; + qint32 m_smooth; + qint32 m_binsPerPixel; + qint32 m_nColor; + bool m_blue; + + void draw(); //Update the Echo plot + void SetRunningState(bool running); + void setPlotZero(int plotZero); + int getPlotZero(); + void setPlotGain(int plotGain); + int getPlotGain(); + int plotWidth(); + void UpdateOverlay(); + void DrawOverlay(); + void setSmooth(int n); + int getSmooth(); + void setColors(qint32 n); + +// void SetPercent2DScreen(int percent){m_Percent2DScreen=percent;} + +protected: + //re-implemented widget event handlers + void paintEvent(QPaintEvent *event); + void resizeEvent(QResizeEvent* event); + +private: + + void MakeFrequencyStrs(); + int XfromFreq(float f); + float FreqfromX(int x); + qint64 RoundFreq(qint64 freq, int resolution); + + QPixmap m_2DPixmap; + QPixmap m_ScalePixmap; + QPixmap m_OverlayPixmap; + QSize m_Size; + QString m_Str; + QString m_HDivText[483]; + + double m_fftBinWidth; + + qint64 m_StartFreq; + + qint32 m_dBStepSize; + qint32 m_hdivs; + qint32 m_line; + qint32 m_freqPerDiv; + qint32 m_h; + qint32 m_h1; + qint32 m_h2; + + bool m_Running; + bool m_paintEventBusy; + +}; + +extern "C" { +//--------------------------------------------------- C and Fortran routines + +void smo121_(float x[], int* npts); +} +#endif // EPLOTTER_H diff --git a/widgets/fastgraph.cpp b/widgets/fastgraph.cpp new file mode 100644 index 00000000..e599138f --- /dev/null +++ b/widgets/fastgraph.cpp @@ -0,0 +1,126 @@ +#include "fastgraph.h" + +#include "commons.h" +#include <QSettings> +#include <QApplication> +#include <QKeyEvent> +#include "fastplot.h" +#include "SettingsGroup.hpp" + +#include "ui_fastgraph.h" +#include "moc_fastgraph.cpp" + +#define NSMAX2 1366 + +FastGraph::FastGraph(QSettings * settings, QWidget *parent) : + QDialog {parent, Qt::Window | Qt::WindowTitleHint | + Qt::WindowCloseButtonHint | + Qt::WindowMinimizeButtonHint}, + m_settings {settings}, + m_ave {40}, + ui {new Ui::FastGraph} +{ + ui->setupUi(this); + setWindowTitle (QApplication::applicationName () + " - " + tr ("Fast Graph")); + installEventFilter(parent); //Installing the filter + ui->fastPlot->setCursor(Qt::CrossCursor); + + //Restore user's settings + SettingsGroup g {m_settings, "FastGraph"}; + restoreGeometry (m_settings->value ("geometry", saveGeometry ()).toByteArray ()); + ui->fastPlot->setPlotZero(m_settings->value("PlotZero", 0).toInt()); + ui->fastPlot->setPlotGain(m_settings->value("PlotGain", 0).toInt()); + ui->zeroSlider->setValue(ui->fastPlot->m_plotZero); + ui->gainSlider->setValue(ui->fastPlot->m_plotGain); + ui->fastPlot->setGreenZero(m_settings->value("GreenZero", 0).toInt()); + ui->greenZeroSlider->setValue(ui->fastPlot->m_greenZero); +// ui->controls_widget->setVisible (!m_settings->value("HideControls", false).toBool ()); + ui->controls_widget->setVisible(true); + connect (ui->fastPlot, &FPlotter::fastPick, this, &FastGraph::fastPick); +} + +void FastGraph::closeEvent (QCloseEvent * e) +{ + saveSettings (); + QDialog::closeEvent (e); +} + +FastGraph::~FastGraph () +{ +} + +void FastGraph::saveSettings() +{ +//Save user's settings + SettingsGroup g {m_settings, "FastGraph"}; + m_settings->setValue ("geometry", saveGeometry ()); + m_settings->setValue("PlotZero",ui->fastPlot->m_plotZero); + m_settings->setValue("PlotGain",ui->fastPlot->m_plotGain); + m_settings->setValue("GreenZero",ui->fastPlot->m_greenZero); + m_settings->setValue("GreenGain",ui->fastPlot->m_greenGain); +// m_settings->setValue ("HideControls", ui->controls_widget->isHidden ()); +} + +void FastGraph::plotSpec(bool diskData, int UTCdisk) +{ + ui->fastPlot->m_diskData=diskData; + ui->fastPlot->m_UTCdisk=UTCdisk; + ui->fastPlot->draw(); +} + +void FastGraph::on_gainSlider_valueChanged(int value) +{ + ui->fastPlot->setPlotGain(value); + ui->fastPlot->draw(); +} + +void FastGraph::on_zeroSlider_valueChanged(int value) +{ + ui->fastPlot->setPlotZero(value); + ui->fastPlot->draw(); +} + +void FastGraph::on_greenZeroSlider_valueChanged(int value) +{ + ui->fastPlot->setGreenZero(value); + ui->fastPlot->draw(); +} + +void FastGraph::setTRPeriod(int n) +{ + m_TRperiod=n; + ui->fastPlot->setTRperiod(m_TRperiod); +} + +void FastGraph::on_pbAutoLevel_clicked() +{ + float sum=0.0; + for(int i=0; i<=fast_jh; i++) { + sum += fast_green[i]; + } + m_ave=sum/fast_jh; + ui->gainSlider->setValue(127-int(2.2*m_ave)); + ui->zeroSlider->setValue(int(m_ave)+20); + ui->greenZeroSlider->setValue(160-int(3.3*m_ave)); +} + +void FastGraph::setMode(QString mode) //setMode +{ + ui->fastPlot->setMode(mode); +} + +void FastGraph::keyPressEvent(QKeyEvent *e) +{ + switch(e->key()) + { +/* + case Qt::Key_M: + if(e->modifiers() & Qt::ControlModifier) { + ui->controls_widget->setVisible (!ui->controls_widget->isVisible ()); + } + break; +*/ + default: + QDialog::keyPressEvent (e); + } +} diff --git a/widgets/fastgraph.h b/widgets/fastgraph.h new file mode 100644 index 00000000..7ed32671 --- /dev/null +++ b/widgets/fastgraph.h @@ -0,0 +1,52 @@ +#ifndef FASTGRAPH_H_ +#define FASTGRAPH_H_ + +#include <QDialog> +#include <QScopedPointer> + +namespace Ui { + class FastGraph; +} + +class QSettings; +class QCloseEvent; +class QKeyEvent; + +class FastGraph : public QDialog +{ + Q_OBJECT + +public: + explicit FastGraph(QSettings *, QWidget *parent = 0); + ~FastGraph (); + + void plotSpec(bool diskData, int UTCdisk); + void saveSettings(); + void setTRPeriod(int n); + void setMode(QString mode); + +signals: + void fastPick(int x0, int x1, int y); + +private slots: + void on_gainSlider_valueChanged(int value); + void on_zeroSlider_valueChanged(int value); + void on_greenZeroSlider_valueChanged(int value); + void on_pbAutoLevel_clicked(); + +protected: + void closeEvent (QCloseEvent *) override; + void keyPressEvent( QKeyEvent *e ) override; + +private: + QSettings * m_settings; + float m_ave; + qint32 m_TRperiod; + + QScopedPointer<Ui::FastGraph> ui; +}; + +extern float fast_green[703]; +extern int fast_jh; + +#endif // FASTGRAPH_H diff --git a/widgets/fastgraph.ui b/widgets/fastgraph.ui new file mode 100644 index 00000000..c62acad6 --- /dev/null +++ b/widgets/fastgraph.ui @@ -0,0 +1,246 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>FastGraph</class> + <widget class="QDialog" name="FastGraph"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>707</width> + <height>253</height> + </rect> + </property> + <property name="windowTitle"> + <string>Fast Graph</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="spacing"> + <number>2</number> + </property> + <property name="sizeConstraint"> + <enum>QLayout::SetFixedSize</enum> + </property> + <property name="leftMargin"> + <number>2</number> + </property> + <property name="topMargin"> + <number>2</number> + </property> + <property name="rightMargin"> + <number>2</number> + </property> + <property name="bottomMargin"> + <number>2</number> + </property> + <item> + <widget class="FPlotter" name="fastPlot"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>703</width> + <height>220</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>703</width> + <height>220</height> + </size> + </property> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Sunken</enum> + </property> + <property name="lineWidth"> + <number>1</number> + </property> + </widget> + </item> + <item> + <widget class="QWidget" name="controls_widget" native="true"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="leftMargin"> + <number>2</number> + </property> + <property name="topMargin"> + <number>2</number> + </property> + <property name="rightMargin"> + <number>2</number> + </property> + <property name="bottomMargin"> + <number>2</number> + </property> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>99</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QSlider" name="gainSlider"> + <property name="toolTip"> + <string>Waterfall gain</string> + </property> + <property name="minimum"> + <number>-60</number> + </property> + <property name="maximum"> + <number>140</number> + </property> + <property name="pageStep"> + <number>40</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_7"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Preferred</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QSlider" name="zeroSlider"> + <property name="toolTip"> + <string>Waterfall zero</string> + </property> + <property name="minimum"> + <number>-60</number> + </property> + <property name="maximum"> + <number>120</number> + </property> + <property name="value"> + <number>60</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Preferred</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QSlider" name="greenZeroSlider"> + <property name="toolTip"> + <string>Spectrum zero</string> + </property> + <property name="minimum"> + <number>-100</number> + </property> + <property name="maximum"> + <number>160</number> + </property> + <property name="value"> + <number>30</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Preferred</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="pbAutoLevel"> + <property name="toolTip"> + <string><html><head/><body><p>Set reasonable levels for gain and zero sliders.</p></body></html></string> + </property> + <property name="text"> + <string>Auto Level</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_5"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>99</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>FPlotter</class> + <extends>QFrame</extends> + <header>widgets/fastplot.h</header> + <container>1</container> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> diff --git a/widgets/fastplot.cpp b/widgets/fastplot.cpp new file mode 100644 index 00000000..1437834d --- /dev/null +++ b/widgets/fastplot.cpp @@ -0,0 +1,290 @@ +#include "fastplot.h" +#include "commons.h" +#include <math.h> +#include <QPainter> +#include <QPen> +#include <QMouseEvent> +#include <QDateTime> +#include <QDebug> +#include "moc_fastplot.cpp" + +#define MAX_SCREENSIZE 2048 + +FPlotter::FPlotter(QWidget *parent) : //FPlotter Constructor + QFrame {parent}, + m_w {703}, + m_plotGain {0}, + m_greenZero {0}, + m_x0 {0}, + m_x1 {0}, + m_ScalePixmap {QPixmap {703, 20}}, + m_pixPerSecond {12000.0/512.0}, + m_hdivs {30}, + m_h {220}, + m_h1 {20}, + m_h2 {m_h-m_h1}, + m_HorizPixmap {QPixmap {m_w, m_h2}}, + m_jh0 {9999}, + m_bPaint2 {true} +{ + m_diskData=false; + setFocusPolicy(Qt::StrongFocus); + setAttribute(Qt::WA_PaintOnScreen,false); + setAutoFillBackground(false); + setAttribute(Qt::WA_OpaquePaintEvent, false); + setAttribute(Qt::WA_NoSystemBackground, true); + + m_HorizPixmap.fill(Qt::black); + m_HorizPixmap.fill(Qt::black); + m_ScalePixmap.fill(Qt::white); + drawScale(); + draw(); + setMouseTracking(true); +} + +FPlotter::~FPlotter() { } // Destructor + +void FPlotter::paintEvent(QPaintEvent *) // paintEvent() +{ + QPainter painter(this); + painter.drawPixmap(0,0,m_ScalePixmap); + painter.drawPixmap(0,m_h1,m_HorizPixmap); +} + +void FPlotter::drawScale() //drawScale() +{ + if(m_ScalePixmap.isNull()) return; + int x; + + QRect rect0; + QPainter painter0(&m_ScalePixmap); + painter0.initFrom(this); + + //create Font to use for scales + QFont Font("Arial"); + Font.setPointSize(8); + QFontMetrics metrics(Font); + Font.setWeight(QFont::Normal); + painter0.setFont(Font); + painter0.setPen(Qt::white); + m_ScalePixmap.fill(Qt::black); + painter0.drawRect(0, 0,m_w,19); + painter0.drawLine(0,19,m_w,19); + +//Draw ticks at 1-second intervals + for( int i=0; i<=m_hdivs; i++) { + x = (int)( (float)i*m_pixPerSecond ); + painter0.drawLine(x,15,x,19); + } + +//Write numbers on the time scale + MakeTimeStrs(); + for( int i=0; i<=m_hdivs; i++) { + if(0==i) { + //left justify the leftmost text + x = (int)( (float)i*m_pixPerSecond); + rect0.setRect(x,0, (int)m_pixPerSecond, 20); + painter0.drawText(rect0, Qt::AlignLeft|Qt::AlignVCenter,m_HDivText[i]); + } + else if(m_hdivs == i) { + //right justify the rightmost text + x = (int)( (float)i*m_pixPerSecond - m_pixPerSecond); + rect0.setRect(x,0, (int)m_pixPerSecond, 20); + painter0.drawText(rect0, Qt::AlignRight|Qt::AlignVCenter,m_HDivText[i]); + } else { + //center justify the rest of the text + x = (int)( (float)i*m_pixPerSecond - m_pixPerSecond/2); + rect0.setRect(x,0, (int)m_pixPerSecond, 20); + painter0.drawText(rect0, Qt::AlignHCenter|Qt::AlignVCenter,m_HDivText[i]); + } + } +} + +void FPlotter::MakeTimeStrs() //MakeTimeStrs +{ + for(int i=0; i<=m_hdivs; i++) { + m_HDivText[i].setNum(i); + } +} + +int FPlotter::XfromTime(float t) //XfromFreq() +{ + return int(t*m_pixPerSecond); +} + +float FPlotter::TimefromX(int x) //FreqfromX() +{ + return float(x/m_pixPerSecond); +} + +void FPlotter::setPlotZero(int plotZero) //setPlotZero() +{ + m_plotZero=plotZero; + m_bPaint2=true; +} + +void FPlotter::setPlotGain(int plotGain) //setPlotGain() +{ + m_plotGain=plotGain; + m_bPaint2=true; +} + +void FPlotter::setGreenZero(int n) +{ + m_greenZero=n; + m_bPaint2=true; +} + +void FPlotter::setTRperiod(int n) +{ + m_TRperiod=n; + m_pixPerSecond=12000.0/512.0; + if(m_TRperiod<30) m_pixPerSecond=12000.0/256.0; + drawScale(); + update(); +} + + +void FPlotter::draw() //draw() +{ + QPainter painter1(&m_HorizPixmap); + QPoint LineBuf[703]; + QPen penGreen(Qt::green,1); + + if(m_diskData) { + int ih=m_UTCdisk/10000; + int im=m_UTCdisk/100 % 100; + int is=m_UTCdisk % 100; + m_t.sprintf("%2.2d:%2.2d:%2.2d",ih,im,is); + } + + int k0=m_jh0; + if(fast_jh < m_jh0 or m_bPaint2) { + k0=0; + QRect tmp(0,0,m_w,119); + painter1.fillRect(tmp,Qt::black); + painter1.setPen(Qt::white); + if(m_diskData) { + int ih=m_UTCdisk/10000; + int im=m_UTCdisk/100 % 100; + int is=m_UTCdisk % 100; + m_t.sprintf("%2.2d:%2.2d:%2.2d",ih,im,is); + } else { + m_t=QDateTime::currentDateTimeUtc().toString("hh:mm:ss"); + } + if(fast_jh>0) painter1.drawText(10,95,m_t); + } + + float gain = pow(10.0,(m_plotGain/20.0)); + for(int k=64*k0; k<64*fast_jh; k++) { //Upper spectrogram + int i = k%64; + int j = k/64; + int y=0.005*gain*fast_s[k] + m_plotZero; + if(y<0) y=0; + if(y>254) y=254; + painter1.setPen(g_ColorTbl[y]); + painter1.drawPoint(j,64-i); + } + + painter1.setPen(penGreen); // Upper green curve + int j=0; + m_greenGain=10; + float greenGain = pow(10.0,(m_greenGain/20.0)); + for(int x=k0; x<=fast_jh; x++) { + int y = 0.9*m_h - greenGain*fast_green[x] - m_greenZero + 40; + if(y>119) y=119; + LineBuf[j].setX(x); +// LineBuf[j].setX(2*x); + LineBuf[j].setY(y); + j++; + } + painter1.drawPolyline(LineBuf,j); + + if((fast_jh < m_jh0) or m_bPaint2) { + QRect tmp(0,120,m_w,219); + painter1.fillRect(tmp,Qt::black); + painter1.setPen(Qt::white); + if(fast_jh>0 and m_jh0 < 9999) painter1.drawText(10,195,m_t0); + m_t0=m_t; + + for(int k=0; k<64*fast_jh2; k++) { //Lower spectrogram + int i = k%64; + int j = k/64; + int y=0.005*gain*fast_s2[k] + m_plotZero; + if(y<0) y=0; + if(y>254) y=254; + painter1.setPen(g_ColorTbl[y]); + painter1.drawPoint(j,164-i); + } + + painter1.setPen(penGreen); //Lower green curve + j=0; + for(int x=0; x<=fast_jh2; x++) { + int y = 0.9*m_h - greenGain*fast_green2[x] - m_greenZero + 140; + if(y>219) y=219; + LineBuf[j].setX(x); + LineBuf[j].setY(y); + j++; + } + painter1.drawPolyline(LineBuf,j); + m_bPaint2=false; + } + + painter1.setPen(Qt::white); + painter1.drawLine(0,100, m_w,100); + if(fast_jh>0) m_jh0=fast_jh; + update(); //trigger a new paintEvent +} + +void FPlotter::mouseMoveEvent(QMouseEvent *event) +{ + QPainter painter(&m_HorizPixmap); + int x=event->x(); +// int y=event->y(); + float t=x/m_pixPerSecond; + QString t1; + t1.sprintf("%5.2f",t); + QRectF rect0(78,85,40,13); //### Should use font metrics ### + painter.fillRect(rect0,Qt::black); + painter.setPen(Qt::yellow); + painter.drawText(80,95,t1); + update(); +} + +void FPlotter::mousePressEvent(QMouseEvent *event) //mousePressEvent +{ + if(m_mode=="MSK144") return; + int x=event->x(); + int y=event->y(); + int n=event->button(); +// bool ctrl = (event->modifiers() & Qt::ControlModifier); + QPainter painter(&m_HorizPixmap); + int x0=x-n*m_pixPerSecond; + int x1=x+n*m_pixPerSecond; + int xmax=m_TRperiod*m_pixPerSecond; + if(x0 < 0) x0=0; + if(x1 > xmax) x1=xmax; + if(x1 > 702) x1=702; + Q_EMIT fastPick (x0,x1,y); + int y0=64; + if(y >= 120) y0+=100; + if(m_x0+m_x1 != 0) { + painter.setPen(Qt::black); + painter.drawLine(m_x0,m_y0,m_x1,m_y0); //Erase previous yellow line + painter.drawLine(m_x0,m_y0-3,m_x0,m_y0+3); + painter.drawLine(m_x1,m_y0-3,m_x1,m_y0+3); + } + painter.setPen(Qt::yellow); + painter.drawLine(x0,y0,x1,y0); //Draw yellow line + painter.drawLine(x0,y0-3,x0,y0+3); + painter.drawLine(x1,y0-3,x1,y0+3); + update(); //trigger a new paintEvent + m_x0=x0; + m_x1=x1; + m_y0=y0; +} + +void FPlotter::setMode(QString mode) //setMode +{ + m_mode=mode; +} diff --git a/widgets/fastplot.h b/widgets/fastplot.h new file mode 100644 index 00000000..b1391338 --- /dev/null +++ b/widgets/fastplot.h @@ -0,0 +1,91 @@ +/////////////////////////////////////////////////////////////////////////// +// Some code in this file and accompanying files is based on work by +// Moe Wheatley, AE4Y, released under the "Simplified BSD License". +// For more details see the accompanying file LICENSE_WHEATLEY.TXT +/////////////////////////////////////////////////////////////////////////// + +#ifndef FPLOTTER_H_ +#define FPLOTTER_H_ + +#include <QFrame> +#include <QString> +#include <QPixmap> +#include <QVector> +#include <QColor> + +class QMouseEvent; + +class FPlotter : public QFrame +{ + Q_OBJECT +public: + explicit FPlotter(QWidget *parent = 0); + ~FPlotter(); + + qint32 m_w; + qint32 m_plotZero; + qint32 m_plotGain; + qint32 m_greenGain; + qint32 m_greenZero; + qint32 m_x0; + qint32 m_x1; + qint32 m_y0; + qint32 m_UTCdisk; + bool m_diskData; + + void draw(); //Update the Fast plot + void setPlotZero(int plotZero); + void setPlotGain(int plotGain); + void setGreenZero(int n); + void setTRperiod(int n); + void drawScale(); + void setMode(QString mode); + +signals: + void fastPick (int x0, int x1, int y); + +protected: + //re-implemented widget event handlers + void paintEvent(QPaintEvent *event); +// void resizeEvent(QResizeEvent* event); + +private slots: + void mousePressEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + +private: + + void MakeTimeStrs(); + int XfromTime(float t); + float TimefromX(int x); + qint64 RoundFreq(qint64 freq, int resolution); + + QPixmap m_ScalePixmap; + QString m_HDivText[483]; + QString m_t; + QString m_t0; + QString m_t1; + QString m_mode; + + double m_pixPerSecond; + + qint32 m_hdivs; + qint32 m_h; + qint32 m_h1; + qint32 m_h2; + QPixmap m_HorizPixmap; + qint32 m_jh0; + qint32 m_TRperiod; + + bool m_bPaint2; +}; + +extern float fast_green[703]; +extern float fast_green2[703]; +extern float fast_s[44992]; //44992=64*703 +extern float fast_s2[44992]; +extern int fast_jh; +extern int fast_jh2; +extern QVector<QColor> g_ColorTbl; + +#endif // FPLOTTER_H diff --git a/widgets/logqso.cpp b/widgets/logqso.cpp new file mode 100644 index 00000000..da8d0081 --- /dev/null +++ b/widgets/logqso.cpp @@ -0,0 +1,211 @@ +#include "logqso.h" + +#include <QString> +#include <QSettings> +#include <QStandardPaths> +#include <QDir> + +#include "logbook/logbook.h" +#include "MessageBox.hpp" +#include "Configuration.hpp" +#include "models/Bands.hpp" +#include "models/CabrilloLog.hpp" +#include "validators/MaidenheadLocatorValidator.hpp" + +#include "ui_logqso.h" +#include "moc_logqso.cpp" + +LogQSO::LogQSO(QString const& programTitle, QSettings * settings + , Configuration const * config, QWidget *parent) + : QDialog {parent, Qt::WindowStaysOnTopHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint} + , ui(new Ui::LogQSO) + , m_settings (settings) + , m_config {config} +{ + ui->setupUi(this); + setWindowTitle(programTitle + " - Log QSO"); + loadSettings (); + ui->grid->setValidator (new MaidenheadLocatorValidator {this}); +} + +LogQSO::~LogQSO () +{ +} + +void LogQSO::loadSettings () +{ + m_settings->beginGroup ("LogQSO"); + restoreGeometry (m_settings->value ("geometry", saveGeometry ()).toByteArray ()); + ui->cbTxPower->setChecked (m_settings->value ("SaveTxPower", false).toBool ()); + ui->cbComments->setChecked (m_settings->value ("SaveComments", false).toBool ()); + m_txPower = m_settings->value ("TxPower", "").toString (); + m_comments = m_settings->value ("LogComments", "").toString(); + m_settings->endGroup (); +} + +void LogQSO::storeSettings () const +{ + m_settings->beginGroup ("LogQSO"); + m_settings->setValue ("geometry", saveGeometry ()); + m_settings->setValue ("SaveTxPower", ui->cbTxPower->isChecked ()); + m_settings->setValue ("SaveComments", ui->cbComments->isChecked ()); + m_settings->setValue ("TxPower", m_txPower); + m_settings->setValue ("LogComments", m_comments); + m_settings->endGroup (); +} + +void LogQSO::initLogQSO(QString const& hisCall, QString const& hisGrid, QString mode, + QString const& rptSent, QString const& rptRcvd, + QDateTime const& dateTimeOn, QDateTime const& dateTimeOff, + Radio::Frequency dialFreq, bool noSuffix, QString xSent, QString xRcvd, + CabrilloLog * cabrillo_log) +{ + if(!isHidden()) return; + ui->call->setText(hisCall); + ui->grid->setText(hisGrid); + ui->name->setText(""); + ui->txPower->setText(""); + ui->comments->setText(""); + if (ui->cbTxPower->isChecked ()) ui->txPower->setText(m_txPower); + if (ui->cbComments->isChecked ()) ui->comments->setText(m_comments); + if (m_config->report_in_comments()) { + auto t=mode; + if(rptSent!="") t+=" Sent: " + rptSent; + if(rptRcvd!="") t+=" Rcvd: " + rptRcvd; + ui->comments->setText(t); + } + if(noSuffix and mode.mid(0,3)=="JT9") mode="JT9"; + if(m_config->log_as_RTTY() and mode.mid(0,3)=="JT9") mode="RTTY"; + ui->mode->setText(mode); + ui->sent->setText(rptSent); + ui->rcvd->setText(rptRcvd); + ui->start_date_time->setDateTime (dateTimeOn); + ui->end_date_time->setDateTime (dateTimeOff); + m_dialFreq=dialFreq; + m_myCall=m_config->my_callsign(); + m_myGrid=m_config->my_grid(); + ui->band->setText (m_config->bands ()->find (dialFreq)); + ui->loggedOperator->setText(m_config->opCall()); + ui->exchSent->setText (xSent); + ui->exchRcvd->setText (xRcvd); + m_cabrilloLog = cabrillo_log; + + using SpOp = Configuration::SpecialOperatingActivity; + auto special_op = m_config->special_op_id (); + if (SpOp::FOX == special_op + || (m_config->autoLog () + && SpOp::NONE < special_op && special_op < SpOp::FOX)) + { + // allow auto logging in Fox mode and contests + accept(); + } + else + { + show(); + } +} + +void LogQSO::accept() +{ + auto hisCall = ui->call->text (); + auto hisGrid = ui->grid->text (); + auto mode = ui->mode->text (); + auto rptSent = ui->sent->text (); + auto rptRcvd = ui->rcvd->text (); + auto m_dateTimeOn = ui->start_date_time->dateTime (); + auto m_dateTimeOff = ui->end_date_time->dateTime (); + auto band = ui->band->text (); + auto name = ui->name->text (); + auto m_txPower = ui->txPower->text (); + auto m_comments = ui->comments->text (); + auto strDialFreq = QString::number (m_dialFreq / 1.e6,'f',6); + auto operator_call = ui->loggedOperator->text (); + auto xsent = ui->exchSent->text (); + auto xrcvd = ui->exchRcvd->text (); + + // validate + using SpOp = Configuration::SpecialOperatingActivity; + auto special_op = m_config->special_op_id (); + if (SpOp::NONE < special_op && special_op < SpOp::FOX) + { + if (xsent.isEmpty () || xrcvd.isEmpty ()) + { + show (); + MessageBox::warning_message (this, tr ("Invalid QSO Data"), + tr ("Check exchange sent and received")); + return; // without accepting + } + + if (!m_cabrilloLog->add_QSO (m_dialFreq, m_dateTimeOff, hisCall, xsent, xrcvd)) + { + show (); + MessageBox::warning_message (this, tr ("Invalid QSO Data"), + tr ("Check all fields")); + return; // without accepting + } + } + + //Log this QSO to file "wsjtx.log" + static QFile f {QDir {QStandardPaths::writableLocation (QStandardPaths::DataLocation)}.absoluteFilePath ("wsjtx.log")}; + if(!f.open(QIODevice::Text | QIODevice::Append)) { + MessageBox::warning_message (this, tr ("Log file error"), + tr ("Cannot open \"%1\" for append").arg (f.fileName ()), + tr ("Error: %1").arg (f.errorString ())); + } else { + QString logEntry=m_dateTimeOn.date().toString("yyyy-MM-dd,") + + m_dateTimeOn.time().toString("hh:mm:ss,") + + m_dateTimeOff.date().toString("yyyy-MM-dd,") + + m_dateTimeOff.time().toString("hh:mm:ss,") + hisCall + "," + + hisGrid + "," + strDialFreq + "," + mode + + "," + rptSent + "," + rptRcvd + "," + m_txPower + + "," + m_comments + "," + name; + QTextStream out(&f); + out << logEntry << endl; + f.close(); + } + + //Clean up and finish logging + Q_EMIT acceptQSO (m_dateTimeOff + , hisCall + , hisGrid + , m_dialFreq + , mode + , rptSent + , rptRcvd + , m_txPower + , m_comments + , name + , m_dateTimeOn + , operator_call + , m_myCall + , m_myGrid + , xsent + , xrcvd + , LogBook::QSOToADIF (hisCall + , hisGrid + , mode + , rptSent + , rptRcvd + , m_dateTimeOn + , m_dateTimeOff + , band + , m_comments + , name + , strDialFreq + , m_myCall + , m_myGrid + , m_txPower + , operator_call + , xsent + , xrcvd)); + QDialog::accept(); +} + +// closeEvent is only called from the system menu close widget for a +// modeless dialog so we use the hideEvent override to store the +// window settings +void LogQSO::hideEvent (QHideEvent * e) +{ + storeSettings (); + QDialog::hideEvent (e); +} diff --git a/widgets/logqso.h b/widgets/logqso.h new file mode 100644 index 00000000..3363d2ea --- /dev/null +++ b/widgets/logqso.h @@ -0,0 +1,67 @@ +// -*- Mode: C++ -*- +#ifndef LogQSO_H_ +#define LogQSO_H_ + +#include <QDialog> + +#include <QString> +#include <QScopedPointer> +#include <QDateTime> + +#include "Radio.hpp" + +namespace Ui { + class LogQSO; +} + +class QSettings; +class Configuration; +class QByteArray; +class CabrilloLog; + +class LogQSO : public QDialog +{ + Q_OBJECT + +public: + explicit LogQSO(QString const& programTitle, QSettings *, Configuration const *, QWidget *parent = 0); + ~LogQSO(); + void initLogQSO(QString const& hisCall, QString const& hisGrid, QString mode, + QString const& rptSent, QString const& rptRcvd, QDateTime const& dateTimeOn, + QDateTime const& dateTimeOff, Radio::Frequency dialFreq, + bool noSuffix, QString xSent, QString xRcvd, CabrilloLog *); + +public slots: + void accept(); + +signals: + void acceptQSO (QDateTime const& QSO_date_off, QString const& call, QString const& grid + , Radio::Frequency dial_freq, QString const& mode + , QString const& rpt_sent, QString const& rpt_received + , QString const& tx_power, QString const& comments + , QString const& name, QDateTime const& QSO_date_on, QString const& operator_call + , QString const& my_call, QString const& my_grid + , QString const& exchange_sent, QString const& exchange_rcvd + , QByteArray const& ADIF); + +protected: + void hideEvent (QHideEvent *); + +private: + void loadSettings (); + void storeSettings () const; + + QScopedPointer<Ui::LogQSO> ui; + QSettings * m_settings; + Configuration const * m_config; + QString m_txPower; + QString m_comments; + Radio::Frequency m_dialFreq; + QString m_myCall; + QString m_myGrid; + QDateTime m_dateTimeOn; + QDateTime m_dateTimeOff; + CabrilloLog * m_cabrilloLog; +}; + +#endif // LogQSO_H diff --git a/widgets/logqso.ui b/widgets/logqso.ui new file mode 100644 index 00000000..a03a3028 --- /dev/null +++ b/widgets/logqso.ui @@ -0,0 +1,525 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>LogQSO</class> + <widget class="QDialog" name="LogQSO"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>377</width> + <height>287</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <layout class="QVBoxLayout" name="verticalLayout_5"> + <item> + <widget class="QLabel" name="label"> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="text"> + <string>Click OK to confirm the following QSO:</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="lab1"> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="text"> + <string>Call</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="call"/> + </item> + </layout> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QLabel" name="lab2"> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="text"> + <string>Start</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QDateTimeEdit" name="start_date_time"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="displayFormat"> + <string>dd/MM/yyyy HH:mm:ss</string> + </property> + <property name="timeSpec"> + <enum>Qt::UTC</enum> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <widget class="QLabel" name="lab2_3"> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="text"> + <string>End</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QDateTimeEdit" name="end_date_time"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="displayFormat"> + <string>dd/MM/yyyy HH:mm:ss</string> + </property> + <property name="timeSpec"> + <enum>Qt::UTC</enum> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <item> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <item> + <widget class="QLabel" name="lab4"> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="text"> + <string>Mode</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="mode"> + <property name="maximumSize"> + <size> + <width>70</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_6"> + <item> + <widget class="QLabel" name="lab5"> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="text"> + <string>Band</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="band"> + <property name="maximumSize"> + <size> + <width>50</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_7"> + <item> + <widget class="QLabel" name="lab6"> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="text"> + <string>Rpt Sent</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="sent"> + <property name="maximumSize"> + <size> + <width>50</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_8"> + <item> + <widget class="QLabel" name="lab7"> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="text"> + <string>Rpt Rcvd</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="rcvd"> + <property name="maximumSize"> + <size> + <width>50</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_9"> + <item> + <widget class="QLabel" name="lab8"> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="text"> + <string>Grid</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="grid"> + <property name="maximumSize"> + <size> + <width>70</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_10"> + <item> + <widget class="QLabel" name="lab9"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="text"> + <string>Name</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="name"> + <property name="enabled"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_6"> + <item> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Tx power</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="txPower"/> + </item> + <item> + <widget class="QCheckBox" name="cbTxPower"> + <property name="text"> + <string>Retain</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="lab10"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="text"> + <string>Comments</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="comments"> + <property name="enabled"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="cbComments"> + <property name="text"> + <string>Retain</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_5"> + <item> + <widget class="QLabel" name="operatorLabel"> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="text"> + <string>Operator</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="loggedOperator"> + <property name="maximumSize"> + <size> + <width>300</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Exch sent</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="exchSent"> + <property name="maximumSize"> + <size> + <width>120</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Rcvd</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="exchRcvd"> + <property name="maximumSize"> + <size> + <width>120</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <tabstops> + <tabstop>call</tabstop> + <tabstop>start_date_time</tabstop> + <tabstop>end_date_time</tabstop> + <tabstop>mode</tabstop> + <tabstop>band</tabstop> + <tabstop>sent</tabstop> + <tabstop>rcvd</tabstop> + <tabstop>grid</tabstop> + <tabstop>name</tabstop> + <tabstop>txPower</tabstop> + <tabstop>cbTxPower</tabstop> + <tabstop>comments</tabstop> + <tabstop>cbComments</tabstop> + </tabstops> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>LogQSO</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>LogQSO</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/widgets/mainwindow.cpp b/widgets/mainwindow.cpp new file mode 100644 index 00000000..42dac2f5 --- /dev/null +++ b/widgets/mainwindow.cpp @@ -0,0 +1,8442 @@ +//---------------------------------------------------------- MainWindow +#include "mainwindow.h" +#include <cinttypes> +#include <cstring> +#include <cmath> +#include <limits> +#include <functional> +#include <fstream> +#include <iterator> +#include <algorithm> +#include <fftw3.h> +#include <QStringListModel> +#include <QSettings> +#include <QKeyEvent> +#include <QSharedMemory> +#include <QFileDialog> +#include <QTextBlock> +#include <QProgressBar> +#include <QLineEdit> +#include <QRegExpValidator> +#include <QRegExp> +#include <QRegularExpression> +#include <QDesktopServices> +#include <QUrl> +#include <QStandardPaths> +#include <QDir> +#include <QDebug> +#include <QtConcurrent/QtConcurrentRun> +#include <QProgressDialog> +#include <QHostInfo> +#include <QVector> +#include <QCursor> +#include <QToolTip> +#include <QAction> +#include <QActionGroup> +#include <QSplashScreen> +#include <QUdpSocket> +#include <QAbstractItemView> + +#include "revision_utils.hpp" +#include "qt_helpers.hpp" +#include "NetworkAccessManager.hpp" +#include "soundout.h" +#include "soundin.h" +#include "Modulator.hpp" +#include "Detector.hpp" +#include "plotter.h" +#include "echoplot.h" +#include "echograph.h" +#include "fastplot.h" +#include "fastgraph.h" +#include "about.h" +#include "messageaveraging.h" +#include "colorhighlighting.h" +#include "widegraph.h" +#include "sleep.h" +#include "logqso.h" +#include "decodedtext.h" +#include "Radio.hpp" +#include "models/Bands.hpp" +#include "TransceiverFactory.hpp" +#include "models/StationList.hpp" +#include "validators/LiveFrequencyValidator.hpp" +#include "MessageClient.hpp" +#include "wsprnet.h" +#include "signalmeter.h" +#include "HelpTextWindow.hpp" +#include "SampleDownloader.hpp" +#include "Audio/BWFFile.hpp" +#include "MultiSettings.hpp" +#include "validators/MaidenheadLocatorValidator.hpp" +#include "validators/CallsignValidator.hpp" +#include "EqualizationToolsDialog.hpp" +#include "LotWUsers.hpp" +#include "logbook/AD1CCty.hpp" +#include "models/FoxLog.hpp" +#include "models/CabrilloLog.hpp" +#include "FoxLogWindow.hpp" +#include "CabrilloLogWindow.hpp" +#include "ExportCabrillo.h" +#include "ui_mainwindow.h" +#include "moc_mainwindow.cpp" + + +extern "C" { + //----------------------------------------------------- C and Fortran routines + void symspec_(struct dec_data *, int* k, int* ntrperiod, int* nsps, int* ingain, + int* minw, float* px, float s[], float* df3, int* nhsym, int* npts8, + float *m_pxmax); + + void hspec_(short int d2[], int* k, int* nutc0, int* ntrperiod, int* nrxfreq, int* ntol, + int* nContest, bool* bmsk144, bool* btrain, double const pcoeffs[], int* ingain, + char mycall[], char hiscall[], bool* bshmsg, bool* bswl, char ddir[], float green[], + float s[], int* jh, float *pxmax, float *rmsNoGain, char line[], char mygrid[], + fortran_charlen_t, fortran_charlen_t, fortran_charlen_t, fortran_charlen_t, + fortran_charlen_t); + + void genft8_(char* msg, int* i3, int* n3, char* msgsent, char ft8msgbits[], + int itone[], fortran_charlen_t, fortran_charlen_t); + + void gen4_(char* msg, int* ichk, char* msgsent, int itone[], + int* itext, fortran_charlen_t, fortran_charlen_t); + + void gen9_(char* msg, int* ichk, char* msgsent, int itone[], + int* itext, fortran_charlen_t, fortran_charlen_t); + + void genmsk_128_90_(char* msg, int* ichk, char* msgsent, int itone[], int* itype, + fortran_charlen_t, fortran_charlen_t); + + void gen65_(char* msg, int* ichk, char* msgsent, int itone[], + int* itext, fortran_charlen_t, fortran_charlen_t); + + void genqra64_(char* msg, int* ichk, char* msgsent, int itone[], + int* itext, fortran_charlen_t, fortran_charlen_t); + + void genwspr_(char* msg, char* msgsent, int itone[], fortran_charlen_t, fortran_charlen_t); + +// void genwspr_fsk8_(char* msg, char* msgsent, int itone[], fortran_charlen_t, fortran_charlen_t); + + void geniscat_(char* msg, char* msgsent, int itone[], fortran_charlen_t, fortran_charlen_t); + + void azdist_(char* MyGrid, char* HisGrid, double* utch, int* nAz, int* nEl, + int* nDmiles, int* nDkm, int* nHotAz, int* nHotABetter, + fortran_charlen_t, fortran_charlen_t); + + void morse_(char* msg, int* icw, int* ncw, fortran_charlen_t); + + int ptt_(int nport, int ntx, int* iptt, int* nopen); + + void wspr_downsample_(short int d2[], int* k); + + int savec2_(char* fname, int* TR_seconds, double* dial_freq, fortran_charlen_t); + + void avecho_( short id2[], int* dop, int* nfrit, int* nqual, float* f1, + float* level, float* sigdb, float* snr, float* dfreq, + float* width); + + void fast_decode_(short id2[], int narg[], int* ntrperiod, + char msg[], char mycall[], char hiscall[], + fortran_charlen_t, fortran_charlen_t, fortran_charlen_t); + void degrade_snr_(short d2[], int* n, float* db, float* bandwidth); + + void wav12_(short d2[], short d1[], int* nbytes, short* nbitsam2); + + void refspectrum_(short int d2[], bool* bclearrefspec, + bool* brefspec, bool* buseref, const char* c_fname, fortran_charlen_t); + + void freqcal_(short d2[], int* k, int* nkhz,int* noffset, int* ntol, + char line[], fortran_charlen_t); + + void fix_contest_msg_(char* MyGrid, char* msg, fortran_charlen_t, fortran_charlen_t); + + void calibrate_(char data_dir[], int* iz, double* a, double* b, double* rms, + double* sigmaa, double* sigmab, int* irc, fortran_charlen_t); + + void foxgen_(); + + void plotsave_(float swide[], int* m_w , int* m_h1, int* irow); + + void chkcall_(char* w, char* basc_call, bool cok, int len1, int len2); +} + +int volatile itone[NUM_ISCAT_SYMBOLS]; //Audio tones for all Tx symbols +int volatile itone0[NUM_ISCAT_SYMBOLS]; //Dummy array, data not actually used +int volatile icw[NUM_CW_SYMBOLS]; //Dits for CW ID +struct dec_data dec_data; // for sharing with Fortran + +int outBufSize; +int rc; +qint32 g_iptt {0}; +wchar_t buffer[256]; +float fast_green[703]; +float fast_green2[703]; +float fast_s[44992]; //44992=64*703 +float fast_s2[44992]; +int fast_jh {0}; +int fast_jhpeak {0}; +int fast_jh2 {0}; +int narg[15]; +QVector<QColor> g_ColorTbl; + +using SpecOp = Configuration::SpecialOperatingActivity; + +namespace +{ + Radio::Frequency constexpr default_frequency {14076000}; + QRegExp message_alphabet {"[- @A-Za-z0-9+./?#<>;]*"}; + // grid exact match excluding RR73 + QRegularExpression grid_regexp {"\\A(?![Rr]{2}73)[A-Ra-r]{2}[0-9]{2}([A-Xa-x]{2}){0,1}\\z"}; + + bool message_is_73 (int type, QStringList const& msg_parts) + { + return type >= 0 + && (((type < 6 || 7 == type) + && (msg_parts.contains ("73") || msg_parts.contains ("RR73"))) + || (type == 6 && !msg_parts.filter ("73").isEmpty ())); + } + + int ms_minute_error () + { + auto const& now = QDateTime::currentDateTimeUtc (); + auto const& time = now.time (); + auto second = time.second (); + return now.msecsTo (now.addSecs (second > 30 ? 60 - second : -second)) - time.msec (); + } +} + +//--------------------------------------------------- MainWindow constructor +MainWindow::MainWindow(QDir const& temp_directory, bool multiple, + MultiSettings * multi_settings, QSharedMemory *shdmem, + unsigned downSampleFactor, + QSplashScreen * splash, QWidget *parent) : + QMainWindow(parent), + m_network_manager {this}, + m_valid {true}, + m_splash {splash}, + m_revision {revision ()}, + m_multiple {multiple}, + m_multi_settings {multi_settings}, + m_configurations_button {0}, + m_settings {multi_settings->settings ()}, + ui(new Ui::MainWindow), + m_logBook {&m_config}, + m_config {&m_network_manager, temp_directory, m_settings, &m_logBook, this}, + m_WSPR_band_hopping {m_settings, &m_config, this}, + m_WSPR_tx_next {false}, + m_rigErrorMessageBox {MessageBox::Critical, tr ("Rig Control Error") + , MessageBox::Cancel | MessageBox::Ok | MessageBox::Retry}, + m_wideGraph (new WideGraph(m_settings)), + m_echoGraph (new EchoGraph(m_settings)), + m_fastGraph (new FastGraph(m_settings)), + // no parent so that it has a taskbar icon + m_logDlg (new LogQSO (program_title (), m_settings, &m_config, nullptr)), + m_lastDialFreq {0}, + m_dialFreqRxWSPR {0}, + m_detector {new Detector {RX_SAMPLE_RATE, NTMAX, downSampleFactor}}, + m_FFTSize {6192 / 2}, // conservative value to avoid buffer overruns + m_soundInput {new SoundInput}, + m_modulator {new Modulator {TX_SAMPLE_RATE, NTMAX}}, + m_soundOutput {new SoundOutput}, + m_msErase {0}, + m_secBandChanged {0}, + m_freqNominal {0}, + m_freqTxNominal {0}, + m_s6 {0.}, + m_tRemaining {0.}, + m_DTtol {3.0}, + m_waterfallAvg {1}, + m_ntx {1}, + m_gen_message_is_cq {false}, + m_send_RR73 {false}, + m_XIT {0}, + m_sec0 {-1}, + m_RxLog {1}, //Write Date and Time to RxLog + m_nutc0 {999999}, + m_ntr {0}, + m_tx {0}, + m_TRperiod {60}, + m_inGain {0}, + m_secID {0}, + m_idleMinutes {0}, + m_nSubMode {0}, + m_nclearave {1}, + m_pctx {0}, + m_nseq {0}, + m_nWSPRdecodes {0}, + m_k0 {9999999}, + m_nPick {0}, + m_frequency_list_fcal_iter {m_config.frequencies ()->begin ()}, + m_nTx73 {0}, + m_btxok {false}, + m_diskData {false}, + m_loopall {false}, + m_txFirst {false}, + m_auto {false}, + m_restart {false}, + m_startAnother {false}, + m_saveDecoded {false}, + m_saveAll {false}, + m_widebandDecode {false}, + m_dataAvailable {false}, + m_blankLine {false}, + m_decodedText2 {false}, + m_freeText {false}, + m_sentFirst73 {false}, + m_currentMessageType {-1}, + m_lastMessageType {-1}, + m_bShMsgs {false}, + m_bSWL {false}, + m_uploading {false}, + m_txNext {false}, + m_grid6 {false}, + m_tuneup {false}, + m_bTxTime {false}, + m_rxDone {false}, + m_bSimplex {false}, + m_bEchoTxOK {false}, + m_bTransmittedEcho {false}, + m_bEchoTxed {false}, + m_bFastDecodeCalled {false}, + m_bDoubleClickAfterCQnnn {false}, + m_bRefSpec {false}, + m_bClearRefSpec {false}, + m_bTrain {false}, + m_bAutoReply {false}, + m_QSOProgress {CALLING}, + m_ihsym {0}, + m_nzap {0}, + m_px {0.0}, + m_iptt0 {0}, + m_btxok0 {false}, + m_nsendingsh {0}, + m_onAirFreq0 {0.0}, + m_first_error {true}, + tx_status_label {"Receiving"}, + wsprNet {new WSPRNet {&m_network_manager, this}}, + m_appDir {QApplication::applicationDirPath ()}, + m_palette {"Linrad"}, + m_mode {"JT9"}, + m_rpt {"-15"}, + m_pfx { + "1A", "1S", + "3A", "3B6", "3B8", "3B9", "3C", "3C0", "3D2", "3D2C", + "3D2R", "3DA", "3V", "3W", "3X", "3Y", "3YB", "3YP", + "4J", "4L", "4S", "4U1I", "4U1U", "4W", "4X", + "5A", "5B", "5H", "5N", "5R", "5T", "5U", "5V", "5W", "5X", "5Z", + "6W", "6Y", + "7O", "7P", "7Q", "7X", + "8P", "8Q", "8R", + "9A", "9G", "9H", "9J", "9K", "9L", "9M2", "9M6", "9N", + "9Q", "9U", "9V", "9X", "9Y", + "A2", "A3", "A4", "A5", "A6", "A7", "A9", "AP", + "BS7", "BV", "BV9", "BY", + "C2", "C3", "C5", "C6", "C9", "CE", "CE0X", "CE0Y", + "CE0Z", "CE9", "CM", "CN", "CP", "CT", "CT3", "CU", + "CX", "CY0", "CY9", + "D2", "D4", "D6", "DL", "DU", + "E3", "E4", "E5", "EA", "EA6", "EA8", "EA9", "EI", "EK", + "EL", "EP", "ER", "ES", "ET", "EU", "EX", "EY", "EZ", + "F", "FG", "FH", "FJ", "FK", "FKC", "FM", "FO", "FOA", + "FOC", "FOM", "FP", "FR", "FRG", "FRJ", "FRT", "FT5W", + "FT5X", "FT5Z", "FW", "FY", + "M", "MD", "MI", "MJ", "MM", "MU", "MW", + "H4", "H40", "HA", "HB", "HB0", "HC", "HC8", "HH", + "HI", "HK", "HK0", "HK0M", "HL", "HM", "HP", "HR", + "HS", "HV", "HZ", + "I", "IS", "IS0", + "J2", "J3", "J5", "J6", "J7", "J8", "JA", "JDM", + "JDO", "JT", "JW", "JX", "JY", + "K", "KC4", "KG4", "KH0", "KH1", "KH2", "KH3", "KH4", "KH5", + "KH5K", "KH6", "KH7", "KH8", "KH9", "KL", "KP1", "KP2", + "KP4", "KP5", + "LA", "LU", "LX", "LY", "LZ", + "OA", "OD", "OE", "OH", "OH0", "OJ0", "OK", "OM", "ON", + "OX", "OY", "OZ", + "P2", "P4", "PA", "PJ2", "PJ7", "PY", "PY0F", "PT0S", "PY0T", "PZ", + "R1F", "R1M", + "S0", "S2", "S5", "S7", "S9", "SM", "SP", "ST", "SU", + "SV", "SVA", "SV5", "SV9", + "T2", "T30", "T31", "T32", "T33", "T5", "T7", "T8", "T9", "TA", + "TF", "TG", "TI", "TI9", "TJ", "TK", "TL", "TN", "TR", "TT", + "TU", "TY", "TZ", + "UA", "UA2", "UA9", "UK", "UN", "UR", + "V2", "V3", "V4", "V5", "V6", "V7", "V8", "VE", "VK", "VK0H", + "VK0M", "VK9C", "VK9L", "VK9M", "VK9N", "VK9W", "VK9X", "VP2E", + "VP2M", "VP2V", "VP5", "VP6", "VP6D", "VP8", "VP8G", "VP8H", + "VP8O", "VP8S", "VP9", "VQ9", "VR", "VU", "VU4", "VU7", + "XE", "XF4", "XT", "XU", "XW", "XX9", "XZ", + "YA", "YB", "YI", "YJ", "YK", "YL", "YN", "YO", "YS", "YU", "YV", "YV0", + "Z2", "Z3", "ZA", "ZB", "ZC4", "ZD7", "ZD8", "ZD9", "ZF", "ZK1N", + "ZK1S", "ZK2", "ZK3", "ZL", "ZL7", "ZL8", "ZL9", "ZP", "ZS", "ZS8" + }, + m_sfx {"P", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A"}, + mem_jt9 {shdmem}, + m_msAudioOutputBuffered (0u), + m_framesAudioInputBuffered (RX_SAMPLE_RATE / 10), + m_downSampleFactor (downSampleFactor), + m_audioThreadPriority (QThread::HighPriority), + m_bandEdited {false}, + m_splitMode {false}, + m_monitoring {false}, + m_tx_when_ready {false}, + m_transmitting {false}, + m_tune {false}, + m_tx_watchdog {false}, + m_block_pwr_tooltip {false}, + m_PwrBandSetOK {true}, + m_lastMonitoredFrequency {default_frequency}, + m_toneSpacing {0.}, + m_firstDecode {0}, + m_optimizingProgress {"Optimizing decoder FFTs for your CPU.\n" + "Please be patient,\n" + "this may take a few minutes", QString {}, 0, 1, this}, + m_messageClient {new MessageClient {QApplication::applicationName (), + version (), revision (), + m_config.udp_server_name (), m_config.udp_server_port (), + this}}, + psk_Reporter {new PSK_Reporter {m_messageClient, this}}, + m_manual {&m_network_manager} +{ + ui->setupUi(this); + createStatusBar(); + add_child_to_event_filter (this); + ui->dxGridEntry->setValidator (new MaidenheadLocatorValidator {this}); + ui->dxCallEntry->setValidator (new CallsignValidator {this}); + ui->sbTR->values ({5, 10, 15, 30}); + ui->decodedTextBrowser->set_configuration (&m_config); + ui->decodedTextBrowser2->set_configuration (&m_config); + + m_baseCall = Radio::base_callsign (m_config.my_callsign ()); + + m_optimizingProgress.setWindowModality (Qt::WindowModal); + m_optimizingProgress.setAutoReset (false); + m_optimizingProgress.setMinimumDuration (15000); // only show after 15s delay + + // Closedown. + connect (ui->actionExit, &QAction::triggered, this, &QMainWindow::close); + + // parts of the rig error message box that are fixed + m_rigErrorMessageBox.setInformativeText (tr ("Do you want to reconfigure the radio interface?")); + m_rigErrorMessageBox.setDefaultButton (MessageBox::Ok); + + // start audio thread and hook up slots & signals for shutdown management + // these objects need to be in the audio thread so that invoking + // their slots is done in a thread safe way + m_soundOutput->moveToThread (&m_audioThread); + m_modulator->moveToThread (&m_audioThread); + m_soundInput->moveToThread (&m_audioThread); + m_detector->moveToThread (&m_audioThread); + + // hook up sound output stream slots & signals and disposal + connect (this, &MainWindow::initializeAudioOutputStream, m_soundOutput, &SoundOutput::setFormat); + connect (m_soundOutput, &SoundOutput::error, this, &MainWindow::showSoundOutError); + // connect (m_soundOutput, &SoundOutput::status, this, &MainWindow::showStatusMessage); + connect (this, &MainWindow::outAttenuationChanged, m_soundOutput, &SoundOutput::setAttenuation); + connect (&m_audioThread, &QThread::finished, m_soundOutput, &QObject::deleteLater); + + // hook up Modulator slots and disposal + connect (this, &MainWindow::transmitFrequency, m_modulator, &Modulator::setFrequency); + connect (this, &MainWindow::endTransmitMessage, m_modulator, &Modulator::stop); + connect (this, &MainWindow::tune, m_modulator, &Modulator::tune); + connect (this, &MainWindow::sendMessage, m_modulator, &Modulator::start); + connect (&m_audioThread, &QThread::finished, m_modulator, &QObject::deleteLater); + + // hook up the audio input stream signals, slots and disposal + connect (this, &MainWindow::startAudioInputStream, m_soundInput, &SoundInput::start); + connect (this, &MainWindow::suspendAudioInputStream, m_soundInput, &SoundInput::suspend); + connect (this, &MainWindow::resumeAudioInputStream, m_soundInput, &SoundInput::resume); + connect (this, &MainWindow::finished, m_soundInput, &SoundInput::stop); + connect(m_soundInput, &SoundInput::error, this, &MainWindow::showSoundInError); + // connect(m_soundInput, &SoundInput::status, this, &MainWindow::showStatusMessage); + connect (&m_audioThread, &QThread::finished, m_soundInput, &QObject::deleteLater); + + connect (this, &MainWindow::finished, this, &MainWindow::close); + + // hook up the detector signals, slots and disposal + connect (this, &MainWindow::FFTSize, m_detector, &Detector::setBlockSize); + connect(m_detector, &Detector::framesWritten, this, &MainWindow::dataSink); + connect (&m_audioThread, &QThread::finished, m_detector, &QObject::deleteLater); + + // setup the waterfall + connect(m_wideGraph.data (), SIGNAL(freezeDecode2(int)),this,SLOT(freezeDecode(int))); + connect(m_wideGraph.data (), SIGNAL(f11f12(int)),this,SLOT(bumpFqso(int))); + connect(m_wideGraph.data (), SIGNAL(setXIT2(int)),this,SLOT(setXIT(int))); + + connect (m_fastGraph.data (), &FastGraph::fastPick, this, &MainWindow::fastPick); + + connect (this, &MainWindow::finished, m_wideGraph.data (), &WideGraph::close); + connect (this, &MainWindow::finished, m_echoGraph.data (), &EchoGraph::close); + connect (this, &MainWindow::finished, m_fastGraph.data (), &FastGraph::close); + + // setup the log QSO dialog + connect (m_logDlg.data (), &LogQSO::acceptQSO, this, &MainWindow::acceptQSO); + connect (this, &MainWindow::finished, m_logDlg.data (), &LogQSO::close); + + // hook up the log book + connect (&m_logBook, &LogBook::finished_loading, [this] (int record_count, QString const& error) { + if (error.size ()) + { + MessageBox::warning_message (this, tr ("Error Scanning ADIF Log"), error); + } + else + { + showStatusMessage (tr ("Scanned ADIF log, %1 worked before records created").arg (record_count)); + } + }); + + // Network message handlers + connect (m_messageClient, &MessageClient::reply, this, &MainWindow::replyToCQ); + connect (m_messageClient, &MessageClient::replay, this, &MainWindow::replayDecodes); + connect (m_messageClient, &MessageClient::location, this, &MainWindow::locationChange); + connect (m_messageClient, &MessageClient::halt_tx, [this] (bool auto_only) { + if (m_config.accept_udp_requests ()) { + if (auto_only) { + if (ui->autoButton->isChecked ()) { + ui->autoButton->click(); + } + } else { + ui->stopTxButton->click(); + } + } + }); + connect (m_messageClient, &MessageClient::error, this, &MainWindow::networkError); + connect (m_messageClient, &MessageClient::free_text, [this] (QString const& text, bool send) { + if (m_config.accept_udp_requests ()) { + tx_watchdog (false); + // send + non-empty text means set and send the free text + // message, !send + non-empty text means set the current free + // text message, send + empty text means send the current free + // text message without change, !send + empty text means clear + // the current free text message + if (0 == ui->tabWidget->currentIndex ()) { + if (!text.isEmpty ()) { + ui->tx5->setCurrentText (text); + } + if (send) { + ui->txb5->click (); + } else if (text.isEmpty ()) { + ui->tx5->setCurrentText (text); + } + } else if (1 == ui->tabWidget->currentIndex ()) { + if (!text.isEmpty ()) { + ui->freeTextMsg->setCurrentText (text); + } + if (send) { + ui->rbFreeText->click (); + } else if (text.isEmpty ()) { + ui->freeTextMsg->setCurrentText (text); + } + } + QApplication::alert (this); + } + }); + + connect (m_messageClient, &MessageClient::highlight_callsign, ui->decodedTextBrowser, &DisplayText::highlight_callsign); + + // Hook up WSPR band hopping + connect (ui->band_hopping_schedule_push_button, &QPushButton::clicked + , &m_WSPR_band_hopping, &WSPRBandHopping::show_dialog); + connect (ui->sbTxPercent, static_cast<void (QSpinBox::*) (int)> (&QSpinBox::valueChanged) + , &m_WSPR_band_hopping, &WSPRBandHopping::set_tx_percent); + + on_EraseButton_clicked (); + + QActionGroup* modeGroup = new QActionGroup(this); + ui->actionFT8->setActionGroup(modeGroup); + ui->actionJT9->setActionGroup(modeGroup); + ui->actionJT65->setActionGroup(modeGroup); + ui->actionJT9_JT65->setActionGroup(modeGroup); + ui->actionJT4->setActionGroup(modeGroup); + ui->actionWSPR->setActionGroup(modeGroup); + ui->actionWSPR_LF->setActionGroup(modeGroup); + ui->actionEcho->setActionGroup(modeGroup); + ui->actionISCAT->setActionGroup(modeGroup); + ui->actionMSK144->setActionGroup(modeGroup); + ui->actionQRA64->setActionGroup(modeGroup); + ui->actionFreqCal->setActionGroup(modeGroup); + + QActionGroup* saveGroup = new QActionGroup(this); + ui->actionNone->setActionGroup(saveGroup); + ui->actionSave_decoded->setActionGroup(saveGroup); + ui->actionSave_all->setActionGroup(saveGroup); + + QActionGroup* DepthGroup = new QActionGroup(this); + ui->actionQuickDecode->setActionGroup(DepthGroup); + ui->actionMediumDecode->setActionGroup(DepthGroup); + ui->actionDeepestDecode->setActionGroup(DepthGroup); + + connect (ui->download_samples_action, &QAction::triggered, [this] () { + if (!m_sampleDownloader) + { + m_sampleDownloader.reset (new SampleDownloader {m_settings, &m_config, &m_network_manager, this}); + } + m_sampleDownloader->show (); + }); + + connect (ui->view_phase_response_action, &QAction::triggered, [this] () { + if (!m_equalizationToolsDialog) + { + m_equalizationToolsDialog.reset (new EqualizationToolsDialog {m_settings, m_config.writeable_data_dir (), m_phaseEqCoefficients, this}); + connect (m_equalizationToolsDialog.data (), &EqualizationToolsDialog::phase_equalization_changed, + [this] (QVector<double> const& coeffs) { + m_phaseEqCoefficients = coeffs; + }); + } + m_equalizationToolsDialog->show (); + }); + + connect (&m_config.lotw_users (), &LotWUsers::LotW_users_error, this, [this] (QString const& reason) { + MessageBox::warning_message (this, tr ("Error Loading LotW Users Data"), reason); + }, Qt::QueuedConnection); + + QButtonGroup* txMsgButtonGroup = new QButtonGroup {this}; + txMsgButtonGroup->addButton(ui->txrb1,1); + txMsgButtonGroup->addButton(ui->txrb2,2); + txMsgButtonGroup->addButton(ui->txrb3,3); + txMsgButtonGroup->addButton(ui->txrb4,4); + txMsgButtonGroup->addButton(ui->txrb5,5); + txMsgButtonGroup->addButton(ui->txrb6,6); + set_dateTimeQSO(-1); + connect(txMsgButtonGroup,SIGNAL(buttonClicked(int)),SLOT(set_ntx(int))); + connect (ui->decodedTextBrowser, &DisplayText::selectCallsign, this, &MainWindow::doubleClickOnCall2); + connect (ui->decodedTextBrowser2, &DisplayText::selectCallsign, this, &MainWindow::doubleClickOnCall); + connect (ui->textBrowser4, &DisplayText::selectCallsign, this, &MainWindow::doubleClickOnFoxQueue); + connect (ui->decodedTextBrowser, &DisplayText::erased, this, &MainWindow::band_activity_cleared); + connect (ui->decodedTextBrowser2, &DisplayText::erased, this, &MainWindow::rx_frequency_activity_cleared); + + // initialize decoded text font and hook up font change signals + // defer initialization until after construction otherwise menu + // fonts do not get set + QTimer::singleShot (0, this, SLOT (initialize_fonts ())); + connect (&m_config, &Configuration::text_font_changed, [this] (QFont const& font) { + set_application_font (font); + }); + connect (&m_config, &Configuration::decoded_text_font_changed, [this] (QFont const& font) { + setDecodedTextFont (font); + }); + + setWindowTitle (program_title ()); + + connect(&proc_jt9, &QProcess::readyReadStandardOutput, this, &MainWindow::readFromStdout); + connect(&proc_jt9, static_cast<void (QProcess::*) (QProcess::ProcessError)> (&QProcess::error), + [this] (QProcess::ProcessError error) { + subProcessError (&proc_jt9, error); + }); + connect(&proc_jt9, static_cast<void (QProcess::*) (int, QProcess::ExitStatus)> (&QProcess::finished), + [this] (int exitCode, QProcess::ExitStatus status) { + subProcessFailed (&proc_jt9, exitCode, status); + }); + + connect(&p1, &QProcess::readyReadStandardOutput, this, &MainWindow::p1ReadFromStdout); + connect(&p1, static_cast<void (QProcess::*) (QProcess::ProcessError)> (&QProcess::error), + [this] (QProcess::ProcessError error) { + subProcessError (&p1, error); + }); + connect(&p1, static_cast<void (QProcess::*) (int, QProcess::ExitStatus)> (&QProcess::finished), + [this] (int exitCode, QProcess::ExitStatus status) { + subProcessFailed (&p1, exitCode, status); + }); + + connect(&p3, static_cast<void (QProcess::*) (QProcess::ProcessError)> (&QProcess::error), + [this] (QProcess::ProcessError error) { + subProcessError (&p3, error); + }); + connect(&p3, static_cast<void (QProcess::*) (int, QProcess::ExitStatus)> (&QProcess::finished), + [this] (int exitCode, QProcess::ExitStatus status) { + subProcessFailed (&p3, exitCode, status); + }); + + // hook up save WAV file exit handling + connect (&m_saveWAVWatcher, &QFutureWatcher<QString>::finished, [this] { + // extract the promise from the future + auto const& result = m_saveWAVWatcher.future ().result (); + if (!result.isEmpty ()) // error + { + MessageBox::critical_message (this, tr("Error Writing WAV File"), result); + } + }); + + // Hook up working frequencies. + ui->bandComboBox->setModel (m_config.frequencies ()); + ui->bandComboBox->setModelColumn (FrequencyList_v2::frequency_mhz_column); + + // combo box drop down width defaults to the line edit + decorator width, + // here we change that to the column width size hint of the model column + ui->bandComboBox->view ()->setMinimumWidth (ui->bandComboBox->view ()->sizeHintForColumn (FrequencyList_v2::frequency_mhz_column)); + + // Enable live band combo box entry validation and action. + auto band_validator = new LiveFrequencyValidator {ui->bandComboBox + , m_config.bands () + , m_config.frequencies () + , &m_freqNominal + , this}; + ui->bandComboBox->setValidator (band_validator); + + // Hook up signals. + connect (band_validator, &LiveFrequencyValidator::valid, this, &MainWindow::band_changed); + connect (ui->bandComboBox->lineEdit (), &QLineEdit::textEdited, [this] (QString const&) {m_bandEdited = true;}); + + // hook up configuration signals + connect (&m_config, &Configuration::transceiver_update, this, &MainWindow::handle_transceiver_update); + connect (&m_config, &Configuration::transceiver_failure, this, &MainWindow::handle_transceiver_failure); + connect (&m_config, &Configuration::udp_server_changed, m_messageClient, &MessageClient::set_server); + connect (&m_config, &Configuration::udp_server_port_changed, m_messageClient, &MessageClient::set_server_port); + + // set up configurations menu + connect (m_multi_settings, &MultiSettings::configurationNameChanged, [this] (QString const& name) { + if ("Default" != name) { + config_label.setText (name); + config_label.show (); + } + else { + config_label.hide (); + } + }); + m_multi_settings->create_menu_actions (this, ui->menuConfig); + m_configurations_button = m_rigErrorMessageBox.addButton (tr ("Configurations...") + , QMessageBox::ActionRole); + + // set up message text validators + ui->tx1->setValidator (new QRegExpValidator {message_alphabet, this}); + ui->tx2->setValidator (new QRegExpValidator {message_alphabet, this}); + ui->tx3->setValidator (new QRegExpValidator {message_alphabet, this}); + ui->tx4->setValidator (new QRegExpValidator {message_alphabet, this}); + ui->tx5->setValidator (new QRegExpValidator {message_alphabet, this}); + ui->tx6->setValidator (new QRegExpValidator {message_alphabet, this}); + ui->freeTextMsg->setValidator (new QRegExpValidator {message_alphabet, this}); + + // Free text macros model to widget hook up. + ui->tx5->setModel (m_config.macros ()); + connect (ui->tx5->lineEdit(), &QLineEdit::editingFinished, + [this] () {on_tx5_currentTextChanged (ui->tx5->lineEdit()->text());}); + ui->freeTextMsg->setModel (m_config.macros ()); + connect (ui->freeTextMsg->lineEdit () + , &QLineEdit::editingFinished + , [this] () {on_freeTextMsg_currentTextChanged (ui->freeTextMsg->lineEdit ()->text ());}); + + connect(&m_guiTimer, &QTimer::timeout, this, &MainWindow::guiUpdate); + m_guiTimer.start(100); //### Don't change the 100 ms! ### + + ptt0Timer.setSingleShot(true); + connect(&ptt0Timer, &QTimer::timeout, this, &MainWindow::stopTx2); + + ptt1Timer.setSingleShot(true); + connect(&ptt1Timer, &QTimer::timeout, this, &MainWindow::startTx2); + + p1Timer.setSingleShot(true); + connect(&p1Timer, &QTimer::timeout, this, &MainWindow::startP1); + + logQSOTimer.setSingleShot(true); + connect(&logQSOTimer, &QTimer::timeout, this, &MainWindow::on_logQSOButton_clicked); + + tuneButtonTimer.setSingleShot(true); + connect(&tuneButtonTimer, &QTimer::timeout, this, &MainWindow::on_stopTxButton_clicked); + + tuneATU_Timer.setSingleShot(true); + connect(&tuneATU_Timer, &QTimer::timeout, this, &MainWindow::stopTuneATU); + + killFileTimer.setSingleShot(true); + connect(&killFileTimer, &QTimer::timeout, this, &MainWindow::killFile); + + uploadTimer.setSingleShot(true); + connect(&uploadTimer, SIGNAL(timeout()), this, SLOT(uploadSpots())); + + TxAgainTimer.setSingleShot(true); + connect(&TxAgainTimer, SIGNAL(timeout()), this, SLOT(TxAgain())); + + connect(m_wideGraph.data (), SIGNAL(setFreq3(int,int)),this, + SLOT(setFreq4(int,int))); + + decodeBusy(false); + QString t1[28]={"1 uW","2 uW","5 uW","10 uW","20 uW","50 uW","100 uW","200 uW","500 uW", + "1 mW","2 mW","5 mW","10 mW","20 mW","50 mW","100 mW","200 mW","500 mW", + "1 W","2 W","5 W","10 W","20 W","50 W","100 W","200 W","500 W","1 kW"}; + + m_msg[0][0]=0; + ui->labDXped->setVisible(false); + ui->labDXped->setStyleSheet("QLabel {background-color: red; color: white;}"); + ui->labNextCall->setText(""); + ui->labNextCall->setVisible(false); + ui->labNextCall->setToolTip(""); //### Possibly temporary ? ### + + for(int i=0; i<28; i++) { //Initialize dBm values + float dbm=(10.0*i)/3.0 - 30.0; + int ndbm=0; + if(dbm<0) ndbm=int(dbm-0.5); + if(dbm>=0) ndbm=int(dbm+0.5); + QString t; + t.sprintf("%d dBm ",ndbm); + t+=t1[i]; + ui->TxPowerComboBox->addItem(t); + } + + ui->labAz->setStyleSheet("border: 0px;"); +// ui->labDist->setStyleSheet("border: 0px;"); + + auto t = "UTC dB DT Freq Message"; + ui->decodedTextLabel->setText(t); + ui->decodedTextLabel2->setText(t); + readSettings(); //Restore user's setup parameters + m_audioThread.start (m_audioThreadPriority); + +#ifdef WIN32 + if (!m_multiple) + { + while(true) + { + int iret=killbyname("jt9.exe"); + if(iret == 603) break; + if(iret != 0) + MessageBox::warning_message (this, tr ("Error Killing jt9.exe Process") + , tr ("KillByName return code: %1") + .arg (iret)); + } + } +#endif + + { + //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 {m_config.temp_dir ().absoluteFilePath (".quit")}; + while (quitFile.exists ()) + { + if (!quitFile.remove ()) + { + MessageBox::query_message (this, tr ("Error removing \"%1\"").arg (quitFile.fileName ()) + , tr ("Click OK to retry")); + } + } + } + + //Create .lock so jt9 will wait + QFile {m_config.temp_dir ().absoluteFilePath (".lock")}.open(QIODevice::ReadWrite); + + QStringList jt9_args { + "-s", QApplication::applicationName () // shared memory key, + // includes rig +#ifdef NDEBUG + , "-w", "1" //FFTW patience - release +#else + , "-w", "1" //FFTW patience - debug builds for speed +#endif + // The number of threads for FFTW specified here is chosen as + // three because that gives the best throughput of the large + // FFTs used in jt9. The count is the minimum of (the number + // available CPU threads less one) and three. This ensures that + // there is always at least one free CPU thread to run the other + // mode decoder in parallel. + , "-m", QString::number (qMin (qMax (QThread::idealThreadCount () - 1, 1), 3)) //FFTW threads + + , "-e", QDir::toNativeSeparators (m_appDir) + , "-a", QDir::toNativeSeparators (m_config.writeable_data_dir ().absolutePath ()) + , "-t", QDir::toNativeSeparators (m_config.temp_dir ().absolutePath ()) + }; + QProcessEnvironment env {QProcessEnvironment::systemEnvironment ()}; + env.insert ("OMP_STACKSIZE", "4M"); + proc_jt9.setProcessEnvironment (env); + proc_jt9.start(QDir::toNativeSeparators (m_appDir) + QDir::separator () + + "jt9", jt9_args, QIODevice::ReadWrite | QIODevice::Unbuffered); + + QString fname {QDir::toNativeSeparators(m_config.writeable_data_dir ().absoluteFilePath ("wsjtx_wisdom.dat"))}; + QByteArray cfname=fname.toLocal8Bit(); + fftwf_import_wisdom_from_filename(cfname); + + //genStdMsgs(m_rpt); + m_ntx = 6; + ui->txrb6->setChecked(true); + + connect (&m_wav_future_watcher, &QFutureWatcher<void>::finished, this, &MainWindow::diskDat); + + connect(&watcher3, SIGNAL(finished()),this,SLOT(fast_decode_done())); +// Q_EMIT startAudioInputStream (m_config.audio_input_device (), m_framesAudioInputBuffered, &m_detector, m_downSampleFactor, m_config.audio_input_channel ()); + Q_EMIT startAudioInputStream (m_config.audio_input_device (), m_framesAudioInputBuffered, m_detector, m_downSampleFactor, m_config.audio_input_channel ()); + Q_EMIT initializeAudioOutputStream (m_config.audio_output_device (), AudioDevice::Mono == m_config.audio_output_channel () ? 1 : 2, m_msAudioOutputBuffered); + Q_EMIT transmitFrequency (ui->TxFreqSpinBox->value () - m_XIT); + + enable_DXCC_entity (m_config.DXCC ()); // sets text window proportions and (re)inits the logbook + + ui->label_9->setStyleSheet("QLabel{background-color: #aabec8}"); + ui->label_10->setStyleSheet("QLabel{background-color: #aabec8}"); + + // this must be done before initializing the mode as some modes need + // to turn off split on the rig e.g. WSPR + m_config.transceiver_online (); + bool vhf {m_config.enable_VHF_features ()}; + + ui->txFirstCheckBox->setChecked(m_txFirst); + morse_(const_cast<char *> (m_config.my_callsign ().toLatin1().constData()), + const_cast<int *> (icw), &m_ncw, m_config.my_callsign ().length()); + on_actionWide_Waterfall_triggered(); + ui->cbShMsgs->setChecked(m_bShMsgs); + ui->cbSWL->setChecked(m_bSWL); + if(m_bFast9) m_bFastMode=true; + ui->cbFast9->setChecked(m_bFast9 or m_bFastMode); + + if(m_mode=="FT8") on_actionFT8_triggered(); + if(m_mode=="JT4") on_actionJT4_triggered(); + if(m_mode=="JT9") on_actionJT9_triggered(); + if(m_mode=="JT65") on_actionJT65_triggered(); + if(m_mode=="JT9+JT65") on_actionJT9_JT65_triggered(); + if(m_mode=="WSPR") on_actionWSPR_triggered(); + if(m_mode=="WSPR-LF") on_actionWSPR_LF_triggered(); + if(m_mode=="ISCAT") on_actionISCAT_triggered(); + if(m_mode=="MSK144") on_actionMSK144_triggered(); + if(m_mode=="QRA64") on_actionQRA64_triggered(); + if(m_mode=="Echo") on_actionEcho_triggered(); + if(m_mode=="Echo") monitor(false); //Don't auto-start Monitor in Echo mode. + if(m_mode=="FreqCal") on_actionFreqCal_triggered(); + + ui->sbSubmode->setValue (vhf ? m_nSubMode : 0); + if(m_mode=="MSK144") { + Q_EMIT transmitFrequency (1000.0); + } else { + Q_EMIT transmitFrequency (ui->TxFreqSpinBox->value() - m_XIT); + } + m_saveDecoded=ui->actionSave_decoded->isChecked(); + m_saveAll=ui->actionSave_all->isChecked(); + ui->sbTxPercent->setValue(m_pctx); + ui->TxPowerComboBox->setCurrentIndex(int(0.3*(m_dBm + 30.0)+0.2)); + ui->cbUploadWSPR_Spots->setChecked(m_uploadSpots); + if((m_ndepth&7)==1) ui->actionQuickDecode->setChecked(true); + if((m_ndepth&7)==2) ui->actionMediumDecode->setChecked(true); + if((m_ndepth&7)==3) ui->actionDeepestDecode->setChecked(true); + ui->actionInclude_averaging->setChecked(m_ndepth&16); + ui->actionInclude_correlation->setChecked(m_ndepth&32); + ui->actionEnable_AP_DXcall->setChecked(m_ndepth&64); + + m_UTCdisk=-1; + m_fCPUmskrtd=0.0; + m_bFastDone=false; + m_bAltV=false; + m_bNoMoreFiles=false; + m_bVHFwarned=false; + m_bDoubleClicked=false; + m_bCallingCQ=false; + m_bCheckedContest=false; + m_bDisplayedOnce=false; + m_wait=0; + m_isort=-3; + m_max_dB=30; + m_CQtype="CQ"; + + if(m_mode.startsWith ("WSPR") and m_pctx>0) { + QPalette palette {ui->sbTxPercent->palette ()}; + palette.setColor(QPalette::Base,Qt::yellow); + ui->sbTxPercent->setPalette(palette); + } + fixStop(); + VHF_features_enabled(m_config.enable_VHF_features()); + m_wideGraph->setVHF(m_config.enable_VHF_features()); + + connect( wsprNet, SIGNAL(uploadStatus(QString)), this, SLOT(uploadResponse(QString))); + + statusChanged(); + + m_fastGraph->setMode(m_mode); + m_wideGraph->setMode(m_mode); + m_wideGraph->setModeTx(m_modeTx); + + connect (&minuteTimer, &QTimer::timeout, this, &MainWindow::on_the_minute); + minuteTimer.setSingleShot (true); + minuteTimer.start (ms_minute_error () + 60 * 1000); + + connect (&splashTimer, &QTimer::timeout, this, &MainWindow::splash_done); + splashTimer.setSingleShot (true); + splashTimer.start (20 * 1000); + + //if(QCoreApplication::applicationVersion().contains("-devel") or + // QCoreApplication::applicationVersion().contains("-rc")) { + QTimer::singleShot (0, this, SLOT (not_GA_warning_message ())); + //} + + if(!ui->cbMenus->isChecked()) { + ui->cbMenus->setChecked(true); + ui->cbMenus->setChecked(false); + } +// this must be the last statement of constructor + if (!m_valid) throw std::runtime_error {"Fatal initialization exception"}; +} + +void MainWindow::not_GA_warning_message () +{ + + + MessageBox::critical_message (this, + "<b><p align=\"center\">" + "IMPORTANT: New protocols for the FT8 and MSK144 modes " + "became the world‑wide standards on December 10, 2018." + , "<p align=\"center\">" + "WSJT‑X 2.0 cannot communicate in these modes with other " + "stations using WSJT‑X v1.9.1 or earlier." + "<p align=\"center\">" + "Please help by urging everyone to upgrade to WSJT‑X 2.0 " + "<nobr>no later than January 1, 2019.</nobr>"); + +// QDateTime now=QDateTime::currentDateTime(); +// QDateTime timeout=QDateTime(QDate(2018,12,31)); +// if(now.daysTo(timeout) < 0) Q_EMIT finished(); +} + +void MainWindow::initialize_fonts () +{ + set_application_font (m_config.text_font ()); + setDecodedTextFont (m_config.decoded_text_font ()); +} + +void MainWindow::splash_done () +{ + m_splash && m_splash->close (); +} + +void MainWindow::on_the_minute () +{ + if (minuteTimer.isSingleShot ()) + { + minuteTimer.setSingleShot (false); + minuteTimer.start (60 * 1000); // run free + } + else + { + auto const& ms_error = ms_minute_error (); + if (qAbs (ms_error) > 1000) // keep drift within +-1s + { + minuteTimer.setSingleShot (true); + minuteTimer.start (ms_error + 60 * 1000); + } + } + + if (m_config.watchdog () && !m_mode.startsWith ("WSPR")) + { + if (m_idleMinutes < m_config.watchdog ()) ++m_idleMinutes; + update_watchdog_label (); + } + else + { + tx_watchdog (false); + } +} + +//--------------------------------------------------- MainWindow destructor +MainWindow::~MainWindow() +{ + m_astroWidget.reset (); + QString fname {QDir::toNativeSeparators(m_config.writeable_data_dir ().absoluteFilePath ("wsjtx_wisdom.dat"))}; + QByteArray cfname=fname.toLocal8Bit(); + fftwf_export_wisdom_to_filename(cfname); + m_audioThread.quit (); + m_audioThread.wait (); + remove_child_from_event_filter (this); +} + +//-------------------------------------------------------- writeSettings() +void MainWindow::writeSettings() +{ + m_settings->beginGroup("MainWindow"); + m_settings->setValue ("geometry", saveGeometry ()); + m_settings->setValue ("geometryNoControls", m_geometryNoControls); + m_settings->setValue ("state", saveState ()); + m_settings->setValue("MRUdir", m_path); + m_settings->setValue("TxFirst",m_txFirst); + m_settings->setValue("DXcall",ui->dxCallEntry->text()); + m_settings->setValue("DXgrid",ui->dxGridEntry->text()); + m_settings->setValue ("AstroDisplayed", m_astroWidget && m_astroWidget->isVisible()); + m_settings->setValue ("MsgAvgDisplayed", m_msgAvgWidget && m_msgAvgWidget->isVisible ()); + m_settings->setValue ("FoxLogDisplayed", m_foxLogWindow && m_foxLogWindow->isVisible ()); + m_settings->setValue ("ContestLogDisplayed", m_contestLogWindow && m_contestLogWindow->isVisible ()); + m_settings->setValue ("FreeText", ui->freeTextMsg->currentText ()); + m_settings->setValue("ShowMenus",ui->cbMenus->isChecked()); + m_settings->setValue("CallFirst",ui->cbFirst->isChecked()); + m_settings->setValue("HoundSort",ui->comboBoxHoundSort->currentIndex()); + m_settings->setValue("FoxNlist",ui->sbNlist->value()); + m_settings->setValue("FoxNslots",ui->sbNslots->value()); + m_settings->setValue("FoxMaxDB",ui->sbMax_dB->value()); + m_settings->setValue ("SerialNumber",ui->sbSerialNumber->value ()); + m_settings->endGroup(); + + m_settings->beginGroup("Common"); + m_settings->setValue("Mode",m_mode); + m_settings->setValue("ModeTx",m_modeTx); + m_settings->setValue("SaveNone",ui->actionNone->isChecked()); + m_settings->setValue("SaveDecoded",ui->actionSave_decoded->isChecked()); + m_settings->setValue("SaveAll",ui->actionSave_all->isChecked()); + m_settings->setValue("NDepth",m_ndepth); + m_settings->setValue("RxFreq",ui->RxFreqSpinBox->value()); + m_settings->setValue("TxFreq",ui->TxFreqSpinBox->value()); + m_settings->setValue("WSPRfreq",ui->WSPRfreqSpinBox->value()); + m_settings->setValue("SubMode",ui->sbSubmode->value()); + m_settings->setValue("DTtol",m_DTtol); + m_settings->setValue("Ftol", ui->sbFtol->value ()); + m_settings->setValue("MinSync",m_minSync); + m_settings->setValue ("AutoSeq", ui->cbAutoSeq->isChecked ()); + m_settings->setValue ("RxAll", ui->cbRxAll->isChecked ()); + m_settings->setValue("ShMsgs",m_bShMsgs); + m_settings->setValue("SWL",ui->cbSWL->isChecked()); + m_settings->setValue ("DialFreq", QVariant::fromValue(m_lastMonitoredFrequency)); + m_settings->setValue("OutAttenuation", ui->outAttenuation->value ()); + m_settings->setValue("NoSuffix",m_noSuffix); + m_settings->setValue("GUItab",ui->tabWidget->currentIndex()); + m_settings->setValue("OutBufSize",outBufSize); + m_settings->setValue ("HoldTxFreq", ui->cbHoldTxFreq->isChecked ()); + m_settings->setValue("PctTx",m_pctx); + m_settings->setValue("dBm",m_dBm); + m_settings->setValue("RR73",m_send_RR73); + m_settings->setValue ("WSPRPreferType1", ui->WSPR_prefer_type_1_check_box->isChecked ()); + m_settings->setValue("UploadSpots",m_uploadSpots); + m_settings->setValue("NoOwnCall",ui->cbNoOwnCall->isChecked()); + m_settings->setValue ("BandHopping", ui->band_hopping_group_box->isChecked ()); + m_settings->setValue ("TRPeriod", ui->sbTR->value ()); + m_settings->setValue("FastMode",m_bFastMode); + m_settings->setValue("Fast9",m_bFast9); + m_settings->setValue ("CQTxfreq", ui->sbCQTxFreq->value ()); + m_settings->setValue("pwrBandTxMemory",m_pwrBandTxMemory); + m_settings->setValue("pwrBandTuneMemory",m_pwrBandTuneMemory); + m_settings->setValue ("FT8AP", ui->actionEnable_AP_FT8->isChecked ()); + m_settings->setValue ("JT65AP", ui->actionEnable_AP_JT65->isChecked ()); + m_settings->setValue("SplitterState",ui->splitter->saveState()); + { + QList<QVariant> coeffs; // suitable for QSettings + for (auto const& coeff : m_phaseEqCoefficients) + { + coeffs << coeff; + } + m_settings->setValue ("PhaseEqualizationCoefficients", QVariant {coeffs}); + } + m_settings->endGroup(); +} + +//---------------------------------------------------------- readSettings() +void MainWindow::readSettings() +{ + ui->cbAutoSeq->setVisible(false); + ui->cbFirst->setVisible(false); + m_settings->beginGroup("MainWindow"); + restoreGeometry (m_settings->value ("geometry", saveGeometry ()).toByteArray ()); + m_geometryNoControls = m_settings->value ("geometryNoControls",saveGeometry()).toByteArray(); + restoreState (m_settings->value ("state", saveState ()).toByteArray ()); + ui->dxCallEntry->setText (m_settings->value ("DXcall", QString {}).toString ()); + ui->dxGridEntry->setText (m_settings->value ("DXgrid", QString {}).toString ()); + m_path = m_settings->value("MRUdir", m_config.save_directory ().absolutePath ()).toString (); + m_txFirst = m_settings->value("TxFirst",false).toBool(); + auto displayAstro = m_settings->value ("AstroDisplayed", false).toBool (); + auto displayMsgAvg = m_settings->value ("MsgAvgDisplayed", false).toBool (); + auto displayFoxLog = m_settings->value ("FoxLogDisplayed", false).toBool (); + auto displayContestLog = m_settings->value ("ContestLogDisplayed", false).toBool (); + if (m_settings->contains ("FreeText")) ui->freeTextMsg->setCurrentText ( + m_settings->value ("FreeText").toString ()); + ui->cbMenus->setChecked(m_settings->value("ShowMenus",true).toBool()); + ui->cbFirst->setChecked(m_settings->value("CallFirst",true).toBool()); + ui->comboBoxHoundSort->setCurrentIndex(m_settings->value("HoundSort",3).toInt()); + ui->sbNlist->setValue(m_settings->value("FoxNlist",12).toInt()); + m_Nslots=m_settings->value("FoxNslots",5).toInt(); + ui->sbNslots->setValue(m_Nslots); + ui->sbMax_dB->setValue(m_settings->value("FoxMaxDB",30).toInt()); + ui->sbSerialNumber->setValue (m_settings->value ("SerialNumber", 1).toInt ()); + m_settings->endGroup(); + + // do this outside of settings group because it uses groups internally + ui->actionAstronomical_data->setChecked (displayAstro); + + m_settings->beginGroup("Common"); + m_mode=m_settings->value("Mode","JT9").toString(); + m_modeTx=m_settings->value("ModeTx","JT9").toString(); + if(m_modeTx.mid(0,3)=="JT9") ui->pbTxMode->setText("Tx JT9 @"); + if(m_modeTx=="JT65") ui->pbTxMode->setText("Tx JT65 #"); + ui->actionNone->setChecked(m_settings->value("SaveNone",true).toBool()); + ui->actionSave_decoded->setChecked(m_settings->value("SaveDecoded",false).toBool()); + ui->actionSave_all->setChecked(m_settings->value("SaveAll",false).toBool()); + ui->RxFreqSpinBox->setValue(0); // ensure a change is signaled + ui->RxFreqSpinBox->setValue(m_settings->value("RxFreq",1500).toInt()); + m_nSubMode=m_settings->value("SubMode",0).toInt(); + ui->sbFtol->setValue (m_settings->value("Ftol", 50).toInt()); + m_minSync=m_settings->value("MinSync",0).toInt(); + ui->syncSpinBox->setValue(m_minSync); + ui->cbAutoSeq->setChecked (m_settings->value ("AutoSeq", false).toBool()); + ui->cbRxAll->setChecked (m_settings->value ("RxAll", false).toBool()); + m_bShMsgs=m_settings->value("ShMsgs",false).toBool(); + m_bSWL=m_settings->value("SWL",false).toBool(); + m_bFast9=m_settings->value("Fast9",false).toBool(); + m_bFastMode=m_settings->value("FastMode",false).toBool(); + ui->sbTR->setValue (m_settings->value ("TRPeriod", 15).toInt()); + m_lastMonitoredFrequency = m_settings->value ("DialFreq", + QVariant::fromValue<Frequency> (default_frequency)).value<Frequency> (); + ui->WSPRfreqSpinBox->setValue(0); // ensure a change is signaled + ui->WSPRfreqSpinBox->setValue(m_settings->value("WSPRfreq",1500).toInt()); + ui->TxFreqSpinBox->setValue(0); // ensure a change is signaled + ui->TxFreqSpinBox->setValue(m_settings->value("TxFreq",1500).toInt()); + m_ndepth=m_settings->value("NDepth",3).toInt(); + m_pctx=m_settings->value("PctTx",20).toInt(); + m_dBm=m_settings->value("dBm",37).toInt(); + m_send_RR73=m_settings->value("RR73",37).toBool(); + if(m_send_RR73) { + m_send_RR73=false; + on_txrb4_doubleClicked(); + } + ui->WSPR_prefer_type_1_check_box->setChecked (m_settings->value ("WSPRPreferType1", true).toBool ()); + m_uploadSpots=m_settings->value("UploadSpots",false).toBool(); + if(!m_uploadSpots) ui->cbUploadWSPR_Spots->setStyleSheet("QCheckBox{background-color: yellow}"); + ui->cbNoOwnCall->setChecked(m_settings->value("NoOwnCall",false).toBool()); + ui->band_hopping_group_box->setChecked (m_settings->value ("BandHopping", false).toBool()); + // setup initial value of tx attenuator + m_block_pwr_tooltip = true; + ui->outAttenuation->setValue (m_settings->value ("OutAttenuation", 0).toInt ()); + m_block_pwr_tooltip = false; + ui->sbCQTxFreq->setValue (m_settings->value ("CQTxFreq", 260).toInt()); + m_noSuffix=m_settings->value("NoSuffix",false).toBool(); + int n=m_settings->value("GUItab",0).toInt(); + ui->tabWidget->setCurrentIndex(n); + outBufSize=m_settings->value("OutBufSize",4096).toInt(); + ui->cbHoldTxFreq->setChecked (m_settings->value ("HoldTxFreq", false).toBool ()); + m_pwrBandTxMemory=m_settings->value("pwrBandTxMemory").toHash(); + m_pwrBandTuneMemory=m_settings->value("pwrBandTuneMemory").toHash(); + ui->actionEnable_AP_FT8->setChecked (m_settings->value ("FT8AP", false).toBool()); + ui->actionEnable_AP_JT65->setChecked (m_settings->value ("JT65AP", false).toBool()); + ui->splitter->restoreState(m_settings->value("SplitterState").toByteArray()); + { + auto const& coeffs = m_settings->value ("PhaseEqualizationCoefficients" + , QList<QVariant> {0., 0., 0., 0., 0.}).toList (); + m_phaseEqCoefficients.clear (); + for (auto const& coeff : coeffs) + { + m_phaseEqCoefficients.append (coeff.value<double> ()); + } + } + m_settings->endGroup(); + + // use these initialisation settings to tune the audio o/p buffer + // size and audio thread priority + m_settings->beginGroup ("Tune"); + m_msAudioOutputBuffered = m_settings->value ("Audio/OutputBufferMs").toInt (); + m_framesAudioInputBuffered = m_settings->value ("Audio/InputBufferFrames", RX_SAMPLE_RATE / 10).toInt (); + m_audioThreadPriority = static_cast<QThread::Priority> (m_settings->value ("Audio/ThreadPriority", QThread::HighPriority).toInt () % 8); + m_settings->endGroup (); + + checkMSK144ContestType(); + if(displayMsgAvg) on_actionMessage_averaging_triggered(); + if (displayFoxLog) on_fox_log_action_triggered (); + if (displayContestLog) on_contest_log_action_triggered (); +} + +void MainWindow::checkMSK144ContestType() +{ + if(SpecOp::NONE != m_config.special_op_id()) + { + if(m_mode=="MSK144" && SpecOp::EU_VHF < m_config.special_op_id()) + { + MessageBox::warning_message (this, tr ("Improper mode"), + "Mode will be changed to FT8. MSK144 not available if Fox, Hound, Field Day, or RTTY contest is selected."); + on_actionFT8_triggered(); + } + } +} + +void MainWindow::set_application_font (QFont const& font) +{ + qApp->setFont (font); + // set font in the application style sheet as well in case it has + // been modified in the style sheet which has priority + qApp->setStyleSheet (qApp->styleSheet () + "* {" + font_as_stylesheet (font) + '}'); + for (auto& widget : qApp->topLevelWidgets ()) + { + widget->updateGeometry (); + } +} + +void MainWindow::setDecodedTextFont (QFont const& font) +{ + ui->decodedTextBrowser->setContentFont (font); + ui->decodedTextBrowser2->setContentFont (font); + ui->textBrowser4->setContentFont(font); + ui->textBrowser4->displayFoxToBeCalled(" "); + ui->textBrowser4->setText(""); + auto style_sheet = "QLabel {" + font_as_stylesheet (font) + '}'; + ui->decodedTextLabel->setStyleSheet (ui->decodedTextLabel->styleSheet () + style_sheet); + ui->decodedTextLabel2->setStyleSheet (ui->decodedTextLabel2->styleSheet () + style_sheet); + if (m_msgAvgWidget) { + m_msgAvgWidget->changeFont (font); + } + if (m_foxLogWindow) { + m_foxLogWindow->set_log_view_font (font); + } + if (m_contestLogWindow) { + m_contestLogWindow->set_log_view_font (font); + } + updateGeometry (); +} + +void MainWindow::fixStop() +{ + m_hsymStop=179; + if(m_mode=="WSPR") { + m_hsymStop=396; + } else if(m_mode=="WSPR-LF") { + m_hsymStop=813; + } else if(m_mode=="Echo") { + m_hsymStop=9; + } else if (m_mode=="JT4"){ + m_hsymStop=176; + if(m_config.decode_at_52s()) m_hsymStop=179; + } else if (m_mode=="JT9"){ + m_hsymStop=173; + if(m_config.decode_at_52s()) m_hsymStop=179; + } else if (m_mode=="JT65" or m_mode=="JT9+JT65"){ + m_hsymStop=174; + if(m_config.decode_at_52s()) m_hsymStop=179; + } else if (m_mode=="QRA64"){ + m_hsymStop=179; + if(m_config.decode_at_52s()) m_hsymStop=186; + } else if (m_mode=="FreqCal"){ + m_hsymStop=((int(m_TRperiod/0.288))/8)*8; + } else if (m_mode=="FT8") { + m_hsymStop=50; + } +} + +//-------------------------------------------------------------- dataSink() +void MainWindow::dataSink(qint64 frames) +{ + static float s[NSMAX]; + char line[80]; + + int k (frames); + QString fname {QDir::toNativeSeparators(m_config.writeable_data_dir ().absoluteFilePath ("refspec.dat"))}; + QByteArray bafname = fname.toLatin1(); + const char *c_fname = bafname.data(); + int len=fname.length(); + + if(m_diskData) { + dec_data.params.ndiskdat=1; + } else { + dec_data.params.ndiskdat=0; + } + + m_bUseRef=m_wideGraph->useRef(); + refspectrum_(&dec_data.d2[k-m_nsps/2],&m_bClearRefSpec,&m_bRefSpec, + &m_bUseRef,c_fname,len); + m_bClearRefSpec=false; + + if(m_mode=="ISCAT" or m_mode=="MSK144" or m_bFast9) { + fastSink(frames); + if(m_bFastMode) return; + } + +// Get power, spectrum, and ihsym + int trmin=m_TRperiod/60; +// int k (frames - 1); + dec_data.params.nfa=m_wideGraph->nStartFreq(); + dec_data.params.nfb=m_wideGraph->Fmax(); + int nsps=m_nsps; + if(m_bFastMode) nsps=6912; + int nsmo=m_wideGraph->smoothYellow()-1; + symspec_(&dec_data,&k,&trmin,&nsps,&m_inGain,&nsmo,&m_px,s,&m_df3,&m_ihsym,&m_npts8,&m_pxmax); + if(m_mode=="WSPR") wspr_downsample_(dec_data.d2,&k); + if(m_ihsym <=0) return; + if(ui) ui->signal_meter_widget->setValue(m_px,m_pxmax); // Update thermometer + if(m_monitoring || m_diskData) { + m_wideGraph->dataSink2(s,m_df3,m_ihsym,m_diskData); + } + if(m_mode=="MSK144") return; + + fixStop(); + if (m_mode == "FreqCal" + // only calculate after 1st chunk, also skip chunk where rig + // changed frequency + && !(m_ihsym % 8) && m_ihsym > 8 && m_ihsym <= m_hsymStop) { + int RxFreq=ui->RxFreqSpinBox->value (); + int nkhz=(m_freqNominal+RxFreq)/1000; + int ftol = ui->sbFtol->value (); + freqcal_(&dec_data.d2[0],&k,&nkhz,&RxFreq,&ftol,&line[0],80); + QString t=QString::fromLatin1(line); + DecodedText decodedtext {t}; + ui->decodedTextBrowser->displayDecodedText (decodedtext,m_baseCall,m_mode,m_config.DXCC(), + m_logBook,m_currentBand, m_config.ppfx()); + if (ui->measure_check_box->isChecked ()) { + // Append results text to file "fmt.all". + QFile f {m_config.writeable_data_dir ().absoluteFilePath ("fmt.all")}; + if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) { + QTextStream out(&f); + out << t << endl; + f.close(); + } else { + MessageBox::warning_message (this, tr ("File Open Error") + , tr ("Cannot open \"%1\" for append: %2") + .arg (f.fileName ()).arg (f.errorString ())); + } + } + if(m_ihsym==m_hsymStop && ui->actionFrequency_calibration->isChecked()) { + freqCalStep(); + } + } + + if(m_ihsym==3*m_hsymStop/4) { + m_dialFreqRxWSPR=m_freqNominal; + } + + if(m_ihsym == m_hsymStop) { + if(m_mode=="Echo") { + float snr=0; + int nfrit=0; + int nqual=0; + float f1=1500.0; + float xlevel=0.0; + float sigdb=0.0; + float dfreq=0.0; + float width=0.0; + echocom_.nclearave=m_nclearave; + int nDop=0; + avecho_(dec_data.d2,&nDop,&nfrit,&nqual,&f1,&xlevel,&sigdb, + &snr,&dfreq,&width); + QString t; + t.sprintf("%3d %7.1f %7.1f %7.1f %7.1f %3d",echocom_.nsum,xlevel,sigdb, + dfreq,width,nqual); + t=QDateTime::currentDateTimeUtc().toString("hh:mm:ss ") + t; + if (ui) ui->decodedTextBrowser->appendText(t); + if(m_echoGraph->isVisible()) m_echoGraph->plotSpec(); + m_nclearave=0; +//Don't restart Monitor after an Echo transmission + if(m_bEchoTxed and !m_auto) { + monitor(false); + m_bEchoTxed=false; + } + return; + } + if(m_mode=="FreqCal") { + return; + } + if( m_dialFreqRxWSPR==0) m_dialFreqRxWSPR=m_freqNominal; + m_dataAvailable=true; + dec_data.params.npts8=(m_ihsym*m_nsps)/16; + dec_data.params.newdat=1; + dec_data.params.nagain=0; + dec_data.params.nzhsym=m_hsymStop; + QDateTime now {QDateTime::currentDateTimeUtc ()}; + m_dateTime = now.toString ("yyyy-MMM-dd hh:mm"); + if(!m_mode.startsWith ("WSPR")) decode(); //Start decoder + + if(!m_diskData) { //Always save; may delete later + + if(m_mode=="FT8") { + int n=now.time().second() % m_TRperiod; + if(n<(m_TRperiod/2)) n=n+m_TRperiod; + auto const& period_start=now.addSecs(-n); + m_fnameWE=m_config.save_directory().absoluteFilePath (period_start.toString("yyMMdd_hhmmss")); + } else { + auto const& period_start = now.addSecs (-(now.time ().minute () % (m_TRperiod / 60)) * 60); + m_fnameWE=m_config.save_directory ().absoluteFilePath (period_start.toString ("yyMMdd_hhmm")); + } + m_fileToSave.clear (); + + // the following is potential a threading hazard - not a good + // idea to pass pointer to be processed in another thread + m_saveWAVWatcher.setFuture (QtConcurrent::run (std::bind (&MainWindow::save_wave_file, + this, m_fnameWE, &dec_data.d2[0], m_TRperiod, m_config.my_callsign(), + m_config.my_grid(), m_mode, m_nSubMode, m_freqNominal, m_hisCall, m_hisGrid))); + if (m_mode=="WSPR") { + QString c2name_string {m_fnameWE + ".c2"}; + int len1=c2name_string.length(); + char c2name[80]; + strcpy(c2name,c2name_string.toLatin1 ().constData ()); + int nsec=120; + int nbfo=1500; + double f0m1500=m_freqNominal/1000000.0 + nbfo - 1500; + int err = savec2_(c2name,&nsec,&f0m1500,len1); + if (err!=0) MessageBox::warning_message (this, tr ("Error saving c2 file"), c2name); + } + } + + if(m_mode.startsWith ("WSPR")) { + QString t2,cmnd,depth_string; + double f0m1500=m_dialFreqRxWSPR/1000000.0; // + 0.000001*(m_BFO - 1500); + t2.sprintf(" -f %.6f ",f0m1500); + if((m_ndepth&7)==1) depth_string=" -qB "; //2 pass w subtract, no Block detection, no shift jittering + if((m_ndepth&7)==2) depth_string=" -B "; //2 pass w subtract, no Block detection + if((m_ndepth&7)==3) depth_string=" -C 5000 -o 4"; //2 pass w subtract, Block detection and OSD. + QString degrade; + degrade.sprintf("-d %4.1f ",m_config.degrade()); + + if(m_diskData) { + cmnd='"' + m_appDir + '"' + "/wsprd " + depth_string + " -a \"" + + QDir::toNativeSeparators(m_config.writeable_data_dir ().absolutePath()) + "\" \"" + m_path + "\""; + } else { + if(m_mode=="WSPR-LF") { +// cmnd='"' + m_appDir + '"' + "/wspr_fsk8d " + degrade + t2 +" -a \"" + +// QDir::toNativeSeparators(m_config.writeable_data_dir ().absolutePath()) + "\" " + +// '"' + m_fnameWE + ".wav\""; + } else { + cmnd='"' + m_appDir + '"' + "/wsprd " + depth_string + " -a \"" + + QDir::toNativeSeparators(m_config.writeable_data_dir ().absolutePath()) + "\" " + + t2 + '"' + m_fnameWE + ".wav\""; + } + } + QString t3=cmnd; + int i1=cmnd.indexOf("/wsprd "); + cmnd=t3.mid(0,i1+7) + t3.mid(i1+7); + +// if(m_mode=="WSPR-LF") cmnd=cmnd.replace("/wsprd ","/wspr_fsk8d "+degrade+t2); + if (ui) ui->DecodeButton->setChecked (true); + m_cmndP1=QDir::toNativeSeparators(cmnd); + p1Timer.start(1000); + m_decoderBusy = true; + statusUpdate (); + } + m_rxDone=true; + } +} + +void MainWindow::startP1() +{ + p1.start(m_cmndP1); +} + +QString MainWindow::save_wave_file (QString const& name, short const * data, int seconds, + QString const& my_callsign, QString const& my_grid, QString const& mode, qint32 sub_mode, + Frequency frequency, QString const& his_call, QString const& his_grid) const +{ + // + // This member function runs in a thread and should not access + // members that may be changed in the GUI thread or any other thread + // without suitable synchronization. + // + QAudioFormat format; + format.setCodec ("audio/pcm"); + format.setSampleRate (12000); + format.setChannelCount (1); + format.setSampleSize (16); + format.setSampleType (QAudioFormat::SignedInt); + auto source = QString {"%1, %2"}.arg (my_callsign).arg (my_grid); + auto comment = QString {"Mode=%1%2, Freq=%3%4"} + .arg (mode) + .arg (QString {mode.contains ('J') && !mode.contains ('+') + ? QString {", Sub Mode="} + QChar {'A' + sub_mode} + : QString {}}) + .arg (Radio::frequency_MHz_string (frequency)) + .arg (QString {!mode.startsWith ("WSPR") ? QString {", DXCall=%1, DXGrid=%2"} + .arg (his_call) + .arg (his_grid).toLocal8Bit () : ""}); + BWFFile::InfoDictionary list_info { + {{{'I','S','R','C'}}, source.toLocal8Bit ()}, + {{{'I','S','F','T'}}, program_title (revision ()).simplified ().toLocal8Bit ()}, + {{{'I','C','R','D'}}, QDateTime::currentDateTimeUtc () + .toString ("yyyy-MM-ddTHH:mm:ss.zzzZ").toLocal8Bit ()}, + {{{'I','C','M','T'}}, comment.toLocal8Bit ()}, + }; + auto file_name = name + ".wav"; + BWFFile wav {format, file_name, list_info}; + if (!wav.open (BWFFile::WriteOnly) + || 0 > wav.write (reinterpret_cast<char const *> (data) + , sizeof (short) * seconds * format.sampleRate ())) + { + return file_name + ": " + wav.errorString (); + } + return QString {}; +} + +//-------------------------------------------------------------- fastSink() +void MainWindow::fastSink(qint64 frames) +{ + int k (frames); + bool decodeNow=false; + + if(k < m_k0) { //New sequence ? + memcpy(fast_green2,fast_green,4*703); //Copy fast_green[] to fast_green2[] + memcpy(fast_s2,fast_s,4*703*64); //Copy fast_s[] into fast_s2[] + fast_jh2=fast_jh; + if(!m_diskData) memset(dec_data.d2,0,2*30*12000); //Zero the d2[] array + m_bFastDecodeCalled=false; + m_bDecoded=false; + } + + QDateTime tnow=QDateTime::currentDateTimeUtc(); + int ihr=tnow.toString("hh").toInt(); + int imin=tnow.toString("mm").toInt(); + int isec=tnow.toString("ss").toInt(); + isec=isec - isec%m_TRperiod; + int nutc0=10000*ihr + 100*imin + isec; + if(m_diskData) nutc0=m_UTCdisk; + char line[80]; + bool bmsk144=((m_mode=="MSK144") and (m_monitoring or m_diskData)); + line[0]=0; + + int RxFreq=ui->RxFreqSpinBox->value (); + int nTRpDepth=m_TRperiod + 1000*(m_ndepth & 3); + qint64 ms0 = QDateTime::currentMSecsSinceEpoch(); +// strncpy(dec_data.params.mycall, (m_baseCall+" ").toLatin1(),12); + strncpy(dec_data.params.mycall,(m_config.my_callsign () + " ").toLatin1(),12); + QString hisCall {ui->dxCallEntry->text ()}; + bool bshmsg=ui->cbShMsgs->isChecked(); + bool bswl=ui->cbSWL->isChecked(); +// strncpy(dec_data.params.hiscall,(Radio::base_callsign (hisCall) + " ").toLatin1 ().constData (), 12); + strncpy(dec_data.params.hiscall,(hisCall + " ").toLatin1 ().constData (), 12); + strncpy(dec_data.params.mygrid, (m_config.my_grid()+" ").toLatin1(),6); + QString dataDir; + dataDir = m_config.writeable_data_dir ().absolutePath (); + char ddir[512]; + strncpy(ddir,dataDir.toLatin1(), sizeof (ddir) - 1); + float pxmax = 0; + float rmsNoGain = 0; + int ftol = ui->sbFtol->value (); + int nContest = static_cast<int> (m_config.special_op_id()); + hspec_(dec_data.d2,&k,&nutc0,&nTRpDepth,&RxFreq,&ftol,&nContest,&bmsk144, + &m_bTrain,m_phaseEqCoefficients.constData(),&m_inGain,&dec_data.params.mycall[0], + &dec_data.params.hiscall[0],&bshmsg,&bswl, + &ddir[0],fast_green,fast_s,&fast_jh,&pxmax,&rmsNoGain,&line[0],&dec_data.params.mygrid[0], + 12,12,512,80,6); + float px = fast_green[fast_jh]; + QString t; + t.sprintf(" Rx noise: %5.1f ",px); + ui->signal_meter_widget->setValue(rmsNoGain,pxmax); // Update thermometer + m_fastGraph->plotSpec(m_diskData,m_UTCdisk); + + if(bmsk144 and (line[0]!=0)) { + QString message {QString::fromLatin1 (line)}; + DecodedText decodedtext {message.replace (QChar::LineFeed, "")}; + ui->decodedTextBrowser->displayDecodedText (decodedtext,m_baseCall,m_mode,m_config.DXCC(), + m_logBook,m_currentBand,m_config.ppfx()); + m_bDecoded=true; + auto_sequence (decodedtext, ui->sbFtol->value (), std::numeric_limits<unsigned>::max ()); + if (m_mode != "ISCAT") postDecode (true, decodedtext.string ()); + writeAllTxt(message); + bool stdMsg = decodedtext.report(m_baseCall, + Radio::base_callsign(ui->dxCallEntry->text()),m_rptRcvd); + if (stdMsg) pskPost (decodedtext); + } + + float fracTR=float(k)/(12000.0*m_TRperiod); + decodeNow=false; + if(fracTR>0.92) { + m_dataAvailable=true; + fast_decode_done(); + m_bFastDone=true; + } + + m_k0=k; + if(m_diskData and m_k0 >= dec_data.params.kin - 7 * 512) decodeNow=true; + if(!m_diskData and m_tRemaining<0.35 and !m_bFastDecodeCalled) decodeNow=true; + if(m_mode=="MSK144") decodeNow=false; + + if(decodeNow) { + m_dataAvailable=true; + m_t0=0.0; + m_t1=k/12000.0; + m_kdone=k; + dec_data.params.newdat=1; + if(!m_decoderBusy) { + m_bFastDecodeCalled=true; + decode(); + } + } + + if(decodeNow or m_bFastDone) { + if(!m_diskData) { + QDateTime now {QDateTime::currentDateTimeUtc()}; + int n=now.time().second() % m_TRperiod; + if(n<(m_TRperiod/2)) n=n+m_TRperiod; + auto const& period_start = now.addSecs (-n); + m_fnameWE = m_config.save_directory ().absoluteFilePath (period_start.toString ("yyMMdd_hhmmss")); + m_fileToSave.clear (); + if(m_saveAll or m_bAltV or (m_bDecoded and m_saveDecoded) or (m_mode!="MSK144")) { + m_bAltV=false; + // the following is potential a threading hazard - not a good + // idea to pass pointer to be processed in another thread + m_saveWAVWatcher.setFuture (QtConcurrent::run (std::bind (&MainWindow::save_wave_file, + this, m_fnameWE, &dec_data.d2[0], m_TRperiod, m_config.my_callsign(), + m_config.my_grid(), m_mode, m_nSubMode, m_freqNominal, m_hisCall, m_hisGrid))); + } + if(m_mode!="MSK144") { + killFileTimer.start (3*1000*m_TRperiod/4); //Kill 3/4 period from now + } + } + m_bFastDone=false; + } + float tsec=0.001*(QDateTime::currentMSecsSinceEpoch() - ms0); + m_fCPUmskrtd=0.9*m_fCPUmskrtd + 0.1*tsec; +} + +void MainWindow::showSoundInError(const QString& errorMsg) +{ + if (m_splash && m_splash->isVisible ()) m_splash->hide (); + MessageBox::critical_message (this, tr ("Error in Sound Input"), errorMsg); +} + +void MainWindow::showSoundOutError(const QString& errorMsg) +{ + if (m_splash && m_splash->isVisible ()) m_splash->hide (); + MessageBox::critical_message (this, tr ("Error in Sound Output"), errorMsg); +} + +void MainWindow::showStatusMessage(const QString& statusMsg) +{ + statusBar()->showMessage(statusMsg, 5000); +} + +void MainWindow::on_actionSettings_triggered() //Setup Dialog +{ + // things that might change that we need know about + auto callsign = m_config.my_callsign (); + auto my_grid = m_config.my_grid (); + SpecOp nContest0=m_config.special_op_id(); + if (QDialog::Accepted == m_config.exec ()) { + checkMSK144ContestType(); + if (m_config.my_callsign () != callsign) { + m_baseCall = Radio::base_callsign (m_config.my_callsign ()); + morse_(const_cast<char *> (m_config.my_callsign ().toLatin1().constData()), + const_cast<int *> (icw), &m_ncw, m_config.my_callsign ().length()); + } + if (m_config.my_callsign () != callsign || m_config.my_grid () != my_grid) { + statusUpdate (); + } + on_dxGridEntry_textChanged (m_hisGrid); // recalculate distances in case of units change + enable_DXCC_entity (m_config.DXCC ()); // sets text window proportions and (re)inits the logbook + + if(m_config.spot_to_psk_reporter ()) pskSetLocal (); + + if(m_config.restart_audio_input ()) { + Q_EMIT startAudioInputStream (m_config.audio_input_device (), + m_framesAudioInputBuffered, m_detector, m_downSampleFactor, + m_config.audio_input_channel ()); + } + + if(m_config.restart_audio_output ()) { + Q_EMIT initializeAudioOutputStream (m_config.audio_output_device (), + AudioDevice::Mono == m_config.audio_output_channel () ? 1 : 2, + m_msAudioOutputBuffered); + } + + displayDialFrequency (); + bool vhf {m_config.enable_VHF_features()}; + m_wideGraph->setVHF(vhf); + if (!vhf) ui->sbSubmode->setValue (0); + + setup_status_bar (vhf); + bool b = vhf && (m_mode=="JT4" or m_mode=="JT65" or m_mode=="ISCAT" or + m_mode=="JT9" or m_mode=="MSK144" or m_mode=="QRA64"); + if(b) VHF_features_enabled(b); + if(m_mode=="FT8") on_actionFT8_triggered(); + if(m_mode=="JT4") on_actionJT4_triggered(); + if(m_mode=="JT9") on_actionJT9_triggered(); + if(m_mode=="JT9+JT65") on_actionJT9_JT65_triggered(); + if(m_mode=="JT65") on_actionJT65_triggered(); + if(m_mode=="QRA64") on_actionQRA64_triggered(); + if(m_mode=="FreqCal") on_actionFreqCal_triggered(); + if(m_mode=="ISCAT") on_actionISCAT_triggered(); + if(m_mode=="MSK144") on_actionMSK144_triggered(); + if(m_mode=="WSPR") on_actionWSPR_triggered(); + if(m_mode=="WSPR-LF") on_actionWSPR_LF_triggered(); + if(m_mode=="Echo") on_actionEcho_triggered(); + if(b) VHF_features_enabled(b); + + m_config.transceiver_online (); + if(!m_bFastMode) setXIT (ui->TxFreqSpinBox->value ()); + if(m_config.single_decode() or m_mode=="JT4") { + ui->label_6->setText("Single-Period Decodes"); + ui->label_7->setText("Average Decodes"); + } + + update_watchdog_label (); + if(!m_splitMode) ui->cbCQTx->setChecked(false); + if(!m_config.enable_VHF_features()) { + ui->actionInclude_averaging->setVisible(false); + ui->actionInclude_correlation->setVisible (false); + ui->actionInclude_averaging->setChecked(false); + ui->actionInclude_correlation->setChecked(false); + ui->actionEnable_AP_JT65->setVisible(false); + } + if(m_config.special_op_id()!=nContest0) ui->tx1->setEnabled(true); + } +} + +void MainWindow::on_monitorButton_clicked (bool checked) +{ + if (!m_transmitting) { + auto prior = m_monitoring; + monitor (checked); + if (checked && !prior) { + if (m_config.monitor_last_used ()) { + // put rig back where it was when last in control + setRig (m_lastMonitoredFrequency); + setXIT (ui->TxFreqSpinBox->value ()); + } + // ensure FreqCal triggers + on_RxFreqSpinBox_valueChanged (ui->RxFreqSpinBox->value ()); + } + //Get Configuration in/out of strict split and mode checking + Q_EMIT m_config.sync_transceiver (true, checked); + } else { + ui->monitorButton->setChecked (false); // disallow + } +} + +void MainWindow::monitor (bool state) +{ + ui->monitorButton->setChecked (state); + if (state) { + m_diskData = false; // no longer reading WAV files + if (!m_monitoring) Q_EMIT resumeAudioInputStream (); + } else { + Q_EMIT suspendAudioInputStream (); + } + m_monitoring = state; +} + +void MainWindow::on_actionAbout_triggered() //Display "About" +{ + CAboutDlg {this}.exec (); +} + +void MainWindow::on_autoButton_clicked (bool checked) +{ + m_auto = checked; + if (checked + && ui->cbFirst->isVisible () && ui->cbFirst->isChecked() + && CALLING == m_QSOProgress) { + m_bAutoReply = false; // ready for next + m_bCallingCQ = true; // allows tail-enders to be picked up + ui->cbFirst->setStyleSheet ("QCheckBox{color:red}"); + } else { + ui->cbFirst->setStyleSheet(""); + } + if (!checked) m_bCallingCQ = false; + statusUpdate (); + m_bEchoTxOK=false; + if(m_auto and (m_mode=="Echo")) { + m_nclearave=1; + echocom_.nsum=0; + } + if(m_mode.startsWith ("WSPR")) { + QPalette palette {ui->sbTxPercent->palette ()}; + if(m_auto or m_pctx==0) { + palette.setColor(QPalette::Base,Qt::white); + } else { + palette.setColor(QPalette::Base,Qt::yellow); + } + ui->sbTxPercent->setPalette(palette); + } + m_tAutoOn=QDateTime::currentMSecsSinceEpoch()/1000; +} + +void MainWindow::auto_tx_mode (bool state) +{ + ui->autoButton->setChecked (state); + on_autoButton_clicked (state); +} + +void MainWindow::keyPressEvent (QKeyEvent * e) +{ + + if(SpecOp::FOX == m_config.special_op_id()) { + switch (e->key()) { + case Qt::Key_Return: + doubleClickOnCall2(Qt::KeyboardModifier(Qt::ShiftModifier + Qt::ControlModifier + Qt::AltModifier)); + return; + case Qt::Key_Enter: + doubleClickOnCall2(Qt::KeyboardModifier(Qt::ShiftModifier + Qt::ControlModifier + Qt::AltModifier)); + return; + case Qt::Key_Backspace: + qDebug() << "Key Backspace"; + return; + } + QMainWindow::keyPressEvent (e); + } + + if(SpecOp::HOUND == m_config.special_op_id()) { + switch (e->key()) { + case Qt::Key_Return: + auto_tx_mode(true); + return; + case Qt::Key_Enter: + auto_tx_mode(true); + return; + } + QMainWindow::keyPressEvent (e); + } + + int n; + switch(e->key()) + { + case Qt::Key_D: + if(m_mode != "WSPR" && e->modifiers() & Qt::ShiftModifier) { + if(!m_decoderBusy) { + dec_data.params.newdat=0; + dec_data.params.nagain=0; + decode(); + return; + } + } + break; + case Qt::Key_F1: + on_actionOnline_User_Guide_triggered(); + return; + case Qt::Key_F2: + on_actionSettings_triggered(); + return; + case Qt::Key_F3: + on_actionKeyboard_shortcuts_triggered(); + return; + case Qt::Key_F4: + clearDX (); + ui->dxCallEntry->setFocus(); + return; + case Qt::Key_F5: + on_actionSpecial_mouse_commands_triggered(); + return; + case Qt::Key_F6: + if(e->modifiers() & Qt::ShiftModifier) { + on_actionDecode_remaining_files_in_directory_triggered(); + return; + } + on_actionOpen_next_in_directory_triggered(); + return; + case Qt::Key_F11: + if((e->modifiers() & Qt::ControlModifier) and (e->modifiers() & Qt::ShiftModifier)) { + m_bandEdited = true; + band_changed(m_freqNominal-2000); + } else { + n=11; + if(e->modifiers() & Qt::ControlModifier) n+=100; + if(e->modifiers() & Qt::ShiftModifier) { + ui->TxFreqSpinBox->setValue(ui->TxFreqSpinBox->value()-60); + } else{ + bumpFqso(n); + } + } + return; + case Qt::Key_F12: + if((e->modifiers() & Qt::ControlModifier) and (e->modifiers() & Qt::ShiftModifier)) { + m_bandEdited = true; + band_changed(m_freqNominal+2000); + } else { + n=12; + if(e->modifiers() & Qt::ControlModifier) n+=100; + if(e->modifiers() & Qt::ShiftModifier) { + ui->TxFreqSpinBox->setValue(ui->TxFreqSpinBox->value()+60); + } else { + bumpFqso(n); + } + } + return; + case Qt::Key_Escape: + m_nextCall=""; + ui->labNextCall->setStyleSheet(""); + ui->labNextCall->setText(""); + on_stopTxButton_clicked(); + abortQSO(); + return; + case Qt::Key_X: + if(e->modifiers() & Qt::AltModifier) { + foxTest(); + return; + } + case Qt::Key_E: + if((e->modifiers() & Qt::ShiftModifier) and SpecOp::FOX > m_config.special_op_id()) { + ui->txFirstCheckBox->setChecked(false); + return; + } + else if((e->modifiers() & Qt::ControlModifier) and SpecOp::FOX > m_config.special_op_id()) { + ui->txFirstCheckBox->setChecked(true); + return; + } + break; + case Qt::Key_F: + if(e->modifiers() & Qt::ControlModifier) { + if(ui->tabWidget->currentIndex()==0) { + ui->tx5->clearEditText(); + ui->tx5->setFocus(); + } else { + ui->freeTextMsg->clearEditText(); + ui->freeTextMsg->setFocus(); + } + return; + } + break; + case Qt::Key_G: + if(e->modifiers() & Qt::AltModifier) { + genStdMsgs (m_rpt, true); + return; + } + break; + case Qt::Key_H: + if(e->modifiers() & Qt::AltModifier) { + on_stopTxButton_clicked(); + return; + } + break; + case Qt::Key_L: + if(e->modifiers() & Qt::ControlModifier) { + lookup(); + genStdMsgs(m_rpt); + return; + } + break; + case Qt::Key_O: + if(e->modifiers() & Qt::ControlModifier) { + on_actionOpen_triggered(); + return; + } + break; + case Qt::Key_V: + if(e->modifiers() & Qt::AltModifier) { + m_fileToSave = m_fnameWE; + m_bAltV=true; + return; + } + break; + case Qt::Key_PageUp: + + break; + case Qt::Key_PageDown: + band_changed(m_freqNominal-2000); + break; } + + QMainWindow::keyPressEvent (e); +} + +void MainWindow::bumpFqso(int n) //bumpFqso() +{ + int i; + bool ctrl = (n>=100); + n=n%100; + i=ui->RxFreqSpinBox->value(); + bool bTrackTx=ui->TxFreqSpinBox->value() == i; + if(n==11) i--; + if(n==12) i++; + if (ui->RxFreqSpinBox->isEnabled ()) { + ui->RxFreqSpinBox->setValue (i); + } + if(ctrl and m_mode.startsWith ("WSPR")) { + ui->WSPRfreqSpinBox->setValue(i); + } else { + if(ctrl and bTrackTx) { + ui->TxFreqSpinBox->setValue (i); + } + } +} + +void MainWindow::displayDialFrequency () +{ + Frequency dial_frequency {m_rigState.ptt () && m_rigState.split () ? + m_rigState.tx_frequency () : m_rigState.frequency ()}; + + // lookup band + auto const& band_name = m_config.bands ()->find (dial_frequency); + if (m_lastBand != band_name) + { + // only change this when necessary as we get called a lot and it + // would trash any user input to the band combo box line edit + ui->bandComboBox->setCurrentText (band_name); + m_wideGraph->setRxBand (band_name); + m_lastBand = band_name; + band_changed(dial_frequency); + } + + // search working frequencies for one we are within 10kHz of (1 Mhz + // of on VHF and up) + bool valid {false}; + quint64 min_offset {99999999}; + for (auto const& item : *m_config.frequencies ()) + { + // we need to do specific checks for above and below here to + // ensure that we can use unsigned Radio::Frequency since we + // potentially use the full 64-bit unsigned range. + auto const& working_frequency = item.frequency_; + auto const& offset = dial_frequency > working_frequency ? + dial_frequency - working_frequency : + working_frequency - dial_frequency; + if (offset < min_offset) { + min_offset = offset; + } + } + if (min_offset < 10000u || (m_config.enable_VHF_features() && min_offset < 1000000u)) { + valid = true; + } + + update_dynamic_property (ui->labDialFreq, "oob", !valid); + ui->labDialFreq->setText (Radio::pretty_frequency_MHz_string (dial_frequency)); +} + +void MainWindow::statusChanged() +{ + statusUpdate (); + QFile f {m_config.temp_dir ().absoluteFilePath ("wsjtx_status.txt")}; + if(f.open(QFile::WriteOnly | QIODevice::Text)) { + QTextStream out(&f); + QString tmpGrid = m_hisGrid; + if (!tmpGrid.size ()) tmpGrid="n/a"; // Not Available + out << qSetRealNumberPrecision (12) << (m_freqNominal / 1.e6) + << ";" << m_mode << ";" << m_hisCall << ";" + << ui->rptSpinBox->value() << ";" << m_modeTx << ";" << tmpGrid << endl; + f.close(); + } else { + if (m_splash && m_splash->isVisible ()) m_splash->hide (); + MessageBox::warning_message (this, tr ("Status File Error") + , tr ("Cannot open \"%1\" for writing: %2") + .arg (f.fileName ()).arg (f.errorString ())); + } + on_dxGridEntry_textChanged(m_hisGrid); +} + +bool MainWindow::eventFilter (QObject * object, QEvent * event) +{ + switch (event->type()) + { + case QEvent::KeyPress: + // fall through + case QEvent::MouseButtonPress: + // reset the Tx watchdog + tx_watchdog (false); + break; + + case QEvent::ChildAdded: + // ensure our child widgets get added to our event filter + add_child_to_event_filter (static_cast<QChildEvent *> (event)->child ()); + break; + + case QEvent::ChildRemoved: + // ensure our child widgets get d=removed from our event filter + remove_child_from_event_filter (static_cast<QChildEvent *> (event)->child ()); + break; + + default: break; + } + return QObject::eventFilter(object, event); +} + +void MainWindow::createStatusBar() //createStatusBar +{ + tx_status_label.setAlignment (Qt::AlignHCenter); + tx_status_label.setMinimumSize (QSize {150, 18}); + tx_status_label.setStyleSheet ("QLabel{background-color: #00ff00}"); + tx_status_label.setFrameStyle (QFrame::Panel | QFrame::Sunken); + statusBar()->addWidget (&tx_status_label); + + config_label.setAlignment (Qt::AlignHCenter); + config_label.setMinimumSize (QSize {80, 18}); + config_label.setFrameStyle (QFrame::Panel | QFrame::Sunken); + statusBar()->addWidget (&config_label); + config_label.hide (); // only shown for non-default configuration + + mode_label.setAlignment (Qt::AlignHCenter); + mode_label.setMinimumSize (QSize {80, 18}); + mode_label.setFrameStyle (QFrame::Panel | QFrame::Sunken); + statusBar()->addWidget (&mode_label); + + last_tx_label.setAlignment (Qt::AlignHCenter); + last_tx_label.setMinimumSize (QSize {150, 18}); + last_tx_label.setFrameStyle (QFrame::Panel | QFrame::Sunken); + statusBar()->addWidget (&last_tx_label); + + band_hopping_label.setAlignment (Qt::AlignHCenter); + band_hopping_label.setMinimumSize (QSize {90, 18}); + band_hopping_label.setFrameStyle (QFrame::Panel | QFrame::Sunken); + + statusBar()->addPermanentWidget(&progressBar); + progressBar.setMinimumSize (QSize {150, 18}); + progressBar.setFormat ("%v/%m"); + + statusBar ()->addPermanentWidget (&watchdog_label); + update_watchdog_label (); +} + +void MainWindow::setup_status_bar (bool vhf) +{ + auto submode = current_submode (); + if (vhf && submode != QChar::Null) + { + mode_label.setText (m_mode + " " + submode); + } + else + { + mode_label.setText (m_mode); + } + if ("ISCAT" == m_mode) { + mode_label.setStyleSheet ("QLabel{background-color: #ff9933}"); + } else if ("JT9" == m_mode) { + mode_label.setStyleSheet ("QLabel{background-color: #ff6ec7}"); + } else if ("JT4" == m_mode) { + mode_label.setStyleSheet ("QLabel{background-color: #cc99ff}"); + } else if ("Echo" == m_mode) { + mode_label.setStyleSheet ("QLabel{background-color: #66ffff}"); + } else if ("JT9+JT65" == m_mode) { + mode_label.setStyleSheet ("QLabel{background-color: #ffff66}"); + } else if ("JT65" == m_mode) { + mode_label.setStyleSheet ("QLabel{background-color: #66ff66}"); + } else if ("QRA64" == m_mode) { + mode_label.setStyleSheet ("QLabel{background-color: #99ff33}"); + } else if ("MSK144" == m_mode) { + mode_label.setStyleSheet ("QLabel{background-color: #ff6666}"); + } else if ("FT8" == m_mode) { + mode_label.setStyleSheet ("QLabel{background-color: #6699ff}"); + } else if ("FreqCal" == m_mode) { + mode_label.setStyleSheet ("QLabel{background-color: #ff9933}"); } + last_tx_label.setText (QString {}); + if (m_mode.contains (QRegularExpression {R"(^(Echo|ISCAT))"})) { + if (band_hopping_label.isVisible ()) statusBar ()->removeWidget (&band_hopping_label); + } else if (m_mode.startsWith ("WSPR")) { + mode_label.setStyleSheet ("QLabel{background-color: #ff66ff}"); + if (!band_hopping_label.isVisible ()) { + statusBar ()->addWidget (&band_hopping_label); + band_hopping_label.show (); + } + } else { + if (band_hopping_label.isVisible ()) statusBar ()->removeWidget (&band_hopping_label); + } +} + +void MainWindow::subProcessFailed (QProcess * process, int exit_code, QProcess::ExitStatus status) +{ + if (m_valid && (exit_code || QProcess::NormalExit != status)) + { + QStringList arguments; + for (auto argument: process->arguments ()) + { + if (argument.contains (' ')) argument = '"' + argument + '"'; + arguments << argument; + } + if (m_splash && m_splash->isVisible ()) m_splash->hide (); + MessageBox::critical_message (this, tr ("Subprocess Error") + , tr ("Subprocess failed with exit code %1") + .arg (exit_code) + , tr ("Running: %1\n%2") + .arg (process->program () + ' ' + arguments.join (' ')) + .arg (QString {process->readAllStandardError()})); + QTimer::singleShot (0, this, SLOT (close ())); + m_valid = false; // ensures exit if still constructing + } +} + +void MainWindow::subProcessError (QProcess * process, QProcess::ProcessError) +{ + if (m_valid) + { + QStringList arguments; + for (auto argument: process->arguments ()) + { + if (argument.contains (' ')) argument = '"' + argument + '"'; + arguments << argument; + } + if (m_splash && m_splash->isVisible ()) m_splash->hide (); + MessageBox::critical_message (this, tr ("Subprocess error") + , tr ("Running: %1\n%2") + .arg (process->program () + ' ' + arguments.join (' ')) + .arg (process->errorString ())); + QTimer::singleShot (0, this, SLOT (close ())); + m_valid = false; // ensures exit if still constructing + } +} + +void MainWindow::closeEvent(QCloseEvent * e) +{ + m_valid = false; // suppresses subprocess errors + m_config.transceiver_offline (); + writeSettings (); + m_astroWidget.reset (); + m_guiTimer.stop (); + m_prefixes.reset (); + m_shortcuts.reset (); + m_mouseCmnds.reset (); + m_colorHighlighting.reset (); + if(m_mode!="MSK144" and m_mode!="FT8") killFile(); + float sw=0.0; + int nw=400; + int nh=100; + int irow=-99; + plotsave_(&sw,&nw,&nh,&irow); + mem_jt9->detach(); + QFile quitFile {m_config.temp_dir ().absoluteFilePath (".quit")}; + quitFile.open(QIODevice::ReadWrite); + QFile {m_config.temp_dir ().absoluteFilePath (".lock")}.remove(); // Allow jt9 to terminate + bool b=proc_jt9.waitForFinished(1000); + if(!b) proc_jt9.close(); + quitFile.remove(); + Q_EMIT finished (); + QMainWindow::closeEvent (e); +} + +void MainWindow::on_stopButton_clicked() //stopButton +{ + monitor (false); + m_loopall=false; + if(m_bRefSpec) { + MessageBox::information_message (this, tr ("Reference spectrum saved")); + m_bRefSpec=false; + } +} + +void MainWindow::on_actionRelease_Notes_triggered () +{ + QDesktopServices::openUrl (QUrl {"http://physics.princeton.edu/pulsar/k1jt/Release_Notes.txt"}); +} + +void MainWindow::on_actionFT8_DXpedition_Mode_User_Guide_triggered() +{ + QDesktopServices::openUrl (QUrl {"http://physics.princeton.edu/pulsar/k1jt/FT8_DXpedition_Mode.pdf"}); +} + +void MainWindow::on_actionQuick_Start_Guide_v2_triggered() +{ + QDesktopServices::openUrl (QUrl {"https://physics.princeton.edu/pulsar/k1jt/Quick_Start_WSJT-X_2.0.pdf"}); +} + +void MainWindow::on_actionOnline_User_Guide_triggered() //Display manual +{ +#if defined (CMAKE_BUILD) + m_manual.display_html_url (QUrl {PROJECT_MANUAL_DIRECTORY_URL}, PROJECT_MANUAL); +#endif +} + +//Display local copy of manual +void MainWindow::on_actionLocal_User_Guide_triggered() +{ +#if defined (CMAKE_BUILD) + m_manual.display_html_file (m_config.doc_dir (), PROJECT_MANUAL); +#endif +} + +void MainWindow::on_actionWide_Waterfall_triggered() //Display Waterfalls +{ + m_wideGraph->show(); +} + +void MainWindow::on_actionEcho_Graph_triggered() +{ + m_echoGraph->show(); +} + +void MainWindow::on_actionFast_Graph_triggered() +{ + m_fastGraph->show(); +} + +void MainWindow::on_actionSolve_FreqCal_triggered() +{ + QString dpath{QDir::toNativeSeparators(m_config.writeable_data_dir().absolutePath()+"/")}; + char data_dir[512]; + int len=dpath.length(); + int iz,irc; + double a,b,rms,sigmaa,sigmab; + strncpy(data_dir,dpath.toLatin1(),len); + calibrate_(data_dir,&iz,&a,&b,&rms,&sigmaa,&sigmab,&irc,len); + QString t2; + if(irc==-1) t2="Cannot open " + dpath + "fmt.all"; + if(irc==-2) t2="Cannot open " + dpath + "fcal2.out"; + if(irc==-3) t2="Insufficient data in fmt.all"; + if(irc==-4) t2 = tr ("Invalid data in fmt.all at line %1").arg (iz); + if(irc>0 or rms>1.0) t2="Check fmt.all for possible bad data."; + if (irc < 0 || irc > 0 || rms > 1.) { + MessageBox::warning_message (this, "Calibration Error", t2); + } + else if (MessageBox::Apply == MessageBox::query_message (this + , tr ("Good Calibration Solution") + , tr ("<pre>" + "%1%L2 ±%L3 ppm\n" + "%4%L5 ±%L6 Hz\n\n" + "%7%L8\n" + "%9%L10 Hz" + "</pre>") + .arg ("Slope: ", 12).arg (b, 0, 'f', 3).arg (sigmab, 0, 'f', 3) + .arg ("Intercept: ", 12).arg (a, 0, 'f', 2).arg (sigmaa, 0, 'f', 2) + .arg ("N: ", 12).arg (iz) + .arg ("StdDev: ", 12).arg (rms, 0, 'f', 2) + , QString {} + , MessageBox::Cancel | MessageBox::Apply)) { + m_config.set_calibration (Configuration::CalibrationParams {a, b}); + if (MessageBox::Yes == MessageBox::query_message (this + , tr ("Delete Calibration Measurements") + , tr ("The \"fmt.all\" file will be renamed as \"fmt.bak\""))) { + // rename fmt.all as we have consumed the resulting calibration + // solution + auto const& backup_file_name = m_config.writeable_data_dir ().absoluteFilePath ("fmt.bak"); + QFile::remove (backup_file_name); + QFile::rename (m_config.writeable_data_dir ().absoluteFilePath ("fmt.all"), backup_file_name); + } + } +} + +void MainWindow::on_actionCopyright_Notice_triggered() +{ + auto const& message = tr("If you make fair use of any part of WSJT-X under terms of the GNU " + "General Public License, you must display the following copyright " + "notice prominently in your derivative work:\n\n" + "\"The algorithms, source code, look-and-feel of WSJT-X and related " + "programs, and protocol specifications for the modes FSK441, FT8, JT4, " + "JT6M, JT9, JT65, JTMS, QRA64, ISCAT, MSK144 are Copyright (C) " + "2001-2018 by one or more of the following authors: Joseph Taylor, " + "K1JT; Bill Somerville, G4WJS; Steven Franke, K9AN; Nico Palermo, " + "IV3NWV; Greg Beam, KI7MT; Michael Black, W9MDB; Edson Pereira, PY2SDR; " + "Philip Karn, KA9Q; and other members of the WSJT Development Group.\""); + MessageBox::warning_message(this, message); +} + +// This allows the window to shrink by removing certain things +// and reducing space used by controls +void MainWindow::hideMenus(bool checked) +{ + int spacing = checked ? 1 : 6; + if (checked) { + statusBar ()->removeWidget (&auto_tx_label); + minimumSize().setHeight(450); + minimumSize().setWidth(700); + restoreGeometry(m_geometryNoControls); + updateGeometry(); + } else { + m_geometryNoControls = saveGeometry(); + statusBar ()->addWidget(&auto_tx_label); + minimumSize().setHeight(520); + minimumSize().setWidth(770); + } + ui->menuBar->setVisible(!checked); + if(m_mode!="FreqCal" and m_mode!="WSPR") { + ui->label_6->setVisible(!checked); + ui->label_7->setVisible(!checked); + ui->decodedTextLabel2->setVisible(!checked); + } + ui->decodedTextLabel->setVisible(!checked); + ui->gridLayout_5->layout()->setSpacing(spacing); + ui->horizontalLayout->layout()->setSpacing(spacing); + ui->horizontalLayout_2->layout()->setSpacing(spacing); + ui->horizontalLayout_3->layout()->setSpacing(spacing); + ui->horizontalLayout_5->layout()->setSpacing(spacing); + ui->horizontalLayout_6->layout()->setSpacing(spacing); + ui->horizontalLayout_7->layout()->setSpacing(spacing); + ui->horizontalLayout_8->layout()->setSpacing(spacing); + ui->horizontalLayout_9->layout()->setSpacing(spacing); + ui->horizontalLayout_10->layout()->setSpacing(spacing); + ui->horizontalLayout_11->layout()->setSpacing(spacing); + ui->horizontalLayout_12->layout()->setSpacing(spacing); + ui->horizontalLayout_13->layout()->setSpacing(spacing); + ui->horizontalLayout_14->layout()->setSpacing(spacing); + ui->verticalLayout->layout()->setSpacing(spacing); + ui->verticalLayout_2->layout()->setSpacing(spacing); + ui->verticalLayout_3->layout()->setSpacing(spacing); + ui->verticalLayout_4->layout()->setSpacing(spacing); + ui->verticalLayout_5->layout()->setSpacing(spacing); + ui->verticalLayout_7->layout()->setSpacing(spacing); + ui->verticalLayout_8->layout()->setSpacing(spacing); + ui->tab->layout()->setSpacing(spacing); +} + +void MainWindow::on_actionAstronomical_data_toggled (bool checked) +{ + if (checked) + { + m_astroWidget.reset (new Astro {m_settings, &m_config}); + + // hook up termination signal + connect (this, &MainWindow::finished, m_astroWidget.data (), &Astro::close); + connect (m_astroWidget.data (), &Astro::tracking_update, [this] { + m_astroCorrection = {}; + setRig (); + setXIT (ui->TxFreqSpinBox->value ()); + displayDialFrequency (); + }); + m_astroWidget->showNormal(); + m_astroWidget->raise (); + m_astroWidget->activateWindow (); + m_astroWidget->nominal_frequency (m_freqNominal, m_freqTxNominal); + } + else + { + m_astroWidget.reset (); + } +} + +void MainWindow::on_fox_log_action_triggered() +{ + if (!m_foxLog) m_foxLog.reset (new FoxLog); + if (!m_foxLogWindow) + { + m_foxLogWindow.reset (new FoxLogWindow {m_settings, &m_config, m_foxLog->model ()}); + + // Connect signals from fox log window + connect (this, &MainWindow::finished, m_foxLogWindow.data (), &FoxLogWindow::close); + connect (m_foxLogWindow.data (), &FoxLogWindow::reset_log_model, [this] () { + if (!m_foxLog) m_foxLog.reset (new FoxLog); + m_foxLog->reset (); + }); + } + m_foxLogWindow->showNormal (); + m_foxLogWindow->raise (); + m_foxLogWindow->activateWindow (); +} + +void MainWindow::on_contest_log_action_triggered() +{ + if (!m_cabrilloLog) m_cabrilloLog.reset (new CabrilloLog {&m_config}); + if (!m_contestLogWindow) + { + m_contestLogWindow.reset (new CabrilloLogWindow {m_settings, &m_config, m_cabrilloLog->model ()}); + + // Connect signals from contest log window + connect (this, &MainWindow::finished, m_contestLogWindow.data (), &CabrilloLogWindow::close); + } + m_contestLogWindow->showNormal (); + m_contestLogWindow->raise (); + m_contestLogWindow->activateWindow (); +} + +void MainWindow::on_actionColors_triggered() +{ + if (!m_colorHighlighting) + { + m_colorHighlighting.reset (new ColorHighlighting {m_settings, m_config.decode_highlighting ()}); + connect (&m_config, &Configuration::decode_highlighting_changed, m_colorHighlighting.data (), &ColorHighlighting::set_items); + } + m_colorHighlighting->showNormal (); + m_colorHighlighting->raise (); + m_colorHighlighting->activateWindow (); +} + +void MainWindow::on_actionMessage_averaging_triggered() +{ + if(!m_msgAvgWidget) { + m_msgAvgWidget.reset (new MessageAveraging {m_settings, m_config.decoded_text_font ()}); + + // Connect signals from Message Averaging window + connect (this, &MainWindow::finished, m_msgAvgWidget.data (), &MessageAveraging::close); + } + m_msgAvgWidget->showNormal(); + m_msgAvgWidget->raise (); + m_msgAvgWidget->activateWindow (); +} + +void MainWindow::on_actionOpen_triggered() //Open File +{ + monitor (false); + + QString fname; + fname=QFileDialog::getOpenFileName(this, "Open File", m_path, + "WSJT Files (*.wav)"); + if(!fname.isEmpty ()) { + m_path=fname; + int i1=fname.lastIndexOf("/"); + QString baseName=fname.mid(i1+1); + tx_status_label.setStyleSheet("QLabel{background-color: #99ffff}"); + tx_status_label.setText(" " + baseName + " "); + on_stopButton_clicked(); + m_diskData=true; + read_wav_file (fname); + } +} + +void MainWindow::read_wav_file (QString const& fname) +{ + // call diskDat() when done + int i0=fname.lastIndexOf("_"); + int i1=fname.indexOf(".wav"); + m_nutc0=m_UTCdisk; + m_UTCdisk=fname.mid(i0+1,i1-i0-1).toInt(); + m_wav_future_watcher.setFuture (QtConcurrent::run ([this, fname] { + auto basename = fname.mid (fname.lastIndexOf ('/') + 1); + auto pos = fname.indexOf (".wav", 0, Qt::CaseInsensitive); + // global variables and threads do not mix well, this needs changing + dec_data.params.nutc = 0; + if (pos > 0) + { + if (pos == fname.indexOf ('_', -11) + 7) + { + dec_data.params.nutc = fname.mid (pos - 6, 6).toInt (); + } + else + { + dec_data.params.nutc = 100 * fname.mid (pos - 4, 4).toInt (); + } + } + BWFFile file {QAudioFormat {}, fname}; + bool ok=file.open (BWFFile::ReadOnly); + if(ok) { + auto bytes_per_frame = file.format ().bytesPerFrame (); + qint64 max_bytes = std::min (std::size_t (m_TRperiod * RX_SAMPLE_RATE), + sizeof (dec_data.d2) / sizeof (dec_data.d2[0]))* bytes_per_frame; + auto n = file.read (reinterpret_cast<char *> (dec_data.d2), + std::min (max_bytes, file.size ())); + int frames_read = n / bytes_per_frame; + // zero unfilled remaining sample space + std::memset(&dec_data.d2[frames_read],0,max_bytes - n); + if (11025 == file.format ().sampleRate ()) { + short sample_size = file.format ().sampleSize (); + wav12_ (dec_data.d2, dec_data.d2, &frames_read, &sample_size); + } + dec_data.params.kin = frames_read; + dec_data.params.newdat = 1; + } else { + dec_data.params.kin = 0; + dec_data.params.newdat = 0; + } + + if(basename.mid(0,10)=="000000_000" && m_mode == "FT8") { + dec_data.params.nutc=15*basename.mid(10,3).toInt(); + } + + })); +} + +void MainWindow::on_actionOpen_next_in_directory_triggered() //Open Next +{ + monitor (false); + + int i,len; + QFileInfo fi(m_path); + QStringList list; + list= fi.dir().entryList().filter(".wav",Qt::CaseInsensitive); + for (i = 0; i < list.size()-1; ++i) { + len=list.at(i).length(); + if(list.at(i)==m_path.right(len)) { + int n=m_path.length(); + QString fname=m_path.replace(n-len,len,list.at(i+1)); + m_path=fname; + int i1=fname.lastIndexOf("/"); + QString baseName=fname.mid(i1+1); + tx_status_label.setStyleSheet("QLabel{background-color: #99ffff}"); + tx_status_label.setText(" " + baseName + " "); + m_diskData=true; + read_wav_file (fname); + if(m_loopall and (i==list.size()-2)) { + m_loopall=false; + m_bNoMoreFiles=true; + } + return; + } + } +} +//Open all remaining files +void MainWindow::on_actionDecode_remaining_files_in_directory_triggered() +{ + m_loopall=true; + on_actionOpen_next_in_directory_triggered(); +} + +void MainWindow::diskDat() //diskDat() +{ + if(dec_data.params.kin>0) { + int k; + int kstep=m_FFTSize; + m_diskData=true; + float db=m_config.degrade(); + float bw=m_config.RxBandwidth(); + if(db > 0.0) degrade_snr_(dec_data.d2,&dec_data.params.kin,&db,&bw); + for(int n=1; n<=m_hsymStop; n++) { // Do the waterfall spectra + k=(n+1)*kstep; + if(k > dec_data.params.kin) break; + dec_data.params.npts8=k/8; + dataSink(k); + qApp->processEvents(); //Update the waterfall + } + } else { + MessageBox::information_message(this, tr("No data read from disk. Wrong file format?")); + } +} + +//Delete ../save/*.wav +void MainWindow::on_actionDelete_all_wav_files_in_SaveDir_triggered() +{ + auto button = MessageBox::query_message (this, tr ("Confirm Delete"), + tr ("Are you sure you want to delete all *.wav and *.c2 files in \"%1\"?") + .arg (QDir::toNativeSeparators (m_config.save_directory ().absolutePath ()))); + if (MessageBox::Yes == button) { + Q_FOREACH (auto const& file + , m_config.save_directory ().entryList ({"*.wav", "*.c2"}, QDir::Files | QDir::Writable)) { + m_config.save_directory ().remove (file); + } + } +} + +void MainWindow::on_actionNone_triggered() //Save None +{ + m_saveDecoded=false; + m_saveAll=false; + ui->actionNone->setChecked(true); +} + +void MainWindow::on_actionSave_decoded_triggered() +{ + m_saveDecoded=true; + m_saveAll=false; + ui->actionSave_decoded->setChecked(true); +} + +void MainWindow::on_actionSave_all_triggered() //Save All +{ + m_saveDecoded=false; + m_saveAll=true; + ui->actionSave_all->setChecked(true); +} + +void MainWindow::on_actionKeyboard_shortcuts_triggered() +{ + if (!m_shortcuts) + { + QFont font; + font.setPointSize (10); + m_shortcuts.reset (new HelpTextWindow {tr ("Keyboard Shortcuts") + , ":/shortcuts.txt", font}); + } + m_shortcuts->showNormal (); + m_shortcuts->raise (); +} + +void MainWindow::on_actionSpecial_mouse_commands_triggered() +{ + if (!m_mouseCmnds) + { + QFont font; + font.setPointSize (10); + m_mouseCmnds.reset (new HelpTextWindow {tr ("Special Mouse Commands") + , ":/mouse_commands.txt", font}); + } + m_mouseCmnds->showNormal (); + m_mouseCmnds->raise (); +} + +void MainWindow::on_DecodeButton_clicked (bool /* checked */) //Decode request +{ + if(m_mode=="MSK144") { + ui->DecodeButton->setChecked(false); + } else { + if(!m_mode.startsWith ("WSPR") && !m_decoderBusy) { + dec_data.params.newdat=0; + dec_data.params.nagain=1; + m_blankLine=false; // don't insert the separator again + decode(); + } + } +} + +void MainWindow::freezeDecode(int n) //freezeDecode() +{ + if((n%100)==2) on_DecodeButton_clicked (true); +} + +void MainWindow::on_ClrAvgButton_clicked() +{ + m_nclearave=1; + if(m_msgAvgWidget != NULL) { + if(m_msgAvgWidget->isVisible()) m_msgAvgWidget->displayAvg(""); + } +} + +void MainWindow::msgAvgDecode2() +{ + on_DecodeButton_clicked (true); +} + +void MainWindow::decode() //decode() +{ + QDateTime now = QDateTime::currentDateTimeUtc (); + if( m_dateTimeLastTX.isValid () ) { + qint64 isecs_since_tx = m_dateTimeLastTX.secsTo(now); + dec_data.params.lapcqonly= (isecs_since_tx > 600); +// QTextStream(stdout) << "last tx " << isecs_since_tx << endl; + } else { + m_dateTimeLastTX = now.addSecs(-900); + dec_data.params.lapcqonly=true; + } + if( m_diskData ) { + dec_data.params.lapcqonly=false; + } + + m_msec0=QDateTime::currentMSecsSinceEpoch(); + if(!m_dataAvailable or m_TRperiod==0) return; + ui->DecodeButton->setChecked (true); + if(!dec_data.params.nagain && m_diskData && !m_bFastMode && m_mode!="FT8") { + dec_data.params.nutc=dec_data.params.nutc/100; + } + if(dec_data.params.nagain==0 && dec_data.params.newdat==1 && (!m_diskData)) { + qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000; + int imin=ms/60000; + int ihr=imin/60; + imin=imin % 60; + if(m_TRperiod>=60) imin=imin - (imin % (m_TRperiod/60)); + dec_data.params.nutc=100*ihr + imin; + if(m_mode=="ISCAT" or m_mode=="MSK144" or m_bFast9 or m_mode=="FT8") { + QDateTime t=QDateTime::currentDateTimeUtc().addSecs(2-m_TRperiod); + ihr=t.toString("hh").toInt(); + imin=t.toString("mm").toInt(); + int isec=t.toString("ss").toInt(); + isec=isec - isec%m_TRperiod; + dec_data.params.nutc=10000*ihr + 100*imin + isec; + } + } + + if(m_nPick==1 and !m_diskData) { + QDateTime t=QDateTime::currentDateTimeUtc(); + int ihr=t.toString("hh").toInt(); + int imin=t.toString("mm").toInt(); + int isec=t.toString("ss").toInt(); + isec=isec - isec%m_TRperiod; + dec_data.params.nutc=10000*ihr + 100*imin + isec; + } + if(m_nPick==2) dec_data.params.nutc=m_nutc0; + dec_data.params.nQSOProgress = m_QSOProgress; + dec_data.params.nfqso=m_wideGraph->rxFreq(); + dec_data.params.nftx = ui->TxFreqSpinBox->value (); + qint32 depth {m_ndepth}; + if (!ui->actionInclude_averaging->isVisible ()) depth &= ~16; + if (!ui->actionInclude_correlation->isVisible ()) depth &= ~32; + if (!ui->actionEnable_AP_DXcall->isVisible ()) depth &= ~64; + dec_data.params.ndepth=depth; + dec_data.params.n2pass=1; + if(m_config.twoPass()) dec_data.params.n2pass=2; + dec_data.params.nranera=m_config.ntrials(); + dec_data.params.naggressive=m_config.aggressive(); + dec_data.params.nrobust=0; + dec_data.params.ndiskdat=0; + if(m_diskData) dec_data.params.ndiskdat=1; + dec_data.params.nfa=m_wideGraph->nStartFreq(); + dec_data.params.nfSplit=m_wideGraph->Fmin(); + dec_data.params.nfb=m_wideGraph->Fmax(); + if(m_mode=="FT8" and SpecOp::HOUND == m_config.special_op_id() and !ui->cbRxAll->isChecked()) dec_data.params.nfb=1000; + if(m_mode=="FT8" and SpecOp::FOX == m_config.special_op_id() ) dec_data.params.nfqso=200; + dec_data.params.ntol=ui->sbFtol->value (); + if(m_mode=="JT9+JT65" or !m_config.enable_VHF_features()) { + dec_data.params.ntol=20; + dec_data.params.naggressive=0; + } + if(dec_data.params.nutc < m_nutc0) m_RxLog = 1; //Date and Time to ALL.TXT + if(dec_data.params.newdat==1 and !m_diskData) m_nutc0=dec_data.params.nutc; + dec_data.params.ntxmode=9; + if(m_modeTx=="JT65") dec_data.params.ntxmode=65; + dec_data.params.nmode=9; + if(m_mode=="JT65") dec_data.params.nmode=65; + if(m_mode=="JT65") dec_data.params.ljt65apon = ui->actionEnable_AP_JT65->isVisible () && ui->actionEnable_AP_JT65->isChecked (); + if(m_mode=="QRA64") dec_data.params.nmode=164; + if(m_mode=="QRA64") dec_data.params.ntxmode=164; + if(m_mode=="JT9+JT65") dec_data.params.nmode=9+65; // = 74 + if(m_mode=="JT4") { + dec_data.params.nmode=4; + dec_data.params.ntxmode=4; + } + if(m_mode=="FT8") dec_data.params.nmode=8; + if(m_mode=="FT8") dec_data.params.lft8apon = ui->actionEnable_AP_FT8->isVisible () && ui->actionEnable_AP_FT8->isChecked (); + if(m_mode=="FT8") dec_data.params.napwid=50; + dec_data.params.ntrperiod=m_TRperiod; + dec_data.params.nsubmode=m_nSubMode; + if(m_mode=="QRA64") dec_data.params.nsubmode=100 + m_nSubMode; + dec_data.params.minw=0; + dec_data.params.nclearave=m_nclearave; + if(m_nclearave!=0) { + QFile f(m_config.temp_dir ().absoluteFilePath ("avemsg.txt")); + f.remove(); + } + dec_data.params.dttol=m_DTtol; + dec_data.params.emedelay=0.0; + if(m_config.decode_at_52s()) dec_data.params.emedelay=2.5; + dec_data.params.minSync=ui->syncSpinBox->isVisible () ? m_minSync : 0; + dec_data.params.nexp_decode = static_cast<int> (m_config.special_op_id()); + if(m_config.single_decode()) dec_data.params.nexp_decode += 32; + if(m_config.enable_VHF_features()) dec_data.params.nexp_decode += 64; + + strncpy(dec_data.params.datetime, m_dateTime.toLatin1(), 20); + strncpy(dec_data.params.mycall, (m_config.my_callsign()+" ").toLatin1(),12); + strncpy(dec_data.params.mygrid, (m_config.my_grid()+" ").toLatin1(),6); + QString hisCall {ui->dxCallEntry->text ()}; + QString hisGrid {ui->dxGridEntry->text ()}; + strncpy(dec_data.params.hiscall,(hisCall + " ").toLatin1 ().constData (), 12); + strncpy(dec_data.params.hisgrid,(hisGrid + " ").toLatin1 ().constData (), 6); + + //newdat=1 ==> this is new data, must do the big FFT + //nagain=1 ==> decode only at fQSO +/- Tol + + char *to = (char*)mem_jt9->data(); + char *from = (char*) dec_data.ss; + int size=sizeof(struct dec_data); + if(dec_data.params.newdat==0) { + int noffset {offsetof (struct dec_data, params.nutc)}; + to += noffset; + from += noffset; + size -= noffset; + } + if(m_mode=="ISCAT" or m_mode=="MSK144" or m_bFast9) { + float t0=m_t0; + float t1=m_t1; + qApp->processEvents(); //Update the waterfall + if(m_nPick > 0) { + t0=m_t0Pick; + t1=m_t1Pick; + } + static short int d2b[360000]; + narg[0]=dec_data.params.nutc; + if(m_kdone>12000*m_TRperiod) { + m_kdone=12000*m_TRperiod; + } + narg[1]=m_kdone; + narg[2]=m_nSubMode; + narg[3]=dec_data.params.newdat; + narg[4]=dec_data.params.minSync; + narg[5]=m_nPick; + narg[6]=1000.0*t0; + narg[7]=1000.0*t1; + narg[8]=2; //Max decode lines per decode attempt + if(dec_data.params.minSync<0) narg[8]=50; + if(m_mode=="ISCAT") narg[9]=101; //ISCAT + if(m_mode=="JT9") narg[9]=102; //Fast JT9 + if(m_mode=="MSK144") narg[9]=104; //MSK144 + narg[10]=ui->RxFreqSpinBox->value(); + narg[11]=ui->sbFtol->value (); + narg[12]=0; + narg[13]=-1; + narg[14]=m_config.aggressive(); + memcpy(d2b,dec_data.d2,2*360000); + watcher3.setFuture (QtConcurrent::run (std::bind (fast_decode_,&d2b[0], + &narg[0],&m_TRperiod,&m_msg[0][0], + dec_data.params.mycall,dec_data.params.hiscall,8000,12,12))); + } else { + memcpy(to, from, qMin(mem_jt9->size(), size)); + QFile {m_config.temp_dir ().absoluteFilePath (".lock")}.remove (); // Allow jt9 to start + decodeBusy(true); + } +} + +void::MainWindow::fast_decode_done() +{ + float t,tmax=-99.0; + dec_data.params.nagain=false; + dec_data.params.ndiskdat=false; +// if(m_msg[0][0]==0) m_bDecoded=false; + for(int i=0; m_msg[i][0] && i<100; i++) { + QString message=QString::fromLatin1(m_msg[i]); + m_msg[i][0]=0; + if(message.length()>80) message=message.left (80); + if(narg[13]/8==narg[12]) message=message.trimmed().replace("<...>",m_calls); + +//Left (Band activity) window + DecodedText decodedtext {message.replace (QChar::LineFeed, "")}; + if(!m_bFastDone) { + ui->decodedTextBrowser->displayDecodedText (decodedtext,m_baseCall,m_mode,m_config.DXCC(), + m_logBook,m_currentBand,m_config.ppfx()); + } + + t=message.mid(10,5).toFloat(); + if(t>tmax) { + tmax=t; + m_bDecoded=true; + } + postDecode (true, decodedtext.string ()); + writeAllTxt(message); + + if(m_mode=="JT9" or m_mode=="MSK144") { +// find and extract any report for myCall + bool stdMsg = decodedtext.report(m_baseCall, + Radio::base_callsign(ui->dxCallEntry->text()), m_rptRcvd); + +// extract details and send to PSKreporter + if (stdMsg) pskPost (decodedtext); + } + if (tmax >= 0.0) auto_sequence (decodedtext, ui->sbFtol->value (), ui->sbFtol->value ()); + } + m_startAnother=m_loopall; + m_nPick=0; + ui->DecodeButton->setChecked (false); + m_bFastDone=false; +} + +void MainWindow::writeAllTxt(QString message) +{ + // Write decoded text to file "ALL.TXT". + QFile f {m_config.writeable_data_dir ().absoluteFilePath ("ALL.TXT")}; + if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) { + QTextStream out(&f); + if(m_RxLog==1) { + out << QDateTime::currentDateTimeUtc().toString("yyyy-MM-dd hh:mm") + << " " << qSetRealNumberPrecision (12) << (m_freqNominal / 1.e6) << " MHz " + << m_mode << endl; + m_RxLog=0; + } + out << message << endl; + f.close(); + } else { + MessageBox::warning_message (this, tr ("File Open Error") + , tr ("Cannot open \"%1\" for append: %2") + .arg (f.fileName ()).arg (f.errorString ())); + } +} + +void MainWindow::decodeDone () +{ + dec_data.params.nagain=0; + dec_data.params.ndiskdat=0; + m_nclearave=0; + QFile {m_config.temp_dir ().absoluteFilePath (".lock")}.open(QIODevice::ReadWrite); + ui->DecodeButton->setChecked (false); + decodeBusy(false); + m_RxLog=0; + m_blankLine=true; + if(SpecOp::FOX == m_config.special_op_id()) houndCallers(); +} + +void MainWindow::readFromStdout() //readFromStdout +{ + while(proc_jt9.canReadLine()) { + auto line_read = proc_jt9.readLine (); + if (auto p = std::strpbrk (line_read.constData (), "\n\r")) + { + // truncate before line ending chars + line_read = line_read.left (p - line_read.constData ()); + } + if(m_mode!="FT8") { + //Pad 22-char msg to at least 37 chars + line_read = line_read.left(43) + " " + line_read.mid(43); + } +// qint64 ms=QDateTime::currentMSecsSinceEpoch() - m_msec0; + bool bAvgMsg=false; + int navg=0; + if(line_read.indexOf("<DecodeFinished>") >= 0) { + if(m_mode=="QRA64") m_wideGraph->drawRed(0,0); + m_bDecoded = line_read.mid(20).trimmed().toInt() > 0; + int mswait=3*1000*m_TRperiod/4; + if(!m_diskData) killFileTimer.start(mswait); //Kill in 3/4 period + decodeDone (); + m_startAnother=m_loopall; + if(m_bNoMoreFiles) { + MessageBox::information_message(this, tr("No more files to open.")); + m_bNoMoreFiles=false; + } + return; + } else { + if(m_mode=="JT4" or m_mode=="JT65" or m_mode=="QRA64" or m_mode=="FT8") { + int n=line_read.indexOf("f"); + if(n<0) n=line_read.indexOf("d"); + if(n>0) { + QString tt=line_read.mid(n+1,1); + navg=tt.toInt(); + if(navg==0) { + char c = tt.data()->toLatin1(); + if(int(c)>=65 and int(c)<=90) navg=int(c)-54; + } + if(navg>1 or line_read.indexOf("f*")>0) bAvgMsg=true; + } + } + + QFile f {m_config.writeable_data_dir ().absoluteFilePath ("ALL.TXT")}; + if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) { + QTextStream out(&f); + if(m_RxLog==1) { + out << QDateTime::currentDateTimeUtc().toString("yyyy-MM-dd hh:mm") + << " " << qSetRealNumberPrecision (12) << (m_freqNominal / 1.e6) << " MHz " + << m_mode << endl; + m_RxLog=0; + } + out << line_read.trimmed () << endl; + f.close(); + } else { + MessageBox::warning_message (this, tr ("File Open Error") + , tr ("Cannot open \"%1\" for append: %2") + .arg (f.fileName ()).arg (f.errorString ())); + } + if (m_config.insert_blank () && m_blankLine && SpecOp::FOX != m_config.special_op_id()) { + 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 decodedtext0 {QString::fromUtf8(line_read.constData())}; + DecodedText decodedtext {QString::fromUtf8(line_read.constData()).remove("TU; ")}; + + if(m_mode=="FT8" and SpecOp::FOX == m_config.special_op_id() and + (decodedtext.string().contains("R+") or decodedtext.string().contains("R-"))) { + auto for_us = decodedtext.string().contains(" " + m_config.my_callsign() + " ") or + decodedtext.string().contains(" "+m_baseCall) or + decodedtext.string().contains(m_baseCall+" ") or + decodedtext.string().contains(" <" + m_config.my_callsign() + "> "); + if(decodedtext.string().contains(" DE ")) for_us=true; //Hound with compound callsign + if(for_us) { + QString houndCall,houndGrid; + decodedtext.deCallAndGrid(/*out*/houndCall,houndGrid); + foxRxSequencer(decodedtext.string(),houndCall,houndGrid); + } + } + +//Left (Band activity) window + if(!bAvgMsg) { + if(m_mode=="FT8" and SpecOp::FOX == m_config.special_op_id()) { + if(!m_bDisplayedOnce) { + // This hack sets the font. Surely there's a better way! + DecodedText dt{"."}; + ui->decodedTextBrowser->displayDecodedText(dt,m_baseCall,m_mode,m_config.DXCC(), + m_logBook,m_currentBand,m_config.ppfx()); + m_bDisplayedOnce=true; + } + } else { + ui->decodedTextBrowser->displayDecodedText(decodedtext0,m_baseCall,m_mode,m_config.DXCC(), + m_logBook,m_currentBand,m_config.ppfx(), + (ui->cbCQonly->isVisible() and ui->cbCQonly->isChecked())); + } + } + +//Right (Rx Frequency) window + bool bDisplayRight=bAvgMsg; + int audioFreq=decodedtext.frequencyOffset(); + + if(m_mode=="FT8") { + auto const& parts = decodedtext.string().remove("<").remove(">") + .split (' ', QString::SkipEmptyParts); + if (parts.size () > 6) { + auto for_us = parts[5].contains (m_baseCall) + || ("DE" == parts[5] && qAbs (ui->RxFreqSpinBox->value () - audioFreq) <= 10); + if(m_baseCall==m_config.my_callsign() and m_baseCall!=parts[5]) for_us=false; + if(m_bCallingCQ && !m_bAutoReply && for_us && ui->cbFirst->isChecked() and + SpecOp::FOX > m_config.special_op_id()) { + m_bDoubleClicked=true; + m_bAutoReply = true; + if(SpecOp::FOX != m_config.special_op_id()) processMessage (decodedtext); + ui->cbFirst->setStyleSheet(""); + } + if(SpecOp::FOX==m_config.special_op_id() and decodedtext.string().contains(" DE ")) for_us=true; //Hound with compound callsign + if(SpecOp::FOX==m_config.special_op_id() and for_us and (audioFreq<1000)) bDisplayRight=true; + if(SpecOp::FOX!=m_config.special_op_id() and (for_us or (abs(audioFreq - m_wideGraph->rxFreq()) <= 10))) bDisplayRight=true; + } + } else { + if(abs(audioFreq - m_wideGraph->rxFreq()) <= 10) bDisplayRight=true; + } + + if (bDisplayRight) { + // This msg is within 10 hertz of our tuned frequency, or a JT4 or JT65 avg, + // or contains MyCall + ui->decodedTextBrowser2->displayDecodedText(decodedtext0,m_baseCall,m_mode,m_config.DXCC(), + m_logBook,m_currentBand,m_config.ppfx()); + + if(m_mode!="JT4") { + bool b65=decodedtext.isJT65(); + if(b65 and m_modeTx!="JT65") on_pbTxMode_clicked(); + if(!b65 and m_modeTx=="JT65") on_pbTxMode_clicked(); + } + m_QSOText = decodedtext.string ().trimmed (); + } + + postDecode (true, decodedtext.string ()); + + if(m_mode=="FT8" and SpecOp::HOUND==m_config.special_op_id()) { + if(decodedtext.string().contains(";")) { + QStringList w=decodedtext.string().mid(24).split(" ",QString::SkipEmptyParts); + QString foxCall=w.at(3); + foxCall=foxCall.remove("<").remove(">"); + if(w.at(0)==m_config.my_callsign() or w.at(0)==Radio::base_callsign(m_config.my_callsign())) { + //### Check for ui->dxCallEntry->text()==foxCall before logging! ### + ui->stopTxButton->click (); + logQSOTimer.start(0); + } + if((w.at(2)==m_config.my_callsign() or w.at(2)==Radio::base_callsign(m_config.my_callsign())) + and ui->tx3->text().length()>0) { + m_rptRcvd=w.at(4); + m_rptSent=decodedtext.string().mid(7,3); + m_nFoxFreq=decodedtext.string().mid(16,4).toInt(); + hound_reply (); + } + } else { + QStringList w=decodedtext.string().mid(24).split(" ",QString::SkipEmptyParts); + if(decodedtext.string().contains("/")) w.append(" +00"); //Add a dummy report + if(w.size()>=3) { + QString foxCall=w.at(1); + if((w.at(0)==m_config.my_callsign() or w.at(0)==Radio::base_callsign(m_config.my_callsign())) and + ui->tx3->text().length()>0) { + if(w.at(2)=="RR73") { + ui->stopTxButton->click (); + logQSOTimer.start(0); + } else { + if(w.at(1)==Radio::base_callsign(ui->dxCallEntry->text()) and + (w.at(2).mid(0,1)=="+" or w.at(2).mid(0,1)=="-")) { + m_rptRcvd=w.at(2); + m_rptSent=decodedtext.string().mid(7,3); + m_nFoxFreq=decodedtext.string().mid(16,4).toInt(); + hound_reply (); + } + } + } + } + } + } + +//### I think this is where we are preventing Hounds from spotting Fox ### + if(m_mode!="FT8" or (SpecOp::HOUND != m_config.special_op_id())) { + if(m_mode=="FT8" or m_mode=="QRA64" or m_mode=="JT4" or m_mode=="JT65" or m_mode=="JT9") { + auto_sequence (decodedtext, 25, 50); + } + +// find and extract any report for myCall, but save in m_rptRcvd only if it's from DXcall + QString rpt; + bool stdMsg = decodedtext.report(m_baseCall, + Radio::base_callsign(ui->dxCallEntry->text()), rpt); + QString deCall; + QString grid; + decodedtext.deCallAndGrid(/*out*/deCall,grid); + { + QString t=Radio::base_callsign(ui->dxCallEntry->text()); + if((t==deCall or t=="") and rpt!="") m_rptRcvd=rpt; + } +// extract details and send to PSKreporter + int nsec=QDateTime::currentMSecsSinceEpoch()/1000-m_secBandChanged; + bool okToPost=(nsec>(4*m_TRperiod)/5); + if (stdMsg && okToPost) pskPost(decodedtext); + + if((m_mode=="JT4" or m_mode=="JT65" or m_mode=="QRA64") and m_msgAvgWidget!=NULL) { + if(m_msgAvgWidget->isVisible()) { + QFile f(m_config.temp_dir ().absoluteFilePath ("avemsg.txt")); + if(f.open(QIODevice::ReadOnly | QIODevice::Text)) { + QTextStream s(&f); + QString t=s.readAll(); + m_msgAvgWidget->displayAvg(t); + } + } + } + } + } + } +} + +// +// start_tolerance - only respond to "DE ..." and free text 73 +// messages within +/- this value +// +// stop_tolerance - kill Tx if running station is seen to reply to +// another caller and we are going to transmit within +// +/- this value of the reply to another caller +// +void MainWindow::auto_sequence (DecodedText const& message, unsigned start_tolerance, unsigned stop_tolerance) +{ + auto const& message_words = message.messageWords (); + auto is_73 = message_words.filter (QRegularExpression {"^(73|RR73)$"}).size(); + bool is_OK=false; + if(m_mode=="MSK144" and message.string().indexOf(ui->dxCallEntry->text()+" R ")>0) is_OK=true; + if (message_words.size () > 2 && (message.isStandardMessage() || (is_73 or is_OK))) { + auto df = message.frequencyOffset (); + auto within_tolerance = (qAbs (ui->RxFreqSpinBox->value () - df) <= int (start_tolerance) + || qAbs (ui->TxFreqSpinBox->value () - df) <= int (start_tolerance)); + bool acceptable_73 = is_73 + && m_QSOProgress >= ROGER_REPORT + && ((message.isStandardMessage () + && (message_words.contains (m_baseCall) + || message_words.contains (m_config.my_callsign ()) + || message_words.contains (ui->dxCallEntry->text ()) + || message_words.contains (Radio::base_callsign (ui->dxCallEntry->text ())) + || message_words.contains ("DE"))) + || !message.isStandardMessage ()); // free text 73/RR73 + QString w2=message_words.at(2); + QString w34; + int nrpt=0; + if(message_words.size()>3) { + w34=message_words.at(3); + nrpt=w2.toInt(); + if(w2=="R") { + nrpt=w34.toInt(); + w34=message_words.at(4); + } + } + bool bEU_VHF_w2=(nrpt>=520001 and nrpt<=594000); + if(bEU_VHF_w2) m_xRcvd=message.string().trimmed().right(13); + if (m_auto + && (m_QSOProgress==REPLYING or (!ui->tx1->isEnabled () and m_QSOProgress==REPORT)) + && qAbs (ui->TxFreqSpinBox->value () - df) <= int (stop_tolerance) + && message_words.at (1) != "DE" + && !message_words.at (1).contains (QRegularExpression {"(^(CQ|QRZ))|" + m_baseCall}) + && message_words.at (2).contains (Radio::base_callsign (ui->dxCallEntry->text ()))) { + // auto stop to avoid accidental QRM + ui->stopTxButton->click (); // halt any transmission + } else if (m_auto // transmit allowed + && ui->cbAutoSeq->isVisible () && ui->cbAutoSeq->isChecked() // auto-sequencing allowed + && ((!m_bCallingCQ // not calling CQ/QRZ + && !m_sentFirst73 // not finished QSO + && ((message_words.at (1).contains (m_baseCall) + // being called and not already in a QSO + && (message_words.at(2).contains(Radio::base_callsign(ui->dxCallEntry->text())) or bEU_VHF_w2)) + // type 2 compound replies + || (within_tolerance && + (acceptable_73 || + ("DE" == message_words.at (1) && + w2.contains(Radio::base_callsign (m_hisCall))))))) + || (m_bCallingCQ && m_bAutoReply + // look for type 2 compound call replies on our Tx and Rx offsets + && ((within_tolerance && "DE" == message_words.at (1)) + || message_words.at (1).contains (m_baseCall))))) { + if(SpecOp::FOX != m_config.special_op_id()) processMessage (message); + } + } +} + +void MainWindow::pskPost (DecodedText const& decodedtext) +{ + if (m_diskData || !m_config.spot_to_psk_reporter() || decodedtext.isLowConfidence ()) return; + + QString msgmode=m_mode; + if(m_mode=="JT9+JT65") { + msgmode="JT9"; + if (decodedtext.isJT65()) msgmode="JT65"; + } + QString deCall; + QString grid; + decodedtext.deCallAndGrid(/*out*/deCall,grid); + int audioFrequency = decodedtext.frequencyOffset(); + if(m_mode=="FT8" or m_mode=="MSK144") { + audioFrequency=decodedtext.string().mid(16,4).toInt(); + } + int snr = decodedtext.snr(); + Frequency frequency = m_freqNominal + audioFrequency; + pskSetLocal (); + if(grid.contains (grid_regexp)) { +// qDebug() << "To PSKreporter:" << deCall << grid << frequency << msgmode << snr; + psk_Reporter->addRemoteStation(deCall,grid,QString::number(frequency),msgmode, + QString::number(snr),QString::number(QDateTime::currentDateTimeUtc ().toTime_t())); + } +} + +void MainWindow::killFile () +{ + if (m_fnameWE.size () && + !(m_saveAll || (m_saveDecoded && m_bDecoded) || m_fnameWE == m_fileToSave)) { + QFile f1 {m_fnameWE + ".wav"}; + if(f1.exists()) f1.remove(); + if(m_mode.startsWith ("WSPR")) { + QFile f2 {m_fnameWE + ".c2"}; + if(f2.exists()) f2.remove(); + } + } +} + +void MainWindow::on_EraseButton_clicked () +{ + qint64 ms=QDateTime::currentMSecsSinceEpoch(); + ui->decodedTextBrowser2->erase (); + if(m_mode.startsWith ("WSPR") or m_mode=="Echo" or m_mode=="ISCAT") { + ui->decodedTextBrowser->erase (); + } else { + if((ms-m_msErase)<500) { + ui->decodedTextBrowser->erase (); + } + } + m_msErase=ms; +} + +void MainWindow::band_activity_cleared () +{ + m_messageClient->clear_decodes (); + QFile f(m_config.temp_dir ().absoluteFilePath ("decoded.txt")); + if(f.exists()) f.remove(); +} + +void MainWindow::rx_frequency_activity_cleared () +{ + m_QSOText.clear(); + set_dateTimeQSO(-1); // G4WJS: why do we do this? +} + +void MainWindow::decodeBusy(bool b) //decodeBusy() +{ + if (!b) m_optimizingProgress.reset (); + m_decoderBusy=b; + ui->DecodeButton->setEnabled(!b); + ui->actionOpen->setEnabled(!b); + ui->actionOpen_next_in_directory->setEnabled(!b); + ui->actionDecode_remaining_files_in_directory->setEnabled(!b); + + statusUpdate (); +} + +//------------------------------------------------------------- //guiUpdate() +void MainWindow::guiUpdate() +{ + static char message[38]; + static char msgsent[38]; + double txDuration; + QString rt; + + if(m_TRperiod==0) m_TRperiod=60; + txDuration=0.0; + if(m_modeTx=="FT8") txDuration=1.0 + 79*1920/12000.0; // FT8 + if(m_modeTx=="JT4") txDuration=1.0 + 207.0*2520/11025.0; // JT4 + if(m_modeTx=="JT9") txDuration=1.0 + 85.0*m_nsps/12000.0; // JT9 + if(m_modeTx=="JT65") txDuration=1.0 + 126*4096/11025.0; // JT65 + if(m_modeTx=="QRA64") txDuration=1.0 + 84*6912/12000.0; // QRA64 + if(m_modeTx=="WSPR") txDuration=2.0 + 162*8192/12000.0; // WSPR + if(m_modeTx=="WSPR-LF") txDuration=2.0 + 114*24576/12000.0; // WSPR-LF + if(m_modeTx=="ISCAT" or m_mode=="MSK144" or m_bFast9) { + txDuration=m_TRperiod-0.25; // ISCAT, JT9-fast, MSK144 + } + + double tx1=0.0; + double tx2=txDuration; + if(m_mode=="FT8") icw[0]=0; //No CW ID in FT8 mode + if((icw[0]>0) and (!m_bFast9)) tx2 += icw[0]*2560.0/48000.0; //Full length including CW ID + if(tx2>m_TRperiod) tx2=m_TRperiod; + + if(!m_txFirst and !m_mode.startsWith ("WSPR")) { + tx1 += m_TRperiod; + tx2 += m_TRperiod; + } + + qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000; + int nsec=ms/1000; + double tsec=0.001*ms; + double t2p=fmod(tsec,2*m_TRperiod); + m_s6=fmod(tsec,6.0); + m_nseq = nsec % m_TRperiod; + m_tRemaining=m_TRperiod - fmod(tsec,double(m_TRperiod)); + + if(m_mode=="Echo") { + txDuration=2.4; + tx1=0.0; + tx2=txDuration; + if(m_auto and m_s6>4.0) m_bEchoTxOK=true; + if(m_transmitting) m_bEchoTxed=true; + } + + if(m_mode.startsWith ("WSPR")) { + if(m_nseq==0 and m_ntr==0) { //Decide whether to Tx or Rx + m_tuneup=false; //This is not an ATU tuneup + if(m_pctx==0) m_WSPR_tx_next = false; //Don't transmit if m_pctx=0 + bool btx = m_auto && m_WSPR_tx_next; // To Tx, we need m_auto and + // scheduled transmit + if(m_auto and m_txNext) btx=true; //TxNext button overrides + if(m_auto and m_pctx==100) btx=true; //Always transmit + + if(btx) { + m_ntr=-1; //This says we will have transmitted + m_txNext=false; + ui->pbTxNext->setChecked(false); + m_bTxTime=true; //Start a WSPR Tx sequence + } else { +// This will be a WSPR Rx sequence. + m_ntr=1; //This says we will have received + m_bTxTime=false; //Start a WSPR Rx sequence + } + } + + } else { +// For all modes other than WSPR + m_bTxTime = (t2p >= tx1) and (t2p < tx2); + if(m_mode=="Echo") m_bTxTime = m_bTxTime and m_bEchoTxOK; + } + if(m_tune) m_bTxTime=true; //"Tune" takes precedence + + if(m_transmitting or m_auto or m_tune) { + m_dateTimeLastTX = QDateTime::currentDateTimeUtc (); + +// Check for "txboth" (testing purposes only) + QFile f(m_appDir + "/txboth"); + if(f.exists() and + fmod(tsec,m_TRperiod)<(1.0 + 85.0*m_nsps/12000.0)) m_bTxTime=true; + +// Don't transmit another mode in the 30 m WSPR sub-band + Frequency onAirFreq = m_freqNominal + ui->TxFreqSpinBox->value(); + if ((onAirFreq > 10139900 and onAirFreq < 10140320) and + !m_mode.startsWith ("WSPR")) { + m_bTxTime=false; + if (m_auto) auto_tx_mode (false); + if(onAirFreq!=m_onAirFreq0) { + m_onAirFreq0=onAirFreq; + auto const& message = tr ("Please choose another Tx frequency." + " WSJT-X will not knowingly transmit another" + " mode in the WSPR sub-band on 30m."); + QTimer::singleShot (0, [=] { // don't block guiUpdate + MessageBox::warning_message (this, tr ("WSPR Guard Band"), message); + }); + } + } + + if(m_mode=="FT8" and SpecOp::FOX==m_config.special_op_id()) { +// Don't allow Fox mode in any of the default FT8 sub-bands. + qint32 ft8Freq[]={1840,3573,7074,10136,14074,18100,21074,24915,28074,50313,70100}; + for(int i=0; i<11; i++) { + int kHzdiff=m_freqNominal/1000 - ft8Freq[i]; + if(qAbs(kHzdiff) < 4) { + m_bTxTime=false; + if (m_auto) auto_tx_mode (false); + auto const& message = tr ("Please choose another dial frequency." + " WSJT-X will not operate in Fox mode" + " in the standard FT8 sub-bands."); + QTimer::singleShot (0, [=] { // don't block guiUpdate + MessageBox::warning_message (this, tr ("Fox Mode warning"), message); + }); + break; + } + } + } + + if (m_config.watchdog() && !m_mode.startsWith ("WSPR") + && m_idleMinutes >= m_config.watchdog ()) { + tx_watchdog (true); // disable transmit + } + + float fTR=float((ms%(1000*m_TRperiod)))/(1000*m_TRperiod); + + QString txMsg; + if(m_ntx == 1) txMsg=ui->tx1->text(); + if(m_ntx == 2) txMsg=ui->tx2->text(); + if(m_ntx == 3) txMsg=ui->tx3->text(); + if(m_ntx == 4) txMsg=ui->tx4->text(); + if(m_ntx == 5) txMsg=ui->tx5->currentText(); + if(m_ntx == 6) txMsg=ui->tx6->text(); + if(m_ntx == 7) txMsg=ui->genMsg->text(); + if(m_ntx == 8) txMsg=ui->freeTextMsg->currentText(); + int msgLength=txMsg.trimmed().length(); + if(msgLength==0 and !m_tune) on_stopTxButton_clicked(); + + if(g_iptt==0 and ((m_bTxTime and fTR<0.75 and msgLength>0) or m_tune)) { + //### Allow late starts + icw[0]=m_ncw; + g_iptt = 1; + setRig (); + if(m_mode=="FT8") { + if (SpecOp::FOX == m_config.special_op_id()) { + if (ui->TxFreqSpinBox->value() > 900) { + ui->TxFreqSpinBox->setValue(300); + } + } + else if (SpecOp::HOUND == m_config.special_op_id()) { + if(m_auto && !m_tune) { + if (ui->TxFreqSpinBox->value() < 999 && m_ntx != 3) { + int nf = (qrand() % 2000) + 1000; // Hound randomized range: 1000-3000 Hz + ui->TxFreqSpinBox->setValue(nf); + } + } + if (m_nSentFoxRrpt==2 and m_ntx==3) { + // move off the original Fox frequency on subsequent tries of Tx3 + int nfreq=m_nFoxFreq + 300; + if(m_nFoxFreq>600) nfreq=m_nFoxFreq - 300; //keep nfreq below 900 Hz + ui->TxFreqSpinBox->setValue(nfreq); + } + if (m_nSentFoxRrpt == 1) { + ++m_nSentFoxRrpt; + } + } + } + + +// If HoldTxFreq is not checked, randomize Fox's Tx Freq +// NB: Maybe this should be done no more than once every 5 minutes or so ? + if(m_mode=="FT8" and SpecOp::FOX==m_config.special_op_id() and !ui->cbHoldTxFreq->isChecked()) { + int fTx = 300.0 + 300.0*double(qrand())/RAND_MAX; + ui->TxFreqSpinBox->setValue(fTx); + } + + setXIT (ui->TxFreqSpinBox->value ()); + Q_EMIT m_config.transceiver_ptt (true); //Assert the PTT + m_tx_when_ready = true; + } + if(!m_bTxTime and !m_tune) m_btxok=false; //Time to stop transmitting + } + + if(m_mode.startsWith ("WSPR") and + ((m_ntr==1 and m_rxDone) or (m_ntr==-1 and m_nseq>tx2))) { + if(m_monitoring) { + m_rxDone=false; + } + if(m_transmitting) { + WSPR_history(m_freqNominal,-1); + m_bTxTime=false; //Time to stop a WSPR transmission + m_btxok=false; + } + else if (m_ntr != -1) { + WSPR_scheduling (); + m_ntr=0; //This WSPR Rx sequence is complete + } + } + + + // Calculate Tx tones when needed + if((g_iptt==1 && m_iptt0==0) || m_restart) { +//---------------------------------------------------------------------- + QByteArray ba; + QByteArray ba0; + + if(m_mode.startsWith ("WSPR")) { + QString sdBm,msg0,msg1,msg2; + sdBm.sprintf(" %d",m_dBm); + m_tx=1-m_tx; + int i2=m_config.my_callsign().indexOf("/"); + if(i2>0 + || (6 == m_config.my_grid ().size () + && !ui->WSPR_prefer_type_1_check_box->isChecked ())) { + if(i2<0) { // "Type 2" WSPR message + msg1=m_config.my_callsign() + " " + m_config.my_grid().mid(0,4) + sdBm; + } else { + msg1=m_config.my_callsign() + sdBm; + } + msg0="<" + m_config.my_callsign() + "> " + m_config.my_grid()+ sdBm; + if(m_tx==0) msg2=msg0; + if(m_tx==1) msg2=msg1; + } else { + msg2=m_config.my_callsign() + " " + m_config.my_grid().mid(0,4) + sdBm; // Normal WSPR message + } + ba=msg2.toLatin1(); + } else { + if(SpecOp::HOUND == m_config.special_op_id() and m_ntx!=3) { //Hound transmits only Tx1 or Tx3 + m_ntx=1; + ui->txrb1->setChecked(true); + } + if(m_ntx == 1) ba=ui->tx1->text().toLocal8Bit(); + if(m_ntx == 2) ba=ui->tx2->text().toLocal8Bit(); + if(m_ntx == 3) ba=ui->tx3->text().toLocal8Bit(); + if(m_ntx == 4) ba=ui->tx4->text().toLocal8Bit(); + if(m_ntx == 5) ba=ui->tx5->currentText().toLocal8Bit(); + if(m_ntx == 6) ba=ui->tx6->text().toLocal8Bit(); + if(m_ntx == 7) ba=ui->genMsg->text().toLocal8Bit(); + if(m_ntx == 8) ba=ui->freeTextMsg->currentText().toLocal8Bit(); + } + + ba2msg(ba,message); + int ichk=0; + if (m_lastMessageSent != m_currentMessage + || m_lastMessageType != m_currentMessageType) + { + m_lastMessageSent = m_currentMessage; + m_lastMessageType = m_currentMessageType; + } + m_currentMessageType = 0; + if(m_tune or m_mode=="Echo") { + itone[0]=0; + } else { + if(m_mode=="ISCAT") { + geniscat_(message, msgsent, const_cast<int *> (itone), 28, 28); + msgsent[28]=0; + } else { + if(m_modeTx=="JT4") gen4_(message, &ichk , msgsent, const_cast<int *> (itone), + &m_currentMessageType, 22, 22); + if(m_modeTx=="JT9") gen9_(message, &ichk, msgsent, const_cast<int *> (itone), + &m_currentMessageType, 22, 22); + if(m_modeTx=="JT65") gen65_(message, &ichk, msgsent, const_cast<int *> (itone), + &m_currentMessageType, 22, 22); + if(m_modeTx=="QRA64") genqra64_(message, &ichk, msgsent, const_cast<int *> (itone), + &m_currentMessageType, 22, 22); + if(m_modeTx=="WSPR") genwspr_(message, msgsent, const_cast<int *> (itone), + 22, 22); +// if(m_modeTx=="WSPR-LF") genwspr_fsk8_(message, msgsent, const_cast<int *> (itone), +// 22, 22); + if(m_modeTx=="MSK144" or m_modeTx=="FT8") { + char MyCall[6]; + char MyGrid[6]; + strncpy(MyCall, (m_config.my_callsign()+" ").toLatin1(),6); + strncpy(MyGrid, (m_config.my_grid()+" ").toLatin1(),6); + if(m_modeTx=="MSK144") { + genmsk_128_90_(message, &ichk, msgsent, const_cast<int *> (itone), + &m_currentMessageType, 37, 37); + if(m_restart) { + int nsym=144; + if(itone[40]==-40) nsym=40; + m_modulator->set_nsym(nsym); + } + } + if(m_modeTx=="FT8") { + if(SpecOp::FOX==m_config.special_op_id() and ui->tabWidget->currentIndex()==2) { + foxTxSequencer(); + } else { + int i3=0; + int n3=0; + char ft8msgbits[77]; + genft8_(message, &i3, &n3, msgsent, const_cast<char *> (ft8msgbits), + const_cast<int *> (itone), 37, 37); + if(SpecOp::FOX == m_config.special_op_id()) { + //Fox must generate the full Tx waveform, not just an itone[] array. + QString fm = QString::fromStdString(message).trimmed(); + foxGenWaveform(0,fm); + foxcom_.nslots=1; + foxcom_.nfreq=ui->TxFreqSpinBox->value(); + if(m_config.split_mode()) foxcom_.nfreq = foxcom_.nfreq - m_XIT; //Fox Tx freq + QString foxCall=m_config.my_callsign() + " "; + strncpy(&foxcom_.mycall[0], foxCall.toLatin1(),12); //Copy Fox callsign into foxcom_ + foxgen_(); + } + } + } + if(SpecOp::EU_VHF==m_config.special_op_id()) { + if(m_ntx==2) m_xSent=ui->tx2->text().right(13); + if(m_ntx==3) m_xSent=ui->tx3->text().right(13); + } + + if(SpecOp::FIELD_DAY==m_config.special_op_id() or SpecOp::RTTY==m_config.special_op_id()) { + if(m_ntx==2 or m_ntx==3) { + QStringList t=ui->tx2->text().split(' ', QString::SkipEmptyParts); + int n=t.size(); + m_xSent=t.at(n-2) + " " + t.at(n-1); + } + } + } + msgsent[37]=0; + } + } + + m_currentMessage = QString::fromLatin1(msgsent); + m_bCallingCQ = CALLING == m_QSOProgress + || m_currentMessage.contains (QRegularExpression {"^(CQ|QRZ) "}); + if(m_mode=="FT8") { + if(m_bCallingCQ && ui->cbFirst->isVisible () && ui->cbFirst->isChecked ()) { + ui->cbFirst->setStyleSheet("QCheckBox{color:red}"); + } else { + ui->cbFirst->setStyleSheet(""); + } + } + + if (m_tune) { + m_currentMessage = "TUNE"; + m_currentMessageType = -1; + } + if(m_restart) { + write_transmit_entry ("ALL.TXT"); + if (m_config.TX_messages ()) { + ui->decodedTextBrowser2->displayTransmittedText(m_currentMessage,m_modeTx, + ui->TxFreqSpinBox->value(),m_bFastMode); + } + } + + auto t2 = QDateTime::currentDateTimeUtc ().toString ("hhmm"); + icw[0] = 0; + auto msg_parts = m_currentMessage.split (' ', QString::SkipEmptyParts); + if (msg_parts.size () > 2) { + // clean up short code forms + msg_parts[0].remove (QChar {'<'}); + msg_parts[0].remove (QChar {'>'}); + msg_parts[1].remove (QChar {'<'}); + msg_parts[1].remove (QChar {'>'}); + } + auto is_73 = m_QSOProgress >= ROGER_REPORT + && message_is_73 (m_currentMessageType, msg_parts); + m_sentFirst73 = is_73 + && !message_is_73 (m_lastMessageType, m_lastMessageSent.split (' ', QString::SkipEmptyParts)); + if (m_sentFirst73) { + m_qsoStop=t2; + if(m_config.id_after_73 ()) { + icw[0] = m_ncw; + } + if((m_config.prompt_to_log() or m_config.autoLog()) && !m_tune) logQSOTimer.start(0); + } + + bool b=(m_mode=="FT8") and ui->cbAutoSeq->isChecked(); + if(is_73 and (m_config.disable_TX_on_73() or b)) { + m_nextCall=""; //### Temporary: disable use of "TU;" messages; + if(m_nextCall!="") { + useNextCall(); + } else { + auto_tx_mode (false); + if(b) { + m_ntx=6; + ui->txrb6->setChecked(true); + m_QSOProgress = CALLING; + } + } + } + + if(m_config.id_interval () >0) { + int nmin=(m_sec0-m_secID)/60; + if(m_sec0<m_secID) nmin=m_config.id_interval(); + if(nmin >= m_config.id_interval()) { + icw[0]=m_ncw; + m_secID=m_sec0; + } + } + + if ((m_currentMessageType < 6 || 7 == m_currentMessageType) + && msg_parts.length() >= 3 + && (msg_parts[1] == m_config.my_callsign () || + msg_parts[1] == m_baseCall)) + { + int i1; + bool ok; + i1 = msg_parts[2].toInt(&ok); + if(ok and i1>=-50 and i1<50) + { + m_rptSent = msg_parts[2]; + m_qsoStart = t2; + } else { + if (msg_parts[2].mid (0, 1) == "R") + { + i1 = msg_parts[2].mid (1).toInt (&ok); + if (ok and i1 >= -50 and i1 < 50) + { + m_rptSent = msg_parts[2].mid (1); + m_qsoStart = t2; + } + } + } + } + m_restart=false; +//---------------------------------------------------------------------- + } else { + if (!m_auto && m_sentFirst73) + { + m_sentFirst73 = false; + if (1 == ui->tabWidget->currentIndex()) + { + ui->genMsg->setText(ui->tx6->text()); + m_ntx=7; + m_QSOProgress = CALLING; + m_gen_message_is_cq = true; + ui->rbGenMsg->setChecked(true); + } + } + } + + if (g_iptt == 1 && m_iptt0 == 0) + { + auto const& current_message = QString::fromLatin1 (msgsent); + if(m_config.watchdog () && !m_mode.startsWith ("WSPR") + && current_message != m_msgSent0) { + tx_watchdog (false); // in case we are auto sequencing + m_msgSent0 = current_message; + } + + if(!m_tune) { + write_transmit_entry ("ALL.TXT"); + } + + if (m_config.TX_messages () && !m_tune && SpecOp::FOX!=m_config.special_op_id()) { + ui->decodedTextBrowser2->displayTransmittedText(current_message, m_modeTx, + ui->TxFreqSpinBox->value(),m_bFastMode); + } + + switch (m_ntx) + { + case 1: m_QSOProgress = REPLYING; break; + case 2: m_QSOProgress = REPORT; break; + case 3: m_QSOProgress = ROGER_REPORT; break; + case 4: m_QSOProgress = ROGERS; break; + case 5: m_QSOProgress = SIGNOFF; break; + case 6: m_QSOProgress = CALLING; break; + default: break; // determined elsewhere + } + m_transmitting = true; + transmitDisplay (true); + statusUpdate (); + } + + if(!m_btxok && m_btxok0 && g_iptt==1) stopTx(); + + if(m_startAnother) { + if(m_mode=="MSK144") { + m_wait++; + } + if(m_mode!="MSK144" or m_wait>=4) { + m_wait=0; + m_startAnother=false; + on_actionOpen_next_in_directory_triggered(); + } + } + + if(m_mode=="FT8" or m_mode=="MSK144") { + if(ui->txrb1->isEnabled() and + (SpecOp::NA_VHF==m_config.special_op_id() or + SpecOp::FIELD_DAY==m_config.special_op_id() or + SpecOp::RTTY==m_config.special_op_id()) ) { + //We're in a contest-like mode other than EU_VHF: start QSO with Tx2. + ui->tx1->setEnabled(false); + } + if(!ui->tx1->isEnabled() and SpecOp::EU_VHF==m_config.special_op_id()) { + //We're in EU_VHF mode: start QSO with Tx1. + ui->tx1->setEnabled(true); + } + } + +//Once per second: + if(nsec != m_sec0) { + // if((!m_msgAvgWidget or (m_msgAvgWidget and !m_msgAvgWidget->isVisible())) + // and (SpecOp::NONE < m_config.special_op_id()) and (SpecOp::HOUND > m_config.special_op_id())) on_actionFox_Log_triggered(); + if(m_freqNominal!=0 and m_freqNominal<50000000 and m_config.enable_VHF_features()) { + if(!m_bVHFwarned) vhfWarning(); + } else { + m_bVHFwarned=false; + } + m_currentBand=m_config.bands()->find(m_freqNominal); + + if( SpecOp::HOUND == m_config.special_op_id() ) { + qint32 tHound=QDateTime::currentMSecsSinceEpoch()/1000 - m_tAutoOn; + //To keep calling Fox, Hound must reactivate Enable Tx at least once every 2 minutes + if(tHound >= 120 and m_ntx==1) auto_tx_mode(false); + } + if(m_auto and m_mode=="Echo" and m_bEchoTxOK) { + progressBar.setMaximum(6); + progressBar.setValue(int(m_s6)); + } + + if(m_mode!="Echo") { + if(m_monitoring or m_transmitting) { + progressBar.setMaximum(m_TRperiod); + int isec=int(fmod(tsec,m_TRperiod)); + progressBar.setValue(isec); + } else { + progressBar.setValue(0); + } + } + + astroUpdate (); + + if(m_transmitting) { + char s[42]; + if(SpecOp::FOX==m_config.special_op_id() and ui->tabWidget->currentIndex()==2) { + sprintf(s,"Tx: %d Slots",foxcom_.nslots); + } else { + sprintf(s,"Tx: %s",msgsent); + } + m_nsendingsh=0; + if(s[4]==64) m_nsendingsh=1; + if(m_nsendingsh==1 or m_currentMessageType==7) { + tx_status_label.setStyleSheet("QLabel{background-color: #66ffff}"); + } else if(m_nsendingsh==-1 or m_currentMessageType==6) { + tx_status_label.setStyleSheet("QLabel{background-color: #ffccff}"); + } else { + tx_status_label.setStyleSheet("QLabel{background-color: #ffff33}"); + } + if(m_tune) { + tx_status_label.setText("Tx: TUNE"); + } else { + if(m_mode=="Echo") { + tx_status_label.setText("Tx: ECHO"); + } else { + s[40]=0; + QString t{QString::fromLatin1(s)}; + if(SpecOp::FOX==m_config.special_op_id() and ui->tabWidget->currentIndex()==2 and foxcom_.nslots==1) { + t=m_fm1.trimmed(); + } + tx_status_label.setText(t.trimmed()); + } + } + } else if(m_monitoring) { + if (!m_tx_watchdog) { + tx_status_label.setStyleSheet("QLabel{background-color: #00ff00}"); + QString t; + t="Receiving"; + if(m_mode=="MSK144") { + int npct=int(100.0*m_fCPUmskrtd/0.298667); + if(npct>90) tx_status_label.setStyleSheet("QLabel{background-color: #ff0000}"); + t.sprintf("Receiving %2d%%",npct); + } + tx_status_label.setText (t); + } + transmitDisplay(false); + } else if (!m_diskData && !m_tx_watchdog) { + tx_status_label.setStyleSheet(""); + tx_status_label.setText(""); + } + + QDateTime t = QDateTime::currentDateTimeUtc(); + QString utc = t.date().toString("yyyy MMM dd") + "\n " + + t.time().toString() + " "; + ui->labUTC->setText(utc); + if(!m_monitoring and !m_diskData) { + ui->signal_meter_widget->setValue(0,0); + } + m_sec0=nsec; + displayDialFrequency (); + } + m_iptt0=g_iptt; + m_btxok0=m_btxok; +} //End of guiUpdate + +void MainWindow::useNextCall() +{ + ui->dxCallEntry->setText(m_nextCall); + m_nextCall=""; + ui->labNextCall->setStyleSheet(""); + ui->labNextCall->setText(""); + if(m_nextGrid.contains(grid_regexp)) { + ui->dxGridEntry->setText(m_nextGrid); + m_ntx=2; + ui->txrb2->setChecked(true); + } else { + m_ntx=3; + ui->txrb3->setChecked(true); + } + genStdMsgs(m_nextRpt); +} + +void MainWindow::startTx2() +{ + if (!m_modulator->isActive ()) { // TODO - not thread safe + double fSpread=0.0; + double snr=99.0; + QString t=ui->tx5->currentText(); + if(t.mid(0,1)=="#") fSpread=t.mid(1,5).toDouble(); + m_modulator->setSpread(fSpread); // TODO - not thread safe + t=ui->tx6->text(); + if(t.mid(0,1)=="#") snr=t.mid(1,5).toDouble(); + if(snr>0.0 or snr < -50.0) snr=99.0; + transmit (snr); + ui->signal_meter_widget->setValue(0,0); + if(m_mode=="Echo" and !m_tune) m_bTransmittedEcho=true; + + if(m_mode.startsWith ("WSPR") and !m_tune) { + if (m_config.TX_messages ()) { + t = " Transmitting " + m_mode + " ----------------------- " + + m_config.bands ()->find (m_freqNominal); + t=WSPR_hhmm(0) + ' ' + t.rightJustified (66, '-'); + ui->decodedTextBrowser->appendText(t); + } + write_transmit_entry ("ALL_WSPR.TXT"); + } + } +} + +void MainWindow::stopTx() +{ + Q_EMIT endTransmitMessage (); + m_btxok = false; + m_transmitting = false; + g_iptt=0; + if (!m_tx_watchdog) { + tx_status_label.setStyleSheet(""); + tx_status_label.setText(""); + } + ptt0Timer.start(200); //end-of-transmission sequencer delay + monitor (true); + statusUpdate (); +} + +void MainWindow::stopTx2() +{ + Q_EMIT m_config.transceiver_ptt (false); //Lower PTT + if (m_mode == "JT9" && m_bFast9 + && ui->cbAutoSeq->isVisible () && ui->cbAutoSeq->isChecked() + && m_ntx == 5 && m_nTx73 >= 5) { + on_stopTxButton_clicked (); + m_nTx73 = 0; + } + if(m_mode.startsWith ("WSPR") and m_ntr==-1 and !m_tuneup) { + m_wideGraph->setWSPRtransmitted(); + WSPR_scheduling (); + m_ntr=0; + } + last_tx_label.setText("Last Tx: " + m_currentMessage.trimmed()); +//### if(m_mode=="FT8" and (SpecOp::HOUND == m_config.special_op_id())) auto_tx_mode(false); ### +} + +void MainWindow::ba2msg(QByteArray ba, char message[]) //ba2msg() +{ + int iz=ba.length(); + for(int i=0; i<37; i++) { + if(i<iz) { + message[i]=ba[i]; + } else { + message[i]=32; + } + } + message[37]=0; +} + +void MainWindow::on_txFirstCheckBox_stateChanged(int nstate) //TxFirst +{ + m_txFirst = (nstate==2); +} + +void MainWindow::set_dateTimeQSO(int m_ntx) +{ + // m_ntx = -1 resets to default time + // Our QSO start time can be fairly well determined from Tx 2 and Tx 3 -- the grid reports + // If we CQ'd and sending sigrpt then 2 minutes ago n=2 + // If we're on msg 3 then 3 minutes ago n=3 -- might have sat on msg1 for a while + // If we've already set our time on just return. + // This should mean that Tx2 or Tx3 has been repeated so don't update the start time + // We reset it in several places + if (m_ntx == -1) { // we use a default date to detect change + m_dateTimeQSOOn = QDateTime {}; + } + else if (m_dateTimeQSOOn.isValid ()) { + return; + } + else { // we also take of m_TRperiod/2 to allow for late clicks + auto now = QDateTime::currentDateTimeUtc(); + m_dateTimeQSOOn = now.addSecs (-(m_ntx - 2) * m_TRperiod - (now.time ().second () % m_TRperiod)); + } +} + +void MainWindow::set_ntx(int n) //set_ntx() +{ + m_ntx=n; +} + +void MainWindow::on_txrb1_toggled (bool status) +{ + if (status) { + if (ui->tx1->isEnabled ()) { + m_ntx = 1; + set_dateTimeQSO (-1); // we reset here as tx2/tx3 is used for start times + } + else { + QTimer::singleShot (0, ui->txrb2, SLOT (click ())); + } + } +} + +void MainWindow::on_txrb1_doubleClicked () +{ + if(m_mode=="FT8" and SpecOp::HOUND == m_config.special_op_id()) return; + // skip Tx1, only allowed if not a type 2 compound callsign + auto const& my_callsign = m_config.my_callsign (); + auto is_compound = my_callsign != m_baseCall; + ui->tx1->setEnabled ((is_compound && shortList (my_callsign)) || !ui->tx1->isEnabled ()); + if (!ui->tx1->isEnabled ()) { + // leave time for clicks to complete before setting txrb2 + QTimer::singleShot (500, ui->txrb2, SLOT (click ())); + } +} + +void MainWindow::on_txrb2_toggled (bool status) +{ + // Tx 2 means we already have CQ'd so good reference + if (status) { + m_ntx=2; + set_dateTimeQSO (m_ntx); + } +} + +void MainWindow::on_txrb3_toggled(bool status) +{ + // Tx 3 means we should have already have done Tx 1 so good reference + if (status) { + m_ntx=3; + set_dateTimeQSO(m_ntx); + } +} + +void MainWindow::on_txrb4_toggled (bool status) +{ + if (status) { + m_ntx=4; + } +} + +void MainWindow::on_txrb4_doubleClicked () +{ + // RR73 only allowed if not a type 2 compound callsign + auto const& my_callsign = m_config.my_callsign (); + auto is_compound = my_callsign != m_baseCall; + m_send_RR73 = !((is_compound && !shortList (my_callsign)) || m_send_RR73); + genStdMsgs (m_rpt); +} + +void MainWindow::on_txrb5_toggled (bool status) +{ + if (status) { + m_ntx = 5; + } +} + +void MainWindow::on_txrb5_doubleClicked () +{ + genStdMsgs (m_rpt, true); +} + +void MainWindow::on_txrb6_toggled(bool status) +{ + if (status) { + m_ntx=6; + if (ui->txrb6->text().contains (QRegularExpression {"^(CQ|QRZ) "})) set_dateTimeQSO(-1); + } +} + +void MainWindow::on_txb1_clicked() +{ + if (ui->tx1->isEnabled ()) { + m_ntx=1; + m_QSOProgress = REPLYING; + ui->txrb1->setChecked(true); + if (m_transmitting) m_restart=true; + } + else { + on_txb2_clicked (); + } +} + +void MainWindow::on_txb1_doubleClicked() +{ + if (m_mode=="FT8" and SpecOp::HOUND == m_config.special_op_id()) return; + // skip Tx1, only allowed if not a type 1 compound callsign + auto const& my_callsign = m_config.my_callsign (); + auto is_compound = my_callsign != m_baseCall; + ui->tx1->setEnabled ((is_compound && shortList (my_callsign)) || !ui->tx1->isEnabled ()); +} + +void MainWindow::on_txb2_clicked() +{ + m_ntx=2; + m_QSOProgress = REPORT; + ui->txrb2->setChecked(true); + if (m_transmitting) m_restart=true; +} + +void MainWindow::on_txb3_clicked() +{ + m_ntx=3; + m_QSOProgress = ROGER_REPORT; + ui->txrb3->setChecked(true); + if (m_transmitting) m_restart=true; +} + +void MainWindow::on_txb4_clicked() +{ + m_ntx=4; + m_QSOProgress = ROGERS; + ui->txrb4->setChecked(true); + if (m_transmitting) m_restart=true; +} + +void MainWindow::on_txb4_doubleClicked() +{ + // RR73 only allowed if not a type 2 compound callsign + auto const& my_callsign = m_config.my_callsign (); + auto is_compound = my_callsign != m_baseCall; + m_send_RR73 = !((is_compound && !shortList (my_callsign)) || m_send_RR73); + genStdMsgs (m_rpt); +} + +void MainWindow::on_txb5_clicked() +{ + m_ntx=5; + m_QSOProgress = SIGNOFF; + ui->txrb5->setChecked(true); + if (m_transmitting) m_restart=true; +} + +void MainWindow::on_txb5_doubleClicked() +{ + genStdMsgs (m_rpt, true); +} + +void MainWindow::on_txb6_clicked() +{ + m_ntx=6; + m_QSOProgress = CALLING; + set_dateTimeQSO(-1); + ui->txrb6->setChecked(true); + if (m_transmitting) m_restart=true; +} + +void MainWindow::doubleClickOnCall2(Qt::KeyboardModifiers modifiers) +{ + set_dateTimeQSO(-1); // reset our QSO start time + m_decodedText2=true; + doubleClickOnCall(modifiers); + m_decodedText2=false; +} + +void MainWindow::doubleClickOnCall(Qt::KeyboardModifiers modifiers) +{ +// if(!(modifiers & Qt::AltModifier) and m_transmitting) { +// qDebug() << "aa" << "Double-click on decode is ignored while transmitting"; +// return; +// } + QTextCursor cursor; + if(m_mode=="ISCAT") { + MessageBox::information_message (this, + "Double-click not available for ISCAT mode"); + } + if(m_decodedText2) { + cursor=ui->decodedTextBrowser->textCursor(); + } else { + cursor=ui->decodedTextBrowser2->textCursor(); + } + + if(modifiers==(Qt::ShiftModifier + Qt::ControlModifier + Qt::AltModifier)) { + //### What was the purpose of this ??? ### + cursor.setPosition(0); + } else { + cursor.setPosition(cursor.selectionStart()); + } + + if(SpecOp::FOX==m_config.special_op_id() and m_decodedText2) { + if(m_houndQueue.count()<10 and m_nSortedHounds>0) { + QString t=cursor.block().text(); + selectHound(t); + } + return; + } + DecodedText message {cursor.block().text()}; + m_bDoubleClicked = true; + processMessage (message, modifiers); +} + +void MainWindow::processMessage (DecodedText const& message, Qt::KeyboardModifiers modifiers) +{ + // decode keyboard modifiers we are interested in + auto shift = modifiers.testFlag (Qt::ShiftModifier); + auto ctrl = modifiers.testFlag (Qt::ControlModifier); + // auto alt = modifiers.testFlag (Qt::AltModifier); + + // basic mode sanity checks + auto const& parts = message.string ().split (' ', QString::SkipEmptyParts); + if (parts.size () < 5) return; + auto const& mode = parts.at (4).left (1); + if (("JT9+JT65" == m_mode && !("@" == mode || "#" == mode)) + || ("JT65" == m_mode && mode != "#") + || ("JT9" == m_mode && mode != "@") + || ("MSK144" == m_mode && !("&" == mode || "^" == mode)) + || ("QRA64" == m_mode && mode.left (1) != ":")) { + return; + } + + //Skip the rest if no decoded text extracted + int frequency = message.frequencyOffset(); + if (message.isTX()) { + if (!m_config.enable_VHF_features()) { + if(!shift) ui->RxFreqSpinBox->setValue(frequency); //Set Rx freq + if((ctrl or shift) and !ui->cbHoldTxFreq->isChecked ()) { + ui->TxFreqSpinBox->setValue(frequency); //Set Tx freq + } + } + return; + } + + // check for CQ with listening frequency + if (parts.size () >= 7 + && (m_bFastMode || m_mode=="FT8") + && "CQ" == parts[5] + && m_config.is_transceiver_online ()) { + bool ok; + auto kHz = parts[6].toUInt (&ok); + if (ok && kHz >= 10 && 3 == parts[6].size ()) { + // QSY Freq for answering CQ nnn + setRig (m_freqNominal / 1000000 * 1000000 + 1000 * kHz); + ui->decodedTextBrowser2->displayQSY (QString {"QSY %1"}.arg (m_freqNominal / 1e6, 7, 'f', 3)); + } + } + + int nmod = message.timeInSeconds () % (2*m_TRperiod); + m_txFirst=(nmod!=0); + if( SpecOp::HOUND == m_config.special_op_id() ) m_txFirst=false; //Hound must not transmit first + if( SpecOp::FOX == m_config.special_op_id() ) m_txFirst=true; //Fox must always transmit first + ui->txFirstCheckBox->setChecked(m_txFirst); + + auto const& message_words = message.messageWords (); + if (message_words.size () < 2) return; + + QString hiscall; + QString hisgrid; + message.deCallAndGrid(/*out*/hiscall,hisgrid); + if(message.string().contains(hiscall+"/R")) { + hiscall+="/R"; + ui->dxCallEntry->setText(hiscall); + } + if(message.string().contains(hiscall+"/P")) { + hiscall+="/P"; + ui->dxCallEntry->setText(hiscall); + } + + bool is_73 = message_words.filter (QRegularExpression {"^(73|RR73)$"}).size (); + if (!is_73 and !message.isStandardMessage() and !message.string().contains("<")) { + qDebug () << "Not processing message - hiscall:" << hiscall << "hisgrid:" << hisgrid + << message.string() << message.isStandardMessage(); + return; + } + + // only allow automatic mode changes between JT9 and JT65, and when not transmitting + if (!m_transmitting and m_mode == "JT9+JT65") { + if (message.isJT9()) + { + m_modeTx="JT9"; + ui->pbTxMode->setText("Tx JT9 @"); + m_wideGraph->setModeTx(m_modeTx); + } else if (message.isJT65()) { + m_modeTx="JT65"; + ui->pbTxMode->setText("Tx JT65 #"); + m_wideGraph->setModeTx(m_modeTx); + } + } else if ((message.isJT9 () and m_modeTx != "JT9" and m_mode != "JT4") or + (message.isJT65 () and m_modeTx != "JT65" and m_mode != "JT4")) { + // if we are not allowing mode change then don't process decode + return; + } + + QString firstcall = message.call(); + if(firstcall.length()==5 and firstcall.mid(0,3)=="CQ ") firstcall="CQ"; + if(!m_bFastMode and (!m_config.enable_VHF_features() or m_mode=="FT8")) { + // Don't change Tx freq if in a fast mode, or VHF features enabled; also not if a + // station is calling me, unless CTRL or SHIFT is held down. + if ((Radio::is_callsign (firstcall) + && firstcall != m_config.my_callsign () && firstcall != m_baseCall + && firstcall != "DE") + || "CQ" == firstcall || "QRZ" == firstcall || ctrl || shift) { + if (((SpecOp::HOUND != m_config.special_op_id()) || m_mode != "FT8") + && (!ui->cbHoldTxFreq->isChecked () || shift || ctrl)) { + ui->TxFreqSpinBox->setValue(frequency); + } + if(m_mode != "JT4" && m_mode != "JT65" && !m_mode.startsWith ("JT9") && + m_mode != "QRA64" && m_mode!="FT8") { + return; + } + } + } + + // prior DX call (possible QSO partner) + auto qso_partner_base_call = Radio::base_callsign (ui->dxCallEntry->text ()); + auto base_call = Radio::base_callsign (hiscall); + +// Determine appropriate response to received message + auto dtext = " " + message.string () + " "; + dtext=dtext.remove("<").remove(">"); + int gen_msg {0}; + if(dtext.contains (" " + m_baseCall + " ") + || dtext.contains ("<" + m_baseCall + "> ") +//###??? || dtext.contains ("<" + m_baseCall + " " + hiscall + "> ") + || dtext.contains ("/" + m_baseCall + " ") + || dtext.contains (" " + m_baseCall + "/") + || (firstcall == "DE")) { + QString w2=""; + if(message_words.size()>=3) w2=message_words.at(2); + QString w34=""; + if(message_words.size()>=4) w34=message_words.at(3); + int nrpt=w2.toInt(); + if(w2=="R") { + nrpt=w34.toInt(); + w34=message_words.at(4); + } + bool bEU_VHF_w2=(nrpt>=520001 and nrpt<=594000); + if(bEU_VHF_w2 and SpecOp::EU_VHF!=m_config.special_op_id()) { + // Switch automatically to EU VHF Contest mode + m_config.setEU_VHF_Contest(); +// m_nContest=EU_VHF; + if(m_transmitting) m_restart=true; + ui->decodedTextBrowser2->displayQSY (QString{"Enabled EU VHF Contest messages."}); + QString t0="EU VHF"; + ui->labDXped->setVisible(true); + ui->labDXped->setText(t0); + } + QStringList t=message.string().split(' ', QString::SkipEmptyParts); + int n=t.size(); + QString t0=t.at(n-2); + QString t1=t0.right(1); + bool bFieldDay_msg = (t1>="A" and t1<="F" and t0.size()<=3 and n>=9); + int m=t0.remove(t1).toInt(); + if(m < 1) bFieldDay_msg=false; + if(bFieldDay_msg) { + m_xRcvd=t.at(n-2) + " " + t.at(n-1); + t0=t.at(n-3); + } + + if(bFieldDay_msg and SpecOp::FIELD_DAY!=m_config.special_op_id()) { + // ### Should be in ARRL Field Day mode ??? ### + MessageBox::information_message (this, tr ("Should you switch to ARRL Field Day mode?")); + } + + n=w34.toInt(); + bool bRTTY = (n>=529 and n<=599); + if(bRTTY and SpecOp::RTTY != m_config.special_op_id()) { + // ### Should be in RTTY contest mode ??? ### + MessageBox::information_message (this, tr ("Should you switch to RTTY contest mode?")); + } + + if(message_words.size () > 3 // enough fields for a normal message + && (message_words.at(1).contains(m_baseCall) || "DE" == message_words.at(1)) +// && (message_words.at(2).contains(qso_partner_base_call) or bEU_VHF_w2)) { + && (message_words.at(2).contains(qso_partner_base_call) or m_bDoubleClicked or bEU_VHF_w2)) { + + if(message_words.at(3).contains(grid_regexp) and SpecOp::EU_VHF!=m_config.special_op_id()) { + if(SpecOp::NA_VHF==m_config.special_op_id()){ + gen_msg=setTxMsg(3); + m_QSOProgress=ROGER_REPORT; + } else { + if(m_mode=="JT65" and message_words.size()>4 and message_words.at(4)=="OOO") { + gen_msg=setTxMsg(3); + m_QSOProgress=ROGER_REPORT; + } else { + gen_msg=setTxMsg(2); + m_QSOProgress=REPORT; + } + } + } else if(w34.contains(grid_regexp) and SpecOp::EU_VHF==m_config.special_op_id()) { + if(nrpt==0) { + gen_msg=setTxMsg(2); + m_QSOProgress=REPORT; + } else { + if(w2=="R") { + gen_msg=setTxMsg(4); + m_QSOProgress=ROGERS; + } else { + gen_msg=setTxMsg(3); + m_QSOProgress=ROGER_REPORT; + } + } + } else if(SpecOp::RTTY == m_config.special_op_id() and bRTTY) { + gen_msg=setTxMsg(3); + m_QSOProgress=ROGER_REPORT; + int n=t.size(); + int nRpt=t[n-2].toInt(); + if(nRpt>=529 and nRpt<=599) m_xRcvd=t[n-2] + " " + t[n-1]; + } else if(SpecOp::FIELD_DAY==m_config.special_op_id() and bFieldDay_msg) { + if(t0=="R") { + gen_msg=setTxMsg(4); + m_QSOProgress=ROGERS; + } else { + gen_msg=setTxMsg(3); + m_QSOProgress=ROGER_REPORT; + } + } else { // no grid on end of msg + QString r=message_words.at (3); + if(m_QSOProgress >= ROGER_REPORT && (r=="RRR" || r.toInt()==73 || "RR73" == r)) { + if(ui->tabWidget->currentIndex()==1) { + gen_msg = 5; + if (ui->rbGenMsg->isChecked ()) m_ntx=7; + m_gen_message_is_cq = false; + } else { + m_bTUmsg=false; + m_nextCall=""; //### Temporary: disable use of "TU;" message + if(SpecOp::RTTY == m_config.special_op_id() and m_nextCall!="") { +// We're in RTTY contest and have "nextCall" queued up: send a "TU; ..." message + logQSOTimer.start(0); + ui->tx3->setText(ui->tx3->text().remove("TU; ")); + useNextCall(); + QString t="TU; " + ui->tx3->text(); + ui->tx3->setText(t); + m_bTUmsg=true; + } else { +// if(SpecOp::RTTY == m_config.special_op_id()) { + if(false) { + logQSOTimer.start(0); + m_ntx=6; + ui->txrb6->setChecked(true); + } else { + m_ntx=5; + ui->txrb5->setChecked(true); + } + } + } + m_QSOProgress = SIGNOFF; + } else if((m_QSOProgress >= REPORT + || (m_QSOProgress >= REPLYING && (m_mode=="MSK144" or m_mode=="FT8"))) + && r.mid(0,1)=="R") { + m_ntx=4; + m_QSOProgress = ROGERS; + if(SpecOp::RTTY == m_config.special_op_id()) { + int n=t.size(); + int nRpt=t[n-2].toInt(); + if(nRpt>=529 and nRpt<=599) m_xRcvd=t[n-2] + " " + t[n-1]; + } + ui->txrb4->setChecked(true); + if(ui->tabWidget->currentIndex()==1) { + gen_msg = 4; + m_ntx=7; + m_gen_message_is_cq = false; + } + } else if(m_QSOProgress>=CALLING and + ((r.toInt()>=-50 && r.toInt()<=49) or (r.toInt()>=529 && r.toInt()<=599))) { + if(SpecOp::EU_VHF==m_config.special_op_id() or + SpecOp::FIELD_DAY==m_config.special_op_id() or + SpecOp::RTTY==m_config.special_op_id()) { + gen_msg=setTxMsg(2); + m_QSOProgress=REPORT; + } else { + if(r.left(2)=="R-" or r.left(2)=="R+") { + gen_msg=setTxMsg(4); + m_QSOProgress=ROGERS; + } else { + gen_msg=setTxMsg(3); + m_QSOProgress=ROGER_REPORT; + } + } + } else { // nothing for us + return; + } + } + } + else if (m_QSOProgress >= ROGERS + && message_words.size () > 2 && message_words.at (1).contains (m_baseCall) + && message_words.at (2) == "73") { + // 73 back to compound call holder + if(ui->tabWidget->currentIndex()==1) { + gen_msg = 5; + if (ui->rbGenMsg->isChecked ()) m_ntx=7; + m_gen_message_is_cq = false; + } + else { + m_ntx=5; + ui->txrb5->setChecked(true); + } + m_QSOProgress = SIGNOFF; + } + else if (!(m_bAutoReply && m_QSOProgress > CALLING)) { + if ((message_words.size () > 4 && message_words.at (1).contains (m_baseCall) + && message_words.at (4) == "OOO")) { + // EME short code report or MSK144/FT8 contest mode reply, send back Tx3 + m_ntx=3; + m_QSOProgress = ROGER_REPORT; + ui->txrb3->setChecked (true); + if (ui->tabWidget->currentIndex () == 1) { + gen_msg = 3; + m_ntx = 7; + m_gen_message_is_cq = false; + } + } else if (!is_73) { // don't respond to sign off messages + m_ntx=2; + m_QSOProgress = REPORT; + ui->txrb2->setChecked(true); + if(ui->tabWidget->currentIndex()==1) { + gen_msg = 2; + m_ntx=7; + m_gen_message_is_cq = false; + } + + if (m_bDoubleClickAfterCQnnn and m_transmitting) { + on_stopTxButton_clicked(); + TxAgainTimer.start(1500); + } + m_bDoubleClickAfterCQnnn=false; + } + else { + return; // nothing we need to respond to + } + } + else { // nothing for us +// if(message_words.size () > 3 // enough fields for a normal message +// && SpecOp::RTTY == m_config.special_op_id() +// && (message_words.at(1).contains(m_baseCall) || "DE" == message_words.at(1)) +// && (!message_words.at(2).contains(qso_partner_base_call) and !bEU_VHF_w2)) { +//// Queue up the next QSO partner +// m_nextCall=message_words.at(2); +// m_nextGrid=message_words.at(3); +// m_nextRpt=message.report(); +// ui->labNextCall->setText("Next: " + m_nextCall); +// ui->labNextCall->setStyleSheet("QLabel {background-color: #66ff66}"); +// } + return; + } + } + else if (firstcall == "DE" && message_words.size () > 3 && message_words.at (3) == "73") { + if (m_QSOProgress >= ROGERS && base_call == qso_partner_base_call && m_currentMessageType) { + // 73 back to compound call holder + if(ui->tabWidget->currentIndex()==1) { + gen_msg = 5; + m_ntx=7; + m_gen_message_is_cq = false; + } else { + m_ntx=5; + ui->txrb5->setChecked(true); + } + m_QSOProgress = SIGNOFF; + } else { + // treat like a CQ/QRZ + if (ui->tx1->isEnabled ()) { + m_ntx = 1; + m_QSOProgress = REPLYING; + ui->txrb1->setChecked (true); + } else { + m_ntx=2; + m_QSOProgress = REPORT; + ui->txrb2->setChecked (true); + } + if(ui->tabWidget->currentIndex()==1) { + gen_msg = 1; + m_ntx=7; + m_gen_message_is_cq = false; + } + } + } + else if (is_73 && !message.isStandardMessage ()) { + if(ui->tabWidget->currentIndex()==1) { + gen_msg = 5; + if (ui->rbGenMsg->isChecked ()) m_ntx=7; + m_gen_message_is_cq = false; + } else { + m_ntx=5; + ui->txrb5->setChecked(true); + } + m_QSOProgress = SIGNOFF; + } else { + // just work them + if (ui->tx1->isEnabled ()) { + m_ntx = 1; + m_QSOProgress = REPLYING; + ui->txrb1->setChecked (true); + } else { + m_ntx=2; + m_QSOProgress = REPORT; + ui->txrb2->setChecked (true); + } + if (1 == ui->tabWidget->currentIndex ()) { + gen_msg = m_ntx; + m_ntx=7; + m_gen_message_is_cq = false; + } + } + + // if we get here then we are reacting to the message + if (m_bAutoReply) m_bCallingCQ = CALLING == m_QSOProgress; + if (ui->RxFreqSpinBox->isEnabled () and m_mode != "MSK144" and !shift) { + ui->RxFreqSpinBox->setValue (frequency); //Set Rx freq + } + + QString s1 = m_QSOText.trimmed (); + QString s2 = message.string ().trimmed(); + if (s1!=s2 and !message.isTX()) { + if (!s2.contains(m_baseCall) or m_mode=="MSK144") { // Taken care of elsewhere if for_us and slow mode + ui->decodedTextBrowser2->displayDecodedText(message, m_baseCall,m_mode,m_config.DXCC(), + m_logBook,m_currentBand,m_config.ppfx()); + } + m_QSOText = s2; + } + + if (Radio::is_callsign (hiscall) + && (base_call != qso_partner_base_call || base_call != hiscall)) { + if (qso_partner_base_call != base_call) { + // clear the DX grid if the base call of his call is different + // from the current DX call + ui->dxGridEntry->clear (); + } + // his base call different or his call more qualified + // i.e. compound version of same base call + ui->dxCallEntry->setText (hiscall); + } + if (hisgrid.contains (grid_regexp)) { + if(ui->dxGridEntry->text().mid(0,4) != hisgrid) ui->dxGridEntry->setText(hisgrid); + } + if (!ui->dxGridEntry->text ().size ()) + lookup(); + m_hisGrid = ui->dxGridEntry->text(); + + QString rpt = message.report(); + int n=rpt.toInt(); + if(m_mode=="MSK144" and m_bShMsgs) { + int n=rpt.toInt(); + if(n<=-2) n=-3; + if(n>=-1 and n<=1) n=0; + if(n>=2 and n<=4) n=3; + if(n>=5 and n<=7) n=6; + if(n>=8 and n<=11) n=10; + if(n>=12 and n<=14) n=13; + if(n>=15) n=16; + rpt=QString::number(n); + } + + ui->rptSpinBox->setValue(n); +// Don't genStdMsgs if we're already sending 73, or a "TU; " msg is queued. + m_bTUmsg=false; //### Temporary: disable use of "TU;" messages + if (!m_nTx73 and !m_bTUmsg) { + genStdMsgs(rpt); + if (gen_msg) { + switch (gen_msg) { + case 1: ui->genMsg->setText (ui->tx1->text ()); break; + case 2: ui->genMsg->setText (ui->tx2->text ()); break; + case 3: ui->genMsg->setText (ui->tx3->text ()); break; + case 4: ui->genMsg->setText (ui->tx4->text ()); break; + case 5: ui->genMsg->setText (ui->tx5->currentText ()); break; + } + if (gen_msg != 5) { // allow user to pre-select a free message + ui->rbGenMsg->setChecked (true); + } + } + } + + if(m_transmitting) m_restart=true; + if (ui->cbAutoSeq->isVisible () && ui->cbAutoSeq->isChecked () && !m_bDoubleClicked) return; + if(m_config.quick_call()) auto_tx_mode(true); + m_bDoubleClicked=false; +} + +int MainWindow::setTxMsg(int n) +{ + m_ntx=n; + if(n==1) ui->txrb1->setChecked(true); + if(n==2) ui->txrb2->setChecked(true); + if(n==3) ui->txrb3->setChecked(true); + if(n==4) ui->txrb4->setChecked(true); + if(n==5) ui->txrb5->setChecked(true); + if(ui->tabWidget->currentIndex()==1) { + m_ntx=7; //### FIX THIS ### + m_gen_message_is_cq = false; + } + return n; +} + +void MainWindow::genCQMsg () +{ + if(m_config.my_callsign().size () && m_config.my_grid().size ()) { + QString grid{m_config.my_grid()}; + if (ui->cbCQTx->isEnabled () && ui->cbCQTx->isVisible () && ui->cbCQTx->isChecked ()) { + if(stdCall(m_config.my_callsign())) { + msgtype (QString {"CQ %1 %2 %3"} + .arg (m_freqNominal / 1000 - m_freqNominal / 1000000 * 1000, 3, 10, QChar {'0'}) + .arg (m_config.my_callsign()) + .arg (grid.left (4)), + ui->tx6); + } else { + msgtype (QString {"CQ %1 %2"} + .arg (m_freqNominal / 1000 - m_freqNominal / 1000000 * 1000, 3, 10, QChar {'0'}) + .arg (m_config.my_callsign()), + ui->tx6); + } + } else { + if(stdCall(m_config.my_callsign())) { + msgtype (QString {"%1 %2 %3"}.arg(m_CQtype).arg(m_config.my_callsign()) + .arg(grid.left(4)),ui->tx6); + } else { + msgtype (QString {"%1 %2"}.arg(m_CQtype).arg(m_config.my_callsign()),ui->tx6); + } + } + if ((m_mode=="JT4" or m_mode=="QRA64") and ui->cbShMsgs->isChecked()) { + if (ui->cbTx6->isChecked ()) { + msgtype ("@1250 (SEND MSGS)", ui->tx6); + } else { + msgtype ("@1000 (TUNE)", ui->tx6); + } + } + + QString t=ui->tx6->text(); + if((m_mode=="FT8" or m_mode=="MSK144") and SpecOp::NONE != m_config.special_op_id() and + t.split(" ").at(1)==m_config.my_callsign() and stdCall(m_config.my_callsign())) { + if(SpecOp::NA_VHF == m_config.special_op_id()) t="CQ TEST" + t.mid(2,-1); + if(SpecOp::EU_VHF == m_config.special_op_id()) t="CQ TEST" + t.mid(2,-1); + if(SpecOp::FIELD_DAY == m_config.special_op_id()) t="CQ FD" + t.mid(2,-1); + if(SpecOp::RTTY == m_config.special_op_id()) t="CQ RU" + t.mid(2,-1); + ui->tx6->setText(t); + } + } else { + ui->tx6->clear (); + } +} + +void MainWindow::abortQSO() +{ + bool b=m_auto; + clearDX(); + if(b) auto_tx_mode(false); + ui->txrb6->setChecked(true); +} + +bool MainWindow::stdCall(QString const& w) +{ + static QRegularExpression standard_call_re { + R"( + ^\s* # optional leading spaces + ( [A-Z]{0,2} | [A-Z][0-9] | [0-9][A-Z] ) # part 1 + ( [0-9][A-Z]{0,3} ) # part 2 + (/R | /P)? # optional suffix + \s*$ # optional trailing spaces + )", QRegularExpression::CaseInsensitiveOption | QRegularExpression::ExtendedPatternSyntaxOption}; + return standard_call_re.match (w).hasMatch (); +} + +void MainWindow::genStdMsgs(QString rpt, bool unconditional) +{ +// Prevent abortQSO from working when a TU; message is already queued +// if(ui->tx3->text().left(4)=="TU; ") { +// return; +// } + + genCQMsg (); + auto const& hisCall=ui->dxCallEntry->text(); + if(!hisCall.size ()) { + ui->labAz->clear (); +// ui->labDist->clear (); + ui->tx1->clear (); + ui->tx2->clear (); + ui->tx3->clear (); + ui->tx4->clear (); + if(unconditional) ui->tx5->lineEdit ()->clear (); //Test if it needs sending again + ui->genMsg->clear (); + m_gen_message_is_cq = false; + return; + } + auto const& my_callsign = m_config.my_callsign (); + auto is_compound = my_callsign != m_baseCall; + auto is_type_one = is_compound && shortList (my_callsign); + auto const& my_grid = m_config.my_grid ().left (4); + auto const& hisBase = Radio::base_callsign (hisCall); + auto eme_short_codes = m_config.enable_VHF_features () && ui->cbShMsgs->isChecked () + && m_mode == "JT65"; + + bool bMyCall=stdCall(my_callsign); + bool bHisCall=stdCall(hisCall); + + QString t0=hisBase + " " + m_baseCall + " "; + QString t0s=hisCall + " " + my_callsign + " "; + QString t0a,t0b; + + if(bHisCall and bMyCall) t0=hisCall + " " + my_callsign + " "; + t0a="<"+hisCall + "> " + my_callsign + " "; + t0b=hisCall + " <" + my_callsign + "> "; + + QString t00=t0; + QString t {t0 + my_grid}; + if(!bMyCall) t=t0a; + msgtype(t, ui->tx1); + if (eme_short_codes) { + t=t+" OOO"; + msgtype(t, ui->tx2); + msgtype("RO", ui->tx3); + msgtype("RRR", ui->tx4); + msgtype("73", ui->tx5->lineEdit()); + } else { + int n=rpt.toInt(); + rpt.sprintf("%+2.2d",n); + + if(m_mode=="MSK144" or m_mode=="FT8") { + QString t2,t3; + QString sent=rpt; + QString rs,rst; + int nn=(n+36)/6; + if(nn<2) nn=2; + if(nn>9) nn=9; + rst.sprintf("5%1d9 ",nn); + rs=rst.mid(0,2); + t=t0; + if(!bMyCall) { + t=t0b; + msgtype(t0a, ui->tx1); + } + if(!bHisCall) { + t=t0a; + msgtype(t0a, ui->tx1); + } + if(SpecOp::NA_VHF==m_config.special_op_id()) sent=my_grid; + if(SpecOp::FIELD_DAY==m_config.special_op_id()) sent=m_config.Field_Day_Exchange(); + if(SpecOp::RTTY==m_config.special_op_id()) { + sent=rst + m_config.RTTY_Exchange(); + QString t1=m_config.RTTY_Exchange(); + if(t1=="DX" or t1=="#") { + t1.sprintf("%4.4d",ui->sbSerialNumber->value()); + sent=rst + t1; + } + } + if(SpecOp::EU_VHF==m_config.special_op_id()) { + QString t1,a; + t=t0.split(" ").at(0) + " "; + a.sprintf("%4.4d ",ui->sbSerialNumber->value()); + sent=rs + a + m_config.my_grid(); + } + msgtype(t + sent, ui->tx2); + if(sent==rpt) msgtype(t + "R" + sent, ui->tx3); + if(sent!=rpt) msgtype(t + "R " + sent, ui->tx3); + } + + if(m_mode=="MSK144" and m_bShMsgs) { + int i=t0s.length()-1; + t0="<" + t0s.mid(0,i) + "> "; + if(SpecOp::NA_VHF != m_config.special_op_id()) { + if(n<=-2) n=-3; + if(n>=-1 and n<=1) n=0; + if(n>=2 and n<=4) n=3; + if(n>=5 and n<=7) n=6; + if(n>=8 and n<=11) n=10; + if(n>=12 and n<=14) n=13; + if(n>=15) n=16; + rpt.sprintf("%+2.2d",n); + } + } + + if((m_mode!="MSK144" and m_mode!="FT8")) { + t=t00 + rpt; + msgtype(t, ui->tx2); + t=t0 + "R" + rpt; + msgtype(t, ui->tx3); + } + + if(m_mode=="MSK144" and m_bShMsgs) { + if(m_config.special_op_id()==SpecOp::NONE) { + t=t0 + "R" + rpt; + msgtype(t, ui->tx3); + } + m_send_RR73=false; + } + + t=t0 + (m_send_RR73 ? "RR73" : "RRR"); + if((m_mode=="MSK144" and !m_bShMsgs) or m_mode=="FT8") { + if(!bHisCall and bMyCall) t=hisCall + " <" + my_callsign + "> " + (m_send_RR73 ? "RR73" : "RRR"); + if(bHisCall and !bMyCall) t="<" + hisCall + "> " + my_callsign + " " + (m_send_RR73 ? "RR73" : "RRR"); + } + if ((m_mode=="JT4" || m_mode=="QRA64") && m_bShMsgs) t="@1500 (RRR)"; + msgtype(t, ui->tx4); + + t=t0 + "73"; + if((m_mode=="MSK144" and !m_bShMsgs) or m_mode=="FT8") { + if(!bHisCall and bMyCall) t=hisCall + " <" + my_callsign + "> 73"; + if(bHisCall and !bMyCall) t="<" + hisCall + "> " + my_callsign + " 73"; + } + if (m_mode=="JT4" || m_mode=="QRA64") { + if (m_bShMsgs) t="@1750 (73)"; + msgtype(t, ui->tx5->lineEdit()); + } else if ("MSK144" == m_mode && m_bShMsgs) { + msgtype(t, ui->tx5->lineEdit()); + } else if(unconditional || hisBase != m_lastCallsign || !m_lastCallsign.size ()) { + // only update tx5 when forced or callsign changes + msgtype(t, ui->tx5->lineEdit()); + m_lastCallsign = hisBase; + } + } + + if(m_mode=="FT8" or m_mode=="MSK144") return; + + if (is_compound) { + if (is_type_one) { + t=hisBase + " " + my_callsign; + msgtype(t, ui->tx1); + } else { + t = "DE " + my_callsign + " "; + switch (m_config.type_2_msg_gen ()) + { + case Configuration::type_2_msg_1_full: + msgtype(t + my_grid, ui->tx1); + if (!eme_short_codes) { + if((m_mode=="MSK144" || m_mode=="FT8") && SpecOp::NA_VHF == m_config.special_op_id()) { + msgtype(t + "R " + my_grid, ui->tx3); + } else { + msgtype(t + "R" + rpt, ui->tx3); + } + if ((m_mode != "JT4" && m_mode != "QRA64") || !m_bShMsgs) { + msgtype(t + "73", ui->tx5->lineEdit ()); + } + } + break; + + case Configuration::type_2_msg_3_full: + if ((m_mode=="MSK144" || m_mode=="FT8") && SpecOp::NA_VHF == m_config.special_op_id()) { + msgtype(t + "R " + my_grid, ui->tx3); + msgtype(t + "RRR", ui->tx4); + } else { + msgtype(t00 + my_grid, ui->tx1); + msgtype(t + "R" + rpt, ui->tx3); + } + if (!eme_short_codes && ((m_mode != "JT4" && m_mode != "QRA64") || !m_bShMsgs)) { + msgtype(t + "73", ui->tx5->lineEdit ()); + } + break; + + case Configuration::type_2_msg_5_only: + msgtype(t00 + my_grid, ui->tx1); + if (!eme_short_codes) { + if ((m_mode=="MSK144" || m_mode=="FT8") && SpecOp::NA_VHF == m_config.special_op_id()) { + msgtype(t + "R " + my_grid, ui->tx3); + msgtype(t + "RRR", ui->tx4); + } else { + msgtype(t0 + "R" + rpt, ui->tx3); + } + } + // don't use short codes here as in a sked with a type 2 + // prefix we would never send out prefix/suffix + msgtype(t + "73", ui->tx5->lineEdit ()); + break; + } + } + if (hisCall != hisBase + && m_config.type_2_msg_gen () != Configuration::type_2_msg_5_only + && !eme_short_codes) { + // cfm we have his full call copied as we could not do this earlier + t = hisCall + " 73"; + msgtype(t, ui->tx5->lineEdit ()); + } + } else { + if (hisCall != hisBase and SpecOp::HOUND != m_config.special_op_id()) { + if (shortList(hisCall)) { + // cfm we know his full call with a type 1 tx1 message + t = hisCall + " " + my_callsign; + msgtype(t, ui->tx1); + } + else if (!eme_short_codes + && ("MSK144" != m_mode || !m_bShMsgs)) { + t=hisCall + " 73"; + msgtype(t, ui->tx5->lineEdit ()); + } + } + } + m_rpt=rpt; + if(SpecOp::HOUND == m_config.special_op_id() and is_compound) ui->tx1->setText("DE " + m_config.my_callsign()); +} + +void MainWindow::TxAgain() +{ + auto_tx_mode(true); +} + +void MainWindow::clearDX () +{ + if (m_QSOProgress != CALLING) + { + auto_tx_mode (false); + } + ui->dxCallEntry->clear (); + ui->dxGridEntry->clear (); + m_lastCallsign.clear (); + m_rptSent.clear (); + m_rptRcvd.clear (); + m_qsoStart.clear (); + m_qsoStop.clear (); + genStdMsgs (QString {}); + if (ui->tabWidget->currentIndex() == 1) { + ui->genMsg->setText(ui->tx6->text()); + m_ntx=7; + m_gen_message_is_cq = true; + ui->rbGenMsg->setChecked(true); + } else { + if (m_mode=="FT8" and SpecOp::HOUND == m_config.special_op_id()) { + m_ntx=1; + ui->txrb1->setChecked(true); + } else { + m_ntx=6; + ui->txrb6->setChecked(true); + } + } + m_QSOProgress = CALLING; +} + +void MainWindow::lookup() //lookup() +{ + QString hisCall {ui->dxCallEntry->text()}; + if (!hisCall.size ()) return; + QFile f {m_config.writeable_data_dir ().absoluteFilePath ("CALL3.TXT")}; + if (f.open (QIODevice::ReadOnly | QIODevice::Text)) + { + char c[132]; + qint64 n=0; + for(int i=0; i<999999; i++) { + n=f.readLine(c,sizeof(c)); + if(n <= 0) { + ui->dxGridEntry->clear (); + break; + } + QString t=QString(c); + if(t.indexOf(hisCall)==0) { + int i1=t.indexOf(","); + QString hisgrid=t.mid(i1+1,6); + i1=hisgrid.indexOf(","); + if(i1>0) { + hisgrid=hisgrid.mid(0,4); + } else { + hisgrid=hisgrid.mid(0,4) + hisgrid.mid(4,2).toLower(); + } + ui->dxGridEntry->setText(hisgrid); + break; + } + } + f.close(); + } +} + +void MainWindow::on_lookupButton_clicked() //Lookup button +{ + lookup(); +} + +void MainWindow::on_addButton_clicked() //Add button +{ + if(!ui->dxGridEntry->text ().size ()) { + MessageBox::warning_message (this, tr ("Add to CALL3.TXT") + , tr ("Please enter a valid grid locator")); + return; + } + m_call3Modified=false; + QString hisCall=ui->dxCallEntry->text(); + QString hisgrid=ui->dxGridEntry->text(); + QString newEntry=hisCall + "," + hisgrid; + + // int ret = MessageBox::query_message(this, tr ("Add to CALL3.TXT"), + // tr ("Is %1 known to be active on EME?").arg (newEntry)); + // if(ret==MessageBox::Yes) { + // newEntry += ",EME,,"; + // } else { + newEntry += ",,,"; + // } + + QFile f1 {m_config.writeable_data_dir ().absoluteFilePath ("CALL3.TXT")}; + if(!f1.open(QIODevice::ReadWrite | QIODevice::Text)) { + MessageBox::warning_message (this, tr ("Add to CALL3.TXT") + , tr ("Cannot open \"%1\" for read/write: %2") + .arg (f1.fileName ()).arg (f1.errorString ())); + return; + } + if(f1.size()==0) { + QTextStream out(&f1); + out << "ZZZZZZ" << endl; + f1.close(); + f1.open(QIODevice::ReadOnly | QIODevice::Text); + } + QFile f2 {m_config.writeable_data_dir ().absoluteFilePath ("CALL3.TMP")}; + if(!f2.open(QIODevice::WriteOnly | QIODevice::Text)) { + MessageBox::warning_message (this, tr ("Add to CALL3.TXT") + , tr ("Cannot open \"%1\" for writing: %2") + .arg (f2.fileName ()).arg (f2.errorString ())); + return; + } + QTextStream in(&f1); //Read from CALL3.TXT + QTextStream out(&f2); //Copy into CALL3.TMP + QString hc=hisCall; + QString hc1=""; + QString hc2="000000"; + QString s; + do { + s=in.readLine(); + hc1=hc2; + if(s.mid(0,2)=="//") { + out << s + QChar::LineFeed; //Copy all comment lines + } else { + int i1=s.indexOf(","); + hc2=s.mid(0,i1); + if(hc>hc1 && hc<hc2) { + out << newEntry + QChar::LineFeed; + out << s + QChar::LineFeed; + m_call3Modified=true; + } else if(hc==hc2) { + QString t {tr ("%1\nis already in CALL3.TXT" + ", do you wish to replace it?").arg (s)}; + int ret = MessageBox::query_message (this, tr ("Add to CALL3.TXT"), t); + if(ret==MessageBox::Yes) { + out << newEntry + QChar::LineFeed; + m_call3Modified=true; + } + } else { + if(s!="") out << s + QChar::LineFeed; + } + } + } while(!s.isNull()); + + f1.close(); + if(hc>hc1 && !m_call3Modified) out << newEntry + QChar::LineFeed; + if(m_call3Modified) { + QFile f0 {m_config.writeable_data_dir ().absoluteFilePath ("CALL3.OLD")}; + if(f0.exists()) f0.remove(); + QFile f1 {m_config.writeable_data_dir ().absoluteFilePath ("CALL3.TXT")}; + f1.rename(m_config.writeable_data_dir ().absoluteFilePath ("CALL3.OLD")); + f2.rename(m_config.writeable_data_dir ().absoluteFilePath ("CALL3.TXT")); + f2.close(); + } +} + +void MainWindow::msgtype(QString t, QLineEdit* tx) //msgtype() +{ +// Set background colors of the Tx message boxes, depending on message type + char message[38]; + char msgsent[38]; + QByteArray s=t.toUpper().toLocal8Bit(); + ba2msg(s,message); + int ichk=1,itype=0; + gen65_(message,&ichk,msgsent,const_cast<int*>(itone0),&itype,22,22); + msgsent[22]=0; + bool text=false; + bool shortMsg=false; + if(itype==6) text=true; + +//### Check this stuff ### + if(itype==7 and m_config.enable_VHF_features() and m_mode=="JT65") shortMsg=true; + if(m_mode=="MSK144" and t.mid(0,1)=="<") text=false; + if((m_mode=="MSK144" or m_mode=="FT8") and SpecOp::NA_VHF==m_config.special_op_id()) { + int i0=t.trimmed().length()-7; + if(t.mid(i0,3)==" R ") text=false; + } + text=false; +//### ... to here ... + + + QPalette p(tx->palette()); + if(text) { + p.setColor(QPalette::Base,"#ffccff"); //pink + } else { + if(shortMsg) { + p.setColor(QPalette::Base,"#66ffff"); //light blue + } else { + p.setColor(QPalette::Base,Qt::transparent); + if(m_mode=="MSK144" and t.mid(0,1)=="<") { + p.setColor(QPalette::Base,"#00ffff"); //another light blue + } + } + } + tx->setPalette(p); + + auto pos = tx->cursorPosition (); + tx->setText(t.toUpper()); + tx->setCursorPosition (pos); +} + +void MainWindow::on_tx1_editingFinished() //tx1 edited +{ + QString t=ui->tx1->text(); + msgtype(t, ui->tx1); +} + +void MainWindow::on_tx2_editingFinished() //tx2 edited +{ + QString t=ui->tx2->text(); + msgtype(t, ui->tx2); +} + +void MainWindow::on_tx3_editingFinished() //tx3 edited +{ + QString t=ui->tx3->text(); + msgtype(t, ui->tx3); +} + +void MainWindow::on_tx4_editingFinished() //tx4 edited +{ + QString t=ui->tx4->text(); + msgtype(t, ui->tx4); +} + +void MainWindow::on_tx5_currentTextChanged (QString const& text) //tx5 edited +{ + msgtype(text, ui->tx5->lineEdit ()); +} + +void MainWindow::on_tx6_editingFinished() //tx6 edited +{ + QString t=ui->tx6->text().toUpper(); + if(t.indexOf(" ")>0) { + QString t1=t.split(" ").at(1); + m_CQtype="CQ"; + if(t1.size()==2) m_CQtype="CQ " + t1; + } + msgtype(t, ui->tx6); +} + +void MainWindow::on_dxCallEntry_textChanged (QString const& call) +{ + m_hisCall = call; + statusChanged(); + statusUpdate (); +} + +void MainWindow::on_dxCallEntry_returnPressed () +{ + on_lookupButton_clicked(); +} + +void MainWindow::on_dxGridEntry_textChanged (QString const& grid) +{ + if (ui->dxGridEntry->hasAcceptableInput ()) { + if (grid != m_hisGrid) { + m_hisGrid = grid; + statusUpdate (); + } + qint64 nsec = (QDateTime::currentMSecsSinceEpoch()/1000) % 86400; + double utch=nsec/3600.0; + int nAz,nEl,nDmiles,nDkm,nHotAz,nHotABetter; + azdist_(const_cast <char *> ((m_config.my_grid () + " ").left (6).toLatin1().constData()), + const_cast <char *> ((m_hisGrid + " ").left (6).toLatin1().constData()),&utch, + &nAz,&nEl,&nDmiles,&nDkm,&nHotAz,&nHotABetter,6,6); + QString t; + int nd=nDkm; + if(m_config.miles()) nd=nDmiles; + if(m_mode=="MSK144") { + if(nHotABetter==0)t.sprintf("Az: %d B: %d El: %d %d",nAz,nHotAz,nEl,nd); + if(nHotABetter!=0)t.sprintf("Az: %d A: %d El: %d %d",nAz,nHotAz,nEl,nd); + } else { + t.sprintf("Az: %d %d",nAz,nd); + } + if(m_config.miles()) t += " mi"; + if(!m_config.miles()) t += " km"; + ui->labAz->setText (t); + } else { + if (m_hisGrid.size ()) { + m_hisGrid.clear (); + ui->labAz->clear (); + statusUpdate (); + } + } +} + +void MainWindow::on_genStdMsgsPushButton_clicked() //genStdMsgs button +{ + genStdMsgs(m_rpt); +} + +void MainWindow::on_logQSOButton_clicked() //Log QSO button +{ + if (!m_hisCall.size ()) { + MessageBox::warning_message (this, tr ("Warning: DX Call field is empty.")); + } + // m_dateTimeQSOOn should really already be set but we'll ensure it gets set to something just in case + if (!m_dateTimeQSOOn.isValid ()) { + m_dateTimeQSOOn = QDateTime::currentDateTimeUtc(); + } + auto dateTimeQSOOff = QDateTime::currentDateTimeUtc(); + if (dateTimeQSOOff < m_dateTimeQSOOn) dateTimeQSOOff = m_dateTimeQSOOn; + QString grid=m_hisGrid; + if(grid=="....") grid=""; + + switch( m_config.special_op_id() ) + { + case SpecOp::NA_VHF: + m_xSent=m_config.my_grid().left(4); + m_xRcvd=m_hisGrid; + break; + case SpecOp::EU_VHF: + m_rptSent=m_xSent.split(" ").at(0).left(2); + m_rptRcvd=m_xRcvd.split(" ").at(0).left(2); + m_hisGrid=m_xRcvd.split(" ").at(1); + grid=m_hisGrid; + ui->dxGridEntry->setText(grid); + break; + case SpecOp::FIELD_DAY: + m_rptSent=m_xSent.split(" ").at(0); + m_rptRcvd=m_xRcvd.split(" ").at(0); + break; + case SpecOp::RTTY: + m_rptSent=m_xSent.split(" ").at(0); + m_rptRcvd=m_xRcvd.split(" ").at(0); + break; + default: break; + } + + auto special_op = m_config.special_op_id (); + if (SpecOp::NONE < special_op && special_op < SpecOp::FOX) + { + if (!m_cabrilloLog) m_cabrilloLog.reset (new CabrilloLog {&m_config}); + } + m_logDlg->initLogQSO (m_hisCall, grid, m_modeTx, m_rptSent, m_rptRcvd, + m_dateTimeQSOOn, dateTimeQSOOff, m_freqNominal + + ui->TxFreqSpinBox->value(), m_noSuffix, m_xSent, m_xRcvd, + m_cabrilloLog.data ()); +} + +void MainWindow::acceptQSO (QDateTime const& QSO_date_off, QString const& call, QString const& grid + , Frequency dial_freq, QString const& mode + , QString const& rpt_sent, QString const& rpt_received + , QString const& tx_power, QString const& comments + , QString const& name, QDateTime const& QSO_date_on, QString const& operator_call + , QString const& my_call, QString const& my_grid + , QString const& exchange_sent, QString const& exchange_rcvd + , QByteArray const& ADIF) +{ + QString date = QSO_date_on.toString("yyyyMMdd"); + if (!m_logBook.add (m_hisCall, grid, m_config.bands()->find(m_freqNominal), m_modeTx, ADIF)) + { + MessageBox::warning_message (this, tr ("Log file error"), + tr ("Cannot open \"%1\"").arg (m_logBook.path ())); + } + + m_messageClient->qso_logged (QSO_date_off, call, grid, dial_freq, mode, rpt_sent, rpt_received + , tx_power, comments, name, QSO_date_on, operator_call, my_call, my_grid + , exchange_sent, exchange_rcvd); + m_messageClient->logged_ADIF (ADIF); + + // Log to N1MM Logger + if (m_config.broadcast_to_n1mm () && m_config.valid_n1mm_info ()) + { + QUdpSocket sock; + if (-1 == sock.writeDatagram (ADIF + " <eor>" + , QHostAddress {m_config.n1mm_server_name ()} + , m_config.n1mm_server_port ())) + { + MessageBox::warning_message (this, tr ("Error sending log to N1MM"), + tr ("Write returned \"%1\"").arg (sock.errorString ())); + } + } + + if (m_config.clear_DX () and SpecOp::HOUND != m_config.special_op_id()) clearDX (); + m_dateTimeQSOOn = QDateTime {}; + auto special_op = m_config.special_op_id (); + if (SpecOp::NONE < special_op && special_op < SpecOp::FOX) + { + ui->sbSerialNumber->setValue (ui->sbSerialNumber->value () + 1); + } + + m_xSent.clear (); + m_xRcvd.clear (); +} + +qint64 MainWindow::nWidgets(QString t) +{ + Q_ASSERT(t.length()==N_WIDGETS); + qint64 n=0; + for(int i=0; i<N_WIDGETS; i++) { + n=n + n + t.mid(i,1).toInt(); + } + return n; +} + +void MainWindow::displayWidgets(qint64 n) +{ + /* See text file "displayWidgets.txt" for widget numbers */ + qint64 j=qint64(1)<<(N_WIDGETS-1); + bool b; + for(int i=0; i<N_WIDGETS; i++) { + b=(n&j) != 0; + if(i==0) ui->txFirstCheckBox->setVisible(b); + if(i==1) ui->TxFreqSpinBox->setVisible(b); + if(i==2) ui->RxFreqSpinBox->setVisible(b); + if(i==3) ui->sbFtol->setVisible(b); + if(i==4) ui->rptSpinBox->setVisible(b); + if(i==5) ui->sbTR->setVisible(b); + if(i==6) { + ui->sbCQTxFreq->setVisible (b); + ui->cbCQTx->setVisible (b); + auto is_compound = m_config.my_callsign () != m_baseCall; + ui->cbCQTx->setEnabled (b && (!is_compound || shortList (m_config.my_callsign ()))); + } + if(i==7) ui->cbShMsgs->setVisible(b); + if(i==8) ui->cbFast9->setVisible(b); + if(i==9) ui->cbAutoSeq->setVisible(b); + if(i==10) ui->cbTx6->setVisible(b); + if(i==11) ui->pbTxMode->setVisible(b); + if(i==12) ui->pbR2T->setVisible(b); + if(i==13) ui->pbT2R->setVisible(b); + if(i==14) ui->cbHoldTxFreq->setVisible(b); + if(i==14 and (!b)) ui->cbHoldTxFreq->setChecked(false); + if(i==15) ui->sbSubmode->setVisible(b); + if(i==16) ui->syncSpinBox->setVisible(b); + if(i==17) ui->WSPR_controls_widget->setVisible(b); + if(i==18) ui->ClrAvgButton->setVisible(b); + if(i==19) ui->actionQuickDecode->setEnabled(b); + if(i==19) ui->actionMediumDecode->setEnabled(b); + if(i==19) ui->actionDeepestDecode->setEnabled(b); + if(i==20) ui->actionInclude_averaging->setVisible (b); + if(i==21) ui->actionInclude_correlation->setVisible (b); + if(i==22) { + if(!b && m_echoGraph->isVisible()) m_echoGraph->hide(); + } + if(i==23) ui->cbSWL->setVisible(b); + if(i==24) ui->actionEnable_AP_FT8->setVisible (b); + if(i==25) ui->actionEnable_AP_JT65->setVisible (b); + if(i==26) ui->actionEnable_AP_DXcall->setVisible (b); + if(i==27) ui->cbFirst->setVisible(b); + if(i==28) ui->labNextCall->setVisible(b); + if(i==29) ui->measure_check_box->setVisible(b); + if(i==30) ui->labDXped->setVisible(b); + if(i==31) ui->cbRxAll->setVisible(b); + if(i==32) ui->cbCQonly->setVisible(b); + j=j>>1; + } + b=SpecOp::EU_VHF==m_config.special_op_id() or (SpecOp::RTTY==m_config.special_op_id() and + (m_config.RTTY_Exchange()=="#" or m_config.RTTY_Exchange()=="DX")); + ui->sbSerialNumber->setVisible(b); + m_lastCallsign.clear (); // ensures Tx5 is updated for new modes + genStdMsgs (m_rpt, true); +} + +void MainWindow::on_actionFT8_triggered() +{ + m_mode="FT8"; + bool bVHF=m_config.enable_VHF_features(); + m_bFast9=false; + m_bFastMode=false; + WSPR_config(false); + switch_mode (Modes::FT8); + m_modeTx="FT8"; + m_nsps=6912; + m_FFTSize = m_nsps / 2; + Q_EMIT FFTSize (m_FFTSize); + m_hsymStop=50; + setup_status_bar (bVHF); + m_toneSpacing=0.0; //??? + ui->actionFT8->setChecked(true); //??? + m_wideGraph->setMode(m_mode); + m_wideGraph->setModeTx(m_modeTx); + VHF_features_enabled(bVHF); + ui->cbAutoSeq->setChecked(true); + m_TRperiod=15; + m_fastGraph->hide(); + m_wideGraph->show(); + ui->decodedTextLabel2->setText(" UTC dB DT Freq Message"); + m_wideGraph->setPeriod(m_TRperiod,m_nsps); + m_modulator->setTRPeriod(m_TRperiod); // TODO - not thread safe + m_detector->setTRPeriod(m_TRperiod); // TODO - not thread safe + ui->label_7->setText("Rx Frequency"); + if(SpecOp::FOX==m_config.special_op_id()) { + ui->label_6->setText("Stations calling DXpedition " + m_config.my_callsign()); + ui->decodedTextLabel->setText( "Call Grid dB Freq Dist Age Continent"); + } else { + ui->label_6->setText("Band Activity"); + ui->decodedTextLabel->setText( " UTC dB DT Freq Message"); + } + displayWidgets(nWidgets("111010000100111000010000100110001")); + ui->txrb2->setEnabled(true); + ui->txrb4->setEnabled(true); + ui->txrb5->setEnabled(true); + ui->txrb6->setEnabled(true); + ui->txb2->setEnabled(true); + ui->txb4->setEnabled(true); + ui->txb5->setEnabled(true); + ui->txb6->setEnabled(true); + ui->txFirstCheckBox->setEnabled(true); + ui->cbAutoSeq->setEnabled(true); + if(SpecOp::FOX==m_config.special_op_id()) { + ui->txFirstCheckBox->setChecked(true); + ui->txFirstCheckBox->setEnabled(false); + ui->cbHoldTxFreq->setChecked(true); + ui->cbAutoSeq->setEnabled(false); + ui->tabWidget->setCurrentIndex(2); + ui->TxFreqSpinBox->setValue(300); + displayWidgets(nWidgets("111010000100111000010000000000100")); + ui->labDXped->setText("Fox"); + on_fox_log_action_triggered(); + } + if(SpecOp::HOUND == m_config.special_op_id()) { + ui->txFirstCheckBox->setChecked(false); + ui->txFirstCheckBox->setEnabled(false); + ui->cbAutoSeq->setEnabled(false); + ui->tabWidget->setCurrentIndex(0); + ui->cbHoldTxFreq->setChecked(true); + displayWidgets(nWidgets("111010000100110000010000000000110")); + ui->labDXped->setText("Hound"); + ui->txrb1->setChecked(true); + ui->txrb2->setEnabled(false); + ui->txrb4->setEnabled(false); + ui->txrb5->setEnabled(false); + ui->txrb6->setEnabled(false); + ui->txb2->setEnabled(false); + ui->txb4->setEnabled(false); + ui->txb5->setEnabled(false); + ui->txb6->setEnabled(false); + } + + if (SpecOp::NONE < m_config.special_op_id () && SpecOp::FOX > m_config.special_op_id ()) { + QString t0=""; + if(SpecOp::NA_VHF==m_config.special_op_id()) t0+="NA VHF"; + if(SpecOp::EU_VHF==m_config.special_op_id()) t0+="EU VHF"; + if(SpecOp::FIELD_DAY==m_config.special_op_id()) t0+="Field Day"; + if(SpecOp::RTTY==m_config.special_op_id()) t0+="RTTY"; + if(t0=="") { + ui->labDXped->setVisible(false); + } else { + ui->labDXped->setVisible(true); + ui->labDXped->setText(t0); + } + on_contest_log_action_triggered(); + } + + if((SpecOp::FOX==m_config.special_op_id() or SpecOp::HOUND==m_config.special_op_id()) and !m_config.split_mode() and !m_bWarnedSplit) { + QString errorMsg; + MessageBox::critical_message (this, + "Operation in FT8 DXpedition mode normally requires\n" + " *Split* rig control (either *Rig* or *Fake It* on\n" + "the *Settings | Radio* tab.)", errorMsg); + m_bWarnedSplit=true; + } + statusChanged(); +} + + + +void MainWindow::on_actionJT4_triggered() +{ + m_mode="JT4"; + bool bVHF=m_config.enable_VHF_features(); + WSPR_config(false); + switch_mode (Modes::JT4); + m_modeTx="JT4"; + m_TRperiod=60; + m_modulator->setTRPeriod(m_TRperiod); // TODO - not thread safe + m_detector->setTRPeriod(m_TRperiod); // TODO - not thread safe + m_nsps=6912; //For symspec only + m_FFTSize = m_nsps / 2; + Q_EMIT FFTSize (m_FFTSize); + m_hsymStop=176; + if(m_config.decode_at_52s()) m_hsymStop=184; + m_toneSpacing=0.0; + ui->actionJT4->setChecked(true); + VHF_features_enabled(true); + m_wideGraph->setPeriod(m_TRperiod,m_nsps); + m_wideGraph->setMode(m_mode); + m_wideGraph->setModeTx(m_modeTx); + m_bFastMode=false; + m_bFast9=false; + setup_status_bar (bVHF); + ui->sbSubmode->setMaximum(6); + ui->label_6->setText("Single-Period Decodes"); + ui->label_7->setText("Average Decodes"); + ui->decodedTextLabel->setText("UTC dB DT Freq Message"); + ui->decodedTextLabel2->setText("UTC dB DT Freq Message"); + if(bVHF) { + ui->sbSubmode->setValue(m_nSubMode); + } else { + ui->sbSubmode->setValue(0); + } + if(bVHF) { + displayWidgets(nWidgets("111110010010111110111100000000000")); + } else { + displayWidgets(nWidgets("111010000000111000110000000000000")); + } + fast_config(false); + statusChanged(); +} + +void MainWindow::on_actionJT9_triggered() +{ + m_mode="JT9"; + bool bVHF=m_config.enable_VHF_features(); + m_bFast9=ui->cbFast9->isChecked(); + m_bFastMode=m_bFast9; + WSPR_config(false); + switch_mode (Modes::JT9); + m_modeTx="JT9"; + m_nsps=6912; + m_FFTSize = m_nsps / 2; + Q_EMIT FFTSize (m_FFTSize); + m_hsymStop=173; + if(m_config.decode_at_52s()) m_hsymStop=179; + setup_status_bar (bVHF); + m_toneSpacing=0.0; + ui->actionJT9->setChecked(true); + m_wideGraph->setMode(m_mode); + m_wideGraph->setModeTx(m_modeTx); + VHF_features_enabled(bVHF); + if(m_nSubMode>=4 and bVHF) { + ui->cbFast9->setEnabled(true); + } else { + ui->cbFast9->setEnabled(false); + ui->cbFast9->setChecked(false); + } + ui->sbSubmode->setMaximum(7); + if(m_bFast9) { + m_TRperiod = ui->sbTR->value (); + m_wideGraph->hide(); + m_fastGraph->show(); + ui->TxFreqSpinBox->setValue(700); + ui->RxFreqSpinBox->setValue(700); + ui->decodedTextLabel->setText("UTC dB T Freq Message"); + ui->decodedTextLabel2->setText("UTC dB T Freq Message"); + } else { + ui->cbAutoSeq->setChecked(false); + m_TRperiod=60; + ui->decodedTextLabel->setText("UTC dB DT Freq Message"); + ui->decodedTextLabel2->setText("UTC dB DT Freq Message"); + } + m_wideGraph->setPeriod(m_TRperiod,m_nsps); + m_modulator->setTRPeriod(m_TRperiod); // TODO - not thread safe + m_detector->setTRPeriod(m_TRperiod); // TODO - not thread safe + ui->label_6->setText("Band Activity"); + ui->label_7->setText("Rx Frequency"); + if(bVHF) { + displayWidgets(nWidgets("111110101000111110010000000000000")); + } else { + displayWidgets(nWidgets("111010000000111000010000000000001")); + } + fast_config(m_bFastMode); + ui->cbAutoSeq->setVisible(m_bFast9); + statusChanged(); +} + +void MainWindow::on_actionJT9_JT65_triggered() +{ + m_mode="JT9+JT65"; + WSPR_config(false); + switch_mode (Modes::JT65); + if(m_modeTx != "JT65") { + ui->pbTxMode->setText("Tx JT9 @"); + m_modeTx="JT9"; + } + m_nSubMode=0; //Dual-mode always means JT9 and JT65A + m_TRperiod=60; + m_modulator->setTRPeriod(m_TRperiod); // TODO - not thread safe + m_detector->setTRPeriod(m_TRperiod); // TODO - not thread safe + m_nsps=6912; + m_FFTSize = m_nsps / 2; + Q_EMIT FFTSize (m_FFTSize); + m_hsymStop=174; + if(m_config.decode_at_52s()) m_hsymStop=183; + m_toneSpacing=0.0; + setup_status_bar (false); + ui->actionJT9_JT65->setChecked(true); + VHF_features_enabled(false); + m_wideGraph->setPeriod(m_TRperiod,m_nsps); + m_wideGraph->setMode(m_mode); + m_wideGraph->setModeTx(m_modeTx); + m_bFastMode=false; + m_bFast9=false; + ui->sbSubmode->setValue(0); + ui->label_6->setText("Band Activity"); + ui->label_7->setText("Rx Frequency"); + ui->decodedTextLabel->setText("UTC dB DT Freq Message"); + ui->decodedTextLabel2->setText("UTC dB DT Freq Message"); + displayWidgets(nWidgets("111010000001111000010000000000001")); + fast_config(false); + statusChanged(); +} + +void MainWindow::on_actionJT65_triggered() +{ + if(m_mode=="JT4" or m_mode.startsWith ("WSPR")) { +// If coming from JT4 or WSPR mode, pretend temporarily that we're coming +// from JT9 and click the pbTxMode button + m_modeTx="JT9"; + on_pbTxMode_clicked(); + } + on_actionJT9_triggered(); + m_mode="JT65"; + m_modeTx="JT65"; + bool bVHF=m_config.enable_VHF_features(); + WSPR_config(false); + switch_mode (Modes::JT65); + if(m_modeTx!="JT65") on_pbTxMode_clicked(); + m_TRperiod=60; + m_modulator->setTRPeriod(m_TRperiod); // TODO - not thread safe + m_detector->setTRPeriod(m_TRperiod); // TODO - not thread safe + m_nsps=6912; //For symspec only + m_FFTSize = m_nsps / 2; + Q_EMIT FFTSize (m_FFTSize); + m_hsymStop=174; + if(m_config.decode_at_52s()) m_hsymStop=183; + m_toneSpacing=0.0; + ui->actionJT65->setChecked(true); + VHF_features_enabled(bVHF); + m_wideGraph->setPeriod(m_TRperiod,m_nsps); + m_wideGraph->setMode(m_mode); + m_wideGraph->setModeTx(m_modeTx); + setup_status_bar (bVHF); + m_bFastMode=false; + m_bFast9=false; + ui->sbSubmode->setMaximum(2); + if(bVHF) { + ui->sbSubmode->setValue(m_nSubMode); + ui->label_6->setText("Single-Period Decodes"); + ui->label_7->setText("Average Decodes"); + } else { + ui->sbSubmode->setValue(0); + ui->label_6->setText("Band Activity"); + ui->label_7->setText("Rx Frequency"); + } + if(bVHF) { + displayWidgets(nWidgets("111110010000111110101100010000000")); + } else { + displayWidgets(nWidgets("111010000000111000010000000000001")); + } + fast_config(false); + if(ui->cbShMsgs->isChecked()) { + ui->cbAutoSeq->setChecked(false); + ui->cbAutoSeq->setVisible(false); + } + statusChanged(); +} + +void MainWindow::on_actionQRA64_triggered() +{ + int n=m_nSubMode; + on_actionJT65_triggered(); + m_nSubMode=n; + m_mode="QRA64"; + m_modeTx="QRA64"; + ui->actionQRA64->setChecked(true); + switch_mode (Modes::QRA64); + setup_status_bar (true); + m_hsymStop=180; + if(m_config.decode_at_52s()) m_hsymStop=188; + m_wideGraph->setMode(m_mode); + m_wideGraph->setModeTx(m_modeTx); + ui->sbSubmode->setMaximum(4); + ui->sbSubmode->setValue(m_nSubMode); + ui->actionInclude_averaging->setVisible (false); + ui->actionInclude_correlation->setVisible (false); + QString fname {QDir::toNativeSeparators(m_config.temp_dir ().absoluteFilePath ("red.dat"))}; + m_wideGraph->setRedFile(fname); + displayWidgets(nWidgets("111110010010111110000000001000000")); + statusChanged(); +} + +void MainWindow::on_actionISCAT_triggered() +{ + m_mode="ISCAT"; + m_modeTx="ISCAT"; + ui->actionISCAT->setChecked(true); + m_TRperiod = ui->sbTR->value (); + m_modulator->setTRPeriod(m_TRperiod); + m_detector->setTRPeriod(m_TRperiod); + m_wideGraph->setPeriod(m_TRperiod,m_nsps); + m_nsps=6912; //For symspec only + m_FFTSize = m_nsps / 2; + Q_EMIT FFTSize (m_FFTSize); + m_hsymStop=103; + m_toneSpacing=11025.0/256.0; + WSPR_config(false); + switch_mode(Modes::ISCAT); + m_wideGraph->setMode(m_mode); + m_wideGraph->setModeTx(m_modeTx); + statusChanged(); + if(!m_fastGraph->isVisible()) m_fastGraph->show(); + if(m_wideGraph->isVisible()) m_wideGraph->hide(); + setup_status_bar (true); + ui->cbShMsgs->setChecked(false); + ui->label_7->setText(""); + ui->decodedTextBrowser2->setVisible(false); + ui->decodedTextLabel2->setVisible(false); + ui->decodedTextLabel->setText( + " UTC Sync dB DT DF F1 M N C T "); + ui->tabWidget->setCurrentIndex(0); + ui->sbSubmode->setMaximum(1); + if(m_nSubMode==0) ui->TxFreqSpinBox->setValue(1012); + if(m_nSubMode==1) ui->TxFreqSpinBox->setValue(560); + displayWidgets(nWidgets("100111000000000110000000000000000")); + fast_config(true); + statusChanged (); +} + +void MainWindow::on_actionMSK144_triggered() +{ + if(SpecOp::EU_VHF < m_config.special_op_id()) { +// We are rejecting the requested mode change, so re-check the old mode + if("FT8"==m_mode) ui->actionFT8->setChecked(true); + if("JT4"==m_mode) ui->actionJT4->setChecked(true); + if("JT9"==m_mode) ui->actionJT9->setChecked(true); + if("JT65"==m_mode) ui->actionJT65->setChecked(true); + if("JT9_JT65"==m_mode) ui->actionJT9_JT65->setChecked(true); + if("ISCAT"==m_mode) ui->actionISCAT->setChecked(true); + if("QRA64"==m_mode) ui->actionQRA64->setChecked(true); + if("WSPR"==m_mode) ui->actionWSPR->setChecked(true); + if("Echo"==m_mode) ui->actionEcho->setChecked(true); + if("FreqCal"==m_mode) ui->actionFreqCal->setChecked(true); +// Make sure that MSK144 is not checked. + ui->actionMSK144->setChecked(false); + MessageBox::warning_message (this, tr ("Improper mode"), + "MSK144 not available if Fox, Hound, Field Day, or RTTY contest is selected."); + return; + } + m_mode="MSK144"; + m_modeTx="MSK144"; + ui->actionMSK144->setChecked(true); + switch_mode (Modes::MSK144); + m_nsps=6; + m_FFTSize = 7 * 512; + Q_EMIT FFTSize (m_FFTSize); + setup_status_bar (true); + m_toneSpacing=0.0; + WSPR_config(false); + VHF_features_enabled(true); + m_bFastMode=true; + m_bFast9=false; + m_TRperiod = ui->sbTR->value (); + m_wideGraph->hide(); + m_fastGraph->show(); + ui->TxFreqSpinBox->setValue(1500); + ui->RxFreqSpinBox->setValue(1500); + ui->RxFreqSpinBox->setMinimum(1400); + ui->RxFreqSpinBox->setMaximum(1600); + ui->RxFreqSpinBox->setSingleStep(10); + ui->decodedTextLabel->setText("UTC dB T Freq Message"); + ui->decodedTextLabel2->setText("UTC dB T Freq Message"); + m_modulator->setTRPeriod(m_TRperiod); // TODO - not thread safe + m_detector->setTRPeriod(m_TRperiod); // TODO - not thread safe + m_fastGraph->setTRPeriod(m_TRperiod); + ui->label_6->setText("Band Activity"); + ui->label_7->setText("Tx Messages"); + ui->actionMSK144->setChecked(true); + ui->rptSpinBox->setMinimum(-8); + ui->rptSpinBox->setMaximum(24); + ui->rptSpinBox->setValue(0); + ui->rptSpinBox->setSingleStep(1); + ui->sbFtol->values ({20, 50, 100, 200}); + displayWidgets(nWidgets("101111110100000000010001000010000")); + fast_config(m_bFastMode); + statusChanged(); + + QString t0=""; + if(SpecOp::NA_VHF==m_config.special_op_id()) t0+="NA VHF"; + if(SpecOp::EU_VHF==m_config.special_op_id()) t0+="EU VHF"; + if(t0=="") { + ui->labDXped->setVisible(false); + } else { + ui->labDXped->setVisible(true); + ui->labDXped->setText(t0); + } +} + +void MainWindow::on_actionWSPR_triggered() +{ + m_mode="WSPR"; + WSPR_config(true); + switch_mode (Modes::WSPR); + m_modeTx="WSPR"; + m_TRperiod=120; + m_modulator->setTRPeriod(m_TRperiod); // TODO - not thread safe + m_detector->setTRPeriod(m_TRperiod); // TODO - not thread safe + m_nsps=6912; //For symspec only + m_FFTSize = m_nsps / 2; + Q_EMIT FFTSize (m_FFTSize); + m_hsymStop=396; + m_toneSpacing=12000.0/8192.0; + setup_status_bar (false); + ui->actionWSPR->setChecked(true); + VHF_features_enabled(false); + m_wideGraph->setPeriod(m_TRperiod,m_nsps); + m_wideGraph->setMode(m_mode); + m_wideGraph->setModeTx(m_modeTx); + m_bFastMode=false; + m_bFast9=false; + ui->TxFreqSpinBox->setValue(ui->WSPRfreqSpinBox->value()); + displayWidgets(nWidgets("000000000000000001010000000000000")); + fast_config(false); + statusChanged(); +} + +void MainWindow::on_actionWSPR_LF_triggered() +{ + on_actionWSPR_triggered(); + m_mode="WSPR-LF"; + switch_mode (Modes::WSPR); + m_modeTx="WSPR-LF"; + m_TRperiod=240; + m_modulator->setTRPeriod(m_TRperiod); // TODO - not thread safe + m_detector->setTRPeriod(m_TRperiod); // TODO - not thread safe + m_hsymStop=813; + m_toneSpacing=12000.0/24576.0; + setup_status_bar (false); + ui->actionWSPR_LF->setChecked(true); + m_wideGraph->setPeriod(m_TRperiod,m_nsps); + statusChanged(); +} + +void MainWindow::on_actionEcho_triggered() +{ + on_actionJT4_triggered(); + m_mode="Echo"; + ui->actionEcho->setChecked(true); + m_TRperiod=3; + m_modulator->setTRPeriod(m_TRperiod); // TODO - not thread safe + m_detector->setTRPeriod(m_TRperiod); // TODO - not thread safe + m_nsps=6912; //For symspec only + m_FFTSize = m_nsps / 2; + Q_EMIT FFTSize (m_FFTSize); + m_hsymStop=9; + m_toneSpacing=1.0; + switch_mode(Modes::Echo); + m_modeTx="Echo"; + setup_status_bar (true); + m_wideGraph->setMode(m_mode); + m_wideGraph->setModeTx(m_modeTx); + ui->TxFreqSpinBox->setValue(1500); + ui->TxFreqSpinBox->setEnabled (false); + if(!m_echoGraph->isVisible()) m_echoGraph->show(); + if (!ui->actionAstronomical_data->isChecked ()) { + ui->actionAstronomical_data->setChecked (true); + } + m_bFastMode=false; + m_bFast9=false; + WSPR_config(true); + ui->decodedTextLabel->setText(" UTC N Level Sig DF Width Q"); + displayWidgets(nWidgets("000000000000000000000010000000000")); + fast_config(false); + statusChanged(); +} + +void MainWindow::on_actionFreqCal_triggered() +{ + on_actionJT9_triggered(); + m_mode="FreqCal"; + ui->actionFreqCal->setChecked(true); + switch_mode(Modes::FreqCal); + m_wideGraph->setMode(m_mode); + m_TRperiod = ui->sbTR->value (); + m_modulator->setTRPeriod(m_TRperiod); // TODO - not thread safe + m_detector->setTRPeriod(m_TRperiod); // TODO - not thread safe + m_nsps=6912; //For symspec only + m_FFTSize = m_nsps / 2; + Q_EMIT FFTSize (m_FFTSize); + m_hsymStop=((int(m_TRperiod/0.288))/8)*8; + m_frequency_list_fcal_iter = m_config.frequencies ()->begin (); + ui->RxFreqSpinBox->setValue(1500); + setup_status_bar (true); +// 18:15:47 0 1 1500 1550.349 0.100 3.5 10.2 + ui->decodedTextLabel->setText(" UTC Freq CAL Offset fMeas DF Level S/N"); + ui->measure_check_box->setChecked (false); + displayWidgets(nWidgets("001101000000000000000000000001000")); + statusChanged(); +} + +void MainWindow::switch_mode (Mode mode) +{ + m_fastGraph->setMode(m_mode); + m_config.frequencies ()->filter (m_config.region (), mode); + auto const& row = m_config.frequencies ()->best_working_frequency (m_freqNominal); + if (row >= 0) { + ui->bandComboBox->setCurrentIndex (row); + on_bandComboBox_activated (row); + } + ui->rptSpinBox->setSingleStep(1); + ui->rptSpinBox->setMinimum(-50); + ui->rptSpinBox->setMaximum(49); + ui->sbFtol->values ({10, 20, 50, 100, 200, 500, 1000}); + if(m_mode=="MSK144") { + ui->RxFreqSpinBox->setMinimum(1400); + ui->RxFreqSpinBox->setMaximum(1600); + ui->RxFreqSpinBox->setSingleStep(25); + } else { + ui->RxFreqSpinBox->setMinimum(200); + ui->RxFreqSpinBox->setMaximum(5000); + ui->RxFreqSpinBox->setSingleStep(1); + } + m_bVHFwarned=false; + bool b=m_mode=="FreqCal"; + ui->tabWidget->setVisible(!b); + if(b) { + ui->DX_controls_widget->setVisible(false); + ui->decodedTextBrowser2->setVisible(false); + ui->decodedTextLabel2->setVisible(false); + ui->label_6->setVisible(false); + ui->label_7->setVisible(false); + } +} + +void MainWindow::WSPR_config(bool b) +{ + ui->decodedTextBrowser2->setVisible(!b); + ui->decodedTextLabel2->setVisible(!b and ui->cbMenus->isChecked()); + ui->controls_stack_widget->setCurrentIndex (b && m_mode != "Echo" ? 1 : 0); + ui->QSO_controls_widget->setVisible (!b); + ui->DX_controls_widget->setVisible (!b); + ui->WSPR_controls_widget->setVisible (b); + ui->label_6->setVisible(!b and ui->cbMenus->isChecked()); + ui->label_7->setVisible(!b and ui->cbMenus->isChecked()); + ui->logQSOButton->setVisible(!b); + ui->DecodeButton->setEnabled(!b); + if(b and (m_mode!="Echo")) { + QString t="UTC dB DT Freq Drift Call Grid dBm "; + if(m_config.miles()) t += " mi"; + if(!m_config.miles()) t += " km"; + ui->decodedTextLabel->setText(t); + if (m_config.is_transceiver_online ()) { + Q_EMIT m_config.transceiver_tx_frequency (0); // turn off split + } + m_bSimplex = true; + } else { + ui->decodedTextLabel->setText("UTC dB DT Freq Message"); + m_bSimplex = false; + } + enable_DXCC_entity (m_config.DXCC ()); // sets text window proportions and (re)inits the logbook +} + +void MainWindow::fast_config(bool b) +{ + m_bFastMode=b; + ui->TxFreqSpinBox->setEnabled(!b); + ui->sbTR->setVisible(b); + if(b and (m_bFast9 or m_mode=="MSK144" or m_mode=="ISCAT")) { + m_wideGraph->hide(); + m_fastGraph->show(); + } else { + m_wideGraph->show(); + m_fastGraph->hide(); + } +} + +void MainWindow::on_TxFreqSpinBox_valueChanged(int n) +{ + m_wideGraph->setTxFreq(n); +// if (ui->cbHoldTxFreq->isChecked ()) ui->RxFreqSpinBox->setValue(n); + if(m_mode!="MSK144") { + Q_EMIT transmitFrequency (n - m_XIT); + } + statusUpdate (); +} + +void MainWindow::on_RxFreqSpinBox_valueChanged(int n) +{ + m_wideGraph->setRxFreq(n); + if (m_mode == "FreqCal") { + setRig (); + } + statusUpdate (); +} + +void MainWindow::on_actionQuickDecode_toggled (bool checked) +{ + m_ndepth ^= (-checked ^ m_ndepth) & 0x00000001; +} + +void MainWindow::on_actionMediumDecode_toggled (bool checked) +{ + m_ndepth ^= (-checked ^ m_ndepth) & 0x00000002; +} + +void MainWindow::on_actionDeepestDecode_toggled (bool checked) +{ + m_ndepth ^= (-checked ^ m_ndepth) & 0x00000003; +} + +void MainWindow::on_actionInclude_averaging_toggled (bool checked) +{ + m_ndepth ^= (-checked ^ m_ndepth) & 0x00000010; +} + +void MainWindow::on_actionInclude_correlation_toggled (bool checked) +{ + m_ndepth ^= (-checked ^ m_ndepth) & 0x00000020; +} + +void MainWindow::on_actionEnable_AP_DXcall_toggled (bool checked) +{ + m_ndepth ^= (-checked ^ m_ndepth) & 0x00000040; +} + +void MainWindow::on_actionErase_ALL_TXT_triggered() //Erase ALL.TXT +{ + int ret = MessageBox::query_message (this, tr ("Confirm Erase"), + tr ("Are you sure you want to erase file ALL.TXT?")); + if(ret==MessageBox::Yes) { + QFile f {m_config.writeable_data_dir ().absoluteFilePath ("ALL.TXT")}; + f.remove(); + m_RxLog=1; + } +} + +void MainWindow::on_reset_cabrillo_log_action_triggered () +{ + if (MessageBox::Yes == MessageBox::query_message (this, tr ("Confirm Reset"), + tr ("Are you sure you want to erase your contest log?"), + tr ("Doing this will remove all QSO records for the current contest. " + "They will be kept in the ADIF log file but will not be available " + "for export in your Cabrillo log."))) + { + ui->sbSerialNumber->setValue (1); + if (!m_cabrilloLog) m_cabrilloLog.reset (new CabrilloLog {&m_config}); + m_cabrilloLog->reset (); + } +} + +void MainWindow::on_actionExport_Cabrillo_log_triggered() +{ + if (!m_cabrilloLog) m_cabrilloLog.reset (new CabrilloLog {&m_config}); + if (QDialog::Accepted == ExportCabrillo {m_settings, &m_config, m_cabrilloLog.data ()}.exec()) + { + MessageBox::information_message (this, tr ("Cabrillo Log saved")); + } +} + + +void MainWindow::on_actionErase_wsjtx_log_adi_triggered() +{ + int ret = MessageBox::query_message (this, tr ("Confirm Erase"), + tr ("Are you sure you want to erase file wsjtx_log.adi?")); + if(ret==MessageBox::Yes) { + QFile f {m_config.writeable_data_dir ().absoluteFilePath ("wsjtx_log.adi")}; + f.remove(); + } +} + +void MainWindow::on_actionOpen_log_directory_triggered () +{ + QDesktopServices::openUrl (QUrl::fromLocalFile (m_config.writeable_data_dir ().absolutePath ())); +} + +void MainWindow::on_bandComboBox_currentIndexChanged (int index) +{ + auto const& frequencies = m_config.frequencies (); + auto const& source_index = frequencies->mapToSource (frequencies->index (index, FrequencyList_v2::frequency_column)); + Frequency frequency {m_freqNominal}; + if (source_index.isValid ()) + { + frequency = frequencies->frequency_list ()[source_index.row ()].frequency_; + } + + // Lookup band + auto const& band = m_config.bands ()->find (frequency); + if (!band.isEmpty ()) + { + ui->bandComboBox->lineEdit ()->setStyleSheet ({}); + ui->bandComboBox->setCurrentText (band); + } + else + { + ui->bandComboBox->lineEdit ()->setStyleSheet ("QLineEdit {color: yellow; background-color : red;}"); + ui->bandComboBox->setCurrentText (m_config.bands ()->oob ()); + } + displayDialFrequency (); +} + +void MainWindow::on_bandComboBox_activated (int index) +{ + auto const& frequencies = m_config.frequencies (); + auto const& source_index = frequencies->mapToSource (frequencies->index (index, FrequencyList_v2::frequency_column)); + Frequency frequency {m_freqNominal}; + if (source_index.isValid ()) + { + frequency = frequencies->frequency_list ()[source_index.row ()].frequency_; + } + m_bandEdited = true; + band_changed (frequency); + m_wideGraph->setRxBand (m_config.bands ()->find (frequency)); +} + +void MainWindow::band_changed (Frequency f) +{ +// bool monitor_off=!m_monitoring; + // Set the attenuation value if options are checked + QString curBand = ui->bandComboBox->currentText(); + if (m_config.pwrBandTxMemory() && !m_tune) { + if (m_pwrBandTxMemory.contains(curBand)) { + ui->outAttenuation->setValue(m_pwrBandTxMemory[curBand].toInt()); + } + else { + m_pwrBandTxMemory[curBand] = ui->outAttenuation->value(); + } + } + + if (m_bandEdited) { + if (!m_mode.startsWith ("WSPR")) { // band hopping preserves auto Tx + if (f + m_wideGraph->nStartFreq () > m_freqNominal + ui->TxFreqSpinBox->value () + || f + m_wideGraph->nStartFreq () + m_wideGraph->fSpan () <= + m_freqNominal + ui->TxFreqSpinBox->value ()) { +// qDebug () << "start f:" << m_wideGraph->nStartFreq () << "span:" << m_wideGraph->fSpan () << "DF:" << ui->TxFreqSpinBox->value (); + // disable auto Tx if "blind" QSY outside of waterfall + ui->stopTxButton->click (); // halt any transmission + auto_tx_mode (false); // disable auto Tx +// m_send_RR73 = false; // force user to reassess on new band + } + } + m_lastBand.clear (); + m_bandEdited = false; + psk_Reporter->sendReport(); // Upload any queued spots before changing band + if (!m_transmitting) monitor (true); + if ("FreqCal" == m_mode) + { + m_frequency_list_fcal_iter = m_config.frequencies ()->find (f); + } + float r=m_freqNominal/(f+0.0001); + if(r<0.9 or r>1.1) m_bVHFwarned=false; + setRig (f); + setXIT (ui->TxFreqSpinBox->value ()); +// if(monitor_off) monitor(false); + } +} + +void MainWindow::vhfWarning() +{ + MessageBox::warning_message (this, tr ("VHF features warning"), + "VHF/UHF/Microwave features is enabled on a lower frequency band."); + m_bVHFwarned=true; +} + +void MainWindow::enable_DXCC_entity (bool on) +{ + if (on and !m_mode.startsWith ("WSPR") and m_mode!="Echo") { + //m_logBook.init(); // re-read the log and cty.dat files +// ui->gridLayout->setColumnStretch(0,55); // adjust proportions of text displays +// ui->gridLayout->setColumnStretch(1,45); + } else { +// ui->gridLayout->setColumnStretch(0,0); +// ui->gridLayout->setColumnStretch(1,0); + } + updateGeometry (); +} + +void MainWindow::on_pbCallCQ_clicked() +{ + genStdMsgs(m_rpt); + ui->genMsg->setText(ui->tx6->text()); + m_ntx=7; + m_QSOProgress = CALLING; + m_gen_message_is_cq = true; + ui->rbGenMsg->setChecked(true); + if(m_transmitting) m_restart=true; + set_dateTimeQSO(-1); +} + +void MainWindow::on_pbAnswerCaller_clicked() +{ + genStdMsgs(m_rpt); + QString t=ui->tx3->text(); + int i0=t.indexOf(" R-"); + if(i0<0) i0=t.indexOf(" R+"); + t=t.mid(0,i0+1)+t.mid(i0+2,3); + ui->genMsg->setText(t); + m_ntx=7; + m_QSOProgress = REPORT; + m_gen_message_is_cq = false; + ui->rbGenMsg->setChecked(true); + if(m_transmitting) m_restart=true; + set_dateTimeQSO(2); +} + +void MainWindow::on_pbSendRRR_clicked() +{ + genStdMsgs(m_rpt); + ui->genMsg->setText(ui->tx4->text()); + m_ntx=7; + m_QSOProgress = ROGERS; + m_gen_message_is_cq = false; + ui->rbGenMsg->setChecked(true); + if(m_transmitting) m_restart=true; +} + +void MainWindow::on_pbAnswerCQ_clicked() +{ + genStdMsgs(m_rpt); + ui->genMsg->setText(ui->tx1->text()); + QString t=ui->tx2->text(); + int i0=t.indexOf("/"); + int i1=t.indexOf(" "); + if(i0>0 and i0<i1) ui->genMsg->setText(t); + m_ntx=7; + m_QSOProgress = REPLYING; + m_gen_message_is_cq = false; + ui->rbGenMsg->setChecked(true); + if(m_transmitting) m_restart=true; +} + +void MainWindow::on_pbSendReport_clicked() +{ + genStdMsgs(m_rpt); + ui->genMsg->setText(ui->tx3->text()); + m_ntx=7; + m_QSOProgress = ROGER_REPORT; + m_gen_message_is_cq = false; + ui->rbGenMsg->setChecked(true); + if(m_transmitting) m_restart=true; + set_dateTimeQSO(3); +} + +void MainWindow::on_pbSend73_clicked() +{ + genStdMsgs(m_rpt); + ui->genMsg->setText(ui->tx5->currentText()); + m_ntx=7; + m_QSOProgress = SIGNOFF; + m_gen_message_is_cq = false; + ui->rbGenMsg->setChecked(true); + if(m_transmitting) m_restart=true; +} + +void MainWindow::on_rbGenMsg_clicked(bool checked) +{ + m_freeText=!checked; + if(!m_freeText) { + if(m_ntx != 7 && m_transmitting) m_restart=true; + m_ntx=7; + // would like to set m_QSOProgress but what to? So leave alone and + // assume it is correct + } +} + +void MainWindow::on_rbFreeText_clicked(bool checked) +{ + m_freeText=checked; + if(m_freeText) { + m_ntx=8; + // would like to set m_QSOProgress but what to? So leave alone and + // assume it is correct. Perhaps should store old value to be + // restored above in on_rbGenMsg_clicked + if (m_transmitting) m_restart=true; + } +} + +void MainWindow::on_freeTextMsg_currentTextChanged (QString const& text) +{ + msgtype(text, ui->freeTextMsg->lineEdit ()); +} + +void MainWindow::on_rptSpinBox_valueChanged(int n) +{ + int step=ui->rptSpinBox->singleStep(); + if(n%step !=0) { + n++; + ui->rptSpinBox->setValue(n); + } + m_rpt=QString::number(n); + int ntx0=m_ntx; + genStdMsgs(m_rpt); + m_ntx=ntx0; + if(m_ntx==1) ui->txrb1->setChecked(true); + if(m_ntx==2) ui->txrb2->setChecked(true); + if(m_ntx==3) ui->txrb3->setChecked(true); + if(m_ntx==4) ui->txrb4->setChecked(true); + if(m_ntx==5) ui->txrb5->setChecked(true); + if(m_ntx==6) ui->txrb6->setChecked(true); + statusChanged(); +} + +void MainWindow::on_tuneButton_clicked (bool checked) +{ + static bool lastChecked = false; + if (lastChecked == checked) return; + lastChecked = checked; + QString curBand = ui->bandComboBox->currentText(); + if (checked && m_tune==false) { // we're starting tuning so remember Tx and change pwr to Tune value + if (m_config.pwrBandTuneMemory ()) { + m_pwrBandTxMemory[curBand] = ui->outAttenuation->value(); // remember our Tx pwr + m_PwrBandSetOK = false; + if (m_pwrBandTuneMemory.contains(curBand)) { + ui->outAttenuation->setValue(m_pwrBandTuneMemory[curBand].toInt()); // set to Tune pwr + } + m_PwrBandSetOK = true; + } + } + else { // we're turning off so remember our Tune pwr setting and reset to Tx pwr + if (m_config.pwrBandTuneMemory() || m_config.pwrBandTxMemory()) { + stopTx(); + m_pwrBandTuneMemory[curBand] = ui->outAttenuation->value(); // remember our Tune pwr + m_PwrBandSetOK = false; + ui->outAttenuation->setValue(m_pwrBandTxMemory[curBand].toInt()); // set to Tx pwr + m_PwrBandSetOK = true; + } + } + if (m_tune) { + tuneButtonTimer.start(250); + } else { + m_sentFirst73=false; + itone[0]=0; + on_monitorButton_clicked (true); + m_tune=true; + } + Q_EMIT tune (checked); +} + +void MainWindow::stop_tuning () +{ + on_tuneButton_clicked(false); + ui->tuneButton->setChecked (false); + m_bTxTime=false; + m_tune=false; +} + +void MainWindow::stopTuneATU() +{ + on_tuneButton_clicked(false); + m_bTxTime=false; +} + +void MainWindow::on_stopTxButton_clicked() //Stop Tx +{ + if (m_tune) stop_tuning (); + if (m_auto and !m_tuneup) auto_tx_mode (false); + m_btxok=false; + m_bCallingCQ = false; + m_bAutoReply = false; // ready for next + ui->cbFirst->setStyleSheet (""); +} + +void MainWindow::rigOpen () +{ + update_dynamic_property (ui->readFreq, "state", "warning"); + ui->readFreq->setText (""); + ui->readFreq->setEnabled (true); + m_config.transceiver_online (); + Q_EMIT m_config.sync_transceiver (true, true); +} + +void MainWindow::on_pbR2T_clicked() +{ + ui->TxFreqSpinBox->setValue(ui->RxFreqSpinBox->value ()); +} + +void MainWindow::on_pbT2R_clicked() +{ + if (ui->RxFreqSpinBox->isEnabled ()) + { + ui->RxFreqSpinBox->setValue (ui->TxFreqSpinBox->value ()); + } +} + + +void MainWindow::on_readFreq_clicked() +{ + if (m_transmitting) return; + + if (m_config.transceiver_online ()) + { + Q_EMIT m_config.sync_transceiver (true, true); + } +} + +void MainWindow::on_pbTxMode_clicked() +{ + if(m_mode=="JT9+JT65") { + if(m_modeTx=="JT9") { + m_modeTx="JT65"; + ui->pbTxMode->setText("Tx JT65 #"); + } else { + m_modeTx="JT9"; + ui->pbTxMode->setText("Tx JT9 @"); + } + m_wideGraph->setModeTx(m_modeTx); + statusChanged(); + } +} + +void MainWindow::setXIT(int n, Frequency base) +{ + if (m_transmitting && !m_config.tx_QSY_allowed ()) return; + // If "CQ nnn ..." feature is active, set the proper Tx frequency + if(m_config.split_mode () && ui->cbCQTx->isEnabled () && ui->cbCQTx->isVisible () && + ui->cbCQTx->isChecked()) + { + if (6 == m_ntx || (7 == m_ntx && m_gen_message_is_cq)) + { + // All conditions are met, use calling frequency + base = m_freqNominal / 1000000 * 1000000 + 1000 * ui->sbCQTxFreq->value () + m_XIT; + } + } + if (!base) base = m_freqNominal; + m_XIT = 0; + if (!m_bSimplex) { + // m_bSimplex is false, so we can use split mode if requested + if (m_config.split_mode () && (!m_config.enable_VHF_features () || m_mode == "FT8")) { + // Don't use XIT for VHF & up + m_XIT=(n/500)*500 - 1500; + } + + if ((m_monitoring || m_transmitting) + && m_config.is_transceiver_online () + && m_config.split_mode ()) + { + // All conditions are met, reset the transceiver Tx dial + // frequency + m_freqTxNominal = base + m_XIT; + if (m_astroWidget) m_astroWidget->nominal_frequency (m_freqNominal, m_freqTxNominal); + Q_EMIT m_config.transceiver_tx_frequency (m_freqTxNominal + m_astroCorrection.tx); + } + } + //Now set the audio Tx freq + Q_EMIT transmitFrequency (ui->TxFreqSpinBox->value () - m_XIT); +} + +void MainWindow::setFreq4(int rxFreq, int txFreq) +{ + if (ui->RxFreqSpinBox->isEnabled ()) ui->RxFreqSpinBox->setValue(rxFreq); + if(m_mode.startsWith ("WSPR")) { + ui->WSPRfreqSpinBox->setValue(txFreq); + } else { + if (ui->TxFreqSpinBox->isEnabled ()) { + ui->TxFreqSpinBox->setValue(txFreq); + } + else if (m_config.enable_VHF_features () + && (Qt::ControlModifier & QApplication::keyboardModifiers ())) { + // for VHF & up we adjust Tx dial frequency to equalize Tx to Rx + // when user CTRL+clicks on waterfall + auto temp = ui->TxFreqSpinBox->value (); + ui->RxFreqSpinBox->setValue (temp); + setRig (m_freqNominal + txFreq - temp); + setXIT (ui->TxFreqSpinBox->value ()); + } + } +} + +void MainWindow::handle_transceiver_update (Transceiver::TransceiverState const& s) +{ + // qDebug () << "MainWindow::handle_transceiver_update:" << s; + Transceiver::TransceiverState old_state {m_rigState}; + //transmitDisplay (s.ptt ()); + if (s.ptt () && !m_rigState.ptt ()) // safe to start audio + // (caveat - DX Lab Suite Commander) + { + if (m_tx_when_ready && g_iptt) // waiting to Tx and still needed + { + ptt1Timer.start(1000 * m_config.txDelay ()); //Start-of-transmission sequencer delay + } + m_tx_when_ready = false; + } + m_rigState = s; + auto old_freqNominal = m_freqNominal; + if (!old_freqNominal) + { + // always take initial rig frequency to avoid start up problems + // with bogus Tx frequencies + m_freqNominal = s.frequency (); + } + if (old_state.online () == false && s.online () == true) + { + // initializing + on_monitorButton_clicked (!m_config.monitor_off_at_startup ()); + } + if (s.frequency () != old_state.frequency () || s.split () != m_splitMode) + { + m_splitMode = s.split (); + if (!s.ptt ()) + { + m_freqNominal = s.frequency () - m_astroCorrection.rx; + if (old_freqNominal != m_freqNominal) + { + m_freqTxNominal = m_freqNominal; + genCQMsg (); + } + + if (m_monitoring) + { + m_lastMonitoredFrequency = m_freqNominal; + } + if (m_lastDialFreq != m_freqNominal && + (m_mode != "MSK144" + || !(ui->cbCQTx->isEnabled () && ui->cbCQTx->isVisible () && ui->cbCQTx->isChecked()))) { + m_lastDialFreq = m_freqNominal; + m_secBandChanged=QDateTime::currentMSecsSinceEpoch()/1000; + if(s.frequency () < 30000000u && !m_mode.startsWith ("WSPR")) { + // Write freq changes to ALL.TXT only below 30 MHz. + QFile f2 {m_config.writeable_data_dir ().absoluteFilePath ("ALL.TXT")}; + if (f2.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) { + QTextStream out(&f2); + out << QDateTime::currentDateTimeUtc().toString("yyyy-MM-dd hh:mm") + << " " << qSetRealNumberPrecision (12) << (m_freqNominal / 1.e6) << " MHz " + << m_mode << endl; + f2.close(); + } else { + MessageBox::warning_message (this, tr ("File Error") + ,tr ("Cannot open \"%1\" for append: %2") + .arg (f2.fileName ()).arg (f2.errorString ())); + } + } + + if (m_config.spot_to_psk_reporter ()) { + pskSetLocal (); + } + statusChanged(); + m_wideGraph->setDialFreq(m_freqNominal / 1.e6); + } + } else { + m_freqTxNominal = s.split () ? s.tx_frequency () - m_astroCorrection.tx : s.frequency (); + } + if (m_astroWidget) m_astroWidget->nominal_frequency (m_freqNominal, m_freqTxNominal); + } + // ensure frequency display is correct + if (m_astroWidget && old_state.ptt () != s.ptt ()) setRig (); + + displayDialFrequency (); + update_dynamic_property (ui->readFreq, "state", "ok"); + ui->readFreq->setEnabled (false); + ui->readFreq->setText (s.split () ? "S" : ""); +} + +void MainWindow::handle_transceiver_failure (QString const& reason) +{ + update_dynamic_property (ui->readFreq, "state", "error"); + ui->readFreq->setEnabled (true); + on_stopTxButton_clicked (); + rigFailure (reason); +} + +void MainWindow::rigFailure (QString const& reason) +{ + if (m_first_error) + { + // one automatic retry + QTimer::singleShot (0, this, SLOT (rigOpen ())); + m_first_error = false; + } + else + { + if (m_splash && m_splash->isVisible ()) m_splash->hide (); + m_rigErrorMessageBox.setDetailedText (reason); + + // don't call slot functions directly to avoid recursion + m_rigErrorMessageBox.exec (); + auto const clicked_button = m_rigErrorMessageBox.clickedButton (); + if (clicked_button == m_configurations_button) + { + ui->menuConfig->exec (QCursor::pos ()); + } + else + { + switch (m_rigErrorMessageBox.standardButton (clicked_button)) + { + case MessageBox::Ok: + m_config.select_tab (1); + QTimer::singleShot (0, this, SLOT (on_actionSettings_triggered ())); + break; + + case MessageBox::Retry: + QTimer::singleShot (0, this, SLOT (rigOpen ())); + break; + + case MessageBox::Cancel: + QTimer::singleShot (0, this, SLOT (close ())); + break; + + default: break; // squashing compile warnings + } + } + m_first_error = true; // reset + } +} + +void MainWindow::transmit (double snr) +{ + double toneSpacing=0.0; + if (m_modeTx == "JT65") { + if(m_nSubMode==0) toneSpacing=11025.0/4096.0; + if(m_nSubMode==1) toneSpacing=2*11025.0/4096.0; + if(m_nSubMode==2) toneSpacing=4*11025.0/4096.0; + Q_EMIT sendMessage (NUM_JT65_SYMBOLS, + 4096.0*12000.0/11025.0, ui->TxFreqSpinBox->value () - m_XIT, + toneSpacing, m_soundOutput, m_config.audio_output_channel (), + true, false, snr, m_TRperiod); + } + + if (m_modeTx == "FT8") { + toneSpacing=12000.0/1920.0; + if(m_config.x2ToneSpacing()) toneSpacing=2*12000.0/1920.0; + if(m_config.x4ToneSpacing()) toneSpacing=4*12000.0/1920.0; + if(SpecOp::FOX==m_config.special_op_id() and !m_tune) toneSpacing=-1; + Q_EMIT sendMessage (NUM_FT8_SYMBOLS, + 1920.0, ui->TxFreqSpinBox->value () - m_XIT, + toneSpacing, m_soundOutput, m_config.audio_output_channel (), + true, false, snr, m_TRperiod); + } + + if (m_modeTx == "QRA64") { + if(m_nSubMode==0) toneSpacing=12000.0/6912.0; + if(m_nSubMode==1) toneSpacing=2*12000.0/6912.0; + if(m_nSubMode==2) toneSpacing=4*12000.0/6912.0; + if(m_nSubMode==3) toneSpacing=8*12000.0/6912.0; + if(m_nSubMode==4) toneSpacing=16*12000.0/6912.0; + Q_EMIT sendMessage (NUM_QRA64_SYMBOLS, + 6912.0, ui->TxFreqSpinBox->value () - m_XIT, + toneSpacing, m_soundOutput, m_config.audio_output_channel (), + true, false, snr, m_TRperiod); + } + + if (m_modeTx == "JT9") { + int nsub=pow(2,m_nSubMode); + int nsps[]={480,240,120,60}; + double sps=m_nsps; + m_toneSpacing=nsub*12000.0/6912.0; + if(m_config.x2ToneSpacing()) m_toneSpacing=2.0*m_toneSpacing; + if(m_config.x4ToneSpacing()) m_toneSpacing=4.0*m_toneSpacing; + bool fastmode=false; + if(m_bFast9 and (m_nSubMode>=4)) { + fastmode=true; + sps=nsps[m_nSubMode-4]; + m_toneSpacing=12000.0/sps; + } + Q_EMIT sendMessage (NUM_JT9_SYMBOLS, sps, + ui->TxFreqSpinBox->value() - m_XIT, m_toneSpacing, + m_soundOutput, m_config.audio_output_channel (), + true, fastmode, snr, m_TRperiod); + } + + if (m_modeTx == "MSK144") { + m_nsps=6; + double f0=1000.0; + if(!m_bFastMode) { + m_nsps=192; + f0=ui->TxFreqSpinBox->value () - m_XIT - 0.5*m_toneSpacing; + } + m_toneSpacing=6000.0/m_nsps; + m_FFTSize = 7 * 512; + Q_EMIT FFTSize (m_FFTSize); + int nsym; + nsym=NUM_MSK144_SYMBOLS; + if(itone[40] < 0) nsym=40; + Q_EMIT sendMessage (nsym, double(m_nsps), f0, m_toneSpacing, + m_soundOutput, m_config.audio_output_channel (), + true, true, snr, m_TRperiod); + } + + if (m_modeTx == "JT4") { + if(m_nSubMode==0) toneSpacing=4.375; + if(m_nSubMode==1) toneSpacing=2*4.375; + if(m_nSubMode==2) toneSpacing=4*4.375; + if(m_nSubMode==3) toneSpacing=9*4.375; + if(m_nSubMode==4) toneSpacing=18*4.375; + if(m_nSubMode==5) toneSpacing=36*4.375; + if(m_nSubMode==6) toneSpacing=72*4.375; + Q_EMIT sendMessage (NUM_JT4_SYMBOLS, + 2520.0*12000.0/11025.0, ui->TxFreqSpinBox->value () - m_XIT, + toneSpacing, m_soundOutput, m_config.audio_output_channel (), + true, false, snr, m_TRperiod); + } + if (m_mode=="WSPR") { + int nToneSpacing=1; + if(m_config.x2ToneSpacing()) nToneSpacing=2; + if(m_config.x4ToneSpacing()) nToneSpacing=4; + Q_EMIT sendMessage (NUM_WSPR_SYMBOLS, 8192.0, + ui->TxFreqSpinBox->value() - 1.5 * 12000 / 8192, + m_toneSpacing*nToneSpacing, m_soundOutput, + m_config.audio_output_channel(),true, false, snr, + m_TRperiod); + } + if (m_mode=="WSPR-LF") { + Q_EMIT sendMessage (NUM_WSPR_LF_SYMBOLS, 24576.0, + ui->TxFreqSpinBox->value(), + m_toneSpacing, m_soundOutput, + m_config.audio_output_channel(),true, false, snr, + m_TRperiod); + } + if(m_mode=="Echo") { + //??? should use "fastMode = true" here ??? + Q_EMIT sendMessage (27, 1024.0, 1500.0, 0.0, m_soundOutput, + m_config.audio_output_channel(), + false, false, snr, m_TRperiod); + } + + if(m_mode=="ISCAT") { + double sps,f0; + if(m_nSubMode==0) { + sps=512.0*12000.0/11025.0; + toneSpacing=11025.0/512.0; + f0=47*toneSpacing; + } else { + sps=256.0*12000.0/11025.0; + toneSpacing=11025.0/256.0; + f0=13*toneSpacing; + } + Q_EMIT sendMessage (NUM_ISCAT_SYMBOLS, sps, f0, toneSpacing, m_soundOutput, + m_config.audio_output_channel(), + true, true, snr, m_TRperiod); + } + +// In auto-sequencing mode, stop after 5 transmissions of "73" message. + if (m_bFastMode || m_bFast9) { + if (ui->cbAutoSeq->isVisible () && ui->cbAutoSeq->isChecked ()) { + if(m_ntx==5) { + m_nTx73 += 1; + } else { + m_nTx73=0; + } + } + } +} + +void MainWindow::on_outAttenuation_valueChanged (int a) +{ + QString tt_str; + qreal dBAttn {a / 10.}; // slider interpreted as dB / 100 + if (m_tune && m_config.pwrBandTuneMemory()) { + tt_str = tr ("Tune digital gain "); + } else { + tt_str = tr ("Transmit digital gain "); + } + tt_str += (a ? QString::number (-dBAttn, 'f', 1) : "0") + "dB"; + if (!m_block_pwr_tooltip) { + QToolTip::showText (QCursor::pos (), tt_str, ui->outAttenuation); + } + QString curBand = ui->bandComboBox->currentText(); + if (m_PwrBandSetOK && !m_tune && m_config.pwrBandTxMemory ()) { + m_pwrBandTxMemory[curBand] = a; // remember our Tx pwr + } + if (m_PwrBandSetOK && m_tune && m_config.pwrBandTuneMemory()) { + m_pwrBandTuneMemory[curBand] = a; // remember our Tune pwr + } + Q_EMIT outAttenuationChanged (dBAttn); +} + +void MainWindow::on_actionShort_list_of_add_on_prefixes_and_suffixes_triggered() +{ + if (!m_prefixes) { + m_prefixes.reset (new HelpTextWindow {tr ("Prefixes"), ":/prefixes.txt", {"Courier", 10}}); + } + m_prefixes->showNormal(); + m_prefixes->raise (); +} + +bool MainWindow::shortList(QString callsign) +{ + int n=callsign.length(); + int i1=callsign.indexOf("/"); + Q_ASSERT(i1>0 and i1<n); + QString t1=callsign.mid(0,i1); + QString t2=callsign.mid(i1+1,n-i1-1); + bool b=(m_pfx.contains(t1) or m_sfx.contains(t2)); + return b; +} + +void MainWindow::pskSetLocal () +{ + // find the station row, if any, that matches the band we are on + auto stations = m_config.stations (); + auto matches = stations->match (stations->index (0, StationList::band_column) + , Qt::DisplayRole + , ui->bandComboBox->currentText () + , 1 + , Qt::MatchExactly); + QString antenna_description; + if (!matches.isEmpty ()) { + antenna_description = stations->index (matches.first ().row () + , StationList::description_column).data ().toString (); + } + // qDebug() << "To PSKreporter: local station details"; + psk_Reporter->setLocalStation(m_config.my_callsign (), m_config.my_grid (), + antenna_description, QString {"WSJT-X v" + version() + " " + + m_revision}.simplified ()); +} + +void MainWindow::transmitDisplay (bool transmitting) +{ + if (transmitting == m_transmitting) { + if (transmitting) { + ui->signal_meter_widget->setValue(0,0); + if (m_monitoring) monitor (false); + m_btxok=true; + } + + auto QSY_allowed = !transmitting or m_config.tx_QSY_allowed () or + !m_config.split_mode (); + if (ui->cbHoldTxFreq->isChecked ()) { + ui->RxFreqSpinBox->setEnabled (QSY_allowed); + ui->pbT2R->setEnabled (QSY_allowed); + } + + if (!m_mode.startsWith ("WSPR")) { + if(m_config.enable_VHF_features ()) { +//### During tests, at least, allow use of Tx Freq spinner with VHF features enabled. + // used fixed 1000Hz Tx DF for VHF & up QSO modes +// ui->TxFreqSpinBox->setValue(1000); +// ui->TxFreqSpinBox->setEnabled (false); + ui->TxFreqSpinBox->setEnabled (true); +//### + } else { + ui->TxFreqSpinBox->setEnabled (QSY_allowed and !m_bFastMode); + ui->pbR2T->setEnabled (QSY_allowed); + ui->cbHoldTxFreq->setEnabled (QSY_allowed); + } + } + + // the following are always disallowed in transmit + ui->menuMode->setEnabled (!transmitting); + //ui->bandComboBox->setEnabled (!transmitting); + if (!transmitting) { + if (m_mode == "JT9+JT65") { + // allow mode switch in Rx when in dual mode + ui->pbTxMode->setEnabled (true); + } + } else { + ui->pbTxMode->setEnabled (false); + } + } +} + +void MainWindow::on_sbFtol_valueChanged(int value) +{ + m_wideGraph->setTol (value); +} + +void::MainWindow::VHF_features_enabled(bool b) +{ + if(m_mode!="JT4" and m_mode!="JT65") b=false; + if(b and (ui->actionInclude_averaging->isChecked() or + ui->actionInclude_correlation->isChecked())) { + ui->actionDeepestDecode->setChecked (true); + } + ui->actionInclude_averaging->setVisible (b); + ui->actionInclude_correlation->setVisible (b); + ui->actionMessage_averaging->setEnabled(b); + ui->actionEnable_AP_DXcall->setVisible (m_mode=="QRA64"); + ui->actionEnable_AP_JT65->setVisible (b && m_mode=="JT65"); + if(!b && m_msgAvgWidget and (SpecOp::FOX != m_config.special_op_id()) and !m_config.autoLog()) { + if(m_msgAvgWidget->isVisible()) m_msgAvgWidget->close(); + } +} + +void MainWindow::on_sbTR_valueChanged(int value) +{ +// if(!m_bFastMode and n>m_nSubMode) m_MinW=m_nSubMode; + if(m_bFastMode or m_mode=="FreqCal") { + m_TRperiod = value; + m_fastGraph->setTRPeriod (value); + m_modulator->setTRPeriod (value); // TODO - not thread safe + m_detector->setTRPeriod (value); // TODO - not thread safe + m_wideGraph->setPeriod (value, m_nsps); + progressBar.setMaximum (value); + } + if(m_monitoring) { + on_stopButton_clicked(); + on_monitorButton_clicked(true); + } + if(m_transmitting) { + on_stopTxButton_clicked(); + } +} + +QChar MainWindow::current_submode () const +{ + QChar submode {0}; + if (m_mode.contains (QRegularExpression {R"(^(JT65|JT9|JT4|ISCAT|QRA64)$)"}) + && (m_config.enable_VHF_features () || "JT4" == m_mode || "ISCAT" == m_mode)) + { + submode = m_nSubMode + 65; + } + return submode; +} + +void MainWindow::on_sbSubmode_valueChanged(int n) +{ + m_nSubMode=n; + m_wideGraph->setSubMode(m_nSubMode); + auto submode = current_submode (); + if (submode != QChar::Null) + { + mode_label.setText (m_mode + " " + submode); + } + else + { + mode_label.setText (m_mode); + } + if(m_mode=="ISCAT") { + if(m_nSubMode==0) ui->TxFreqSpinBox->setValue(1012); + if(m_nSubMode==1) ui->TxFreqSpinBox->setValue(560); + } + if(m_mode=="JT9") { + if(m_nSubMode<4) { + ui->cbFast9->setChecked(false); + on_cbFast9_clicked(false); + ui->cbFast9->setEnabled(false); + ui->sbTR->setVisible(false); + m_TRperiod=60; + } else { + ui->cbFast9->setEnabled(true); + } + ui->sbTR->setVisible(m_bFast9); + if(m_bFast9) ui->TxFreqSpinBox->setValue(700); + } + if(m_transmitting and m_bFast9 and m_nSubMode>=4) transmit (99.0); + statusUpdate (); +} + +void MainWindow::on_cbFast9_clicked(bool b) +{ + if(m_mode=="JT9") { + m_bFast9=b; +// ui->cbAutoSeq->setVisible(b); + on_actionJT9_triggered(); + } + + if(b) { + m_TRperiod = ui->sbTR->value (); + } else { + m_TRperiod=60; + } + progressBar.setMaximum(m_TRperiod); + m_wideGraph->setPeriod(m_TRperiod,m_nsps); + fast_config(b); + statusChanged (); +} + + +void MainWindow::on_cbShMsgs_toggled(bool b) +{ + ui->cbTx6->setEnabled(b); + m_bShMsgs=b; + if(b) ui->cbSWL->setChecked(false); + if(m_bShMsgs and (m_mode=="MSK144")) ui->rptSpinBox->setValue(1); + int it0=itone[0]; + int ntx=m_ntx; + m_lastCallsign.clear (); // ensure Tx5 gets updated + genStdMsgs(m_rpt); + itone[0]=it0; + if(ntx==1) ui->txrb1->setChecked(true); + if(ntx==2) ui->txrb2->setChecked(true); + if(ntx==3) ui->txrb3->setChecked(true); + if(ntx==4) ui->txrb4->setChecked(true); + if(ntx==5) ui->txrb5->setChecked(true); + if(ntx==6) ui->txrb6->setChecked(true); +} + +void MainWindow::on_cbSWL_toggled(bool b) +{ + if(b) ui->cbShMsgs->setChecked(false); +} + +void MainWindow::on_cbTx6_toggled(bool) +{ + genCQMsg (); +} + +// Takes a decoded CQ line and sets it up for reply +void MainWindow::replyToCQ (QTime time, qint32 snr, float delta_time, quint32 delta_frequency + , QString const& mode, QString const& message_text + , bool /*low_confidence*/, quint8 modifiers) +{ + if (!m_config.accept_udp_requests ()) + { + return; + } + + QString format_string {"%1 %2 %3 %4 %5 %6"}; + auto const& time_string = time.toString ("~" == mode || "&" == mode ? "hhmmss" : "hhmm"); + auto message_line = format_string + .arg (time_string) + .arg (snr, 3) + .arg (delta_time, 4, 'f', 1) + .arg (delta_frequency, 4) + .arg (mode, -2) + .arg (message_text); + QTextCursor start {ui->decodedTextBrowser->document ()}; + start.movePosition (QTextCursor::End); + auto cursor = ui->decodedTextBrowser->document ()->find (message_line, start, QTextDocument::FindBackward); + if (cursor.isNull ()) + { + // try again with with -0.0 delta time + cursor = ui->decodedTextBrowser->document ()->find (format_string + .arg (time_string) + .arg (snr, 3) + .arg ('-' + QString::number (delta_time, 'f', 1), 4) + .arg (delta_frequency, 4) + .arg (mode, -2) + .arg (message_text), start, QTextDocument::FindBackward); + } + if (!cursor.isNull ()) + { + if (m_config.udpWindowToFront ()) + { + show (); + raise (); + activateWindow (); + } + if (m_config.udpWindowRestore () && isMinimized ()) + { + showNormal (); + raise (); + } + if (message_text.contains (QRegularExpression {R"(^(CQ |CQDX |QRZ ))"})) { + // a message we are willing to accept and auto reply to + m_bDoubleClicked = true; + } + DecodedText message {message_line}; + Qt::KeyboardModifiers kbmod {modifiers << 24}; + processMessage (message, kbmod); + tx_watchdog (false); + QApplication::alert (this); + } + else + { + qDebug () << "process reply message ignored, decode not found:" << message_line; + } +} + +void MainWindow::locationChange (QString const& location) +{ + QString grid {location.trimmed ()}; + int len; + + // string 6 chars or fewer, interpret as a grid, or use with a 'GRID:' prefix + if (grid.size () > 6) { + if (grid.toUpper ().startsWith ("GRID:")) { + grid = grid.mid (5).trimmed (); + } + else { + // TODO - support any other formats, e.g. latlong? Or have that conversion done external to wsjtx + return; + } + } + if (MaidenheadLocatorValidator::Acceptable == MaidenheadLocatorValidator ().validate (grid, len)) { + qDebug() << "locationChange: Grid supplied is " << grid; + if (m_config.my_grid () != grid) { + m_config.set_location (grid); + genStdMsgs (m_rpt, false); + statusUpdate (); + } + } else { + qDebug() << "locationChange: Invalid grid " << grid; + } +} + +void MainWindow::replayDecodes () +{ + // we accept this request even if the setting to accept UDP requests + // is not checked + + // attempt to parse the decoded text + for (QTextBlock block = ui->decodedTextBrowser->document ()->firstBlock (); block.isValid (); block = block.next ()) + { + auto message = block.text (); + message = message.left (message.indexOf (QChar::Nbsp)); // discard + // any + // appended info + if (message.size() >= 4 && message.left (4) != "----") + { + auto const& parts = message.split (' ', QString::SkipEmptyParts); + if (parts.size () >= 5 && parts[3].contains ('.')) // WSPR + { + postWSPRDecode (false, parts); + } + else + { + // TODO - how to skip ISCAT decodes + postDecode (false, message); + } + } + } + statusChanged (); +} + +void MainWindow::postDecode (bool is_new, QString const& message) +{ + auto const& decode = message.trimmed (); + auto const& parts = decode.left (22).split (' ', QString::SkipEmptyParts); + if (parts.size () >= 5) + { + auto has_seconds = parts[0].size () > 4; + m_messageClient->decode (is_new + , QTime::fromString (parts[0], has_seconds ? "hhmmss" : "hhmm") + , parts[1].toInt () + , parts[2].toFloat (), parts[3].toUInt (), parts[4] + , decode.mid (has_seconds ? 24 : 22) + , QChar {'?'} == decode.mid (has_seconds ? 24 + 21 : 22 + 21, 1) + , m_diskData); + } +} + +void MainWindow::postWSPRDecode (bool is_new, QStringList parts) +{ + if (parts.size () < 8) + { + parts.insert (6, ""); + } + m_messageClient->WSPR_decode (is_new, QTime::fromString (parts[0], "hhmm"), parts[1].toInt () + , parts[2].toFloat (), Radio::frequency (parts[3].toFloat (), 6) + , parts[4].toInt (), parts[5], parts[6], parts[7].toInt () + , m_diskData); +} + +void MainWindow::networkError (QString const& e) +{ + if (m_splash && m_splash->isVisible ()) m_splash->hide (); + if (MessageBox::Retry == MessageBox::warning_message (this, tr ("Network Error") + , tr ("Error: %1\nUDP server %2:%3") + .arg (e) + .arg (m_config.udp_server_name ()) + .arg (m_config.udp_server_port ()) + , QString {} + , MessageBox::Cancel | MessageBox::Retry + , MessageBox::Cancel)) + { + // retry server lookup + m_messageClient->set_server (m_config.udp_server_name ()); + } +} + +void MainWindow::on_syncSpinBox_valueChanged(int n) +{ + m_minSync=n; +} + +void MainWindow::p1ReadFromStdout() //p1readFromStdout +{ + QString t1; + while(p1.canReadLine()) { + QString t(p1.readLine()); + if(ui->cbNoOwnCall->isChecked()) { + if(t.contains(" " + m_config.my_callsign() + " ")) continue; + if(t.contains(" <" + m_config.my_callsign() + "> ")) continue; + } + if(t.indexOf("<DecodeFinished>") >= 0) { + m_bDecoded = m_nWSPRdecodes > 0; + if(!m_diskData) { + WSPR_history(m_dialFreqRxWSPR, m_nWSPRdecodes); + if(m_nWSPRdecodes==0 and ui->band_hopping_group_box->isChecked()) { + t = " Receiving " + m_mode + " ----------------------- " + + m_config.bands ()->find (m_dialFreqRxWSPR); + t=WSPR_hhmm(-60) + ' ' + t.rightJustified (66, '-'); + ui->decodedTextBrowser->appendText(t); + } + killFileTimer.start (45*1000); //Kill in 45s (for slow modes) + } + m_nWSPRdecodes=0; + ui->DecodeButton->setChecked (false); + if(m_uploadSpots + && m_config.is_transceiver_online ()) { // need working rig control + float x=qrand()/((double)RAND_MAX + 1.0); + int msdelay=20000*x; + uploadTimer.start(msdelay); //Upload delay + } else { + QFile f(QDir::toNativeSeparators(m_config.writeable_data_dir ().absolutePath()) + "/wspr_spots.txt"); + if(f.exists()) f.remove(); + } + m_RxLog=0; + m_startAnother=m_loopall; + m_blankLine=true; + m_decoderBusy = false; + statusUpdate (); + } else { + + int n=t.length(); + t=t.mid(0,n-2) + " "; + t.remove(QRegExp("\\s+$")); + QStringList rxFields = t.split(QRegExp("\\s+")); + QString rxLine; + QString grid=""; + if ( rxFields.count() == 8 ) { + rxLine = QString("%1 %2 %3 %4 %5 %6 %7 %8") + .arg(rxFields.at(0), 4) + .arg(rxFields.at(1), 4) + .arg(rxFields.at(2), 5) + .arg(rxFields.at(3), 11) + .arg(rxFields.at(4), 4) + .arg(rxFields.at(5).leftJustified (12)) + .arg(rxFields.at(6), -6) + .arg(rxFields.at(7), 3); + postWSPRDecode (true, rxFields); + grid = rxFields.at(6); + } else if ( rxFields.count() == 7 ) { // Type 2 message + rxLine = QString("%1 %2 %3 %4 %5 %6 %7 %8") + .arg(rxFields.at(0), 4) + .arg(rxFields.at(1), 4) + .arg(rxFields.at(2), 5) + .arg(rxFields.at(3), 11) + .arg(rxFields.at(4), 4) + .arg(rxFields.at(5).leftJustified (12)) + .arg("", -6) + .arg(rxFields.at(6), 3); + postWSPRDecode (true, rxFields); + } else { + rxLine = t; + } + if(grid!="") { + double utch=0.0; + int nAz,nEl,nDmiles,nDkm,nHotAz,nHotABetter; + azdist_(const_cast <char *> (m_config.my_grid ().toLatin1().constData()), + const_cast <char *> (grid.toLatin1().constData()),&utch, + &nAz,&nEl,&nDmiles,&nDkm,&nHotAz,&nHotABetter,6,6); + QString t1; + if(m_config.miles()) { + t1.sprintf("%7d",nDmiles); + } else { + t1.sprintf("%7d",nDkm); + } + rxLine += t1; + } + + if (m_config.insert_blank () && m_blankLine) { + QString band; + Frequency f=1000000.0*rxFields.at(3).toDouble()+0.5; + band = ' ' + m_config.bands ()->find (f); + ui->decodedTextBrowser->appendText(band.rightJustified (71, '-')); + m_blankLine = false; + } + m_nWSPRdecodes += 1; + ui->decodedTextBrowser->appendText(rxLine); + } + } +} + +QString MainWindow::WSPR_hhmm(int n) +{ + QDateTime t=QDateTime::currentDateTimeUtc().addSecs(n); + int m=t.toString("hhmm").toInt()/2; + QString t1; + t1.sprintf("%04d",2*m); + return t1; +} + +void MainWindow::WSPR_history(Frequency dialFreq, int ndecodes) +{ + QDateTime t=QDateTime::currentDateTimeUtc().addSecs(-60); + QString t1=t.toString("yyMMdd"); + QString t2=WSPR_hhmm(-60); + QString t3; + t3.sprintf("%13.6f",0.000001*dialFreq); + if(ndecodes<0) { + t1=t1 + " " + t2 + t3 + " T"; + } else { + QString t4; + t4.sprintf("%4d",ndecodes); + t1=t1 + " " + t2 + t3 + " R" + t4; + } + QFile f {m_config.writeable_data_dir ().absoluteFilePath ("WSPR_history.txt")}; + if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) { + QTextStream out(&f); + out << t1 << endl; + f.close(); + } else { + MessageBox::warning_message (this, tr ("File Error") + , tr ("Cannot open \"%1\" for append: %2") + .arg (f.fileName ()).arg (f.errorString ())); + } +} + +void MainWindow::uploadSpots() +{ + // do not spot replays or if rig control not working + if(m_diskData || !m_config.is_transceiver_online ()) return; + if(m_uploading) { + qDebug() << "Previous upload has not completed, spots were lost"; + wsprNet->abortOutstandingRequests (); + m_uploading = false; + } + QString rfreq = QString("%1").arg(0.000001*(m_dialFreqRxWSPR + 1500), 0, 'f', 6); + QString tfreq = QString("%1").arg(0.000001*(m_dialFreqRxWSPR + + ui->TxFreqSpinBox->value()), 0, 'f', 6); + wsprNet->upload(m_config.my_callsign(), m_config.my_grid(), rfreq, tfreq, + m_mode, QString::number(ui->autoButton->isChecked() ? m_pctx : 0), + QString::number(m_dBm), version(), + QDir::toNativeSeparators(m_config.writeable_data_dir ().absolutePath()) + "/wspr_spots.txt"); + m_uploading = true; +} + +void MainWindow::uploadResponse(QString response) +{ + if (response == "done") { + m_uploading=false; + } else { + if (response.startsWith ("Upload Failed")) { + m_uploading=false; + } + qDebug () << "WSPRnet.org status:" << response; + } +} + +void MainWindow::on_TxPowerComboBox_currentIndexChanged(const QString &arg1) +{ + int i1=arg1.indexOf(" "); + m_dBm=arg1.mid(0,i1).toInt(); +} + +void MainWindow::on_sbTxPercent_valueChanged(int n) +{ + m_pctx=n; + if(m_pctx>0) { + ui->pbTxNext->setEnabled(true); + } else { + m_txNext=false; + ui->pbTxNext->setChecked(false); + ui->pbTxNext->setEnabled(false); + } +} + +void MainWindow::on_cbUploadWSPR_Spots_toggled(bool b) +{ + m_uploadSpots=b; + if(m_uploadSpots) ui->cbUploadWSPR_Spots->setStyleSheet(""); + if(!m_uploadSpots) ui->cbUploadWSPR_Spots->setStyleSheet( + "QCheckBox{background-color: yellow}"); +} + +void MainWindow::on_WSPRfreqSpinBox_valueChanged(int n) +{ + ui->TxFreqSpinBox->setValue(n); +} + +void MainWindow::on_pbTxNext_clicked(bool b) +{ + m_txNext=b; +} + +void MainWindow::WSPR_scheduling () +{ + m_WSPR_tx_next = false; + if (m_config.is_transceiver_online () // need working rig control for hopping + && !m_config.is_dummy_rig () + && ui->band_hopping_group_box->isChecked ()) { + auto hop_data = m_WSPR_band_hopping.next_hop (m_auto); + qDebug () << "hop data: period:" << hop_data.period_name_ + << "frequencies index:" << hop_data.frequencies_index_ + << "tune:" << hop_data.tune_required_ + << "tx:" << hop_data.tx_next_; + m_WSPR_tx_next = hop_data.tx_next_; + if (hop_data.frequencies_index_ >= 0) { // new band + ui->bandComboBox->setCurrentIndex (hop_data.frequencies_index_); + on_bandComboBox_activated (hop_data.frequencies_index_); + m_cmnd.clear (); + QStringList prefixes {".bat", ".cmd", ".exe", ""}; + for (auto const& prefix : prefixes) + { + auto const& path = m_appDir + "/user_hardware" + prefix; + QFile f {path}; + if (f.exists ()) { + m_cmnd = QDir::toNativeSeparators (f.fileName ()) + ' ' + + m_config.bands ()->find (m_freqNominal).remove ('m'); + } + } + if(m_cmnd!="") p3.start(m_cmnd); // Execute user's hardware controller + + // Produce a short tuneup signal + m_tuneup = false; + if (hop_data.tune_required_) { + m_tuneup = true; + on_tuneButton_clicked (true); + tuneATU_Timer.start (2500); + } + } + + // Display grayline status + band_hopping_label.setText (hop_data.period_name_); + } + else { + m_WSPR_tx_next = m_WSPR_band_hopping.next_is_tx ("WSPR-LF" == m_mode); + } +} + +void MainWindow::astroUpdate () +{ + if (m_astroWidget) + { + // no Doppler correction while CTRL pressed allows manual tuning + if (Qt::ControlModifier & QApplication::queryKeyboardModifiers ()) return; + + auto correction = m_astroWidget->astroUpdate(QDateTime::currentDateTimeUtc (), + m_config.my_grid(), m_hisGrid, + m_freqNominal, + "Echo" == m_mode, m_transmitting, + !m_config.tx_QSY_allowed (), m_TRperiod); + // no Doppler correction in Tx if rig can't do it + if (m_transmitting && !m_config.tx_QSY_allowed ()) return; + if (!m_astroWidget->doppler_tracking ()) return; + if ((m_monitoring || m_transmitting) + // no Doppler correction below 6m + && m_freqNominal >= 50000000 + && m_config.split_mode ()) + { + // adjust for rig resolution + if (m_config.transceiver_resolution () > 2) + { + correction.rx = (correction.rx + 50) / 100 * 100; + correction.tx = (correction.tx + 50) / 100 * 100; + } + else if (m_config.transceiver_resolution () > 1) + { + correction.rx = (correction.rx + 10) / 20 * 20; + correction.tx = (correction.tx + 10) / 20 * 20; + } + else if (m_config.transceiver_resolution () > 0) + { + correction.rx = (correction.rx + 5) / 10 * 10; + correction.tx = (correction.tx + 5) / 10 * 10; + } + else if (m_config.transceiver_resolution () < -2) + { + correction.rx = correction.rx / 100 * 100; + correction.tx = correction.tx / 100 * 100; + } + else if (m_config.transceiver_resolution () < -1) + { + correction.rx = correction.rx / 20 * 20; + correction.tx = correction.tx / 20 * 20; + } + else if (m_config.transceiver_resolution () < 0) + { + correction.rx = correction.rx / 10 * 10; + correction.tx = correction.tx / 10 * 10; + } + m_astroCorrection = correction; + } + else + { + m_astroCorrection = {}; + } + + setRig (); + } +} + +void MainWindow::setRig (Frequency f) +{ + if (f) + { + m_freqNominal = f; + genCQMsg (); + m_freqTxNominal = m_freqNominal; + if (m_astroWidget) m_astroWidget->nominal_frequency (m_freqNominal, m_freqTxNominal); + } + if (m_mode == "FreqCal" + && m_frequency_list_fcal_iter != m_config.frequencies ()->end ()) { + m_freqNominal = m_frequency_list_fcal_iter->frequency_ - ui->RxFreqSpinBox->value (); + } + if(m_transmitting && !m_config.tx_QSY_allowed ()) return; + if ((m_monitoring || m_transmitting) && m_config.transceiver_online ()) + { + if (m_transmitting && m_config.split_mode ()) + { + Q_EMIT m_config.transceiver_tx_frequency (m_freqTxNominal + m_astroCorrection.tx); + } + else + { + Q_EMIT m_config.transceiver_frequency (m_freqNominal + m_astroCorrection.rx); + } + } +} + +void MainWindow::fastPick(int x0, int x1, int y) +{ + float pixPerSecond=12000.0/512.0; + if(m_TRperiod<30) pixPerSecond=12000.0/256.0; + if(m_mode!="ISCAT" and m_mode!="MSK144") return; + if(!m_decoderBusy) { + dec_data.params.newdat=0; + dec_data.params.nagain=1; + m_blankLine=false; // don't insert the separator again + m_nPick=1; + if(y > 120) m_nPick=2; + m_t0Pick=x0/pixPerSecond; + m_t1Pick=x1/pixPerSecond; + m_dataAvailable=true; + decode(); + } +} + +void MainWindow::on_actionMeasure_reference_spectrum_triggered() +{ + if(!m_monitoring) on_monitorButton_clicked (true); + m_bRefSpec=true; +} + +void MainWindow::on_actionMeasure_phase_response_triggered() +{ + if(m_bTrain) { + m_bTrain=false; + MessageBox::information_message (this, tr ("Phase Training Disabled")); + } else { + m_bTrain=true; + MessageBox::information_message (this, tr ("Phase Training Enabled")); + } +} + +void MainWindow::on_actionErase_reference_spectrum_triggered() +{ + m_bClearRefSpec=true; +} + +void MainWindow::freqCalStep() +{ + if (m_frequency_list_fcal_iter == m_config.frequencies ()->end () + || ++m_frequency_list_fcal_iter == m_config.frequencies ()->end ()) { + m_frequency_list_fcal_iter = m_config.frequencies ()->begin (); + } + + // allow for empty list + if (m_frequency_list_fcal_iter != m_config.frequencies ()->end ()) { + setRig (m_frequency_list_fcal_iter->frequency_ - ui->RxFreqSpinBox->value ()); + } +} + +void MainWindow::on_sbCQTxFreq_valueChanged(int) +{ + setXIT (ui->TxFreqSpinBox->value ()); +} + +void MainWindow::on_cbCQTx_toggled(bool b) +{ + ui->sbCQTxFreq->setEnabled(b); + genCQMsg(); + if(b) { + ui->txrb6->setChecked(true); + m_ntx=6; + m_QSOProgress = CALLING; + } + setRig (); + setXIT (ui->TxFreqSpinBox->value ()); +} + +void MainWindow::statusUpdate () const +{ + if (!ui) return; + auto submode = current_submode (); + m_messageClient->status_update (m_freqNominal, m_mode, m_hisCall, + QString::number (ui->rptSpinBox->value ()), + m_modeTx, ui->autoButton->isChecked (), + m_transmitting, m_decoderBusy, + ui->RxFreqSpinBox->value (), ui->TxFreqSpinBox->value (), + m_config.my_callsign (), m_config.my_grid (), + m_hisGrid, m_tx_watchdog, + submode != QChar::Null ? QString {submode} : QString {}, m_bFastMode, + static_cast<quint8> (m_config.special_op_id ())); +} + +void MainWindow::childEvent (QChildEvent * e) +{ + if (e->child ()->isWidgetType ()) + { + switch (e->type ()) + { + case QEvent::ChildAdded: add_child_to_event_filter (e->child ()); break; + case QEvent::ChildRemoved: remove_child_from_event_filter (e->child ()); break; + default: break; + } + } + QMainWindow::childEvent (e); +} + +// add widget and any child widgets to our event filter so that we can +// take action on key press ad mouse press events anywhere in the main window +void MainWindow::add_child_to_event_filter (QObject * target) +{ + if (target && target->isWidgetType ()) + { + target->installEventFilter (this); + } + auto const& children = target->children (); + for (auto iter = children.begin (); iter != children.end (); ++iter) + { + add_child_to_event_filter (*iter); + } +} + +// recursively remove widget and any child widgets from our event filter +void MainWindow::remove_child_from_event_filter (QObject * target) +{ + auto const& children = target->children (); + for (auto iter = children.begin (); iter != children.end (); ++iter) + { + remove_child_from_event_filter (*iter); + } + if (target && target->isWidgetType ()) + { + target->removeEventFilter (this); + } +} + +void MainWindow::tx_watchdog (bool triggered) +{ + auto prior = m_tx_watchdog; + m_tx_watchdog = triggered; + if (triggered) + { + m_bTxTime=false; + if (m_tune) stop_tuning (); + if (m_auto) auto_tx_mode (false); + tx_status_label.setStyleSheet ("QLabel{background-color: #ff0000}"); + tx_status_label.setText ("Runaway Tx watchdog"); + QApplication::alert (this); + } + else + { + m_idleMinutes = 0; + update_watchdog_label (); + } + if (prior != triggered) statusUpdate (); +} + +void MainWindow::update_watchdog_label () +{ + if (m_config.watchdog () && !m_mode.startsWith ("WSPR")) + { + watchdog_label.setText (QString {"WD:%1m"}.arg (m_config.watchdog () - m_idleMinutes)); + watchdog_label.setVisible (true); + } + else + { + watchdog_label.setText (QString {}); + watchdog_label.setVisible (false); + } +} + +void MainWindow::on_cbMenus_toggled(bool b) +{ + hideMenus(!b); +} + +void MainWindow::on_cbCQonly_toggled(bool) +{ + QFile {m_config.temp_dir().absoluteFilePath(".lock")}.remove(); // Allow jt9 to start + decodeBusy(true); +} + +void MainWindow::on_cbFirst_toggled(bool b) +{ + if (b) { + if (m_auto && CALLING == m_QSOProgress) { + ui->cbFirst->setStyleSheet ("QCheckBox{color:red}"); + } + } else { + ui->cbFirst->setStyleSheet (""); + } +} + +void MainWindow::on_cbAutoSeq_toggled(bool b) +{ + if(!b) ui->cbFirst->setChecked(false); + ui->cbFirst->setVisible((m_mode=="FT8") and b); +} + +void MainWindow::on_measure_check_box_stateChanged (int state) +{ + m_config.enable_calibration (Qt::Checked != state); +} + +void MainWindow::write_transmit_entry (QString const& file_name) +{ + QFile f {m_config.writeable_data_dir ().absoluteFilePath (file_name)}; + if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) + { + QTextStream out(&f); + auto time = QDateTime::currentDateTimeUtc (); + time = time.addSecs (-(time.time ().second () % m_TRperiod)); + out << time.toString("yyMMdd_hhmmss") + << " Transmitting " << qSetRealNumberPrecision (12) << (m_freqNominal / 1.e6) + << " MHz " << m_modeTx + << ": " << m_currentMessage << endl; + f.close(); + } + else + { + auto const& message = tr ("Cannot open \"%1\" for append: %2") + .arg (f.fileName ()).arg (f.errorString ()); + QTimer::singleShot (0, [=] { // don't block guiUpdate + MessageBox::warning_message (this, tr ("Log File Error"), message); + }); + } +} + +// -------------------------- Code for FT8 DXpedition Mode --------------------------- + +void MainWindow::hound_reply () +{ + if (!m_tune) { + //Select TX3, set TxFreq to FoxFreq, and Force Auto ON. + ui->txrb3->setChecked (true); + m_nSentFoxRrpt = 1; + ui->rptSpinBox->setValue(m_rptSent.toInt()); + if (!m_auto) auto_tx_mode(true); + ui->TxFreqSpinBox->setValue (m_nFoxFreq); + } +} + +void MainWindow::on_sbNlist_valueChanged(int n) +{ + m_Nlist=n; +} + +void MainWindow::on_sbNslots_valueChanged(int n) +{ + m_Nslots=n; + QString t; + t.sprintf(" NSlots %d",m_Nslots); + writeFoxQSO(t); +} + +void MainWindow::on_sbMax_dB_valueChanged(int n) +{ + m_max_dB=n; + QString t; + t.sprintf(" Max_dB %d",m_max_dB); + writeFoxQSO(t); +} + +void MainWindow::on_pbFoxReset_clicked() +{ + auto button = MessageBox::query_message (this, tr ("Confirm Reset"), + tr ("Are you sure you want to clear the QSO queues?")); + if(button == MessageBox::Yes) { + QFile f(m_config.temp_dir().absoluteFilePath("houndcallers.txt")); + f.remove(); + ui->decodedTextBrowser->setText(""); + ui->textBrowser4->setText(""); + m_houndQueue.clear(); + m_foxQSO.clear(); + m_foxQSOinProgress.clear(); + writeFoxQSO(" Reset"); + } +} + +void MainWindow::on_comboBoxHoundSort_activated(int index) +{ + if(index!=-99) houndCallers(); //Silence compiler warning +} + +//------------------------------------------------------------------------------ +QString MainWindow::sortHoundCalls(QString t, int isort, int max_dB) +{ +/* Called from "houndCallers()" to sort the list of calling stations by + * specified criteria. + * + * QString "t" contains a list of Hound callers read from file "houndcallers.txt". + * isort=0: random (shuffled order) + * 1: Call + * 2: Grid + * 3: SNR (reverse order) + * 4: Distance (reverse order) +*/ + + QMap<QString,QString> map; + QStringList lines,lines2; + QString msg,houndCall,t1; + QString ABC{"ABCDEFGHIJKLMNOPQRSTUVWXYZ _"}; + QList<int> list; + int i,j,k,m,n,nlines; + bool bReverse=(isort >= 3); + + isort=qAbs(isort); +// Save only the most recent transmission from each caller. + lines = t.split("\n"); + nlines=lines.length()-1; + for(i=0; i<nlines; i++) { + msg=lines.at(i); //key = callsign + if(msg.mid(13,1)==" ") msg=msg.mid(0,13) + "...." + msg.mid(17); + houndCall=msg.split(" ").at(0); //value = "call grid snr freq dist age" + map[houndCall]=msg; + } + + j=0; + t=""; + for(auto a: map.keys()) { + t1=map[a].split(" ",QString::SkipEmptyParts).at(2); + int nsnr=t1.toInt(); // get snr + if(nsnr <= max_dB) { // keep only if snr in specified range + if(isort==1) t += map[a] + "\n"; + if(isort==3 or isort==4) { + i=2; // sort Hound calls by snr + if(isort==4) i=4; // sort Hound calls by distance + t1=map[a].split(" ",QString::SkipEmptyParts).at(i); + n=1000*(t1.toInt()+100) + j; // pack (snr or dist) and index j into n + } + + if(isort==2) { // sort Hound calls by grid + t1=map[a].split(" ",QString::SkipEmptyParts).at(1); + if(t1=="....") t1="ZZ99"; + 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; // pack ngrid and index j into n + } + + list.insert(j,n); // add n to list at [j] + lines2.insert(j,map[a]); // add map[a] to lines2 at [j] + j++; + } + } + + if(isort>1) { + if(bReverse) { + std::sort (list.begin (), list.end (), std::greater<int> ()); + } else { + std::sort (list.begin (), list.end ()); + } + } + + if(isort>1) { + for(i=0; i<j; i++) { + k=list[i]%1000; + n=list[i]/1000 - 100; + t += lines2.at(k) + "\n"; + } + } + + int nn=lines2.length(); + if(isort==0) { // shuffle Hound calls to random order + int a[nn]; + for(i=0; i<nn; i++) { + a[i]=i; + } + for(i=nn-1; i>-1; i--) { + j=(i+1)*double(qrand())/RAND_MAX; + m=a[j]; + a[j]=a[i]; + a[i]=m; + t += lines2.at(m) + "\n"; + } + } + + int i0=t.indexOf("\n") + 1; + m_nSortedHounds=0; + if(i0 > 0) { + m_nSortedHounds=qMin(t.length(),m_Nlist*i0)/i0; // Number of sorted & displayed Hounds + } + m_houndCallers=t.mid(0,m_Nlist*i0); + + return m_houndCallers; +} + +//------------------------------------------------------------------------------ +void MainWindow::selectHound(QString line) +{ +/* Called from doubleClickOnCall() in DXpedition Fox mode. + * QString "line" is a user-selected line from left text window. + * The line may be selected by double-clicking; alternatively, hitting + * <Enter> is equivalent to double-clicking on the top-most line. +*/ + + if(line.length()==0) return; + QString houndCall=line.split(" ",QString::SkipEmptyParts).at(0); + +// Don't add a call already enqueued or in QSO + if(ui->textBrowser4->toPlainText().indexOf(houndCall) >= 0) return; + + QString houndGrid=line.split(" ",QString::SkipEmptyParts).at(1); // Hound caller's grid + QString rpt=line.split(" ",QString::SkipEmptyParts).at(2); // Hound SNR + + m_houndCallers=m_houndCallers.remove(line+"\n"); // Remove t from sorted Hound list + m_nSortedHounds--; + ui->decodedTextBrowser->setText(m_houndCallers); // Populate left window with Hound callers + QString t1=houndCall + " "; + QString t2=rpt; + if(rpt.mid(0,1) != "-" and rpt.mid(0,1) != "+") t2="+" + rpt; + if(t2.length()==2) t2=t2.mid(0,1) + "0" + t2.mid(1,1); + t1=t1.mid(0,12) + t2; + ui->textBrowser4->displayFoxToBeCalled(t1); // Add hound call and rpt to tb4 + t1=t1 + " " + houndGrid; // Append the grid + m_houndQueue.enqueue(t1); // Put this hound into the queue + writeFoxQSO(" Sel: " + t1); + QTextCursor cursor = ui->textBrowser4->textCursor(); + cursor.setPosition(0); // Scroll to top of list + ui->textBrowser4->setTextCursor(cursor); +} + +//------------------------------------------------------------------------------ +void MainWindow::houndCallers() +{ +/* Called from decodeDone(), in DXpedition Fox mode. Reads decodes from file + * "houndcallers.txt", ignoring any that are not addressed to MyCall, are already + * in the stack, or with whom a QSO has been started. Others are considered to + * be Hounds eager for a QSO. We add caller information (Call, Grid, SNR, Freq, + * Distance, Age, and Continent) to a list, sort the list by specified criteria, + * and display the top N_Hounds entries in the left text window. +*/ + QFile f(m_config.temp_dir().absoluteFilePath("houndcallers.txt")); + if(f.open(QIODevice::ReadOnly | QIODevice::Text)) { + QTextStream s(&f); + QString t=""; + QString line,houndCall,paddedHoundCall; + m_nHoundsCalling=0; + int nTotal=0; //Total number of decoded Hounds calling Fox in 4 most recent Rx sequences + +// Read and process the file of Hound callers. + while(!s.atEnd()) { + line=s.readLine(); + nTotal++; + int i0=line.indexOf(" "); + houndCall=line.mid(0,i0); + paddedHoundCall=houndCall + " "; + //Don't list a hound already in the queue + if(!ui->textBrowser4->toPlainText().contains(paddedHoundCall)) { + if(m_loggedByFox[houndCall].contains(m_lastBand)) continue; //already logged on this band + if(m_foxQSO.contains(houndCall)) continue; //still in the QSO map + auto const& entity = m_logBook.countries ().lookup (houndCall); + auto const& continent = AD1CCty::continent (entity.continent); + +//If we are using a directed CQ, ignore Hound calls that do not comply. + QString CQtext=ui->comboBoxCQ->currentText(); + if(CQtext.length()==5 and (continent!=CQtext.mid(3,2))) continue; + int nCallArea=-1; + if(CQtext.length()==4) { + for(int i=houndCall.length()-1; i>0; i--) { + if(houndCall.mid(i,1).toInt() > 0) nCallArea=houndCall.mid(i,1).toInt(); + if(houndCall.mid(i,1)=="0") nCallArea=0; + if(nCallArea>=0) break; + } + if(nCallArea!=CQtext.mid(3,1).toInt()) continue; + } +//This houndCall passes all tests, add it to the list. + t = t + line + " " + continent + "\n"; + m_nHoundsCalling++; // Number of accepted Hounds to be sorted + } + } + if(m_foxLogWindow) m_foxLogWindow->callers (nTotal); + +// Sort and display accumulated list of Hound callers + if(t.length()>30) { + m_isort=ui->comboBoxHoundSort->currentIndex(); + QString t1=sortHoundCalls(t,m_isort,m_max_dB); + ui->decodedTextBrowser->setText(t1); + } + f.close(); + } +} + +void MainWindow::foxRxSequencer(QString msg, QString houndCall, QString rptRcvd) +{ +/* Called from "readFromStdOut()" to process decoded messages of the form + * "myCall houndCall R+rpt". + * + * If houndCall matches a callsign in one of our active QSO slots, we + * prepare to send "houndCall RR73" to that caller. +*/ + if(m_foxQSO.contains(houndCall)) { + m_foxQSO[houndCall].rcvd=rptRcvd.mid(1); //Save report Rcvd, for the log + m_foxQSO[houndCall].tFoxRrpt=m_tFoxTx; //Save time R+rpt was received + writeFoxQSO(" Rx: " + msg.trimmed()); + } else { + for(QString hc: m_foxQSO.keys()) { //Check for a matching compound call + if(hc.contains("/"+houndCall) or hc.contains(houndCall+"/")) { + m_foxQSO[hc].rcvd=rptRcvd.mid(1); //Save report Rcvd, for the log + m_foxQSO[hc].tFoxRrpt=m_tFoxTx; //Save time R+rpt was received + writeFoxQSO(" Rx: " + msg.trimmed()); + } + } + } +} + +void MainWindow::foxTxSequencer() +{ +/* Called from guiUpdate at the point where an FT8 Fox-mode transmission + * is to be started. + * + * Determine what the Tx message(s) will be for each active slot, call + * foxgen() to generate and accumulate the corresponding waveform. +*/ + + qint64 now=QDateTime::currentMSecsSinceEpoch()/1000; + QStringList list1; //Up to NSlots Hound calls to be sent RR73 + QStringList list2; //Up to NSlots Hound calls to be sent a report + QString fm; //Fox message to be transmitted + QString hc,hc1,hc2; //Hound calls + QString t,rpt; + qint32 islot=0; + qint32 n1,n2,n3; + + m_tFoxTx++; //Increment Fox Tx cycle counter + + //Is it time for a stand-alone CQ? + if(m_tFoxTxSinceCQ >= m_foxCQtime and ui->cbMoreCQs->isChecked()) { + fm=ui->comboBoxCQ->currentText() + " " + m_config.my_callsign(); + if(!fm.contains("/")) { + //If Fox is not a compound callsign, add grid to the CQ message. + fm += " " + m_config.my_grid().mid(0,4); + m_fullFoxCallTime=now; + } + m_tFoxTx0=m_tFoxTx; //Remember when we sent a CQ + islot++; + foxGenWaveform(islot-1,fm); + goto Transmit; + } +//Compile list1: up to NSLots Hound calls to be sent RR73 + for(QString hc: m_foxQSO.keys()) { //Check all Hound calls: First priority + if(m_foxQSO[hc].tFoxRrpt<0) continue; + if(m_foxQSO[hc].tFoxRrpt - m_foxQSO[hc].tFoxTxRR73 > 3) { + //Has been a long time since we sent RR73 + list1 << hc; //Add to list1 + m_foxQSO[hc].tFoxTxRR73 = m_tFoxTx; //Time RR73 is sent + m_foxQSO[hc].nRR73++; //Increment RR73 counter + if(list1.size()==m_Nslots) goto list1Done; + } + } + + for(QString hc: m_foxQSO.keys()) { //Check all Hound calls: Second priority + if(m_foxQSO[hc].tFoxRrpt<0) continue; + if(m_foxQSO[hc].tFoxTxRR73 < 0) { + //Have not yet sent RR73 + list1 << hc; //Add to list1 + m_foxQSO[hc].tFoxTxRR73 = m_tFoxTx; //Time RR73 is sent + m_foxQSO[hc].nRR73++; //Increment RR73 counter + if(list1.size()==m_Nslots) goto list1Done; + } + } + + for(QString hc: m_foxQSO.keys()) { //Check all Hound calls: Third priority + if(m_foxQSO[hc].tFoxRrpt<0) continue; + if(m_foxQSO[hc].tFoxTxRR73 <= m_foxQSO[hc].tFoxRrpt) { + //We received R+rpt more recently than we sent RR73 + list1 << hc; //Add to list1 + m_foxQSO[hc].tFoxTxRR73 = m_tFoxTx; //Time RR73 is sent + m_foxQSO[hc].nRR73++; //Increment RR73 counter + if(list1.size()==m_Nslots) goto list1Done; + } + } + +list1Done: +//Compile list2: Up to Nslots Hound calls to be sent a report. + for(int i=0; i<m_foxQSOinProgress.count(); i++) { + //First do those for QSOs in progress + hc=m_foxQSOinProgress.at(i); + if((m_foxQSO[hc].tFoxRrpt < 0) and (m_foxQSO[hc].ncall < m_maxStrikes)) { + //Sent him a report and have not received R+rpt: call him again + list2 << hc; //Add to list2 + if(list2.size()==m_Nslots) goto list2Done; + } + } + + while(!m_houndQueue.isEmpty()) { + //Start QSO with a new Hound + t=m_houndQueue.dequeue(); //Fetch new hound from queue + int i0=t.indexOf(" "); + hc=t.mid(0,i0); //hound call + list2 << hc; //Add new Hound to list2 + m_foxQSOinProgress.enqueue(hc); //Put him in the QSO queue + m_foxQSO[hc].grid=t.mid(16,4); //Hound grid + rpt=t.mid(12,3); //report to send Hound + m_foxQSO[hc].sent=rpt; //Report to send him + m_foxQSO[hc].ncall=0; //Start a new Hound + m_foxQSO[hc].nRR73 = 0; //Have not sent RR73 + m_foxQSO[hc].rcvd = -99; //Have not received R+rpt + m_foxQSO[hc].tFoxRrpt = -1; //Have not received R+rpt + m_foxQSO[hc].tFoxTxRR73 = -1; //Have not sent RR73 + rm_tb4(hc); //Remove this Hound from tb4 + if(list2.size()==m_Nslots) goto list2Done; + if(m_foxQSO.count()>=2*m_Nslots) goto list2Done; + } + +list2Done: + n1=list1.size(); + n2=list2.size(); + n3=qMax(n1,n2); + if(n3>m_Nslots) n3=m_Nslots; + for(int i=0; i<n3; i++) { + hc1=""; + fm=""; + if(i<n1 and i<n2) { + hc1=list1.at(i); + hc2=list2.at(i); + m_foxQSO[hc2].ncall++; + fm = Radio::base_callsign(hc1) + " RR73; " + Radio::base_callsign(hc2) + + " <" + m_config.my_callsign() + "> " + m_foxQSO[hc2].sent; + } + if(i<n1 and i>=n2) { + hc1=list1.at(i); + fm = Radio::base_callsign(hc1) + " " + m_baseCall + " RR73"; //Standard FT8 message + } + + if(hc1!="") { + // Log this QSO! + auto QSO_time = QDateTime::currentDateTimeUtc (); + m_hisCall=hc1; + m_hisGrid=m_foxQSO[hc1].grid; + m_rptSent=m_foxQSO[hc1].sent; + m_rptRcvd=m_foxQSO[hc1].rcvd; + if (!m_foxLog) m_foxLog.reset (new FoxLog); + if (!m_foxLogWindow) on_fox_log_action_triggered (); + if (m_foxLog->add_QSO (QSO_time, m_hisCall, m_hisGrid, m_rptSent, m_rptRcvd, m_lastBand)) + { + writeFoxQSO (QString {" Log: %1 %2 %3 %4 %5"}.arg (m_hisCall).arg (m_hisGrid) + .arg (m_rptSent).arg (m_rptRcvd).arg (m_lastBand)); + logQSOTimer.start(0); + m_foxRateQueue.enqueue (now); //Add present time in seconds + //to Rate queue. + } + m_loggedByFox[hc1] += (m_lastBand + " "); + } + + if(i<n2 and fm=="") { + hc2=list2.at(i); + m_foxQSO[hc2].ncall++; + fm = Radio::base_callsign(hc2) + " " + m_baseCall + " " + m_foxQSO[hc2].sent; //Standard FT8 message + } + islot++; + foxGenWaveform(islot-1,fm); //Generate tx waveform + } + + if(islot < m_Nslots) { + //At least one slot is still open + if(islot==0 or ((m_tFoxTx-m_tFoxTx0>=4) and ui->cbMoreCQs->isChecked())) { + //Roughly every 4th Tx sequence, put a CQ message in an otherwise empty slot + fm=ui->comboBoxCQ->currentText() + " " + m_config.my_callsign(); + if(!fm.contains("/")) { + fm += " " + m_config.my_grid().mid(0,4); + m_tFoxTx0=m_tFoxTx; //Remember when we send a CQ + m_fullFoxCallTime=now; + } + islot++; + foxGenWaveform(islot-1,fm); + } + } + +Transmit: + foxcom_.nslots=islot; + foxcom_.nfreq=ui->TxFreqSpinBox->value(); + if(m_config.split_mode()) foxcom_.nfreq = foxcom_.nfreq - m_XIT; //Fox Tx freq + QString foxCall=m_config.my_callsign() + " "; + strncpy(&foxcom_.mycall[0], foxCall.toLatin1(),12); //Copy Fox callsign into foxcom_ + foxgen_(); + m_tFoxTxSinceCQ++; + + for(QString hc: m_foxQSO.keys()) { //Check for strikeout or timeout + if(m_foxQSO[hc].ncall>=m_maxStrikes) m_foxQSO[hc].ncall++; + bool b1=((m_tFoxTx - m_foxQSO[hc].tFoxRrpt) > 2*m_maxFoxWait) and + (m_foxQSO[hc].tFoxRrpt > 0); + bool b2=((m_tFoxTx - m_foxQSO[hc].tFoxTxRR73) > m_maxFoxWait) and + (m_foxQSO[hc].tFoxTxRR73>0); + bool b3=(m_foxQSO[hc].ncall >= m_maxStrikes+m_maxFoxWait); + bool b4=(m_foxQSO[hc].nRR73 >= m_maxStrikes); + if(b1 or b2 or b3 or b4) { + m_foxQSO.remove(hc); + m_foxQSOinProgress.removeOne(hc); + } + } + + while(!m_foxRateQueue.isEmpty()) { + qint64 age = now - m_foxRateQueue.head(); + if(age < 3600) break; + m_foxRateQueue.dequeue(); + } + if (m_foxLogWindow) + { + m_foxLogWindow->rate (m_foxRateQueue.size ()); + m_foxLogWindow->queued (m_foxQSOinProgress.count ()); + } +} + +void MainWindow::rm_tb4(QString houndCall) +{ + if(houndCall=="") return; + QString t=""; + QString tb4=ui->textBrowser4->toPlainText(); + QStringList list=tb4.split("\n"); + int n=list.size(); + int j=0; + for (int i=0; i<n; i++) { + if(j>0) t += "\n"; + QString line=list.at(i); + if(!line.contains(houndCall + " ")) { + j++; + t += line; + } + } + t.replace("\n\n","\n"); + ui->textBrowser4->setText(t); +} + +void MainWindow::doubleClickOnFoxQueue(Qt::KeyboardModifiers modifiers) +{ + if(modifiers==9999) return; //Silence compiler warning + QTextCursor cursor=ui->textBrowser4->textCursor(); + cursor.setPosition(cursor.selectionStart()); + QString houndCall=cursor.block().text().mid(0,12).trimmed(); + rm_tb4(houndCall); + writeFoxQSO(" Del: " + houndCall); + QQueue<QString> tmpQueue; + while(!m_houndQueue.isEmpty()) { + QString t=m_houndQueue.dequeue(); + QString hc=t.mid(0,12).trimmed(); + if(hc != houndCall) tmpQueue.enqueue(t); + } + m_houndQueue.swap(tmpQueue); +} + +void MainWindow::foxGenWaveform(int i,QString fm) +{ +//Generate and accumulate the Tx waveform + fm += " "; + fm=fm.mid(0,40); + if(fm.mid(0,3)=="CQ ") m_tFoxTxSinceCQ=-1; + + QString txModeArg; + txModeArg.sprintf("FT8fox %d",i+1); + ui->decodedTextBrowser2->displayTransmittedText(fm.trimmed(), txModeArg, + ui->TxFreqSpinBox->value()+60*i,m_bFastMode); + foxcom_.i3bit[i]=0; + if(fm.indexOf("<")>0) foxcom_.i3bit[i]=1; + strncpy(&foxcom_.cmsg[i][0],fm.toLatin1(),40); //Copy this message into cmsg[i] + if(i==0) m_fm1=fm; + QString t; + t.sprintf(" Tx%d: ",i+1); + writeFoxQSO(t + fm.trimmed()); +} + +void MainWindow::writeFoxQSO(QString const& msg) +{ + QString t; + t.sprintf("%3d%3d%3d",m_houndQueue.count(),m_foxQSOinProgress.count(),m_foxQSO.count()); + QFile f {m_config.writeable_data_dir ().absoluteFilePath ("FoxQSO.txt")}; + if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) { + QTextStream out(&f); + out << QDateTime::currentDateTimeUtc().toString("yyyy-MM-dd hh:mm:ss") + << " " << fixed << qSetRealNumberPrecision (3) << (m_freqNominal/1.e6) + << t << msg << endl; + f.close(); + } else { + MessageBox::warning_message (this, tr("File Open Error"), + tr("Cannot open \"%1\" for append: %2").arg(f.fileName()).arg(f.errorString())); + } +} + +/*################################################################################### */ +void MainWindow::foxTest() +{ + QFile f("steps.txt"); + if(!f.open(QIODevice::ReadOnly | QIODevice::Text)) return; + + QFile fdiag("diag.txt"); + if(!fdiag.open(QIODevice::WriteOnly | QIODevice::Text)) return; + + QTextStream s(&f); + QTextStream sdiag(&fdiag); + QString line; + QString t; + QString msg; + QString hc1; + QString rptRcvd; + qint32 n=0; + + while(!s.atEnd()) { + line=s.readLine(); + if(line.length()==0) continue; + if(line.mid(0,4).toInt()==0) line=" " + line; + if(line.contains("NSlots")) { + n=line.mid(44,1).toInt(); + ui->sbNslots->setValue(n); + } + if(line.contains("Sel:")) { + t=line.mid(43,6) + " " + line.mid(54,4) + " " + line.mid(50,3); + selectHound(t); + } + + if(line.contains("Del:")) { + int i0=line.indexOf("Del:"); + hc1=line.mid(i0+6); + int i1=hc1.indexOf(" "); + hc1=hc1.mid(0,i1); + rm_tb4(hc1); + writeFoxQSO(" Del: " + hc1); + QQueue<QString> tmpQueue; + while(!m_houndQueue.isEmpty()) { + t=m_houndQueue.dequeue(); + QString hc=t.mid(0,6).trimmed(); + if(hc != hc1) tmpQueue.enqueue(t); + } + m_houndQueue.swap(tmpQueue); + } + if(line.contains("Rx:")) { + msg=line.mid(43); + t=msg.mid(24); + int i0=t.indexOf(" "); + hc1=t.mid(i0+1); + int i1=hc1.indexOf(" "); + hc1=hc1.mid(0,i1); + int i2=qMax(msg.indexOf("R+"),msg.indexOf("R-")); + if(i2>20) { + rptRcvd=msg.mid(i2,4); + foxRxSequencer(msg,hc1,rptRcvd); + } + } + if(line.contains("Tx1:")) { + foxTxSequencer(); + } else { + t.sprintf("%3d %3d %3d %3d %5d ",m_houndQueue.count(), + m_foxQSOinProgress.count(),m_foxQSO.count(), + m_loggedByFox.count(),m_tFoxTx); + sdiag << t << line.mid(37).trimmed() << "\n"; + } + } +} diff --git a/widgets/mainwindow.h b/widgets/mainwindow.h new file mode 100644 index 00000000..cfae4202 --- /dev/null +++ b/widgets/mainwindow.h @@ -0,0 +1,751 @@ +// -*- Mode: C++ -*- +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <QMainWindow> +#include <QLabel> +#include <QThread> +#include <QProcess> +#include <QProgressBar> +#include <QTimer> +#include <QDateTime> +#include <QList> +#include <QAudioDeviceInfo> +#include <QScopedPointer> +#include <QDir> +#include <QProgressDialog> +#include <QAbstractSocket> +#include <QHostAddress> +#include <QPointer> +#include <QSet> +#include <QVector> +#include <QFuture> +#include <QFutureWatcher> + +#include "AudioDevice.hpp" +#include "commons.h" +#include "Radio.hpp" +#include "models/Modes.hpp" +#include "models/FrequencyList.hpp" +#include "Configuration.hpp" +#include "WSPRBandHopping.hpp" +#include "Transceiver.hpp" +#include "DisplayManual.hpp" +#include "psk_reporter.h" +#include "logbook/logbook.h" +#include "astro.h" +#include "MessageBox.hpp" +#include "NetworkAccessManager.hpp" + +#define NUM_JT4_SYMBOLS 206 //(72+31)*2, embedded sync +#define NUM_JT65_SYMBOLS 126 //63 data + 63 sync +#define NUM_JT9_SYMBOLS 85 //69 data + 16 sync +#define NUM_WSPR_SYMBOLS 162 //(50+31)*2, embedded sync +#define NUM_WSPR_LF_SYMBOLS 412 //300 data + 109 sync + 3 ramp +#define NUM_ISCAT_SYMBOLS 1291 //30*11025/256 +#define NUM_MSK144_SYMBOLS 144 //s8 + d48 + s8 + d80 +#define NUM_QRA64_SYMBOLS 84 //63 data + 21 sync +#define NUM_FT8_SYMBOLS 79 +#define NUM_CW_SYMBOLS 250 +#define TX_SAMPLE_RATE 48000 +#define N_WIDGETS 33 + +extern int volatile itone[NUM_ISCAT_SYMBOLS]; //Audio tones for all Tx symbols +extern int volatile icw[NUM_CW_SYMBOLS]; //Dits for CW ID + +//--------------------------------------------------------------- MainWindow +namespace Ui { + class MainWindow; +} + +class QSharedMemory; +class QSplashScreen; +class QSettings; +class QLineEdit; +class QFont; +class QHostInfo; +class EchoGraph; +class FastGraph; +class WideGraph; +class LogQSO; +class Transceiver; +class MessageAveraging; +class FoxLog; +class FoxLogWindow; +class CabrilloLog; +class CabrilloLogWindow; +class ColorHighlighting; +class MessageClient; +class QTime; +class WSPRBandHopping; +class HelpTextWindow; +class WSPRNet; +class SoundOutput; +class Modulator; +class SoundInput; +class Detector; +class SampleDownloader; +class MultiSettings; +class EqualizationToolsDialog; +class DecodedText; + +class MainWindow : public QMainWindow +{ + Q_OBJECT; + +public: + using Frequency = Radio::Frequency; + using FrequencyDelta = Radio::FrequencyDelta; + using Mode = Modes::Mode; + + explicit MainWindow(QDir const& temp_directory, bool multiple, MultiSettings *, + QSharedMemory *shdmem, unsigned downSampleFactor, + QSplashScreen *, + QWidget *parent = nullptr); + ~MainWindow(); + + int decoderBusy () const {return m_decoderBusy;} + +public slots: + void showSoundInError(const QString& errorMsg); + void showSoundOutError(const QString& errorMsg); + void showStatusMessage(const QString& statusMsg); + void dataSink(qint64 frames); + void fastSink(qint64 frames); + void diskDat(); + void freezeDecode(int n); + void guiUpdate(); + void doubleClickOnCall (Qt::KeyboardModifiers); + void doubleClickOnCall2(Qt::KeyboardModifiers); + void doubleClickOnFoxQueue(Qt::KeyboardModifiers); + void readFromStdout(); + void p1ReadFromStdout(); + void setXIT(int n, Frequency base = 0u); + void setFreq4(int rxFreq, int txFreq); + void msgAvgDecode2(); + void fastPick(int x0, int x1, int y); + +protected: + void keyPressEvent (QKeyEvent *) override; + void closeEvent(QCloseEvent *) override; + void childEvent(QChildEvent *) override; + bool eventFilter(QObject *, QEvent *) override; + +private slots: + void initialize_fonts (); + void on_tx1_editingFinished(); + void on_tx2_editingFinished(); + void on_tx3_editingFinished(); + void on_tx4_editingFinished(); + void on_tx5_currentTextChanged (QString const&); + void on_tx6_editingFinished(); + void on_actionSettings_triggered(); + void on_monitorButton_clicked (bool); + void on_actionAbout_triggered(); + void on_autoButton_clicked (bool); + void on_stopTxButton_clicked(); + void on_stopButton_clicked(); + void on_actionRelease_Notes_triggered (); + void on_actionFT8_DXpedition_Mode_User_Guide_triggered(); + void on_actionQuick_Start_Guide_v2_triggered(); + void on_actionOnline_User_Guide_triggered(); + void on_actionLocal_User_Guide_triggered(); + void on_actionWide_Waterfall_triggered(); + void on_actionOpen_triggered(); + void on_actionOpen_next_in_directory_triggered(); + void on_actionDecode_remaining_files_in_directory_triggered(); + void on_actionDelete_all_wav_files_in_SaveDir_triggered(); + void on_actionOpen_log_directory_triggered (); + void on_actionNone_triggered(); + void on_actionSave_all_triggered(); + void on_actionKeyboard_shortcuts_triggered(); + void on_actionSpecial_mouse_commands_triggered(); + void on_actionSolve_FreqCal_triggered(); + void on_actionCopyright_Notice_triggered(); + void on_DecodeButton_clicked (bool); + void decode(); + void decodeBusy(bool b); + void on_EraseButton_clicked(); + void band_activity_cleared (); + void rx_frequency_activity_cleared (); + void on_txFirstCheckBox_stateChanged(int arg1); + void set_dateTimeQSO(int m_ntx); + void set_ntx(int n); + void on_txrb1_toggled(bool status); + void on_txrb1_doubleClicked (); + void on_txrb2_toggled(bool status); + void on_txrb3_toggled(bool status); + void on_txrb4_toggled(bool status); + void on_txrb4_doubleClicked (); + void on_txrb5_toggled(bool status); + void on_txrb5_doubleClicked (); + void on_txrb6_toggled(bool status); + void on_txb1_clicked(); + void on_txb1_doubleClicked (); + void on_txb2_clicked(); + void on_txb3_clicked(); + void on_txb4_clicked(); + void on_txb4_doubleClicked (); + void on_txb5_clicked(); + void on_txb5_doubleClicked (); + void on_txb6_clicked(); + void on_lookupButton_clicked(); + void on_addButton_clicked(); + void on_dxCallEntry_textChanged (QString const&); + void on_dxGridEntry_textChanged (QString const&); + void on_dxCallEntry_returnPressed (); + void on_genStdMsgsPushButton_clicked(); + void on_logQSOButton_clicked(); + void on_actionJT9_triggered(); + void on_actionJT65_triggered(); + void on_actionJT9_JT65_triggered(); + void on_actionJT4_triggered(); + void on_actionFT8_triggered(); + void on_TxFreqSpinBox_valueChanged(int arg1); + void on_actionSave_decoded_triggered(); + void on_actionQuickDecode_toggled (bool); + void on_actionMediumDecode_toggled (bool); + void on_actionDeepestDecode_toggled (bool); + void bumpFqso(int n); + void on_actionErase_ALL_TXT_triggered(); + void on_reset_cabrillo_log_action_triggered (); + void on_actionErase_wsjtx_log_adi_triggered(); + void on_actionExport_Cabrillo_log_triggered(); + void startTx2(); + void startP1(); + void stopTx(); + void stopTx2(); + void on_pbCallCQ_clicked(); + void on_pbAnswerCaller_clicked(); + void on_pbSendRRR_clicked(); + void on_pbAnswerCQ_clicked(); + void on_pbSendReport_clicked(); + void on_pbSend73_clicked(); + void on_rbGenMsg_clicked(bool checked); + void on_rbFreeText_clicked(bool checked); + void on_freeTextMsg_currentTextChanged (QString const&); + void on_rptSpinBox_valueChanged(int n); + void killFile(); + void on_tuneButton_clicked (bool); + void on_pbR2T_clicked(); + void on_pbT2R_clicked(); + void acceptQSO (QDateTime const&, QString const& call, QString const& grid + , Frequency dial_freq, QString const& mode + , QString const& rpt_sent, QString const& rpt_received + , QString const& tx_power, QString const& comments + , QString const& name, QDateTime const& QSO_date_on, QString const& operator_call + , QString const& my_call, QString const& my_grid + , QString const& exchange_sent, QString const& exchange_rcvd + , QByteArray const& ADIF); + void on_bandComboBox_currentIndexChanged (int index); + void on_bandComboBox_activated (int index); + void on_readFreq_clicked(); + void on_pbTxMode_clicked(); + void on_RxFreqSpinBox_valueChanged(int n); + void on_outAttenuation_valueChanged (int); + void rigOpen (); + void handle_transceiver_update (Transceiver::TransceiverState const&); + void handle_transceiver_failure (QString const& reason); + void on_actionAstronomical_data_toggled (bool); + void on_actionShort_list_of_add_on_prefixes_and_suffixes_triggered(); + void band_changed (Frequency); + void monitor (bool); + void stop_tuning (); + void stopTuneATU(); + void auto_tx_mode(bool); + void on_actionMessage_averaging_triggered(); + void on_contest_log_action_triggered (); + void on_fox_log_action_triggered (); + void on_actionColors_triggered(); + void on_actionInclude_averaging_toggled (bool); + void on_actionInclude_correlation_toggled (bool); + void on_actionEnable_AP_DXcall_toggled (bool); + void VHF_features_enabled(bool b); + void on_sbSubmode_valueChanged(int n); + void on_cbShMsgs_toggled(bool b); + void on_cbSWL_toggled(bool b); + void on_cbTx6_toggled(bool b); + void on_cbMenus_toggled(bool b); + void on_cbCQonly_toggled(bool b); + void on_cbFirst_toggled(bool b); + void on_cbAutoSeq_toggled(bool b); + void networkError (QString const&); + void on_ClrAvgButton_clicked(); + void on_actionWSPR_triggered(); + void on_actionWSPR_LF_triggered(); + void on_syncSpinBox_valueChanged(int n); + void on_TxPowerComboBox_currentIndexChanged(const QString &arg1); + void on_sbTxPercent_valueChanged(int n); + void on_cbUploadWSPR_Spots_toggled(bool b); + void WSPR_config(bool b); + void uploadSpots(); + void TxAgain(); + void uploadResponse(QString response); + void on_WSPRfreqSpinBox_valueChanged(int n); + void on_pbTxNext_clicked(bool b); + void on_actionEcho_Graph_triggered(); + void on_actionEcho_triggered(); + void on_actionISCAT_triggered(); + void on_actionFast_Graph_triggered(); + void fast_decode_done(); + void on_actionMeasure_reference_spectrum_triggered(); + void on_actionErase_reference_spectrum_triggered(); + void on_actionMeasure_phase_response_triggered(); + void on_sbTR_valueChanged (int); + void on_sbFtol_valueChanged (int); + void on_cbFast9_clicked(bool b); + void on_sbCQTxFreq_valueChanged(int n); + void on_cbCQTx_toggled(bool b); + void on_actionMSK144_triggered(); + void on_actionQRA64_triggered(); + void on_actionFreqCal_triggered(); + void splash_done (); + void on_measure_check_box_stateChanged (int); + void on_sbNlist_valueChanged(int n); + void on_sbNslots_valueChanged(int n); + void on_sbMax_dB_valueChanged(int n); + void on_pbFoxReset_clicked(); + void on_comboBoxHoundSort_activated (int index); + void not_GA_warning_message (); + void checkMSK144ContestType(); + int setTxMsg(int n); + bool stdCall(QString const& w); + +private: + Q_SIGNAL void initializeAudioOutputStream (QAudioDeviceInfo, + unsigned channels, unsigned msBuffered) const; + Q_SIGNAL void stopAudioOutputStream () const; + Q_SIGNAL void startAudioInputStream (QAudioDeviceInfo const&, + int framesPerBuffer, AudioDevice * sink, + unsigned downSampleFactor, AudioDevice::Channel) const; + Q_SIGNAL void suspendAudioInputStream () const; + Q_SIGNAL void resumeAudioInputStream () const; + Q_SIGNAL void startDetector (AudioDevice::Channel) const; + Q_SIGNAL void FFTSize (unsigned) const; + Q_SIGNAL void detectorClose () const; + Q_SIGNAL void finished () const; + Q_SIGNAL void transmitFrequency (double) const; + Q_SIGNAL void endTransmitMessage (bool quick = false) const; + Q_SIGNAL void tune (bool = true) const; + Q_SIGNAL void sendMessage (unsigned symbolsLength, double framesPerSymbol, + double frequency, double toneSpacing, + SoundOutput *, AudioDevice::Channel = AudioDevice::Mono, + bool synchronize = true, bool fastMode = false, double dBSNR = 99., + int TRperiod=60) const; + Q_SIGNAL void outAttenuationChanged (qreal) const; + Q_SIGNAL void toggleShorthand () const; + +private: + void astroUpdate (); + void writeAllTxt(QString message); + void auto_sequence (DecodedText const& message, unsigned start_tolerance, unsigned stop_tolerance); + void hideMenus(bool b); + void foxTest(); + void setColorHighlighting(); + + NetworkAccessManager m_network_manager; + bool m_valid; + QSplashScreen * m_splash; + QString m_revision; + bool m_multiple; + MultiSettings * m_multi_settings; + QPushButton * m_configurations_button; + QSettings * m_settings; + QScopedPointer<Ui::MainWindow> ui; + + LogBook m_logBook; // must be before Configuration construction + Configuration m_config; + WSPRBandHopping m_WSPR_band_hopping; + bool m_WSPR_tx_next; + MessageBox m_rigErrorMessageBox; + QScopedPointer<SampleDownloader> m_sampleDownloader; + QScopedPointer<EqualizationToolsDialog> m_equalizationToolsDialog; + + QScopedPointer<WideGraph> m_wideGraph; + QScopedPointer<EchoGraph> m_echoGraph; + QScopedPointer<FastGraph> m_fastGraph; + QScopedPointer<LogQSO> m_logDlg; + QScopedPointer<Astro> m_astroWidget; + QScopedPointer<HelpTextWindow> m_shortcuts; + QScopedPointer<HelpTextWindow> m_prefixes; + QScopedPointer<HelpTextWindow> m_mouseCmnds; + QScopedPointer<MessageAveraging> m_msgAvgWidget; + QScopedPointer<FoxLog> m_foxLog; + QScopedPointer<FoxLogWindow> m_foxLogWindow; + QScopedPointer<CabrilloLog> m_cabrilloLog; + QScopedPointer<CabrilloLogWindow> m_contestLogWindow; + QScopedPointer<ColorHighlighting> m_colorHighlighting; + Transceiver::TransceiverState m_rigState; + Frequency m_lastDialFreq; + QString m_lastBand; + QString m_lastCallsign; + Frequency m_dialFreqRxWSPR; // best guess at WSPR QRG + + Detector * m_detector; + unsigned m_FFTSize; + SoundInput * m_soundInput; + Modulator * m_modulator; + SoundOutput * m_soundOutput; + QThread m_audioThread; + + qint64 m_msErase; + qint64 m_secBandChanged; + qint64 m_freqMoon; + qint64 m_msec0; + qint64 m_fullFoxCallTime; + + Frequency m_freqNominal; + Frequency m_freqTxNominal; + Astro::Correction m_astroCorrection; + + double m_s6; + double m_tRemaining; + + float m_DTtol; + float m_t0; + float m_t1; + float m_t0Pick; + float m_t1Pick; + float m_fCPUmskrtd; + + qint32 m_waterfallAvg; + qint32 m_ntx; + bool m_gen_message_is_cq; + bool m_send_RR73; + qint32 m_timeout; + qint32 m_XIT; + qint32 m_setftx; + qint32 m_ndepth; + qint32 m_sec0; + qint32 m_RxLog; + qint32 m_nutc0; + qint32 m_ntr; + qint32 m_tx; + qint32 m_hsym; + qint32 m_TRperiod; + qint32 m_nsps; + qint32 m_hsymStop; + qint32 m_inGain; + qint32 m_ncw; + qint32 m_secID; + qint32 m_idleMinutes; + qint32 m_nSubMode; + qint32 m_nclearave; + qint32 m_minSync; + qint32 m_dBm; + qint32 m_pctx; + qint32 m_nseq; + qint32 m_nWSPRdecodes; + qint32 m_k0; + qint32 m_kdone; + qint32 m_nPick; + FrequencyList_v2::const_iterator m_frequency_list_fcal_iter; + qint32 m_nTx73; + qint32 m_UTCdisk; + qint32 m_wait; + qint32 m_isort; + qint32 m_max_dB; + qint32 m_nDXped=0; + qint32 m_nSortedHounds=0; + qint32 m_nHoundsCalling=0; + qint32 m_Nlist=12; + qint32 m_Nslots=5; + qint32 m_nFoxMsgTimes[5]={0,0,0,0,0}; + qint32 m_tAutoOn; + qint32 m_tFoxTx=0; + qint32 m_tFoxTx0=0; + qint32 m_maxStrikes=3; //Max # of repeats: 3 strikes and you're out + qint32 m_maxFoxWait=3; //Max wait time for expected Hound replies + qint32 m_foxCQtime=10; //CQs at least every 5 minutes + qint32 m_tFoxTxSinceCQ=999; //Fox Tx cycles since most recent CQ + qint32 m_nFoxFreq; //Audio freq at which Hound received a call from Fox + qint32 m_nSentFoxRrpt=0; //Serial number for next R+rpt Hound will send to Fox + + bool m_btxok; //True if OK to transmit + bool m_diskData; + bool m_loopall; + bool m_decoderBusy; + bool m_txFirst; + bool m_auto; + bool m_restart; + bool m_startAnother; + bool m_saveDecoded; + bool m_saveAll; + bool m_widebandDecode; + bool m_call3Modified; + bool m_dataAvailable; + bool m_bDecoded; + bool m_noSuffix; + bool m_blankLine; + bool m_decodedText2; + bool m_freeText; + bool m_sentFirst73; + int m_currentMessageType; + QString m_currentMessage; + int m_lastMessageType; + QString m_lastMessageSent; + bool m_bShMsgs; + bool m_bSWL; + bool m_uploadSpots; + bool m_uploading; + bool m_txNext; + bool m_grid6; + bool m_tuneup; + bool m_bTxTime; + bool m_rxDone; + bool m_bSimplex; // not using split even if it is available + bool m_bEchoTxOK; + bool m_bTransmittedEcho; + bool m_bEchoTxed; + bool m_bFastMode; + bool m_bFast9; + bool m_bFastDecodeCalled; + bool m_bDoubleClickAfterCQnnn; + bool m_bRefSpec; + bool m_bClearRefSpec; + bool m_bTrain; + bool m_bUseRef; + bool m_bFastDone; + bool m_bAltV; + bool m_bNoMoreFiles; + bool m_bDoubleClicked; + bool m_bCallingCQ; + bool m_bAutoReply; + bool m_bCheckedContest; + bool m_bWarnedSplit=false; + bool m_bTUmsg; + + enum + { + CALLING, + REPLYING, + REPORT, + ROGER_REPORT, + ROGERS, + SIGNOFF + } + m_QSOProgress; //State machine counter + + enum {CALL, GRID, DXCC, MULT}; + + int m_ihsym; + int m_nzap; + int m_npts8; + float m_px; + float m_pxmax; + float m_df3; + int m_iptt0; + bool m_btxok0; + int m_nsendingsh; + double m_onAirFreq0; + bool m_first_error; + + char m_msg[100][80]; + + // labels in status bar + QLabel tx_status_label; + QLabel config_label; + QLabel mode_label; + QLabel last_tx_label; + QLabel auto_tx_label; + QLabel band_hopping_label; + QProgressBar progressBar; + QLabel watchdog_label; + + QFuture<void> m_wav_future; + QFutureWatcher<void> m_wav_future_watcher; + QFutureWatcher<void> watcher3; + QFutureWatcher<QString> m_saveWAVWatcher; + + QProcess proc_jt9; + QProcess p1; + QProcess p3; + + WSPRNet *wsprNet; + + QTimer m_guiTimer; + QTimer ptt1Timer; //StartTx delay + QTimer ptt0Timer; //StopTx delay + QTimer logQSOTimer; + QTimer killFileTimer; + QTimer tuneButtonTimer; + QTimer uploadTimer; + QTimer tuneATU_Timer; + QTimer TxAgainTimer; + QTimer minuteTimer; + QTimer splashTimer; + QTimer p1Timer; + + QString m_path; + QString m_baseCall; + QString m_hisCall; + QString m_hisGrid; + QString m_appDir; + QString m_palette; + QString m_dateTime; + QString m_mode; + QString m_modeTx; + QString m_fnameWE; // save path without extension + QString m_rpt; + QString m_nextRpt; + QString m_rptSent; + QString m_rptRcvd; + QString m_qsoStart; + QString m_qsoStop; + QString m_cmnd; + QString m_cmndP1; + QString m_msgSent0; + QString m_fileToSave; + QString m_calls; + QString m_CQtype; + QString m_opCall; + QString m_houndCallers; //Sorted list of Hound callers + QString m_fm0; + QString m_fm1; + QString m_xSent; //Contest exchange sent + QString m_xRcvd; //Contest exchange received + QString m_currentBand; + QString m_nextCall; + QString m_nextGrid; + + QSet<QString> m_pfx; + QSet<QString> m_sfx; + + struct FoxQSO //Everything we need to know about QSOs in progress (or recently logged). + { + QString grid; //Hound's declared locator + QString sent; //Report sent to Hound + QString rcvd; //Report received from Hound + qint32 ncall; //Number of times report sent to Hound + qint32 nRR73; //Number of times RR73 sent to Hound + qint32 tFoxRrpt; //m_tFoxTx (Fox Tx cycle counter) when R+rpt was received from Hound + qint32 tFoxTxRR73; //m_tFoxTx when RR73 was sent to Hound + }; + + QMap<QString,FoxQSO> m_foxQSO; //Key = HoundCall, value = parameters for QSO in progress + QMap<QString,QString> m_loggedByFox; //Key = HoundCall, value = logged band + + QQueue<QString> m_houndQueue; //Selected Hounds available for starting a QSO + QQueue<QString> m_foxQSOinProgress; //QSOs in progress: Fox has sent a report + QQueue<qint64> m_foxRateQueue; + + QDateTime m_dateTimeQSOOn; + QDateTime m_dateTimeLastTX; + + QSharedMemory *mem_jt9; + QString m_QSOText; + unsigned m_msAudioOutputBuffered; + unsigned m_framesAudioInputBuffered; + unsigned m_downSampleFactor; + QThread::Priority m_audioThreadPriority; + bool m_bandEdited; + bool m_splitMode; + bool m_monitoring; + bool m_tx_when_ready; + bool m_transmitting; + bool m_tune; + bool m_tx_watchdog; // true when watchdog triggered + bool m_block_pwr_tooltip; + bool m_PwrBandSetOK; + bool m_bVHFwarned; + bool m_bDisplayedOnce; + Frequency m_lastMonitoredFrequency; + double m_toneSpacing; + int m_firstDecode; + QProgressDialog m_optimizingProgress; + QTimer m_heartbeat; + MessageClient * m_messageClient; + PSK_Reporter *psk_Reporter; + DisplayManual m_manual; + QHash<QString, QVariant> m_pwrBandTxMemory; // Remembers power level by band + QHash<QString, QVariant> m_pwrBandTuneMemory; // Remembers power level by band for tuning + QByteArray m_geometryNoControls; + QVector<double> m_phaseEqCoefficients; + + //---------------------------------------------------- private functions + void readSettings(); + void set_application_font (QFont const&); + void setDecodedTextFont (QFont const&); + void writeSettings(); + void createStatusBar(); + void updateStatusBar(); + void genStdMsgs(QString rpt, bool unconditional = false); + void genCQMsg(); + void clearDX (); + void lookup(); + void ba2msg(QByteArray ba, char* message); + void msgtype(QString t, QLineEdit* tx); + void stub(); + void statusChanged(); + void fixStop(); + bool shortList(QString callsign); + void transmit (double snr = 99.); + void rigFailure (QString const& reason); + void pskSetLocal (); + void pskPost(DecodedText const& decodedtext); + void displayDialFrequency (); + void transmitDisplay (bool); + void processMessage(DecodedText const&, Qt::KeyboardModifiers = 0); + void replyToCQ (QTime, qint32 snr, float delta_time, quint32 delta_frequency, QString const& mode, QString const& message_text, bool low_confidence, quint8 modifiers); + void locationChange(QString const& location); + void replayDecodes (); + void postDecode (bool is_new, QString const& message); + void postWSPRDecode (bool is_new, QStringList message_parts); + void enable_DXCC_entity (bool on); + void switch_mode (Mode); + void WSPR_scheduling (); + void freqCalStep(); + void setRig (Frequency = 0); // zero frequency means no change + void WSPR_history(Frequency dialFreq, int ndecodes); + QString WSPR_hhmm(int n); + void fast_config(bool b); + void CQTxFreq(); + void useNextCall(); + void abortQSO(); + bool isWorked(int itype, QString key, float fMHz=0, QString=""); + + QString save_wave_file (QString const& name + , short const * data + , int seconds + , QString const& my_callsign + , QString const& my_grid + , QString const& mode + , qint32 sub_mode + , Frequency frequency + , QString const& his_call + , QString const& his_grid) const; + void hound_reply (); + QString sortHoundCalls(QString t, int isort, int max_dB); + void rm_tb4(QString houndCall); + void read_wav_file (QString const& fname); + void decodeDone (); + void subProcessFailed (QProcess *, int exit_code, QProcess::ExitStatus); + void subProcessError (QProcess *, QProcess::ProcessError); + void statusUpdate () const; + void update_watchdog_label (); + void on_the_minute (); + void add_child_to_event_filter (QObject *); + void remove_child_from_event_filter (QObject *); + void setup_status_bar (bool vhf); + void tx_watchdog (bool triggered); + qint64 nWidgets(QString t); + void displayWidgets(qint64 n); + void vhfWarning(); + QChar current_submode () const; // returns QChar {0} if sub mode is + // not appropriate + void write_transmit_entry (QString const& file_name); + void selectHound(QString t); + void houndCallers(); + void foxRxSequencer(QString msg, QString houndCall, QString rptRcvd); + void foxTxSequencer(); + void foxGenWaveform(int i,QString fm); + void writeFoxQSO (QString const& msg); +}; + +extern int killbyname(const char* progName); +extern void getDev(int* numDevices,char hostAPI_DeviceName[][50], + int minChan[], int maxChan[], + int minSpeed[], int maxSpeed[]); +extern int next_tx_state(int pctx); + +#endif // MAINWINDOW_H diff --git a/widgets/mainwindow.ui b/widgets/mainwindow.ui new file mode 100644 index 00000000..21799434 --- /dev/null +++ b/widgets/mainwindow.ui @@ -0,0 +1,3485 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>805</width> + <height>555</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Ignored" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="windowTitle"> + <string>WSJT-X by K1JT</string> + </property> + <property name="styleSheet"> + <string notr="true"/> + </property> + <widget class="QWidget" name="centralWidget"> + <layout class="QVBoxLayout" name="verticalLayout_6" stretch="1,0,0"> + <item> + <widget class="QSplitter" name="splitter"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <widget class="QWidget" name="layoutWidget"> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <widget class="QLabel" name="label_6"> + <property name="maximumSize"> + <size> + <width>500</width> + <height>16777215</height> + </size> + </property> + <property name="font"> + <font> + <pointsize>10</pointsize> + <weight>50</weight> + <bold>false</bold> + </font> + </property> + <property name="text"> + <string>Band Activity</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="decodedTextLabel"> + <property name="minimumSize"> + <size> + <width>300</width> + <height>20</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>20</height> + </size> + </property> + <property name="palette"> + <palette> + <active> + <colorrole role="Base"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>252</red> + <green>252</green> + <blue>252</blue> + </color> + </brush> + </colorrole> + <colorrole role="Window"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>170</red> + <green>170</green> + <blue>170</blue> + </color> + </brush> + </colorrole> + </active> + <inactive> + <colorrole role="Base"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>252</red> + <green>252</green> + <blue>252</blue> + </color> + </brush> + </colorrole> + <colorrole role="Window"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>170</red> + <green>170</green> + <blue>170</blue> + </color> + </brush> + </colorrole> + </inactive> + <disabled> + <colorrole role="Base"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>170</red> + <green>170</green> + <blue>170</blue> + </color> + </brush> + </colorrole> + <colorrole role="Window"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>170</red> + <green>170</green> + <blue>170</blue> + </color> + </brush> + </colorrole> + </disabled> + </palette> + </property> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="text"> + <string>UTC dB DT Freq Dr </string> + </property> + <property name="textFormat"> + <enum>Qt::PlainText</enum> + </property> + <property name="indent"> + <number>5</number> + </property> + </widget> + </item> + <item> + <widget class="DisplayText" name="decodedTextBrowser"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>10</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>200</width> + <height>100</height> + </size> + </property> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="verticalScrollBarPolicy"> + <enum>Qt::ScrollBarAlwaysOn</enum> + </property> + <property name="horizontalScrollBarPolicy"> + <enum>Qt::ScrollBarAsNeeded</enum> + </property> + <property name="cursorWidth"> + <number>0</number> + </property> + <property name="textInteractionFlags"> + <set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="layoutWidget_1"> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="label_7"> + <property name="font"> + <font> + <pointsize>10</pointsize> + <weight>50</weight> + <bold>false</bold> + </font> + </property> + <property name="text"> + <string>Rx Frequency</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="decodedTextLabel2"> + <property name="minimumSize"> + <size> + <width>300</width> + <height>20</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>20</height> + </size> + </property> + <property name="palette"> + <palette> + <active> + <colorrole role="Base"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>252</red> + <green>252</green> + <blue>252</blue> + </color> + </brush> + </colorrole> + <colorrole role="Window"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>170</red> + <green>170</green> + <blue>170</blue> + </color> + </brush> + </colorrole> + </active> + <inactive> + <colorrole role="Base"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>252</red> + <green>252</green> + <blue>252</blue> + </color> + </brush> + </colorrole> + <colorrole role="Window"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>170</red> + <green>170</green> + <blue>170</blue> + </color> + </brush> + </colorrole> + </inactive> + <disabled> + <colorrole role="Base"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>170</red> + <green>170</green> + <blue>170</blue> + </color> + </brush> + </colorrole> + <colorrole role="Window"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>170</red> + <green>170</green> + <blue>170</blue> + </color> + </brush> + </colorrole> + </disabled> + </palette> + </property> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="text"> + <string>UTC dB DT Freq Dr </string> + </property> + <property name="textFormat"> + <enum>Qt::PlainText</enum> + </property> + <property name="indent"> + <number>5</number> + </property> + </widget> + </item> + <item> + <widget class="DisplayText" name="decodedTextBrowser2"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> + <horstretch>0</horstretch> + <verstretch>10</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>200</width> + <height>100</height> + </size> + </property> + <property name="verticalScrollBarPolicy"> + <enum>Qt::ScrollBarAlwaysOn</enum> + </property> + <property name="cursorWidth"> + <number>0</number> + </property> + <property name="textInteractionFlags"> + <set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set> + </property> + </widget> + </item> + </layout> + </widget> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,2,2,2,2,2,2,2,2,2,1"> + <item> + <widget class="QCheckBox" name="cbCQonly"> + <property name="text"> + <string>CQ only</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="logQSOButton"> + <property name="minimumSize"> + <size> + <width>50</width> + <height>0</height> + </size> + </property> + <property name="toolTip"> + <string><html><head/><body><p>Enter this QSO in log</p></body></html></string> + </property> + <property name="text"> + <string>Log &QSO</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="stopButton"> + <property name="minimumSize"> + <size> + <width>50</width> + <height>0</height> + </size> + </property> + <property name="toolTip"> + <string>Stop monitoring</string> + </property> + <property name="text"> + <string>&Stop</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="monitorButton"> + <property name="minimumSize"> + <size> + <width>50</width> + <height>0</height> + </size> + </property> + <property name="toolTip"> + <string><html><head/><body><p>Toggle monitoring On/Off</p></body></html></string> + </property> + <property name="styleSheet"> + <string notr="true">QPushButton:checked { + background-color: #00ff00; + border-style: outset; + border-width: 1px; + border-radius: 5px; + border-color: black; + min-width: 5em; + padding: 3px; +}</string> + </property> + <property name="text"> + <string>&Monitor</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="EraseButton"> + <property name="minimumSize"> + <size> + <width>50</width> + <height>0</height> + </size> + </property> + <property name="toolTip"> + <string><html><head/><body><p>Erase right window. Double-click to erase both windows.</p></body></html></string> + </property> + <property name="text"> + <string>&Erase</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="ClrAvgButton"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="toolTip"> + <string><html><head/><body><p>Clear the accumulating message average.</p></body></html></string> + </property> + <property name="text"> + <string>Clear Avg</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="DecodeButton"> + <property name="minimumSize"> + <size> + <width>50</width> + <height>0</height> + </size> + </property> + <property name="toolTip"> + <string><html><head/><body><p>Decode most recent Rx period at QSO Frequency</p></body></html></string> + </property> + <property name="styleSheet"> + <string notr="true">QPushButton:checked { + background-color: cyan; + border-style: outset; + border-width: 1px; + border-radius: 5px; + border-color: black; + min-width: 5em; + padding: 3px; +}</string> + </property> + <property name="text"> + <string>&Decode</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="autoButton"> + <property name="minimumSize"> + <size> + <width>50</width> + <height>0</height> + </size> + </property> + <property name="toolTip"> + <string><html><head/><body><p>Toggle Auto-Tx On/Off</p></body></html></string> + </property> + <property name="styleSheet"> + <string notr="true">QPushButton:checked { + background-color: red; + border-style: outset; + border-width: 1px; + border-radius: 5px; + border-color: black; + min-width: 5em; + padding: 3px; +}</string> + </property> + <property name="text"> + <string>E&nable Tx</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="stopTxButton"> + <property name="minimumSize"> + <size> + <width>50</width> + <height>0</height> + </size> + </property> + <property name="toolTip"> + <string>Stop transmitting immediately</string> + </property> + <property name="text"> + <string>&Halt Tx</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="tuneButton"> + <property name="toolTip"> + <string><html><head/><body><p>Toggle a pure Tx tone On/Off</p></body></html></string> + </property> + <property name="styleSheet"> + <string notr="true">QPushButton:checked { + background-color: red; + border-style: outset; + border-width: 1px; + border-radius: 5px; + border-color: black; + min-width: 5em; + padding: 3px; +}</string> + </property> + <property name="text"> + <string>&Tune</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="cbMenus"> + <property name="text"> + <string>Menus</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QGridLayout" name="gridLayout_5" columnstretch="0,0,0,0,0"> + <item row="0" column="2"> + <widget class="QLabel" name="labDialFreq"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>USB dial frequency</string> + </property> + <property name="styleSheet"> + <string notr="true">QLabel { + font-family: MS Shell Dlg 2; + font-size: 16pt; + color : yellow; + background-color : black; +} +QLabel[oob="true"] { + background-color: red; +} +</string> + </property> + <property name="text"> + <string>14.078 000</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="margin"> + <number>5</number> + </property> + </widget> + </item> + <item row="1" column="0" rowspan="2"> + <widget class="SignalMeter" name="signal_meter_widget"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + <property name="toolTip"> + <string><html><head/><body><p>30dB recommended when only noise present<br/>Green when good<br/>Red when clipping may occur<br/>Yellow when too low</p></body></html></string> + </property> + <property name="frameShape"> + <enum>QFrame::Panel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Sunken</enum> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QWidget" name="DX_controls_widget" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <layout class="QGridLayout" name="gridLayout_2"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="label_3"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="palette"> + <palette> + <active> + <colorrole role="Base"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>252</red> + <green>252</green> + <blue>252</blue> + </color> + </brush> + </colorrole> + <colorrole role="Window"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>159</red> + <green>175</green> + <blue>213</blue> + </color> + </brush> + </colorrole> + </active> + <inactive> + <colorrole role="Base"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>252</red> + <green>252</green> + <blue>252</blue> + </color> + </brush> + </colorrole> + <colorrole role="Window"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>159</red> + <green>175</green> + <blue>213</blue> + </color> + </brush> + </colorrole> + </inactive> + <disabled> + <colorrole role="Base"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>159</red> + <green>175</green> + <blue>213</blue> + </color> + </brush> + </colorrole> + <colorrole role="Window"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>159</red> + <green>175</green> + <blue>213</blue> + </color> + </brush> + </colorrole> + </disabled> + </palette> + </property> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="text"> + <string>DX Call</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="margin"> + <number>5</number> + </property> + <property name="indent"> + <number>2</number> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="label_4"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="palette"> + <palette> + <active> + <colorrole role="Base"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>252</red> + <green>252</green> + <blue>252</blue> + </color> + </brush> + </colorrole> + <colorrole role="Window"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>159</red> + <green>175</green> + <blue>213</blue> + </color> + </brush> + </colorrole> + </active> + <inactive> + <colorrole role="Base"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>252</red> + <green>252</green> + <blue>252</blue> + </color> + </brush> + </colorrole> + <colorrole role="Window"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>159</red> + <green>175</green> + <blue>213</blue> + </color> + </brush> + </colorrole> + </inactive> + <disabled> + <colorrole role="Base"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>159</red> + <green>175</green> + <blue>213</blue> + </color> + </brush> + </colorrole> + <colorrole role="Window"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>159</red> + <green>175</green> + <blue>213</blue> + </color> + </brush> + </colorrole> + </disabled> + </palette> + </property> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="text"> + <string>DX Grid</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="margin"> + <number>5</number> + </property> + <property name="indent"> + <number>2</number> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLineEdit" name="dxCallEntry"> + <property name="toolTip"> + <string>Callsign of station to be worked</string> + </property> + <property name="text"> + <string/> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QPushButton" name="lookupButton"> + <property name="toolTip"> + <string>Search for callsign in database</string> + </property> + <property name="text"> + <string>&Lookup</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="dxGridEntry"> + <property name="toolTip"> + <string>Locator of station to be worked</string> + </property> + <property name="text"> + <string/> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="2" column="0" colspan="2"> + <widget class="QLabel" name="labAz"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="text"> + <string>Az: 251 16553 km</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="indent"> + <number>4</number> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QPushButton" name="addButton"> + <property name="toolTip"> + <string>Add callsign and locator to database</string> + </property> + <property name="text"> + <string>Add</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="0" column="4"> + <widget class="QLabel" name="label"> + <property name="text"> + <string> Pwr</string> + </property> + </widget> + </item> + <item row="0" column="1" alignment="Qt::AlignHCenter|Qt::AlignVCenter"> + <widget class="QPushButton" name="readFreq"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip"> + <string><html><head/><body><p>If orange or red there has been a rig control failure, click to reset and read the dial frequency. S implies split mode.</p></body></html></string> + </property> + <property name="styleSheet"> + <string notr="true">QPushButton { + font-family: helvetica; + font-size: 9pt; + font-weight: bold; + background-color: white; + color: black; + border-style: solid; + border-width:1px; + border-radius:10px; + border-color: gray; + max-width:20px; + max-height:20px; + min-width:20px; + min-height:20px; +} +QPushButton[state="error"] { + background-color: red; +} +QPushButton[state="warning"] { + background-color: orange; +} +QPushButton[state="ok"] { + background-color: #00ff00; +}</string> + </property> + <property name="text"> + <string>?</string> + </property> + </widget> + </item> + <item row="1" column="4" rowspan="2"> + <widget class="QSlider" name="outAttenuation"> + <property name="toolTip"> + <string>Adjust Tx audio level</string> + </property> + <property name="maximum"> + <number>450</number> + </property> + <property name="value"> + <number>0</number> + </property> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="invertedAppearance"> + <bool>true</bool> + </property> + <property name="invertedControls"> + <bool>true</bool> + </property> + <property name="tickPosition"> + <enum>QSlider::TicksBelow</enum> + </property> + <property name="tickInterval"> + <number>50</number> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QComboBox" name="bandComboBox"> + <property name="toolTip"> + <string><html><head/><body><p>Select operating band or enter frequency in MHz or enter kHz increment followed by k.</p></body></html></string> + </property> + <property name="editable"> + <bool>true</bool> + </property> + <property name="insertPolicy"> + <enum>QComboBox::NoInsert</enum> + </property> + <property name="sizeAdjustPolicy"> + <enum>QComboBox::AdjustToMinimumContentsLength</enum> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QLabel" name="labUTC"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="styleSheet"> + <string notr="true">QLabel { + font-family: MS Shell Dlg 2; + font-size: 16pt; + background-color : black; + color : yellow; +}</string> + </property> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Sunken</enum> + </property> + <property name="lineWidth"> + <number>2</number> + </property> + <property name="midLineWidth"> + <number>0</number> + </property> + <property name="text"> + <string><html><head/><body><p align="center"> 2015 Jun 17 </p><p align="center"> 01:23:45 </p></body></html></string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="margin"> + <number>5</number> + </property> + </widget> + </item> + <item row="0" column="3" rowspan="3"> + <widget class="QStackedWidget" name="controls_stack_widget"> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="page"> + <layout class="QHBoxLayout" name="horizontalLayout_8"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QWidget" name="QSO_controls_widget" native="true"> + <layout class="QHBoxLayout" name="horizontalLayout_6" stretch="0,0"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <layout class="QGridLayout" name="gridLayout_3"> + <item row="1" column="1"> + <widget class="QCheckBox" name="cbHoldTxFreq"> + <property name="toolTip"> + <string><html><head/><body><p>Check to keep Tx frequency fixed when double-clicking on decoded text.</p></body></html></string> + </property> + <property name="text"> + <string>Hold Tx Freq</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QSpinBox" name="RxFreqSpinBox"> + <property name="toolTip"> + <string>Audio Rx frequency</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="suffix"> + <string> Hz</string> + </property> + <property name="prefix"> + <string>Rx </string> + </property> + <property name="minimum"> + <number>200</number> + </property> + <property name="maximum"> + <number>5000</number> + </property> + <property name="value"> + <number>1500</number> + </property> + </widget> + </item> + <item row="2" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <item> + <widget class="QPushButton" name="pbR2T"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>20</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>50</width> + <height>20</height> + </size> + </property> + <property name="toolTip"> + <string>Set Tx frequency to Rx Frequency</string> + </property> + <property name="text"> + <string>â–²</string> + </property> + </widget> + </item> + <item> + <widget class="HintedSpinBox" name="sbFtol"> + <property name="toolTip"> + <string>Frequency tolerance (Hz)</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="prefix"> + <string>F Tol </string> + </property> + <property name="minimum"> + <number>10</number> + </property> + <property name="maximum"> + <number>1000</number> + </property> + <property name="value"> + <number>10</number> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="pbT2R"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>20</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>50</width> + <height>20</height> + </size> + </property> + <property name="toolTip"> + <string>Set Rx frequency to Tx Frequency</string> + </property> + <property name="text"> + <string>â–¼</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="5" column="1"> + <widget class="QSpinBox" name="syncSpinBox"> + <property name="toolTip"> + <string><html><head/><body><p>Synchronizing threshold. Lower numbers accept weaker sync signals.</p></body></html></string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="prefix"> + <string>Sync </string> + </property> + <property name="minimum"> + <number>-1</number> + </property> + <property name="maximum"> + <number>10</number> + </property> + <property name="value"> + <number>1</number> + </property> + </widget> + </item> + <item row="7" column="0" colspan="2"> + <layout class="QHBoxLayout" name="horizontalLayout_5"> + <item> + <widget class="QCheckBox" name="cbShMsgs"> + <property name="toolTip"> + <string><html><head/><body><p>Check to use short-format messages.</p></body></html></string> + </property> + <property name="text"> + <string>Sh</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="cbFast9"> + <property name="toolTip"> + <string><html><head/><body><p>Check to enable JT9 fast modes</p></body></html></string> + </property> + <property name="text"> + <string>Fast</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="cbAutoSeq"> + <property name="toolTip"> + <string><html><head/><body><p>Check to enable automatic sequencing of Tx messages based on received messages.</p></body></html></string> + </property> + <property name="text"> + <string>Auto Seq</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="cbFirst"> + <property name="toolTip"> + <string><html><head/><body><p>Check to call the first decoded responder to my CQ.</p></body></html></string> + </property> + <property name="text"> + <string>Call 1st</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="cbTx6"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip"> + <string>Check to generate "@1250 (SEND MSGS)" in Tx6.</string> + </property> + <property name="text"> + <string>Tx6</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="0" column="0"> + <widget class="QCheckBox" name="txFirstCheckBox"> + <property name="toolTip"> + <string><html><head/><body><p>Check to Tx in even-numbered minutes or sequences, starting at 0; uncheck for odd sequences.</p></body></html></string> + </property> + <property name="text"> + <string>Tx even/1st</string> + </property> + </widget> + </item> + <item row="6" column="0" colspan="2"> + <layout class="QHBoxLayout" name="horizontalLayout_11"> + <item> + <widget class="QSpinBox" name="sbCQTxFreq"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip"> + <string><html><head/><body><p>Frequency to call CQ on in kHz above the current MHz</p></body></html></string> + </property> + <property name="prefix"> + <string>Tx CQ </string> + </property> + <property name="minimum"> + <number>1</number> + </property> + <property name="maximum"> + <number>999</number> + </property> + <property name="value"> + <number>260</number> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="cbCQTx"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip"> + <string><html><head/><body><p>Check this to call CQ on the &quot;Tx CQ&quot; frequency. Rx will be on the current frequency and the CQ message wiill include the current Rx frequency so callers know which frequency to reply on.</p><p>Not available to nonstandard callsign holders.</p></body></html></string> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="cbRxAll"> + <property name="text"> + <string>Rx All Freqs</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="4" column="1"> + <widget class="LettersSpinBox" name="sbSubmode"> + <property name="toolTip"> + <string><html><head/><body><p>Submode determines tone spacing; A is narrowest.</p></body></html></string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="prefix"> + <string>Submode </string> + </property> + <property name="minimum"> + <number>0</number> + </property> + <property name="maximum"> + <number>7</number> + </property> + </widget> + </item> + <item row="8" column="0" colspan="2"> + <layout class="QHBoxLayout" name="horizontalLayout_15"> + <item> + <widget class="QLabel" name="labDXped"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>Fox</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="cbSWL"> + <property name="toolTip"> + <string><html><head/><body><p>Check to monitor Sh messages.</p></body></html></string> + </property> + <property name="text"> + <string>SWL</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="measure_check_box"> + <property name="toolTip"> + <string><html><head/><body><p>Check this to start recording calibration data.<br/>While measuring calibration correction is disabled.<br/>When not checked you can view the calibration results.</p></body></html></string> + </property> + <property name="text"> + <string>Measure</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="4" column="0"> + <widget class="QSpinBox" name="rptSpinBox"> + <property name="toolTip"> + <string><html><head/><body><p>Signal report: Signal-to-noise ratio in 2500 Hz reference bandwidth (dB).</p></body></html></string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="prefix"> + <string> Report </string> + </property> + <property name="minimum"> + <number>-50</number> + </property> + <property name="maximum"> + <number>49</number> + </property> + <property name="value"> + <number>-15</number> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="RestrictedSpinBox" name="sbTR"> + <property name="toolTip"> + <string><html><head/><body><p>Tx/Rx or Frequency calibration sequence length</p></body></html></string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="suffix"> + <string> s</string> + </property> + <property name="prefix"> + <string>T/R </string> + </property> + <property name="minimum"> + <number>5</number> + </property> + <property name="maximum"> + <number>30</number> + </property> + <property name="value"> + <number>30</number> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QPushButton" name="pbTxMode"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Toggle Tx mode</string> + </property> + <property name="text"> + <string>Tx JT9 @</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QSpinBox" name="TxFreqSpinBox"> + <property name="toolTip"> + <string>Audio Tx frequency</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="suffix"> + <string> Hz</string> + </property> + <property name="prefix"> + <string>Tx </string> + </property> + <property name="minimum"> + <number>200</number> + </property> + <property name="maximum"> + <number>5000</number> + </property> + <property name="value"> + <number>1500</number> + </property> + </widget> + </item> + <item row="9" column="0"> + <spacer name="verticalSpacer_4"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item row="3" column="1"> + <widget class="QSpinBox" name="sbSerialNumber"> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="prefix"> + <string>Tx# </string> + </property> + <property name="minimum"> + <number>1</number> + </property> + <property name="maximum"> + <number>4095</number> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLabel" name="labNextCall"> + <property name="toolTip"> + <string><html><head/><body><p>Double-click on another caller to queue that call for your next QSO.</p></body></html></string> + </property> + <property name="text"> + <string>Next Call</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QTabWidget" name="tabWidget"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="tabPosition"> + <enum>QTabWidget::West</enum> + </property> + <property name="tabShape"> + <enum>QTabWidget::Triangular</enum> + </property> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="tab"> + <attribute name="title"> + <string>1</string> + </attribute> + <layout class="QGridLayout" name="gridLayout_7"> + <item row="0" column="0"> + <layout class="QGridLayout" name="gridLayout_6"> + <item row="2" column="1"> + <widget class="QRadioButton" name="txrb2"> + <property name="toolTip"> + <string>Send this message in next Tx interval</string> + </property> + <property name="styleSheet"> + <string notr="true">margin-left: 10%; margin-right: 0%</string> + </property> + <property name="text"> + <string/> + </property> + <property name="shortcut"> + <string>Ctrl+2</string> + </property> + <attribute name="buttonGroup"> + <string notr="true">buttonGroup</string> + </attribute> + </widget> + </item> + <item row="1" column="1"> + <widget class="DoubleClickableRadioButton" name="txrb1"> + <property name="toolTip"> + <string><html><head/><body><p>Send this message in next Tx interval</p><p>Double click to toggle the use of the Tx1 message to start a QSO with a station (not allowed for type 1 compound call holders)</p></body></html></string> + </property> + <property name="styleSheet"> + <string notr="true">margin-left: 10%; margin-right: 0%</string> + </property> + <property name="text"> + <string/> + </property> + <property name="shortcut"> + <string>Ctrl+1</string> + </property> + <attribute name="buttonGroup"> + <string notr="true">buttonGroup</string> + </attribute> + </widget> + </item> + <item row="2" column="2"> + <widget class="QPushButton" name="txb2"> + <property name="toolTip"> + <string>Switch to this Tx message NOW</string> + </property> + <property name="styleSheet"> + <string notr="true">padding-left: 15%; padding-right: 15%; padding-top: 3%; padding-bottom: 3%</string> + </property> + <property name="text"> + <string>Tx &2</string> + </property> + <property name="shortcut"> + <string>Alt+2</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLineEdit" name="tx2"/> + </item> + <item row="1" column="2"> + <widget class="DoubleClickablePushButton" name="txb1"> + <property name="toolTip"> + <string><html><head/><body><p>Switch to this Tx message NOW</p><p>Double click to toggle the use of the Tx1 message to start a QSO with a station (not allowed for type 1 compound call holders)</p></body></html></string> + </property> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> + </property> + <property name="styleSheet"> + <string notr="true">padding-left: 15%; padding-right: 15%; padding-top: 3%; padding-bottom: 3%</string> + </property> + <property name="text"> + <string>Tx &1</string> + </property> + <property name="shortcut"> + <string>Alt+1</string> + </property> + </widget> + </item> + <item row="6" column="1"> + <widget class="QRadioButton" name="txrb6"> + <property name="toolTip"> + <string>Send this message in next Tx interval</string> + </property> + <property name="styleSheet"> + <string notr="true">margin-left: 10%; margin-right: 0%</string> + </property> + <property name="text"> + <string/> + </property> + <property name="shortcut"> + <string>Ctrl+6</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <attribute name="buttonGroup"> + <string notr="true">buttonGroup</string> + </attribute> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLineEdit" name="tx3"/> + </item> + <item row="5" column="1"> + <widget class="DoubleClickableRadioButton" name="txrb5"> + <property name="toolTip"> + <string><html><head/><body><p>Send this message in next Tx interval</p><p>Double-click to reset to the standard 73 message</p></body></html></string> + </property> + <property name="styleSheet"> + <string notr="true">margin-left: 10%; margin-right: 0%</string> + </property> + <property name="text"> + <string/> + </property> + <property name="shortcut"> + <string>Ctrl+5</string> + </property> + <attribute name="buttonGroup"> + <string notr="true">buttonGroup</string> + </attribute> + </widget> + </item> + <item row="3" column="1"> + <widget class="QRadioButton" name="txrb3"> + <property name="toolTip"> + <string>Send this message in next Tx interval</string> + </property> + <property name="styleSheet"> + <string notr="true">margin-left: 10%; margin-right: 0%</string> + </property> + <property name="text"> + <string/> + </property> + <property name="shortcut"> + <string>Ctrl+3</string> + </property> + <attribute name="buttonGroup"> + <string notr="true">buttonGroup</string> + </attribute> + </widget> + </item> + <item row="3" column="2"> + <widget class="QPushButton" name="txb3"> + <property name="toolTip"> + <string>Switch to this Tx message NOW</string> + </property> + <property name="styleSheet"> + <string notr="true">padding-left: 15%; padding-right: 15%; padding-top: 3%; padding-bottom: 3%</string> + </property> + <property name="text"> + <string>Tx &3</string> + </property> + <property name="shortcut"> + <string>Alt+3</string> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="DoubleClickableRadioButton" name="txrb4"> + <property name="toolTip"> + <string><html><head/><body><p>Send this message in next Tx interval</p><p>Double-click to toggle between RRR and RR73 messages in Tx4 (not allowed for type 2 compound call holders)</p><p>RR73 messages should only be used when you are reasonably confident that no message repetitions will be required</p></body></html></string> + </property> + <property name="styleSheet"> + <string notr="true">margin-left: 10%; margin-right: 0%</string> + </property> + <property name="text"> + <string/> + </property> + <property name="shortcut"> + <string>Ctrl+4</string> + </property> + <attribute name="buttonGroup"> + <string notr="true">buttonGroup</string> + </attribute> + </widget> + </item> + <item row="4" column="2"> + <widget class="DoubleClickablePushButton" name="txb4"> + <property name="toolTip"> + <string><html><head/><body><p>Switch to this Tx message NOW</p><p>Double-click to toggle between RRR and RR73 messages in Tx4 (not allowed for type2 compound call holders)</p><p>RR73 messages should only be used when you are reasonably confident that no message repetitions will be required</p></body></html></string> + </property> + <property name="styleSheet"> + <string notr="true">padding-left: 15%; padding-right: 15%; padding-top: 3%; padding-bottom: 3%</string> + </property> + <property name="text"> + <string>Tx &4</string> + </property> + <property name="shortcut"> + <string>Alt+4</string> + </property> + </widget> + </item> + <item row="5" column="2"> + <widget class="DoubleClickablePushButton" name="txb5"> + <property name="toolTip"> + <string><html><head/><body><p>Switch to this Tx message NOW</p><p>Double-click to reset to the standard 73 message</p></body></html></string> + </property> + <property name="styleSheet"> + <string notr="true">padding-left: 15%; padding-right: 15%; padding-top: 3%; padding-bottom: 3%</string> + </property> + <property name="text"> + <string>Tx &5</string> + </property> + <property name="shortcut"> + <string>Alt+5</string> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLineEdit" name="tx4"/> + </item> + <item row="0" column="2"> + <widget class="QLabel" name="label_2"> + <property name="toolTip"> + <string>Switch to this Tx message NOW</string> + </property> + <property name="text"> + <string>Now</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QPushButton" name="genStdMsgsPushButton"> + <property name="toolTip"> + <string>Generate standard messages for minimal QSO</string> + </property> + <property name="text"> + <string>Generate Std Msgs</string> + </property> + </widget> + </item> + <item row="6" column="2"> + <widget class="QPushButton" name="txb6"> + <property name="toolTip"> + <string>Switch to this Tx message NOW</string> + </property> + <property name="styleSheet"> + <string notr="true">padding-left: 15%; padding-right: 15%; padding-top: 3%; padding-bottom: 3%</string> + </property> + <property name="text"> + <string>Tx &6</string> + </property> + <property name="shortcut"> + <string>Alt+6</string> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QComboBox" name="tx5"> + <property name="toolTip"> + <string>Enter a free text message (maximum 13 characters) +or select a predefined macro from the dropdown list. +Press ENTER to add the current text to the predefined +list. The list can be maintained in Settings (F2).</string> + </property> + <property name="editable"> + <bool>true</bool> + </property> + <property name="insertPolicy"> + <enum>QComboBox::InsertAtBottom</enum> + </property> + </widget> + </item> + <item row="6" column="0"> + <widget class="QLineEdit" name="tx6"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLineEdit" name="tx1"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="label_5"> + <property name="toolTip"> + <string>Queue up the next Tx message</string> + </property> + <property name="text"> + <string>Next</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab_2"> + <attribute name="title"> + <string>2</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <property name="leftMargin"> + <number>6</number> + </property> + <property name="topMargin"> + <number>6</number> + </property> + <property name="rightMargin"> + <number>6</number> + </property> + <property name="bottomMargin"> + <number>6</number> + </property> + <item> + <layout class="QGridLayout" name="gridLayout_4"> + <property name="horizontalSpacing"> + <number>0</number> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="label_9"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>2</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>30</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>30</height> + </size> + </property> + <property name="text"> + <string>Calling CQ </string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QPushButton" name="pbCallCQ"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>2</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Generate a CQ message</string> + </property> + <property name="text"> + <string>CQ</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QPushButton" name="pbSendRRR"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>2</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Generate message with RRR</string> + </property> + <property name="text"> + <string>RRR</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QPushButton" name="pbAnswerCaller"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>2</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Generate message with report</string> + </property> + <property name="text"> + <string>dB</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="label_10"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>2</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>30</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>30</height> + </size> + </property> + <property name="text"> + <string>Answering CQ</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QPushButton" name="pbAnswerCQ"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>2</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Generate message for replying to a CQ</string> + </property> + <property name="text"> + <string>Grid</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QPushButton" name="pbSendReport"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>2</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Generate message with R+report</string> + </property> + <property name="text"> + <string>R+dB</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QPushButton" name="pbSend73"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>2</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Generate message with 73</string> + </property> + <property name="text"> + <string>73</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QLineEdit" name="genMsg"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>3</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="rbGenMsg"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>26</height> + </size> + </property> + <property name="toolTip"> + <string>Send this standard (generated) message</string> + </property> + <property name="text"> + <string>Gen msg</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QComboBox" name="freeTextMsg"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>3</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>150</width> + <height>0</height> + </size> + </property> + <property name="toolTip"> + <string>Enter a free text message (maximum 13 characters) +or select a predefined macro from the dropdown list. +Press ENTER to add the current text to the predefined +list. The list can be maintained in Settings (F2).</string> + </property> + <property name="editable"> + <bool>true</bool> + </property> + <property name="insertPolicy"> + <enum>QComboBox::InsertAtBottom</enum> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="rbFreeText"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Send this free-text message (max 13 characters)</string> + </property> + <property name="text"> + <string>Free msg</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab_3"> + <attribute name="title"> + <string>3</string> + </attribute> + <layout class="QGridLayout" name="gridLayout_11"> + <item row="0" column="1" rowspan="2"> + <layout class="QGridLayout" name="gridLayout_10"> + <item row="2" column="0"> + <widget class="QSpinBox" name="sbMax_dB"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>16777215</height> + </size> + </property> + <property name="prefix"> + <string>Max dB </string> + </property> + <property name="minimum"> + <number>-15</number> + </property> + <property name="maximum"> + <number>30</number> + </property> + <property name="value"> + <number>30</number> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QComboBox" name="comboBoxCQ"> + <property name="currentText"> + <string>CQ</string> + </property> + <item> + <property name="text"> + <string>CQ</string> + </property> + </item> + <item> + <property name="text"> + <string>CQ AF</string> + </property> + </item> + <item> + <property name="text"> + <string>CQ AN</string> + </property> + </item> + <item> + <property name="text"> + <string>CQ AS</string> + </property> + </item> + <item> + <property name="text"> + <string>CQ EU</string> + </property> + </item> + <item> + <property name="text"> + <string>CQ NA</string> + </property> + </item> + <item> + <property name="text"> + <string>CQ OC</string> + </property> + </item> + <item> + <property name="text"> + <string>CQ SA</string> + </property> + </item> + <item> + <property name="text"> + <string>CQ 0</string> + </property> + </item> + <item> + <property name="text"> + <string>CQ 1</string> + </property> + </item> + <item> + <property name="text"> + <string>CQ 2</string> + </property> + </item> + <item> + <property name="text"> + <string>CQ 3</string> + </property> + </item> + <item> + <property name="text"> + <string>CQ 4</string> + </property> + </item> + <item> + <property name="text"> + <string>CQ 5</string> + </property> + </item> + <item> + <property name="text"> + <string>CQ 6</string> + </property> + </item> + <item> + <property name="text"> + <string>CQ 7</string> + </property> + </item> + <item> + <property name="text"> + <string>CQ 8</string> + </property> + </item> + <item> + <property name="text"> + <string>CQ 9</string> + </property> + </item> + </widget> + </item> + <item row="6" column="0"> + <widget class="QPushButton" name="pbFoxReset"> + <property name="text"> + <string>Reset</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QSpinBox" name="sbNlist"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>16777215</height> + </size> + </property> + <property name="prefix"> + <string>N List </string> + </property> + <property name="minimum"> + <number>5</number> + </property> + <property name="maximum"> + <number>100</number> + </property> + <property name="value"> + <number>12</number> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QSpinBox" name="sbNslots"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>16777215</height> + </size> + </property> + <property name="suffix"> + <string/> + </property> + <property name="prefix"> + <string>N Slots </string> + </property> + <property name="minimum"> + <number>1</number> + </property> + <property name="maximum"> + <number>5</number> + </property> + <property name="value"> + <number>1</number> + </property> + <property name="displayIntegerBase"> + <number>10</number> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QComboBox" name="comboBoxHoundSort"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>16777215</height> + </size> + </property> + <property name="currentText"> + <string>Random</string> + </property> + <property name="maxVisibleItems"> + <number>5</number> + </property> + <item> + <property name="text"> + <string>Random</string> + </property> + </item> + <item> + <property name="text"> + <string>Call</string> + </property> + </item> + <item> + <property name="text"> + <string>Grid</string> + </property> + </item> + <item> + <property name="text"> + <string>S/N (dB)</string> + </property> + </item> + <item> + <property name="text"> + <string>Distance</string> + </property> + </item> + </widget> + </item> + <item row="7" column="0"> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item row="5" column="0"> + <widget class="QCheckBox" name="cbMoreCQs"> + <property name="text"> + <string>More CQs</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="0" column="0"> + <widget class="DisplayText" name="textBrowser4"> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + </layout> + </widget> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="page_2"> + <layout class="QVBoxLayout" name="verticalLayout_5"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QWidget" name="widget_2" native="true"> + <layout class="QHBoxLayout" name="horizontalLayout_9"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QWidget" name="WSPR_controls_widget" native="true"> + <layout class="QGridLayout" name="gridLayout_9"> + <item row="1" column="0"> + <spacer name="horizontalSpacer_7"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="2"> + <spacer name="horizontalSpacer_6"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="2" column="1"> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_12"> + <item> + <layout class="QVBoxLayout" name="verticalLayout_7"> + <item> + <widget class="QSpinBox" name="WSPRfreqSpinBox"> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="suffix"> + <string> Hz</string> + </property> + <property name="prefix"> + <string>Tx </string> + </property> + <property name="minimum"> + <number>1400</number> + </property> + <property name="maximum"> + <number>1700</number> + </property> + <property name="value"> + <number>1500</number> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="sbTxPercent"> + <property name="toolTip"> + <string>Percentage of 2-minute sequences devoted to transmitting.</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="suffix"> + <string> %</string> + </property> + <property name="prefix"> + <string>Tx Pct </string> + </property> + <property name="maximum"> + <number>100</number> + </property> + </widget> + </item> + <item> + <widget class="QGroupBox" name="band_hopping_group_box"> + <property name="title"> + <string>Band Hopping</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_7"> + <item> + <widget class="QPushButton" name="band_hopping_schedule_push_button"> + <property name="toolTip"> + <string>Choose bands and times of day for band-hopping.</string> + </property> + <property name="text"> + <string>Schedule ...</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_8"> + <item> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_10"> + <item> + <widget class="QCheckBox" name="cbUploadWSPR_Spots"> + <property name="toolTip"> + <string>Upload decoded messages to WSPRnet.org.</string> + </property> + <property name="text"> + <string>Upload spots</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QCheckBox" name="WSPR_prefer_type_1_check_box"> + <property name="toolTip"> + <string><html><head/><body><p>6 digit locators cause 2 different mesages to be sent, the second contains the full locator but only a hashed callsign, other stations must have decoded the first once before they can decode your call in the second. Check this option to only send 4 digit locators if it will avoid the two message protocol.</p></body></html></string> + </property> + <property name="text"> + <string>Prefer type 1 messages</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="cbNoOwnCall"> + <property name="text"> + <string>No own call decodes</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_13"> + <item> + <widget class="QPushButton" name="pbTxNext"> + <property name="toolTip"> + <string>Transmit during the next 2-minute sequence.</string> + </property> + <property name="styleSheet"> + <string notr="true">QPushButton:checked { + background-color: red; + border-style: outset; + border-width: 1px; + border-radius: 5px; + border-color: black; + min-width: 5em; + padding: 3px; +}</string> + </property> + <property name="text"> + <string>Tx Next</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_14"> + <item> + <widget class="QComboBox" name="TxPowerComboBox"> + <property name="toolTip"> + <string>Set Tx power in dBm (dB above 1 mW) as part of your WSPR message.</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </item> + <item row="0" column="1"> + <spacer name="verticalSpacer_3"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <widget class="QMenuBar" name="menuBar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>805</width> + <height>21</height> + </rect> + </property> + <widget class="QMenu" name="menuFile"> + <property name="title"> + <string>File</string> + </property> + <addaction name="actionOpen"/> + <addaction name="actionOpen_next_in_directory"/> + <addaction name="actionDecode_remaining_files_in_directory"/> + <addaction name="separator"/> + <addaction name="actionDelete_all_wav_files_in_SaveDir"/> + <addaction name="actionErase_ALL_TXT"/> + <addaction name="actionErase_wsjtx_log_adi"/> + <addaction name="reset_cabrillo_log_action"/> + <addaction name="actionExport_Cabrillo_log"/> + <addaction name="actionOpen_log_directory"/> + <addaction name="separator"/> + <addaction name="actionSettings"/> + <addaction name="separator"/> + <addaction name="separator"/> + <addaction name="actionExit"/> + </widget> + <widget class="QMenu" name="menuView"> + <property name="title"> + <string>View</string> + </property> + <addaction name="actionWide_Waterfall"/> + <addaction name="actionAstronomical_data"/> + <addaction name="actionMessage_averaging"/> + <addaction name="actionEcho_Graph"/> + <addaction name="actionFast_Graph"/> + <addaction name="contest_log_action"/> + <addaction name="fox_log_action"/> + <addaction name="actionColors"/> + <addaction name="separator"/> + </widget> + <widget class="QMenu" name="menuDecode"> + <property name="title"> + <string>Decode</string> + </property> + <addaction name="actionQuickDecode"/> + <addaction name="actionMediumDecode"/> + <addaction name="actionDeepestDecode"/> + <addaction name="separator"/> + <addaction name="actionInclude_averaging"/> + <addaction name="actionInclude_correlation"/> + <addaction name="actionEnable_AP_FT8"/> + <addaction name="actionEnable_AP_JT65"/> + <addaction name="actionEnable_AP_DXcall"/> + </widget> + <widget class="QMenu" name="menuSave"> + <property name="title"> + <string>Save</string> + </property> + <addaction name="actionNone"/> + <addaction name="actionSave_decoded"/> + <addaction name="actionSave_all"/> + </widget> + <widget class="QMenu" name="menuHelp"> + <property name="title"> + <string>Help</string> + </property> + <addaction name="actionRelease_Notes"/> + <addaction name="actionOnline_User_Guide"/> + <addaction name="actionLocal_User_Guide"/> + <addaction name="actionFT8_DXpedition_Mode_User_Guide"/> + <addaction name="actionQuick_Start_Guide_v2"/> + <addaction name="download_samples_action"/> + <addaction name="separator"/> + <addaction name="actionKeyboard_shortcuts"/> + <addaction name="actionSpecial_mouse_commands"/> + <addaction name="actionShort_list_of_add_on_prefixes_and_suffixes"/> + <addaction name="separator"/> + <addaction name="actionCopyright_Notice"/> + <addaction name="separator"/> + <addaction name="actionAbout"/> + </widget> + <widget class="QMenu" name="menuMode"> + <property name="title"> + <string>Mode</string> + </property> + <addaction name="actionFT8"/> + <addaction name="actionJT4"/> + <addaction name="actionJT9"/> + <addaction name="actionJT9_JT65"/> + <addaction name="actionJT65"/> + <addaction name="actionQRA64"/> + <addaction name="separator"/> + <addaction name="actionISCAT"/> + <addaction name="actionMSK144"/> + <addaction name="separator"/> + <addaction name="actionWSPR"/> + <addaction name="actionWSPR_LF"/> + <addaction name="separator"/> + <addaction name="actionEcho"/> + <addaction name="separator"/> + <addaction name="actionFreqCal"/> + </widget> + <widget class="QMenu" name="menuConfig"> + <property name="title"> + <string>Configurations</string> + </property> + </widget> + <widget class="QMenu" name="menuTools"> + <property name="title"> + <string>Tools</string> + </property> + <addaction name="actionErase_reference_spectrum"/> + <addaction name="actionMeasure_reference_spectrum"/> + <addaction name="separator"/> + <addaction name="actionMeasure_phase_response"/> + <addaction name="view_phase_response_action"/> + <addaction name="separator"/> + <addaction name="actionFrequency_calibration"/> + <addaction name="actionSolve_FreqCal"/> + </widget> + <addaction name="menuFile"/> + <addaction name="menuConfig"/> + <addaction name="menuView"/> + <addaction name="menuMode"/> + <addaction name="menuDecode"/> + <addaction name="menuSave"/> + <addaction name="menuTools"/> + <addaction name="menuHelp"/> + </widget> + <widget class="QStatusBar" name="statusBar"/> + <action name="actionExit"> + <property name="text"> + <string>Exit</string> + </property> + <property name="menuRole"> + <enum>QAction::QuitRole</enum> + </property> + </action> + <action name="actionDeviceSetup"> + <property name="checkable"> + <bool>false</bool> + </property> + <property name="text"> + <string>Configuration</string> + </property> + <property name="shortcut"> + <string>F2</string> + </property> + </action> + <action name="actionAbout"> + <property name="text"> + <string>About WSJT-X</string> + </property> + <property name="shortcut"> + <string>Ctrl+F1</string> + </property> + </action> + <action name="actionWide_Waterfall"> + <property name="text"> + <string>Waterfall</string> + </property> + </action> + <action name="actionOpen"> + <property name="text"> + <string>Open</string> + </property> + <property name="shortcut"> + <string>Ctrl+O</string> + </property> + </action> + <action name="actionOpen_next_in_directory"> + <property name="text"> + <string>Open next in directory</string> + </property> + <property name="shortcut"> + <string>F6</string> + </property> + </action> + <action name="actionDecode_remaining_files_in_directory"> + <property name="text"> + <string>Decode remaining files in directory</string> + </property> + <property name="shortcut"> + <string>Shift+F6</string> + </property> + </action> + <action name="actionDelete_all_wav_files_in_SaveDir"> + <property name="text"> + <string>Delete all *.wav && *.c2 files in SaveDir</string> + </property> + </action> + <action name="actionQuickDecode"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>false</bool> + </property> + <property name="text"> + <string>Fast</string> + </property> + </action> + <action name="actionNone"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="text"> + <string>None</string> + </property> + </action> + <action name="actionSave_all"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>Save all</string> + </property> + </action> + <action name="actionOnline_User_Guide"> + <property name="text"> + <string>Online User Guide</string> + </property> + <property name="shortcut"> + <string>F1</string> + </property> + </action> + <action name="actionKeyboard_shortcuts"> + <property name="text"> + <string>Keyboard shortcuts</string> + </property> + <property name="shortcut"> + <string>F3</string> + </property> + </action> + <action name="actionSpecial_mouse_commands"> + <property name="text"> + <string>Special mouse commands</string> + </property> + <property name="shortcut"> + <string>F5</string> + </property> + </action> + <action name="actionJT9"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="text"> + <string>JT9</string> + </property> + </action> + <action name="actionSave_decoded"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Save decoded</string> + </property> + </action> + <action name="actionMediumDecode"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>false</bool> + </property> + <property name="text"> + <string>Normal</string> + </property> + </action> + <action name="actionDeepestDecode"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="text"> + <string>Deep</string> + </property> + </action> + <action name="actionMonitor_OFF_at_startup"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>Monitor OFF at startup</string> + </property> + </action> + <action name="actionErase_ALL_TXT"> + <property name="text"> + <string>Erase ALL.TXT</string> + </property> + </action> + <action name="actionErase_wsjtx_log_adi"> + <property name="text"> + <string>Erase wsjtx_log.adi</string> + </property> + </action> + <action name="actionConvert_JT9_x_to_RTTY"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>Convert mode to RTTY for logging</string> + </property> + </action> + <action name="actionLog_dB_reports_to_Comments"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>Log dB reports to Comments</string> + </property> + </action> + <action name="actionPrompt_to_log_QSO"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>Prompt me to log QSO</string> + </property> + </action> + <action name="actionBlank_line_between_decoding_periods"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>Blank line between decoding periods</string> + </property> + </action> + <action name="actionClear_DX_Call_and_Grid_after_logging"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>Clear DX Call and Grid after logging</string> + </property> + </action> + <action name="actionDisplay_distance_in_miles"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>Display distance in miles</string> + </property> + </action> + <action name="actionDouble_click_on_call_sets_Tx_Enable"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>Double-click on call sets Tx Enable</string> + </property> + <property name="shortcut"> + <string>F7</string> + </property> + </action> + <action name="action_73TxDisable"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>Tx disabled after sending 73</string> + </property> + </action> + <action name="actionRunaway_Tx_watchdog"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>Runaway Tx watchdog</string> + </property> + </action> + <action name="actionAllow_multiple_instances"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>Allow multiple instances</string> + </property> + </action> + <action name="actionLockTxFreq"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>Tx freq locked to Rx freq</string> + </property> + </action> + <action name="actionJT65"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>JT65</string> + </property> + </action> + <action name="actionJT9_JT65"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>JT9+JT65</string> + </property> + </action> + <action name="actionTx2QSO"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>Tx messages to Rx Frequency window</string> + </property> + </action> + <action name="actionGray1"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>Gray1</string> + </property> + </action> + <action name="actionEnable_DXCC_entity"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>Show DXCC entity and worked B4 status</string> + </property> + </action> + <action name="actionAstronomical_data"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>Astronomical data</string> + </property> + </action> + <action name="actionShort_list_of_add_on_prefixes_and_suffixes"> + <property name="text"> + <string>List of Type 1 prefixes and suffixes</string> + </property> + </action> + <action name="actionSettings"> + <property name="text"> + <string>Settings...</string> + </property> + <property name="shortcut"> + <string>F2</string> + </property> + </action> + <action name="actionLocal_User_Guide"> + <property name="text"> + <string>Local User Guide</string> + </property> + </action> + <action name="actionOpen_log_directory"> + <property name="text"> + <string>Open log directory</string> + </property> + </action> + <action name="actionJT4"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>JT4</string> + </property> + </action> + <action name="actionMessage_averaging"> + <property name="text"> + <string>Message averaging</string> + </property> + <property name="shortcut"> + <string>F7</string> + </property> + </action> + <action name="actionInclude_averaging"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>Enable averaging</string> + </property> + </action> + <action name="actionInclude_correlation"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>Enable deep search</string> + </property> + </action> + <action name="actionWSPR"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>WSPR</string> + </property> + </action> + <action name="actionEcho_Graph"> + <property name="text"> + <string>Echo Graph</string> + </property> + <property name="shortcut"> + <string>F8</string> + </property> + </action> + <action name="actionEcho"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>Echo</string> + </property> + <property name="toolTip"> + <string>EME Echo mode</string> + </property> + </action> + <action name="actionISCAT"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>ISCAT</string> + </property> + </action> + <action name="actionFast_Graph"> + <property name="text"> + <string>Fast Graph</string> + </property> + <property name="shortcut"> + <string>F9</string> + </property> + </action> + <action name="download_samples_action"> + <property name="text"> + <string>&Download Samples ...</string> + </property> + <property name="whatsThis"> + <string><html><head/><body><p>Download sample audio files demonstrating the various modes.</p></body></html></string> + </property> + </action> + <action name="actionMSK144"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>MSK144</string> + </property> + </action> + <action name="actionQRA64"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>QRA64</string> + </property> + </action> + <action name="actionRelease_Notes"> + <property name="text"> + <string>Release Notes</string> + </property> + </action> + <action name="actionEnable_AP_DXcall"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>Enable AP for DX Call</string> + </property> + </action> + <action name="actionFreqCal"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>FreqCal</string> + </property> + </action> + <action name="actionMeasure_reference_spectrum"> + <property name="text"> + <string>Measure reference spectrum</string> + </property> + </action> + <action name="actionMeasure_phase_response"> + <property name="text"> + <string>Measure phase response</string> + </property> + </action> + <action name="actionErase_reference_spectrum"> + <property name="text"> + <string>Erase reference spectrum</string> + </property> + </action> + <action name="actionFrequency_calibration"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>Execute frequency calibration cycle</string> + </property> + </action> + <action name="view_phase_response_action"> + <property name="text"> + <string>Equalization tools ...</string> + </property> + </action> + <action name="actionWSPR_LF"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>WSPR-LF</string> + </property> + <property name="toolTip"> + <string>Experimental LF/MF mode</string> + </property> + <property name="visible"> + <bool>false</bool> + </property> + </action> + <action name="actionFT8"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>FT8</string> + </property> + </action> + <action name="actionEnable_AP_FT8"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>Enable AP</string> + </property> + </action> + <action name="actionEnable_AP_JT65"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>Enable AP</string> + </property> + </action> + <action name="actionSolve_FreqCal"> + <property name="text"> + <string>Solve for calibration parameters</string> + </property> + </action> + <action name="actionCopyright_Notice"> + <property name="text"> + <string>Copyright notice</string> + </property> + <property name="shortcut"> + <string>Shift+F1</string> + </property> + </action> + <action name="fox_log_action"> + <property name="checkable"> + <bool>false</bool> + </property> + <property name="text"> + <string>Fox log</string> + </property> + </action> + <action name="reset_fox_log_action"> + <property name="text"> + <string>Reset Fox log ...</string> + </property> + <property name="toolTip"> + <string><html><head/><body><p>Ths will erase the file FoxQSO.txt and delete the Fox log file which is used for dupe detection.</p></body></html></string> + </property> + </action> + <action name="actionFT8_DXpedition_Mode_User_Guide"> + <property name="text"> + <string>FT8 DXpedition Mode User Guide</string> + </property> + </action> + <action name="reset_cabrillo_log_action"> + <property name="text"> + <string>Reset Cabrillo log ...</string> + </property> + </action> + <action name="actionColors"> + <property name="text"> + <string>Color highlighting scheme</string> + </property> + </action> + <action name="actionContest_Log"> + <property name="text"> + <string>Contest Log</string> + </property> + </action> + <action name="actionExport_Cabrillo_log"> + <property name="text"> + <string>Export Cabrillo log ...</string> + </property> + </action> + <action name="actionQuick_Start_Guide_v2"> + <property name="text"> + <string>Quick-Start Guide to WSJT-X 2.0</string> + </property> + </action> + <action name="contest_log_action"> + <property name="text"> + <string>Contest log</string> + </property> + </action> + </widget> + <layoutdefault spacing="6" margin="11"/> + <customwidgets> + <customwidget> + <class>DisplayText</class> + <extends>QTextEdit</extends> + <header>widgets/displaytext.h</header> + </customwidget> + <customwidget> + <class>LettersSpinBox</class> + <extends>QSpinBox</extends> + <header>widgets/LettersSpinBox.hpp</header> + </customwidget> + <customwidget> + <class>SignalMeter</class> + <extends>QFrame</extends> + <header>widgets/signalmeter.h</header> + <container>1</container> + </customwidget> + <customwidget> + <class>HintedSpinBox</class> + <extends>QSpinBox</extends> + <header>widgets/HintedSpinBox.hpp</header> + </customwidget> + <customwidget> + <class>RestrictedSpinBox</class> + <extends>QSpinBox</extends> + <header>widgets/RestrictedSpinBox.hpp</header> + </customwidget> + <customwidget> + <class>DoubleClickableRadioButton</class> + <extends>QRadioButton</extends> + <header>widgets/DoubleClickableRadioButton.hpp</header> + </customwidget> + <customwidget> + <class>DoubleClickablePushButton</class> + <extends>QPushButton</extends> + <header>widgets/DoubleClickablePushButton.hpp</header> + </customwidget> + </customwidgets> + <tabstops> + <tabstop>logQSOButton</tabstop> + <tabstop>stopButton</tabstop> + <tabstop>monitorButton</tabstop> + <tabstop>EraseButton</tabstop> + <tabstop>ClrAvgButton</tabstop> + <tabstop>DecodeButton</tabstop> + <tabstop>autoButton</tabstop> + <tabstop>stopTxButton</tabstop> + <tabstop>tuneButton</tabstop> + <tabstop>dxCallEntry</tabstop> + <tabstop>dxGridEntry</tabstop> + <tabstop>lookupButton</tabstop> + <tabstop>addButton</tabstop> + <tabstop>txFirstCheckBox</tabstop> + <tabstop>TxFreqSpinBox</tabstop> + <tabstop>rptSpinBox</tabstop> + <tabstop>sbTR</tabstop> + <tabstop>sbCQTxFreq</tabstop> + <tabstop>cbCQTx</tabstop> + <tabstop>cbShMsgs</tabstop> + <tabstop>cbFast9</tabstop> + <tabstop>cbAutoSeq</tabstop> + <tabstop>cbTx6</tabstop> + <tabstop>pbTxMode</tabstop> + <tabstop>sbSubmode</tabstop> + <tabstop>syncSpinBox</tabstop> + <tabstop>tabWidget</tabstop> + <tabstop>pbCallCQ</tabstop> + <tabstop>pbAnswerCQ</tabstop> + <tabstop>pbAnswerCaller</tabstop> + <tabstop>pbSendReport</tabstop> + <tabstop>pbSendRRR</tabstop> + <tabstop>pbSend73</tabstop> + <tabstop>genMsg</tabstop> + <tabstop>rbGenMsg</tabstop> + <tabstop>freeTextMsg</tabstop> + <tabstop>rbFreeText</tabstop> + <tabstop>outAttenuation</tabstop> + <tabstop>genStdMsgsPushButton</tabstop> + <tabstop>tx1</tabstop> + <tabstop>tx2</tabstop> + <tabstop>tx3</tabstop> + <tabstop>tx4</tabstop> + <tabstop>tx5</tabstop> + <tabstop>tx6</tabstop> + <tabstop>txrb1</tabstop> + <tabstop>txrb2</tabstop> + <tabstop>txrb3</tabstop> + <tabstop>txrb4</tabstop> + <tabstop>txrb5</tabstop> + <tabstop>txrb6</tabstop> + <tabstop>txb1</tabstop> + <tabstop>txb2</tabstop> + <tabstop>txb3</tabstop> + <tabstop>txb4</tabstop> + <tabstop>txb5</tabstop> + <tabstop>txb6</tabstop> + <tabstop>band_hopping_group_box</tabstop> + <tabstop>band_hopping_schedule_push_button</tabstop> + <tabstop>cbUploadWSPR_Spots</tabstop> + <tabstop>WSPR_prefer_type_1_check_box</tabstop> + <tabstop>pbTxNext</tabstop> + <tabstop>TxPowerComboBox</tabstop> + <tabstop>WSPRfreqSpinBox</tabstop> + <tabstop>decodedTextBrowser2</tabstop> + <tabstop>decodedTextBrowser</tabstop> + <tabstop>bandComboBox</tabstop> + <tabstop>sbTxPercent</tabstop> + <tabstop>readFreq</tabstop> + </tabstops> + <resources/> + <connections/> + <buttongroups> + <buttongroup name="buttonGroup"> + <property name="exclusive"> + <bool>true</bool> + </property> + </buttongroup> + </buttongroups> +</ui> diff --git a/widgets/messageaveraging.cpp b/widgets/messageaveraging.cpp new file mode 100644 index 00000000..fce02284 --- /dev/null +++ b/widgets/messageaveraging.cpp @@ -0,0 +1,71 @@ +#include "messageaveraging.h" + +#include <QSettings> +#include <QApplication> +#include <QTextCharFormat> + +#include "SettingsGroup.hpp" +#include "qt_helpers.hpp" +#include "ui_messageaveraging.h" + +MessageAveraging::MessageAveraging(QSettings * settings, QFont const& font, QWidget *parent) : + QWidget(parent), + settings_ {settings}, + ui(new Ui::MessageAveraging) +{ + ui->setupUi(this); + setWindowTitle (QApplication::applicationName () + " - " + tr ("Message Averaging")); + ui->msgAvgPlainTextEdit->setReadOnly (true); + changeFont (font); + read_settings (); + ui->header_label->setText(" UTC Sync DT Freq "); +} + +MessageAveraging::~MessageAveraging() +{ + write_settings (); +} + +void MessageAveraging::changeFont (QFont const& font) +{ + ui->header_label->setStyleSheet (font_as_stylesheet (font)); + ui->msgAvgPlainTextEdit->setStyleSheet (font_as_stylesheet (font)); + setContentFont (font); + updateGeometry (); +} + +void MessageAveraging::setContentFont(QFont const& font) +{ + ui->msgAvgPlainTextEdit->setFont (font); + QTextCharFormat charFormat; + charFormat.setFont (font); + ui->msgAvgPlainTextEdit->selectAll (); + auto cursor = ui->msgAvgPlainTextEdit->textCursor (); + cursor.mergeCharFormat (charFormat); + cursor.clearSelection (); + cursor.movePosition (QTextCursor::End); + + // position so viewport scrolled to left + cursor.movePosition (QTextCursor::Up); + cursor.movePosition (QTextCursor::StartOfLine); + + ui->msgAvgPlainTextEdit->setTextCursor (cursor); + ui->msgAvgPlainTextEdit->ensureCursorVisible (); +} + +void MessageAveraging::read_settings () +{ + SettingsGroup group {settings_, "MessageAveraging"}; + restoreGeometry (settings_->value ("window/geometry").toByteArray ()); +} + +void MessageAveraging::write_settings () +{ + SettingsGroup group {settings_, "MessageAveraging"}; + settings_->setValue ("window/geometry", saveGeometry ()); +} + +void MessageAveraging::displayAvg(QString const& t) +{ + ui->msgAvgPlainTextEdit->setPlainText(t); +} diff --git a/widgets/messageaveraging.h b/widgets/messageaveraging.h new file mode 100644 index 00000000..4a8556b2 --- /dev/null +++ b/widgets/messageaveraging.h @@ -0,0 +1,32 @@ +// -*- Mode: C++ -*- +#ifndef MESSAGEAVERAGING_H_ +#define MESSAGEAVERAGING_H_ + +#include <QWidget> + +class QSettings; +class QFont; + +namespace Ui { + class MessageAveraging; +} + +class MessageAveraging + : public QWidget +{ +public: + explicit MessageAveraging(QSettings *, QFont const&, QWidget * parent = 0); + ~MessageAveraging(); + void displayAvg(QString const&); + void changeFont (QFont const&); + +private: + void read_settings (); + void write_settings (); + void setContentFont (QFont const&); + QSettings * settings_; + + QScopedPointer<Ui::MessageAveraging> ui; +}; + +#endif diff --git a/widgets/messageaveraging.ui b/widgets/messageaveraging.ui new file mode 100644 index 00000000..7957e66e --- /dev/null +++ b/widgets/messageaveraging.ui @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MessageAveraging</class> + <widget class="QWidget" name="MessageAveraging"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>405</width> + <height>268</height> + </rect> + </property> + <property name="windowTitle"> + <string>Message Averaging</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QGridLayout" name="gridLayout"> + <item row="1" column="0"> + <widget class="QPlainTextEdit" name="msgAvgPlainTextEdit"> + <property name="lineWrapMode"> + <enum>QPlainTextEdit::NoWrap</enum> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="header_label"> + <property name="text"> + <string> UTC Sync DT Freq </string> + </property> + <property name="margin"> + <number>3</number> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/widgets/meterwidget.cpp b/widgets/meterwidget.cpp new file mode 100644 index 00000000..9e441a15 --- /dev/null +++ b/widgets/meterwidget.cpp @@ -0,0 +1,83 @@ +// Simple bargraph meter +// Implemented by Edson Pereira PY2SDR + +#include "meterwidget.h" + +#include <QPainter> +#include <QPolygon> + +#include "moc_meterwidget.cpp" + +#define MAXDB 90 + +MeterWidget::MeterWidget(QWidget * parent) + : QWidget {parent} + , m_signal {0} + , m_noisePeak {0} + , m_sigPeak {0} +{ + for ( int i = 0; i < 10; i++ ) { + signalQueue.enqueue(0); + } +} + +void MeterWidget::setValue(int value) +{ + m_signal = value; + signalQueue.enqueue(value); + signalQueue.dequeue(); + + // Get signal peak + int tmp = 0; + for (int i = 0; i < signalQueue.size(); ++i) { + if (signalQueue.at(i) > tmp) + tmp = signalQueue.at(i); + } + m_noisePeak = tmp; + + update(); +} + +QSize MeterWidget::sizeHint () const +{ + return {10, 100}; +} + +void MeterWidget::paintEvent (QPaintEvent * event) +{ + QWidget::paintEvent (event); + + // Sanitize + m_signal = m_signal < 0 ? 0 : m_signal; + m_signal = m_signal > MAXDB ? MAXDB : m_signal; + + QPainter p {this}; + p.setPen (Qt::NoPen); + + auto const& target = contentsRect (); + QRect r {QPoint {target.left (), static_cast<int> (target.top () + target.height () - m_signal / (double)MAXDB * target.height ())} + , QPoint {target.right (), target.bottom ()}}; + p.setBrush (QColor(85,170,85)); + if (m_sigPeak > 85) { + p.setBrush(Qt::red); + } + else if (m_noisePeak < 15) { + p.setBrush(QColor(232,81,0)); + } + p.drawRect (r); + + if (m_noisePeak) + { + // Draw peak hold indicator + auto peak = static_cast<int> (target.top () + target.height () - m_noisePeak / (double)MAXDB * target.height ()); + p.setBrush (Qt::black); + p.translate (target.left (), peak); + p.drawPolygon (QPolygon {{{0, -4}, {0, 4}, {target.width (), 0}}}); + } +} + +// +void MeterWidget::set_sigPeak(int value) +{ + m_sigPeak = value; +} diff --git a/widgets/meterwidget.h b/widgets/meterwidget.h new file mode 100644 index 00000000..08bda6d5 --- /dev/null +++ b/widgets/meterwidget.h @@ -0,0 +1,33 @@ +// -*- Mode: C++ -*- +#ifndef METERWIDGET_H +#define METERWIDGET_H + +#include <QWidget> +#include <QQueue> + +class MeterWidget : public QWidget +{ + Q_OBJECT + Q_PROPERTY (int value READ value WRITE setValue) + +public: + explicit MeterWidget (QWidget *parent = 0); + + // value property + int value () const {return m_signal;} + Q_SLOT void setValue (int value); + + // QWidget implementation + QSize sizeHint () const override; + void set_sigPeak(int value); +protected: + void paintEvent( QPaintEvent * ) override; + +private: + QQueue<int> signalQueue; + int m_signal; + int m_noisePeak; + int m_sigPeak; // peak value for color coding +}; + +#endif // METERWIDGET_H diff --git a/widgets/plotter.cpp b/widgets/plotter.cpp new file mode 100644 index 00000000..761dae08 --- /dev/null +++ b/widgets/plotter.cpp @@ -0,0 +1,804 @@ +#include "plotter.h" +#include <math.h> +#include <QAction> +#include <QMenu> +#include <QPainter> +#include <QDateTime> +#include <QPen> +#include <QMouseEvent> +#include <QDebug> +#include "commons.h" +#include "moc_plotter.cpp" +#include <fstream> +#include <iostream> + +#define MAX_SCREENSIZE 2048 + +extern "C" { + void flat4_(float swide[], int* iz, int* nflatten); + void plotsave_(float swide[], int* m_w , int* m_h1, int* irow); +} + +CPlotter::CPlotter(QWidget *parent) : //CPlotter Constructor + QFrame {parent}, + m_set_freq_action {new QAction {tr ("&Set Rx && Tx Offset"), this}}, + m_bScaleOK {false}, + m_bReference {false}, + m_bReference0 {false}, + m_fSpan {2000.0}, + m_plotZero {0}, + m_plotGain {0}, + m_plot2dGain {0}, + m_plot2dZero {0}, + m_nSubMode {0}, + m_Running {false}, + m_paintEventBusy {false}, + m_fftBinWidth {1500.0/2048.0}, + m_dialFreq {0.}, + m_sum {}, + m_dBStepSize {10}, + m_FreqUnits {1}, + m_hdivs {HORZ_DIVS}, + m_line {0}, + m_fSample {12000}, + m_nsps {6912}, + m_Percent2DScreen {30}, //percent of screen used for 2D display + m_Percent2DScreen0 {0}, + m_rxFreq {1020}, + m_txFreq {0}, + m_startFreq {0} +{ + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + setFocusPolicy(Qt::StrongFocus); + setAttribute(Qt::WA_PaintOnScreen,false); + setAutoFillBackground(false); + setAttribute(Qt::WA_OpaquePaintEvent, false); + setAttribute(Qt::WA_NoSystemBackground, true); + m_bReplot=false; + + // contextual pop up menu + setContextMenuPolicy (Qt::CustomContextMenu); + connect (this, &QWidget::customContextMenuRequested, [this] (QPoint const& pos) { + QMenu menu {this}; + menu.addAction (m_set_freq_action); + auto const& connection = connect (m_set_freq_action, &QAction::triggered, [this, pos] () { + int newFreq = FreqfromX (pos.x ()) + .5; + emit setFreq1 (newFreq, newFreq); + }); + menu.exec (mapToGlobal (pos)); + disconnect (connection); + }); +} + +CPlotter::~CPlotter() { } // Destructor + +QSize CPlotter::minimumSizeHint() const +{ + return QSize(50, 50); +} + +QSize CPlotter::sizeHint() const +{ + return QSize(180, 180); +} + +void CPlotter::resizeEvent(QResizeEvent* ) //resizeEvent() +{ + if(!size().isValid()) return; + if( m_Size != size() or (m_bReference != m_bReference0) or + m_Percent2DScreen != m_Percent2DScreen0) { + m_Size = size(); + m_w = m_Size.width(); + m_h = m_Size.height(); + m_h2 = m_Percent2DScreen*m_h/100.0; + if(m_h2>m_h-30) m_h2=m_h-30; + if(m_bReference) m_h2=m_h-30; + if(m_h2<1) m_h2=1; + m_h1=m_h-m_h2; +// m_line=0; + m_2DPixmap = QPixmap(m_Size.width(), m_h2); + m_2DPixmap.fill(Qt::black); + m_WaterfallPixmap = QPixmap(m_Size.width(), m_h1); + m_OverlayPixmap = QPixmap(m_Size.width(), m_h2); + m_OverlayPixmap.fill(Qt::black); + m_WaterfallPixmap.fill(Qt::black); + m_2DPixmap.fill(Qt::black); + m_ScalePixmap = QPixmap(m_w,30); + m_ScalePixmap.fill(Qt::white); + m_Percent2DScreen0 = m_Percent2DScreen; + } + DrawOverlay(); +} + +void CPlotter::paintEvent(QPaintEvent *) // paintEvent() +{ + if(m_paintEventBusy) return; + m_paintEventBusy=true; + QPainter painter(this); + painter.drawPixmap(0,0,m_ScalePixmap); + painter.drawPixmap(0,30,m_WaterfallPixmap); + painter.drawPixmap(0,m_h1,m_2DPixmap); + m_paintEventBusy=false; +} + +void CPlotter::draw(float swide[], bool bScroll, bool bRed) +{ + int j,j0; + static int ktop=0; + float y,y2,ymin; + double fac = sqrt(m_binsPerPixel*m_waterfallAvg/15.0); + double gain = fac*pow(10.0,0.015*m_plotGain); + double gain2d = pow(10.0,0.02*(m_plot2dGain)); + + if(m_bReference != m_bReference0) resizeEvent(NULL); + m_bReference0=m_bReference; + +//move current data down one line (must do this before attaching a QPainter object) + if(bScroll and !m_bReplot) m_WaterfallPixmap.scroll(0,1,0,0,m_w,m_h1); + QPainter painter1(&m_WaterfallPixmap); + m_2DPixmap = m_OverlayPixmap.copy(0,0,m_w,m_h2); + QPainter painter2D(&m_2DPixmap); + if(!painter2D.isActive()) return; + QFont Font("Arial"); + Font.setPointSize(12); + Font.setWeight(QFont::Normal); + painter2D.setFont(Font); + + if(m_bLinearAvg) { + painter2D.setPen(Qt::yellow); + } else if(m_bReference) { + painter2D.setPen(Qt::blue); + } else { + painter2D.setPen(Qt::green); + } + static QPoint LineBuf[MAX_SCREENSIZE]; + static QPoint LineBuf2[MAX_SCREENSIZE]; + j=0; + j0=int(m_startFreq/m_fftBinWidth + 0.5); + int iz=XfromFreq(5000.0); + int jz=iz*m_binsPerPixel; + m_fMax=FreqfromX(iz); + + if(bScroll and swide[0]<1.e29) { + flat4_(swide,&iz,&m_Flatten); + if(!m_bReplot) flat4_(&dec_data.savg[j0],&jz,&m_Flatten); + } + + ymin=1.e30; + if(swide[0]>1.e29 and swide[0]< 1.5e30) painter1.setPen(Qt::green); + if(swide[0]>1.4e30) painter1.setPen(Qt::yellow); + if(!m_bReplot) { + m_j=0; + int irow=-1; + plotsave_(swide,&m_w,&m_h1,&irow); + } + for(int i=0; i<iz; i++) { + y=swide[i]; + if(y<ymin) ymin=y; + int y1 = 10.0*gain*y + m_plotZero; + if (y1<0) y1=0; + if (y1>254) y1=254; + if (swide[i]<1.e29) painter1.setPen(g_ColorTbl[y1]); + painter1.drawPoint(i,m_j); + } + + m_line++; + + float y2min=1.e30; + float y2max=-1.e30; + for(int i=0; i<iz; i++) { + y=swide[i] - ymin; + y2=0; + if(m_bCurrent) y2 = gain2d*y + m_plot2dZero; //Current + + if(bScroll) { + float sum=0.0; + int j=j0+m_binsPerPixel*i; + for(int k=0; k<m_binsPerPixel; k++) { + sum+=dec_data.savg[j++]; + } + m_sum[i]=sum; + } + if(m_bCumulative) y2=gain2d*(m_sum[i]/m_binsPerPixel + m_plot2dZero); + if(m_Flatten==0) y2 += 15; //### could do better! ### + + if(m_bLinearAvg) { //Linear Avg (yellow) + float sum=0.0; + int j=j0+m_binsPerPixel*i; + for(int k=0; k<m_binsPerPixel; k++) { + sum+=spectra_.syellow[j++]; + } + y2=gain2d*sum/m_binsPerPixel + m_plot2dZero; + } + + if(m_bReference) { //Reference (red) + float df_ref=12000.0/6912.0; + int j=FreqfromX(i)/df_ref + 0.5; + y2=spectra_.ref[j] + m_plot2dZero; +// if(gain2d>1.5) y2=spectra_.filter[j] + m_plot2dZero; + + } + + if(i==iz-1) { + painter2D.drawPolyline(LineBuf,j); + if(m_mode=="QRA64") { + painter2D.setPen(Qt::red); + painter2D.drawPolyline(LineBuf2,ktop); + } + } + LineBuf[j].setX(i); + LineBuf[j].setY(int(0.9*m_h2-y2*m_h2/70.0)); + if(y2<y2min) y2min=y2; + if(y2>y2max) y2max=y2; + j++; + } + if(m_bReplot) return; + + if(swide[0]>1.0e29) m_line=0; + if(m_line == painter1.fontMetrics ().height ()) { + painter1.setPen(Qt::white); + QString t; + qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000; + int n=(ms/1000) % m_TRperiod; + QDateTime t1=QDateTime::currentDateTimeUtc().addSecs(-n); + if(m_TRperiod < 60) { + t=t1.toString("hh:mm:ss") + " " + m_rxBand; + } else { + t=t1.toString("hh:mm") + " " + m_rxBand; + } + painter1.drawText (5, painter1.fontMetrics ().ascent (), t); + } + + if(m_mode=="JT4" or m_mode=="QRA64") { + QPen pen3(Qt::yellow); //Mark freqs of JT4 single-tone msgs + painter2D.setPen(pen3); + Font.setWeight(QFont::Bold); + painter2D.setFont(Font); + int x1=XfromFreq(m_rxFreq); + y=0.2*m_h2; + painter2D.drawText(x1-4,y,"T"); + x1=XfromFreq(m_rxFreq+250); + painter2D.drawText(x1-4,y,"M"); + x1=XfromFreq(m_rxFreq+500); + painter2D.drawText(x1-4,y,"R"); + x1=XfromFreq(m_rxFreq+750); + painter2D.drawText(x1-4,y,"73"); + } + + if(bRed) { + std::ifstream f; + f.open(m_redFile.toLatin1()); + if(f) { + int x,y; + float freq,sync; + float slimit=6.0; + QPen pen0(Qt::red,1); + painter1.setPen(pen0); + for(int i=0; i<99999; i++) { + f >> freq >> sync; + if(f.eof()) break; + x=XfromFreq(freq); + y=(sync-slimit)*3.0; + if(y>0) { + if(y>15.0) y=15.0; + if(x>=0 and x<=m_w) { + painter1.setPen(pen0); + painter1.drawLine(x,0,x,y); + } + } + } + f.close(); + } +// m_bDecodeFinished=false; + } + + update(); //trigger a new paintEvent + m_bScaleOK=true; +} + +void CPlotter::drawRed(int ia, int ib, float swide[]) +{ + m_ia=ia; + m_ib=ib; + draw(swide,false,true); +} + +void CPlotter::replot() +{ + float swide[m_w]; + m_bReplot=true; + for(int irow=0; irow<m_h1; irow++) { + m_j=irow; + plotsave_(swide,&m_w,&m_h1,&irow); + draw(swide,false,false); + } + update(); //trigger a new paintEvent + m_bReplot=false; +} + +void CPlotter::DrawOverlay() //DrawOverlay() +{ + if(m_OverlayPixmap.isNull()) return; + if(m_WaterfallPixmap.isNull()) return; + int w = m_WaterfallPixmap.width(); + int x,y,x1,x2,x3,x4,x5,x6; + float pixperdiv; + + double df = m_binsPerPixel*m_fftBinWidth; + QRect rect; + QPen penOrange(QColor(255,165,0),3); + QPen penGreen(Qt::green, 3); //Mark Tol range with green line + QPen penRed(Qt::red, 3); //Mark Tx freq with red + QPainter painter(&m_OverlayPixmap); + painter.initFrom(this); + QLinearGradient gradient(0, 0, 0 ,m_h2); //fill background with gradient + gradient.setColorAt(1, Qt::black); + gradient.setColorAt(0, Qt::darkBlue); + painter.setBrush(gradient); + painter.drawRect(0, 0, m_w, m_h2); + painter.setBrush(Qt::SolidPattern); + + m_fSpan = w*df; +// int n=m_fSpan/10; + m_freqPerDiv=10; + if(m_fSpan>100) m_freqPerDiv=20; + if(m_fSpan>250) m_freqPerDiv=50; + if(m_fSpan>500) m_freqPerDiv=100; + if(m_fSpan>1000) m_freqPerDiv=200; + if(m_fSpan>2500) m_freqPerDiv=500; + + pixperdiv = m_freqPerDiv/df; + m_hdivs = w*df/m_freqPerDiv + 1.9999; + + float xx0=float(m_startFreq)/float(m_freqPerDiv); + xx0=xx0-int(xx0); + int x0=xx0*pixperdiv+0.5; + for( int i=1; i<m_hdivs; i++) { //draw vertical grids + x = (int)((float)i*pixperdiv ) - x0; + if(x >= 0 and x<=m_w) { + painter.setPen(QPen(Qt::white, 1,Qt::DotLine)); + painter.drawLine(x, 0, x , m_h2); + } + } + + pixperdiv = (float)m_h2 / (float)VERT_DIVS; + painter.setPen(QPen(Qt::white, 1,Qt::DotLine)); + for( int i=1; i<VERT_DIVS; i++) { //draw horizontal grids + y = (int)( (float)i*pixperdiv ); + painter.drawLine(0, y, w, y); + } + + QRect rect0; + QPainter painter0(&m_ScalePixmap); + painter0.initFrom(this); + + //create Font to use for scales + QFont Font("Arial"); + Font.setPointSize(12); + Font.setWeight(QFont::Normal); + painter0.setFont(Font); + painter0.setPen(Qt::black); + + if(m_binsPerPixel < 1) m_binsPerPixel=1; + m_hdivs = w*df/m_freqPerDiv + 0.9999; + + m_ScalePixmap.fill(Qt::white); + painter0.drawRect(0, 0, w, 30); + MakeFrequencyStrs(); + +//draw tick marks on upper scale + pixperdiv = m_freqPerDiv/df; + for( int i=0; i<m_hdivs; i++) { //major ticks + x = (int)((m_xOffset+i)*pixperdiv ); + painter0.drawLine(x,18,x,30); + } + int minor=5; + if(m_freqPerDiv==200) minor=4; + for( int i=1; i<minor*m_hdivs; i++) { //minor ticks + x = i*pixperdiv/minor; + painter0.drawLine(x,24,x,30); + } + + //draw frequency values + for( int i=0; i<=m_hdivs; i++) { + x = (int)((m_xOffset+i)*pixperdiv - pixperdiv/2); + if(int(x+pixperdiv/2) > 70) { + rect0.setRect(x,0, (int)pixperdiv, 20); + painter0.drawText(rect0, Qt::AlignHCenter|Qt::AlignVCenter,m_HDivText[i]); + } + } + + float bw=9.0*12000.0/m_nsps; //JT9 + + if(m_mode=="FT8") bw=7*12000.0/1920.0; //FT8 + + if(m_mode=="JT4") { //JT4 + bw=3*11025.0/2520.0; //Max tone spacing (3/4 of actual BW) + if(m_nSubMode==1) bw=2*bw; + if(m_nSubMode==2) bw=4*bw; + if(m_nSubMode==3) bw=9*bw; + if(m_nSubMode==4) bw=18*bw; + if(m_nSubMode==5) bw=36*bw; + if(m_nSubMode==6) bw=72*bw; + + painter0.setPen(penGreen); + x1=XfromFreq(m_rxFreq-m_tol); + x2=XfromFreq(m_rxFreq+m_tol); + painter0.drawLine(x1,29,x2,29); + for(int i=0; i<4; i++) { + x1=XfromFreq(m_rxFreq+bw*i/3.0); + int j=24; + if(i==0) j=18; + painter0.drawLine(x1,j,x1,30); + } + painter0.setPen(penRed); + for(int i=0; i<4; i++) { + x1=XfromFreq(m_txFreq+bw*i/3.0); + painter0.drawLine(x1,12,x1,18); + } + } + + if(m_modeTx=="JT9" and m_nSubMode>0) { //JT9 + bw=8.0*12000.0/m_nsps; + if(m_nSubMode==1) bw=2*bw; //B + if(m_nSubMode==2) bw=4*bw; //C + if(m_nSubMode==3) bw=8*bw; //D + if(m_nSubMode==4) bw=16*bw; //E + if(m_nSubMode==5) bw=32*bw; //F + if(m_nSubMode==6) bw=64*bw; //G + if(m_nSubMode==7) bw=128*bw; //H + } + + if(m_mode=="QRA64") { //QRA64 + bw=63.0*12000.0/m_nsps; + if(m_nSubMode==1) bw=2*bw; //B + if(m_nSubMode==2) bw=4*bw; //C + if(m_nSubMode==3) bw=8*bw; //D + if(m_nSubMode==4) bw=16*bw; //E + } + + if(m_modeTx=="JT65") { //JT65 + bw=65.0*11025.0/4096.0; + if(m_nSubMode==1) bw=2*bw; //B + if(m_nSubMode==2) bw=4*bw; //C + } + + painter0.setPen(penGreen); + if(m_mode=="WSPR") { + x1=XfromFreq(1400); + x2=XfromFreq(1600); + painter0.drawLine(x1,29,x2,29); + } + + if(m_mode=="WSPR-LF") { + x1=XfromFreq(1600); + x2=XfromFreq(1700); + painter0.drawLine(x1,29,x2,29); + } + + if(m_mode=="FreqCal") { //FreqCal + x1=XfromFreq(m_rxFreq-m_tol); + x2=XfromFreq(m_rxFreq+m_tol); + painter0.drawLine(x1,29,x2,29); + x1=XfromFreq(m_rxFreq); + painter0.drawLine(x1,24,x1,30); + } + + if(m_mode=="JT9" or m_mode=="JT65" or m_mode=="JT9+JT65" or m_mode=="QRA64" or m_mode=="FT8") { + + if(m_mode=="QRA64" or (m_mode=="JT65" and m_bVHF)) { + painter0.setPen(penGreen); + x1=XfromFreq(m_rxFreq-m_tol); + x2=XfromFreq(m_rxFreq+m_tol); + painter0.drawLine(x1,28,x2,28); + x1=XfromFreq(m_rxFreq); + painter0.drawLine(x1,24,x1,30); + + if(m_mode=="JT65") { + painter0.setPen(penOrange); + x3=XfromFreq(m_rxFreq+20.0*bw/65.0); //RO + painter0.drawLine(x3,24,x3,30); + x4=XfromFreq(m_rxFreq+30.0*bw/65.0); //RRR + painter0.drawLine(x4,24,x4,30); + x5=XfromFreq(m_rxFreq+40.0*bw/65.0); //73 + painter0.drawLine(x5,24,x5,30); + } + painter0.setPen(penGreen); + x6=XfromFreq(m_rxFreq+bw); //Highest tone + painter0.drawLine(x6,24,x6,30); + + } else { + painter0.setPen(penGreen); + x1=XfromFreq(m_rxFreq); + x2=XfromFreq(m_rxFreq+bw); + painter0.drawLine(x1,24,x1,30); + painter0.drawLine(x1,28,x2,28); + painter0.drawLine(x2,24,x2,30); + } + } + + if(m_mode=="JT9" or m_mode=="JT65" or m_mode=="JT9+JT65" or + m_mode.mid(0,4)=="WSPR" or m_mode=="QRA64" or m_mode=="FT8") { + painter0.setPen(penRed); + x1=XfromFreq(m_txFreq); + x2=XfromFreq(m_txFreq+bw); + if(m_mode=="WSPR") { + bw=4*12000.0/8192.0; //WSPR + x1=XfromFreq(m_txFreq-0.5*bw); + x2=XfromFreq(m_txFreq+0.5*bw); + } + if(m_mode=="WSPR-LF") { + bw=3*12000.0/8640.0; //WSPR-LF + x1=XfromFreq(m_txFreq-0.5*bw); + x2=XfromFreq(m_txFreq+0.5*bw); + } + painter0.drawLine(x1,17,x1,21); + painter0.drawLine(x1,17,x2,17); + painter0.drawLine(x2,17,x2,21); + } + + if(m_mode=="JT9+JT65") { + QPen pen2(Qt::blue, 3); //Mark the JT65 | JT9 divider + painter0.setPen(pen2); + x1=XfromFreq(m_fMin); + if(x1<2) x1=2; + x2=x1+30; + painter0.drawLine(x1,8,x1,28); + } + + if(m_dialFreq>10.13 and m_dialFreq< 10.15 and m_mode.mid(0,4)!="WSPR") { + float f1=1.0e6*(10.1401 - m_dialFreq); + float f2=f1+200.0; + x1=XfromFreq(f1); + x2=XfromFreq(f2); + if(x1<=m_w and x2>=0) { + painter0.setPen(penOrange); //Mark WSPR sub-band orange + painter0.drawLine(x1,9,x2,9); + } + } +} + +void CPlotter::MakeFrequencyStrs() //MakeFrequencyStrs +{ + int f=(m_startFreq+m_freqPerDiv-1)/m_freqPerDiv; + f*=m_freqPerDiv; + m_xOffset=float(f-m_startFreq)/m_freqPerDiv; + for(int i=0; i<=m_hdivs; i++) { + m_HDivText[i].setNum(f); + f+=m_freqPerDiv; + } +} + +int CPlotter::XfromFreq(float f) //XfromFreq() +{ +// float w = m_WaterfallPixmap.width(); + int x = int(m_w * (f - m_startFreq)/m_fSpan + 0.5); + if(x<0 ) return 0; + if(x>m_w) return m_w; + return x; +} + +float CPlotter::FreqfromX(int x) //FreqfromX() +{ + return float(m_startFreq + x*m_binsPerPixel*m_fftBinWidth); +} + +void CPlotter::SetRunningState(bool running) //SetRunningState() +{ + m_Running = running; +} + +void CPlotter::setPlotZero(int plotZero) //setPlotZero() +{ + m_plotZero=plotZero; +} + +int CPlotter::plotZero() //PlotZero() +{ + return m_plotZero; +} + +void CPlotter::setPlotGain(int plotGain) //setPlotGain() +{ + m_plotGain=plotGain; +} + +int CPlotter::plotGain() //plotGain() +{ + return m_plotGain; +} + +int CPlotter::plot2dGain() //plot2dGain +{ + return m_plot2dGain; +} + +void CPlotter::setPlot2dGain(int n) //setPlot2dGain +{ + m_plot2dGain=n; + update(); +} + +int CPlotter::plot2dZero() //plot2dZero +{ + return m_plot2dZero; +} + +void CPlotter::setPlot2dZero(int plot2dZero) //setPlot2dZero +{ + m_plot2dZero=plot2dZero; +} + +void CPlotter::setStartFreq(int f) //SetStartFreq() +{ + m_startFreq=f; + resizeEvent(NULL); + update(); +} + +int CPlotter::startFreq() //startFreq() +{ + return m_startFreq; +} + +int CPlotter::plotWidth(){return m_WaterfallPixmap.width();} //plotWidth +void CPlotter::UpdateOverlay() {DrawOverlay();} //UpdateOverlay +void CPlotter::setDataFromDisk(bool b) {m_dataFromDisk=b;} //setDataFromDisk + +void CPlotter::setRxRange(int fMin) //setRxRange +{ + m_fMin=fMin; +} + +void CPlotter::setBinsPerPixel(int n) //setBinsPerPixel +{ + m_binsPerPixel = n; + DrawOverlay(); //Redraw scales and ticks + update(); //trigger a new paintEvent} +} + +int CPlotter::binsPerPixel() //binsPerPixel +{ + return m_binsPerPixel; +} + +void CPlotter::setWaterfallAvg(int n) //setNavg +{ + m_waterfallAvg = n; +} + +void CPlotter::setRxFreq (int x) //setRxFreq +{ + m_rxFreq = x; // x is freq in Hz + DrawOverlay(); + update(); +} + +int CPlotter::rxFreq() {return m_rxFreq;} //rxFreq + +void CPlotter::mouseReleaseEvent (QMouseEvent * event) +{ + if (Qt::LeftButton == event->button ()) { + int x=event->x(); + if(x<0) x=0; + if(x>m_Size.width()) x=m_Size.width(); + bool ctrl = (event->modifiers() & Qt::ControlModifier); + bool shift = (event->modifiers() & Qt::ShiftModifier); + int newFreq = int(FreqfromX(x)+0.5); + int oldTxFreq = m_txFreq; + int oldRxFreq = m_rxFreq; + if (ctrl) { + emit setFreq1 (newFreq, newFreq); + } else if (shift) { + emit setFreq1 (oldRxFreq, newFreq); + } else { + emit setFreq1(newFreq,oldTxFreq); + } + + int n=1; + if(ctrl) n+=100; + emit freezeDecode1(n); + } + else { + event->ignore (); // let parent handle + } +} + +void CPlotter::mouseDoubleClickEvent (QMouseEvent * event) +{ + if (Qt::LeftButton == event->button ()) { + bool ctrl = (event->modifiers() & Qt::ControlModifier); + int n=2; + if(ctrl) n+=100; + emit freezeDecode1(n); + } + else { + event->ignore (); // let parent handle + } +} + +void CPlotter::setNsps(int ntrperiod, int nsps) //setNsps +{ + m_TRperiod=ntrperiod; + m_nsps=nsps; + m_fftBinWidth=1500.0/2048.0; + if(m_nsps==15360) m_fftBinWidth=1500.0/2048.0; + if(m_nsps==40960) m_fftBinWidth=1500.0/6144.0; + if(m_nsps==82944) m_fftBinWidth=1500.0/12288.0; + if(m_nsps==252000) m_fftBinWidth=1500.0/32768.0; + DrawOverlay(); //Redraw scales and ticks + update(); //trigger a new paintEvent} +} + +void CPlotter::setTxFreq(int n) //setTxFreq +{ + m_txFreq=n; + DrawOverlay(); + update(); +} + +void CPlotter::setMode(QString mode) //setMode +{ + m_mode=mode; +} + +void CPlotter::setSubMode(int n) //setSubMode +{ + m_nSubMode=n; +} + +void CPlotter::setModeTx(QString modeTx) //setModeTx +{ + m_modeTx=modeTx; +} + +int CPlotter::Fmax() +{ + return m_fMax; +} + +void CPlotter::setDialFreq(double d) +{ + m_dialFreq=d; + DrawOverlay(); + update(); +} + +void CPlotter::setRxBand(QString band) +{ + m_rxBand=band; +} + +void CPlotter::setFlatten(bool b1, bool b2) +{ + m_Flatten=0; + if(b1) m_Flatten=1; + if(b2) m_Flatten=2; +} + +void CPlotter::setTol(int n) //setTol() +{ + m_tol=n; + DrawOverlay(); +} + +void CPlotter::setColours(QVector<QColor> const& cl) +{ + g_ColorTbl = cl; +} + +void CPlotter::SetPercent2DScreen(int percent) +{ + m_Percent2DScreen=percent; + resizeEvent(NULL); + update(); +} +void CPlotter::setVHF(bool bVHF) +{ + m_bVHF=bVHF; +} + +void CPlotter::setRedFile(QString fRed) +{ + m_redFile=fRed; +} diff --git a/widgets/plotter.h b/widgets/plotter.h new file mode 100644 index 00000000..e243c177 --- /dev/null +++ b/widgets/plotter.h @@ -0,0 +1,178 @@ +// -*- Mode: C++ -*- +/////////////////////////////////////////////////////////////////////////// +// Some code in this file and accompanying files is based on work by +// Moe Wheatley, AE4Y, released under the "Simplified BSD License". +// For more details see the accompanying file LICENSE_WHEATLEY.TXT +/////////////////////////////////////////////////////////////////////////// + +#ifndef PLOTTER_H_ +#define PLOTTER_H_ + +#include <QFrame> +#include <QSize> +#include <QImage> +#include <QVector> +#include <QColor> + +#define VERT_DIVS 7 //specify grid screen divisions +#define HORZ_DIVS 20 + +extern bool g_single_decode; + +class QAction; + +class CPlotter : public QFrame +{ + Q_OBJECT + +public: + explicit CPlotter(QWidget *parent = 0); + ~CPlotter(); + + QSize minimumSizeHint() const; + QSize sizeHint() const; + + void draw(float swide[], bool bScroll, bool bRed); //Update the waterfall + void replot(); + void SetRunningState(bool running); + void setPlotZero(int plotZero); + int plotZero(); + void setPlotGain(int plotGain); + int plotGain(); + int plot2dGain(); + void setPlot2dGain(int n); + int plot2dZero(); + void setPlot2dZero(int plot2dZero); + void setStartFreq(int f); + int startFreq(); + int plotWidth(); + void UpdateOverlay(); + void setDataFromDisk(bool b); + void setRxRange(int fMin); + void setBinsPerPixel(int n); + int binsPerPixel(); + void setWaterfallAvg(int n); + void setRxFreq(int n); + void DrawOverlay(); + int rxFreq(); + void setFsample(int n); + void setNsps(int ntrperiod, int nsps); + void setTxFreq(int n); + void setMode(QString mode); + void setSubMode(int n); + void setModeTx(QString modeTx); + void SetPercent2DScreen(int percent); + int Fmax(); + void setDialFreq(double d); + void setCurrent(bool b) {m_bCurrent = b;} + bool current() const {return m_bCurrent;} + void setCumulative(bool b) {m_bCumulative = b;} + bool cumulative() const {return m_bCumulative;} + void setLinearAvg(bool b) {m_bLinearAvg = b;} + bool linearAvg() const {return m_bLinearAvg;} + void setBreadth(qint32 w) {m_w = w;} + qint32 breadth() const {return m_w;} + float fSpan() const {return m_fSpan;} + void setColours(QVector<QColor> const& cl); + void setFlatten(bool b1, bool b2); + void setTol(int n); + void setRxBand(QString band); + void setReference(bool b) {m_bReference = b;} + bool Reference() const {return m_bReference;} + void drawRed(int ia, int ib, float swide[]); + void setVHF(bool bVHF); + void setRedFile(QString fRed); + bool scaleOK () const {return m_bScaleOK;} +signals: + void freezeDecode1(int n); + void setFreq1(int rxFreq, int txFreq); + +protected: + //re-implemented widget event handlers + void paintEvent(QPaintEvent *event) override; + void resizeEvent(QResizeEvent* event) override; + void mouseReleaseEvent (QMouseEvent * event) override; + void mouseDoubleClickEvent (QMouseEvent * event) override; + +private: + + void MakeFrequencyStrs(); + int XfromFreq(float f); + float FreqfromX(int x); + + QAction * m_set_freq_action; + + bool m_bScaleOK; + bool m_bCurrent; + bool m_bCumulative; + bool m_bLinearAvg; + bool m_bReference; + bool m_bReference0; + bool m_bVHF; + + float m_fSpan; + + qint32 m_plotZero; + qint32 m_plotGain; + qint32 m_plot2dGain; + qint32 m_plot2dZero; + qint32 m_binsPerPixel; + qint32 m_waterfallAvg; + qint32 m_w; + qint32 m_Flatten; + qint32 m_nSubMode; + qint32 m_ia; + qint32 m_ib; + + QPixmap m_WaterfallPixmap; + QPixmap m_2DPixmap; + QPixmap m_ScalePixmap; + QPixmap m_OverlayPixmap; + + QSize m_Size; + QString m_Str; + QString m_HDivText[483]; + QString m_mode; + QString m_modeTx; + QString m_rxBand; + QString m_redFile; + + bool m_Running; + bool m_paintEventBusy; + bool m_dataFromDisk; + bool m_bReplot; + + double m_fftBinWidth; + double m_dialFreq; + double m_xOffset; + + float m_sum[2048]; + + qint32 m_dBStepSize; + qint32 m_FreqUnits; + qint32 m_hdivs; + qint32 m_line; + qint32 m_fSample; + qint32 m_xClick; + qint32 m_freqPerDiv; + qint32 m_nsps; + qint32 m_Percent2DScreen; + qint32 m_Percent2DScreen0; + qint32 m_h; + qint32 m_h1; + qint32 m_h2; + qint32 m_TRperiod; + qint32 m_rxFreq; + qint32 m_txFreq; + qint32 m_fMin; + qint32 m_fMax; + qint32 m_startFreq; + qint32 m_tol; + qint32 m_j; + + char m_sutc[6]; +}; + +extern QVector<QColor> g_ColorTbl; + +#endif // PLOTTER_H diff --git a/widgets/signalmeter.cpp b/widgets/signalmeter.cpp new file mode 100644 index 00000000..715c8dbd --- /dev/null +++ b/widgets/signalmeter.cpp @@ -0,0 +1,107 @@ +// Simple bargraph dB meter +// Implemented by Edson Pereira PY2SDR +// + +#include "signalmeter.h" + +#include <QVBoxLayout> +#include <QHBoxLayout> +#include <QLabel> +#include <QPainter> +#include <QFontMetrics> +#include <QDebug> + +#include "meterwidget.h" + +#include "moc_signalmeter.cpp" + +#define MAXDB 90 + +class Scale final + : public QWidget +{ +public: + explicit Scale (QWidget * parent = 0) + : QWidget {parent} + { + setSizePolicy (QSizePolicy::Minimum, QSizePolicy::MinimumExpanding); + } + + QSize sizeHint () const override + { + return minimumSizeHint (); + } + + QSize minimumSizeHint () const override + { + QFontMetrics font_metrics {font (), nullptr}; + return {tick_length + text_indent + font_metrics.width ("00+"), (font_metrics.height () + line_spacing) * range}; + } + +protected: + void paintEvent (QPaintEvent * event) override + { + QWidget::paintEvent (event); + + QPainter p {this}; + auto const& target = contentsRect (); + QFontMetrics font_metrics {p.font (), this}; + auto font_offset = font_metrics.ascent () / 2; + p.drawLine (target.left (), target.top () + font_offset, target.left (), target.bottom () - font_offset - font_metrics.descent ()); + for (int i = 0; i <= range; ++i) + { + p.save (); + p.translate (target.left () + , target.top () + font_offset + i * (target.height () - font_metrics.ascent () - font_metrics.descent ()) / range); + p.drawLine (0, 0, tick_length, 0); + if((i%2==1)) { + auto text = QString::number ((range - i) * scale); + p.drawText (tick_length + text_indent, font_offset, text); + } + p.restore (); + } + } + +private: + static int constexpr tick_length {4}; + static int constexpr text_indent {2}; + static int constexpr line_spacing {0}; + static int constexpr range {MAXDB/10}; + static int constexpr scale {10}; +}; + +SignalMeter::SignalMeter (QWidget * parent) + : QFrame {parent} +{ + auto outer_layout = new QVBoxLayout; + outer_layout->setSpacing (0); + + auto inner_layout = new QHBoxLayout; + inner_layout->setContentsMargins (9, 0, 9, 0); + inner_layout->setSpacing (0); + + m_meter = new MeterWidget; + m_meter->setSizePolicy (QSizePolicy::Minimum, QSizePolicy::Minimum); + inner_layout->addWidget (m_meter); + + m_scale = new Scale; + inner_layout->addWidget (m_scale); + + m_reading = new QLabel(this); + + outer_layout->addLayout (inner_layout); + outer_layout->addWidget (m_reading); + setLayout (outer_layout); +} + +void SignalMeter::setValue(float value, float valueMax) +{ + if(value<0) value=0; + QFontMetrics font_metrics {m_scale->font (), nullptr}; + m_meter->setContentsMargins (0, font_metrics.ascent () / 2, 0, font_metrics.ascent () / 2 + font_metrics.descent ()); + m_meter->setValue(int(value)); + m_meter->set_sigPeak(valueMax); + QString t; + t.sprintf("%d dB",int(value+0.5)); + m_reading->setText(t); +} diff --git a/widgets/signalmeter.h b/widgets/signalmeter.h new file mode 100644 index 00000000..bf277ebd --- /dev/null +++ b/widgets/signalmeter.h @@ -0,0 +1,27 @@ +// -*- Mode: C++ -*- +#ifndef SIGNALMETER_H +#define SIGNALMETER_H + +#include <QFrame> + +class QLabel; +class MeterWidget; + +class SignalMeter final + : public QFrame +{ + Q_OBJECT + +public: + explicit SignalMeter (QWidget * parent = nullptr); + +public slots: + void setValue (float value, float valueMax); + +private: + MeterWidget * m_meter; + QWidget * m_scale; + QLabel * m_reading; +}; + +#endif // SIGNALMETER_H diff --git a/widgets/widegraph.cpp b/widgets/widegraph.cpp new file mode 100644 index 00000000..b4601ba4 --- /dev/null +++ b/widgets/widegraph.cpp @@ -0,0 +1,525 @@ +#include "widegraph.h" + +#include <algorithm> +#include <QApplication> +#include <QSettings> +#include <QDateTime> +#include <QKeyEvent> +#include "ui_widegraph.h" +#include "commons.h" +#include "Configuration.hpp" +#include "MessageBox.hpp" +#include "SettingsGroup.hpp" +#include "moc_widegraph.cpp" + +namespace +{ + auto user_defined = QObject::tr ("User Defined"); + float swide[MAX_SCREENSIZE]; +} + +WideGraph::WideGraph(QSettings * settings, QWidget *parent) : + QDialog(parent), + ui(new Ui::WideGraph), + m_settings (settings), + m_palettes_path {":/Palettes"}, + m_ntr0 {0}, + m_n {0}, + m_bHaveTransmitted {false} +{ + ui->setupUi(this); + + setWindowTitle (QApplication::applicationName () + " - " + tr ("Wide Graph")); + setWindowFlags (Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint); + setMaximumWidth (MAX_SCREENSIZE); + setMaximumHeight (880); + + ui->widePlot->setCursor(Qt::CrossCursor); + ui->widePlot->setMaximumHeight(800); + ui->widePlot->setCurrent(false); + + connect(ui->widePlot, SIGNAL(freezeDecode1(int)),this, + SLOT(wideFreezeDecode(int))); + + connect(ui->widePlot, SIGNAL(setFreq1(int,int)),this, + SLOT(setFreq2(int,int))); + + { + //Restore user's settings + SettingsGroup g {m_settings, "WideGraph"}; + restoreGeometry (m_settings->value ("geometry", saveGeometry ()).toByteArray ()); + ui->widePlot->setPlotZero(m_settings->value("PlotZero", 0).toInt()); + ui->widePlot->setPlotGain(m_settings->value("PlotGain", 0).toInt()); + ui->widePlot->setPlot2dGain(m_settings->value("Plot2dGain", 0).toInt()); + ui->widePlot->setPlot2dZero(m_settings->value("Plot2dZero", 0).toInt()); + ui->zeroSlider->setValue(ui->widePlot->plotZero()); + ui->gainSlider->setValue(ui->widePlot->plotGain()); + ui->gain2dSlider->setValue(ui->widePlot->plot2dGain()); + ui->zero2dSlider->setValue(ui->widePlot->plot2dZero()); + int n = m_settings->value("BinsPerPixel",2).toInt(); + m_bFlatten=m_settings->value("Flatten",true).toBool(); + m_bRef=m_settings->value("UseRef",false).toBool(); + ui->cbFlatten->setChecked(m_bFlatten); + ui->widePlot->setFlatten(m_bFlatten,m_bRef); + ui->cbRef->setChecked(m_bRef); + ui->widePlot->setBreadth(m_settings->value("PlotWidth",1000).toInt()); + ui->bppSpinBox->setValue(n); + m_nsmo=m_settings->value("SmoothYellow",1).toInt(); + ui->smoSpinBox->setValue(m_nsmo); + m_Percent2DScreen=m_settings->value("Percent2D",30).toInt(); + m_waterfallAvg = m_settings->value("WaterfallAvg",5).toInt(); + ui->waterfallAvgSpinBox->setValue(m_waterfallAvg); + ui->widePlot->setWaterfallAvg(m_waterfallAvg); + ui->widePlot->setCurrent(m_settings->value("Current",false).toBool()); + ui->widePlot->setCumulative(m_settings->value("Cumulative",true).toBool()); + ui->widePlot->setLinearAvg(m_settings->value("LinearAvg",false).toBool()); + ui->widePlot->setReference(m_settings->value("Reference",false).toBool()); + if(ui->widePlot->current()) ui->spec2dComboBox->setCurrentIndex(0); + if(ui->widePlot->cumulative()) ui->spec2dComboBox->setCurrentIndex(1); + if(ui->widePlot->linearAvg()) ui->spec2dComboBox->setCurrentIndex(2); + if(ui->widePlot->Reference()) ui->spec2dComboBox->setCurrentIndex(3); + int nbpp=m_settings->value("BinsPerPixel",2).toInt(); + ui->widePlot->setBinsPerPixel(nbpp); + ui->sbPercent2dPlot->setValue(m_Percent2DScreen); + ui->widePlot->setStartFreq(m_settings->value("StartFreq",0).toInt()); + ui->fStartSpinBox->setValue(ui->widePlot->startFreq()); + m_waterfallPalette=m_settings->value("WaterfallPalette","Default").toString(); + m_userPalette = WFPalette {m_settings->value("UserPalette").value<WFPalette::Colours> ()}; + m_fMinPerBand = m_settings->value ("FminPerBand").toHash (); + setRxRange (); + ui->controls_widget->setVisible(!m_settings->value("HideControls",false).toBool()); + ui->cbControls->setChecked(!m_settings->value("HideControls",false).toBool()); + } + + int index=0; + for (QString const& file: + m_palettes_path.entryList(QDir::NoDotAndDotDot | + QDir::System | QDir::Hidden | + QDir::AllDirs | QDir::Files, + QDir::DirsFirst)) { + QString t=file.mid(0,file.length()-4); + ui->paletteComboBox->addItem(t); + if(t==m_waterfallPalette) ui->paletteComboBox->setCurrentIndex(index); + index++; + } + ui->paletteComboBox->addItem (user_defined); + if (user_defined == m_waterfallPalette) ui->paletteComboBox->setCurrentIndex(index); + readPalette (); +} + +WideGraph::~WideGraph () +{ +} + +void WideGraph::closeEvent (QCloseEvent * e) +{ + saveSettings (); + QDialog::closeEvent (e); +} + +void WideGraph::saveSettings() //saveSettings +{ + SettingsGroup g {m_settings, "WideGraph"}; + m_settings->setValue ("geometry", saveGeometry ()); + m_settings->setValue ("PlotZero", ui->widePlot->plotZero()); + m_settings->setValue ("PlotGain", ui->widePlot->plotGain()); + m_settings->setValue ("Plot2dGain", ui->widePlot->plot2dGain()); + m_settings->setValue ("Plot2dZero", ui->widePlot->plot2dZero()); + m_settings->setValue ("PlotWidth", ui->widePlot->plotWidth ()); + m_settings->setValue ("BinsPerPixel", ui->bppSpinBox->value ()); + m_settings->setValue ("SmoothYellow", ui->smoSpinBox->value ()); + m_settings->setValue ("Percent2D",m_Percent2DScreen); + m_settings->setValue ("WaterfallAvg", ui->waterfallAvgSpinBox->value ()); + m_settings->setValue ("Current", ui->widePlot->current()); + m_settings->setValue ("Cumulative", ui->widePlot->cumulative()); + m_settings->setValue ("LinearAvg", ui->widePlot->linearAvg()); + m_settings->setValue ("Reference", ui->widePlot->Reference()); + m_settings->setValue ("BinsPerPixel", ui->widePlot->binsPerPixel ()); + m_settings->setValue ("StartFreq", ui->widePlot->startFreq ()); + m_settings->setValue ("WaterfallPalette", m_waterfallPalette); + m_settings->setValue ("UserPalette", QVariant::fromValue (m_userPalette.colours ())); + m_settings->setValue("Flatten",m_bFlatten); + m_settings->setValue("UseRef",m_bRef); + m_settings->setValue ("HideControls", ui->controls_widget->isHidden ()); + m_settings->setValue ("FminPerBand", m_fMinPerBand); +} + +void WideGraph::drawRed(int ia, int ib) +{ + ui->widePlot->drawRed(ia,ib,swide); +} + +void WideGraph::dataSink2(float s[], float df3, int ihsym, int ndiskdata) //dataSink2 +{ + static float splot[NSMAX]; + int nbpp = ui->widePlot->binsPerPixel(); + +//Average spectra over specified number, m_waterfallAvg + if (m_n==0) { + for (int i=0; i<NSMAX; i++) + splot[i]=s[i]; + } else { + for (int i=0; i<NSMAX; i++) + splot[i] += s[i]; + } + m_n++; + + if (m_n>=m_waterfallAvg) { + for (int i=0; i<NSMAX; i++) + splot[i] /= m_n; //Normalize the average + m_n=0; + int i=int(ui->widePlot->startFreq()/df3 + 0.5); + int jz=5000.0/(nbpp*df3); + if(jz>MAX_SCREENSIZE) jz=MAX_SCREENSIZE; + m_jz=jz; + for (int j=0; j<jz; j++) { + float ss=0.0; + float smax=0; + for (int k=0; k<nbpp; k++) { + float sp=splot[i++]; + ss += sp; + smax=qMax(smax,sp); + } +// swide[j]=nbpp*smax; + swide[j]=nbpp*ss; + } + +// Time according to this computer + qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000; + int ntr = (ms/1000) % m_TRperiod; + if((ndiskdata && ihsym <= m_waterfallAvg) || (!ndiskdata && ntr<m_ntr0)) { + float flagValue=1.0e30; + if(m_bHaveTransmitted) flagValue=2.0e30; + for(int i=0; i<MAX_SCREENSIZE; i++) { + swide[i] = flagValue; + } + for(int i=0; i<NSMAX; i++) { + splot[i] = flagValue; + } + m_bHaveTransmitted=false; + } + m_ntr0=ntr; + ui->widePlot->draw(swide,true,false); + } +} + +void WideGraph::on_bppSpinBox_valueChanged(int n) //bpp +{ + ui->widePlot->setBinsPerPixel(n); +} + +void WideGraph::on_waterfallAvgSpinBox_valueChanged(int n) //Navg +{ + m_waterfallAvg = n; + ui->widePlot->setWaterfallAvg(n); +} + +void WideGraph::keyPressEvent(QKeyEvent *e) //F11, F12 +{ + switch(e->key()) + { + int n; + case Qt::Key_F11: + n=11; + if(e->modifiers() & Qt::ControlModifier) n+=100; + emit f11f12(n); + break; + case Qt::Key_F12: + n=12; + if(e->modifiers() & Qt::ControlModifier) n+=100; + emit f11f12(n); + break; + default: + QDialog::keyPressEvent (e); + } +} + +void WideGraph::setRxFreq(int n) //setRxFreq +{ + ui->widePlot->setRxFreq(n); + ui->widePlot->draw(swide,false,false); +} + +int WideGraph::rxFreq() //rxFreq +{ + return ui->widePlot->rxFreq(); +} + +int WideGraph::nStartFreq() //nStartFreq +{ + return ui->widePlot->startFreq(); +} + +void WideGraph::wideFreezeDecode(int n) //wideFreezeDecode +{ + emit freezeDecode2(n); +} + +void WideGraph::setRxRange () +{ + ui->widePlot->setRxRange (Fmin ()); + ui->widePlot->DrawOverlay(); + ui->widePlot->update(); +} + +int WideGraph::Fmin() //Fmin +{ + return "60m" == m_rxBand ? 0 : m_fMinPerBand.value (m_rxBand, 2500).toUInt (); +} + +int WideGraph::Fmax() //Fmax +{ + return std::min(5000,ui->widePlot->Fmax()); +} + +int WideGraph::fSpan() +{ + return ui->widePlot->fSpan (); +} + +void WideGraph::setPeriod(int ntrperiod, int nsps) //SetPeriod +{ + m_TRperiod=ntrperiod; + m_nsps=nsps; + ui->widePlot->setNsps(ntrperiod, nsps); +} + +void WideGraph::setTxFreq(int n) //setTxFreq +{ + emit setXIT2(n); + ui->widePlot->setTxFreq(n); +} + +void WideGraph::setMode(QString mode) //setMode +{ + m_mode=mode; + ui->fSplitSpinBox->setEnabled(m_mode=="JT9+JT65"); + ui->widePlot->setMode(mode); + ui->widePlot->DrawOverlay(); + ui->widePlot->update(); +} + +void WideGraph::setSubMode(int n) //setSubMode +{ + m_nSubMode=n; + ui->widePlot->setSubMode(n); + ui->widePlot->DrawOverlay(); + ui->widePlot->update(); +} +void WideGraph::setModeTx(QString modeTx) //setModeTx +{ + m_modeTx=modeTx; + ui->widePlot->setModeTx(modeTx); + ui->widePlot->DrawOverlay(); + ui->widePlot->update(); +} + + //Current-Cumulative-Yellow +void WideGraph::on_spec2dComboBox_currentIndexChanged(const QString &arg1) +{ + ui->widePlot->setCurrent(false); + ui->widePlot->setCumulative(false); + ui->widePlot->setLinearAvg(false); + ui->widePlot->setReference(false); + ui->smoSpinBox->setEnabled(false); + if(arg1=="Current") ui->widePlot->setCurrent(true); + if(arg1=="Cumulative") ui->widePlot->setCumulative(true); + if(arg1=="Linear Avg") { + ui->widePlot->setLinearAvg(true); + ui->smoSpinBox->setEnabled(true); + } + if(arg1=="Reference") { + ui->widePlot->setReference(true); + } + replot(); +} + +void WideGraph::on_fSplitSpinBox_valueChanged(int n) //fSplit +{ + if (m_rxBand != "60m") m_fMinPerBand[m_rxBand] = n; + setRxRange (); +} + +void WideGraph::setFreq2(int rxFreq, int txFreq) //setFreq2 +{ + emit setFreq3(rxFreq,txFreq); +} + +void WideGraph::setDialFreq(double d) //setDialFreq +{ + ui->widePlot->setDialFreq(d); +} + +void WideGraph::setRxBand (QString const& band) +{ + m_rxBand = band; + if ("60m" == m_rxBand) + { + ui->fSplitSpinBox->setEnabled (false); + ui->fSplitSpinBox->setValue (0); + } + else + { + ui->fSplitSpinBox->setValue (m_fMinPerBand.value (band, 2500).toUInt ()); + ui->fSplitSpinBox->setEnabled (m_mode=="JT9+JT65"); + } + ui->widePlot->setRxBand(band); + setRxRange (); +} + + +void WideGraph::on_fStartSpinBox_valueChanged(int n) //fStart +{ + ui->widePlot->setStartFreq(n); +} + +void WideGraph::readPalette () //readPalette +{ + try + { + if (user_defined == m_waterfallPalette) + { + ui->widePlot->setColours (WFPalette {m_userPalette}.interpolate ()); + } + else + { + ui->widePlot->setColours (WFPalette {m_palettes_path.absoluteFilePath (m_waterfallPalette + ".pal")}.interpolate()); + } + } + catch (std::exception const& e) + { + MessageBox::warning_message (this, tr ("Read Palette"), e.what ()); + } +} + +void WideGraph::on_paletteComboBox_activated (QString const& palette) //palette selector +{ + m_waterfallPalette = palette; + readPalette(); + replot(); +} + +void WideGraph::on_cbFlatten_toggled(bool b) //Flatten On/Off +{ + m_bFlatten=b; + if(m_bRef and m_bFlatten) { + m_bRef=false; + ui->cbRef->setChecked(false); + } + ui->widePlot->setFlatten(m_bFlatten,m_bRef); +} + +void WideGraph::on_cbRef_toggled(bool b) +{ + m_bRef=b; + if(m_bRef and m_bFlatten) { + m_bFlatten=false; + ui->cbFlatten->setChecked(false); + } + ui->widePlot->setFlatten(m_bFlatten,m_bRef); +} + +void WideGraph::on_cbControls_toggled(bool b) +{ + ui->controls_widget->setVisible(b); +} + +void WideGraph::on_adjust_palette_push_button_clicked (bool) //Adjust Palette +{ + try + { + if (m_userPalette.design ()) + { + m_waterfallPalette = user_defined; + ui->paletteComboBox->setCurrentText (m_waterfallPalette); + readPalette (); + } + } + catch (std::exception const& e) + { + MessageBox::warning_message (this, tr ("Read Palette"), e.what ()); + } +} + +bool WideGraph::flatten() //Flatten +{ + return m_bFlatten; +} + +bool WideGraph::useRef() //Flatten +{ + return m_bRef; +} + +void WideGraph::replot() +{ + if(ui->widePlot->scaleOK()) ui->widePlot->replot(); +} + +void WideGraph::on_gainSlider_valueChanged(int value) //Gain +{ + ui->widePlot->setPlotGain(value); + replot(); +} + +void WideGraph::on_zeroSlider_valueChanged(int value) //Zero +{ + ui->widePlot->setPlotZero(value); + replot(); +} + +void WideGraph::on_gain2dSlider_valueChanged(int value) //Gain2 +{ + ui->widePlot->setPlot2dGain(value); + if(ui->widePlot->scaleOK ()) { + ui->widePlot->draw(swide,false,false); + if(m_mode=="QRA64") ui->widePlot->draw(swide,false,true); + } +} + +void WideGraph::on_zero2dSlider_valueChanged(int value) //Zero2 +{ + ui->widePlot->setPlot2dZero(value); + if(ui->widePlot->scaleOK ()) { + ui->widePlot->draw(swide,false,false); + if(m_mode=="QRA64") ui->widePlot->draw(swide,false,true); + } +} + +void WideGraph::setTol(int n) //setTol +{ + ui->widePlot->setTol(n); + ui->widePlot->DrawOverlay(); + ui->widePlot->update(); +} + +void WideGraph::on_smoSpinBox_valueChanged(int n) +{ + m_nsmo=n; +} + +int WideGraph::smoothYellow() +{ + return m_nsmo; +} + +void WideGraph::setWSPRtransmitted() +{ + m_bHaveTransmitted=true; +} + +void WideGraph::setVHF(bool bVHF) +{ + ui->widePlot->setVHF(bVHF); +} + +void WideGraph::on_sbPercent2dPlot_valueChanged(int n) +{ + m_Percent2DScreen=n; + ui->widePlot->SetPercent2DScreen(n); +} + +void WideGraph::setRedFile(QString fRed) +{ + ui->widePlot->setRedFile(fRed); +} diff --git a/widgets/widegraph.h b/widgets/widegraph.h new file mode 100644 index 00000000..a809a6c8 --- /dev/null +++ b/widgets/widegraph.h @@ -0,0 +1,119 @@ +// -*- Mode: C++ -*- +#ifndef WIDEGRAPH_H_ +#define WIDEGRAPH_H_ + +#include <QDialog> +#include <QScopedPointer> +#include <QDir> +#include <QHash> +#include <QVariant> +#include "WFPalette.hpp" + +#define MAX_SCREENSIZE 2048 + +namespace Ui { + class WideGraph; +} + +class QSettings; +class Configuration; + +class WideGraph : public QDialog +{ + Q_OBJECT + +public: + explicit WideGraph(QSettings *, QWidget *parent = 0); + ~WideGraph (); + + void dataSink2(float s[], float df3, int ihsym, int ndiskdata); + void setRxFreq(int n); + int rxFreq(); + int nStartFreq(); + int Fmin(); + int Fmax(); + int fSpan(); + void saveSettings(); + void setFsample(int n); + void setPeriod(int ntrperiod, int nsps); + void setTxFreq(int n); + void setMode(QString mode); + void setSubMode(int n); + void setModeTx(QString modeTx); + bool flatten(); + bool useRef(); + void setTol(int n); + int smoothYellow(); + void setRxBand (QString const& band); + void setWSPRtransmitted(); + void drawRed(int ia, int ib); + void setVHF(bool bVHF); + void setRedFile(QString fRed); + +signals: + void freezeDecode2(int n); + void f11f12(int n); + void setXIT2(int n); + void setFreq3(int rxFreq, int txFreq); + +public slots: + void wideFreezeDecode(int n); + void setFreq2(int rxFreq, int txFreq); + void setDialFreq(double d); + +protected: + void keyPressEvent (QKeyEvent *e) override; + void closeEvent (QCloseEvent *) override; + +private slots: + void on_waterfallAvgSpinBox_valueChanged(int arg1); + void on_bppSpinBox_valueChanged(int arg1); + void on_spec2dComboBox_currentIndexChanged(const QString &arg1); + void on_fSplitSpinBox_valueChanged(int n); + void on_fStartSpinBox_valueChanged(int n); + void on_paletteComboBox_activated(const QString &palette); + void on_cbFlatten_toggled(bool b); + void on_cbRef_toggled(bool b); + void on_cbControls_toggled(bool b); + void on_adjust_palette_push_button_clicked (bool); + void on_gainSlider_valueChanged(int value); + void on_zeroSlider_valueChanged(int value); + void on_gain2dSlider_valueChanged(int value); + void on_zero2dSlider_valueChanged(int value); + void on_smoSpinBox_valueChanged(int n); + void on_sbPercent2dPlot_valueChanged(int n); + +private: + void readPalette (); + void setRxRange (); + void replot(); + + QScopedPointer<Ui::WideGraph> ui; + + QSettings * m_settings; + QDir m_palettes_path; + WFPalette m_userPalette; + QHash<QString, QVariant> m_fMinPerBand; + + qint32 m_waterfallAvg; + qint32 m_TRperiod; + qint32 m_nsps; + qint32 m_ntr0; + qint32 m_fMax; + qint32 m_nSubMode; + qint32 m_nsmo; + qint32 m_Percent2DScreen; + qint32 m_jz=MAX_SCREENSIZE; + qint32 m_n; + + bool m_bFlatten; + bool m_bRef; + bool m_bHaveTransmitted; //Set true at end of a WSPR transmission + + QString m_rxBand; + QString m_mode; + QString m_modeTx; + QString m_waterfallPalette; +}; + +#endif // WIDEGRAPH_H diff --git a/widgets/widegraph.ui b/widgets/widegraph.ui new file mode 100644 index 00000000..d302fac6 --- /dev/null +++ b/widgets/widegraph.ui @@ -0,0 +1,526 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>WideGraph</class> + <widget class="QDialog" name="WideGraph"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>799</width> + <height>337</height> + </rect> + </property> + <property name="windowTitle"> + <string>Dialog</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="spacing"> + <number>1</number> + </property> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="CPlotter" name="widePlot"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>400</width> + <height>100</height> + </size> + </property> + <property name="frameShape"> + <enum>QFrame::NoFrame</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Plain</enum> + </property> + <property name="lineWidth"> + <number>1</number> + </property> + <widget class="QCheckBox" name="cbControls"> + <property name="geometry"> + <rect> + <x>5</x> + <y>0</y> + <width>77</width> + <height>17</height> + </rect> + </property> + <property name="text"> + <string>Controls</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </widget> + </item> + <item> + <widget class="QWidget" name="controls_widget" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <layout class="QGridLayout" name="gridLayout"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <property name="horizontalSpacing"> + <number>5</number> + </property> + <property name="verticalSpacing"> + <number>0</number> + </property> + <item row="1" column="8"> + <widget class="QSlider" name="gain2dSlider"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>100</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>200</width> + <height>16777215</height> + </size> + </property> + <property name="toolTip"> + <string>Spectrum gain</string> + </property> + <property name="minimum"> + <number>-50</number> + </property> + <property name="maximum"> + <number>50</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="tickPosition"> + <enum>QSlider::TicksAbove</enum> + </property> + </widget> + </item> + <item row="0" column="4"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="labPalette"> + <property name="text"> + <string> Palette </string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="adjust_palette_push_button"> + <property name="toolTip"> + <string><html><head/><body><p>Enter definition for a new color palette.</p></body></html></string> + </property> + <property name="text"> + <string>Adjust...</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="0" column="8"> + <widget class="QSlider" name="gainSlider"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>100</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>200</width> + <height>16777215</height> + </size> + </property> + <property name="toolTip"> + <string>Waterfall gain</string> + </property> + <property name="minimum"> + <number>-50</number> + </property> + <property name="maximum"> + <number>50</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="tickPosition"> + <enum>QSlider::TicksAbove</enum> + </property> + </widget> + </item> + <item row="0" column="11"> + <widget class="QSpinBox" name="sbPercent2dPlot"> + <property name="toolTip"> + <string><html><head/><body><p>Set fractional size of spectrum in this window.</p></body></html></string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="suffix"> + <string> %</string> + </property> + <property name="prefix"> + <string>Spec </string> + </property> + <property name="maximum"> + <number>100</number> + </property> + <property name="singleStep"> + <number>5</number> + </property> + <property name="value"> + <number>30</number> + </property> + </widget> + </item> + <item row="0" column="6"> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QCheckBox" name="cbFlatten"> + <property name="toolTip"> + <string><html><head/><body><p>Flatten spectral baseline over the full displayed interval.</p></body></html></string> + </property> + <property name="text"> + <string>Flatten</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="cbRef"> + <property name="toolTip"> + <string><html><head/><body><p>Compute and save a reference spectrum. (Not yet fully implemented.)</p></body></html></string> + </property> + <property name="text"> + <string>Ref Spec</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="11"> + <widget class="QSpinBox" name="smoSpinBox"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip"> + <string>Smoothing of Linear Average spectrum</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="suffix"> + <string/> + </property> + <property name="prefix"> + <string>Smooth </string> + </property> + <property name="minimum"> + <number>1</number> + </property> + <property name="maximum"> + <number>7</number> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QSpinBox" name="bppSpinBox"> + <property name="toolTip"> + <string>Compression factor for frequency scale</string> + </property> + <property name="suffix"> + <string/> + </property> + <property name="prefix"> + <string>Bins/Pixel </string> + </property> + <property name="minimum"> + <number>1</number> + </property> + <property name="maximum"> + <number>1000</number> + </property> + <property name="singleStep"> + <number>1</number> + </property> + <property name="value"> + <number>2</number> + </property> + </widget> + </item> + <item row="1" column="4"> + <widget class="QComboBox" name="paletteComboBox"> + <property name="toolTip"> + <string>Select waterfall palette</string> + </property> + </widget> + </item> + <item row="1" column="6"> + <widget class="QComboBox" name="spec2dComboBox"> + <property name="toolTip"> + <string><html><head/><body><p>Select data for spectral display</p></body></html></string> + </property> + <property name="currentIndex"> + <number>0</number> + </property> + <item> + <property name="text"> + <string>Current</string> + </property> + </item> + <item> + <property name="text"> + <string>Cumulative</string> + </property> + </item> + <item> + <property name="text"> + <string>Linear Avg</string> + </property> + </item> + <item> + <property name="text"> + <string>Reference</string> + </property> + </item> + </widget> + </item> + <item row="0" column="2"> + <widget class="QSpinBox" name="fStartSpinBox"> + <property name="toolTip"> + <string><html><head/><body><p>Frequency at left edge of waterfall</p></body></html></string> + </property> + <property name="suffix"> + <string> Hz</string> + </property> + <property name="prefix"> + <string>Start </string> + </property> + <property name="maximum"> + <number>4900</number> + </property> + <property name="singleStep"> + <number>100</number> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QSpinBox" name="fSplitSpinBox"> + <property name="toolTip"> + <string><html><head/><body><p>Decode JT9 only above this frequency</p></body></html></string> + </property> + <property name="suffix"> + <string> JT9</string> + </property> + <property name="prefix"> + <string>JT65 </string> + </property> + <property name="minimum"> + <number>0</number> + </property> + <property name="maximum"> + <number>5000</number> + </property> + <property name="singleStep"> + <number>100</number> + </property> + <property name="value"> + <number>3000</number> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QSpinBox" name="waterfallAvgSpinBox"> + <property name="toolTip"> + <string>Number of FFTs averaged (controls waterfall scrolling rate)</string> + </property> + <property name="prefix"> + <string>N Avg </string> + </property> + <property name="minimum"> + <number>1</number> + </property> + <property name="maximum"> + <number>50</number> + </property> + </widget> + </item> + <item row="0" column="10"> + <widget class="QSlider" name="zeroSlider"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>100</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>200</width> + <height>16777215</height> + </size> + </property> + <property name="toolTip"> + <string>Waterfall zero</string> + </property> + <property name="minimum"> + <number>-50</number> + </property> + <property name="maximum"> + <number>50</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="tickPosition"> + <enum>QSlider::TicksAbove</enum> + </property> + </widget> + </item> + <item row="1" column="10"> + <widget class="QSlider" name="zero2dSlider"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>100</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>200</width> + <height>16777215</height> + </size> + </property> + <property name="toolTip"> + <string>Spectrum zero</string> + </property> + <property name="minimum"> + <number>-50</number> + </property> + <property name="maximum"> + <number>50</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="tickPosition"> + <enum>QSlider::TicksAbove</enum> + </property> + </widget> + </item> + <item row="0" column="0" rowspan="2"> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="0" column="12" rowspan="2"> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="0" column="3" rowspan="2"> + <widget class="Line" name="line"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + </widget> + </item> + <item row="0" column="5" rowspan="2"> + <widget class="Line" name="line_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>CPlotter</class> + <extends>QFrame</extends> + <header>widgets/plotter.h</header> + <container>1</container> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> diff --git a/widgets/widgets.pri b/widgets/widgets.pri new file mode 100644 index 00000000..24ddd5a3 --- /dev/null +++ b/widgets/widgets.pri @@ -0,0 +1,30 @@ +SOURCES += \ + widgets/astro.cpp widgets/LettersSpinBox.cpp \ + widgets/logqso.cpp widgets/displaytext.cpp \ + widgets/meterwidget.cpp widgets/signalmeter.cpp \ + widgets/plotter.cpp widgets/widegraph.cpp widgets/about.cpp \ + widgets/mainwindow.cpp widgets/messageaveraging.cpp \ + widgets/echoplot.cpp widgets/echograph.cpp widgets/fastgraph.cpp \ + widgets/fastplot.cpp widgets/MessageBox.cpp \ + widgets/colorhighlighting.cpp widgets/ExportCabrillo.cpp \ + widgets/AbstractLogWindow.cpp \ + widgets/FoxLogWindow.cpp widgets/CabrilloLogWindow.cpp + +HEADERS += \ + widgets/mainwindow.h widgets/plotter.h \ + widgets/about.h widgets/widegraph.h \ + widgets/displaytext.h widgets/logqso.h widgets/LettersSpinBox.hpp \ + widgets/FrequencyLineEdit.hpp widgets/signalmeter.h \ + widgets/meterwidget.h widgets/messageaveraging.h \ + widgets/echoplot.h widgets/echograph.h widgets/fastgraph.h \ + widgets/fastplot.h widgets/MessageBox.hpp widgets/colorhighlighting.h \ + widgets/ExportCabrillo.h widgets/AbstractLogWindow.hpp \ + widgets/FoxLogWindow.hpp widgets/CabrilloLogWindow.hpp + +FORMS += \ + widgets/mainwindow.ui widgets/about.ui \ + widgets/widegraph.ui widgets/astro.ui \ + widgets/logqso.ui widgets/messageaveraging.ui \ + widgets/echograph.ui widgets/fastgraph.ui \ + widgets/colorhighlighting.ui widgets/ExportCabrillo.ui \ + widgets/FoxLogWindow.ui widgets/CabrilloLogWindow.ui |
