mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-06 06:53:37 +00:00
Ask to save calibration when closing the app
This commit is contained in:
parent
15c7492bec
commit
753dd3d261
7 changed files with 53 additions and 4 deletions
|
|
@ -20,6 +20,32 @@ void InformationBox::ShowMessage(QString title, QString message, QString message
|
|||
}
|
||||
}
|
||||
|
||||
bool InformationBox::AskQuestion(QString title, QString question, bool defaultAnswer, QString messageID)
|
||||
{
|
||||
// check if the user still wants to see this message
|
||||
unsigned int hash;
|
||||
if(messageID.isEmpty()) {
|
||||
hash = qHash(question);
|
||||
} else {
|
||||
hash = qHash(messageID);
|
||||
}
|
||||
|
||||
QSettings s;
|
||||
if(!s.contains(hashToSettingsKey(hash))) {
|
||||
auto box = new InformationBox(title, question, hash, nullptr);
|
||||
box->setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
int ret = box->exec();
|
||||
if(ret == QMessageBox::Yes) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// don't show this question anymore
|
||||
return defaultAnswer;
|
||||
}
|
||||
}
|
||||
|
||||
InformationBox::InformationBox(QString title, QString message, unsigned int hash, QWidget *parent)
|
||||
: QMessageBox(parent),
|
||||
hash(hash)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ class InformationBox : public QMessageBox
|
|||
Q_OBJECT
|
||||
public:
|
||||
static void ShowMessage(QString title, QString message, QString messageID = QString());
|
||||
// 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());
|
||||
private:
|
||||
InformationBox(QString title, QString message, unsigned int hash, QWidget *parent);
|
||||
~InformationBox();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue