SCPI commands for saving/loading calibration files

This commit is contained in:
Jan Käberich 2021-10-12 21:58:44 +02:00
parent e4106fe3a2
commit 09366d73cc
15 changed files with 110 additions and 36 deletions

View file

@ -3,8 +3,15 @@
#include <QSettings>
#include <QDebug>
bool InformationBox::has_gui = true;
void InformationBox::ShowMessage(QString title, QString message, QString messageID, bool block)
{
if(!has_gui) {
// no gui option active, do not show any messages
return;
}
// check if the user still wants to see this message
unsigned int hash;
if(messageID.isEmpty()) {
@ -31,12 +38,21 @@ void InformationBox::ShowMessageBlocking(QString title, QString message, QString
void InformationBox::ShowError(QString title, QString message)
{
if(!has_gui) {
// no gui option active, do not show any messages
return;
}
auto box = new InformationBox(title, message, QMessageBox::Information, 0, nullptr);
box->show();
}
bool InformationBox::AskQuestion(QString title, QString question, bool defaultAnswer, QString messageID)
{
if(!has_gui) {
// no gui option active, do not show any messages
return defaultAnswer;
}
// check if the user still wants to see this message
unsigned int hash;
if(messageID.isEmpty()) {
@ -61,6 +77,11 @@ bool InformationBox::AskQuestion(QString title, QString question, bool defaultAn
}
}
void InformationBox::setGUI(bool enable)
{
has_gui = enable;
}
InformationBox::InformationBox(QString title, QString message, Icon icon, unsigned int hash, QWidget *parent)
: QMessageBox(parent),
hash(hash)

View file

@ -12,11 +12,14 @@ public:
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());
static void setGUI(bool enable);
private:
InformationBox(QString title, QString message, QMessageBox::Icon icon, unsigned int hash, QWidget *parent);
~InformationBox();
static QString hashToSettingsKey(unsigned int hash);
unsigned int hash;
static bool has_gui;
};
#endif // INFORMATIONBOX_H