Fixed needless config saves

This commit is contained in:
AlexandreRouma 2023-01-13 22:43:42 +01:00
parent a53dc1a6ae
commit bad8ecba49
2 changed files with 15 additions and 10 deletions

View File

@ -548,22 +548,27 @@ void MainWindow::draw() {
if (!lockWaterfallControls) { if (!lockWaterfallControls) {
// Handle arrow keys // Handle arrow keys
if (vfo != NULL && (gui::waterfall.mouseInFFT || gui::waterfall.mouseInWaterfall)) { if (vfo != NULL && (gui::waterfall.mouseInFFT || gui::waterfall.mouseInWaterfall)) {
bool freqChanged = false;
if (ImGui::IsKeyPressed(ImGuiKey_LeftArrow) && !gui::freqSelect.digitHovered) { if (ImGui::IsKeyPressed(ImGuiKey_LeftArrow) && !gui::freqSelect.digitHovered) {
double nfreq = gui::waterfall.getCenterFrequency() + vfo->generalOffset - vfo->snapInterval; double nfreq = gui::waterfall.getCenterFrequency() + vfo->generalOffset - vfo->snapInterval;
nfreq = roundl(nfreq / vfo->snapInterval) * vfo->snapInterval; nfreq = roundl(nfreq / vfo->snapInterval) * vfo->snapInterval;
tuner::tune(tuningMode, gui::waterfall.selectedVFO, nfreq); tuner::tune(tuningMode, gui::waterfall.selectedVFO, nfreq);
freqChanged = true;
} }
if (ImGui::IsKeyPressed(ImGuiKey_RightArrow) && !gui::freqSelect.digitHovered) { if (ImGui::IsKeyPressed(ImGuiKey_RightArrow) && !gui::freqSelect.digitHovered) {
double nfreq = gui::waterfall.getCenterFrequency() + vfo->generalOffset + vfo->snapInterval; double nfreq = gui::waterfall.getCenterFrequency() + vfo->generalOffset + vfo->snapInterval;
nfreq = roundl(nfreq / vfo->snapInterval) * vfo->snapInterval; nfreq = roundl(nfreq / vfo->snapInterval) * vfo->snapInterval;
tuner::tune(tuningMode, gui::waterfall.selectedVFO, nfreq); tuner::tune(tuningMode, gui::waterfall.selectedVFO, nfreq);
freqChanged = true;
} }
core::configManager.acquire(); if (freqChanged) {
core::configManager.conf["frequency"] = gui::waterfall.getCenterFrequency(); core::configManager.acquire();
if (vfo != NULL) { core::configManager.conf["frequency"] = gui::waterfall.getCenterFrequency();
core::configManager.conf["vfoOffsets"][gui::waterfall.selectedVFO] = vfo->generalOffset; if (vfo != NULL) {
core::configManager.conf["vfoOffsets"][gui::waterfall.selectedVFO] = vfo->generalOffset;
}
core::configManager.release(true);
} }
core::configManager.release(true);
} }
// Handle scrollwheel // Handle scrollwheel

View File

@ -145,11 +145,11 @@ private:
std::lock_guard lck(_this->vfoMtx); std::lock_guard lck(_this->vfoMtx);
if (ImGui::Combo(CONCAT("##_rigctl_srv_rec_", _this->name), &_this->recorderId, _this->recorderNamesTxt.c_str())) { if (ImGui::Combo(CONCAT("##_rigctl_srv_rec_", _this->name), &_this->recorderId, _this->recorderNamesTxt.c_str())) {
_this->selectRecorderByName(_this->recorderNames[_this->recorderId], false); _this->selectRecorderByName(_this->recorderNames[_this->recorderId], false);
} if (!_this->selectedRecorder.empty()) {
if (!_this->selectedRecorder.empty()) { config.acquire();
config.acquire(); config.conf[_this->name]["recorder"] = _this->selectedRecorder;
config.conf[_this->name]["recorder"] = _this->selectedRecorder; config.release(true);
config.release(true); }
} }
} }