Entropy Piano Tuner  1.1.3 (documentation not yet complete)
An open-source experimental software for piano tuning by entropy minimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
donotshowagainmessagebox.cpp
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright 2015 Haye Hinrichsen, Christoph Wick
3  *
4  * This file is part of Entropy Piano Tuner.
5  *
6  * Entropy Piano Tuner is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * Entropy Piano Tuner is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * Entropy Piano Tuner. If not, see http://www.gnu.org/licenses/.
18  *****************************************************************************/
19 
21 #include <QCheckBox>
22 #include "settingsforqt.h"
23 #include "../core/system/eptexception.h"
24 
25 DoNotShowAgainMessageBox::DoNotShowAgainMessageBox(Type type, const QString &text, QWidget *parent) :
26  QMessageBox(parent),
27  mType(type)
28 {
29  setCheckBox(new QCheckBox(tr("Do not show again.")));
30 
31  // generate title and buttons
32  switch (type) {
33  case RESET_PITCHES:
34  setWindowTitle(tr("Clear pitch markers"));
35  setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
36  break;
38  setWindowTitle(tr("Not all keys recorded"));
39  setStandardButtons(QMessageBox::Ok);
40  break;
42  setWindowTitle(tr("Tuning curve not calculated"));
43  setStandardButtons(QMessageBox::Ok);
44  break;
46  setWindowTitle(tr("Tuning curve must be recalculated"));
47  setStandardButtons(QMessageBox::Ok);
48  break;
49  default:
50  setWindowTitle(tr("Question"));
51  setStandardButtons(QMessageBox::Ok);
52  break;
53  }
54 
55  if (text.isEmpty()) {
56  switch (type) {
57  case RESET_PITCHES:
58  setText(tr("Do you really want to clear all pitch markers? This can not be undone!"));
59  break;
61  setText(tr("Not all keys have been recorded. Switch the mode and record them."));
62  break;
64  setText(tr("The tuning curve has not been calculated. Switch the mode and calculate it."));
65  break;
67  setText(tr("There are missing frequencies in the calculated tuning curve. Recalculate to fix this."));
68  break;
69  default:
70  EPT_EXCEPT(EptException::ERR_NOT_IMPLEMENTED, "DoNotShowAgainMessageBoxTypeNotImplemented");
71  }
72  } else {
73  setText(text);
74  }
75 }
76 
78 {
79 
80 }
81 
82 
83 int DoNotShowAgainMessageBox::show(Type type, const QString text, QWidget *parent) {
84  if (doNotShowAgain(type)) {
85  // do not show again, accept
86  return QMessageBox::Accepted;
87  }
88 
89  DoNotShowAgainMessageBox b(type, text, parent);
90 
91  int r(b.exec());
92  if (r == QMessageBox::Rejected || r == QMessageBox::Cancel) {
93  return r;
94  }
95  if (b.checkBox()->isChecked()) {
96  // store state
98  }
99  return QMessageBox::Accepted;
100 }
101 
104 }
A MessageBox with a QCheckBox to remember the decision of the user.
void setDoNotShowAgainMessageBox(int id, bool doNotShowAgain)
Sets a AutoClosingMessageBox state whether to show again.
DoNotShowAgainMessageBox(Type type, const QString &text, QWidget *parent)
Private constructor.
#define EPT_EXCEPT(num, desc)
Definition: eptexception.h:119
bool doNotShowAgainMessageBox(int id) const
Getter function to check if the given AutoClosingMessageBox shall not be shown again.
static int show(Type type, const QString text, QWidget *parent=nullptr)
Show a message box if the user didnt check the QCheckBox.
static bool doNotShowAgain(Type type)
static SettingsForQt & getSingleton()
Getter function for the singleton.
Type
The type and unique id for the message box.