Vidalia  0.2.17
VMessageBox.h
Go to the documentation of this file.
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.torproject.org/projects/vidalia.html. No part of Vidalia, 
00007 **  including this file, may be copied, modified, propagated, or distributed 
00008 **  except according to the terms described in the LICENSE file.
00009 */
00010 
00011 /*
00012 ** \file VMessageBox.h
00013 ** \brief Provides a custom Vidalia mesage box
00014 */
00015 
00016 #ifndef _VMESSAGEBOX_H
00017 #define _VMESSAGEBOX_H
00018 
00019 #include <QMessageBox>
00020 #include <QString>
00021 
00022 
00023 class VMessageBox : public QMessageBox
00024 {
00025   Q_OBJECT
00026 
00027 public:
00028   enum Button {
00029     NoButton = 0,
00030     Ok,
00031     Cancel,
00032     Yes,
00033     No,
00034     Help,
00035     Retry,
00036     ShowLog,
00037     ShowSettings,
00038     Continue,
00039     Quit,
00040     Browse
00041   };
00042   
00043   /** Default constructor. */
00044   VMessageBox(QWidget *parent = 0);
00045 
00046   /** Displays an critical message box with the given caption, message text,
00047    * and visible buttons. To specify a button as a default button or an escape
00048    * button, OR the Button enum value with QMessageBox::Default or
00049    * QMessageBox::Escape, respectively. */
00050   static int critical(QWidget *parent, QString caption, QString text,
00051                         int button0, int button1 = NoButton, 
00052                         int button2 = NoButton);
00053   
00054   /** Displays an information message box with the given caption, message text,
00055    * and visible buttons. To specify a button as a default button or an escape
00056    * button, OR the Button enum value with QMessageBox::Default or
00057    * QMessageBox::Escape, respectively. */
00058   static int information(QWidget *parent, QString caption, QString text,
00059                             int button0, int button1 = NoButton, 
00060                             int button2 = NoButton);
00061 
00062   /** Displays a warning message box with the given caption, message text, and
00063    * visible buttons. To specify as a default button or an escape
00064    * button, OR the Button enum value with QMessageBox::Default or
00065    * QMessageBox::Escape, respectively. */
00066   static int warning(QWidget *parent, QString caption, QString text,
00067                         int button0, int button1 = NoButton, 
00068                         int button2 = NoButton);
00069 
00070   /** Displays a warning message box with the given caption, message text, and
00071    * visible buttons. To specify as a default button or an escape
00072    * button, OR the Button enum value with QMessageBox::Default or
00073    * QMessageBox::Escape, respectively. */
00074   static int question(QWidget *parent, QString caption, QString text,
00075                          int button0, int button1 = NoButton, 
00076                          int button2 = NoButton);
00077   
00078   /** Converts a Button enum value to a translated string. */
00079   static QString buttonText(int button);
00080   
00081 private:
00082   /** Returns the button (0, 1, or 2) that is OR-ed with QMessageBox::Default,
00083    * or 0 if none are. */
00084   static int defaultButton(int button0, int button1, int button2);
00085   /** Returns the button (0, 1, or 2) that is OR-ed with QMessageBox::Escape,
00086    * or -1 if none are. */
00087   static int escapeButton(int button0, int button1, int button2);
00088   /** Returns the Button enum value from the given return value. */
00089   static int selected(int ret, int button0, int button1, int button2);
00090 };
00091 
00092 #endif
00093