mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-14 20:31:53 -05:00
Implement signal when main preferences are changed. Partially implements #1139
This commit is contained in:
parent
9a2ba902c7
commit
4b82b919d3
@ -1,6 +1,7 @@
|
|||||||
#ifndef INCLUDE_SETTINGS_H
|
#ifndef INCLUDE_SETTINGS_H
|
||||||
#define INCLUDE_SETTINGS_H
|
#define INCLUDE_SETTINGS_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include "device/deviceuserargs.h"
|
#include "device/deviceuserargs.h"
|
||||||
#include "limerfe/limerfeusbcalib.h"
|
#include "limerfe/limerfeusbcalib.h"
|
||||||
@ -15,7 +16,8 @@ class AudioDeviceManager;
|
|||||||
class AMBEEngine;
|
class AMBEEngine;
|
||||||
|
|
||||||
|
|
||||||
class SDRBASE_API MainSettings {
|
class SDRBASE_API MainSettings : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
MainSettings();
|
MainSettings();
|
||||||
~MainSettings();
|
~MainSettings();
|
||||||
@ -68,37 +70,106 @@ public:
|
|||||||
FeatureSetPreset* getWorkingFeatureSetPreset() { return &m_workingFeatureSetPreset; }
|
FeatureSetPreset* getWorkingFeatureSetPreset() { return &m_workingFeatureSetPreset; }
|
||||||
QList<FeatureSetPreset*> *getFeatureSetPresets() { return &m_featureSetPresets; }
|
QList<FeatureSetPreset*> *getFeatureSetPresets() { return &m_featureSetPresets; }
|
||||||
|
|
||||||
int getSourceItemIndex() const { return m_preferences.getSourceItemIndex(); }
|
const QString& getSourceDevice() const { return m_preferences.getSourceDevice(); }
|
||||||
void setSourceItemIndex(int value) { m_preferences.setSourceItemIndex(value); }
|
void setSourceDevice(const QString& value)
|
||||||
|
{
|
||||||
|
m_preferences.setSourceDevice(value);
|
||||||
|
emit preferenceChanged(Preferences::SourceDevice);
|
||||||
|
}
|
||||||
|
|
||||||
int getSourceIndex() const { return m_preferences.getSourceIndex(); }
|
int getSourceIndex() const { return m_preferences.getSourceIndex(); }
|
||||||
void setSourceIndex(int value) { m_preferences.setSourceIndex(value); }
|
void setSourceIndex(int value)
|
||||||
const QString& getSourceDeviceId() const { return m_preferences.getSourceDevice(); }
|
{
|
||||||
void setSourceDeviceId(const QString& deviceId) { m_preferences.setSourceDevice(deviceId); }
|
m_preferences.setSourceIndex(value);
|
||||||
|
emit preferenceChanged(Preferences::SourceIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
int getSourceItemIndex() const { return m_preferences.getSourceItemIndex(); }
|
||||||
|
void setSourceItemIndex(int value)
|
||||||
|
{
|
||||||
|
m_preferences.setSourceItemIndex(value);
|
||||||
|
emit preferenceChanged(Preferences::SourceItemIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString& getAudioType() const { return m_preferences.getAudioType(); }
|
||||||
|
void setAudioType(const QString& value)
|
||||||
|
{
|
||||||
|
m_preferences.setAudioType(value);
|
||||||
|
emit preferenceChanged(Preferences::AudioType);
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString& getAudioDevice() const { return m_preferences.getAudioDevice(); }
|
||||||
|
void setAudioDevice(const QString& value)
|
||||||
|
{
|
||||||
|
m_preferences.setAudioDevice(value);
|
||||||
|
emit preferenceChanged(Preferences::AudioDevice);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString getStationName() const { return m_preferences.getStationName(); }
|
||||||
|
void setStationName(const QString& name)
|
||||||
|
{
|
||||||
|
m_preferences.setStationName(name);
|
||||||
|
emit preferenceChanged(Preferences::StationName);
|
||||||
|
}
|
||||||
|
|
||||||
void setStationName(const QString& name) { m_preferences.setStationName(name); }
|
|
||||||
void setLatitude(float latitude) { m_preferences.setLatitude(latitude); }
|
|
||||||
void setLongitude(float longitude) { m_preferences.setLongitude(longitude); }
|
|
||||||
void setAltitude(float altitude) { m_preferences.setAltitude(altitude); }
|
|
||||||
QString getStationName() const { return m_preferences.getStationName(); }
|
|
||||||
float getLatitude() const { return m_preferences.getLatitude(); }
|
float getLatitude() const { return m_preferences.getLatitude(); }
|
||||||
float getLongitude() const { return m_preferences.getLongitude(); }
|
void setLatitude(float latitude)
|
||||||
float getAltitude() const { return m_preferences.getAltitude(); }
|
{
|
||||||
|
m_preferences.setLatitude(latitude);
|
||||||
|
emit preferenceChanged(Preferences::Latitude);
|
||||||
|
}
|
||||||
|
|
||||||
|
float getLongitude() const { return m_preferences.getLongitude(); }
|
||||||
|
void setLongitude(float longitude)
|
||||||
|
{
|
||||||
|
m_preferences.setLongitude(longitude);
|
||||||
|
emit preferenceChanged(Preferences::Longitude);
|
||||||
|
}
|
||||||
|
|
||||||
|
float getAltitude() const { return m_preferences.getAltitude(); }
|
||||||
|
void setAltitude(float altitude)
|
||||||
|
{
|
||||||
|
m_preferences.setAltitude(altitude);
|
||||||
|
emit preferenceChanged(Preferences::Altitude);
|
||||||
|
}
|
||||||
|
|
||||||
void setConsoleMinLogLevel(const QtMsgType& minLogLevel) { m_preferences.setConsoleMinLogLevel(minLogLevel); }
|
|
||||||
void setFileMinLogLevel(const QtMsgType& minLogLevel) { m_preferences.setFileMinLogLevel(minLogLevel); }
|
|
||||||
void setUseLogFile(bool useLogFile) { m_preferences.setUseLogFile(useLogFile); }
|
|
||||||
void setLogFileName(const QString& value) { m_preferences.setLogFileName(value); }
|
|
||||||
QtMsgType getConsoleMinLogLevel() const { return m_preferences.getConsoleMinLogLevel(); }
|
QtMsgType getConsoleMinLogLevel() const { return m_preferences.getConsoleMinLogLevel(); }
|
||||||
|
void setConsoleMinLogLevel(const QtMsgType& minLogLevel)
|
||||||
|
{
|
||||||
|
m_preferences.setConsoleMinLogLevel(minLogLevel);
|
||||||
|
emit preferenceChanged(Preferences::ConsoleMinLogLevel);
|
||||||
|
}
|
||||||
|
|
||||||
QtMsgType getFileMinLogLevel() const { return m_preferences.getFileMinLogLevel(); }
|
QtMsgType getFileMinLogLevel() const { return m_preferences.getFileMinLogLevel(); }
|
||||||
|
void setFileMinLogLevel(const QtMsgType& minLogLevel)
|
||||||
|
{
|
||||||
|
m_preferences.setFileMinLogLevel(minLogLevel);
|
||||||
|
emit preferenceChanged(Preferences::FileMinLogLevel);
|
||||||
|
}
|
||||||
|
|
||||||
bool getUseLogFile() const { return m_preferences.getUseLogFile(); }
|
bool getUseLogFile() const { return m_preferences.getUseLogFile(); }
|
||||||
|
void setUseLogFile(bool useLogFile)
|
||||||
|
{
|
||||||
|
m_preferences.setUseLogFile(useLogFile);
|
||||||
|
emit preferenceChanged(Preferences::UseLogFile);
|
||||||
|
}
|
||||||
|
|
||||||
const QString& getLogFileName() const { return m_preferences.getLogFileName(); }
|
const QString& getLogFileName() const { return m_preferences.getLogFileName(); }
|
||||||
|
void setLogFileName(const QString& value)
|
||||||
|
{
|
||||||
|
m_preferences.setLogFileName(value);
|
||||||
|
emit preferenceChanged(Preferences::LogFileName);
|
||||||
|
}
|
||||||
|
|
||||||
DeviceUserArgs& getDeviceUserArgs() { return m_hardwareDeviceUserArgs; }
|
DeviceUserArgs& getDeviceUserArgs() { return m_hardwareDeviceUserArgs; }
|
||||||
LimeRFEUSBCalib& getLimeRFEUSBCalib() { return m_limeRFEUSBCalib; }
|
LimeRFEUSBCalib& getLimeRFEUSBCalib() { return m_limeRFEUSBCalib; }
|
||||||
|
|
||||||
const AudioDeviceManager *getAudioDeviceManager() const { return m_audioDeviceManager; }
|
const AudioDeviceManager *getAudioDeviceManager() const { return m_audioDeviceManager; }
|
||||||
void setAudioDeviceManager(AudioDeviceManager *audioDeviceManager) { m_audioDeviceManager = audioDeviceManager; }
|
void setAudioDeviceManager(AudioDeviceManager *audioDeviceManager) { m_audioDeviceManager = audioDeviceManager; }
|
||||||
void setAMBEEngine(AMBEEngine *ambeEngine) { m_ambeEngine = ambeEngine; }
|
void setAMBEEngine(AMBEEngine *ambeEngine) { m_ambeEngine = ambeEngine; }
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void preferenceChanged(int);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Preferences m_preferences;
|
Preferences m_preferences;
|
||||||
AudioDeviceManager *m_audioDeviceManager;
|
AudioDeviceManager *m_audioDeviceManager;
|
||||||
|
@ -26,19 +26,19 @@ void Preferences::resetToDefaults()
|
|||||||
QByteArray Preferences::serialize() const
|
QByteArray Preferences::serialize() const
|
||||||
{
|
{
|
||||||
SimpleSerializer s(1);
|
SimpleSerializer s(1);
|
||||||
s.writeString(2, m_sourceDevice);
|
s.writeString((int) SourceDevice, m_sourceDevice);
|
||||||
s.writeString(3, m_audioType);
|
s.writeString((int) AudioType, m_audioType);
|
||||||
s.writeString(4, m_audioDevice);
|
s.writeString((int) AudioDevice, m_audioDevice);
|
||||||
s.writeS32(5, m_sourceIndex);
|
s.writeS32((int) SourceIndex, m_sourceIndex);
|
||||||
s.writeFloat(6, m_latitude);
|
s.writeFloat((int) Latitude, m_latitude);
|
||||||
s.writeFloat(7, m_longitude);
|
s.writeFloat((int) Longitude, m_longitude);
|
||||||
s.writeS32(8, (int) m_consoleMinLogLevel);
|
s.writeS32((int) ConsoleMinLogLevel, (int) m_consoleMinLogLevel);
|
||||||
s.writeBool(9, m_useLogFile);
|
s.writeBool((int) UseLogFile, m_useLogFile);
|
||||||
s.writeString(10, m_logFileName);
|
s.writeString((int) LogFileName, m_logFileName);
|
||||||
s.writeS32(11, (int) m_fileMinLogLevel);
|
s.writeS32((int) FileMinLogLevel, (int) m_fileMinLogLevel);
|
||||||
s.writeString(12, m_stationName);
|
s.writeString((int) StationName, m_stationName);
|
||||||
s.writeFloat(13, m_altitude);
|
s.writeFloat((int) Altitude, m_altitude);
|
||||||
s.writeS32(14, m_sourceItemIndex);
|
s.writeS32((int) SourceItemIndex, m_sourceItemIndex);
|
||||||
return s.final();
|
return s.final();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,14 +55,14 @@ bool Preferences::deserialize(const QByteArray& data)
|
|||||||
|
|
||||||
if(d.getVersion() == 1)
|
if(d.getVersion() == 1)
|
||||||
{
|
{
|
||||||
d.readString(2, &m_sourceDevice);
|
d.readString((int) SourceDevice, &m_sourceDevice);
|
||||||
d.readString(3, &m_audioType);
|
d.readString((int) AudioType, &m_audioType);
|
||||||
d.readString(4, &m_audioDevice);
|
d.readString((int) AudioDevice, &m_audioDevice);
|
||||||
d.readS32(5, &m_sourceIndex, 0);
|
d.readS32((int) SourceIndex, &m_sourceIndex, 0);
|
||||||
d.readFloat(6, &m_latitude, 0.0f);
|
d.readFloat((int) Latitude, &m_latitude, 0.0f);
|
||||||
d.readFloat(7, &m_longitude, 0.0f);
|
d.readFloat((int) Longitude, &m_longitude, 0.0f);
|
||||||
|
|
||||||
d.readS32(8, &tmpInt, (int) QtDebugMsg);
|
d.readS32((int) ConsoleMinLogLevel, &tmpInt, (int) QtDebugMsg);
|
||||||
|
|
||||||
if ((tmpInt == (int) QtDebugMsg) ||
|
if ((tmpInt == (int) QtDebugMsg) ||
|
||||||
(tmpInt == (int) QtInfoMsg) ||
|
(tmpInt == (int) QtInfoMsg) ||
|
||||||
@ -74,13 +74,13 @@ bool Preferences::deserialize(const QByteArray& data)
|
|||||||
m_consoleMinLogLevel = QtDebugMsg;
|
m_consoleMinLogLevel = QtDebugMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
d.readBool(9, &m_useLogFile, false);
|
d.readBool((int) UseLogFile, &m_useLogFile, false);
|
||||||
d.readString(10, &m_logFileName, "sdrangel.log");
|
d.readString((int) LogFileName, &m_logFileName, "sdrangel.log");
|
||||||
|
|
||||||
d.readS32(11, &tmpInt, (int) QtDebugMsg);
|
d.readS32((int) FileMinLogLevel, &tmpInt, (int) QtDebugMsg);
|
||||||
d.readString(12, &m_stationName, "Home");
|
d.readString((int) StationName, &m_stationName, "Home");
|
||||||
d.readFloat(13, &m_altitude, 0.0f);
|
d.readFloat((int) Altitude, &m_altitude, 0.0f);
|
||||||
d.readS32(14, &m_sourceItemIndex, 0);
|
d.readS32((int) SourceItemIndex, &m_sourceItemIndex, 0);
|
||||||
|
|
||||||
if ((tmpInt == (int) QtDebugMsg) ||
|
if ((tmpInt == (int) QtDebugMsg) ||
|
||||||
(tmpInt == (int) QtInfoMsg) ||
|
(tmpInt == (int) QtInfoMsg) ||
|
||||||
|
@ -7,41 +7,69 @@
|
|||||||
|
|
||||||
class SDRBASE_API Preferences {
|
class SDRBASE_API Preferences {
|
||||||
public:
|
public:
|
||||||
Preferences();
|
enum ElementType
|
||||||
|
{
|
||||||
|
SourceDevice = 2,
|
||||||
|
AudioType,
|
||||||
|
AudioDevice,
|
||||||
|
SourceIndex,
|
||||||
|
Latitude,
|
||||||
|
Longitude,
|
||||||
|
ConsoleMinLogLevel,
|
||||||
|
UseLogFile,
|
||||||
|
LogFileName,
|
||||||
|
FileMinLogLevel,
|
||||||
|
StationName,
|
||||||
|
Altitude,
|
||||||
|
SourceItemIndex
|
||||||
|
};
|
||||||
|
|
||||||
|
Preferences();
|
||||||
|
Preferences(const Preferences&) = default;
|
||||||
|
Preferences& operator=(const Preferences&) = default;
|
||||||
|
|
||||||
void resetToDefaults();
|
void resetToDefaults();
|
||||||
QByteArray serialize() const;
|
QByteArray serialize() const;
|
||||||
bool deserialize(const QByteArray& data);
|
bool deserialize(const QByteArray& data);
|
||||||
|
|
||||||
void setSourceDevice(const QString& value) { m_sourceDevice = value; }
|
|
||||||
const QString& getSourceDevice() const { return m_sourceDevice; }
|
const QString& getSourceDevice() const { return m_sourceDevice; }
|
||||||
void setSourceIndex(const int value) { m_sourceIndex = value; }
|
void setSourceDevice(const QString& value) { m_sourceDevice = value; }
|
||||||
|
|
||||||
int getSourceIndex() const { return m_sourceIndex; }
|
int getSourceIndex() const { return m_sourceIndex; }
|
||||||
void setSourceItemIndex(const int value) { m_sourceItemIndex = value; }
|
void setSourceIndex(const int value) { m_sourceIndex = value; }
|
||||||
|
|
||||||
int getSourceItemIndex() const { return m_sourceItemIndex; }
|
int getSourceItemIndex() const { return m_sourceItemIndex; }
|
||||||
|
void setSourceItemIndex(const int value) { m_sourceItemIndex = value; }
|
||||||
|
|
||||||
void setAudioType(const QString& value) { m_audioType = value; }
|
|
||||||
const QString& getAudioType() const { return m_audioType; }
|
const QString& getAudioType() const { return m_audioType; }
|
||||||
void setAudioDevice(const QString& value) { m_audioDevice = value; }
|
void setAudioType(const QString& value) { m_audioType = value; }
|
||||||
|
|
||||||
const QString& getAudioDevice() const { return m_audioDevice; }
|
const QString& getAudioDevice() const { return m_audioDevice; }
|
||||||
|
void setAudioDevice(const QString& value) { m_audioDevice = value; }
|
||||||
|
|
||||||
|
QString getStationName() const { return m_stationName; }
|
||||||
void setStationName(const QString& name) { m_stationName = name; }
|
void setStationName(const QString& name) { m_stationName = name; }
|
||||||
void setLatitude(float latitude) { m_latitude = latitude; }
|
|
||||||
void setLongitude(float longitude) { m_longitude = longitude; }
|
|
||||||
void setAltitude(float altitude) { m_altitude = altitude; }
|
|
||||||
QString getStationName() const { return m_stationName; }
|
|
||||||
float getLatitude() const { return m_latitude; }
|
|
||||||
float getLongitude() const { return m_longitude; }
|
|
||||||
float getAltitude() const { return m_altitude; }
|
|
||||||
|
|
||||||
void setConsoleMinLogLevel(const QtMsgType& minLogLevel) { m_consoleMinLogLevel = minLogLevel; }
|
float getLatitude() const { return m_latitude; }
|
||||||
void setFileMinLogLevel(const QtMsgType& minLogLevel) { m_fileMinLogLevel = minLogLevel; }
|
void setLatitude(float latitude) { m_latitude = latitude; }
|
||||||
void setUseLogFile(bool useLogFile) { m_useLogFile = useLogFile; }
|
|
||||||
void setLogFileName(const QString& value) { m_logFileName = value; }
|
float getLongitude() const { return m_longitude; }
|
||||||
|
void setLongitude(float longitude) { m_longitude = longitude; }
|
||||||
|
|
||||||
|
float getAltitude() const { return m_altitude; }
|
||||||
|
void setAltitude(float altitude) { m_altitude = altitude; }
|
||||||
|
|
||||||
QtMsgType getConsoleMinLogLevel() const { return m_consoleMinLogLevel; }
|
QtMsgType getConsoleMinLogLevel() const { return m_consoleMinLogLevel; }
|
||||||
|
void setConsoleMinLogLevel(const QtMsgType& minLogLevel) { m_consoleMinLogLevel = minLogLevel; }
|
||||||
|
|
||||||
QtMsgType getFileMinLogLevel() const { return m_fileMinLogLevel; }
|
QtMsgType getFileMinLogLevel() const { return m_fileMinLogLevel; }
|
||||||
|
void setFileMinLogLevel(const QtMsgType& minLogLevel) { m_fileMinLogLevel = minLogLevel; }
|
||||||
|
|
||||||
bool getUseLogFile() const { return m_useLogFile; }
|
bool getUseLogFile() const { return m_useLogFile; }
|
||||||
|
void setUseLogFile(bool useLogFile) { m_useLogFile = useLogFile; }
|
||||||
|
|
||||||
const QString& getLogFileName() const { return m_logFileName; }
|
const QString& getLogFileName() const { return m_logFileName; }
|
||||||
|
void setLogFileName(const QString& value) { m_logFileName = value; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString m_sourceDevice; //!< Identification of the source used in R0 tab (GUI flavor) at startup
|
QString m_sourceDevice; //!< Identification of the source used in R0 tab (GUI flavor) at startup
|
||||||
|
@ -236,12 +236,12 @@ MainWindow::MainWindow(qtwebapp::LoggerWithFile *logger, const MainParser& parse
|
|||||||
splash->showStatusMessage("load last device or file input...", Qt::white);
|
splash->showStatusMessage("load last device or file input...", Qt::white);
|
||||||
qDebug() << "MainWindow::MainWindow: select SampleSource from settings or default (file input)...";
|
qDebug() << "MainWindow::MainWindow: select SampleSource from settings or default (file input)...";
|
||||||
qDebug() << "MainWindow::MainWindow: look for"
|
qDebug() << "MainWindow::MainWindow: look for"
|
||||||
<< m_mainCore->m_settings.getSourceDeviceId()
|
<< m_mainCore->m_settings.getSourceDevice()
|
||||||
<< "at index" << m_mainCore->m_settings.getSourceIndex()
|
<< "at index" << m_mainCore->m_settings.getSourceIndex()
|
||||||
<< "and item index" << m_mainCore->m_settings.getSourceItemIndex();
|
<< "and item index" << m_mainCore->m_settings.getSourceItemIndex();
|
||||||
|
|
||||||
int deviceIndex = DeviceEnumerator::instance()->getRxSamplingDeviceIndex(
|
int deviceIndex = DeviceEnumerator::instance()->getRxSamplingDeviceIndex(
|
||||||
m_mainCore->m_settings.getSourceDeviceId(),
|
m_mainCore->m_settings.getSourceDevice(),
|
||||||
m_mainCore->m_settings.getSourceIndex(),
|
m_mainCore->m_settings.getSourceIndex(),
|
||||||
m_mainCore->m_settings.getSourceItemIndex());
|
m_mainCore->m_settings.getSourceItemIndex());
|
||||||
addSourceDevice(deviceIndex); // add the first device set with file input device as default if device in settings is not enumerated
|
addSourceDevice(deviceIndex); // add the first device set with file input device as default if device in settings is not enumerated
|
||||||
@ -2079,7 +2079,7 @@ void MainWindow::sampleSourceChanged(int tabIndex, int newDeviceIndex)
|
|||||||
qDebug("MainWindow::sampleSourceChanged: save default starting device %s[%d:%d]",
|
qDebug("MainWindow::sampleSourceChanged: save default starting device %s[%d:%d]",
|
||||||
qPrintable(samplingDevice->id), samplingDevice->sequence, samplingDevice->deviceItemIndex);
|
qPrintable(samplingDevice->id), samplingDevice->sequence, samplingDevice->deviceItemIndex);
|
||||||
m_mainCore->m_settings.setSourceIndex(samplingDevice->sequence);
|
m_mainCore->m_settings.setSourceIndex(samplingDevice->sequence);
|
||||||
m_mainCore->m_settings.setSourceDeviceId(samplingDevice->id);
|
m_mainCore->m_settings.setSourceDevice(samplingDevice->id);
|
||||||
m_mainCore->m_settings.setSourceItemIndex(samplingDevice->deviceItemIndex);
|
m_mainCore->m_settings.setSourceItemIndex(samplingDevice->deviceItemIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user