libyui-qt  2.43.5
/usr/src/RPM/BUILD/libyui-qt-2.43.5/src/YQGenericButton.h
00001 /*
00002   Copyright (C) 2000-2012 Novell, Inc
00003   This library is free software; you can redistribute it and/or modify
00004   it under the terms of the GNU Lesser General Public License as
00005   published by the Free Software Foundation; either version 2.1 of the
00006   License, or (at your option) version 3.0 of the License. This library
00007   is distributed in the hope that it will be useful, but WITHOUT ANY
00008   WARRANTY; without even the implied warranty of MERCHANTABILITY or
00009   FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00010   License for more details. You should have received a copy of the GNU
00011   Lesser General Public License along with this library; if not, write
00012   to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
00013   Floor, Boston, MA 02110-1301 USA
00014 */
00015 
00016 
00017 /*-/
00018 
00019   File:       YQGenericButton.h
00020 
00021   Author:     Stefan Hundhammer <sh@suse.de>
00022 
00023 /-*/
00024 
00025 
00026 #ifndef YQGenericButton_h
00027 #define YQGenericButton_h
00028 
00029 #include <qwidget.h>
00030 
00031 #include <yui/YPushButton.h>
00032 
00033 
00034 class QPushButton;
00035 class QObject;
00036 class YQDialog;
00037 
00038 using std::string;
00039 
00040 /**
00041  * Abstract base class for push button and similar widgets -
00042  * all that can become a YQDialog's "default button".
00043  **/
00044 class YQGenericButton : public QWidget, public YPushButton
00045 {
00046     friend class YQDialog;
00047 
00048     Q_OBJECT
00049 
00050 protected:
00051 
00052     /**
00053      * Constructor.
00054      **/
00055     YQGenericButton( YWidget *          parent,
00056                      const std::string &        label );
00057 
00058 public:
00059 
00060     /**
00061      * Destructor.
00062      **/
00063     virtual ~YQGenericButton();
00064 
00065     /**
00066      * Set enabled/disabled state.
00067      *
00068      * Reimplemented from YWidget.
00069      **/
00070     virtual void setEnabled( bool enabled );
00071 
00072     /**
00073      * Returns 'true' if this button is enabled, 'false' otherwise.
00074      **/
00075     bool isEnabled() const;
00076 
00077     /**
00078      * Changes the label (the text) of the button.
00079      **/
00080     void setLabel( const QString & label );
00081 
00082     /**
00083      * Changes the label (the text) of the button.
00084      *
00085      * Reimplemented from YWidget.
00086      **/
00087     virtual void setLabel( const std::string & label );
00088 
00089     /**
00090      * Show this button as the dialog's default button. The button never calls
00091      * this by itself - the parent dialog is responsible for that.
00092      **/
00093     void showAsDefault( bool show = true );
00094 
00095     /**
00096      * Returns 'true' if this button is shown as a default button - which may
00097      * mean that this really is the dialogs's default button or it is the
00098      * dialog's focus button (a button that currently has the keyboard focus).
00099      *
00100      * Don't confuse this with YPushButton::isDefaultButton()!
00101      **/
00102     bool isShownAsDefault() const;
00103 
00104     /**
00105      * Accept the keyboard focus.
00106      **/
00107     virtual bool setKeyboardFocus();
00108 
00109     /**
00110      * Set this button's icon.
00111      *
00112      * Reimplemented from YPushButton.
00113      **/
00114     virtual void setIcon( const std::string & iconName );
00115 
00116     /**
00117      * Returns the button's text (label) - useful for log messages etc.
00118      **/
00119     QString text() const;
00120 
00121     /**
00122      * Returns the internal Qt PushButton.
00123      **/
00124     QPushButton * qPushButton() const { return _qPushButton; }
00125 
00126     /**
00127      * Returns the internal parent dialog.
00128      **/
00129     YQDialog * yQDialog() const { return _dialog; }
00130 
00131 
00132 public slots:
00133 
00134     /**
00135      * Activate (animated) this button.
00136      **/
00137     void activate();
00138 
00139 
00140 protected:
00141 
00142     /**
00143      * Set the corresponding QPushButton.
00144      **/
00145     void setQPushButton( QPushButton * pb );
00146 
00147     /**
00148      * Redirect events from the _qPushButton member to this object.
00149      *
00150      * Overwritten from QObject.
00151      **/
00152     bool eventFilter( QObject * obj, QEvent * event );
00153 
00154     /**
00155      * Returns the corresponding YQDialog.
00156      * Throws an exception if there is none.
00157      **/
00158     YQDialog * dialog();
00159 
00160     void forgetDialog();
00161 
00162 private:
00163 
00164     YQDialog *          _dialog;
00165     QPushButton *       _qPushButton;
00166 };
00167 
00168 #endif // YQGenericButton_h
 All Classes Functions Variables