2020-09-19 19:06:50 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2020 Edouard Griffiths, F4EXB //
|
|
|
|
// //
|
|
|
|
// 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 <QMessageBox>
|
2022-04-21 17:31:01 -04:00
|
|
|
#include <QResizeEvent>
|
2020-09-19 19:06:50 -04:00
|
|
|
|
|
|
|
#include "feature/featureuiset.h"
|
|
|
|
#include "gui/basicfeaturesettingsdialog.h"
|
2021-12-29 15:20:06 -05:00
|
|
|
#include "gui/crightclickenabler.h"
|
|
|
|
#include "gui/audioselectdialog.h"
|
|
|
|
#include "dsp/dspengine.h"
|
2020-10-12 15:59:04 -04:00
|
|
|
#include "device/deviceset.h"
|
2021-12-29 15:20:06 -05:00
|
|
|
#include "util/db.h"
|
2020-10-12 15:59:04 -04:00
|
|
|
#include "maincore.h"
|
2020-09-19 19:06:50 -04:00
|
|
|
|
|
|
|
#include "ui_simplepttgui.h"
|
|
|
|
#include "simplepttreport.h"
|
|
|
|
#include "simpleptt.h"
|
|
|
|
#include "simplepttgui.h"
|
|
|
|
|
|
|
|
SimplePTTGUI* SimplePTTGUI::create(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Feature *feature)
|
|
|
|
{
|
|
|
|
SimplePTTGUI* gui = new SimplePTTGUI(pluginAPI, featureUISet, feature);
|
|
|
|
return gui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimplePTTGUI::destroy()
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimplePTTGUI::resetToDefaults()
|
|
|
|
{
|
|
|
|
m_settings.resetToDefaults();
|
|
|
|
displaySettings();
|
|
|
|
applySettings(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray SimplePTTGUI::serialize() const
|
|
|
|
{
|
|
|
|
return m_settings.serialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SimplePTTGUI::deserialize(const QByteArray& data)
|
|
|
|
{
|
2020-09-20 21:13:36 -04:00
|
|
|
if (m_settings.deserialize(data))
|
2020-09-19 19:06:50 -04:00
|
|
|
{
|
2022-05-13 16:24:48 -04:00
|
|
|
m_feature->setWorkspaceIndex(m_settings.m_workspaceIndex);
|
2020-09-19 19:06:50 -04:00
|
|
|
displaySettings();
|
|
|
|
applySettings(true);
|
|
|
|
return true;
|
2020-09-20 21:13:36 -04:00
|
|
|
}
|
|
|
|
else
|
2020-09-19 19:06:50 -04:00
|
|
|
{
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-21 17:31:01 -04:00
|
|
|
void SimplePTTGUI::resizeEvent(QResizeEvent* size)
|
|
|
|
{
|
2022-04-24 13:34:48 -04:00
|
|
|
int maxWidth = getRollupContents()->maximumWidth();
|
|
|
|
int minHeight = getRollupContents()->minimumHeight() + getAdditionalHeight();
|
|
|
|
resize(width() < maxWidth ? width() : maxWidth, minHeight);
|
2022-04-21 17:31:01 -04:00
|
|
|
size->accept();
|
|
|
|
}
|
|
|
|
|
2020-09-19 19:06:50 -04:00
|
|
|
bool SimplePTTGUI::handleMessage(const Message& message)
|
|
|
|
{
|
|
|
|
if (SimplePTT::MsgConfigureSimplePTT::match(message))
|
|
|
|
{
|
|
|
|
qDebug("SimplePTTGUI::handleMessage: SimplePTT::MsgConfigureSimplePTT");
|
|
|
|
const SimplePTT::MsgConfigureSimplePTT& cfg = (SimplePTT::MsgConfigureSimplePTT&) message;
|
|
|
|
m_settings = cfg.getSettings();
|
|
|
|
blockApplySettings(true);
|
|
|
|
displaySettings();
|
|
|
|
blockApplySettings(false);
|
|
|
|
|
|
|
|
return true;
|
2020-09-20 21:13:36 -04:00
|
|
|
}
|
2020-09-19 19:06:50 -04:00
|
|
|
else if (SimplePTTReport::MsgRadioState::match(message))
|
|
|
|
{
|
|
|
|
qDebug("SimplePTTGUI::handleMessage: SimplePTTReport::MsgRadioState");
|
|
|
|
const SimplePTTReport::MsgRadioState& cfg = (SimplePTTReport::MsgRadioState&) message;
|
|
|
|
SimplePTTReport::RadioState state = cfg.getState();
|
|
|
|
ui->statusIndicator->setStyleSheet("QLabel { background-color: " +
|
|
|
|
m_statusColors[(int) state] + "; border-radius: 12px; }");
|
2020-09-20 21:13:36 -04:00
|
|
|
ui->statusIndicator->setToolTip(m_statusTooltips[(int) state]);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2021-12-29 15:20:06 -05:00
|
|
|
else if (SimplePTTReport::MsgVox::match(message))
|
|
|
|
{
|
|
|
|
qDebug("SimplePTTGUI::handleMessage: SimplePTTReport::MsgVox");
|
|
|
|
const SimplePTTReport::MsgVox& cfg = (const SimplePTTReport::MsgVox&) message;
|
|
|
|
|
|
|
|
if (cfg.getVox()) {
|
2022-01-03 13:07:43 -05:00
|
|
|
ui->voxLevel->setStyleSheet("QDial { background-color : green; }");
|
2021-12-29 15:20:06 -05:00
|
|
|
} else {
|
2022-01-03 13:07:43 -05:00
|
|
|
ui->voxLevel->setStyleSheet("QDial { background:rgb(79,79,79); }");
|
2021-12-29 15:20:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2020-09-20 21:13:36 -04:00
|
|
|
else if (SimplePTT::MsgPTT::match(message))
|
|
|
|
{
|
|
|
|
qDebug("SimplePTTGUI::handleMessage: SimplePTT::MsgPTT");
|
|
|
|
const SimplePTT::MsgPTT& cfg = (SimplePTT::MsgPTT&) message;
|
|
|
|
bool ptt = cfg.getTx();
|
2020-09-28 19:24:29 -04:00
|
|
|
blockApplySettings(true);
|
2020-09-20 21:13:36 -04:00
|
|
|
ui->ptt->setChecked(ptt);
|
2020-09-28 19:24:29 -04:00
|
|
|
blockApplySettings(false);
|
2020-09-20 21:13:36 -04:00
|
|
|
|
2020-09-19 19:06:50 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimplePTTGUI::handleInputMessages()
|
|
|
|
{
|
|
|
|
Message* message;
|
|
|
|
|
|
|
|
while ((message = getInputMessageQueue()->pop()))
|
|
|
|
{
|
|
|
|
if (handleMessage(*message)) {
|
|
|
|
delete message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimplePTTGUI::onWidgetRolled(QWidget* widget, bool rollDown)
|
|
|
|
{
|
|
|
|
(void) widget;
|
|
|
|
(void) rollDown;
|
2021-11-23 08:35:57 -05:00
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
getRollupContents()->saveState(m_rollupState);
|
2021-11-23 08:35:57 -05:00
|
|
|
applySettings();
|
2020-09-19 19:06:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
SimplePTTGUI::SimplePTTGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Feature *feature, QWidget* parent) :
|
2020-10-03 17:55:24 -04:00
|
|
|
FeatureGUI(parent),
|
2020-09-19 19:06:50 -04:00
|
|
|
ui(new Ui::SimplePTTGUI),
|
|
|
|
m_pluginAPI(pluginAPI),
|
|
|
|
m_featureUISet(featureUISet),
|
|
|
|
m_doApplySettings(true),
|
|
|
|
m_lastFeatureState(0)
|
|
|
|
{
|
2022-05-13 16:24:48 -04:00
|
|
|
m_feature = feature;
|
2020-09-19 19:06:50 -04:00
|
|
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
2022-04-24 13:34:48 -04:00
|
|
|
m_helpURL = "plugins/feature/simpleptt/readme.md";
|
|
|
|
RollupContents *rollupContents = getRollupContents();
|
|
|
|
ui->setupUi(rollupContents);
|
|
|
|
setSizePolicy(rollupContents->sizePolicy());
|
|
|
|
rollupContents->arrangeRollups();
|
|
|
|
connect(rollupContents, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
|
|
|
|
|
2020-09-19 19:06:50 -04:00
|
|
|
m_simplePTT = reinterpret_cast<SimplePTT*>(feature);
|
|
|
|
m_simplePTT->setMessageQueueToGUI(&m_inputMessageQueue);
|
|
|
|
|
2022-01-08 23:27:12 -05:00
|
|
|
m_settings.setRollupState(&m_rollupState);
|
2020-09-19 19:06:50 -04:00
|
|
|
|
|
|
|
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
|
|
|
|
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
|
2021-12-29 15:20:06 -05:00
|
|
|
CRightClickEnabler *voxRightClickEnabler = new CRightClickEnabler(ui->vox);
|
|
|
|
connect(voxRightClickEnabler, SIGNAL(rightClick(const QPoint &)), this, SLOT(audioSelect()));
|
2020-09-20 21:13:36 -04:00
|
|
|
|
2020-09-19 19:06:50 -04:00
|
|
|
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
2021-12-29 15:20:06 -05:00
|
|
|
m_statusTimer.start(500);
|
2020-09-19 19:06:50 -04:00
|
|
|
|
|
|
|
m_statusTooltips.push_back("Idle"); // 0 - all off
|
|
|
|
m_statusTooltips.push_back("Rx on"); // 1 - Rx on
|
|
|
|
m_statusTooltips.push_back("Tx on"); // 2 - Tx on
|
|
|
|
|
|
|
|
m_statusColors.push_back("gray"); // All off
|
|
|
|
m_statusColors.push_back("rgb(85, 232, 85)"); // Rx on (green)
|
|
|
|
m_statusColors.push_back("rgb(232, 85, 85)"); // Tx on (red)
|
|
|
|
|
|
|
|
updateDeviceSetLists();
|
|
|
|
displaySettings();
|
|
|
|
applySettings(true);
|
2022-04-04 04:23:52 -04:00
|
|
|
makeUIConnections();
|
2020-09-19 19:06:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
SimplePTTGUI::~SimplePTTGUI()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2022-05-13 16:24:48 -04:00
|
|
|
void SimplePTTGUI::setWorkspaceIndex(int index)
|
|
|
|
{
|
|
|
|
m_settings.m_workspaceIndex = index;
|
|
|
|
m_feature->setWorkspaceIndex(index);
|
|
|
|
}
|
|
|
|
|
2020-09-19 19:06:50 -04:00
|
|
|
void SimplePTTGUI::blockApplySettings(bool block)
|
|
|
|
{
|
|
|
|
m_doApplySettings = !block;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimplePTTGUI::displaySettings()
|
|
|
|
{
|
|
|
|
setTitleColor(m_settings.m_rgbColor);
|
|
|
|
setWindowTitle(m_settings.m_title);
|
2022-04-04 04:23:52 -04:00
|
|
|
setTitle(m_settings.m_title);
|
2020-09-20 21:13:36 -04:00
|
|
|
blockApplySettings(true);
|
|
|
|
ui->rxtxDelay->setValue(m_settings.m_rx2TxDelayMs);
|
|
|
|
ui->txrxDelay->setValue(m_settings.m_tx2RxDelayMs);
|
2022-04-04 04:23:52 -04:00
|
|
|
getRollupContents()->restoreState(m_rollupState);
|
2021-12-29 15:20:06 -05:00
|
|
|
ui->vox->setChecked(m_settings.m_vox);
|
|
|
|
ui->voxEnable->setChecked(m_settings.m_voxEnable);
|
|
|
|
ui->voxLevel->setValue(m_settings.m_voxLevel);
|
|
|
|
ui->voxLevelText->setText(tr("%1").arg(m_settings.m_voxLevel));
|
|
|
|
ui->voxHold->setValue(m_settings.m_voxHold);
|
2020-09-20 21:13:36 -04:00
|
|
|
blockApplySettings(false);
|
2020-09-19 19:06:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void SimplePTTGUI::updateDeviceSetLists()
|
|
|
|
{
|
2020-10-12 15:59:04 -04:00
|
|
|
MainCore *mainCore = MainCore::instance();
|
|
|
|
std::vector<DeviceSet*>& deviceSets = mainCore->getDeviceSets();
|
|
|
|
std::vector<DeviceSet*>::const_iterator it = deviceSets.begin();
|
2020-09-19 19:06:50 -04:00
|
|
|
|
|
|
|
ui->rxDevice->blockSignals(true);
|
|
|
|
ui->txDevice->blockSignals(true);
|
|
|
|
|
|
|
|
ui->rxDevice->clear();
|
|
|
|
ui->txDevice->clear();
|
|
|
|
unsigned int deviceIndex = 0;
|
|
|
|
unsigned int rxIndex = 0;
|
|
|
|
unsigned int txIndex = 0;
|
|
|
|
|
2020-10-12 15:59:04 -04:00
|
|
|
for (; it != deviceSets.end(); ++it, deviceIndex++)
|
2020-09-19 19:06:50 -04:00
|
|
|
{
|
|
|
|
DSPDeviceSourceEngine *deviceSourceEngine = (*it)->m_deviceSourceEngine;
|
|
|
|
DSPDeviceSinkEngine *deviceSinkEngine = (*it)->m_deviceSinkEngine;
|
|
|
|
|
|
|
|
if (deviceSourceEngine)
|
|
|
|
{
|
|
|
|
ui->rxDevice->addItem(QString("R%1").arg(deviceIndex), deviceIndex);
|
|
|
|
rxIndex++;
|
|
|
|
}
|
|
|
|
else if (deviceSinkEngine)
|
|
|
|
{
|
|
|
|
ui->txDevice->addItem(QString("T%1").arg(deviceIndex), deviceIndex);
|
|
|
|
txIndex++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-20 21:13:36 -04:00
|
|
|
int rxDeviceIndex;
|
|
|
|
int txDeviceIndex;
|
|
|
|
|
2020-09-19 19:06:50 -04:00
|
|
|
if (rxIndex > 0)
|
|
|
|
{
|
|
|
|
if (m_settings.m_rxDeviceSetIndex < 0) {
|
2020-09-20 21:13:36 -04:00
|
|
|
ui->rxDevice->setCurrentIndex(0);
|
2020-09-19 19:06:50 -04:00
|
|
|
} else {
|
2020-09-20 21:13:36 -04:00
|
|
|
ui->rxDevice->setCurrentIndex(m_settings.m_rxDeviceSetIndex);
|
2020-09-19 19:06:50 -04:00
|
|
|
}
|
2020-09-20 21:13:36 -04:00
|
|
|
|
|
|
|
rxDeviceIndex = ui->rxDevice->currentData().toInt();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rxDeviceIndex = -1;
|
2020-09-19 19:06:50 -04:00
|
|
|
}
|
2020-09-20 21:13:36 -04:00
|
|
|
|
|
|
|
|
2020-09-19 19:06:50 -04:00
|
|
|
if (txIndex > 0)
|
|
|
|
{
|
|
|
|
if (m_settings.m_txDeviceSetIndex < 0) {
|
2020-09-20 21:13:36 -04:00
|
|
|
ui->txDevice->setCurrentIndex(0);
|
2020-09-19 19:06:50 -04:00
|
|
|
} else {
|
|
|
|
ui->txDevice->setCurrentIndex(m_settings.m_txDeviceSetIndex);
|
|
|
|
}
|
2020-09-20 21:13:36 -04:00
|
|
|
|
|
|
|
txDeviceIndex = ui->txDevice->currentData().toInt();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
txDeviceIndex = -1;
|
2020-09-19 19:06:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((rxDeviceIndex != m_settings.m_rxDeviceSetIndex) ||
|
|
|
|
(txDeviceIndex != m_settings.m_txDeviceSetIndex))
|
|
|
|
{
|
|
|
|
qDebug("SimplePTTGUI::updateDeviceSetLists: device index changed: %d:%d", rxDeviceIndex, txDeviceIndex);
|
|
|
|
m_settings.m_rxDeviceSetIndex = rxDeviceIndex;
|
|
|
|
m_settings.m_txDeviceSetIndex = txDeviceIndex;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->rxDevice->blockSignals(false);
|
|
|
|
ui->txDevice->blockSignals(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimplePTTGUI::onMenuDialogCalled(const QPoint &p)
|
|
|
|
{
|
|
|
|
if (m_contextMenuType == ContextMenuChannelSettings)
|
|
|
|
{
|
|
|
|
BasicFeatureSettingsDialog dialog(this);
|
|
|
|
dialog.setTitle(m_settings.m_title);
|
2020-09-20 21:13:36 -04:00
|
|
|
dialog.setUseReverseAPI(m_settings.m_useReverseAPI);
|
|
|
|
dialog.setReverseAPIAddress(m_settings.m_reverseAPIAddress);
|
|
|
|
dialog.setReverseAPIPort(m_settings.m_reverseAPIPort);
|
2020-09-27 18:13:53 -04:00
|
|
|
dialog.setReverseAPIFeatureSetIndex(m_settings.m_reverseAPIFeatureSetIndex);
|
|
|
|
dialog.setReverseAPIFeatureIndex(m_settings.m_reverseAPIFeatureIndex);
|
2022-04-18 06:08:33 -04:00
|
|
|
dialog.setDefaultTitle(m_displayedName);
|
2020-09-19 19:06:50 -04:00
|
|
|
|
|
|
|
dialog.move(p);
|
|
|
|
dialog.exec();
|
|
|
|
|
|
|
|
m_settings.m_title = dialog.getTitle();
|
2020-09-20 21:13:36 -04:00
|
|
|
m_settings.m_useReverseAPI = dialog.useReverseAPI();
|
|
|
|
m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress();
|
|
|
|
m_settings.m_reverseAPIPort = dialog.getReverseAPIPort();
|
2020-09-27 18:13:53 -04:00
|
|
|
m_settings.m_reverseAPIFeatureSetIndex = dialog.getReverseAPIFeatureSetIndex();
|
|
|
|
m_settings.m_reverseAPIFeatureIndex = dialog.getReverseAPIFeatureIndex();
|
2020-09-19 19:06:50 -04:00
|
|
|
|
2022-04-18 06:08:33 -04:00
|
|
|
setTitle(m_settings.m_title);
|
2020-09-19 19:06:50 -04:00
|
|
|
setTitleColor(m_settings.m_rgbColor);
|
|
|
|
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
resetContextMenuType();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimplePTTGUI::on_startStop_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (m_doApplySettings)
|
|
|
|
{
|
2022-01-03 13:07:43 -05:00
|
|
|
if (checked)
|
|
|
|
{
|
|
|
|
updateDeviceSetLists();
|
|
|
|
displaySettings();
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2020-09-19 19:06:50 -04:00
|
|
|
SimplePTT::MsgStartStop *message = SimplePTT::MsgStartStop::create(checked);
|
|
|
|
m_simplePTT->getInputMessageQueue()->push(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimplePTTGUI::on_devicesRefresh_clicked()
|
|
|
|
{
|
|
|
|
updateDeviceSetLists();
|
|
|
|
displaySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimplePTTGUI::on_rxDevice_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
if (index >= 0)
|
|
|
|
{
|
|
|
|
m_settings.m_rxDeviceSetIndex = index;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimplePTTGUI::on_txDevice_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
if (index >= 0)
|
|
|
|
{
|
|
|
|
m_settings.m_txDeviceSetIndex = index;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimplePTTGUI::on_rxtxDelay_valueChanged(int value)
|
|
|
|
{
|
|
|
|
m_settings.m_rx2TxDelayMs = value;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimplePTTGUI::on_txrxDelay_valueChanged(int value)
|
|
|
|
{
|
|
|
|
m_settings.m_tx2RxDelayMs = value;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimplePTTGUI::on_ptt_toggled(bool checked)
|
|
|
|
{
|
|
|
|
applyPTT(checked);
|
|
|
|
}
|
|
|
|
|
2021-12-29 15:20:06 -05:00
|
|
|
void SimplePTTGUI::on_vox_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_settings.m_vox = checked;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimplePTTGUI::on_voxEnable_clicked(bool checked)
|
|
|
|
{
|
|
|
|
m_settings.m_voxEnable = checked;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimplePTTGUI::on_voxLevel_valueChanged(int value)
|
|
|
|
{
|
|
|
|
m_settings.m_voxLevel = value;
|
2022-01-03 13:07:43 -05:00
|
|
|
ui->voxLevelText->setText(tr("%1").arg(m_settings.m_voxLevel));
|
2021-12-29 15:20:06 -05:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimplePTTGUI::on_voxHold_valueChanged(int value)
|
|
|
|
{
|
|
|
|
m_settings.m_voxHold = value;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2020-09-19 19:06:50 -04:00
|
|
|
void SimplePTTGUI::updateStatus()
|
|
|
|
{
|
|
|
|
int state = m_simplePTT->getState();
|
|
|
|
|
|
|
|
if (m_lastFeatureState != state)
|
|
|
|
{
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case Feature::StNotStarted:
|
|
|
|
ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
|
|
|
break;
|
|
|
|
case Feature::StIdle:
|
|
|
|
ui->startStop->setStyleSheet("QToolButton { background-color : blue; }");
|
|
|
|
break;
|
|
|
|
case Feature::StRunning:
|
|
|
|
ui->startStop->setStyleSheet("QToolButton { background-color : green; }");
|
|
|
|
break;
|
|
|
|
case Feature::StError:
|
|
|
|
ui->startStop->setStyleSheet("QToolButton { background-color : red; }");
|
|
|
|
QMessageBox::information(this, tr("Message"), m_simplePTT->getErrorMessage());
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_lastFeatureState = state;
|
|
|
|
}
|
2021-12-29 15:20:06 -05:00
|
|
|
|
|
|
|
if (m_settings.m_vox)
|
|
|
|
{
|
|
|
|
float peak;
|
|
|
|
m_simplePTT->getAudioPeak(peak);
|
|
|
|
int peakDB = CalcDb::dbPower(peak);
|
|
|
|
ui->audioPeak->setText(tr("%1 dB").arg(peakDB));
|
|
|
|
}
|
2020-09-19 19:06:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void SimplePTTGUI::applySettings(bool force)
|
|
|
|
{
|
|
|
|
if (m_doApplySettings)
|
|
|
|
{
|
|
|
|
SimplePTT::MsgConfigureSimplePTT* message = SimplePTT::MsgConfigureSimplePTT::create( m_settings, force);
|
|
|
|
m_simplePTT->getInputMessageQueue()->push(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimplePTTGUI::applyPTT(bool tx)
|
|
|
|
{
|
|
|
|
if (m_doApplySettings)
|
|
|
|
{
|
2022-01-03 13:07:43 -05:00
|
|
|
qDebug("SimplePTTGUI::applyPTT: %s", tx ? "tx" : "rx");
|
2020-09-19 19:06:50 -04:00
|
|
|
SimplePTT::MsgPTT* message = SimplePTT::MsgPTT::create(tx);
|
|
|
|
m_simplePTT->getInputMessageQueue()->push(message);
|
|
|
|
}
|
|
|
|
}
|
2021-12-29 15:20:06 -05:00
|
|
|
|
|
|
|
void SimplePTTGUI::audioSelect()
|
|
|
|
{
|
|
|
|
qDebug("SimplePTTGUI::audioSelect");
|
|
|
|
AudioSelectDialog audioSelect(DSPEngine::instance()->getAudioDeviceManager(), m_settings.m_audioDeviceName);
|
|
|
|
audioSelect.exec();
|
|
|
|
|
|
|
|
if (audioSelect.m_selected)
|
|
|
|
{
|
|
|
|
m_settings.m_audioDeviceName = audioSelect.m_audioDeviceName;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
}
|
2022-04-04 04:23:52 -04:00
|
|
|
|
|
|
|
void SimplePTTGUI::makeUIConnections()
|
|
|
|
{
|
|
|
|
QObject::connect(ui->startStop, &ButtonSwitch::toggled, this, &SimplePTTGUI::on_startStop_toggled);
|
|
|
|
QObject::connect(ui->devicesRefresh, &QPushButton::clicked, this, &SimplePTTGUI::on_devicesRefresh_clicked);
|
|
|
|
QObject::connect(ui->rxDevice, qOverload<int>(&QComboBox::currentIndexChanged), this, &SimplePTTGUI::on_rxDevice_currentIndexChanged);
|
|
|
|
QObject::connect(ui->txDevice, qOverload<int>(&QComboBox::currentIndexChanged), this, &SimplePTTGUI::on_txDevice_currentIndexChanged);
|
|
|
|
QObject::connect(ui->rxtxDelay, qOverload<int>(&QSpinBox::valueChanged), this, &SimplePTTGUI::on_rxtxDelay_valueChanged);
|
|
|
|
QObject::connect(ui->txrxDelay, qOverload<int>(&QSpinBox::valueChanged), this, &SimplePTTGUI::on_txrxDelay_valueChanged);
|
|
|
|
QObject::connect(ui->ptt, &ButtonSwitch::toggled, this, &SimplePTTGUI::on_ptt_toggled);
|
|
|
|
QObject::connect(ui->vox, &ButtonSwitch::toggled, this, &SimplePTTGUI::on_vox_toggled);
|
|
|
|
QObject::connect(ui->voxEnable, &QCheckBox::clicked, this, &SimplePTTGUI::on_voxEnable_clicked);
|
|
|
|
QObject::connect(ui->voxLevel, &QDial::valueChanged, this, &SimplePTTGUI::on_voxLevel_valueChanged);
|
|
|
|
QObject::connect(ui->voxHold, qOverload<int>(&QSpinBox::valueChanged), this, &SimplePTTGUI::on_voxHold_valueChanged);
|
|
|
|
}
|