mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-04 06:54:39 -04:00
Make device title editable in the basic device settings. Fixes #2292
This commit is contained in:
@@ -433,6 +433,9 @@ void RemoteInput::webapiUpdateDeviceSettings(
|
||||
const QStringList& deviceSettingsKeys,
|
||||
SWGSDRangel::SWGDeviceSettings& response)
|
||||
{
|
||||
if (deviceSettingsKeys.contains("title")) {
|
||||
settings.m_title = *response.getRemoteInputSettings()->getTitle();
|
||||
}
|
||||
if (deviceSettingsKeys.contains("apiAddress")) {
|
||||
settings.m_apiAddress = *response.getRemoteInputSettings()->getApiAddress();
|
||||
}
|
||||
@@ -473,6 +476,12 @@ void RemoteInput::webapiUpdateDeviceSettings(
|
||||
|
||||
void RemoteInput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const RemoteInputSettings& settings)
|
||||
{
|
||||
if (response.getRemoteInputSettings()->getTitle()) {
|
||||
*response.getRemoteInputSettings()->getTitle() = settings.m_title;
|
||||
} else {
|
||||
response.getRemoteInputSettings()->setTitle(new QString(settings.m_title));
|
||||
}
|
||||
|
||||
response.getRemoteInputSettings()->setApiAddress(new QString(settings.m_apiAddress));
|
||||
response.getRemoteInputSettings()->setApiPort(settings.m_apiPort);
|
||||
response.getRemoteInputSettings()->setDataAddress(new QString(settings.m_dataAddress));
|
||||
@@ -529,6 +538,9 @@ void RemoteInput::webapiReverseSendSettings(const QList<QString>& deviceSettings
|
||||
|
||||
// transfer data that has been modified. When force is on transfer all data except reverse API data
|
||||
|
||||
if (deviceSettingsKeys.contains("title") || force) {
|
||||
swgRemoteInputSettings->setTitle(new QString(settings.m_title));
|
||||
}
|
||||
if (deviceSettingsKeys.contains("apiAddress") || force) {
|
||||
swgRemoteInputSettings->setApiAddress(new QString(settings.m_apiAddress));
|
||||
}
|
||||
@@ -700,5 +712,3 @@ void RemoteInput::analyzeRemoteChannelSettingsReply(const QJsonObject& jsonObjec
|
||||
m_guiMessageQueue->push(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "gui/glspectrum.h"
|
||||
#include "gui/basicdevicesettingsdialog.h"
|
||||
#include "gui/dialogpositioner.h"
|
||||
#include "mainspectrum/mainspectrumgui.h"
|
||||
#include "dsp/dspcommands.h"
|
||||
#include "dsp/hbfilterchainconverter.h"
|
||||
#include "device/deviceapi.h"
|
||||
@@ -299,6 +300,8 @@ void RemoteInputGui::displaySettings()
|
||||
{
|
||||
blockApplySettings(true);
|
||||
|
||||
setTitle(m_settings.m_title);
|
||||
getDeviceUISet()->m_mainSpectrumGUI->setTitle(m_settings.m_title);
|
||||
ui->centerFrequency->setText(tr("%L1").arg(m_streamCenterFrequency));
|
||||
ui->deviceRateText->setText(tr("%1k").arg(m_streamSampleRate / 1000.0));
|
||||
|
||||
@@ -698,21 +701,30 @@ void RemoteInputGui::openDeviceSettingsDialog(const QPoint& p)
|
||||
dialog.setReverseAPIAddress(m_settings.m_reverseAPIAddress);
|
||||
dialog.setReverseAPIPort(m_settings.m_reverseAPIPort);
|
||||
dialog.setReverseAPIDeviceIndex(m_settings.m_reverseAPIDeviceIndex);
|
||||
dialog.setTitle(m_settings.m_title);
|
||||
dialog.setDefaultTitle(getDefaultTitle());
|
||||
|
||||
dialog.move(p);
|
||||
new DialogPositioner(&dialog, false);
|
||||
dialog.exec();
|
||||
|
||||
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_settingsKeys.append("useReverseAPI");
|
||||
m_settingsKeys.append("reverseAPIAddress");
|
||||
m_settingsKeys.append("reverseAPIPort");
|
||||
m_settingsKeys.append("reverseAPIDeviceIndex");
|
||||
if (dialog.result() == QDialog::Accepted)
|
||||
{
|
||||
m_settings.m_title = dialog.getTitle();
|
||||
setTitle(m_settings.m_title);
|
||||
getDeviceUISet()->m_mainSpectrumGUI->setTitle(m_settings.m_title);
|
||||
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_settingsKeys.append("title");
|
||||
m_settingsKeys.append("useReverseAPI");
|
||||
m_settingsKeys.append("reverseAPIAddress");
|
||||
m_settingsKeys.append("reverseAPIPort");
|
||||
m_settingsKeys.append("reverseAPIDeviceIndex");
|
||||
|
||||
sendSettings();
|
||||
sendSettings();
|
||||
}
|
||||
}
|
||||
|
||||
resetContextMenuType();
|
||||
|
||||
@@ -28,6 +28,7 @@ RemoteInputSettings::RemoteInputSettings()
|
||||
|
||||
void RemoteInputSettings::resetToDefaults()
|
||||
{
|
||||
m_title = "RemoteInput";
|
||||
m_apiAddress = "127.0.0.1";
|
||||
m_apiPort = 8091;
|
||||
m_dataAddress = "127.0.0.1";
|
||||
@@ -46,6 +47,7 @@ QByteArray RemoteInputSettings::serialize() const
|
||||
{
|
||||
SimpleSerializer s(1);
|
||||
|
||||
s.writeString(1, m_title);
|
||||
s.writeString(3, m_multicastAddress);
|
||||
s.writeBool(4, m_multicastJoin);
|
||||
s.writeString(5, m_apiAddress);
|
||||
@@ -76,6 +78,7 @@ bool RemoteInputSettings::deserialize(const QByteArray& data)
|
||||
{
|
||||
quint32 uintval;
|
||||
|
||||
d.readString(1, &m_title, "RemoteInput");
|
||||
d.readString(3, &m_multicastAddress, "224.0.0.1");
|
||||
d.readBool(4, &m_multicastJoin, false);
|
||||
d.readString(5, &m_apiAddress, "127.0.0.1");
|
||||
@@ -110,6 +113,9 @@ bool RemoteInputSettings::deserialize(const QByteArray& data)
|
||||
|
||||
void RemoteInputSettings::applySettings(const QStringList& settingsKeys, const RemoteInputSettings& settings)
|
||||
{
|
||||
if (settingsKeys.contains("title")) {
|
||||
m_title = settings.m_title;
|
||||
}
|
||||
if (settingsKeys.contains("apiAddress")) {
|
||||
m_apiAddress = settings.m_apiAddress;
|
||||
}
|
||||
@@ -152,6 +158,9 @@ QString RemoteInputSettings::getDebugString(const QStringList& settingsKeys, boo
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
|
||||
if (settingsKeys.contains("title") || force) {
|
||||
ostr << " m_title: " << m_title.toStdString();
|
||||
}
|
||||
if (settingsKeys.contains("apiAddress") || force) {
|
||||
ostr << " m_apiAddress: " << m_apiAddress.toStdString();
|
||||
}
|
||||
@@ -191,4 +200,3 @@ QString RemoteInputSettings::getDebugString(const QStringList& settingsKeys, boo
|
||||
|
||||
return QString(ostr.str().c_str());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,9 @@
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
|
||||
struct RemoteInputSettings {
|
||||
struct RemoteInputSettings
|
||||
{
|
||||
QString m_title;
|
||||
QString m_apiAddress;
|
||||
quint16 m_apiPort;
|
||||
QString m_dataAddress;
|
||||
|
||||
Reference in New Issue
Block a user