vmessagebox.h

Go to the documentation of this file.
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 1238 2006-09-25 17:50:57Z 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   };
00051   
00052   /** Default constructor. */
00053   VMessageBox(QWidget *parent = 0);
00054 
00055   /** Displays an critical 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 critical(QWidget *parent, QString caption, QString text,
00060                         int button0, int button1 = NoButton, 
00061                         int button2 = NoButton);
00062   
00063   /** Displays an information message box with the given caption, message text,
00064    * and visible buttons. To specify a button 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 information(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 warning(QWidget *parent, QString caption, QString text,
00076                         int button0, int button1 = NoButton, 
00077                         int button2 = NoButton);
00078 
00079   /** Displays a warning message box with the given caption, message text, and
00080    * visible buttons. To specify as a default button or an escape
00081    * button, OR the Button enum value with QMessageBox::Default or
00082    * QMessageBox::Escape, respectively. */
00083   static int question(QWidget *parent, QString caption, QString text,
00084                          int button0, int button1 = NoButton, 
00085                          int button2 = NoButton);
00086   
00087   /** Converts a Button enum value to a translated string. */
00088   static QString buttonText(int button);
00089   
00090 private:
00091   /** Returns the button (0, 1, or 2) that is OR-ed with QMessageBox::Default,
00092    * or 0 if none are. */
00093   static int defaultButton(int button0, int button1, int button2);
00094   /** Returns the button (0, 1, or 2) that is OR-ed with QMessageBox::Escape,
00095    * or -1 if none are. */
00096   static int escapeButton(int button0, int button1, int button2);
00097   /** Returns the Button enum value from the given return value. */
00098   static int selected(int ret, int button0, int button1, int button2);
00099 };
00100 
00101 #endif
00102 

Generated on Mon Oct 23 20:08:16 2006 for Vidalia by  doxygen 1.5.0