1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-17 13:51:47 -05:00

REST API: config: fixes (1)

This commit is contained in:
f4exb 2019-08-12 01:46:27 +02:00
parent 48bd89aa09
commit ca66e47283
4 changed files with 55 additions and 16 deletions

View File

@ -619,19 +619,19 @@ void FreqTracker::webapiUpdateChannelSettings(
settings.m_squelchGate = response.getFreqTrackerSettings()->getSquelchGate(); settings.m_squelchGate = response.getFreqTrackerSettings()->getSquelchGate();
} }
if (channelSettingsKeys.contains("useReverseAPI")) { if (channelSettingsKeys.contains("useReverseAPI")) {
settings.m_useReverseAPI = response.getAmDemodSettings()->getUseReverseApi() != 0; settings.m_useReverseAPI = response.getFreqTrackerSettings()->getUseReverseApi() != 0;
} }
if (channelSettingsKeys.contains("reverseAPIAddress")) { if (channelSettingsKeys.contains("reverseAPIAddress")) {
settings.m_reverseAPIAddress = *response.getAmDemodSettings()->getReverseApiAddress(); settings.m_reverseAPIAddress = *response.getFreqTrackerSettings()->getReverseApiAddress();
} }
if (channelSettingsKeys.contains("reverseAPIPort")) { if (channelSettingsKeys.contains("reverseAPIPort")) {
settings.m_reverseAPIPort = response.getAmDemodSettings()->getReverseApiPort(); settings.m_reverseAPIPort = response.getFreqTrackerSettings()->getReverseApiPort();
} }
if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) { if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) {
settings.m_reverseAPIDeviceIndex = response.getAmDemodSettings()->getReverseApiDeviceIndex(); settings.m_reverseAPIDeviceIndex = response.getFreqTrackerSettings()->getReverseApiDeviceIndex();
} }
if (channelSettingsKeys.contains("reverseAPIChannelIndex")) { if (channelSettingsKeys.contains("reverseAPIChannelIndex")) {
settings.m_reverseAPIChannelIndex = response.getAmDemodSettings()->getReverseApiChannelIndex(); settings.m_reverseAPIChannelIndex = response.getFreqTrackerSettings()->getReverseApiChannelIndex();
} }
} }

View File

@ -114,10 +114,10 @@ void WebAPIAdapterBase::webapiFormatPreset(
swgSpectrumConfig->setFftWindow((int) m_spectrumSettings.m_fftWindow); swgSpectrumConfig->setFftWindow((int) m_spectrumSettings.m_fftWindow);
swgSpectrumConfig->setRefLevel(m_spectrumSettings.m_refLevel); swgSpectrumConfig->setRefLevel(m_spectrumSettings.m_refLevel);
swgSpectrumConfig->setPowerRange(m_spectrumSettings.m_powerRange); swgSpectrumConfig->setPowerRange(m_spectrumSettings.m_powerRange);
swgSpectrumConfig->setDisplayWaterfall(m_spectrumSettings.m_displayWaterfall ? 0 : 1); swgSpectrumConfig->setDisplayWaterfall(m_spectrumSettings.m_displayWaterfall ? 1 : 0);
swgSpectrumConfig->setInvertedWaterfall(m_spectrumSettings.m_invertedWaterfall ? 0 : 1); swgSpectrumConfig->setInvertedWaterfall(m_spectrumSettings.m_invertedWaterfall ? 1 : 0);
swgSpectrumConfig->setDisplayMaxHold(m_spectrumSettings.m_displayMaxHold ? 0 : 1); swgSpectrumConfig->setDisplayMaxHold(m_spectrumSettings.m_displayMaxHold ? 1 : 0);
swgSpectrumConfig->setDisplayHistogram(m_spectrumSettings.m_displayHistogram ? 0 : 1); swgSpectrumConfig->setDisplayHistogram(m_spectrumSettings.m_displayHistogram ? 1 : 0);
swgSpectrumConfig->setDecay(m_spectrumSettings.m_decay); swgSpectrumConfig->setDecay(m_spectrumSettings.m_decay);
swgSpectrumConfig->setDisplayGrid(m_spectrumSettings.m_displayGrid ? 1 : 0); swgSpectrumConfig->setDisplayGrid(m_spectrumSettings.m_displayGrid ? 1 : 0);
swgSpectrumConfig->setInvert(m_spectrumSettings.m_invert ? 1 : 0); swgSpectrumConfig->setInvert(m_spectrumSettings.m_invert ? 1 : 0);

View File

@ -2270,13 +2270,16 @@ bool WebAPIRequestMapper::validateConfig(SWGSDRangel::SWGInstanceConfigResponse&
if (jsonObject.contains("presets")) if (jsonObject.contains("presets"))
{ {
QList<SWGSDRangel::SWGPreset *> *presets = new QList<SWGSDRangel::SWGPreset *>();
config.setPresets(presets);
QJsonArray presetsJson = jsonObject["presets"].toArray(); QJsonArray presetsJson = jsonObject["presets"].toArray();
QJsonArray::const_iterator presetsIt = presetsJson.begin(); QJsonArray::const_iterator presetsIt = presetsJson.begin();
for (; presetsIt != presetsJson.end(); ++presetsIt) for (; presetsIt != presetsJson.end(); ++presetsIt)
{ {
SWGSDRangel::SWGPreset *preset = new SWGSDRangel::SWGPreset();
QJsonObject presetJson = presetsIt->toObject(); QJsonObject presetJson = presetsIt->toObject();
SWGSDRangel::SWGPreset *preset = new SWGSDRangel::SWGPreset();
presets->append(preset);
configKeys.m_presetKeys.append(WebAPIAdapterInterface::PresetKeys()); configKeys.m_presetKeys.append(WebAPIAdapterInterface::PresetKeys());
appendPresetKeys(preset, presetJson, configKeys.m_presetKeys.back()); appendPresetKeys(preset, presetJson, configKeys.m_presetKeys.back());
} }
@ -2349,11 +2352,17 @@ bool WebAPIRequestMapper::appendPresetKeys(
for (; channelsIt != channelsJson.end(); ++channelsIt) for (; channelsIt != channelsJson.end(); ++channelsIt)
{ {
QJsonObject channelJson = channelsIt->toObject(); QJsonObject channelJson = channelsIt->toObject();
channels->append(new SWGSDRangel::SWGChannelConfig()); SWGSDRangel::SWGChannelConfig *channelConfig = new SWGSDRangel::SWGChannelConfig();
presetKeys.m_channelsKeys.append(WebAPIAdapterInterface::ChannelKeys()); presetKeys.m_channelsKeys.append(WebAPIAdapterInterface::ChannelKeys());
if (!appendPresetChannelKeys(channels->back(), channelJson, presetKeys.m_channelsKeys.back())) { if (appendPresetChannelKeys(channelConfig, channelJson, presetKeys.m_channelsKeys.back()))
return false; {
channels->append(channelConfig);
}
else
{
delete channelConfig;
presetKeys.m_channelsKeys.takeLast(); // remove channel keys
} }
} }
} }
@ -2368,11 +2377,17 @@ bool WebAPIRequestMapper::appendPresetKeys(
for (; devicesIt != devicesJson.end(); ++devicesIt) for (; devicesIt != devicesJson.end(); ++devicesIt)
{ {
QJsonObject deviceJson = devicesIt->toObject(); QJsonObject deviceJson = devicesIt->toObject();
devices->append(new SWGSDRangel::SWGDeviceConfig()); SWGSDRangel::SWGDeviceConfig *deviceConfig = new SWGSDRangel::SWGDeviceConfig();
presetKeys.m_devicesKeys.append(WebAPIAdapterInterface::DeviceKeys()); presetKeys.m_devicesKeys.append(WebAPIAdapterInterface::DeviceKeys());
if (!appendPresetDeviceKeys(devices->back(), deviceJson, presetKeys.m_devicesKeys.back())) { if (appendPresetDeviceKeys(deviceConfig, deviceJson, presetKeys.m_devicesKeys.back()))
return false; {
devices->append(deviceConfig);
}
else
{
delete deviceConfig;
presetKeys.m_devicesKeys.takeLast(); // remove device keys
} }
} }
} }

View File

@ -121,6 +121,7 @@ MainWindow::MainWindow(qtwebapp::LoggerWithFile *logger, const MainParser& parse
SDRangelSplash *splash = new SDRangelSplash(logoPixmap); SDRangelSplash *splash = new SDRangelSplash(logoPixmap);
splash->setMessageRect(QRect(10, 80, 350, 16)); splash->setMessageRect(QRect(10, 80, 350, 16));
splash->show(); splash->show();
splash->showStatusMessage("starting...", Qt::white);
splash->showStatusMessage("starting...", Qt::white); splash->showStatusMessage("starting...", Qt::white);
m_settings.setAudioDeviceManager(m_dspEngine->getAudioDeviceManager()); m_settings.setAudioDeviceManager(m_dspEngine->getAudioDeviceManager());
@ -912,6 +913,29 @@ QTreeWidgetItem* MainWindow::addCommandToTree(const Command* command)
void MainWindow::applySettings() void MainWindow::applySettings()
{ {
loadPresetSettings(m_settings.getWorkingPreset(), 0); loadPresetSettings(m_settings.getWorkingPreset(), 0);
m_settings.sortPresets();
int middleIndex = m_settings.getPresetCount() / 2;
QTreeWidgetItem *treeItem;
ui->presetTree->clear();
for (int i = 0; i < m_settings.getPresetCount(); ++i)
{
treeItem = addPresetToTree(m_settings.getPreset(i));
if (i == middleIndex) {
ui->presetTree->setCurrentItem(treeItem);
}
}
m_settings.sortCommands();
ui->commandTree->clear();
for (int i = 0; i < m_settings.getCommandCount(); ++i) {
treeItem = addCommandToTree(m_settings.getCommand(i));
}
setLoggingOptions();
} }
bool MainWindow::handleMessage(const Message& cmd) bool MainWindow::handleMessage(const Message& cmd)