From 10191b45d59387470d1df284b1a50699437415e8 Mon Sep 17 00:00:00 2001 From: "Gonzalo J. Carracedo Carballal" Date: Mon, 16 Sep 2024 08:19:06 +0200 Subject: [PATCH] Add checkbox to disable connection quality warning --- App/AppConfig.cpp | 2 ++ UIMediator/SpectrumMediator.cpp | 15 ++++++++++++++- include/AppConfig.h | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/App/AppConfig.cpp b/App/AppConfig.cpp index 91e47d4..82e7e43 100644 --- a/App/AppConfig.cpp +++ b/App/AppConfig.cpp @@ -53,6 +53,7 @@ AppConfig::serialize(void) obj.set("fullScreen", this->fullScreen); obj.set("sidePanelRatio", this->sidePanelRatio); obj.set("disableHighRateWarning", this->disableHighRateWarning); + obj.set("disableConnectionQualityWarning", this->disableConnectionQualityWarning); obj.set("loFreq", this->loFreq); obj.set("bandwidth", this->bandwidth); obj.set("lastLoadedFile", this->lastLoadedFile); @@ -138,6 +139,7 @@ AppConfig::deserialize(Suscan::Object const &conf) TRYSILENT(this->fullScreen = conf.get("fullScreen", this->fullScreen)); TRYSILENT(this->sidePanelRatio = conf.get("sidePanelRatio", this->sidePanelRatio)); TRYSILENT(this->disableHighRateWarning = conf.get("disableHighRateWarning", this->disableHighRateWarning)); + TRYSILENT(this->disableConnectionQualityWarning = conf.get("disableConnectionQualityWarning", this->disableHighRateWarning)); TRYSILENT(this->loFreq = conf.get("loFreq", this->loFreq)); TRYSILENT(this->bandwidth = conf.get("bandwidth", this->bandwidth)); TRYSILENT(this->lastLoadedFile = conf.get("lastLoadedFile", this->lastLoadedFile)); diff --git a/UIMediator/SpectrumMediator.cpp b/UIMediator/SpectrumMediator.cpp index 77e28ce..6ea6acc 100644 --- a/UIMediator/SpectrumMediator.cpp +++ b/UIMediator/SpectrumMediator.cpp @@ -23,6 +23,7 @@ #include "MainSpectrum.h" #include #include +#include using namespace SigDigger; @@ -86,13 +87,25 @@ UIMediator::feedPSD(const Suscan::PSDMessage &msg) if ((m_psdDelta - interval) / interval > SIGDIGGER_UI_MEDIATOR_PSD_MAX_LAG) { if (m_laggedMsgBox == nullptr) { + QCheckBox *cb = new QCheckBox("Do not show again"); m_laggedMsgBox = new QMessageBox(m_owner); m_laggedMsgBox->setWindowTitle("Connection quality warning"); m_laggedMsgBox->setWindowModality(Qt::NonModal); m_laggedMsgBox->setIcon(QMessageBox::Icon::Warning); + m_laggedMsgBox->setCheckBox(cb); + + QObject::connect( + cb, + &QCheckBox::stateChanged, + [this](int state) { + if (static_cast(state) == Qt::CheckState::Checked) { + m_appConfig->disableConnectionQualityWarning = true; + } + }); } - if (m_laggedMsgBox->isHidden()) { + if (m_laggedMsgBox->isHidden() + && !m_appConfig->disableConnectionQualityWarning) { m_laggedMsgBox->setText( QString::asprintf( "The rate at which spectrum data is arriving is slower than " diff --git a/include/AppConfig.h b/include/AppConfig.h index 0efbae5..a1e30b7 100644 --- a/include/AppConfig.h +++ b/include/AppConfig.h @@ -69,7 +69,7 @@ namespace SigDigger { int y = -1; qreal sidePanelRatio = .16; bool disableHighRateWarning = false; - + bool disableConnectionQualityWarning = false; int loFreq = 0; unsigned int bandwidth = 0;