Vidalia  0.2.21
VMessageBox.h
Go to the documentation of this file.
1 /*
2 ** This file is part of Vidalia, and is subject to the license terms in the
3 ** LICENSE file, found in the top level directory of this distribution. If you
4 ** did not receive the LICENSE file with this file, you may obtain it from the
5 ** Vidalia source package distributed by the Vidalia Project at
6 ** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7 ** including this file, may be copied, modified, propagated, or distributed
8 ** except according to the terms described in the LICENSE file.
9 */
10 
11 /*
12 ** \file VMessageBox.h
13 ** \brief Provides a custom Vidalia mesage box
14 */
15 
16 #ifndef _VMESSAGEBOX_H
17 #define _VMESSAGEBOX_H
18 
19 #include <QMessageBox>
20 #include <QString>
21 
22 
23 class VMessageBox : public QMessageBox
24 {
25  Q_OBJECT
26 
27 public:
28  enum Button {
29  NoButton = 0,
30  Ok,
32  Yes,
33  No,
41  };
42 
43  /** Default constructor. */
44  VMessageBox(QWidget *parent = 0);
45 
46  /** Displays an critical message box with the given caption, message text,
47  * and visible buttons. To specify a button as a default button or an escape
48  * button, OR the Button enum value with QMessageBox::Default or
49  * QMessageBox::Escape, respectively. */
50  static int critical(QWidget *parent, QString caption, QString text,
51  int button0, int button1 = NoButton,
52  int button2 = NoButton);
53 
54  /** Displays an information message box with the given caption, message text,
55  * and visible buttons. To specify a button as a default button or an escape
56  * button, OR the Button enum value with QMessageBox::Default or
57  * QMessageBox::Escape, respectively. */
58  static int information(QWidget *parent, QString caption, QString text,
59  int button0, int button1 = NoButton,
60  int button2 = NoButton);
61 
62  /** Displays a warning message box with the given caption, message text, and
63  * visible buttons. To specify as a default button or an escape
64  * button, OR the Button enum value with QMessageBox::Default or
65  * QMessageBox::Escape, respectively. */
66  static int warning(QWidget *parent, QString caption, QString text,
67  int button0, int button1 = NoButton,
68  int button2 = NoButton);
69 
70  /** Displays a warning message box with the given caption, message text, and
71  * visible buttons. To specify as a default button or an escape
72  * button, OR the Button enum value with QMessageBox::Default or
73  * QMessageBox::Escape, respectively. */
74  static int question(QWidget *parent, QString caption, QString text,
75  int button0, int button1 = NoButton,
76  int button2 = NoButton);
77 
78  /** Converts a Button enum value to a translated string. */
79  static QString buttonText(int button);
80 
81 private:
82  /** Returns the button (0, 1, or 2) that is OR-ed with QMessageBox::Default,
83  * or 0 if none are. */
84  static int defaultButton(int button0, int button1, int button2);
85  /** Returns the button (0, 1, or 2) that is OR-ed with QMessageBox::Escape,
86  * or -1 if none are. */
87  static int escapeButton(int button0, int button1, int button2);
88  /** Returns the Button enum value from the given return value. */
89  static int selected(int ret, int button0, int button1, int button2);
90 };
91 
92 #endif
93