diff --git a/Software/PC_Application/CustomWidgets/informationbox.cpp b/Software/PC_Application/CustomWidgets/informationbox.cpp index 71af4a3..5357b29 100644 --- a/Software/PC_Application/CustomWidgets/informationbox.cpp +++ b/Software/PC_Application/CustomWidgets/informationbox.cpp @@ -3,7 +3,7 @@ #include #include -void InformationBox::ShowMessage(QString title, QString message, QString messageID) +void InformationBox::ShowMessage(QString title, QString message, QString messageID, bool block) { // check if the user still wants to see this message unsigned int hash; @@ -16,10 +16,19 @@ void InformationBox::ShowMessage(QString title, QString message, QString message QSettings s; if(!s.contains(hashToSettingsKey(hash))) { auto box = new InformationBox(title, message, QMessageBox::Information, hash, nullptr); - box->show(); + if(block) { + box->exec(); + } else { + box->show(); + } } } +void InformationBox::ShowMessageBlocking(QString title, QString message, QString messageID) +{ + ShowMessage(title, message, messageID, true); +} + void InformationBox::ShowError(QString title, QString message) { auto box = new InformationBox(title, message, QMessageBox::Information, 0, nullptr); diff --git a/Software/PC_Application/CustomWidgets/informationbox.h b/Software/PC_Application/CustomWidgets/informationbox.h index 1352f99..d1e5494 100644 --- a/Software/PC_Application/CustomWidgets/informationbox.h +++ b/Software/PC_Application/CustomWidgets/informationbox.h @@ -7,7 +7,8 @@ class InformationBox : public QMessageBox { Q_OBJECT public: - static void ShowMessage(QString title, QString message, QString messageID = QString()); + static void ShowMessage(QString title, QString message, QString messageID = QString(), bool block = false); + static void ShowMessageBlocking(QString title, QString message, QString messageID = QString()); static void ShowError(QString title, QString message); // Display a dialog with yes/no buttons. Returns true if yes is clicked, false otherwise. If the user has selected to never see this message again, defaultAnswer is returned instead static bool AskQuestion(QString title, QString question, bool defaultAnswer, QString messageID = QString()); diff --git a/Software/PC_Application/Traces/tracexyplot.cpp b/Software/PC_Application/Traces/tracexyplot.cpp index dabe146..0668fc2 100644 --- a/Software/PC_Application/Traces/tracexyplot.cpp +++ b/Software/PC_Application/Traces/tracexyplot.cpp @@ -964,16 +964,22 @@ void TraceXYPlot::traceDropped(Trace *t, QPoint position) { if(t->outputType() == Trace::DataType::Frequency && XAxis.type != XAxisType::Frequency) { // needs to switch to frequency domain graph - InformationBox::ShowMessage("X Axis Domain Change", "You dropped a frequency domain trace but the graph is still set up for the time domain." - " All current traces will be removed and the graph changed to frequency domain."); + if(!InformationBox::AskQuestion("X Axis Domain Change", "You dropped a frequency domain trace but the graph is still set up for the time domain." + " Do you want to remove all traces and change the graph to frequency domain?", true, "DomainChangeRequest")) { + // user declined to change domain, to not add trace + return; + } setXAxis(XAxisType::Frequency, XAxisMode::FitTraces, 0, 1, 0.1); setYAxis(0, YAxisType::Magnitude, false, true, 0, 1, 1.0); setYAxis(1, YAxisType::Phase, false, true, 0, 1, 1.0); } if(t->outputType() != Trace::DataType::Frequency && XAxis.type == XAxisType::Frequency) { // needs to switch to time domain graph - InformationBox::ShowMessage("X Axis Domain Change", "You dropped a time domain trace but the graph is still set up for the frequency domain." - " All current traces will be removed and the graph changed to time domain."); + if(!InformationBox::AskQuestion("X Axis Domain Change", "You dropped a time domain trace but the graph is still set up for the frequency domain." + " Do you want to remove all traces and change the graph to time domain?", true, "DomainChangeRequest")) { + // user declined to change domain, to not add trace + return; + } setXAxis(XAxisType::Time, XAxisMode::FitTraces, 0, 1, 0.1); setYAxis(0, YAxisType::ImpulseMag, false, true, 0, 1, 1.0); setYAxis(1, YAxisType::Disabled, false, true, 0, 1, 1.0); diff --git a/Software/PC_Application/VNA/Deembedding/twothru.cpp b/Software/PC_Application/VNA/Deembedding/twothru.cpp index caef40a..63fd06b 100644 --- a/Software/PC_Application/VNA/Deembedding/twothru.cpp +++ b/Software/PC_Application/VNA/Deembedding/twothru.cpp @@ -400,14 +400,14 @@ std::vector TwoThru::calculateErrorBoxes(std::vector ret; if(data_2xthru.size() != data_fix_dut_fix.size()) { - InformationBox::ShowMessage("Unable to calculate", "The DUT and 2xthru measurements do not have the same amount of points, calculation not possible"); + InformationBox::ShowMessageBlocking("Unable to calculate", "The DUT and 2xthru measurements do not have the same amount of points, calculation not possible"); return ret; } // check if frequencies are the same (measurements must be taken with identical span settings) for(unsigned int i=0;i (double) data_2xthru[i].frequency / 1e9) { - InformationBox::ShowMessage("Unable to calculate", "The DUT and 2xthru measurements do not have identical frequencies for all points, calculation not possible"); + InformationBox::ShowMessageBlocking("Unable to calculate", "The DUT and 2xthru measurements do not have identical frequencies for all points, calculation not possible"); return ret; } } diff --git a/Software/PC_Application/VNA/vna.cpp b/Software/PC_Application/VNA/vna.cpp index 26b74dc..753d5b8 100644 --- a/Software/PC_Application/VNA/vna.cpp +++ b/Software/PC_Application/VNA/vna.cpp @@ -838,7 +838,7 @@ void VNA::ApplyCalibration(Calibration::Type type) } } else { // Not all required traces available - InformationBox::ShowMessage("Missing calibration measurements", "Not all calibration measurements for this type of calibration have been taken. The calibration can be enabled after the missing measurements have been acquired."); + InformationBox::ShowMessageBlocking("Missing calibration measurements", "Not all calibration measurements for this type of calibration have been taken. The calibration can be enabled after the missing measurements have been acquired."); DisableCalibration(true); StartCalibrationDialog(type); } @@ -1093,7 +1093,7 @@ void VNA::StartCalibrationDialog(Calibration::Type type) connect(this, &VNA::CalibrationMeasurementComplete, traceDialog, &CalibrationTraceDialog::measurementComplete); connect(traceDialog, &CalibrationTraceDialog::calibrationInvalidated, [=](){ DisableCalibration(true); - InformationBox::ShowMessage("Calibration disabled", "The currently active calibration is no longer supported by the available measurements and was disabled."); + InformationBox::ShowMessageBlocking("Calibration disabled", "The currently active calibration is no longer supported by the available measurements and was disabled."); }); traceDialog->show(); }