1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-14 04:11:48 -05:00
sdrangel/sdrbase/settings/mainsettings.h

276 lines
12 KiB
C
Raw Normal View History

///////////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
// Copyright (C) 2020, 2022-2023 Jon Beniston, M7RCE <jon@beniston.com> //
// //
// 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/>. //
///////////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_SETTINGS_H
#define INCLUDE_SETTINGS_H
#include <QObject>
#include <QString>
2019-06-12 12:50:53 -04:00
#include "device/deviceuserargs.h"
#include "preferences.h"
#include "preset.h"
2020-09-23 23:38:05 -04:00
#include "featuresetpreset.h"
2023-08-24 10:51:50 -04:00
#include "pluginpreset.h"
#include "configuration.h"
#include "export.h"
#include "plugin/pluginmanager.h"
2018-01-04 05:11:53 -05:00
class Command;
2019-07-20 17:25:00 -04:00
class AudioDeviceManager;
2018-01-04 05:11:53 -05:00
class SDRBASE_API MainSettings : public QObject {
Q_OBJECT
public:
MainSettings();
~MainSettings();
2020-09-23 23:38:05 -04:00
void load();
void save() const;
void resetToDefaults();
2019-08-06 02:48:14 -04:00
void initialize();
2019-01-17 05:22:38 -05:00
QString getFileLocation() const;
int getFileFormat() const; //!< see QSettings::Format for the values
const Preferences& getPreferences() const { return m_preferences; }
2019-08-06 02:48:14 -04:00
void setPreferences(const Preferences& preferences) { m_preferences = preferences; }
Preset* newPreset(const QString& group, const QString& description);
2019-08-06 02:48:14 -04:00
void addPreset(Preset *preset);
void deletePreset(const Preset* preset);
QByteArray serializePreset(const Preset* preset) const;
bool deserializePreset(const QByteArray& blob, Preset* preset);
int getPresetCount() const { return m_presets.count(); }
const Preset* getPreset(int index) const { return m_presets[index]; }
2019-05-08 19:12:40 -04:00
const Preset* getPreset(const QString& groupName, quint64 centerFrequency, const QString& description, const QString& type) const;
void sortPresets();
void renamePresetGroup(const QString& oldGroupName, const QString& newGroupName);
void deletePresetGroup(const QString& groupName);
2019-08-06 02:48:14 -04:00
void clearPresets();
2020-09-23 23:38:05 -04:00
const Preset& getWorkingPresetConst() const { return m_workingPreset; }
Preset* getWorkingPreset() { return &m_workingPreset; }
QList<Preset*> *getPresets() { return &m_presets; }
2018-01-04 05:11:53 -05:00
void addCommand(Command *command);
void deleteCommand(const Command* command);
int getCommandCount() const { return m_commands.count(); }
const Command* getCommand(int index) const { return m_commands[index]; }
const Command* getCommand(const QString& groupName, const QString& description) const;
void sortCommands();
void renameCommandGroup(const QString& oldGroupName, const QString& newGroupName);
void deleteCommandGroup(const QString& groupName);
2019-08-06 02:48:14 -04:00
void clearCommands();
2018-01-04 05:11:53 -05:00
2020-09-23 23:38:05 -04:00
FeatureSetPreset* newFeatureSetPreset(const QString& group, const QString& description);
void addFeatureSetPreset(FeatureSetPreset *preset);
void deleteFeatureSetPreset(const FeatureSetPreset* preset);
int getFeatureSetPresetCount() const { return m_featureSetPresets.count(); }
const FeatureSetPreset* getFeatureSetPreset(int index) const { return m_featureSetPresets[index]; }
const FeatureSetPreset* getFeatureSetPreset(const QString& groupName, const QString& description) const;
void sortFeatureSetPresets();
void renameFeatureSetPresetGroup(const QString& oldGroupName, const QString& newGroupName);
void deleteFeatureSetPresetGroup(const QString& groupName);
void clearFeatureSetPresets();
const FeatureSetPreset& getWorkingFeatureSetPresetConst() const { return m_workingFeatureSetPreset; }
FeatureSetPreset* getWorkingFeatureSetPreset() { return &m_workingFeatureSetPreset; }
QList<FeatureSetPreset*> *getFeatureSetPresets() { return &m_featureSetPresets; }
2023-08-24 10:51:50 -04:00
PluginPreset* newPluginPreset(const QString& group, const QString& description);
void addPluginPreset(PluginPreset *preset);
void deletePluginPreset(const PluginPreset* preset);
int getPluginPresetCount() const { return m_pluginPresets.count(); }
const PluginPreset* getPluginPreset(int index) const { return m_pluginPresets[index]; }
const PluginPreset* getPluginPreset(const QString& groupName, const QString& description) const;
void sortPluginPresets();
void renamePluginPresetGroup(const QString& oldGroupName, const QString& newGroupName);
void deletePluginPresetGroup(const QString& groupName);
void clearPluginPresets();
const PluginPreset& getWorkingPluginPresetConst() const { return m_workingPluginPreset; }
PluginPreset* getWorkingPluginPreset() { return &m_workingPluginPreset; }
QList<PluginPreset*> *getPluginPresets() { return &m_pluginPresets; }
Configuration* newConfiguration(const QString& group, const QString& description);
void addConfiguration(Configuration *configuration);
void deleteConfiguration(const Configuration *configuration);
QByteArray serializeConfiguration(const Configuration *configuration) const;
bool deserializeConfiguration(const QByteArray& blob, Configuration *configuration);
int getConfigurationCount() const { return m_configurations.size(); }
const Configuration* getConfiguration(int index) const { return m_configurations[index]; }
const Configuration* getConfiguration(const QString& groupName, const QString& description) const;
void sortConfigurations();
void renameConfigurationGroup(const QString& oldGroupName, const QString& newGroupName);
void deleteConfigurationGroup(const QString& groupName);
void clearConfigurations();
const Configuration& getWorkingConfigurationConst() const { return m_workingConfiguration; }
Configuration* getWorkingConfiguration() { return &m_workingConfiguration; }
QList<Configuration*> *getConfigurations() { return &m_configurations; }
const QString& getSourceDevice() const { return m_preferences.getSourceDevice(); }
void setSourceDevice(const QString& value)
{
m_preferences.setSourceDevice(value);
emit preferenceChanged(Preferences::SourceDevice);
}
int getSourceIndex() const { return m_preferences.getSourceIndex(); }
void setSourceIndex(int value)
{
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);
}
2016-09-28 07:38:38 -04:00
float getLatitude() const { return m_preferences.getLatitude(); }
void setLatitude(float latitude)
{
m_preferences.setLatitude(latitude);
emit preferenceChanged(Preferences::Latitude);
}
2016-09-28 07:38:38 -04:00
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);
}
2016-09-28 07:38:38 -04:00
bool getAutoUpdatePosition() const { return m_preferences.getAutoUpdatePosition(); }
void setAutoUpdatePosition(bool autoUpdatePosition)
{
m_preferences.setAutoUpdatePosition(autoUpdatePosition);
}
2017-11-11 20:23:55 -05:00
QtMsgType getConsoleMinLogLevel() const { return m_preferences.getConsoleMinLogLevel(); }
void setConsoleMinLogLevel(const QtMsgType& minLogLevel)
{
m_preferences.setConsoleMinLogLevel(minLogLevel);
emit preferenceChanged(Preferences::ConsoleMinLogLevel);
}
2017-11-11 20:23:55 -05:00
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(); }
void setUseLogFile(bool useLogFile)
{
m_preferences.setUseLogFile(useLogFile);
emit preferenceChanged(Preferences::UseLogFile);
}
const QString& getLogFileName() const { return m_preferences.getLogFileName(); }
void setLogFileName(const QString& value)
{
m_preferences.setLogFileName(value);
emit preferenceChanged(Preferences::LogFileName);
}
2019-06-12 12:50:53 -04:00
DeviceUserArgs& getDeviceUserArgs() { return m_hardwareDeviceUserArgs; }
const AudioDeviceManager *getAudioDeviceManager() const { return m_audioDeviceManager; }
void setAudioDeviceManager(AudioDeviceManager *audioDeviceManager) { m_audioDeviceManager = audioDeviceManager; }
2022-06-18 07:35:44 -04:00
int getMultisampling() const { return m_preferences.getMultisampling(); }
void setMultisampling(int samples)
{
m_preferences.setMultisampling(samples);
emit preferenceChanged(Preferences::Multisampling);
}
int getMapMultisampling() const { return m_preferences.getMapMultisampling(); }
void setMapMultisampling(int samples)
{
m_preferences.setMapMultisampling(samples);
emit preferenceChanged(Preferences::MapMultisampling);
}
bool getMapSmoothing() const { return m_preferences.getMapSmoothing(); }
void setMapSmoothing(bool smoothing)
{
m_preferences.setMapSmoothing(smoothing);
emit preferenceChanged(Preferences::MapSmoothing);
}
2023-08-13 18:52:57 -04:00
const QString& getFFTEngine() const { return m_preferences.getFFTEngine(); }
void setFFTEngine(const QString& fftEngine)
{
m_preferences.setFFTEngine(fftEngine);
emit preferenceChanged(Preferences::FFTEngine);
}
signals:
void preferenceChanged(int);
protected:
Preferences m_preferences;
AudioDeviceManager *m_audioDeviceManager;
Preset m_workingPreset;
typedef QList<Preset*> Presets;
Presets m_presets;
2018-01-04 05:11:53 -05:00
typedef QList<Command*> Commands;
Commands m_commands;
FeatureSetPreset m_workingFeatureSetPreset;
2020-09-23 23:38:05 -04:00
typedef QList<FeatureSetPreset*> FeatureSetPresets;
FeatureSetPresets m_featureSetPresets;
2023-08-24 10:51:50 -04:00
PluginPreset m_workingPluginPreset;
typedef QList<PluginPreset*> PluginPresets;
PluginPresets m_pluginPresets;
Configuration m_workingConfiguration;
typedef QList<Configuration*> Configurations;
Configurations m_configurations;
2019-06-12 12:50:53 -04:00
DeviceUserArgs m_hardwareDeviceUserArgs;
};
#endif // INCLUDE_SETTINGS_H