mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-01 21:54:55 -04:00
Add AvailableChannelOrFeatureHandler for handling lists of channels, features and message pipes to them.
This commit is contained in:
@@ -51,7 +51,7 @@ void GS232ControllerGUI::resetToDefaults()
|
||||
{
|
||||
m_settings.resetToDefaults();
|
||||
displaySettings();
|
||||
applySettings(true);
|
||||
applyAllSettings();
|
||||
}
|
||||
|
||||
QByteArray GS232ControllerGUI::serialize() const
|
||||
@@ -65,7 +65,7 @@ bool GS232ControllerGUI::deserialize(const QByteArray& data)
|
||||
{
|
||||
m_feature->setWorkspaceIndex(m_settings.m_workspaceIndex);
|
||||
displaySettings();
|
||||
applySettings(true);
|
||||
applyAllSettings();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -121,9 +121,7 @@ void GS232ControllerGUI::displayToAzEl(float coord1, float coord2)
|
||||
m_settings.m_azimuth = coord1;
|
||||
m_settings.m_elevation = coord2;
|
||||
}
|
||||
m_settingsKeys.append("azimuth");
|
||||
m_settingsKeys.append("elevation");
|
||||
applySettings();
|
||||
applySettings({"azimuth", "elevation"});
|
||||
}
|
||||
|
||||
bool GS232ControllerGUI::handleMessage(const Message& message)
|
||||
@@ -149,7 +147,7 @@ bool GS232ControllerGUI::handleMessage(const Message& message)
|
||||
{
|
||||
GS232Controller::MsgReportAvailableChannelOrFeatures& report =
|
||||
(GS232Controller::MsgReportAvailableChannelOrFeatures&) message;
|
||||
updatePipeList(report.getItems());
|
||||
updatePipeList(report.getItems(), report.getRenameFrom(), report.getRenameTo());
|
||||
return true;
|
||||
}
|
||||
else if (GS232ControllerReport::MsgReportAzAl::match(message))
|
||||
@@ -206,7 +204,7 @@ void GS232ControllerGUI::onWidgetRolled(QWidget* widget, bool rollDown)
|
||||
(void) rollDown;
|
||||
|
||||
getRollupContents()->saveState(m_rollupState);
|
||||
applySettings();
|
||||
applySetting("rollupState");
|
||||
}
|
||||
|
||||
GS232ControllerGUI::GS232ControllerGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Feature *feature, QWidget* parent) :
|
||||
@@ -260,7 +258,7 @@ GS232ControllerGUI::GS232ControllerGUI(PluginAPI* pluginAPI, FeatureUISet *featu
|
||||
connect(&m_inputTimer, &QTimer::timeout, this, &GS232ControllerGUI::checkInputController);
|
||||
|
||||
displaySettings();
|
||||
applySettings(true);
|
||||
applyAllSettings();
|
||||
makeUIConnections();
|
||||
|
||||
// Get pre-existing pipes
|
||||
@@ -408,8 +406,7 @@ void GS232ControllerGUI::on_inputController_currentIndexChanged(int index)
|
||||
if (index >= 0)
|
||||
{
|
||||
m_settings.m_inputController = ui->inputController->currentText();
|
||||
m_settingsKeys.append("inputController");
|
||||
applySettings();
|
||||
applySetting("inputController");
|
||||
updateInputController();
|
||||
}
|
||||
}
|
||||
@@ -425,28 +422,24 @@ void GS232ControllerGUI::on_highSensitivity_clicked(bool checked)
|
||||
{
|
||||
m_settings.m_highSensitivity = checked;
|
||||
ui->highSensitivity->setText(checked ? "H" : "L");
|
||||
m_settingsKeys.append("highSensitivity");
|
||||
applySettings();
|
||||
applySetting("highSensitivity");
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::on_enableTargetControl_clicked(bool checked)
|
||||
{
|
||||
m_settings.m_targetControlEnabled = checked;
|
||||
m_settingsKeys.append("targetControlEnabled");
|
||||
applySettings();
|
||||
applySetting("targetControlEnabled");
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::on_enableOffsetControl_clicked(bool checked)
|
||||
{
|
||||
m_settings.m_offsetControlEnabled = checked;
|
||||
m_settingsKeys.append("offsetControlEnabled");
|
||||
applySettings();
|
||||
applySetting("offsetControlEnabled");
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::inputConfigurationComplete()
|
||||
{
|
||||
m_settingsKeys.append("inputControllerSettings");
|
||||
applySettings();
|
||||
applySetting("inputControllerSettings");
|
||||
}
|
||||
|
||||
GS232ControllerGUI::~GS232ControllerGUI()
|
||||
@@ -546,10 +539,16 @@ void GS232ControllerGUI::updateSerialPortList(const QStringList& serialPorts)
|
||||
ui->serialPort->blockSignals(false);
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::updatePipeList(const QList<MainCore::AvailableChannelOrFeature>& sources)
|
||||
void GS232ControllerGUI::updatePipeList(const AvailableChannelOrFeatureList& sources, const QStringList& renameFrom, const QStringList& renameTo)
|
||||
{
|
||||
QString currentText = ui->sources->currentText();
|
||||
QString newText;
|
||||
// Update source settting if it has been renamed
|
||||
if (renameFrom.contains(m_settings.m_source))
|
||||
{
|
||||
m_settings.m_source = renameTo[renameFrom.indexOf(m_settings.m_source)];
|
||||
applySetting("source");
|
||||
}
|
||||
|
||||
int prevIdx = ui->sources->currentIndex();
|
||||
ui->sources->blockSignals(true);
|
||||
ui->sources->clear();
|
||||
|
||||
@@ -557,40 +556,33 @@ void GS232ControllerGUI::updatePipeList(const QList<MainCore::AvailableChannelOr
|
||||
ui->sources->addItem(source.getLongId());
|
||||
}
|
||||
|
||||
int index = ui->sources->findText(m_settings.m_source);
|
||||
ui->sources->setCurrentIndex(index);
|
||||
|
||||
if (index < 0) // current source is not found
|
||||
// Select current setting, if it exists
|
||||
// If not, and no prior setting, make sure nothing selected, as channel/feature may be created later on
|
||||
// If not found and something was previously selected, clear the setting, as probably deleted
|
||||
int idx = ui->sources->findText(m_settings.m_source);
|
||||
if (idx >= 0)
|
||||
{
|
||||
ui->sources->setCurrentIndex(idx);
|
||||
}
|
||||
else if (prevIdx == -1)
|
||||
{
|
||||
ui->sources->setCurrentIndex(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_settings.m_source = "";
|
||||
applySetting("source");
|
||||
ui->targetName->setText("");
|
||||
m_settingsKeys.append("source");
|
||||
applySettings();
|
||||
}
|
||||
|
||||
// if (currentText.isEmpty())
|
||||
// {
|
||||
// // Source feature may be loaded after this, so may not have existed when
|
||||
// // displaySettings was called
|
||||
// if (sources.size() > 0) {
|
||||
// ui->sources->setCurrentIndex(ui->sources->findText(m_settings.m_source));
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// ui->sources->setCurrentIndex(ui->sources->findText(currentText));
|
||||
// }
|
||||
|
||||
ui->sources->blockSignals(false);
|
||||
|
||||
// QString newText = ui->sources->currentText();
|
||||
|
||||
// if (currentText != newText)
|
||||
// {
|
||||
// m_settings.m_source = newText;
|
||||
// ui->targetName->setText("");
|
||||
// applySettings();
|
||||
// }
|
||||
// If no current settting, select first available
|
||||
if (m_settings.m_source.isEmpty() && (ui->sources->count() > 0))
|
||||
{
|
||||
ui->sources->setCurrentIndex(0);
|
||||
on_sources_currentTextChanged(ui->sources->currentText());
|
||||
}
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::onMenuDialogCalled(const QPoint &p)
|
||||
@@ -620,15 +612,17 @@ void GS232ControllerGUI::onMenuDialogCalled(const QPoint &p)
|
||||
setTitle(m_settings.m_title);
|
||||
setTitleColor(m_settings.m_rgbColor);
|
||||
|
||||
m_settingsKeys.append("title");
|
||||
m_settingsKeys.append("rgbColor");
|
||||
m_settingsKeys.append("useReverseAPI");
|
||||
m_settingsKeys.append("reverseAPIAddress");
|
||||
m_settingsKeys.append("reverseAPIPort");
|
||||
m_settingsKeys.append("reverseAPIFeatureSetIndex");
|
||||
m_settingsKeys.append("reverseAPIFeatureIndex");
|
||||
QList<QString> settingsKeys({
|
||||
"rgbColor",
|
||||
"title",
|
||||
"useReverseAPI",
|
||||
"reverseAPIAddress",
|
||||
"reverseAPIPort",
|
||||
"reverseAPIDeviceIndex",
|
||||
"reverseAPIChannelIndex"
|
||||
});
|
||||
|
||||
applySettings();
|
||||
applySettings(settingsKeys);
|
||||
}
|
||||
|
||||
resetContextMenuType();
|
||||
@@ -698,15 +692,13 @@ void GS232ControllerGUI::on_protocol_currentIndexChanged(int index)
|
||||
{
|
||||
m_settings.m_protocol = (GS232ControllerSettings::Protocol)index;
|
||||
setProtocol(m_settings.m_protocol);
|
||||
m_settingsKeys.append("protocol");
|
||||
applySettings();
|
||||
applySetting("protocol");
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::on_connection_currentIndexChanged(int index)
|
||||
{
|
||||
m_settings.m_connection = (GS232ControllerSettings::Connection)index;
|
||||
m_settingsKeys.append("connection");
|
||||
applySettings();
|
||||
applySetting("connection");
|
||||
updateConnectionWidgets();
|
||||
}
|
||||
|
||||
@@ -714,30 +706,26 @@ void GS232ControllerGUI::on_serialPort_currentIndexChanged(int index)
|
||||
{
|
||||
(void) index;
|
||||
m_settings.m_serialPort = ui->serialPort->currentText();
|
||||
m_settingsKeys.append("serialPort");
|
||||
applySettings();
|
||||
applySetting("serialPort");
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::on_baudRate_currentIndexChanged(int index)
|
||||
{
|
||||
(void) index;
|
||||
m_settings.m_baudRate = ui->baudRate->currentText().toInt();
|
||||
m_settingsKeys.append("baudRate");
|
||||
applySettings();
|
||||
applySetting("baudRate");
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::on_host_editingFinished()
|
||||
{
|
||||
m_settings.m_host = ui->host->text();
|
||||
m_settingsKeys.append("host");
|
||||
applySettings();
|
||||
applySetting("host");
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::on_port_valueChanged(int value)
|
||||
{
|
||||
m_settings.m_port = value;
|
||||
m_settingsKeys.append("port");
|
||||
applySettings();
|
||||
applySetting("port");
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::on_coord1_valueChanged(double value)
|
||||
@@ -764,8 +752,7 @@ void GS232ControllerGUI::on_azimuthOffset_valueChanged(double value)
|
||||
m_inputAzOffset = value;
|
||||
}
|
||||
m_settings.m_azimuthOffset = (float) value;
|
||||
m_settingsKeys.append("azimuthOffset");
|
||||
applySettings();
|
||||
applySetting("azimuthOffset");
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::on_elevationOffset_valueChanged(double value)
|
||||
@@ -774,58 +761,50 @@ void GS232ControllerGUI::on_elevationOffset_valueChanged(double value)
|
||||
m_inputElOffset = value;
|
||||
}
|
||||
m_settings.m_elevationOffset = (float) value;
|
||||
m_settingsKeys.append("elevationOffset");
|
||||
applySettings();
|
||||
applySetting("elevationOffset");
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::on_azimuthMin_valueChanged(int value)
|
||||
{
|
||||
m_settings.m_azimuthMin = value;
|
||||
m_settingsKeys.append("azimuthMin");
|
||||
applySettings();
|
||||
applySetting("azimuthMin");
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::on_azimuthMax_valueChanged(int value)
|
||||
{
|
||||
m_settings.m_azimuthMax = value;
|
||||
m_settingsKeys.append("azimuthMax");
|
||||
applySettings();
|
||||
applySetting("azimuthMax");
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::on_elevationMin_valueChanged(int value)
|
||||
{
|
||||
m_settings.m_elevationMin = value;
|
||||
m_settingsKeys.append("elevationMin");
|
||||
applySettings();
|
||||
applySetting("elevationMin");
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::on_elevationMax_valueChanged(int value)
|
||||
{
|
||||
m_settings.m_elevationMax = value;
|
||||
m_settingsKeys.append("elevationMax");
|
||||
applySettings();
|
||||
applySetting("elevationMax");
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::on_tolerance_valueChanged(double value)
|
||||
{
|
||||
m_settings.m_tolerance = value;
|
||||
m_settingsKeys.append("tolerance");
|
||||
applySettings();
|
||||
applySetting("tolerance");
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::on_precision_valueChanged(int value)
|
||||
{
|
||||
m_settings.m_precision = value;
|
||||
setPrecision();
|
||||
m_settingsKeys.append("precision");
|
||||
applySettings();
|
||||
applySetting("precision");
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::on_coordinates_currentIndexChanged(int index)
|
||||
{
|
||||
m_settings.m_coordinates = (GS232ControllerSettings::Coordinates)index;
|
||||
m_settingsKeys.append("coordinates");
|
||||
applySettings();
|
||||
applySetting("coordinates");
|
||||
|
||||
float coord1, coord2;
|
||||
azElToDisplay(m_settings.m_azimuth, m_settings.m_elevation, coord1, coord2);
|
||||
@@ -880,8 +859,7 @@ void GS232ControllerGUI::on_track_stateChanged(int state)
|
||||
ui->targetName->setText("");
|
||||
}
|
||||
|
||||
m_settingsKeys.append("track");
|
||||
applySettings();
|
||||
applySetting("track");
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::on_sources_currentTextChanged(const QString& text)
|
||||
@@ -889,36 +867,31 @@ void GS232ControllerGUI::on_sources_currentTextChanged(const QString& text)
|
||||
qDebug("GS232ControllerGUI::on_sources_currentTextChanged: %s", qPrintable(text));
|
||||
m_settings.m_source = text;
|
||||
ui->targetName->setText("");
|
||||
m_settingsKeys.append("source");
|
||||
applySettings();
|
||||
applySetting("source");
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::on_dfmTrack_clicked(bool checked)
|
||||
{
|
||||
m_settings.m_dfmTrackOn = checked;
|
||||
m_settingsKeys.append("dfmTrackOn");
|
||||
applySettings();
|
||||
applySetting("dfmTrackOn");
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::on_dfmLubePumps_clicked(bool checked)
|
||||
{
|
||||
m_settings.m_dfmLubePumpsOn = checked;
|
||||
m_settingsKeys.append("dfmLubePumpsOn");
|
||||
applySettings();
|
||||
applySetting("dfmLubePumpsOn");
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::on_dfmBrakes_clicked(bool checked)
|
||||
{
|
||||
m_settings.m_dfmBrakesOn = checked;
|
||||
m_settingsKeys.append("dfmBrakesOn");
|
||||
applySettings();
|
||||
applySetting("dfmBrakesOn");
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::on_dfmDrives_clicked(bool checked)
|
||||
{
|
||||
m_settings.m_dfmDrivesOn = checked;
|
||||
m_settingsKeys.append("dfmDrivesOn");
|
||||
applySettings();
|
||||
applySetting("dfmDrivesOn");
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::on_dfmShowStatus_clicked()
|
||||
@@ -983,17 +956,28 @@ void GS232ControllerGUI::updateStatus()
|
||||
}
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::applySettings(bool force)
|
||||
void GS232ControllerGUI::applySetting(const QString& settingsKey)
|
||||
{
|
||||
applySettings({settingsKey});
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::applySettings(const QStringList& settingsKeys, bool force)
|
||||
{
|
||||
m_settingsKeys.append(settingsKeys);
|
||||
if (m_doApplySettings)
|
||||
{
|
||||
GS232Controller::MsgConfigureGS232Controller* message = GS232Controller::MsgConfigureGS232Controller::create(m_settings, m_settingsKeys, force);
|
||||
m_gs232Controller->getInputMessageQueue()->push(message);
|
||||
m_settingsKeys.clear();
|
||||
}
|
||||
|
||||
m_settingsKeys.clear();
|
||||
}
|
||||
|
||||
void GS232ControllerGUI::applyAllSettings()
|
||||
{
|
||||
applySettings(QStringList(), true);
|
||||
}
|
||||
|
||||
|
||||
void GS232ControllerGUI::makeUIConnections()
|
||||
{
|
||||
QObject::connect(ui->startStop, &ButtonSwitch::toggled, this, &GS232ControllerGUI::on_startStop_toggled);
|
||||
|
||||
Reference in New Issue
Block a user