Fix visibility of information boxes in certain situations by introducing a blocking option
This commit is contained in:
parent
7d84e0fc68
commit
0efd31e8ce
@ -3,7 +3,7 @@
|
|||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
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
|
// check if the user still wants to see this message
|
||||||
unsigned int hash;
|
unsigned int hash;
|
||||||
@ -16,10 +16,19 @@ void InformationBox::ShowMessage(QString title, QString message, QString message
|
|||||||
QSettings s;
|
QSettings s;
|
||||||
if(!s.contains(hashToSettingsKey(hash))) {
|
if(!s.contains(hashToSettingsKey(hash))) {
|
||||||
auto box = new InformationBox(title, message, QMessageBox::Information, hash, nullptr);
|
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)
|
void InformationBox::ShowError(QString title, QString message)
|
||||||
{
|
{
|
||||||
auto box = new InformationBox(title, message, QMessageBox::Information, 0, nullptr);
|
auto box = new InformationBox(title, message, QMessageBox::Information, 0, nullptr);
|
||||||
|
@ -7,7 +7,8 @@ class InformationBox : public QMessageBox
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
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);
|
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
|
// 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());
|
static bool AskQuestion(QString title, QString question, bool defaultAnswer, QString messageID = QString());
|
||||||
|
@ -964,16 +964,22 @@ void TraceXYPlot::traceDropped(Trace *t, QPoint position)
|
|||||||
{
|
{
|
||||||
if(t->outputType() == Trace::DataType::Frequency && XAxis.type != XAxisType::Frequency) {
|
if(t->outputType() == Trace::DataType::Frequency && XAxis.type != XAxisType::Frequency) {
|
||||||
// needs to switch to frequency domain graph
|
// 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."
|
if(!InformationBox::AskQuestion("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.");
|
" 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);
|
setXAxis(XAxisType::Frequency, XAxisMode::FitTraces, 0, 1, 0.1);
|
||||||
setYAxis(0, YAxisType::Magnitude, false, true, 0, 1, 1.0);
|
setYAxis(0, YAxisType::Magnitude, false, true, 0, 1, 1.0);
|
||||||
setYAxis(1, YAxisType::Phase, 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) {
|
if(t->outputType() != Trace::DataType::Frequency && XAxis.type == XAxisType::Frequency) {
|
||||||
// needs to switch to time domain graph
|
// 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."
|
if(!InformationBox::AskQuestion("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.");
|
" 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);
|
setXAxis(XAxisType::Time, XAxisMode::FitTraces, 0, 1, 0.1);
|
||||||
setYAxis(0, YAxisType::ImpulseMag, false, true, 0, 1, 1.0);
|
setYAxis(0, YAxisType::ImpulseMag, false, true, 0, 1, 1.0);
|
||||||
setYAxis(1, YAxisType::Disabled, false, true, 0, 1, 1.0);
|
setYAxis(1, YAxisType::Disabled, false, true, 0, 1, 1.0);
|
||||||
|
@ -400,14 +400,14 @@ std::vector<TwoThru::Point> TwoThru::calculateErrorBoxes(std::vector<Protocol::D
|
|||||||
vector<Point> ret;
|
vector<Point> ret;
|
||||||
|
|
||||||
if(data_2xthru.size() != data_fix_dut_fix.size()) {
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if frequencies are the same (measurements must be taken with identical span settings)
|
// check if frequencies are the same (measurements must be taken with identical span settings)
|
||||||
for(unsigned int i=0;i<data_2xthru.size();i++) {
|
for(unsigned int i=0;i<data_2xthru.size();i++) {
|
||||||
if(abs((long int)data_2xthru[i].frequency - (long int)data_fix_dut_fix[i].frequency) > (double) data_2xthru[i].frequency / 1e9) {
|
if(abs((long int)data_2xthru[i].frequency - (long int)data_fix_dut_fix[i].frequency) > (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;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -838,7 +838,7 @@ void VNA::ApplyCalibration(Calibration::Type type)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Not all required traces available
|
// 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);
|
DisableCalibration(true);
|
||||||
StartCalibrationDialog(type);
|
StartCalibrationDialog(type);
|
||||||
}
|
}
|
||||||
@ -1093,7 +1093,7 @@ void VNA::StartCalibrationDialog(Calibration::Type type)
|
|||||||
connect(this, &VNA::CalibrationMeasurementComplete, traceDialog, &CalibrationTraceDialog::measurementComplete);
|
connect(this, &VNA::CalibrationMeasurementComplete, traceDialog, &CalibrationTraceDialog::measurementComplete);
|
||||||
connect(traceDialog, &CalibrationTraceDialog::calibrationInvalidated, [=](){
|
connect(traceDialog, &CalibrationTraceDialog::calibrationInvalidated, [=](){
|
||||||
DisableCalibration(true);
|
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();
|
traceDialog->show();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user