00001 /* 00002 ** This file is part of Vidalia, and is subject to the license terms in the 00003 ** LICENSE file, found in the top level directory of this distribution. If you 00004 ** did not receive the LICENSE file with this file, you may obtain it from the 00005 ** Vidalia source package distributed by the Vidalia Project at 00006 ** http://www.vidalia-project.net/. No part of Vidalia, including this file, 00007 ** may be copied, modified, propagated, or distributed except according to the 00008 ** terms described in the LICENSE file. 00009 */ 00010 00011 /* 00012 ** \file VMessageBox.h 00013 ** \version $Id: VMessageBox.h 3735 2009-04-28 20:28:01Z edmanm $ 00014 ** \brief Provides a custom Vidalia mesage box 00015 */ 00016 00017 #ifndef _VMESSAGEBOX_H 00018 #define _VMESSAGEBOX_H 00019 00020 #include <QMessageBox> 00021 #include <QString> 00022 00023 00024 class VMessageBox : public QMessageBox 00025 { 00026 Q_OBJECT 00027 00028 public: 00029 enum Button { 00030 NoButton = 0, 00031 Ok, 00032 Cancel, 00033 Yes, 00034 No, 00035 Help, 00036 Retry, 00037 ShowLog, 00038 ShowSettings, 00039 Continue, 00040 Quit, 00041 Browse 00042 }; 00043 00044 /** Default constructor. */ 00045 VMessageBox(QWidget *parent = 0); 00046 00047 /** Displays an critical message box with the given caption, message text, 00048 * and visible buttons. To specify a button as a default button or an escape 00049 * button, OR the Button enum value with QMessageBox::Default or 00050 * QMessageBox::Escape, respectively. */ 00051 static int critical(QWidget *parent, QString caption, QString text, 00052 int button0, int button1 = NoButton, 00053 int button2 = NoButton); 00054 00055 /** Displays an information message box with the given caption, message text, 00056 * and visible buttons. To specify a button as a default button or an escape 00057 * button, OR the Button enum value with QMessageBox::Default or 00058 * QMessageBox::Escape, respectively. */ 00059 static int information(QWidget *parent, QString caption, QString text, 00060 int button0, int button1 = NoButton, 00061 int button2 = NoButton); 00062 00063 /** Displays a warning message box with the given caption, message text, and 00064 * visible buttons. To specify as a default button or an escape 00065 * button, OR the Button enum value with QMessageBox::Default or 00066 * QMessageBox::Escape, respectively. */ 00067 static int warning(QWidget *parent, QString caption, QString text, 00068 int button0, int button1 = NoButton, 00069 int button2 = NoButton); 00070 00071 /** Displays a warning message box with the given caption, message text, and 00072 * visible buttons. To specify as a default button or an escape 00073 * button, OR the Button enum value with QMessageBox::Default or 00074 * QMessageBox::Escape, respectively. */ 00075 static int question(QWidget *parent, QString caption, QString text, 00076 int button0, int button1 = NoButton, 00077 int button2 = NoButton); 00078 00079 /** Converts a Button enum value to a translated string. */ 00080 static QString buttonText(int button); 00081 00082 private: 00083 /** Returns the button (0, 1, or 2) that is OR-ed with QMessageBox::Default, 00084 * or 0 if none are. */ 00085 static int defaultButton(int button0, int button1, int button2); 00086 /** Returns the button (0, 1, or 2) that is OR-ed with QMessageBox::Escape, 00087 * or -1 if none are. */ 00088 static int escapeButton(int button0, int button1, int button2); 00089 /** Returns the Button enum value from the given return value. */ 00090 static int selected(int ret, int button0, int button1, int button2); 00091 }; 00092 00093 #endif 00094