Vidalia  0.3.1
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 #include "VSettings.h"
23 
24 class QCheckBox;
25 
26 class VMessageBox : public QMessageBox
27 {
28  Q_OBJECT
29 
30 public:
31  enum Button {
32  NoButton = 0,
33  Ok,
35  Yes,
36  No,
44  };
45 
46  /** Default constructor. */
47  VMessageBox(QWidget *parent = 0);
48 
49  /** Displays an critical message box with the given caption, message text,
50  * and visible buttons. To specify a button as a default button or an escape
51  * button, OR the Button enum value with QMessageBox::Default or
52  * QMessageBox::Escape, respectively. */
53  static int critical(QWidget *parent, QString caption, QString text,
54  int button0, int button1 = NoButton,
55  int button2 = NoButton);
56 
57  /** Displays an information message box with the given caption, message text,
58  * and visible buttons. To specify a button as a default button or an escape
59  * button, OR the Button enum value with QMessageBox::Default or
60  * QMessageBox::Escape, respectively. */
61  static int information(QWidget *parent, QString caption, QString text,
62  int button0, int button1 = NoButton,
63  int button2 = NoButton);
64 
65  /** Displays a warning message box with the given caption, message text, and
66  * visible buttons. To specify as a default button or an escape
67  * button, OR the Button enum value with QMessageBox::Default or
68  * QMessageBox::Escape, respectively. */
69  static int warning(QWidget *parent, QString caption, QString text,
70  int button0, int button1 = NoButton,
71  int button2 = NoButton);
72 
73  /** Displays a warning message box with the given caption, message text, and
74  * visible buttons. To specify as a default button or an escape
75  * button, OR the Button enum value with QMessageBox::Default or
76  * QMessageBox::Escape, respectively. */
77  static int question(QWidget *parent, QString caption, QString text,
78  int button0, int button1 = NoButton,
79  int button2 = NoButton,
80  QString remember = QString(), VSettings *settings = 0,
81  QString key = QString());
82 
83  /** Converts a Button enum value to a translated string. */
84  static QString buttonText(int button);
85 
86 private:
87  /** Returns the button (0, 1, or 2) that is OR-ed with QMessageBox::Default,
88  * or 0 if none are. */
89  static int defaultButton(int button0, int button1, int button2);
90  /** Returns the button (0, 1, or 2) that is OR-ed with QMessageBox::Escape,
91  * or -1 if none are. */
92  static int escapeButton(int button0, int button1, int button2);
93  /** Returns the Button enum value from the given return value. */
94  static int selected(int ret, int button0, int button1, int button2);
95 
96  QCheckBox *_chkRemember;
97 };
98 
99 #endif
100 
static int selected(int ret, int button0, int button1, int button2)
Definition: VMessageBox.cpp:68
QCheckBox * _chkRemember
Definition: VMessageBox.h:96
static int information(QWidget *parent, QString caption, QString text, int button0, int button1=NoButton, int button2=NoButton)
static int critical(QWidget *parent, QString caption, QString text, int button0, int button1=NoButton, int button2=NoButton)
VMessageBox(QWidget *parent=0)
Definition: VMessageBox.cpp:26
static int escapeButton(int button0, int button1, int button2)
Definition: VMessageBox.cpp:53
static int warning(QWidget *parent, QString caption, QString text, int button0, int button1=NoButton, int button2=NoButton)
static int question(QWidget *parent, QString caption, QString text, int button0, int button1=NoButton, int button2=NoButton, QString remember=QString(), VSettings *settings=0, QString key=QString())
static QString buttonText(int button)
Definition: VMessageBox.cpp:80
static int defaultButton(int button0, int button1, int button2)
Definition: VMessageBox.cpp:38