00001 /**************************************************************** 00002 * Vidalia is distributed under the following license: 00003 * 00004 * Copyright (C) 2006, Matt Edman, Justin Hipple 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 ****************************************************************/ 00021 00022 /** 00023 * \file vmessagebox.h 00024 * \version $Id: vmessagebox.h 1839 2007-08-21 04:33:14Z edmanm $ 00025 * \brief Provides a custom Vidalia mesage box 00026 */ 00027 00028 #ifndef _VMESSAGEBOX_H 00029 #define _VMESSAGEBOX_H 00030 00031 #include <QMessageBox> 00032 #include <QString> 00033 00034 00035 class VMessageBox : public QMessageBox 00036 { 00037 Q_OBJECT 00038 00039 public: 00040 enum Button { 00041 NoButton = 0, 00042 Ok, 00043 Cancel, 00044 Yes, 00045 No, 00046 Help, 00047 Retry, 00048 ShowLog, 00049 ShowSettings, 00050 Continue, 00051 Quit, 00052 Browse 00053 }; 00054 00055 /** Default constructor. */ 00056 VMessageBox(QWidget *parent = 0); 00057 00058 /** Displays an critical message box with the given caption, message text, 00059 * and visible buttons. To specify a button as a default button or an escape 00060 * button, OR the Button enum value with QMessageBox::Default or 00061 * QMessageBox::Escape, respectively. */ 00062 static int critical(QWidget *parent, QString caption, QString text, 00063 int button0, int button1 = NoButton, 00064 int button2 = NoButton); 00065 00066 /** Displays an information message box with the given caption, message text, 00067 * and visible buttons. To specify a button as a default button or an escape 00068 * button, OR the Button enum value with QMessageBox::Default or 00069 * QMessageBox::Escape, respectively. */ 00070 static int information(QWidget *parent, QString caption, QString text, 00071 int button0, int button1 = NoButton, 00072 int button2 = NoButton); 00073 00074 /** Displays a warning message box with the given caption, message text, and 00075 * visible buttons. To specify as a default button or an escape 00076 * button, OR the Button enum value with QMessageBox::Default or 00077 * QMessageBox::Escape, respectively. */ 00078 static int warning(QWidget *parent, QString caption, QString text, 00079 int button0, int button1 = NoButton, 00080 int button2 = NoButton); 00081 00082 /** Displays a warning message box with the given caption, message text, and 00083 * visible buttons. To specify as a default button or an escape 00084 * button, OR the Button enum value with QMessageBox::Default or 00085 * QMessageBox::Escape, respectively. */ 00086 static int question(QWidget *parent, QString caption, QString text, 00087 int button0, int button1 = NoButton, 00088 int button2 = NoButton); 00089 00090 /** Converts a Button enum value to a translated string. */ 00091 static QString buttonText(int button); 00092 00093 private: 00094 /** Returns the button (0, 1, or 2) that is OR-ed with QMessageBox::Default, 00095 * or 0 if none are. */ 00096 static int defaultButton(int button0, int button1, int button2); 00097 /** Returns the button (0, 1, or 2) that is OR-ed with QMessageBox::Escape, 00098 * or -1 if none are. */ 00099 static int escapeButton(int button0, int button1, int button2); 00100 /** Returns the Button enum value from the given return value. */ 00101 static int selected(int ret, int button0, int button1, int button2); 00102 }; 00103 00104 #endif 00105