mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2024-12-24 18:08:27 +01:00
The enabled state of all modules is now preserved
This commit is contained in:
parent
fd9f4ebdc3
commit
73bbd69e3f
@ -158,17 +158,28 @@ int sdrpp_main(int argc, char *argv[]) {
|
||||
defConfig["min"] = -120.0;
|
||||
|
||||
// Module instances
|
||||
defConfig["moduleInstances"]["Airspy Source"] = "airspy_source";
|
||||
defConfig["moduleInstances"]["AirspyHF+ Source"] = "airspyhf_source";
|
||||
defConfig["moduleInstances"]["BladeRF Source"] = "bladerf_source";
|
||||
defConfig["moduleInstances"]["File Source"] = "file_source";
|
||||
defConfig["moduleInstances"]["HackRF Source"] = "hackrf_source";
|
||||
defConfig["moduleInstances"]["LimeSDR Source"] = "limesdr_source";
|
||||
defConfig["moduleInstances"]["RTL-SDR Source"] = "rtl_sdr_source";
|
||||
defConfig["moduleInstances"]["RTL-TCP Source"] = "rtl_tcp_source";
|
||||
defConfig["moduleInstances"]["SDRplay Source"] = "sdrplay_source";
|
||||
defConfig["moduleInstances"]["SoapySDR Source"] = "soapy_source";
|
||||
defConfig["moduleInstances"]["PlutoSDR Source"] = "plutosdr_source";
|
||||
defConfig["moduleInstances"]["Airspy Source"]["module"] = "airspy_source";
|
||||
defConfig["moduleInstances"]["Airspy Source"]["enabled"] = true;
|
||||
defConfig["moduleInstances"]["AirspyHF+ Source"]["module"] = "airspyhf_source";
|
||||
defConfig["moduleInstances"]["AirspyHF+ Source"]["enabled"] = true;
|
||||
defConfig["moduleInstances"]["BladeRF Source"]["module"] = "bladerf_source";
|
||||
defConfig["moduleInstances"]["BladeRF Source"]["enabled"] = true;
|
||||
defConfig["moduleInstances"]["File Source"]["module"] = "file_source";
|
||||
defConfig["moduleInstances"]["File Source"]["enabled"] = true;
|
||||
defConfig["moduleInstances"]["HackRF Source"]["module"] = "hackrf_source";
|
||||
defConfig["moduleInstances"]["HackRF Source"]["enabled"] = true;
|
||||
defConfig["moduleInstances"]["LimeSDR Source"]["module"] = "limesdr_source";
|
||||
defConfig["moduleInstances"]["LimeSDR Source"]["enabled"] = true;
|
||||
defConfig["moduleInstances"]["RTL-SDR Source"]["module"] = "rtl_sdr_source";
|
||||
defConfig["moduleInstances"]["RTL-SDR Source"]["enabled"] = true;
|
||||
defConfig["moduleInstances"]["RTL-TCP Source"]["module"] = "rtl_tcp_source";
|
||||
defConfig["moduleInstances"]["RTL-TCP Source"]["enabled"] = true;
|
||||
defConfig["moduleInstances"]["SDRplay Source"]["module"] = "sdrplay_source";
|
||||
defConfig["moduleInstances"]["SDRplay Source"]["enabled"] = true;
|
||||
defConfig["moduleInstances"]["SoapySDR Source"]["module"] = "soapy_source";
|
||||
defConfig["moduleInstances"]["SoapySDR Source"]["enabled"] = true;
|
||||
defConfig["moduleInstances"]["PlutoSDR Source"]["module"] = "plutosdr_source";
|
||||
defConfig["moduleInstances"]["PlutoSDR Source"]["enabled"] = true;
|
||||
|
||||
defConfig["moduleInstances"]["Audio Sink"] = "audio_sink";
|
||||
|
||||
@ -232,6 +243,16 @@ int sdrpp_main(int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
// Update to new module representation in config if needed
|
||||
for (auto [_name, inst] : core::configManager.conf["moduleInstances"].items()) {
|
||||
if (!inst.is_string()) { continue; }
|
||||
std::string mod = inst;
|
||||
json newMod;
|
||||
newMod["module"] = mod;
|
||||
newMod["enabled"] = true;
|
||||
core::configManager.conf["moduleInstances"][_name] = newMod;
|
||||
}
|
||||
|
||||
core::configManager.release(true);
|
||||
|
||||
// Setup window
|
||||
|
@ -111,7 +111,7 @@ void MainWindow::init() {
|
||||
// Read module config
|
||||
core::configManager.acquire();
|
||||
std::vector<std::string> modules = core::configManager.conf["modules"];
|
||||
std::map<std::string, std::string> modList = core::configManager.conf["moduleInstances"];
|
||||
auto modList = core::configManager.conf["moduleInstances"].items();
|
||||
core::configManager.release();
|
||||
|
||||
// Load additional modules specified through config
|
||||
@ -122,10 +122,13 @@ void MainWindow::init() {
|
||||
}
|
||||
|
||||
// Create module instances
|
||||
for (auto const& [name, module] : modList) {
|
||||
spdlog::info("Initializing {0} ({1})", name, module);
|
||||
LoadingScreen::show("Initializing " + name + " (" + module + ")");
|
||||
core::moduleManager.createInstance(name, module);
|
||||
for (auto const& [name, _module] : modList) {
|
||||
std::string mod = _module["module"];
|
||||
bool enabled = _module["enabled"];
|
||||
spdlog::info("Initializing {0} ({1})", name, mod);
|
||||
LoadingScreen::show("Initializing " + name + " (" + mod + ")");
|
||||
core::moduleManager.createInstance(name, mod);
|
||||
if (!enabled) { core::moduleManager.disableInstance(name); }
|
||||
}
|
||||
|
||||
// Load color maps
|
||||
@ -446,6 +449,12 @@ void MainWindow::draw() {
|
||||
arr[i]["open"] = gui::menu.order[i].open;
|
||||
}
|
||||
core::configManager.conf["menuElements"] = arr;
|
||||
|
||||
// Update enabled and disabled modules
|
||||
for (auto [_name, inst] : core::moduleManager.instances) {
|
||||
core::configManager.conf["moduleInstances"][_name]["enabled"] = inst.instance->isEnabled();
|
||||
}
|
||||
|
||||
core::configManager.release(true);
|
||||
}
|
||||
if (startedWithMenuClosed) {
|
||||
|
@ -106,6 +106,7 @@ bool Menu::draw(bool updateStates) {
|
||||
bool enabled = item.inst->isEnabled();
|
||||
if (ImGui::Checkbox(("##_menu_checkbox_" + opt.name).c_str(), &enabled)) {
|
||||
enabled ? item.inst->enable() : item.inst->disable();
|
||||
changed = true;
|
||||
}
|
||||
ImGui::SetCursorPos(pos);
|
||||
}
|
||||
@ -127,6 +128,7 @@ bool Menu::draw(bool updateStates) {
|
||||
bool enabled = item.inst->isEnabled();
|
||||
if (ImGui::Checkbox(("##_menu_checkbox_" + opt.name).c_str(), &enabled)) {
|
||||
enabled ? item.inst->enable() : item.inst->disable();
|
||||
changed = true;
|
||||
}
|
||||
ImGui::SetCursorPos(pos);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user