]> vaikene.ee Git - evaf/blob - src/main/GUI/fatalerr.h
Warning fixes and copyright update.
[evaf] / src / main / GUI / fatalerr.h
1 /**
2 * @file main/GUI/fatalerr.h
3 * @brief Fatal error message dialog box
4 * @author Enar Vaikene
5 *
6 * Copyright (c) 2011-2019 Enar Vaikene
7 *
8 * This file is part of the eVaf C++ cross-platform application development framework.
9 *
10 * This file can be used under the terms of the GNU General Public License
11 * version 3.0 as published by the Free Software Foundation and appearing in
12 * the file LICENSE included in the packaging of this file. Please review the
13 * the following information to ensure the GNU General Public License version
14 * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
15 *
16 * Alternatively, this file may be used in accordance with the Commercial License
17 * Agreement provided with the Software.
18 */
19
20 #ifndef __GUI_FATALERR_H
21 # define __GUI_FATALERR_H
22
23 #include <QDialog>
24
25 class QTimerEvent;
26
27 namespace eVaf {
28 namespace GUI {
29 namespace Internal {
30
31 /**
32 * Fatal error message dialog box
33 *
34 * The fatal error message dialog box shows a fatal error message and starts a count-down
35 * to close the dialog box and abort the application. Users can click on the Ignore button
36 * to keep the application running for diagnostics.
37 */
38 class FatalErr : public QDialog
39 {
40 Q_OBJECT
41
42 public:
43
44 /// Returns values
45 enum Result {
46 Abort = 0, ///< User clicked on the Abort button or the dialog box timed out
47 Ignore = 1 ///< User clicked on the Ignore button
48 };
49
50 /**
51 * Creates the fatal error message dialog box
52 * @param title Title of the dialog box
53 * @param text Text shown on the dialog box
54 * @param parent Optional parent widget
55 */
56 FatalErr(QString const & title, QString const & text, QWidget * parent = nullptr);
57
58 /**
59 * Shows a fatal error message dialog box
60 * @param title Title of the dialog box
61 * @param text Text shown on the dialog box
62 * @param parent Optional parent widget
63 * @return The result code
64 */
65 static int message(QString const & title, QString const & text, QWidget * parent = nullptr);
66
67
68 protected:
69
70 /// Timer event handler
71 virtual void timerEvent(QTimerEvent *);
72
73
74 private slots:
75
76 /// Ignore button clicked
77 void ignoreClicked();
78
79 /// Abort button clicked
80 void abortClicked();
81
82
83 private:
84
85 /// Count-down time in secons
86 static int const Timer = 60;
87
88 /// Count-down timer
89 int mTimer;
90
91 /// The Abort button
92 QPushButton * wAbort;
93
94 };
95
96 } // namespace eVaf::GUI::Internal
97 } // namespace eVaf::GUI
98 } // namespace eVaf
99
100 #endif // fatalerr.h