2021-06-22 12:38:56 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
2024-04-07 11:51:55 -04:00
|
|
|
// Copyright (C) 2020-2024 Jon Beniston, M7RCE <jon@beniston.com> //
|
2023-11-18 06:02:48 -05:00
|
|
|
// Copyright (C) 2020-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
|
2021-06-22 12:38:56 -04:00
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
|
|
// (at your option) any later version. //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include <limits>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <QDockWidget>
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
#include "radioclockgui.h"
|
|
|
|
|
|
|
|
#include "device/deviceuiset.h"
|
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "dsp/dspcommands.h"
|
|
|
|
#include "ui_radioclockgui.h"
|
|
|
|
#include "plugin/pluginapi.h"
|
|
|
|
#include "util/db.h"
|
|
|
|
#include "gui/basicchannelsettingsdialog.h"
|
2022-12-20 05:31:15 -05:00
|
|
|
#include "gui/dialpopup.h"
|
|
|
|
#include "gui/dialogpositioner.h"
|
2021-06-22 12:38:56 -04:00
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "maincore.h"
|
|
|
|
|
|
|
|
#include "radioclock.h"
|
|
|
|
|
|
|
|
RadioClockGUI* RadioClockGUI::create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel)
|
|
|
|
{
|
|
|
|
RadioClockGUI* gui = new RadioClockGUI(pluginAPI, deviceUISet, rxChannel);
|
|
|
|
return gui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RadioClockGUI::destroy()
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RadioClockGUI::resetToDefaults()
|
|
|
|
{
|
|
|
|
m_settings.resetToDefaults();
|
|
|
|
displaySettings();
|
|
|
|
applySettings(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray RadioClockGUI::serialize() const
|
|
|
|
{
|
|
|
|
return m_settings.serialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RadioClockGUI::deserialize(const QByteArray& data)
|
|
|
|
{
|
|
|
|
if(m_settings.deserialize(data)) {
|
|
|
|
displaySettings();
|
|
|
|
applySettings(true);
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RadioClockGUI::displayDateTime()
|
|
|
|
{
|
|
|
|
QDateTime dateTime = m_dateTime;
|
|
|
|
if (m_settings.m_timezone == RadioClockSettings::UTC) {
|
|
|
|
dateTime = dateTime.toUTC();
|
|
|
|
} else if (m_settings.m_timezone == RadioClockSettings::LOCAL) {
|
|
|
|
dateTime = dateTime.toLocalTime();
|
|
|
|
}
|
|
|
|
ui->date->setText(dateTime.date().toString());
|
|
|
|
ui->time->setText(dateTime.time().toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RadioClockGUI::handleMessage(const Message& message)
|
|
|
|
{
|
|
|
|
if (RadioClock::MsgConfigureRadioClock::match(message))
|
|
|
|
{
|
|
|
|
qDebug("RadioClockGUI::handleMessage: RadioClock::MsgConfigureRadioClock");
|
|
|
|
const RadioClock::MsgConfigureRadioClock& cfg = (RadioClock::MsgConfigureRadioClock&) message;
|
|
|
|
m_settings = cfg.getSettings();
|
|
|
|
blockApplySettings(true);
|
2021-12-02 17:54:39 -05:00
|
|
|
ui->scopeGUI->updateSettings();
|
|
|
|
m_channelMarker.updateSettings(static_cast<const ChannelMarker*>(m_settings.m_channelMarker));
|
2021-06-22 12:38:56 -04:00
|
|
|
displaySettings();
|
|
|
|
blockApplySettings(false);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (RadioClock::MsgDateTime::match(message))
|
|
|
|
{
|
|
|
|
RadioClock::MsgDateTime& report = (RadioClock::MsgDateTime&) message;
|
|
|
|
m_dateTime = report.getDateTime();
|
|
|
|
displayDateTime();
|
2021-07-22 11:08:55 -04:00
|
|
|
switch (report.getDST())
|
|
|
|
{
|
|
|
|
case RadioClockSettings::UNKNOWN:
|
|
|
|
ui->dst->setText("");
|
|
|
|
break;
|
|
|
|
case RadioClockSettings::NOT_IN_EFFECT:
|
|
|
|
ui->dst->setText("Not in effect");
|
|
|
|
break;
|
|
|
|
case RadioClockSettings::IN_EFFECT:
|
|
|
|
ui->dst->setText("In effect");
|
|
|
|
break;
|
|
|
|
case RadioClockSettings::ENDING:
|
|
|
|
ui->dst->setText("Ending");
|
|
|
|
break;
|
|
|
|
case RadioClockSettings::STARTING:
|
|
|
|
ui->dst->setText("Starting");
|
|
|
|
break;
|
|
|
|
}
|
2021-06-22 12:38:56 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (RadioClock::MsgStatus::match(message))
|
|
|
|
{
|
|
|
|
RadioClock::MsgStatus& report = (RadioClock::MsgStatus&) message;
|
|
|
|
ui->status->setText(report.getStatus());
|
|
|
|
return true;
|
|
|
|
}
|
2022-04-13 05:08:21 -04:00
|
|
|
else if (DSPSignalNotification::match(message))
|
|
|
|
{
|
|
|
|
const DSPSignalNotification& notif = (const DSPSignalNotification&) message;
|
|
|
|
m_deviceCenterFrequency = notif.getCenterFrequency();
|
|
|
|
m_basebandSampleRate = notif.getSampleRate();
|
2024-04-07 11:51:55 -04:00
|
|
|
calcOffset();
|
2022-04-13 05:08:21 -04:00
|
|
|
updateAbsoluteCenterFrequency();
|
|
|
|
return true;
|
|
|
|
}
|
2021-06-22 12:38:56 -04:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-04-07 11:51:55 -04:00
|
|
|
// Calculate input frequency offset, when device center frequency changes
|
|
|
|
void RadioClockGUI::calcOffset()
|
|
|
|
{
|
|
|
|
if (m_settings.m_frequencyMode == RadioClockSettings::Offset)
|
|
|
|
{
|
|
|
|
ui->deltaFrequency->setValueRange(false, 7, -m_basebandSampleRate/2, m_basebandSampleRate/2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qint64 offset = m_settings.m_frequency - m_deviceCenterFrequency;
|
|
|
|
m_channelMarker.setCenterFrequency(offset);
|
|
|
|
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
|
|
|
|
updateAbsoluteCenterFrequency();
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-22 12:38:56 -04:00
|
|
|
void RadioClockGUI::handleInputMessages()
|
|
|
|
{
|
|
|
|
Message* message;
|
|
|
|
|
|
|
|
while ((message = getInputMessageQueue()->pop()) != 0)
|
|
|
|
{
|
|
|
|
if (handleMessage(*message))
|
|
|
|
{
|
|
|
|
delete message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RadioClockGUI::channelMarkerChangedByCursor()
|
|
|
|
{
|
|
|
|
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
|
2024-04-07 11:51:55 -04:00
|
|
|
m_settings.m_frequency = m_deviceCenterFrequency + m_settings.m_inputFrequencyOffset;
|
|
|
|
|
|
|
|
qint64 value = 0;
|
|
|
|
|
|
|
|
if (m_settings.m_frequencyMode == RadioClockSettings::Offset) {
|
|
|
|
value = m_settings.m_inputFrequencyOffset;
|
|
|
|
} else if (m_settings.m_frequencyMode == RadioClockSettings::Absolute) {
|
|
|
|
value = m_settings.m_frequency;
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->deltaFrequency->blockSignals(true);
|
|
|
|
ui->deltaFrequency->setValue(value);
|
|
|
|
ui->deltaFrequency->blockSignals(false);
|
|
|
|
|
|
|
|
updateAbsoluteCenterFrequency();
|
2021-06-22 12:38:56 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RadioClockGUI::channelMarkerHighlightedByCursor()
|
|
|
|
{
|
2022-04-25 18:42:26 -04:00
|
|
|
setHighlighted(m_channelMarker.getHighlighted());
|
2021-06-22 12:38:56 -04:00
|
|
|
}
|
|
|
|
|
2024-04-07 11:51:55 -04:00
|
|
|
void RadioClockGUI::on_frequencyMode_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
m_settings.m_frequencyMode = (RadioClockSettings::FrequencyMode) index;
|
|
|
|
ui->deltaFrequency->blockSignals(true);
|
|
|
|
|
|
|
|
if (m_settings.m_frequencyMode == RadioClockSettings::Offset)
|
|
|
|
{
|
|
|
|
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
|
|
|
|
ui->deltaFrequency->setValue(m_settings.m_inputFrequencyOffset);
|
|
|
|
ui->deltaUnits->setText("Hz");
|
|
|
|
}
|
|
|
|
else if (m_settings.m_frequencyMode == RadioClockSettings::Absolute)
|
|
|
|
{
|
|
|
|
ui->deltaFrequency->setValueRange(true, 11, 0, 99999999999, 0);
|
|
|
|
ui->deltaFrequency->setValue(m_settings.m_frequency);
|
|
|
|
ui->deltaUnits->setText("Hz");
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->deltaFrequency->blockSignals(false);
|
|
|
|
|
|
|
|
updateAbsoluteCenterFrequency();
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2021-06-22 12:38:56 -04:00
|
|
|
void RadioClockGUI::on_deltaFrequency_changed(qint64 value)
|
|
|
|
{
|
2024-04-07 11:51:55 -04:00
|
|
|
qint64 offset = 0;
|
|
|
|
|
|
|
|
if (m_settings.m_frequencyMode == RadioClockSettings::Offset)
|
|
|
|
{
|
|
|
|
offset = value;
|
|
|
|
m_settings.m_frequency = m_deviceCenterFrequency + offset;
|
|
|
|
}
|
|
|
|
else if (m_settings.m_frequencyMode == RadioClockSettings::Absolute)
|
|
|
|
{
|
|
|
|
m_settings.m_frequency = value;
|
|
|
|
offset = m_settings.m_frequency - m_deviceCenterFrequency;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_channelMarker.setCenterFrequency(offset);
|
2021-06-22 12:38:56 -04:00
|
|
|
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
|
2022-04-13 05:08:21 -04:00
|
|
|
updateAbsoluteCenterFrequency();
|
2021-06-22 12:38:56 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RadioClockGUI::on_rfBW_valueChanged(int value)
|
|
|
|
{
|
|
|
|
ui->rfBWText->setText(QString("%1 Hz").arg(value));
|
|
|
|
m_channelMarker.setBandwidth(value);
|
|
|
|
m_settings.m_rfBandwidth = value;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RadioClockGUI::on_threshold_valueChanged(int value)
|
|
|
|
{
|
|
|
|
ui->thresholdText->setText(QString("%1 dB").arg(value));
|
|
|
|
m_settings.m_threshold = value;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RadioClockGUI::on_modulation_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
m_settings.m_modulation = (RadioClockSettings::Modulation)index;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RadioClockGUI::on_timezone_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
m_settings.m_timezone = (RadioClockSettings::DisplayTZ)index;
|
|
|
|
displayDateTime();
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RadioClockGUI::onWidgetRolled(QWidget* widget, bool rollDown)
|
|
|
|
{
|
2022-11-09 11:59:02 -05:00
|
|
|
(void) widget;
|
|
|
|
(void) rollDown;
|
|
|
|
|
dd maximize button to MainSpectrum and expandible Channels and Features.
Add sizeToContents in ChannelGUI and FeatureGUI, called when widget is
rolled, so we can remove resizing code from all of the individual
channels and features.
In RollupContents, use minimumSizeHint for calculated size, so that
minimumWidth can come from .ui file.
In DeviceGUI::sizeToContents(), call adjustSize(), so Device GUIs start
out at minimum needed size (which should restore appearance prior to
last patch).
In stackSubWindows, use available space for channels if no
spectrum/features present.
In stackSubWindows, fix spectrum from being sized too big, resulting in
scroll bars appearing.
Reset user-defined channel width in stackSubWindows, when channels are
removed.
Don't stack maximized windows.
There's one hack in Channel/FeatureGUI::maximizeWindow(). It seems that
when maximimzing a window, QOpenGLWidgets aren't always paint properly
immediately afterwards, so the code forces an additional update. I can't
see why the first call to paintGL doesn't work.
2022-11-11 07:24:27 -05:00
|
|
|
getRollupContents()->saveState(m_rollupState);
|
2021-11-24 04:50:42 -05:00
|
|
|
applySettings();
|
2021-06-22 12:38:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void RadioClockGUI::onMenuDialogCalled(const QPoint &p)
|
|
|
|
{
|
2024-08-25 17:36:46 -04:00
|
|
|
if (m_contextMenuType == ContextMenuType::ContextMenuChannelSettings)
|
2021-06-22 12:38:56 -04:00
|
|
|
{
|
|
|
|
BasicChannelSettingsDialog dialog(&m_channelMarker, this);
|
|
|
|
dialog.setUseReverseAPI(m_settings.m_useReverseAPI);
|
|
|
|
dialog.setReverseAPIAddress(m_settings.m_reverseAPIAddress);
|
|
|
|
dialog.setReverseAPIPort(m_settings.m_reverseAPIPort);
|
|
|
|
dialog.setReverseAPIDeviceIndex(m_settings.m_reverseAPIDeviceIndex);
|
|
|
|
dialog.setReverseAPIChannelIndex(m_settings.m_reverseAPIChannelIndex);
|
2022-04-17 19:42:03 -04:00
|
|
|
dialog.setDefaultTitle(m_displayedName);
|
|
|
|
|
|
|
|
if (m_deviceUISet->m_deviceMIMOEngine)
|
|
|
|
{
|
|
|
|
dialog.setNumberOfStreams(m_radioClock->getNumberOfDeviceStreams());
|
|
|
|
dialog.setStreamIndex(m_settings.m_streamIndex);
|
|
|
|
}
|
|
|
|
|
2021-06-22 12:38:56 -04:00
|
|
|
dialog.move(p);
|
2022-12-20 05:31:15 -05:00
|
|
|
new DialogPositioner(&dialog, false);
|
2021-06-22 12:38:56 -04:00
|
|
|
dialog.exec();
|
|
|
|
|
|
|
|
m_settings.m_rgbColor = m_channelMarker.getColor().rgb();
|
|
|
|
m_settings.m_title = m_channelMarker.getTitle();
|
|
|
|
m_settings.m_useReverseAPI = dialog.useReverseAPI();
|
|
|
|
m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress();
|
|
|
|
m_settings.m_reverseAPIPort = dialog.getReverseAPIPort();
|
|
|
|
m_settings.m_reverseAPIDeviceIndex = dialog.getReverseAPIDeviceIndex();
|
|
|
|
m_settings.m_reverseAPIChannelIndex = dialog.getReverseAPIChannelIndex();
|
|
|
|
|
|
|
|
setWindowTitle(m_settings.m_title);
|
2022-04-12 10:20:45 -04:00
|
|
|
setTitle(m_channelMarker.getTitle());
|
2021-06-22 12:38:56 -04:00
|
|
|
setTitleColor(m_settings.m_rgbColor);
|
|
|
|
|
2022-04-17 19:42:03 -04:00
|
|
|
if (m_deviceUISet->m_deviceMIMOEngine)
|
|
|
|
{
|
|
|
|
m_settings.m_streamIndex = dialog.getSelectedStreamIndex();
|
|
|
|
m_channelMarker.clearStreamIndexes();
|
|
|
|
m_channelMarker.addStreamIndex(m_settings.m_streamIndex);
|
|
|
|
updateIndexLabel();
|
|
|
|
}
|
2021-06-22 12:38:56 -04:00
|
|
|
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
resetContextMenuType();
|
|
|
|
}
|
|
|
|
|
|
|
|
RadioClockGUI::RadioClockGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel, QWidget* parent) :
|
|
|
|
ChannelGUI(parent),
|
|
|
|
ui(new Ui::RadioClockGUI),
|
|
|
|
m_pluginAPI(pluginAPI),
|
|
|
|
m_deviceUISet(deviceUISet),
|
|
|
|
m_channelMarker(this),
|
2022-04-13 05:08:21 -04:00
|
|
|
m_deviceCenterFrequency(0),
|
|
|
|
m_basebandSampleRate(1),
|
2021-06-22 12:38:56 -04:00
|
|
|
m_doApplySettings(true),
|
|
|
|
m_tickCount(0)
|
|
|
|
{
|
|
|
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
2022-04-24 06:28:56 -04:00
|
|
|
m_helpURL = "plugins/channelrx/radioclock/readme.md";
|
|
|
|
RollupContents *rollupContents = getRollupContents();
|
|
|
|
ui->setupUi(rollupContents);
|
|
|
|
setSizePolicy(rollupContents->sizePolicy());
|
|
|
|
rollupContents->arrangeRollups();
|
|
|
|
connect(rollupContents, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
|
2021-06-22 12:38:56 -04:00
|
|
|
|
|
|
|
m_radioClock = reinterpret_cast<RadioClock*>(rxChannel);
|
|
|
|
m_radioClock->setMessageQueueToGUI(getInputMessageQueue());
|
|
|
|
|
|
|
|
connect(&MainCore::instance()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); // 50 ms
|
|
|
|
|
|
|
|
m_scopeVis = m_radioClock->getScopeSink();
|
|
|
|
m_scopeVis->setGLScope(ui->glScope);
|
2021-07-12 17:18:14 -04:00
|
|
|
m_scopeVis->setLiveRate(RadioClockSettings::RADIOCLOCK_CHANNEL_SAMPLE_RATE);
|
2021-06-22 12:38:56 -04:00
|
|
|
ui->glScope->connectTimer(MainCore::instance()->getMasterTimer());
|
|
|
|
ui->scopeGUI->setBuddies(m_scopeVis->getInputMessageQueue(), m_scopeVis, ui->glScope);
|
2021-07-22 11:08:55 -04:00
|
|
|
ui->scopeGUI->setStreams(QStringList({"IQ", "MagSq", "TH", "FM", "Data", "Samp", "GotMM", "GotM"}));
|
2021-07-13 10:24:30 -04:00
|
|
|
ui->scopeGUI->setSampleRate(RadioClockSettings::RADIOCLOCK_CHANNEL_SAMPLE_RATE);
|
2021-06-22 12:38:56 -04:00
|
|
|
|
|
|
|
ui->status->setText("Looking for minute marker");
|
|
|
|
|
|
|
|
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
|
|
|
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
|
|
|
|
ui->channelPowerMeter->setColorTheme(LevelMeterSignalDB::ColorGreenAndBlue);
|
|
|
|
|
|
|
|
m_channelMarker.blockSignals(true);
|
|
|
|
m_channelMarker.setColor(Qt::yellow);
|
|
|
|
m_channelMarker.setBandwidth(m_settings.m_rfBandwidth);
|
|
|
|
m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset);
|
|
|
|
m_channelMarker.setTitle("Radio Clock");
|
|
|
|
m_channelMarker.blockSignals(false);
|
|
|
|
m_channelMarker.setVisible(true); // activate signal on the last setting only
|
|
|
|
|
|
|
|
setTitleColor(m_channelMarker.getColor());
|
|
|
|
m_settings.setChannelMarker(&m_channelMarker);
|
2022-01-08 23:27:12 -05:00
|
|
|
m_settings.setRollupState(&m_rollupState);
|
2021-06-22 12:38:56 -04:00
|
|
|
m_settings.setScopeGUI(ui->scopeGUI);
|
|
|
|
|
|
|
|
m_deviceUISet->addChannelMarker(&m_channelMarker);
|
|
|
|
|
2022-06-12 17:16:26 -04:00
|
|
|
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
|
2021-06-22 12:38:56 -04:00
|
|
|
connect(&m_channelMarker, SIGNAL(changedByCursor()), this, SLOT(channelMarkerChangedByCursor()));
|
|
|
|
connect(&m_channelMarker, SIGNAL(highlightedByCursor()), this, SLOT(channelMarkerHighlightedByCursor()));
|
|
|
|
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
|
|
|
|
|
|
|
|
ui->scopeContainer->setVisible(false);
|
|
|
|
|
|
|
|
displaySettings();
|
2022-04-12 10:20:45 -04:00
|
|
|
makeUIConnections();
|
2021-06-22 12:38:56 -04:00
|
|
|
applySettings(true);
|
2022-12-20 05:31:15 -05:00
|
|
|
DialPopup::addPopupsToChildDials(this);
|
2023-11-13 15:51:03 -05:00
|
|
|
m_resizer.enableChildMouseTracking();
|
2021-06-22 12:38:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
RadioClockGUI::~RadioClockGUI()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RadioClockGUI::blockApplySettings(bool block)
|
|
|
|
{
|
|
|
|
m_doApplySettings = !block;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RadioClockGUI::applySettings(bool force)
|
|
|
|
{
|
|
|
|
if (m_doApplySettings)
|
|
|
|
{
|
|
|
|
RadioClock::MsgConfigureRadioClock* message = RadioClock::MsgConfigureRadioClock::create( m_settings, force);
|
|
|
|
m_radioClock->getInputMessageQueue()->push(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RadioClockGUI::displaySettings()
|
|
|
|
{
|
|
|
|
m_channelMarker.blockSignals(true);
|
|
|
|
m_channelMarker.setBandwidth(m_settings.m_rfBandwidth);
|
|
|
|
m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset);
|
|
|
|
m_channelMarker.setTitle(m_settings.m_title);
|
|
|
|
m_channelMarker.blockSignals(false);
|
|
|
|
m_channelMarker.setColor(m_settings.m_rgbColor); // activate signal on the last setting only
|
|
|
|
|
|
|
|
setTitleColor(m_settings.m_rgbColor);
|
|
|
|
setWindowTitle(m_channelMarker.getTitle());
|
2022-04-12 10:20:45 -04:00
|
|
|
setTitle(m_channelMarker.getTitle());
|
2021-06-22 12:38:56 -04:00
|
|
|
|
|
|
|
blockApplySettings(true);
|
|
|
|
|
2024-04-07 11:51:55 -04:00
|
|
|
ui->frequencyMode->setCurrentIndex((int) m_settings.m_frequencyMode);
|
|
|
|
on_frequencyMode_currentIndexChanged((int) m_settings.m_frequencyMode);
|
2021-06-22 12:38:56 -04:00
|
|
|
|
|
|
|
ui->rfBWText->setText(QString("%1 Hz").arg((int)m_settings.m_rfBandwidth));
|
|
|
|
ui->rfBW->setValue(m_settings.m_rfBandwidth);
|
|
|
|
|
|
|
|
ui->thresholdText->setText(QString("%1 dB").arg(m_settings.m_threshold));
|
|
|
|
ui->threshold->setValue(m_settings.m_threshold);
|
|
|
|
|
|
|
|
ui->modulation->setCurrentIndex((int)m_settings.m_modulation);
|
|
|
|
ui->timezone->setCurrentIndex((int)m_settings.m_timezone);
|
|
|
|
|
2022-04-17 19:42:03 -04:00
|
|
|
updateIndexLabel();
|
2021-06-22 12:38:56 -04:00
|
|
|
|
2022-04-12 10:20:45 -04:00
|
|
|
getRollupContents()->restoreState(m_rollupState);
|
2022-04-13 05:08:21 -04:00
|
|
|
updateAbsoluteCenterFrequency();
|
2021-06-22 12:38:56 -04:00
|
|
|
blockApplySettings(false);
|
|
|
|
}
|
|
|
|
|
2022-04-22 13:21:24 -04:00
|
|
|
void RadioClockGUI::leaveEvent(QEvent* event)
|
2021-06-22 12:38:56 -04:00
|
|
|
{
|
|
|
|
m_channelMarker.setHighlighted(false);
|
2022-04-22 13:21:24 -04:00
|
|
|
ChannelGUI::leaveEvent(event);
|
2021-06-22 12:38:56 -04:00
|
|
|
}
|
|
|
|
|
2022-11-17 09:36:12 -05:00
|
|
|
void RadioClockGUI::enterEvent(EnterEventType* event)
|
2021-06-22 12:38:56 -04:00
|
|
|
{
|
|
|
|
m_channelMarker.setHighlighted(true);
|
2022-04-22 13:21:24 -04:00
|
|
|
ChannelGUI::enterEvent(event);
|
2021-06-22 12:38:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void RadioClockGUI::tick()
|
|
|
|
{
|
|
|
|
double magsqAvg, magsqPeak;
|
|
|
|
int nbMagsqSamples;
|
|
|
|
m_radioClock->getMagSqLevels(magsqAvg, magsqPeak, nbMagsqSamples);
|
|
|
|
double powDbAvg = CalcDb::dbPower(magsqAvg);
|
|
|
|
double powDbPeak = CalcDb::dbPower(magsqPeak);
|
|
|
|
|
|
|
|
ui->channelPowerMeter->levelChanged(
|
|
|
|
(100.0f + powDbAvg) / 100.0f,
|
|
|
|
(100.0f + powDbPeak) / 100.0f,
|
|
|
|
nbMagsqSamples);
|
|
|
|
|
|
|
|
if (m_tickCount % 4 == 0) {
|
|
|
|
ui->channelPower->setText(QString::number(powDbAvg, 'f', 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
m_tickCount++;
|
|
|
|
}
|
2022-04-12 10:20:45 -04:00
|
|
|
|
|
|
|
void RadioClockGUI::makeUIConnections()
|
|
|
|
{
|
2024-04-07 11:51:55 -04:00
|
|
|
QObject::connect(ui->frequencyMode, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &RadioClockGUI::on_frequencyMode_currentIndexChanged);
|
2022-04-12 10:20:45 -04:00
|
|
|
QObject::connect(ui->deltaFrequency, &ValueDialZ::changed, this, &RadioClockGUI::on_deltaFrequency_changed);
|
|
|
|
QObject::connect(ui->rfBW, &QSlider::valueChanged, this, &RadioClockGUI::on_rfBW_valueChanged);
|
|
|
|
QObject::connect(ui->threshold, &QDial::valueChanged, this, &RadioClockGUI::on_threshold_valueChanged);
|
|
|
|
QObject::connect(ui->modulation, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &RadioClockGUI::on_modulation_currentIndexChanged);
|
|
|
|
QObject::connect(ui->timezone, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &RadioClockGUI::on_timezone_currentIndexChanged);
|
|
|
|
}
|
2022-04-13 05:08:21 -04:00
|
|
|
|
|
|
|
void RadioClockGUI::updateAbsoluteCenterFrequency()
|
|
|
|
{
|
|
|
|
setStatusFrequency(m_deviceCenterFrequency + m_settings.m_inputFrequencyOffset);
|
2024-04-07 11:51:55 -04:00
|
|
|
if ( (m_basebandSampleRate > 1)
|
|
|
|
&& ( (m_settings.m_inputFrequencyOffset >= m_basebandSampleRate / 2)
|
|
|
|
|| (m_settings.m_inputFrequencyOffset < -m_basebandSampleRate / 2))) {
|
|
|
|
setStatusText("Frequency out of band");
|
|
|
|
} else {
|
|
|
|
setStatusText("");
|
|
|
|
}
|
2022-04-13 05:08:21 -04:00
|
|
|
}
|